in ddm-bpm-extension/src/main/java/com/epam/digital/data/platform/bpms/extension/delegate/connector/keycloak/officer/KeycloakSaveOfficerUserAttributesDelegate.java [78:114]
protected void executeInternal(DelegateExecution execution) throws Exception {
var userName = usernameVariable.from(execution).getOrThrow();
var fullName = fullNameVariable.from(execution).get();
validateSystemAttribute(fullName, FULL_NAME_REGEX, ATTRIBUTE_FULL_NAME);
var edrpou = edrpouVariable.from(execution).get();
validateSystemAttribute(edrpou, EDRPOU_REGEX, ATTRIBUTE_EDRPOU);
var drfo = drfoVariable.from(execution).get();
validateSystemAttribute(drfo, DRFO_REGEX, ATTRIBUTE_DRFO);
var attributes = attributesVariable.from(execution).getOptional().orElse(Maps.newHashMap());
validateCustomAttributes(attributes);
var userRepresentation = idmService.getUserRepresentationByUserName(userName);
var currentAttr = userRepresentation.getAttributes();
var currentUserFullName = getValueFromCurrentAttribute(currentAttr, ATTRIBUTE_FULL_NAME);
var currentUserEdrpou = getValueFromCurrentAttribute(currentAttr, ATTRIBUTE_EDRPOU);
var currentUserDrfo = getValueFromCurrentAttribute(currentAttr, ATTRIBUTE_DRFO);
var fullNameForSearch = Objects.isNull(fullName) ? currentUserFullName : fullName;
var edrpouForSearch = Objects.isNull(edrpou) ? currentUserEdrpou : edrpou;
var drfoForSearch = Objects.isNull(drfo) ? currentUserDrfo : drfo;
var isSearchSystemAttributesEqualsCurrentUserSystemAttributes =
Objects.equals(fullNameForSearch, currentUserFullName) && Objects.equals(edrpouForSearch,
currentUserEdrpou) && Objects.equals(drfoForSearch, currentUserDrfo);
if (!isSearchSystemAttributesEqualsCurrentUserSystemAttributes) {
checkUserExistenceByAttributes(idmService, fullNameForSearch, edrpouForSearch, drfoForSearch);
}
addAttributeIfDefined(attributes, ATTRIBUTE_FULL_NAME, fullName);
addAttributeIfDefined(attributes, ATTRIBUTE_EDRPOU, edrpou);
addAttributeIfDefined(attributes, ATTRIBUTE_DRFO, drfo);
addUserDetailsIfFullNameDefined(fullName, userRepresentation);
var mappedAttributes = mapAttributeValuesToList(attributes);
addUserAttributes(mappedAttributes, userRepresentation);
idmService.updateUserRepresentation(userRepresentation);
}