use of eu.bcvsolutions.idm.core.api.dto.IdmRoleTreeNodeDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmIdentityContractServiceIntegrationTest method saveAutomaticRole.
/**
* Save automatic role with repository and manual create and wait for task
* @param automaticRole
* @return
*/
private IdmRoleTreeNodeDto saveAutomaticRole(IdmRoleTreeNodeDto automaticRole, boolean withLongRunningTask) {
// default name
automaticRole.setName("default");
IdmRoleTreeNodeDto roleTreeNode = roleTreeNodeService.saveInternal(automaticRole);
//
if (withLongRunningTask) {
AddNewAutomaticRoleTaskExecutor task = new AddNewAutomaticRoleTaskExecutor();
task.setAutomaticRoleId(roleTreeNode.getId());
taskManager.executeSync(task);
}
//
return roleTreeNodeService.get(roleTreeNode.getId());
}
use of eu.bcvsolutions.idm.core.api.dto.IdmRoleTreeNodeDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmIdentityContractServiceIntegrationTest method prepareAutomaticRoles.
/**
*/
private void prepareAutomaticRoles() {
// prepare automatic roles
automaticRoleA = new IdmRoleTreeNodeDto();
automaticRoleA.setRecursionType(RecursionType.DOWN);
automaticRoleA.setRole(roleA.getId());
automaticRoleA.setTreeNode(nodeA.getId());
automaticRoleA = saveAutomaticRole(automaticRoleA, false);
automaticRoleD = new IdmRoleTreeNodeDto();
automaticRoleD.setRecursionType(RecursionType.DOWN);
automaticRoleD.setRole(roleB.getId());
automaticRoleD.setTreeNode(nodeD.getId());
automaticRoleD = saveAutomaticRole(automaticRoleD, false);
automaticRoleF = new IdmRoleTreeNodeDto();
automaticRoleF.setRecursionType(RecursionType.UP);
automaticRoleF.setRole(roleC.getId());
automaticRoleF.setTreeNode(nodeF.getId());
automaticRoleF = saveAutomaticRole(automaticRoleF, false);
automaticRoleE = new IdmRoleTreeNodeDto();
automaticRoleE.setRecursionType(RecursionType.NO);
automaticRoleE.setRole(roleD.getId());
automaticRoleE.setTreeNode(nodeE.getId());
automaticRoleE = saveAutomaticRole(automaticRoleE, false);
}
use of eu.bcvsolutions.idm.core.api.dto.IdmRoleTreeNodeDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmIdentityContractServiceIntegrationTest method testAssingRoleForContractValidInTheFuture.
@Test
public void testAssingRoleForContractValidInTheFuture() {
IdmIdentityDto identity = helper.createIdentity();
//
IdmIdentityContractDto contractD = new IdmIdentityContractDto();
contractD.setIdentity(identity.getId());
contractD.setWorkPosition(nodeD.getId());
contractD.setValidFrom(new LocalDate().plusDays(1));
contractD = service.save(contractD);
//
// create new automatic role
automaticRoleD = new IdmRoleTreeNodeDto();
automaticRoleD.setRecursionType(RecursionType.NO);
automaticRoleD.setRole(roleA.getId());
automaticRoleD.setTreeNode(nodeD.getId());
automaticRoleD = saveAutomaticRole(automaticRoleD, true);
//
// check
List<IdmIdentityRoleDto> identityRoles = identityRoleService.findAllByContract(contractD.getId());
assertEquals(1, identityRoles.size());
assertEquals(automaticRoleD.getId(), identityRoles.get(0).getRoleTreeNode());
}
use of eu.bcvsolutions.idm.core.api.dto.IdmRoleTreeNodeDto in project CzechIdMng by bcvsolutions.
the class IdmRoleTreeNodeController method delete.
@Override
@ResponseBody
@RequestMapping(value = "/{backendId}", method = RequestMethod.DELETE)
@PreAuthorize("hasAuthority('" + CoreGroupPermission.ROLETREENODE_DELETE + "')")
@ApiOperation(value = "Delete automatic role. Uses request!", nickname = "deleteRoleTreeNode", tags = { IdmRoleTreeNodeController.TAG }, authorizations = { @Authorization(value = SwaggerConfig.AUTHENTICATION_BASIC, scopes = { @AuthorizationScope(scope = CoreGroupPermission.ROLETREENODE_DELETE, description = "") }), @Authorization(value = SwaggerConfig.AUTHENTICATION_CIDMST, scopes = { @AuthorizationScope(scope = CoreGroupPermission.ROLETREENODE_DELETE, description = "") }) })
public ResponseEntity<?> delete(@ApiParam(value = "Automatic role's uuid identifier.", required = true) @PathVariable @NotNull String backendId) {
IdmRoleTreeNodeDto automaticRole = this.getDto(backendId);
Assert.notNull(automaticRole);
requestService.deleteAutomaticRole(automaticRole, AutomaticRoleRequestType.TREE);
throw new AcceptedException();
}
use of eu.bcvsolutions.idm.core.api.dto.IdmRoleTreeNodeDto in project CzechIdMng by bcvsolutions.
the class IdmRoleTreeNodeController method post.
@Override
@ResponseBody
@RequestMapping(method = RequestMethod.POST)
@PreAuthorize("hasAuthority('" + CoreGroupPermission.ROLETREENODE_CREATE + "')" + " or hasAuthority('" + CoreGroupPermission.ROLETREENODE_UPDATE + "')")
@ApiOperation(value = "Create / update automatic role", nickname = "postRoleTreeNode", response = IdmRoleTreeNodeDto.class, tags = { IdmRoleTreeNodeController.TAG }, authorizations = { @Authorization(value = SwaggerConfig.AUTHENTICATION_BASIC, scopes = { @AuthorizationScope(scope = CoreGroupPermission.ROLETREENODE_CREATE, description = ""), @AuthorizationScope(scope = CoreGroupPermission.ROLETREENODE_UPDATE, description = "") }), @Authorization(value = SwaggerConfig.AUTHENTICATION_CIDMST, scopes = { @AuthorizationScope(scope = CoreGroupPermission.ROLETREENODE_CREATE, description = ""), @AuthorizationScope(scope = CoreGroupPermission.ROLETREENODE_UPDATE, description = "") }) }, notes = "If role has guarantee assigned, then automatic role has to be approved by him at first (configurable by entity event processor).")
public ResponseEntity<?> post(@Valid @RequestBody IdmRoleTreeNodeDto dto) {
Assert.notNull(dto);
IdmRoleTreeNodeDto result = requestService.createTreeAutomaticRole(dto);
if (result == null) {
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
return new ResponseEntity<>(toResource(result), HttpStatus.CREATED);
}
Aggregations