Search in sources :

Example 11 with SysSchemaObjectClassFilter

use of eu.bcvsolutions.idm.acc.dto.filter.SysSchemaObjectClassFilter in project CzechIdMng by bcvsolutions.

the class DefaultSysSystemService method duplicate.

@Override
@Transactional
public SysSystemDto duplicate(UUID id) {
    SysSystemDto originalSystem = this.get(id);
    Asserts.notNull(originalSystem, "System must be found!");
    // Clone and save system
    SysSystemDto clone = this.clone(id);
    String name = MessageFormat.format("{0}{1}", "Copy-of-", clone.getName());
    name = this.duplicateName(name, 0);
    clone.setName(name);
    // Set as inactive system
    clone.setDisabled(true);
    SysSystemDto system = this.save(clone);
    // Cache old and new IDs
    Map<UUID, UUID> schemaAttributesCache = new HashMap<UUID, UUID>();
    Map<UUID, UUID> mappedAttributesCache = new HashMap<UUID, UUID>();
    // Duplicate connector configuration values in EAV
    IcConnectorInstance connectorInstance = getConnectorInstance(originalSystem);
    if (connectorInstance != null && connectorInstance.getConnectorKey() != null && connectorInstance.getConnectorKey().getFramework() != null) {
        IdmFormDefinitionDto formDefinition = getConnectorFormDefinition(connectorInstance);
        List<IdmFormValueDto> originalFormValues = this.getFormService().getValues(id, SysSystem.class, formDefinition);
        SysSystem systemEntity = getEntity(system.getId());
        originalFormValues.stream().forEach(value -> {
            systemFormValueService.duplicate(value.getId(), systemEntity);
        });
    }
    // Duplicate schema
    SysSchemaObjectClassFilter objectClassFilter = new SysSchemaObjectClassFilter();
    objectClassFilter.setSystemId(id);
    objectClassService.find(objectClassFilter, null).getContent().stream().forEach(schema -> {
        UUID originalSchemaId = schema.getId();
        SysSchemaObjectClassDto duplicatedSchema = this.duplicateSchema(originalSchemaId, system, schemaAttributesCache);
        // Duplicate mapped attributes
        SysSystemMappingFilter systemMappingFilter = new SysSystemMappingFilter();
        systemMappingFilter.setSystemId(id);
        systemMappingService.find(systemMappingFilter, null).getContent().stream().filter(mapping -> {
            // Find mapping for this schema
            return mapping.getObjectClass().equals(originalSchemaId);
        }).forEach(mapping -> {
            final UUID originalMappingId = mapping.getId();
            SysSystemMappingDto duplicatedMapping = systemMappingService.duplicateMapping(originalMappingId, duplicatedSchema, schemaAttributesCache, mappedAttributesCache, false);
            // Duplicate sync configs
            List<AbstractSysSyncConfigDto> syncConfigs = findSyncConfigs(id);
            syncConfigs.stream().filter(syncConfig -> {
                // Find configuration of sync for this mapping
                return syncConfig.getSystemMapping().equals(originalMappingId);
            }).forEach(syncConfig -> {
                UUID syncConfigId = syncConfig.getId();
                duplicateSyncConf(syncConfigId, duplicatedMapping, mappedAttributesCache);
            });
        });
    });
    return system;
}
Also used : SysConnectorKey_(eu.bcvsolutions.idm.acc.entity.SysConnectorKey_) SysSystem_(eu.bcvsolutions.idm.acc.entity.SysSystem_) FormPropertyManager(eu.bcvsolutions.idm.acc.service.api.FormPropertyManager) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) IcRemoteServerException(eu.bcvsolutions.idm.ic.exception.IcRemoteServerException) SysSyncConfigFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncConfigFilter) SysSystemFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemFilter) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) Autowired(org.springframework.beans.factory.annotation.Autowired) IcConfigurationPropertiesImpl(eu.bcvsolutions.idm.ic.impl.IcConfigurationPropertiesImpl) Asserts(org.apache.http.util.Asserts) FormService(eu.bcvsolutions.idm.core.eav.api.service.FormService) IcObjectPoolConfigurationImpl(eu.bcvsolutions.idm.ic.impl.IcObjectPoolConfigurationImpl) StringUtils(org.apache.commons.lang3.StringUtils) IcConfigurationProperties(eu.bcvsolutions.idm.ic.api.IcConfigurationProperties) SysConnectorKeyDto(eu.bcvsolutions.idm.acc.dto.SysConnectorKeyDto) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) IcConnectorInstance(eu.bcvsolutions.idm.ic.api.IcConnectorInstance) Predicate(javax.persistence.criteria.Predicate) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) Map(java.util.Map) OperationOptions(org.identityconnectors.framework.common.objects.OperationOptions) CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) IcConnectorConfigurationCzechIdMImpl(eu.bcvsolutions.idm.ic.czechidm.domain.IcConnectorConfigurationCzechIdMImpl) SysSyncConfigService(eu.bcvsolutions.idm.acc.service.api.SysSyncConfigService) AbstractSysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto) IcConfigurationFacade(eu.bcvsolutions.idm.ic.service.api.IcConfigurationFacade) CriteriaQuery(javax.persistence.criteria.CriteriaQuery) SysSystem(eu.bcvsolutions.idm.acc.entity.SysSystem) ImmutableMap(com.google.common.collect.ImmutableMap) SysSchemaAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter) IcConnectorKeyImpl(eu.bcvsolutions.idm.ic.impl.IcConnectorKeyImpl) IcObjectPoolConfiguration(eu.bcvsolutions.idm.ic.api.IcObjectPoolConfiguration) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) UUID(java.util.UUID) Page(org.springframework.data.domain.Page) Collectors(java.util.stream.Collectors) SysSchemaObjectClassFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaObjectClassFilter) Serializable(java.io.Serializable) List(java.util.List) IcConnectorServer(eu.bcvsolutions.idm.ic.api.IcConnectorServer) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) Optional(java.util.Optional) SysSchemaObjectClassService(eu.bcvsolutions.idm.acc.service.api.SysSchemaObjectClassService) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) AccResultCode(eu.bcvsolutions.idm.acc.domain.AccResultCode) IcConnectorConfiguration(eu.bcvsolutions.idm.ic.api.IcConnectorConfiguration) IcConnectorFacade(eu.bcvsolutions.idm.ic.service.api.IcConnectorFacade) ConnectorType(eu.bcvsolutions.idm.acc.service.api.ConnectorType) HashMap(java.util.HashMap) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) SysSystemRepository(eu.bcvsolutions.idm.acc.repository.SysSystemRepository) MessageFormat(java.text.MessageFormat) ArrayList(java.util.ArrayList) PersistentType(eu.bcvsolutions.idm.core.eav.api.domain.PersistentType) IdmPasswordPolicy_(eu.bcvsolutions.idm.core.model.entity.IdmPasswordPolicy_) SysSystemMappingService(eu.bcvsolutions.idm.acc.service.api.SysSystemMappingService) ConfidentialStorage(eu.bcvsolutions.idm.core.api.service.ConfidentialStorage) IcObjectClassInfo(eu.bcvsolutions.idm.ic.api.IcObjectClassInfo) Service(org.springframework.stereotype.Service) EntityUtils(eu.bcvsolutions.idm.core.api.utils.EntityUtils) SysSystemFormValueService(eu.bcvsolutions.idm.acc.service.api.SysSystemFormValueService) IcConfigurationProperty(eu.bcvsolutions.idm.ic.api.IcConfigurationProperty) Qualifier(org.springframework.beans.factory.annotation.Qualifier) IcObjectClass(eu.bcvsolutions.idm.ic.api.IcObjectClass) DefaultConnectorType(eu.bcvsolutions.idm.acc.connector.DefaultConnectorType) IdmFormInstanceDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto) Root(javax.persistence.criteria.Root) IcAttributeInfo(eu.bcvsolutions.idm.ic.api.IcAttributeInfo) IcConnectorInstanceImpl(eu.bcvsolutions.idm.ic.impl.IcConnectorInstanceImpl) SysSystemMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter) IcConnectorKey(eu.bcvsolutions.idm.ic.api.IcConnectorKey) IcSchema(eu.bcvsolutions.idm.ic.api.IcSchema) SysSystemService(eu.bcvsolutions.idm.acc.service.api.SysSystemService) SysSchemaAttributeService(eu.bcvsolutions.idm.acc.service.api.SysSchemaAttributeService) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) SysRemoteServer_(eu.bcvsolutions.idm.acc.entity.SysRemoteServer_) IcConnectorConfigurationImpl(eu.bcvsolutions.idm.ic.impl.IcConnectorConfigurationImpl) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) AbstractFormableService(eu.bcvsolutions.idm.core.eav.api.service.AbstractFormableService) Collections(java.util.Collections) SysSystemAttributeMappingService(eu.bcvsolutions.idm.acc.service.api.SysSystemAttributeMappingService) EntityEventManager(eu.bcvsolutions.idm.core.api.service.EntityEventManager) AuthorizableType(eu.bcvsolutions.idm.core.security.api.dto.AuthorizableType) Transactional(org.springframework.transaction.annotation.Transactional) Assert(org.springframework.util.Assert) HashMap(java.util.HashMap) SysSchemaObjectClassFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaObjectClassFilter) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) SysSystem(eu.bcvsolutions.idm.acc.entity.SysSystem) AbstractSysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto) SysSystemMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter) IcConnectorInstance(eu.bcvsolutions.idm.ic.api.IcConnectorInstance) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) UUID(java.util.UUID) Transactional(org.springframework.transaction.annotation.Transactional)

