use of eu.bcvsolutions.idm.ic.impl.IcConnectorObjectImpl in project CzechIdMng by bcvsolutions.
the class ConnIdIcConvertUtil method convertConnIdConnectorObject.
public static IcConnectorObject convertConnIdConnectorObject(ConnectorObject connObject) {
if (connObject == null) {
return null;
}
IcObjectClass icClass = ConnIdIcConvertUtil.convertConnIdObjectClass(connObject.getObjectClass());
Set<Attribute> attributes = connObject.getAttributes();
List<IcAttribute> icAttributes = new ArrayList<>();
if (attributes != null) {
for (Attribute a : attributes) {
icAttributes.add(ConnIdIcConvertUtil.convertConnIdAttribute(a));
}
}
return new IcConnectorObjectImpl(connObject.getUid().getUidValue(), icClass, icAttributes);
}
use of eu.bcvsolutions.idm.ic.impl.IcConnectorObjectImpl in project CzechIdMng by bcvsolutions.
the class BasicVirtualConnector method createRequest.
/**
* Create new instance of request DTO. Method does not persist him.
*
* @param objectClass
* @param attributes
* @param uidString
* @param operationType
* @return
*/
private VsRequestDto createRequest(IcObjectClass objectClass, List<IcAttribute> attributes, String uidString, VsOperationType operationType) {
VsRequestDto request = new VsRequestDto();
request.setUid(uidString);
request.setState(VsRequestState.CONCEPT);
request.setSystem(this.systemId);
request.setConfiguration(this.configuration);
request.setConnectorKey(connectorKey);
request.setConnectorObject(new IcConnectorObjectImpl(uidString, objectClass, attributes));
request.setExecuteImmediately(!this.virtualConfiguration.isRequiredConfirmation());
request.setOperationType(operationType);
request.setImplementers(this.loadImplementers(this.virtualConfiguration.getImplementers()));
return request;
}
use of eu.bcvsolutions.idm.ic.impl.IcConnectorObjectImpl in project CzechIdMng by bcvsolutions.
the class DefaultVsRequestService method getVsConnectorObject.
@Override
public IcConnectorObject getVsConnectorObject(VsRequestDto request) {
LOG.info(MessageFormat.format("Start read vs connector object [{0}].", request));
Assert.notNull(request, "VS request cannot be null!");
Assert.notNull(request.getConnectorObject(), "Connector object in request cannot be null!");
// Find account by UID and System ID
VsAccountDto account = accountService.findByUidSystem(request.getUid(), request.getSystem());
if (account == null) {
return null;
}
BasicVirtualConfiguration configuration = getVirtualConnector(request).getVirtualConfiguration();
List<IcAttribute> attributes = accountService.getIcAttributes(account);
// result list
if (!configuration.isDisableSupported()) {
IcAttribute enableAttribute = attributes.stream().filter(attribute -> attribute.getName().equals(IcAttributeInfo.ENABLE)).findFirst().orElse(null);
if (enableAttribute != null) {
attributes.remove(enableAttribute);
}
}
IcConnectorObjectImpl connectorObject = new IcConnectorObjectImpl();
connectorObject.setUidValue(account.getUid());
connectorObject.setObjectClass(request.getConnectorObject().getObjectClass());
connectorObject.setAttributes(attributes);
return connectorObject;
}
use of eu.bcvsolutions.idm.ic.impl.IcConnectorObjectImpl in project CzechIdMng by bcvsolutions.
the class DefaultVsRequestService method getWishConnectorObject.
@Override
public VsConnectorObjectDto getWishConnectorObject(VsRequestDto request) {
LOG.info(MessageFormat.format("Start read wish connector object [{0}].", request));
Assert.notNull(request, "VS request cannot be null!");
List<VsAttributeDto> resultAttributes = new ArrayList<>();
IcConnectorObject realConnectorObject = this.getVsConnectorObject(request);
IcConnectorObject currentObject = realConnectorObject != null ? realConnectorObject : new IcConnectorObjectImpl();
IcConnectorObject changeObject = request.getConnectorObject() != null ? request.getConnectorObject() : new IcConnectorObjectImpl();
List<IcAttribute> currentAttributes = currentObject.getAttributes();
List<IcAttribute> changedAttributes = request.getConnectorObject().getAttributes();
// First add all new attributes
changedAttributes.forEach(changedAttribute -> {
if (currentObject.getAttributeByName(changedAttribute.getName()) == null) {
VsAttributeDto vsAttribute = new VsAttributeDto(changedAttribute.getName(), changedAttribute.isMultiValue(), true);
if (changedAttribute.isMultiValue()) {
if (changedAttribute.getValues() != null) {
changedAttribute.getValues().forEach(value -> {
vsAttribute.getValues().add(new VsAttributeValueDto(value, null, VsValueChangeType.ADDED));
});
}
} else {
vsAttribute.setValue(new VsAttributeValueDto(changedAttribute.getValue(), null, VsValueChangeType.ADDED));
}
resultAttributes.add(vsAttribute);
}
});
// Second add all already exists attributes
currentAttributes.forEach(currentAttribute -> {
VsAttributeDto vsAttribute;
// Attribute was changed
if (changeObject.getAttributeByName(currentAttribute.getName()) != null) {
vsAttribute = new VsAttributeDto(currentAttribute.getName(), currentAttribute.isMultiValue(), true);
IcAttribute changedAttribute = changeObject.getAttributeByName(currentAttribute.getName());
if (changedAttribute.isMultiValue()) {
if (changedAttribute.getValues() != null) {
changedAttribute.getValues().forEach(value -> {
if (currentAttribute.getValues() != null && currentAttribute.getValues().contains(value)) {
vsAttribute.getValues().add(new VsAttributeValueDto(value, value, null));
} else {
vsAttribute.getValues().add(new VsAttributeValueDto(value, null, VsValueChangeType.ADDED));
}
});
}
if (currentAttribute.getValues() != null) {
currentAttribute.getValues().forEach(value -> {
if (changedAttribute.getValues() == null || !changedAttribute.getValues().contains(value)) {
vsAttribute.getValues().add(new VsAttributeValueDto(value, value, VsValueChangeType.REMOVED));
}
});
}
} else {
Object changedValue = changedAttribute.getValue();
Object currentValue = currentAttribute.getValue();
if ((changedValue == null && currentValue == null) || (changedValue != null && changedValue.equals(currentObject)) || (currentValue != null && currentValue.equals(changedValue))) {
vsAttribute.setValue(new VsAttributeValueDto(changedValue, currentValue, null));
} else {
vsAttribute.setValue(new VsAttributeValueDto(changedValue, currentValue, VsValueChangeType.UPDATED));
}
}
} else {
// Attribute was not changed
vsAttribute = new VsAttributeDto(currentAttribute.getName(), currentAttribute.isMultiValue(), false);
if (currentAttribute.isMultiValue()) {
if (currentAttribute.getValues() != null) {
currentAttribute.getValues().forEach(value -> {
vsAttribute.getValues().add(new VsAttributeValueDto(value, value, null));
});
}
} else {
vsAttribute.setValue(new VsAttributeValueDto(currentAttribute.getValue(), currentAttribute.getValue(), null));
}
}
resultAttributes.add(vsAttribute);
});
BasicVirtualConfiguration configuration = getVirtualConnector(request).getVirtualConfiguration();
// result list
if (!configuration.isDisableSupported()) {
VsAttributeDto enableAttribute = resultAttributes.stream().filter(attribute -> attribute.getName().equals(IcAttributeInfo.ENABLE)).findFirst().orElse(null);
if (enableAttribute != null) {
resultAttributes.remove(enableAttribute);
}
}
VsConnectorObjectDto wishObject = new VsConnectorObjectDto();
wishObject.setUid(request.getUid());
wishObject.setAttributes(resultAttributes);
return wishObject;
}
use of eu.bcvsolutions.idm.ic.impl.IcConnectorObjectImpl in project CzechIdMng by bcvsolutions.
the class AbstractProvisioningExecutor method prepareProvisioningForAttribute.
private SysProvisioningOperationDto prepareProvisioningForAttribute(SysSystemEntityDto systemEntity, AttributeMapping attributeMapping, Object value, ProvisioningOperationType operationType, DTO dto) {
Assert.notNull(systemEntity);
Assert.notNull(systemEntity.getSystem());
Assert.notNull(systemEntity.getEntityType());
Assert.notNull(systemEntity.getUid());
Assert.notNull(attributeMapping);
SysSchemaAttributeDto schemaAttributeDto = getSchemaAttribute(attributeMapping);
if (!schemaAttributeDto.isUpdateable()) {
throw new ProvisioningException(AccResultCode.PROVISIONING_SCHEMA_ATTRIBUTE_IS_NOT_UPDATEABLE, ImmutableMap.of("property", attributeMapping.getIdmPropertyName(), "uid", systemEntity.getUid()));
}
SysSchemaObjectClassDto schemaObjectClassDto = schemaObjectClassService.get(schemaAttributeDto.getObjectClass());
String objectClassName = schemaObjectClassDto.getObjectClassName();
// We do transformation to system if is attribute only constant
Object valueTransformed = value;
if (!attributeMapping.isEntityAttribute() && !attributeMapping.isExtendedAttribute()) {
// If is attribute handling resolve as constant, then we don't want
// do transformation again (was did in getAttributeValue)
} else {
valueTransformed = attributeMappingService.transformValueToResource(systemEntity.getUid(), value, attributeMapping, dto);
}
IcAttribute icAttributeForCreate = attributeMappingService.createIcAttribute(schemaAttributeDto, valueTransformed);
//
// Call ic modul for update single attribute
IcConnectorObject connectorObject = new IcConnectorObjectImpl(systemEntity.getUid(), new IcObjectClassImpl(objectClassName), ImmutableList.of(icAttributeForCreate));
SysProvisioningOperationDto.Builder operationBuilder = new SysProvisioningOperationDto.Builder().setOperationType(ProvisioningEventType.UPDATE).setSystemEntity(systemEntity).setEntityIdentifier(dto == null ? null : dto.getId()).setProvisioningContext(new ProvisioningContext(connectorObject));
//
return operationBuilder.build();
}
Aggregations