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) {
|
public void listenKafkaRole(String kafkaMessage) {
|
||||||
ervuDirectoriesService.upsertKafkaRoleMessage(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;
|
private String idmUrl;
|
||||||
@Value("${ervu.collection:domain, role}")
|
@Value("${ervu.collection:domain, role}")
|
||||||
private String ervuCollection;
|
private String ervuCollection;
|
||||||
|
@Value("${ervu.admin.role:gomu_supervisor, system_administrator, security_administrator}")
|
||||||
|
private String ervuAdminRole;
|
||||||
@Autowired
|
@Autowired
|
||||||
private RestTemplate restTemplate;
|
private RestTemplate restTemplate;
|
||||||
@Autowired
|
@Autowired
|
||||||
|
|
@ -58,7 +60,7 @@ public class ErvuDirectoriesService {
|
||||||
try {
|
try {
|
||||||
String[] ervuCollectionArray = ervuCollection.split(",");
|
String[] ervuCollectionArray = ervuCollection.split(",");
|
||||||
Arrays.stream(ervuCollectionArray).forEach(ervuCollection -> {
|
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();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||||
String emptyJson = "{}";
|
String emptyJson = "{}";
|
||||||
|
|
@ -163,6 +165,7 @@ public class ErvuDirectoriesService {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void upsertRoleData(List<RoleResponse.Data> dataList) {
|
private void upsertRoleData(List<RoleResponse.Data> dataList) {
|
||||||
|
String[] adminRoles = ervuAdminRole.split(",");
|
||||||
List<UserApplicationRoleRecord> newRoleRecords = new ArrayList<>();
|
List<UserApplicationRoleRecord> newRoleRecords = new ArrayList<>();
|
||||||
List<UserApplicationRoleRecord> roleRecords = new ArrayList<>();
|
List<UserApplicationRoleRecord> roleRecords = new ArrayList<>();
|
||||||
List<String> ids = ervuDirectoriesDaoService.getRoleIds();
|
List<String> ids = ervuDirectoriesDaoService.getRoleIds();
|
||||||
|
|
@ -183,6 +186,11 @@ public class ErvuDirectoriesService {
|
||||||
roleRecord.setCreated(createdAt);
|
roleRecord.setCreated(createdAt);
|
||||||
roleRecord.setUpdated(updatedAt);
|
roleRecord.setUpdated(updatedAt);
|
||||||
roleRecord.setFinished(finishAt);
|
roleRecord.setFinished(finishAt);
|
||||||
|
Arrays.stream(adminRoles).forEach(role -> {
|
||||||
|
if (role.trim().equals(data.getName())) {
|
||||||
|
roleRecord.setAdminRole(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
if (ids.contains(data.getId())) {
|
if (ids.contains(data.getId())) {
|
||||||
roleRecords.add(roleRecord);
|
roleRecords.add(roleRecord);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,29 +2,25 @@ package ru.micord.ervu.account_applications.service;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
|
|
||||||
import net.javacrumbs.shedlock.core.SchedulerLock;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import static org.springframework.scheduling.config.ScheduledTaskRegistrar.CRON_DISABLED;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Eduard Tihomirov
|
* @author Eduard Tihomirov
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class ErvuDirectoriesUpdateShedulerService {
|
public class ErvuDirectoriesUpdateService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ErvuDirectoriesService ervuDirectoriesService;
|
private ErvuDirectoriesService ervuDirectoriesService;
|
||||||
|
|
||||||
@Value("${directory.update.cron:0 0 */1 * * *}")
|
@Value("${load.directories:true}")
|
||||||
private String cronLoad;
|
private Boolean loadDirectories;
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void init() {
|
public void init() {
|
||||||
if (!cronLoad.equals(CRON_DISABLED)) {
|
if (loadDirectories) {
|
||||||
new Thread(this::runWithSleep).start();
|
new Thread(this::runWithSleep).start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -36,12 +32,6 @@ public class ErvuDirectoriesUpdateShedulerService {
|
||||||
catch (InterruptedException e) {
|
catch (InterruptedException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
run();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Scheduled(cron = "${directory.update.cron:0 0 */1 * * *}")
|
|
||||||
@SchedulerLock(name = "updateDirectories")
|
|
||||||
public void run() {
|
|
||||||
ervuDirectoriesService.updateDirectories();
|
ervuDirectoriesService.updateDirectories();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -20,6 +20,8 @@ KAFKA_USER=user1
|
||||||
KAFKA_PASS=Blfi9d2OFG
|
KAFKA_PASS=Blfi9d2OFG
|
||||||
KAFKA_CONSUMER_GROUP_ID=1
|
KAFKA_CONSUMER_GROUP_ID=1
|
||||||
KAFKA_DOMAIN_GROUP_ID=ervu-account-applications-backend-domain
|
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
|
KAFKA_ROLE_GROUP_ID=ervu-account-applications-backend-role
|
||||||
IDM_URL=http://idm
|
IDM_URL=http://idm
|
||||||
|
|
||||||
|
|
@ -28,4 +30,6 @@ ERVU_HTTP_TIMEOUT=30
|
||||||
ERVU_PWD_SIGN_SECRET_KEY=xoL2Y3VRdQ4phXG85o6dRqcgqb4bk6ULdkJJdlRLhZM=
|
ERVU_PWD_SIGN_SECRET_KEY=xoL2Y3VRdQ4phXG85o6dRqcgqb4bk6ULdkJJdlRLhZM=
|
||||||
KAFKA_ROLE_RECONCILIATION=idmv2.role.reconciliation
|
KAFKA_ROLE_RECONCILIATION=idmv2.role.reconciliation
|
||||||
KAFKA_DOMAIN_RECONCILIATION=idmv2.domain.reconciliation
|
KAFKA_DOMAIN_RECONCILIATION=idmv2.domain.reconciliation
|
||||||
|
KAFKA_DOMAIN_UPDATED=idmv2.domain.created
|
||||||
|
KAFKA_DOMAIN_CREATED=idmv2.domain.updated
|
||||||
ERVU_ROLE_ADMIN=security_administrator
|
ERVU_ROLE_ADMIN=security_administrator
|
||||||
Loading…
Add table
Add a link
Reference in a new issue