use of eu.bcvsolutions.idm.core.api.dto.DefaultResultModel in project CzechIdMng by bcvsolutions.
the class EntityEventLockQueueMonitoringEvaluator method evaluate.
@Override
public IdmMonitoringResultDto evaluate(IdmMonitoringDto monitoring) {
long treshold = getParameterConverter().toLong(monitoring.getEvaluatorProperties(), PARAMETER_THRESHOLD, DEFAULT_THRESHOLD);
long count = LOCK.getQueueLength();
ResultModel resultModel = new DefaultResultModel(CoreResultCode.MONITORING_EVENT_LOCK_QUEUE, ImmutableMap.of("count", Long.toString(count)));
IdmMonitoringResultDto result = new IdmMonitoringResultDto();
result.setValue(Long.toString(count));
result.setResult(new OperationResultDto.Builder(OperationState.EXECUTED).setModel(resultModel).build());
if (treshold < count) {
result.setLevel(NotificationLevel.WARNING);
}
//
return result;
}
use of eu.bcvsolutions.idm.core.api.dto.DefaultResultModel in project CzechIdMng by bcvsolutions.
the class H2DatabaseMonitoringEvaluator method evaluate.
@Override
public IdmMonitoringResultDto evaluate(IdmMonitoringDto monitoring) {
ResultModel resultModel;
//
String resolvedDbName = flywayMigrationStrategy.resolveDbName(dataSource);
if (IdmFlywayMigrationStrategy.H2_DBNAME.equals(resolvedDbName)) {
if (applicationConfiguration.isProduction()) {
resultModel = new DefaultResultModel(CoreResultCode.MONITORING_H2_DATABASE_ERROR, ImmutableMap.of("instanceId", monitoring.getInstanceId()));
} else {
resultModel = new DefaultResultModel(CoreResultCode.MONITORING_H2_DATABASE_WARNING, ImmutableMap.of("instanceId", monitoring.getInstanceId(), "stage", applicationConfiguration.getStage()));
}
} else {
resultModel = new DefaultResultModel(CoreResultCode.MONITORING_H2_DATABASE_SUCCESS, ImmutableMap.of("instanceId", monitoring.getInstanceId(), "databaseName", resolvedDbName));
}
//
IdmMonitoringResultDto result = new IdmMonitoringResultDto();
result.setValue(resolvedDbName);
result.setResult(new OperationResultDto.Builder(OperationState.EXECUTED).setModel(resultModel).build());
//
return result;
}
use of eu.bcvsolutions.idm.core.api.dto.DefaultResultModel in project CzechIdMng by bcvsolutions.
the class DefaultUniformPasswordManager method addSystemNameToEntityState.
@Override
@SuppressWarnings("unchecked")
public void addSystemNameToEntityState(IdmEntityStateDto uniformPasswordState, String systemName) {
ResultModel model = uniformPasswordState.getResult().getModel();
// Add system name to entity state for uniform password (will be used in bulk notification).
Object successSystemNamesObj = model.getParameters().get(UniformPasswordManager.SUCCESS_SYSTEM_NAMES);
Set<String> successSystems;
if (successSystemNamesObj instanceof Set) {
successSystems = (Set<String>) successSystemNamesObj;
} else {
successSystems = Sets.newHashSet();
}
successSystems.add(systemName);
// Create new parameters for entity state.
HashMap<String, Object> newParameters = Maps.newHashMap(model.getParameters());
newParameters.put(UniformPasswordManager.SUCCESS_SYSTEM_NAMES, successSystems);
uniformPasswordState.getResult().setModel(new DefaultResultModel(CoreResultCode.IDENTITY_UNIFORM_PASSWORD, newParameters));
}
use of eu.bcvsolutions.idm.core.api.dto.DefaultResultModel in project CzechIdMng by bcvsolutions.
the class RoleSynchronizationExecutor method initRoleRequest.
/**
* Get role-request from a cache or create new one if no exist in a cache.
*/
private void initRoleRequest(IdmIdentityContractDto primeContract, Map<UUID, UUID> roleRequestCache, SysSyncRoleConfigDto config) {
if (!roleRequestCache.containsKey(primeContract.getId())) {
IdmRoleRequestDto roleRequest = roleRequestService.createRequest(primeContract);
roleRequest.setState(RoleRequestState.CONCEPT);
OperationResultDto systemResult = new OperationResultDto.Builder(OperationState.NOT_EXECUTED).setModel(new DefaultResultModel(AccResultCode.SYNC_OF_ROLES_COMMON_ROLE_REQUEST, ImmutableMap.of("system", syncContext.getSystem().getCode()))).build();
roleRequest.setSystemState(systemResult);
roleRequest.addToLog(MessageFormat.format("Role-request created from ROLE sync with ID [{0}] on the system [{1}].", config.getId(), syncContext.getSystem().getCode()));
roleRequest = roleRequestService.save(roleRequest);
roleRequestCache.put(primeContract.getId(), roleRequest.getId());
}
}
use of eu.bcvsolutions.idm.core.api.dto.DefaultResultModel in project CzechIdMng by bcvsolutions.
the class DefaultEntityEventManager method toDto.
private IdmEntityEventDto toDto(EntityEvent<? extends Identifiable> event) {
IdmEntityEventDto entityEvent = new IdmEntityEventDto();
//
entityEvent.setResult(new OperationResultDto.Builder(OperationState.CREATED).build());
entityEvent.setInstanceId(eventConfiguration.getAsynchronousInstanceId());
if (event == null) {
entityEvent.setPriority(PriorityType.NORMAL);
return entityEvent;
}
entityEvent.setId(event.getId());
entityEvent.setSuperOwnerId(event.getSuperOwnerId());
entityEvent.setEventType(event.getType().name());
entityEvent.getProperties().putAll(event.getProperties());
entityEvent.setParent(event.getParentId());
entityEvent.setRootId(event.getRootId());
entityEvent.setParentEventType(event.getParentType());
// look out - it's the wish - when asynchronous event should be executed...
entityEvent.setExecuteDate(event.getExecuteDate());
entityEvent.setPriority(event.getPriority() != null ? event.getPriority() : PriorityType.NORMAL);
entityEvent.setContent(event.getContent());
entityEvent.setOriginalSource(event.getOriginalSource());
entityEvent.setClosed(event.isClosed());
if (entityEvent.isClosed()) {
entityEvent.setResult(new OperationResultDto.Builder(OperationState.EXECUTED).setModel(new DefaultResultModel(CoreResultCode.EVENT_ALREADY_CLOSED)).build());
}
entityEvent.setSuspended(event.isSuspended());
//
return entityEvent;
}
Aggregations