Search in sources :

Example 16 with AcceptedException

use of eu.bcvsolutions.idm.core.api.exception.AcceptedException in project CzechIdMng by bcvsolutions.

the class DefaultIdmAutomaticRoleRequestService method createTreeAutomaticRole.

@Override
public IdmRoleTreeNodeDto createTreeAutomaticRole(IdmRoleTreeNodeDto automaticRole) {
    Assert.notNull(automaticRole);
    IdmAutomaticRoleRequestDto request = new IdmAutomaticRoleRequestDto();
    request.setName(automaticRole.getName());
    request.setTreeNode(automaticRole.getTreeNode());
    request.setRecursionType(automaticRole.getRecursionType());
    request.setRole(automaticRole.getRole());
    request.setRequestType(AutomaticRoleRequestType.TREE);
    request.setOperation(RequestOperationType.ADD);
    request.setResult(new OperationResultDto.Builder(OperationState.CREATED).build());
    request = this.save(request);
    IdmAutomaticRoleRequestDto result = this.getIdmAutomaticRoleRequestService().startRequest(request.getId(), true);
    if (RequestState.EXECUTED == result.getState()) {
        UUID createdAutomaticRoleId = result.getAutomaticRole();
        Assert.notNull(createdAutomaticRoleId);
        return automaticRoleTreeService.get(createdAutomaticRoleId);
    }
    if (RequestState.IN_PROGRESS == result.getState()) {
        throw new AcceptedException();
    }
    if (RequestState.EXCEPTION == result.getState()) {
        throw new AcceptedException();
    }
    return null;
}
Also used : IdmAutomaticRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmAutomaticRoleRequestDto) CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) AcceptedException(eu.bcvsolutions.idm.core.api.exception.AcceptedException) UUID(java.util.UUID)

Example 17 with AcceptedException

use of eu.bcvsolutions.idm.core.api.exception.AcceptedException in project CzechIdMng by bcvsolutions.

the class DefaultIdmRoleTreeNodeService method delete.

/**
 * Publish {@link RoleTreeNodeEvent} only.
 *
 * @see {@link RoleTreeNodeDeleteProcessor}
 */
@Override
@Transactional(noRollbackFor = AcceptedException.class)
public void delete(IdmRoleTreeNodeDto roleTreeNode, BasePermission... permission) {
    Assert.notNull(roleTreeNode);
    checkAccess(this.getEntity(roleTreeNode.getId()), permission);
    // 
    LOG.debug("Deleting automatic role [{}] - [{}] - [{}]", roleTreeNode.getRole(), roleTreeNode.getTreeNode(), roleTreeNode.getRecursionType());
    // 
    EventContext<IdmRoleTreeNodeDto> context = entityEventManager.process(new RoleTreeNodeEvent(RoleTreeNodeEventType.DELETE, roleTreeNode));
    // 
    if (context.isSuspended()) {
        throw new AcceptedException();
    }
}
Also used : IdmRoleTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleTreeNodeDto) RoleTreeNodeEvent(eu.bcvsolutions.idm.core.model.event.RoleTreeNodeEvent) AcceptedException(eu.bcvsolutions.idm.core.api.exception.AcceptedException) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

AcceptedException (eu.bcvsolutions.idm.core.api.exception.AcceptedException)17 IdmAutomaticRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmAutomaticRoleRequestDto)10 UUID (java.util.UUID)10 IdmRoleTreeNodeDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleTreeNodeDto)8 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)7 IdmAutomaticRoleAttributeDto (eu.bcvsolutions.idm.core.api.dto.IdmAutomaticRoleAttributeDto)6 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)6 AbstractCoreWorkflowIntegrationTest (eu.bcvsolutions.idm.core.AbstractCoreWorkflowIntegrationTest)5 IdmAutomaticRoleAttributeRuleDto (eu.bcvsolutions.idm.core.api.dto.IdmAutomaticRoleAttributeRuleDto)5 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)5 IdmRoleGuaranteeDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleGuaranteeDto)5 RoleRequestException (eu.bcvsolutions.idm.core.api.exception.RoleRequestException)5 Test (org.junit.Test)5 CoreException (eu.bcvsolutions.idm.core.api.exception.CoreException)4 IdmTreeNodeDto (eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto)3 IdmRoleTreeNodeFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleTreeNodeFilter)3 Transactional (org.springframework.transaction.annotation.Transactional)3 IdmAutomaticRoleAttributeRuleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmAutomaticRoleAttributeRuleRequestDto)2 DefaultEventResult (eu.bcvsolutions.idm.core.api.event.DefaultEventResult)2 RoleTreeNodeEvent (eu.bcvsolutions.idm.core.model.event.RoleTreeNodeEvent)2