use of eu.bcvsolutions.idm.core.model.event.RoleTreeNodeEvent in project CzechIdMng by bcvsolutions.
the class DefaultIdmRoleTreeNodeService method save.
/**
* Publish {@link RoleTreeNodeEvent} only.
*
* @see {@link RoleTreeNodeSaveProcessor}
*/
@Override
@Transactional(noRollbackFor = AcceptedException.class)
public IdmRoleTreeNodeDto save(IdmRoleTreeNodeDto roleTreeNode, BasePermission... permission) {
Assert.notNull(roleTreeNode);
checkAccess(toEntity(roleTreeNode, null), permission);
//
LOG.debug("Saving automatic role [{}] - [{}] - [{}]", roleTreeNode.getRole(), roleTreeNode.getTreeNode(), roleTreeNode.getRecursionType());
//
if (isNew(roleTreeNode)) {
// create
// check if exists same entity for roleId, treeNodeId and recursion type
IdmRoleTreeNodeFilter filter = new IdmRoleTreeNodeFilter();
filter.setRoleId(roleTreeNode.getRole());
filter.setTreeNodeId(roleTreeNode.getTreeNode());
filter.setRecursionType(roleTreeNode.getRecursionType());
List<IdmRoleTreeNodeDto> content = this.find(filter, null).getContent();
if (!content.isEmpty()) {
throw new ResultCodeException(CoreResultCode.ROLE_TREE_NODE_TYPE_EXISTS, ImmutableMap.of("roleId", roleTreeNode.getRole(), "treeNodeId", roleTreeNode.getTreeNode(), "recursionType", roleTreeNode.getRecursionType()));
}
//
EventContext<IdmRoleTreeNodeDto> context = entityEventManager.process(new RoleTreeNodeEvent(RoleTreeNodeEventType.CREATE, roleTreeNode));
if (context.isSuspended()) {
throw new AcceptedException();
}
return context.getContent();
}
throw new ResultCodeException(CoreResultCode.METHOD_NOT_ALLOWED, "Automatic role update is not supported");
}
use of eu.bcvsolutions.idm.core.model.event.RoleTreeNodeEvent 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