Example 12 with SysSchemaObjectClassFilter

use of eu.bcvsolutions.idm.acc.dto.filter.SysSchemaObjectClassFilter in project CzechIdMng by bcvsolutions.

the class MockMsSqlConnectorType method initMockSysSystemService.

private MockSysSystemService initMockSysSystemService() {
    if (systemService == null) {
        systemService = AutowireHelper.createBean(MockSysSystemService.class);
        systemService.setGetSchemaCallBack(new GetSchemaCallBack() {

            @Override
            public List<SysSchemaObjectClassDto> call(SysSystemDto systemDto) {
                if (systemDto != null) {
                    SysSchemaObjectClassFilter schemaFilter = new SysSchemaObjectClassFilter();
                    schemaFilter.setSystemId(systemDto.getId());
                    List<SysSchemaObjectClassDto> content = schemaObjectClassService.find(schemaFilter, null).getContent();
                    if (content.size() > 0) {
                        return content;
                    }
                    SysSchemaObjectClassDto schemaObjectClassDto = new SysSchemaObjectClassDto();
                    schemaObjectClassDto.setObjectClassName(IcObjectClassInfo.ACCOUNT);
                    schemaObjectClassDto.setSystem(systemDto.getId());
                    schemaObjectClassDto = schemaObjectClassService.save(schemaObjectClassDto);
                    return Lists.newArrayList(schemaObjectClassDto);
                }
                return null;
            }
        });
    }
    return systemService;
}
Also used : SysSchemaObjectClassFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaObjectClassFilter) List(java.util.List) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto)

