Search in sources :

Example 1 with SysRoleSystemFilter

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

the class DefaultSysRoleSystemServiceFilterTest method testSystemMappingIdFilter.

@Test
public void testSystemMappingIdFilter() {
    IdmRoleDto role1 = helper.createRole();
    IdmRoleDto role2 = helper.createRole();
    SysSystemDto system1 = helper.createTestResourceSystem(true);
    SysSystemDto system2 = helper.createTestResourceSystem(true);
    // 
    SysSystemMappingDto sysSystemMappingDto1 = mappingService.findBySystemId(system1.getId(), SystemOperationType.PROVISIONING, SystemEntityType.IDENTITY).get(0);
    SysSystemMappingDto sysSystemMappingDto2 = mappingService.findBySystemId(system2.getId(), SystemOperationType.PROVISIONING, SystemEntityType.IDENTITY).get(0);
    SysRoleSystemDto roleSystem1 = createRoleSystem(role1.getId(), system1.getId(), sysSystemMappingDto1.getId());
    createRoleSystem(role2.getId(), system1.getId(), sysSystemMappingDto2.getId());
    // 
    SysRoleSystemFilter roleFilter = new SysRoleSystemFilter();
    roleFilter.setSystemMappingId(sysSystemMappingDto1.getId());
    Page<SysRoleSystemDto> pages = roleSystemService.find(roleFilter, null);
    assertEquals(1, pages.getTotalElements());
    assertEquals(roleSystem1.getId(), pages.getContent().get(0).getId());
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) SysRoleSystemFilter(eu.bcvsolutions.idm.acc.dto.filter.SysRoleSystemFilter) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 2 with SysRoleSystemFilter

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

the class DefaultSysRoleSystemServiceFilterTest method testRoleIdFilter.

@Test
public void testRoleIdFilter() {
    IdmRoleDto role = helper.createRole();
    IdmRoleDto role2 = helper.createRole();
    SysSystemDto system = helper.createTestResourceSystem(true);
    // 
    SysSystemMappingDto sysSystemMappingDto = mappingService.findBySystemId(system.getId(), SystemOperationType.PROVISIONING, SystemEntityType.IDENTITY).get(0);
    SysRoleSystemDto roleSystem = createRoleSystem(role.getId(), system.getId(), sysSystemMappingDto.getId());
    createRoleSystem(role2.getId(), system.getId(), sysSystemMappingDto.getId());
    // 
    SysRoleSystemFilter roleFilter = new SysRoleSystemFilter();
    roleFilter.setRoleId(role.getId());
    Page<SysRoleSystemDto> pages = roleSystemService.find(roleFilter, null);
    // 
    assertEquals(1, pages.getTotalElements());
    assertEquals(roleSystem.getId(), pages.getContent().get(0).getId());
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) SysRoleSystemFilter(eu.bcvsolutions.idm.acc.dto.filter.SysRoleSystemFilter) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 3 with SysRoleSystemFilter

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

the class SystemMappingDeleteProcessor method process.

@Override
public EventResult<SysSystemMappingDto> process(EntityEvent<SysSystemMappingDto> event) {
    SysSystemMappingDto systemMapping = event.getContent();
    // 
    if (configService.countBySystemMapping(systemMapping) > 0) {
        throw new ResultCodeException(AccResultCode.SYSTEM_MAPPING_DELETE_FAILED_USED_IN_SYNC, ImmutableMap.of("mapping", systemMapping.getName()));
    }
    // 
    // remove all handled attributes
    SysSystemAttributeMappingFilter filter = new SysSystemAttributeMappingFilter();
    filter.setSystemMappingId(systemMapping.getId());
    systemAttributeMappingService.find(filter, null).forEach(systemAttributeMapping -> {
        systemAttributeMappingService.delete(systemAttributeMapping);
    });
    // 
    // delete mapped roles
    SysRoleSystemFilter roleSystemFilter = new SysRoleSystemFilter();
    roleSystemFilter.setSystemMappingId(systemMapping.getId());
    roleSystemService.find(roleSystemFilter, null).forEach(roleSystem -> {
        roleSystemService.delete(roleSystem);
    });
    // 
    systemMappingService.deleteInternal(systemMapping);
    // 
    return new DefaultEventResult<>(event, this);
}
Also used : SysRoleSystemFilter(eu.bcvsolutions.idm.acc.dto.filter.SysRoleSystemFilter) SysSystemAttributeMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)

