use of eu.bcvsolutions.idm.core.api.exception.ResultCodeException in project CzechIdMng by bcvsolutions.
the class AbstractReportExecutor method generate.
@Override
public RptReportDto generate(RptReportDto report) {
try {
IdmAttachmentDto data = generateData(report);
report.setData(data.getId());
return report;
} catch (ResultCodeException ex) {
throw ex;
} catch (Exception ex) {
// TODO: better exception
throw new CoreException(ex);
}
}
use of eu.bcvsolutions.idm.core.api.exception.ResultCodeException in project CzechIdMng by bcvsolutions.
the class SystemExportBulkActionIntegrationTest method testExportAndImportBreakIdentityAdvancedPairing.
@Test
public void testExportAndImportBreakIdentityAdvancedPairing() {
SysSystemDto system = createSystem();
SysProvisioningBreakConfigDto originalBreak = new SysProvisioningBreakConfigDto();
originalBreak.setSystem(system.getId());
originalBreak.setOperationType(ProvisioningEventType.CREATE);
originalBreak.setPeriod(10l);
originalBreak = provisioningBreakService.save(originalBreak);
IdmIdentityDto originalRecipient = getHelper().createIdentity();
SysProvisioningBreakRecipientDto breakRecipient = new SysProvisioningBreakRecipientDto();
breakRecipient.setIdentity(originalRecipient.getId());
breakRecipient.setBreakConfig(originalBreak.getId());
breakRecipient = provisioningBreakRecipientService.save(breakRecipient);
// Make export, upload, delete system and import.
IdmExportImportDto importBatch = executeExportAndImport(system, SystemExportBulkAction.NAME);
system = systemService.get(system.getId());
Assert.assertNotNull(system);
List<SysProvisioningBreakConfigDto> breaks = findBreaks(system);
Assert.assertEquals(1, breaks.size());
Assert.assertEquals(originalBreak.getId(), breaks.get(0).getId());
breakRecipient = provisioningBreakRecipientService.get(breakRecipient.getId());
Assert.assertNotNull(breakRecipient);
Assert.assertEquals(originalRecipient.getId(), breakRecipient.getIdentity());
// Delete original recipient.
identityService.delete(originalRecipient);
// Execute failed import (check advanced pairing -> will failed -> identity
// missing).
ImportTaskExecutor lrt = new ImportTaskExecutor(importBatch.getId(), false);
try {
importManager.internalExecuteImport(importBatch, false, lrt);
Assert.assertTrue(false);
} catch (ResultCodeException ex) {
if (ex.getError() != null && ex.getError().getError() != null && CoreResultCode.IMPORT_ADVANCED_PARING_FAILED_NOT_FOUND.name().equals(ex.getError().getError().getStatusEnum())) {
// I expect the exception here.
} else {
Assert.assertTrue(false);
}
}
// Create recipient with same user name.
IdmIdentityDto newRecipient = getHelper().createIdentity(originalRecipient.getUsername());
// Execute import (check advanced pairing).
importBatch = importManager.executeImport(importBatch, false);
Assert.assertNotNull(importBatch);
Assert.assertEquals(ExportImportType.IMPORT, importBatch.getType());
Assert.assertEquals(OperationState.EXECUTED, importBatch.getResult().getState());
breakRecipient = provisioningBreakRecipientService.get(breakRecipient.getId());
Assert.assertNotNull(breakRecipient);
Assert.assertEquals(newRecipient.getId(), breakRecipient.getIdentity());
}
use of eu.bcvsolutions.idm.core.api.exception.ResultCodeException in project CzechIdMng by bcvsolutions.
the class ContractGuaranteeSaveAndDeleteProcessorTest method testDeleteGuaranteeOfContractWithSlice.
@Test
public void testDeleteGuaranteeOfContractWithSlice() {
IdmIdentityDto sliceGuarantee = getHelper().createIdentity();
IdmIdentityDto identity = getHelper().createIdentity();
IdmContractSliceDto slice = getHelper().createContractSlice(identity, null, LocalDate.now().minusDays(1), null, null);
UUID contractId = slice.getParentContract();
getHelper().createContractSliceGuarantee(slice.getId(), sliceGuarantee.getId());
IdmContractSliceGuaranteeFilter sliceGuaranteefilter = new IdmContractSliceGuaranteeFilter();
sliceGuaranteefilter.setGuaranteeId(sliceGuarantee.getId());
List<IdmContractSliceGuaranteeDto> sliceGuarantees = contractSliceGuaranteeService.find(sliceGuaranteefilter, null).getContent();
Assert.assertEquals(1, sliceGuarantees.size());
IdmContractGuaranteeFilter guaranteeFilter = new IdmContractGuaranteeFilter();
guaranteeFilter.setIdentityContractId(contractId);
List<IdmContractGuaranteeDto> contractGuarantees = contractGuaranteeService.find(guaranteeFilter, null).getContent();
Assert.assertEquals(1, contractGuarantees.size());
IdmIdentityDto sliceGuaranteeIdent = DtoUtils.getEmbedded(sliceGuarantees.get(0), IdmContractSliceGuarantee_.guarantee);
IdmIdentityDto contractGuaranteeIdent = DtoUtils.getEmbedded(contractGuarantees.get(0), IdmContractSliceGuarantee_.guarantee);
Assert.assertEquals(sliceGuaranteeIdent.getId(), contractGuaranteeIdent.getId());
try {
contractGuaranteeService.delete(contractGuarantees.get(0));
fail("Contract guarantee can't be deleted directly when slice is applied");
} catch (ResultCodeException ex) {
Assert.assertTrue(CoreResultCode.CONTRACT_IS_CONTROLLED_GUARANTEE_CANNOT_BE_DELETED.toString().equals(ex.getError().getErrors().get(0).getStatusEnum()));
}
// guarantee can be still deleted via contract slice operation
contractSliceGuaranteeService.delete(sliceGuarantees.get(0));
sliceGuarantees = contractSliceGuaranteeService.find(sliceGuaranteefilter, null).getContent();
Assert.assertEquals(0, sliceGuarantees.size());
contractGuarantees = contractGuaranteeService.find(guaranteeFilter, null).getContent();
Assert.assertEquals(0, contractGuarantees.size());
}
use of eu.bcvsolutions.idm.core.api.exception.ResultCodeException in project CzechIdMng by bcvsolutions.
the class AbstractRemoveBulkAction method processDto.
@Override
protected OperationResult processDto(DTO dto) {
try {
if (dto instanceof Requestable && requestConfiguration.isRequestModeEnabled(dto.getClass())) {
// Request mode is enabled for that DTO
Requestable requestable = (Requestable) dto;
IdmRequestDto request = requestManager.deleteRequestable(requestable, false);
if (RequestState.IN_PROGRESS == request.getState()) {
throw new AcceptedException(request.getId().toString());
}
if (RequestState.EXCEPTION == request.getState()) {
throw new CoreException(ExceptionUtils.resolveException(request.getResult().getException()));
}
return new OperationResult.Builder(request.getResult().getState()).setCause(request.getResult().getException()).build();
}
this.getService().delete(dto);
return new OperationResult.Builder(OperationState.EXECUTED).build();
} catch (AcceptedException ex) {
return new OperationResult.Builder(OperationState.RUNNING).setException(ex).build();
} catch (ResultCodeException ex) {
return new OperationResult.Builder(OperationState.EXCEPTION).setException(ex).build();
} catch (Exception ex) {
Throwable resolvedException = ExceptionUtils.resolveException(ex);
if (resolvedException instanceof ResultCodeException) {
return //
new OperationResult.Builder(OperationState.EXCEPTION).setException(//
(ResultCodeException) resolvedException).build();
}
return new OperationResult.Builder(OperationState.EXCEPTION).setCause(ex).build();
}
}
use of eu.bcvsolutions.idm.core.api.exception.ResultCodeException in project CzechIdMng by bcvsolutions.
the class RoleCatalogueDeleteBulkAction method processDto.
@Override
protected OperationResult processDto(IdmRoleCatalogueDto roleCatalogue) {
boolean forceDelete = getParameterConverter().toBoolean(getProperties(), EntityEventProcessor.PROPERTY_FORCE_DELETE, false);
if (!forceDelete) {
return super.processDto(roleCatalogue);
}
// force delete
try {
// force delete can execute role catalogue admin only
getService().checkAccess(roleCatalogue, IdmBasePermission.ADMIN);
//
RoleCatalogueEvent roleCatalogueEvent = new RoleCatalogueEvent(RoleCatalogueEventType.DELETE, roleCatalogue, new ConfigurationMap(getProperties()).toMap());
roleCatalogueService.publish(roleCatalogueEvent);
//
return new OperationResult.Builder(OperationState.EXECUTED).build();
} catch (ResultCodeException ex) {
return new OperationResult.Builder(OperationState.EXCEPTION).setException(ex).build();
} catch (Exception ex) {
Throwable resolvedException = ExceptionUtils.resolveException(ex);
if (resolvedException instanceof ResultCodeException) {
return //
new OperationResult.Builder(OperationState.EXCEPTION).setException(//
(ResultCodeException) resolvedException).build();
}
return new OperationResult.Builder(OperationState.EXCEPTION).setCause(ex).build();
}
}
Aggregations