Example 13 with SysSchemaObjectClassFilter

use of eu.bcvsolutions.idm.acc.dto.filter.SysSchemaObjectClassFilter in project CzechIdMng by bcvsolutions.

the class SystemDeleteProcessor method process.

@Override
public EventResult<SysSystemDto> process(EntityEvent<SysSystemDto> event) {
    SysSystemDto system = event.getContent();
    Assert.notNull(system, "System is required.");
    // 
    // if exists provisioning operations, then is not possible to delete
    // system
    SysProvisioningOperationFilter operationFilter = new SysProvisioningOperationFilter();
    operationFilter.setSystemId(system.getId());
    if (provisioningOperationService.count(operationFilter) > 0) {
        throw new ResultCodeException(AccResultCode.SYSTEM_DELETE_FAILED_HAS_OPERATIONS, ImmutableMap.of("system", system.getName()));
    }
    if (accountRepository.countBySystem_Id(system.getId()) > 0) {
        throw new ResultCodeException(AccResultCode.SYSTEM_DELETE_FAILED_HAS_ACCOUNTS, ImmutableMap.of("system", system.getName()));
    }
    // Check if system is used in some systems group.
    SysSystemGroupSystemFilter groupSystemFilter = new SysSystemGroupSystemFilter();
    groupSystemFilter.setSystemId(system.getId());
    long count = systemGroupSystemService.count(groupSystemFilter);
    if (count > 0) {
        throw new ResultCodeException(AccResultCode.SYSTEM_DELETE_FAILED_HAS_SYSTEM_GROUPS, ImmutableMap.of("system", system.getName(), "count", count));
    }
    // delete system entities
    SysSystemEntityFilter systemEntityFilter = new SysSystemEntityFilter();
    systemEntityFilter.setSystemId(system.getId());
    systemEntityService.find(systemEntityFilter, null).forEach(systemEntity -> {
        systemEntityService.delete(systemEntity);
    });
    // delete synchronization configs
    SysSyncConfigFilter synchronizationConfigFilter = new SysSyncConfigFilter();
    synchronizationConfigFilter.setSystemId(system.getId());
    synchronizationConfigService.find(synchronizationConfigFilter, null).forEach(config -> {
        synchronizationConfigService.delete(config);
    });
    // delete schema
    SysSchemaObjectClassFilter filter = new SysSchemaObjectClassFilter();
    filter.setSystemId(system.getId());
    objectClassService.find(filter, null).forEach(schemaObjectClass -> {
        objectClassService.delete(schemaObjectClass);
    });
    // delete archived provisioning operations
    provisioningArchiveRepository.deleteBySystem_Id(system.getId());
    // 
    // clear provisioning break cache
    clearProvisioningBreakAndCache(system.getId());
    // 
    // deletes all confidential values
    confidentialStorage.deleteAll(system.getId(), SysSystem.class);
    // 
    // Delete connected uniform password. Or throw error at the beginning?
    AccUniformPasswordSystemFilter uniformPasswordSystemFilter = new AccUniformPasswordSystemFilter();
    uniformPasswordSystemFilter.setSystemId(system.getId());
    passwordFilterSystemService.find(uniformPasswordSystemFilter, null).forEach(uniformPasswordSystem -> {
        passwordFilterSystemService.delete(uniformPasswordSystem);
    });
    // 
    // deletes identity
    service.deleteInternal(system);
    return new DefaultEventResult<>(event, this);
}
Also used : SysSystemGroupSystemFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemGroupSystemFilter) AccUniformPasswordSystemFilter(eu.bcvsolutions.idm.acc.dto.filter.AccUniformPasswordSystemFilter) SysProvisioningOperationFilter(eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter) SysSchemaObjectClassFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaObjectClassFilter) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult) SysSyncConfigFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncConfigFilter) SysSystemEntityFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemEntityFilter) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto)

