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