Example 4 with SysRoleSystemFilter

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

the class SysRoleSystemController method toFilter.

@Override
protected SysRoleSystemFilter toFilter(MultiValueMap<String, Object> parameters) {
    SysRoleSystemFilter filter = new SysRoleSystemFilter();
    filter.setRoleId(getParameterConverter().toUuid(parameters, "roleId"));
    filter.setSystemId(getParameterConverter().toUuid(parameters, "systemId"));
    return filter;
}
Also used : SysRoleSystemFilter(eu.bcvsolutions.idm.acc.dto.filter.SysRoleSystemFilter)

Example 5 with SysRoleSystemFilter

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

the class CoreReferentialIntegrityIntegrationTest method testRoleReferentialIntegrity.

@Test
public void testRoleReferentialIntegrity() {
    IdmRoleDto role = helper.createRole();
    // role systems
    SysSystemDto system = new SysSystemDto();
    system.setName("system_" + System.currentTimeMillis());
    system = systemService.save(system);
    // schema
    SysSchemaObjectClassDto objectClass = new SysSchemaObjectClassDto();
    objectClass.setSystem(system.getId());
    objectClass.setObjectClassName("__ACCOUNT__");
    objectClass = schemaObjectClassService.save(objectClass);
    SysSystemMappingDto systemMapping = new SysSystemMappingDto();
    systemMapping.setName("default_" + System.currentTimeMillis());
    systemMapping.setObjectClass(objectClass.getId());
    systemMapping.setOperationType(SystemOperationType.PROVISIONING);
    systemMapping.setEntityType(SystemEntityType.IDENTITY);
    systemMapping = systemEntityHandlingService.save(systemMapping);
    SysRoleSystemDto roleSystem = new SysRoleSystemDto();
    roleSystem.setSystem(system.getId());
    roleSystem.setRole(role.getId());
    roleSystem.setSystemMapping(systemMapping.getId());
    roleSystemService.save(roleSystem);
    SysRoleSystemFilter filter = new SysRoleSystemFilter();
    filter.setRoleId(role.getId());
    assertNotNull(roleService.getByCode(role.getName()));
    assertEquals(1, roleSystemService.find(filter, null).getTotalElements());
    roleService.delete(role);
    assertNull(roleService.getByCode(role.getName()));
    assertEquals(0, roleSystemService.find(filter, null).getTotalElements());
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) SysRoleSystemFilter(eu.bcvsolutions.idm.acc.dto.filter.SysRoleSystemFilter) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

SysRoleSystemFilter (eu.bcvsolutions.idm.acc.dto.filter.SysRoleSystemFilter)11 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)9 SysRoleSystemDto (eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto)8 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)8 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)7 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)5 Test (org.junit.Test)5 SysRoleSystemAttributeDto (eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto)3 SysSchemaObjectClassDto (eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)3 SysSystemAttributeMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 AccResultCode (eu.bcvsolutions.idm.acc.domain.AccResultCode)2 SystemEntityType (eu.bcvsolutions.idm.acc.domain.SystemEntityType)2 AccAccountDto (eu.bcvsolutions.idm.acc.dto.AccAccountDto)2 AccIdentityAccountDto (eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto)2 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)2 AccIdentityAccountFilter (eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter)2 SysRoleSystemAttributeFilter (eu.bcvsolutions.idm.acc.dto.filter.SysRoleSystemAttributeFilter)2 SysRoleSystem_ (eu.bcvsolutions.idm.acc.entity.SysRoleSystem_)2 ProvisioningException (eu.bcvsolutions.idm.acc.exception.ProvisioningException)2