Example 14 with SysSchemaObjectClassFilter

use of eu.bcvsolutions.idm.acc.dto.filter.SysSchemaObjectClassFilter in project CzechIdMng by bcvsolutions.

the class DefaultAccAccountService method getSchemaAttributes.

/**
 * Find schema's attributes for the system id and schema name.
 *
 * @param systemId
 * @param schema
 *            - If is schema name null, then will used default '__ACCOUNT__'.
 * @return
 */
private List<SysSchemaAttributeDto> getSchemaAttributes(UUID systemId, String schema) {
    SysSchemaObjectClassFilter schemaFilter = new SysSchemaObjectClassFilter();
    schemaFilter.setSystemId(systemId);
    schemaFilter.setObjectClassName(schema != null ? schema : IcObjectClassInfo.ACCOUNT);
    List<SysSchemaObjectClassDto> schemas = schemaObjectClassService.find(schemaFilter, null).getContent();
    if (schemas.size() != 1) {
        return null;
    }
    SysSchemaAttributeFilter schemaAttributeFilter = new SysSchemaAttributeFilter();
    schemaAttributeFilter.setObjectClassId(schemas.get(0).getId());
    schemaAttributeFilter.setSystemId(systemId);
    return schemaAttributeService.find(schemaAttributeFilter, null).getContent();
}
Also used : SysSchemaObjectClassFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaObjectClassFilter) SysSchemaAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)

Example 15 with SysSchemaObjectClassFilter

use of eu.bcvsolutions.idm.acc.dto.filter.SysSchemaObjectClassFilter in project CzechIdMng by bcvsolutions.

the class DefaultSysRoleSystemAttributeService method getObjectClassId.

/**
 * Returns systems object's scheme
 *
 * @param systemId
 * @param objectClassName
 * @return
 */
private UUID getObjectClassId(UUID systemId, String objectClassName) {
    SysSchemaObjectClassFilter filter = new SysSchemaObjectClassFilter();
    filter.setSystemId(systemId);
    filter.setObjectClassName(objectClassName);
    List<SysSchemaObjectClassDto> objectClasses = schemaObjectClassService.find(filter, null).getContent();
    if (objectClasses.isEmpty()) {
        throw new ResultCodeException(AccResultCode.SYSTEM_SCHEMA_OBJECT_CLASS_NOT_FOUND, ImmutableMap.of("objectClassName", objectClassName, "systemId", systemId));
    }
    return objectClasses.get(0).getId();
}
Also used : SysSchemaObjectClassFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaObjectClassFilter) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)

Aggregations

SysSchemaObjectClassFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSchemaObjectClassFilter)15 SysSchemaObjectClassDto (eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)11 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)8 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)6 SysSchemaAttributeFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter)6 SysSyncConfigFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSyncConfigFilter)5 SysSystemMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter)5 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)5 SysSchemaAttributeDto (eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto)4 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)4 IdmFormDefinitionDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto)4 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)4 AbstractSysSyncConfigDto (eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto)3 SysConnectorKeyDto (eu.bcvsolutions.idm.acc.dto.SysConnectorKeyDto)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 DefaultConnectorType (eu.bcvsolutions.idm.acc.connector.DefaultConnectorType)2 AccResultCode (eu.bcvsolutions.idm.acc.domain.AccResultCode)2 SysRoleSystemAttributeDto (eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto)2 SysRoleSystemDto (eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto)2 SysRoleSystemFilter (eu.bcvsolutions.idm.acc.dto.filter.SysRoleSystemFilter)2