SUPPORT-9115: Fix
This commit is contained in:
parent
b0b31e39aa
commit
1d97152772
4 changed files with 37 additions and 15 deletions
|
|
@ -23,4 +23,24 @@ public class ErvuDirectoriesListener {
|
|||
public void listenKafkaRole(String kafkaMessage) {
|
||||
ervuDirectoriesService.upsertKafkaRoleMessage(kafkaMessage);
|
||||
}
|
||||
// Пока не заведены, обещают в будущих апдейтах создать
|
||||
// @KafkaListener(id = "${kafka.role.updated.group.id}", topics = "${kafka.role.updated}")
|
||||
// public void listenKafkaRoleUpdated(String kafkaMessage) {
|
||||
// ervuDirectoriesService.upsertKafkaRoleMessage(kafkaMessage);
|
||||
// }
|
||||
|
||||
// @KafkaListener(id = "${kafka.role.created.group.id}", topics = "${kafka.role.created}")
|
||||
// public void listenKafkaRoleUpdated(String kafkaMessage) {
|
||||
// ervuDirectoriesService.upsertKafkaRoleMessage(kafkaMessage);
|
||||
// }
|
||||
|
||||
@KafkaListener(id = "${kafka.domain.updated.group.id}", topics = "${kafka.domain.updated}")
|
||||
public void listenKafkaDomainUpdated(String kafkaMessage) {
|
||||
ervuDirectoriesService.upsertKafkaDomainMessage(kafkaMessage);
|
||||
}
|
||||
|
||||
@KafkaListener(id = "${kafka.domain.created.group.id}", topics = "${kafka.domain.created}")
|
||||
public void listenKafkaDomainCreated(String kafkaMessage) {
|
||||
ervuDirectoriesService.upsertKafkaDomainMessage(kafkaMessage);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,6 +42,8 @@ public class ErvuDirectoriesService {
|
|||
private String idmUrl;
|
||||
@Value("${ervu.collection:domain, role}")
|
||||
private String ervuCollection;
|
||||
@Value("${ervu.admin.role:gomu_supervisor, system_administrator, security_administrator}")
|
||||
private String ervuAdminRole;
|
||||
@Autowired
|
||||
private RestTemplate restTemplate;
|
||||
@Autowired
|
||||
|
|
@ -58,7 +60,7 @@ public class ErvuDirectoriesService {
|
|||
try {
|
||||
String[] ervuCollectionArray = ervuCollection.split(",");
|
||||
Arrays.stream(ervuCollectionArray).forEach(ervuCollection -> {
|
||||
String targetUrl = idmUrl + "/reconcile/"+ ervuCollection + "/to/kafka/v1";
|
||||
String targetUrl = idmUrl + "/reconcile/"+ ervuCollection.trim() + "/to/kafka/v1";
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
String emptyJson = "{}";
|
||||
|
|
@ -163,6 +165,7 @@ public class ErvuDirectoriesService {
|
|||
}
|
||||
|
||||
private void upsertRoleData(List<RoleResponse.Data> dataList) {
|
||||
String[] adminRoles = ervuAdminRole.split(",");
|
||||
List<UserApplicationRoleRecord> newRoleRecords = new ArrayList<>();
|
||||
List<UserApplicationRoleRecord> roleRecords = new ArrayList<>();
|
||||
List<String> ids = ervuDirectoriesDaoService.getRoleIds();
|
||||
|
|
@ -183,6 +186,11 @@ public class ErvuDirectoriesService {
|
|||
roleRecord.setCreated(createdAt);
|
||||
roleRecord.setUpdated(updatedAt);
|
||||
roleRecord.setFinished(finishAt);
|
||||
Arrays.stream(adminRoles).forEach(role -> {
|
||||
if (role.trim().equals(data.getName())) {
|
||||
roleRecord.setAdminRole(true);
|
||||
}
|
||||
});
|
||||
if (ids.contains(data.getId())) {
|
||||
roleRecords.add(roleRecord);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,29 +2,25 @@ package ru.micord.ervu.account_applications.service;
|
|||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import net.javacrumbs.shedlock.core.SchedulerLock;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import static org.springframework.scheduling.config.ScheduledTaskRegistrar.CRON_DISABLED;
|
||||
|
||||
/**
|
||||
* @author Eduard Tihomirov
|
||||
*/
|
||||
@Service
|
||||
public class ErvuDirectoriesUpdateShedulerService {
|
||||
public class ErvuDirectoriesUpdateService {
|
||||
|
||||
@Autowired
|
||||
private ErvuDirectoriesService ervuDirectoriesService;
|
||||
|
||||
@Value("${directory.update.cron:0 0 */1 * * *}")
|
||||
private String cronLoad;
|
||||
@Value("${load.directories:true}")
|
||||
private Boolean loadDirectories;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
if (!cronLoad.equals(CRON_DISABLED)) {
|
||||
if (loadDirectories) {
|
||||
new Thread(this::runWithSleep).start();
|
||||
}
|
||||
}
|
||||
|
|
@ -36,12 +32,6 @@ public class ErvuDirectoriesUpdateShedulerService {
|
|||
catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
run();
|
||||
}
|
||||
|
||||
@Scheduled(cron = "${directory.update.cron:0 0 */1 * * *}")
|
||||
@SchedulerLock(name = "updateDirectories")
|
||||
public void run() {
|
||||
ervuDirectoriesService.updateDirectories();
|
||||
}
|
||||
}
|
||||
|
|
@ -20,6 +20,8 @@ KAFKA_USER=user1
|
|||
KAFKA_PASS=Blfi9d2OFG
|
||||
KAFKA_CONSUMER_GROUP_ID=1
|
||||
KAFKA_DOMAIN_GROUP_ID=ervu-account-applications-backend-domain
|
||||
KAFKA_DOMAIN_UPDATED_GROUP_ID=ervu-account-applications-backend-domain-updated
|
||||
KAFKA_DOMAIN_CREATED_GROUP_ID=ervu-account-applications-backend-domain-updated
|
||||
KAFKA_ROLE_GROUP_ID=ervu-account-applications-backend-role
|
||||
IDM_URL=http://idm
|
||||
|
||||
|
|
@ -28,4 +30,6 @@ ERVU_HTTP_TIMEOUT=30
|
|||
ERVU_PWD_SIGN_SECRET_KEY=xoL2Y3VRdQ4phXG85o6dRqcgqb4bk6ULdkJJdlRLhZM=
|
||||
KAFKA_ROLE_RECONCILIATION=idmv2.role.reconciliation
|
||||
KAFKA_DOMAIN_RECONCILIATION=idmv2.domain.reconciliation
|
||||
KAFKA_DOMAIN_UPDATED=idmv2.domain.created
|
||||
KAFKA_DOMAIN_CREATED=idmv2.domain.updated
|
||||
ERVU_ROLE_ADMIN=security_administrator
|
||||
Loading…
Add table
Add a link
Reference in a new issue