use of eu.bcvsolutions.idm.core.api.dto.DefaultResultModel in project CzechIdMng by bcvsolutions.
the class IdmMessageDtoUnitTest method testModelOveloadLevel.
@Test
public void testModelOveloadLevel() {
ResultModel model = new DefaultResultModel(CoreResultCode.INTERNAL_SERVER_ERROR);
IdmMessageDto message = new IdmMessageDto.Builder().setModel(model).setLevel(NotificationLevel.SUCCESS).build();
Assert.assertEquals(NotificationLevel.SUCCESS, message.getLevel());
}
use of eu.bcvsolutions.idm.core.api.dto.DefaultResultModel 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.DefaultResultModel in project CzechIdMng by bcvsolutions.
the class DisabledProvisioningSystemProcessor method process.
@Override
public EventResult<AccAccountDto> process(EntityEvent<AccAccountDto> event) {
AccAccountDto account = event.getContent();
//
SysSystemDto system = DtoUtils.getEmbedded(account, AccAccount_.system, (SysSystemDto) null);
if (system == null) {
system = systemService.get(account.getSystem());
}
boolean isDryRun = getBooleanProperty(ProvisioningService.DRY_RUN_PROPERTY_NAME, event.getProperties());
boolean closed = false;
if (system.isDisabledProvisioning() && !isDryRun) {
ResultModel resultModel = new DefaultResultModel(AccResultCode.PROVISIONING_SYSTEM_DISABLED_PROVISIONING, ImmutableMap.of("name", account.getRealUid(), "system", system.getName()));
LOG.info(resultModel.toString());
//
closed = true;
}
//
return new DefaultEventResult<>(event, this, closed);
}
use of eu.bcvsolutions.idm.core.api.dto.DefaultResultModel in project CzechIdMng by bcvsolutions.
the class ProvisioningBreakProcessor method blockOperation.
/**
* Method block this operation and send message to topic.
*
* @param provisioningOperation
* @return
*/
private SysProvisioningOperationDto blockOperation(SysProvisioningOperationDto provisioningOperation, SysSystemDto system) {
String uid = provisioningOperationService.getByProvisioningOperation(provisioningOperation).getUid();
ResultModel resultModel = new DefaultResultModel(AccResultCode.PROVISIONING_SYSTEM_BLOCKED, ImmutableMap.of("name", uid, "system", system.getName()));
provisioningOperation.setResult(new OperationResult.Builder(OperationState.BLOCKED).setModel(resultModel).build());
//
provisioningOperation = provisioningOperationService.saveOperation(provisioningOperation);
//
// send also to provisioning topic (websocket)
notificationManager.send(AccModuleDescriptor.TOPIC_PROVISIONING, new IdmMessageDto.Builder().setModel(resultModel).build());
return provisioningOperation;
}
use of eu.bcvsolutions.idm.core.api.dto.DefaultResultModel 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 = eventConfiguration.getAsynchronousInstanceId();
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());
List<IdmEntityStateDto> states = entityStateManager.findStates(filter, null).getContent();
states.stream().filter(state -> {
return OperationState.RUNNING == state.getResult().getState();
}).forEach(state -> {
state.setResult(result);
entityStateManager.saveState(null, state);
});
});
//
cacheManager.evictCache(TRANSACTION_EVENT_CACHE_NAME);
}
Aggregations