Skip to content
This repository has been archived by the owner on Aug 4, 2023. It is now read-only.

Making hrms service compatible with central instance. #149

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -92,15 +93,23 @@ 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();
StringBuilder uri = new StringBuilder();
uri.append(propertiesManager.getUserHost()).append(propertiesManager.getUserSearchEndpoint()); // URL for user search call
Map<String, Object> 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<String, Object> responseMap = (LinkedHashMap<String, Object>) restCallRepository.fetchResult(uri, userSearchRequest);
List<LinkedHashMap<String, Object>> users = (List<LinkedHashMap<String, Object>>) responseMap.get("user");
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ------------------------------#
Expand Down