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;
}
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();
}
}
Aggregations