Search in sources :

Example 41 with DefaultResultModel

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;
}
Also used : DefaultResultModel(eu.bcvsolutions.idm.core.api.dto.DefaultResultModel) OperationResultDto(eu.bcvsolutions.idm.core.api.dto.OperationResultDto) DefaultResultModel(eu.bcvsolutions.idm.core.api.dto.DefaultResultModel) ResultModel(eu.bcvsolutions.idm.core.api.dto.ResultModel) IdmMonitoringResultDto(eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringResultDto)

Example 42 with DefaultResultModel

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;
}
Also used : DefaultResultModel(eu.bcvsolutions.idm.core.api.dto.DefaultResultModel) OperationResultDto(eu.bcvsolutions.idm.core.api.dto.OperationResultDto) DefaultResultModel(eu.bcvsolutions.idm.core.api.dto.DefaultResultModel) ResultModel(eu.bcvsolutions.idm.core.api.dto.ResultModel) IdmMonitoringResultDto(eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringResultDto)

Example 43 with DefaultResultModel

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));
}
Also used : Set(java.util.Set) DefaultResultModel(eu.bcvsolutions.idm.core.api.dto.DefaultResultModel) DefaultResultModel(eu.bcvsolutions.idm.core.api.dto.DefaultResultModel) ResultModel(eu.bcvsolutions.idm.core.api.dto.ResultModel) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString)

Example 44 with DefaultResultModel

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());
    }
}
Also used : DefaultResultModel(eu.bcvsolutions.idm.core.api.dto.DefaultResultModel) IcFilterBuilder(eu.bcvsolutions.idm.ic.filter.impl.IcFilterBuilder) OperationResultDto(eu.bcvsolutions.idm.core.api.dto.OperationResultDto) IdmRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto)

Example 45 with DefaultResultModel

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;
}
Also used : DefaultResultModel(eu.bcvsolutions.idm.core.api.dto.DefaultResultModel) OperationResultDto(eu.bcvsolutions.idm.core.api.dto.OperationResultDto) IdmEntityEventDto(eu.bcvsolutions.idm.core.api.dto.IdmEntityEventDto)

Aggregations

DefaultResultModel (eu.bcvsolutions.idm.core.api.dto.DefaultResultModel)104 ResultModel (eu.bcvsolutions.idm.core.api.dto.ResultModel)52 UUID (java.util.UUID)48 OperationResultDto (eu.bcvsolutions.idm.core.api.dto.OperationResultDto)40 OperationResult (eu.bcvsolutions.idm.core.api.entity.OperationResult)35 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)25 IdmEntityStateDto (eu.bcvsolutions.idm.core.api.dto.IdmEntityStateDto)24 DefaultEventResult (eu.bcvsolutions.idm.core.api.event.DefaultEventResult)21 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)19 HashMap (java.util.HashMap)19 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)18 OperationState (eu.bcvsolutions.idm.core.api.domain.OperationState)16 IdmRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto)16 Autowired (org.springframework.beans.factory.annotation.Autowired)16 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)15 List (java.util.List)15 IdmConceptRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmConceptRoleRequestDto)14 Set (java.util.Set)14 ImmutableMap (com.google.common.collect.ImmutableMap)13 CoreResultCode (eu.bcvsolutions.idm.core.api.domain.CoreResultCode)13