Search in sources :

Example 6 with IdmIdentityRoleValidRequestDto

use of eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleValidRequestDto in project CzechIdMng by bcvsolutions.

the class IdentityRoleValidRequestTaskExecutor method process.

@Override
public Boolean process() {
    boolean canContinue = true;
    counter = 0L;
    List<IdmIdentityRoleValidRequestDto> list = validRequestService.findAllValid();
    // init count
    if (count == null) {
        count = Long.valueOf(list.size());
    }
    LOG.info("Account management starts for all newly valid roles from now. Count [{}]", count);
    for (IdmIdentityRoleValidRequestDto request : list) {
        try {
            // after success provisioning is request removed from db
            entityEventManager.process(new IdentityRoleValidRequestEvent(IdentityRoleValidRequestEventType.IDENTITY_ROLE_VALID, request));
        } catch (RuntimeException e) {
            // log failed operation
            request.increaseAttempt();
            request.setResult(new OperationResult.Builder(OperationState.NOT_EXECUTED).setCause(e).build());
            this.validRequestService.save(request);
        }
        counter++;
        canContinue = updateState();
        if (!canContinue) {
            break;
        }
    }
    return Boolean.TRUE;
}
Also used : IdentityRoleValidRequestEvent(eu.bcvsolutions.idm.core.model.event.IdentityRoleValidRequestEvent) IdmIdentityRoleValidRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleValidRequestDto)

Example 7 with IdmIdentityRoleValidRequestDto

use of eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleValidRequestDto in project CzechIdMng by bcvsolutions.

the class IdentityRoleValidRequestIntegrationTest method deleteIdentity.

@Test
public void deleteIdentity() {
    IdmIdentityDto identity = createAndSaveIdentity();
    IdmRoleDto role = createAndSaveRole();
    IdmTreeTypeDto treeType = createAndSaveTreeType();
    IdmTreeNodeDto treeNode = createAndSaveTreeNode(treeType);
    IdmIdentityContractDto identityContract = createAndSaveIdentityContract(identity, treeNode);
    LocalDate from = new LocalDate();
    from = from.plusDays(5);
    createAndSaveIdentityRole(identityContract, role, null, from);
    List<IdmIdentityRoleValidRequestDto> list = identityRoleValidRequestService.find(null).getContent();
    int size = list.size();
    identityService.delete(identity);
    list = identityRoleValidRequestService.find(null).getContent();
    assertNotEquals(size, list.size());
    list = identityRoleValidRequestService.findAllValidRequestForIdentityId(identity.getId());
    assertEquals(true, list.isEmpty());
}
Also used : IdmTreeTypeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) LocalDate(org.joda.time.LocalDate) IdmIdentityRoleValidRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleValidRequestDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 8 with IdmIdentityRoleValidRequestDto

use of eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleValidRequestDto in project CzechIdMng by bcvsolutions.

the class IdentityRoleDeleteProcessor method process.

@Override
public EventResult<IdmIdentityRoleDto> process(EntityEvent<IdmIdentityRoleDto> event) {
    IdmIdentityRoleDto identityRole = event.getContent();
    // Find all concepts and remove relation on identity role
    IdmConceptRoleRequestFilter conceptRequestFilter = new IdmConceptRoleRequestFilter();
    conceptRequestFilter.setIdentityRoleId(identityRole.getId());
    conceptRequestService.find(conceptRequestFilter, null).getContent().forEach(concept -> {
        IdmRoleRequestDto request = roleRequestService.get(concept.getRoleRequest());
        String message = null;
        if (concept.getState().isTerminatedState()) {
            message = MessageFormat.format("IdentityRole [{0}] (reqested in concept [{1}]) was deleted (not from this role request)!", identityRole.getId(), concept.getId());
        } else {
            message = MessageFormat.format("Request change in concept [{0}], was not executed, because requested IdentityRole [{1}] was deleted (not from this role request)!", concept.getId(), identityRole.getId());
            concept.setState(RoleRequestState.CANCELED);
        }
        roleRequestService.addToLog(request, message);
        conceptRequestService.addToLog(concept, message);
        concept.setIdentityRole(null);
        roleRequestService.save(request);
        conceptRequestService.save(concept);
    });
    // 
    // remove all IdentityRoleValidRequest for this role
    List<IdmIdentityRoleValidRequestDto> validRequests = identityRoleValidRequestService.findAllValidRequestForIdentityRoleId(identityRole.getId());
    identityRoleValidRequestService.deleteAll(validRequests);
    // 
    // Delete identity role
    service.deleteInternal(identityRole);
    // 
    return new DefaultEventResult<>(event, this);
}
Also used : IdmConceptRoleRequestFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmConceptRoleRequestFilter) DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) IdmRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto) IdmIdentityRoleValidRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleValidRequestDto)

Example 9 with IdmIdentityRoleValidRequestDto

use of eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleValidRequestDto in project CzechIdMng by bcvsolutions.

the class DefaultIdentityRoleValidRequestService method createByIdentityRoleId.

@Override
public IdmIdentityRoleValidRequestDto createByIdentityRoleId(UUID identityRoleId) {
    IdmIdentityRoleValidRequestDto dto = toDto(repository.findOneByIdentityRole_Id(identityRoleId));
    // 
    if (dto == null) {
        dto = new IdmIdentityRoleValidRequestDto();
        dto.setResult(new OperationResult.Builder(OperationState.CREATED).build());
        dto.setIdentityRole(identityRoleId);
    }
    // just update modified date
    return this.save(dto);
}
Also used : IdmIdentityRoleValidRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleValidRequestDto)

Aggregations

IdmIdentityRoleValidRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleValidRequestDto)9 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)6 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)5 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)5 IdmTreeNodeDto (eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto)5 IdmTreeTypeDto (eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto)5 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)5 LocalDate (org.joda.time.LocalDate)5 Test (org.junit.Test)5 IdmIdentityRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto)2 DefaultEventResult (eu.bcvsolutions.idm.core.api.event.DefaultEventResult)2 AccIdentityAccountDto (eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto)1 AccIdentityAccountFilter (eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter)1 IdmRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto)1 IdmConceptRoleRequestFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmConceptRoleRequestFilter)1 IdmContractGuaranteeFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmContractGuaranteeFilter)1 IdmRoleGuaranteeFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleGuaranteeFilter)1 IdmRoleRequestFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleRequestFilter)1 IdmIdentityRole (eu.bcvsolutions.idm.core.model.entity.IdmIdentityRole)1 IdentityRoleValidRequestEvent (eu.bcvsolutions.idm.core.model.event.IdentityRoleValidRequestEvent)1