use of eu.bcvsolutions.idm.ic.api.IcConnectorKey in project CzechIdMng by bcvsolutions.
the class AbstractProvisioningExecutor method prepareProvisioning.
private SysProvisioningOperationDto prepareProvisioning(SysSystemEntityDto systemEntity, DTO dto, UUID entityId, ProvisioningOperationType operationType, List<? extends AttributeMapping> attributes) {
Assert.notNull(systemEntity);
Assert.notNull(systemEntity.getUid());
Assert.notNull(systemEntity.getEntityType());
SysSystemDto system = DtoUtils.getEmbedded(systemEntity, SysSystemEntity_.system, SysSystemDto.class);
Assert.notNull(system);
// If are input attributes null, then we load default mapped attributes
if (attributes == null) {
attributes = findAttributeMappings(system, systemEntity.getEntityType());
}
if (attributes == null || attributes.isEmpty()) {
return null;
}
// Find connector identification persisted in system
IcConnectorKey connectorKey = system.getConnectorKey();
if (connectorKey == null) {
throw new ProvisioningException(AccResultCode.CONNECTOR_KEY_FOR_SYSTEM_NOT_FOUND, ImmutableMap.of("system", system.getName()));
}
// Find connector configuration persisted in system
IcConnectorConfiguration connectorConfig = systemService.getConnectorConfiguration(system);
if (connectorConfig == null) {
throw new ProvisioningException(AccResultCode.CONNECTOR_CONFIGURATION_FOR_SYSTEM_NOT_FOUND, ImmutableMap.of("system", system.getName()));
}
// One IDM object can be mapped to one connector object (= one connector
// class).
SysSystemMappingDto mapping = getMapping(system, systemEntity.getEntityType());
if (mapping == null) {
// TODO: delete operation?
return null;
}
//
Map<ProvisioningAttributeDto, Object> accountAttributes = prepareMappedAttributesValues(dto, operationType, systemEntity, attributes);
// public provisioning event
SysSchemaObjectClassDto schemaObjectClassDto = schemaObjectClassService.get(mapping.getObjectClass());
IcConnectorObject connectorObject = new IcConnectorObjectImpl(systemEntity.getUid(), new IcObjectClassImpl(schemaObjectClassDto.getObjectClassName()), null);
SysProvisioningOperationDto.Builder operationBuilder = new SysProvisioningOperationDto.Builder().setOperationType(operationType).setSystemEntity(systemEntity).setEntityIdentifier(entityId).setProvisioningContext(new ProvisioningContext(accountAttributes, connectorObject));
//
return operationBuilder.build();
}
use of eu.bcvsolutions.idm.ic.api.IcConnectorKey in project CzechIdMng by bcvsolutions.
the class AbstractSynchronizationExecutor method validate.
/**
* Validate synchronization on: Exist, enable, running, has mapping, has
* connector key, has connector configuration
*
* @param synchronizationConfigId
* @return
*/
protected SynchronizationContext validate(UUID synchronizationConfigId) {
SynchronizationContext context = new SynchronizationContext();
AbstractSysSyncConfigDto config = synchronizationConfigService.get(synchronizationConfigId);
//
if (config == null) {
throw new ProvisioningException(AccResultCode.SYNCHRONIZATION_NOT_FOUND, ImmutableMap.of("id", synchronizationConfigId));
}
// Synchronization must be enabled
if (!config.isEnabled()) {
throw new ProvisioningException(AccResultCode.SYNCHRONIZATION_IS_NOT_ENABLED, ImmutableMap.of("name", config.getName()));
}
// Synchronization can not be running twice
SysSyncLogFilter logFilter = new SysSyncLogFilter();
logFilter.setSynchronizationConfigId(config.getId());
logFilter.setRunning(Boolean.TRUE);
if (!synchronizationLogService.find(logFilter, null).getContent().isEmpty()) {
throw new ProvisioningException(AccResultCode.SYNCHRONIZATION_IS_RUNNING, ImmutableMap.of("name", config.getName()));
}
SysSystemMappingDto mapping = systemMappingService.get(config.getSystemMapping());
Assert.notNull(mapping);
SysSchemaObjectClassDto schemaObjectClassDto = schemaObjectClassService.get(mapping.getObjectClass());
SysSystemDto system = DtoUtils.getEmbedded(schemaObjectClassDto, SysSchemaObjectClass_.system, SysSystemDto.class);
Assert.notNull(system);
// System must be enabled
if (system.isDisabled()) {
throw new ProvisioningException(AccResultCode.SYNCHRONIZATION_SYSTEM_IS_NOT_ENABLED, ImmutableMap.of("name", config.getName(), "system", system.getName()));
}
SystemEntityType entityType = mapping.getEntityType();
SysSystemAttributeMappingFilter attributeHandlingFilter = new SysSystemAttributeMappingFilter();
attributeHandlingFilter.setSystemMappingId(mapping.getId());
List<SysSystemAttributeMappingDto> mappedAttributes = systemAttributeMappingService.find(attributeHandlingFilter, null).getContent();
// Find connector identification persisted in system
IcConnectorKey connectorKey = system.getConnectorKey();
if (connectorKey == null) {
throw new ProvisioningException(AccResultCode.CONNECTOR_KEY_FOR_SYSTEM_NOT_FOUND, ImmutableMap.of("system", system.getName()));
}
// Find connector configuration persisted in system
IcConnectorConfiguration connectorConfig = systemService.getConnectorConfiguration(system);
if (connectorConfig == null) {
throw new ProvisioningException(AccResultCode.CONNECTOR_CONFIGURATION_FOR_SYSTEM_NOT_FOUND, ImmutableMap.of("system", system.getName()));
}
context.addConfig(config).addSystem(system).addEntityType(entityType).addMappedAttributes(mappedAttributes).addConnectorConfig(connectorConfig);
return context;
}
use of eu.bcvsolutions.idm.ic.api.IcConnectorKey in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemService method generateSchema.
@Override
@Transactional
public List<SysSchemaObjectClassDto> generateSchema(SysSystemDto system) {
Assert.notNull(system);
Assert.notNull(system.getId());
// Find connector identification persisted in system
IcConnectorKey connectorKey = system.getConnectorKey();
if (connectorKey == null) {
throw new ResultCodeException(AccResultCode.CONNECTOR_KEY_FOR_SYSTEM_NOT_FOUND, ImmutableMap.of("system", system.getName()));
}
// Find connector configuration persisted in system
IcConnectorConfiguration connectorConfig = getConnectorConfiguration(system);
if (connectorConfig == null) {
throw new ResultCodeException(AccResultCode.CONNECTOR_CONFIGURATION_FOR_SYSTEM_NOT_FOUND, ImmutableMap.of("system", system.getName()));
}
// Call IC module and find schema for given connector key and
// configuration
IcSchema icSchema = icConfigurationFacade.getSchema(system.getConnectorInstance(), connectorConfig);
if (icSchema == null) {
throw new ResultCodeException(AccResultCode.CONNECTOR_SCHEMA_FOR_SYSTEM_NOT_FOUND, ImmutableMap.of("system", system.getName()));
}
// Load existing object class from system
SysSchemaObjectClassFilter objectClassFilter = new SysSchemaObjectClassFilter();
objectClassFilter.setSystemId(system.getId());
List<SysSchemaObjectClassDto> sysObjectClassesInSystem = null;
Page<SysSchemaObjectClassDto> page = objectClassService.find(objectClassFilter, null);
sysObjectClassesInSystem = page.getContent();
// Convert IC schema to ACC entities
List<SysSchemaObjectClassDto> sysObjectClasses = new ArrayList<SysSchemaObjectClassDto>();
List<SysSchemaAttributeDto> sysAttributes = new ArrayList<SysSchemaAttributeDto>();
for (IcObjectClassInfo objectClass : icSchema.getDeclaredObjectClasses()) {
// __ACCOUNT__ and __GROUP__
if (!(objectClass.getType().startsWith("__") && objectClass.getType().endsWith("__"))) {
continue;
}
SysSchemaObjectClassDto sysObjectClass = null;
// values from resource
if (sysObjectClassesInSystem != null) {
Optional<SysSchemaObjectClassDto> objectClassSame = sysObjectClassesInSystem.stream().filter(objectClassInSystem -> {
//
return objectClassInSystem.getObjectClassName().equals(objectClass.getType());
}).findFirst();
if (objectClassSame.isPresent()) {
sysObjectClass = objectClassSame.get();
}
}
// Convert IC object class to ACC (if is null, then will be created
// new instance)
sysObjectClass = convertIcObjectClassInfo(objectClass, sysObjectClass);
sysObjectClass.setSystem(system.getId());
// object class may not exist
sysObjectClass = schemaObjectClassService.save(sysObjectClass);
sysObjectClasses.add(sysObjectClass);
List<SysSchemaAttributeDto> attributesInSystem = null;
// Load existing attributes for existing object class in system
if (sysObjectClass.getId() != null) {
SysSchemaAttributeFilter attFilter = new SysSchemaAttributeFilter();
attFilter.setSystemId(system.getId());
attFilter.setObjectClassId(sysObjectClass.getId());
Page<SysSchemaAttributeDto> attributesInSystemPage = attributeService.find(attFilter, null);
attributesInSystem = attributesInSystemPage.getContent();
}
for (IcAttributeInfo attribute : objectClass.getAttributeInfos()) {
// If will be IC and ACC attribute same (same name), then we
// will do only refresh object values from resource
SysSchemaAttributeDto sysAttribute = null;
if (attributesInSystem != null) {
Optional<SysSchemaAttributeDto> sysAttributeOptional = attributesInSystem.stream().filter(a -> {
return a.getName().equals(attribute.getName());
}).findFirst();
if (sysAttributeOptional.isPresent()) {
sysAttribute = sysAttributeOptional.get();
}
}
sysAttribute = convertIcAttributeInfo(attribute, sysAttribute);
sysAttribute.setObjectClass(sysObjectClass.getId());
sysAttributes.add(sysAttribute);
}
}
// Persist generated schema to system
sysObjectClasses = (List<SysSchemaObjectClassDto>) objectClassService.saveAll(sysObjectClasses);
attributeService.saveAll(sysAttributes);
return sysObjectClasses;
}
use of eu.bcvsolutions.idm.ic.api.IcConnectorKey in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemService method checkSystem.
@Override
@Transactional
public void checkSystem(SysSystemDto system) {
Assert.notNull(system);
// Find connector identification persisted in system
IcConnectorKey connectorKey = system.getConnectorKey();
if (connectorKey == null) {
throw new ResultCodeException(AccResultCode.CONNECTOR_KEY_FOR_SYSTEM_NOT_FOUND, ImmutableMap.of("system", system.getName()));
}
// Find connector configuration persisted in system
IcConnectorConfiguration connectorConfig = getConnectorConfiguration(system);
if (connectorConfig == null) {
throw new ResultCodeException(AccResultCode.CONNECTOR_CONFIGURATION_FOR_SYSTEM_NOT_FOUND, ImmutableMap.of("system", system.getName()));
}
// Call IC module
icConfigurationFacade.test(system.getConnectorInstance(), connectorConfig);
}
use of eu.bcvsolutions.idm.ic.api.IcConnectorKey in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemServiceTest method testCreateConnectorConfiguration.
@Test
public void testCreateConnectorConfiguration() {
// TODO: test system will be moved here, after UI eav form implementation
@SuppressWarnings("deprecation") IcConnectorKey connectorKey = systemService.getTestConnectorKey();
// create connector instance impl with connector key
IcConnectorInstance connectorInstance = new IcConnectorInstanceImpl(null, connectorKey, false);
IcConnectorConfiguration conf = icConfigurationAggregatorService.getConnectorConfiguration(connectorInstance);
IdmFormDefinitionDto savedFormDefinition = systemService.getConnectorFormDefinition(connectorInstance);
assertEquals(conf.getConfigurationProperties().getProperties().size(), savedFormDefinition.getFormAttributes().size());
assertEquals(conf.getConfigurationProperties().getProperties().get(3).getDisplayName(), savedFormDefinition.getFormAttributes().get(3).getName());
}
Aggregations