use of eu.bcvsolutions.idm.core.api.dto.ResultModel in project CzechIdMng by bcvsolutions.
the class IdmMessageDtoUnitTest method testModelError.
@Test
public void testModelError() {
ResultModel model = new DefaultResultModel(CoreResultCode.INTERNAL_SERVER_ERROR);
IdmMessageDto message = new IdmMessageDto.Builder().setModel(model).build();
Assert.assertEquals(model.getStatusEnum(), message.getSubject());
Assert.assertEquals(model.getMessage(), message.getTextMessage());
Assert.assertEquals(model.getMessage(), message.getHtmlMessage());
Assert.assertEquals(NotificationLevel.ERROR, message.getLevel());
}
use of eu.bcvsolutions.idm.core.api.dto.ResultModel in project CzechIdMng by bcvsolutions.
the class IdmMessageDtoUnitTest method testModelWarning.
@Test
public void testModelWarning() {
ResultModel model = new DefaultResultModel(CoreResultCode.BAD_VALUE);
IdmMessageDto message = new IdmMessageDto.Builder().setModel(model).build();
Assert.assertEquals(model.getStatusEnum(), message.getSubject());
Assert.assertEquals(model.getMessage(), message.getTextMessage());
Assert.assertEquals(model.getMessage(), message.getHtmlMessage());
Assert.assertEquals(NotificationLevel.WARNING, message.getLevel());
}
use of eu.bcvsolutions.idm.core.api.dto.ResultModel in project CzechIdMng by bcvsolutions.
the class DefaultEntityEventManager method init.
/**
* Cancel all previously ran events
*/
@Override
public void init() {
LOG.info("Cancel unprocessed events - event was interrupt during instance restart");
//
String instanceId = configurationService.getInstanceId();
entityEventService.findByState(instanceId, OperationState.RUNNING).forEach(event -> {
LOG.info("Cancel unprocessed event [{}] - event was interrupt during instance [{}] restart", event.getId(), instanceId);
//
// cancel event
ResultModel resultModel = new DefaultResultModel(CoreResultCode.EVENT_CANCELED_BY_RESTART, ImmutableMap.of("eventId", event.getId(), "eventType", event.getEventType(), "ownerId", String.valueOf(event.getOwnerId()), "instanceId", event.getInstanceId()));
OperationResultDto result = new OperationResultDto.Builder(OperationState.CANCELED).setModel(resultModel).build();
event.setResult(result);
entityEventService.saveInternal(event);
//
// cancel event states
IdmEntityStateFilter filter = new IdmEntityStateFilter();
filter.setEventId(event.getId());
entityStateService.find(filter, null).getContent().stream().filter(state -> {
return OperationState.RUNNING == state.getResult().getState();
}).forEach(state -> {
event.setResult(result);
entityStateService.save(state);
});
});
}
use of eu.bcvsolutions.idm.core.api.dto.ResultModel in project CzechIdMng by bcvsolutions.
the class DefaultProvisioningExecutor method persistOperation.
/**
* Persist new operation
*
* @param provisioningOperation
* @return
*/
private SysProvisioningOperationDto persistOperation(SysProvisioningOperationDto provisioningOperation) {
Assert.notNull(provisioningOperation);
Assert.notNull(provisioningOperation.getSystemEntity());
Assert.notNull(provisioningOperation.getProvisioningContext());
// get system from service, in provisioning operation may not exist
SysSystemDto system = systemService.get(provisioningOperation.getSystem());
Assert.notNull(system);
// make sure system will be in embedded
provisioningOperation.getEmbedded().put(SysProvisioningOperation_.system.getName(), system);
//
// save new operation to provisioning log / queue
String uid = systemEntityService.getByProvisioningOperation(provisioningOperation).getUid();
SysProvisioningBatchDto batch = batchService.findBatch(system.getId(), provisioningOperation.getEntityIdentifier(), provisioningOperation.getSystemEntity());
if (batch == null) {
batch = batchService.save(new SysProvisioningBatchDto());
provisioningOperation.setResult(new OperationResult.Builder(OperationState.CREATED).build());
} else {
// put to queue, if previous
ResultModel resultModel = new DefaultResultModel(AccResultCode.PROVISIONING_IS_IN_QUEUE, ImmutableMap.of("name", uid, "system", system.getName(), "operationType", provisioningOperation.getOperationType(), "objectClass", provisioningOperation.getProvisioningContext().getConnectorObject().getObjectClass()));
LOG.debug(resultModel.toString());
provisioningOperation.setResult(new OperationResult.Builder(OperationState.NOT_EXECUTED).setModel(resultModel).build());
if (securityService.getCurrentId() != null) {
// TODO: check logged identity and account owner
notificationManager.send(AccModuleDescriptor.TOPIC_PROVISIONING, new IdmMessageDto.Builder(NotificationLevel.WARNING).setModel(provisioningOperation.getResult().getModel()).build());
}
}
provisioningOperation.setBatch(batch.getId());
provisioningOperation = provisioningOperationService.save(provisioningOperation);
//
return provisioningOperation;
}
use of eu.bcvsolutions.idm.core.api.dto.ResultModel in project CzechIdMng by bcvsolutions.
the class DefaultSysProvisioningOperationService method handleSuccessful.
@Override
@Transactional
public SysProvisioningOperationDto handleSuccessful(SysProvisioningOperationDto operation) {
SysSystemDto system = systemService.get(operation.getSystem());
String uid = this.getByProvisioningOperation(operation).getUid();
ResultModel resultModel = new DefaultResultModel(AccResultCode.PROVISIONING_SUCCEED, ImmutableMap.of("name", uid, "system", system.getName(), "operationType", operation.getOperationType(), "objectClass", operation.getProvisioningContext().getConnectorObject().getObjectClass().getType()));
operation.setResult(new OperationResult.Builder(OperationState.EXECUTED).setModel(resultModel).build());
operation = save(operation);
//
LOG.debug(resultModel.toString());
if (securityService.getCurrentId() != null) {
// TODO: check account owner
notificationManager.send(AccModuleDescriptor.TOPIC_PROVISIONING, new IdmMessageDto.Builder().setModel(resultModel).build());
}
return operation;
}
Aggregations