diff --git a/business-services/egov-hrms/src/main/java/org/egov/hrms/config/PropertiesManager.java b/business-services/egov-hrms/src/main/java/org/egov/hrms/config/PropertiesManager.java index d9263d4587b..ff486ebf359 100644 --- a/business-services/egov-hrms/src/main/java/org/egov/hrms/config/PropertiesManager.java +++ b/business-services/egov-hrms/src/main/java/org/egov/hrms/config/PropertiesManager.java @@ -111,9 +111,6 @@ public class PropertiesManager { @Value("${state.level.tenant.id}") public String stateLevelTenantId; - @Value("${parent.level.tenant.id}") - private String parentLevelTenantId; - @Value("${decryption.abac.enable}") private Boolean isDecryptionEnable; } \ No newline at end of file diff --git a/business-services/egov-hrms/src/main/java/org/egov/hrms/service/UserService.java b/business-services/egov-hrms/src/main/java/org/egov/hrms/service/UserService.java index 5f6fe6c20dd..a59e5f8bc52 100644 --- a/business-services/egov-hrms/src/main/java/org/egov/hrms/service/UserService.java +++ b/business-services/egov-hrms/src/main/java/org/egov/hrms/service/UserService.java @@ -54,6 +54,7 @@ import org.egov.hrms.web.contract.UserRequest; import org.egov.hrms.web.contract.UserResponse; import org.egov.tracer.model.CustomException; +import org.slf4j.MDC; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; @@ -92,6 +93,11 @@ public class UserService { private String internalMicroserviceRoleUuid = null; + @Autowired + private MultiStateInstanceUtil multiStateInstanceUtil; + + public static final String TENANTID_MDC_STRING = "TENANTID"; + @PostConstruct void initalizeSystemuser(){ RequestInfo requestInfo = new RequestInfo(); @@ -99,8 +105,11 @@ void initalizeSystemuser(){ uri.append(propertiesManager.getUserHost()).append(propertiesManager.getUserSearchEndpoint()); // URL for user search call Map userSearchRequest = new HashMap<>(); userSearchRequest.put("RequestInfo", requestInfo); - userSearchRequest.put("tenantId", propertiesManager.getParentLevelTenantId()); + userSearchRequest.put("tenantId", propertiesManager.getStateLevelTenantId()); userSearchRequest.put("roleCodes", Collections.singletonList(INTERNALMICROSERVICEROLE_CODE)); + if(multiStateInstanceUtil.getIsEnvironmentCentralInstance()){ + MDC.put(TENANTID_MDC_STRING, propertiesManager.getStateLevelTenantId()); + } try { LinkedHashMap responseMap = (LinkedHashMap) restCallRepository.fetchResult(uri, userSearchRequest); List> users = (List>) responseMap.get("user"); @@ -118,10 +127,10 @@ private void createInternalMicroserviceUser(RequestInfo requestInfo){ //Creating role with INTERNAL_MICROSERVICE_ROLE Role role = Role.builder() .name(INTERNALMICROSERVICEROLE_NAME).code(INTERNALMICROSERVICEROLE_CODE) - .tenantId(propertiesManager.getParentLevelTenantId()).build(); + .tenantId(propertiesManager.getStateLevelTenantId()).build(); User user = User.builder().userName(INTERNALMICROSERVICEUSER_USERNAME) .name(INTERNALMICROSERVICEUSER_NAME).mobileNumber(INTERNALMICROSERVICEUSER_MOBILENO) - .type(INTERNALMICROSERVICEUSER_TYPE).tenantId(propertiesManager.getParentLevelTenantId()) + .type(INTERNALMICROSERVICEUSER_TYPE).tenantId(propertiesManager.getStateLevelTenantId()) .roles(Collections.singletonList(role)).id(0L).build(); userCreateRequest.put("RequestInfo", requestInfo); diff --git a/business-services/egov-hrms/src/main/resources/application.properties b/business-services/egov-hrms/src/main/resources/application.properties index 11600397ad1..557f3edfc0b 100644 --- a/business-services/egov-hrms/src/main/resources/application.properties +++ b/business-services/egov-hrms/src/main/resources/application.properties @@ -68,7 +68,6 @@ egov.hrms.default.pagination.limit=200 egov.hrms.default.pwd.length=8 open.search.enabled.roles=SUPERUSER egov.pwd.allowed.special.characters=@#$% -parent.level.tenant.id=pb decryption.abac.enable=false #------------------------------ KAFKA CONFIGURATIONS ------------------------------#