- boolean checkPriorityStatus = StringUtils.equals(String.valueOf(sysRoleList.getPriority()),
- String.valueOf(updateExtRole.getPriority()));
- ExternalAccessRole updateRole = new ExternalAccessRole();
- if (!isActiveValueChanged || !checkPriorityStatus || sysRoleList.getId().equals(IS_NULL_STRING)
- || !sysRoleList.getId().equals(String.valueOf(epRoleList.get(0).getId()))) {
- String updateDesc = "";
- List<EPRole> getRole;
- final Map<String, String> getAppRoleByName = new HashMap<>();
- getAppRoleByName.put(APP_ROLE_NAME_PARAM, updateExtRole.getName());
- if (app.getId().equals(PortalConstants.PORTAL_APP_ID)) {
- getRole = dataAccessService.executeNamedQuery(GET_PORTAL_APP_ROLES_QUERY, getAppRoleByName,
- null);
- } else {
- getAppRoleByName.put("appId", String.valueOf(app.getId()));
- getRole = dataAccessService.executeNamedQuery(GET_ROLE_TO_UPDATE_IN_EXTERNAL_AUTH_SYSTEM,
- getAppRoleByName, null);
- }
- Map<String, String> extSystemUpdateRoleJsonMapper = new LinkedHashMap<>();
- extSystemUpdateRoleJsonMapper.put(ID, String.valueOf(getRole.get(0).getId()));
- extSystemUpdateRoleJsonMapper.put(ROLE_NAME, String.valueOf(updateExtRole.getName()));
- extSystemUpdateRoleJsonMapper.put(ACTIVE, String.valueOf(updateExtRole.getActive()));
- extSystemUpdateRoleJsonMapper.put(PRIORITY, String.valueOf(updateExtRole.getPriority()));
- if (app.getId().equals(PortalConstants.PORTAL_APP_ID)) {
- extSystemUpdateRoleJsonMapper.put(APP_ID, "null");
- extSystemUpdateRoleJsonMapper.put(APP_ROLE_ID, "null");
- } else {
- extSystemUpdateRoleJsonMapper.put(APP_ID, String.valueOf(app.getId()));
- extSystemUpdateRoleJsonMapper.put(APP_ROLE_ID,
- String.valueOf(getRole.get(0).getAppRoleId()));
-
- }
- updateDesc = mapper.writeValueAsString(extSystemUpdateRoleJsonMapper);
- updateRole.setName(app.getNameSpace() + "." + updateExtRole.getName().replaceAll(
- EcompPortalUtils.EXTERNAL_CENTRAL_AUTH_ROLE_HANDLE_SPECIAL_CHARACTERS, "_"));
- updateRole.setDescription(updateDesc);
- String updateRoleDesc = mapper.writeValueAsString(updateRole);
- HttpEntity<String> entity = new HttpEntity<>(updateRoleDesc, headers);
- logger.debug(EELFLoggerDelegate.debugLogger, "updateRoleInExternalSystem: {} for PUT: {}",
- CONNECTING_TO_EXTERNAL_AUTH_SYSTEM_LOG_MESSAGE, updateRoleDesc);
- ResponseEntity<String> updatePermsResponse = template.exchange(
- SystemProperties.getProperty(EPCommonSystemProperties.EXTERNAL_CENTRAL_ACCESS_URL)
- + "role",
- HttpMethod.PUT, entity, String.class);
- logger.debug(EELFLoggerDelegate.debugLogger,
- "updateRoleInExternalSystem: Finished updating in External Auth system {} and status code: {} ",
- updateRoleDesc, updatePermsResponse.getStatusCode().value());