Search in sources :

Example 31 with CommunicationException

use of com.evolveum.midpoint.util.exception.CommunicationException in project midpoint by Evolveum.

the class CertHelper method appendStatistics.

public void appendStatistics(StringBuilder sb, AccessCertificationCampaignType campaign, Task task, OperationResult result) {
    AccessCertificationCasesStatisticsType stat;
    try {
        stat = certificationManager.getCampaignStatistics(campaign.getOid(), false, task, result);
    } catch (ObjectNotFoundException | SchemaException | SecurityViolationException | ObjectAlreadyExistsException | ExpressionEvaluationException | RuntimeException | CommunicationException | ConfigurationException e) {
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't get campaign statistics", e);
        sb.append("Couldn't get campaign statistics because of ").append(e);
        return;
    }
    int all = stat.getMarkedAsAccept() + stat.getMarkedAsRevoke() + stat.getMarkedAsReduce() + stat.getMarkedAsNotDecide() + stat.getWithoutResponse();
    sb.append("Number of cases:\t").append(all);
    sb.append("\nMarked as ACCEPT:\t").append(stat.getMarkedAsAccept());
    sb.append("\nMarked as REVOKE:\t").append(stat.getMarkedAsRevoke()).append(" (remedied: ").append(stat.getMarkedAsRevokeAndRemedied()).append(")");
    sb.append("\nMarked as REDUCE:\t").append(stat.getMarkedAsReduce()).append(" (remedied: ").append(stat.getMarkedAsReduceAndRemedied()).append(")");
    sb.append("\nMarked as NOT DECIDED:\t").append(stat.getMarkedAsNotDecide());
    sb.append("\nNo response:\t\t").append(stat.getWithoutResponse());
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) AccessCertificationCasesStatisticsType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCasesStatisticsType) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)

Example 32 with CommunicationException

use of com.evolveum.midpoint.util.exception.CommunicationException in project midpoint by Evolveum.

the class AbstractRequest method executeAndClose.

ServerResponse executeAndClose(String urlPrefix, String urlSuffix, String jsonString) throws CommunicationException, SecurityViolationException {
    try {
        logRequest(urlPrefix, urlSuffix, jsonString);
        HttpRequestBase request = createRequest(urlPrefix, urlSuffix, jsonString);
        var response = createHttpClient().execute(request, new ApacheResponseHandler());
        logResponse(response);
        processCommonExceptions(response);
        return response;
    } catch (IOException e) {
        throw new CommunicationException("Couldn't invoke ID Match service: " + e.getMessage(), e);
    } finally {
        closeHttpClient();
    }
}
Also used : HttpRequestBase(org.apache.http.client.methods.HttpRequestBase) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) IOException(java.io.IOException)

Example 33 with CommunicationException

use of com.evolveum.midpoint.util.exception.CommunicationException in project midpoint by Evolveum.

the class AssignmentProcessor method evaluateFocusMappings.

private <AH extends AssignmentHolderType> void evaluateFocusMappings(LensContext<AH> context, XMLGregorianCalendar now, LensFocusContext<AH> focusContext, DeltaSetTriple<EvaluatedAssignmentImpl<AH>> evaluatedAssignmentTriple, Task task, OperationResult parentResult) throws SchemaException, ExpressionEvaluationException, PolicyViolationException, ConfigurationException, SecurityViolationException, ObjectNotFoundException, CommunicationException {
    OperationResult result = parentResult.subresult(OP_EVALUATE_FOCUS_MAPPINGS).setMinor().build();
    try {
        LOGGER.trace("Starting evaluation of assignment-held mappings");
        ObjectDeltaObject<AH> focusOdoRelative = focusContext.getObjectDeltaObjectRelative();
        List<AssignedFocusMappingEvaluationRequest> allRequests = new ArrayList<>();
        for (EvaluatedAssignmentImpl<AH> evaluatedAssignment : evaluatedAssignmentTriple.getAllValues()) {
            allRequests.addAll(evaluatedAssignment.getFocusMappingEvaluationRequests());
        }
        FocalMappingSetEvaluation.TripleCustomizer<?, ?> customizer = (triple, abstractRequest) -> {
            if (triple == null) {
                return null;
            }
            DeltaSetTriple<ItemValueWithOrigin<PrismValue, ItemDefinition<?>>> rv = prismContext.deltaFactory().createDeltaSetTriple();
            AssignedFocusMappingEvaluationRequest request = (AssignedFocusMappingEvaluationRequest) abstractRequest;
            // noinspection unchecked
            EvaluatedAssignmentImpl<AH> evaluatedAssignment = (EvaluatedAssignmentImpl<AH>) request.getEvaluatedAssignment();
            PlusMinusZero relativeMode = request.getRelativeMode();
            Set<PlusMinusZero> presence = new HashSet<>();
            PlusMinusZero resultingMode = null;
            if (evaluatedAssignmentTriple.presentInPlusSet(evaluatedAssignment)) {
                resultingMode = PlusMinusZero.compute(PlusMinusZero.PLUS, relativeMode);
                presence.add(PlusMinusZero.PLUS);
            }
            if (evaluatedAssignmentTriple.presentInMinusSet(evaluatedAssignment)) {
                resultingMode = PlusMinusZero.compute(PlusMinusZero.MINUS, relativeMode);
                presence.add(PlusMinusZero.MINUS);
            }
            if (evaluatedAssignmentTriple.presentInZeroSet(evaluatedAssignment)) {
                resultingMode = PlusMinusZero.compute(PlusMinusZero.ZERO, relativeMode);
                presence.add(PlusMinusZero.ZERO);
            }
            LOGGER.trace("triple customizer: presence = {}, relativeMode = {}, resultingMode = {}", presence, relativeMode, resultingMode);
            if (presence.isEmpty()) {
                throw new IllegalStateException("Evaluated assignment is not present in any of plus/minus/zero sets " + "of the triple. Assignment = " + evaluatedAssignment + ", triple = " + triple);
            } else if (presence.size() > 1) {
                // TODO think about this
                throw new IllegalStateException("Evaluated assignment is present in more than one plus/minus/zero sets " + "of the triple: " + presence + ". Assignment = " + evaluatedAssignment + ", triple = " + triple);
            }
            if (resultingMode != null) {
                switch(resultingMode) {
                    case PLUS:
                        // MID-6403
                        rv.addAllToPlusSet(triple.getNonNegativeValues());
                        break;
                    case MINUS:
                        // MID-6403
                        rv.addAllToMinusSet(triple.getNonPositiveValues());
                        break;
                    case ZERO:
                        rv = triple;
                        break;
                }
            }
            return rv;
        };
        FocalMappingSetEvaluation.EvaluatedMappingConsumer mappingConsumer = (mapping, abstractRequest) -> {
            AssignedFocusMappingEvaluationRequest request = (AssignedFocusMappingEvaluationRequest) abstractRequest;
            request.getEvaluatedAssignment().addFocusMapping(mapping);
        };
        TargetObjectSpecification<AH> targetSpecification = new FixedTargetSpecification<>(focusOdoRelative.getNewObject(), true);
        MappingEvaluationEnvironment env = new MappingEvaluationEnvironment("focus mappings in assignments of " + focusContext.getHumanReadableName(), now, task);
        FocalMappingSetEvaluation<AH, AH> mappingSetEvaluation = new FocalMappingSetEvaluationBuilder<AH, AH>().context(context).evaluationRequests(allRequests).phase(null).focusOdo(focusOdoRelative).targetSpecification(targetSpecification).tripleCustomizer(customizer).mappingConsumer(mappingConsumer).iteration(focusContext.getIteration()).iterationToken(focusContext.getIterationToken()).beans(beans).env(env).result(result).build();
        mappingSetEvaluation.evaluateMappingsToTriples();
        PathKeyedMap<DeltaSetTriple<ItemValueWithOrigin<?, ?>>> focusOutputTripleMap = mappingSetEvaluation.getOutputTripleMap();
        logOutputTripleMap(focusOutputTripleMap);
        DeltaSetTripleMapConsolidation<AH> consolidation = new DeltaSetTripleMapConsolidation<>(focusOutputTripleMap, focusOdoRelative.getNewObject(), focusOdoRelative.getObjectDelta(), context::primaryFocusItemDeltaExists, null, null, focusContext.getObjectDefinition(), env, beans, context, result);
        consolidation.computeItemDeltas();
        Collection<ItemDelta<?, ?>> focusDeltas = consolidation.getItemDeltas();
        LOGGER.trace("Computed focus deltas: {}", focusDeltas);
        focusContext.swallowToSecondaryDelta(focusDeltas);
        focusContext.recompute();
    } catch (Throwable t) {
        result.recordFatalError(t.getMessage(), t);
        throw t;
    } finally {
        result.computeStatusIfUnknown();
    }
}
Also used : Autowired(org.springframework.beans.factory.annotation.Autowired) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) OperationResultStatus(com.evolveum.midpoint.schema.result.OperationResultStatus) BooleanUtils(org.apache.commons.lang.BooleanUtils) MappingFactory(com.evolveum.midpoint.model.common.mapping.MappingFactory) QNameUtil(com.evolveum.midpoint.util.QNameUtil) LensContext(com.evolveum.midpoint.model.impl.lens.LensContext) ProcessorExecution(com.evolveum.midpoint.model.impl.lens.projector.util.ProcessorExecution) com.evolveum.midpoint.prism(com.evolveum.midpoint.prism) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) ActivationComputer(com.evolveum.midpoint.common.ActivationComputer) MiscUtil(com.evolveum.midpoint.util.MiscUtil) Task(com.evolveum.midpoint.task.api.Task) Objects(java.util.Objects) ResourceShadowDiscriminator(com.evolveum.midpoint.schema.ResourceShadowDiscriminator) ComplexConstructionConsumer(com.evolveum.midpoint.model.impl.lens.projector.ComplexConstructionConsumer) SystemObjectCache(com.evolveum.midpoint.model.common.SystemObjectCache) ProvisioningService(com.evolveum.midpoint.provisioning.api.ProvisioningService) Entry(java.util.Map.Entry) com.evolveum.midpoint.prism.delta(com.evolveum.midpoint.prism.delta) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) QName(javax.xml.namespace.QName) NotNull(org.jetbrains.annotations.NotNull) ProcessorMethod(com.evolveum.midpoint.model.impl.lens.projector.util.ProcessorMethod) FocusTypeUtil(com.evolveum.midpoint.schema.util.FocusTypeUtil) ContextLoader(com.evolveum.midpoint.model.impl.lens.projector.ContextLoader) PolicyViolationException(com.evolveum.midpoint.util.exception.PolicyViolationException) java.util(java.util) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) ModelBeans(com.evolveum.midpoint.model.impl.ModelBeans) ObjectDeltaObject(com.evolveum.midpoint.prism.util.ObjectDeltaObject) EvaluatedConstructionPack(com.evolveum.midpoint.model.impl.lens.construction.EvaluatedConstructionPack) SchemaConstants(com.evolveum.midpoint.schema.constants.SchemaConstants) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Trace(com.evolveum.midpoint.util.logging.Trace) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) ModelImplUtils(com.evolveum.midpoint.model.impl.util.ModelImplUtils) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) ObjectTypeUtil(com.evolveum.midpoint.schema.util.ObjectTypeUtil) SchemaDebugUtil(com.evolveum.midpoint.schema.util.SchemaDebugUtil) MappingEvaluationEnvironment(com.evolveum.midpoint.model.common.mapping.MappingEvaluationEnvironment) com.evolveum.midpoint.model.impl.lens.projector.mappings(com.evolveum.midpoint.model.impl.lens.projector.mappings) RelationRegistry(com.evolveum.midpoint.schema.RelationRegistry) Qualifier(org.springframework.beans.factory.annotation.Qualifier) PathKeyedMap(com.evolveum.midpoint.prism.path.PathKeyedMap) ModelExecuteOptions(com.evolveum.midpoint.model.api.ModelExecuteOptions) EvaluatedAssignmentImpl(com.evolveum.midpoint.model.impl.lens.assignments.EvaluatedAssignmentImpl) EvaluatedAssignedResourceObjectConstructionImpl(com.evolveum.midpoint.model.impl.lens.construction.EvaluatedAssignedResourceObjectConstructionImpl) ProjectorProcessor(com.evolveum.midpoint.model.impl.lens.projector.ProjectorProcessor) ItemValueWithOrigin(com.evolveum.midpoint.model.impl.lens.ItemValueWithOrigin) DeltaSetTripleMapConsolidation(com.evolveum.midpoint.model.impl.lens.projector.focus.consolidation.DeltaSetTripleMapConsolidation) LensUtil(com.evolveum.midpoint.model.impl.lens.LensUtil) ConstructionProcessor(com.evolveum.midpoint.model.impl.lens.projector.ConstructionProcessor) AssignmentEvaluator(com.evolveum.midpoint.model.impl.lens.assignments.AssignmentEvaluator) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) ObjectResolver(com.evolveum.midpoint.repo.common.ObjectResolver) SynchronizationPolicyDecision(com.evolveum.midpoint.model.api.context.SynchronizationPolicyDecision) TunnelException(com.evolveum.midpoint.util.exception.TunnelException) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) ReferenceResolver(com.evolveum.midpoint.model.api.util.ReferenceResolver) Component(org.springframework.stereotype.Component) LensProjectionContext(com.evolveum.midpoint.model.impl.lens.LensProjectionContext) ItemName(com.evolveum.midpoint.prism.path.ItemName) PolicyRuleProcessor(com.evolveum.midpoint.model.impl.lens.projector.policy.PolicyRuleProcessor) LensFocusContext(com.evolveum.midpoint.model.impl.lens.LensFocusContext) TraceManager(com.evolveum.midpoint.util.logging.TraceManager) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) MappingEvaluationEnvironment(com.evolveum.midpoint.model.common.mapping.MappingEvaluationEnvironment) EvaluatedAssignmentImpl(com.evolveum.midpoint.model.impl.lens.assignments.EvaluatedAssignmentImpl) DeltaSetTripleMapConsolidation(com.evolveum.midpoint.model.impl.lens.projector.focus.consolidation.DeltaSetTripleMapConsolidation)

Example 34 with CommunicationException

use of com.evolveum.midpoint.util.exception.CommunicationException in project midpoint by Evolveum.

the class SynchronizationExpressionsEvaluator method findFocusesByCorrelationRule.

@NotNull
private <F extends FocusType> List<PrismObject<F>> findFocusesByCorrelationRule(Class<F> focusType, ShadowType currentShadow, ConditionalSearchFilterType conditionalFilter, ExpressionProfile expressionProfile, ResourceType resourceType, SystemConfigurationType configurationType, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException {
    if (!conditionalFilter.containsFilterClause()) {
        LOGGER.warn("Correlation rule for resource '{}' doesn't contain filter clause, " + "returning empty list of users.", resourceType);
        return emptyList();
    }
    ObjectQuery q;
    try {
        q = prismContext.getQueryConverter().createObjectQuery(focusType, conditionalFilter);
        q = updateFilterWithAccountValues(currentShadow, resourceType, configurationType, q, expressionProfile, "Correlation expression", task, result);
    } catch (SchemaException ex) {
        LoggingUtils.logException(LOGGER, "Couldn't convert query (simplified)\n{}.", ex, SchemaDebugUtil.prettyPrint(conditionalFilter));
        throw new SchemaException("Couldn't convert query.", ex);
    } catch (ObjectNotFoundException ex) {
        LoggingUtils.logException(LOGGER, "Couldn't convert query (simplified)\n{}.", ex, SchemaDebugUtil.prettyPrint(conditionalFilter));
        throw new ObjectNotFoundException("Couldn't convert query.", ex);
    } catch (ExpressionEvaluationException ex) {
        LoggingUtils.logException(LOGGER, "Couldn't convert query (simplified)\n{}.", ex, SchemaDebugUtil.prettyPrint(conditionalFilter));
        throw new ExpressionEvaluationException("Couldn't convert query.", ex);
    } catch (CommunicationException ex) {
        LoggingUtils.logException(LOGGER, "Couldn't convert query (simplified)\n{}.", ex, SchemaDebugUtil.prettyPrint(conditionalFilter));
        throw new CommunicationException("Couldn't convert query.", ex);
    } catch (ConfigurationException ex) {
        LoggingUtils.logException(LOGGER, "Couldn't convert query (simplified)\n{}.", ex, SchemaDebugUtil.prettyPrint(conditionalFilter));
        throw new ConfigurationException("Couldn't convert query.", ex);
    } catch (SecurityViolationException ex) {
        LoggingUtils.logException(LOGGER, "Couldn't convert query (simplified)\n{}.", ex, SchemaDebugUtil.prettyPrint(conditionalFilter));
        throw new SecurityViolationException("Couldn't convert query.", ex);
    }
    try {
        LOGGER.trace("SYNCHRONIZATION: CORRELATION: expression for results in filter\n{}", q.debugDumpLazily());
        // TODO read-only later
        return repositoryService.searchObjects(focusType, q, null, result);
    } catch (RuntimeException ex) {
        LoggingUtils.logException(LOGGER, "Couldn't search users in repository, based on filter (simplified)\n{}.", ex, q.debugDump());
        throw new SystemException("Couldn't search users in repository, based on filter (See logs).", ex);
    }
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) SystemException(com.evolveum.midpoint.util.exception.SystemException) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) NotNull(org.jetbrains.annotations.NotNull)

Example 35 with CommunicationException

use of com.evolveum.midpoint.util.exception.CommunicationException in project midpoint by Evolveum.

the class SynchronizationExpressionsEvaluator method findUserByConfirmationRule.

<F extends FocusType> List<PrismObject<F>> findUserByConfirmationRule(Class<F> focusType, List<PrismObject<F>> users, ShadowType currentShadow, ResourceType resource, SystemConfigurationType configuration, ExpressionType expression, Task task, OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException {
    List<PrismObject<F>> list = new ArrayList<>();
    for (PrismObject<F> user : users) {
        try {
            F userType = user.asObjectable();
            boolean confirmedUser = evaluateConfirmationExpression(focusType, userType, currentShadow, resource, configuration, expression, task, result);
            if (confirmedUser) {
                list.add(user);
            }
        } catch (RuntimeException ex) {
            LoggingUtils.logException(LOGGER, "Couldn't confirm user {}", ex, user.getElementName());
            throw new SystemException("Couldn't confirm user " + user.getElementName(), ex);
        } catch (ExpressionEvaluationException ex) {
            LoggingUtils.logException(LOGGER, "Couldn't confirm user {}", ex, user.getElementName());
            throw new ExpressionEvaluationException("Couldn't confirm user " + user.getElementName(), ex);
        } catch (ObjectNotFoundException ex) {
            LoggingUtils.logException(LOGGER, "Couldn't confirm user {}", ex, user.getElementName());
            throw new ObjectNotFoundException("Couldn't confirm user " + user.getElementName(), ex);
        } catch (SchemaException ex) {
            LoggingUtils.logException(LOGGER, "Couldn't confirm user {}", ex, user.getElementName());
            throw new SchemaException("Couldn't confirm user " + user.getElementName(), ex);
        } catch (CommunicationException ex) {
            LoggingUtils.logException(LOGGER, "Couldn't confirm user {}", ex, user.getElementName());
            throw new CommunicationException("Couldn't confirm user " + user.getElementName(), ex);
        } catch (ConfigurationException ex) {
            LoggingUtils.logException(LOGGER, "Couldn't confirm user {}", ex, user.getElementName());
            throw new ConfigurationException("Couldn't confirm user " + user.getElementName(), ex);
        } catch (SecurityViolationException ex) {
            LoggingUtils.logException(LOGGER, "Couldn't confirm user {}", ex, user.getElementName());
            throw new SecurityViolationException("Couldn't confirm user " + user.getElementName(), ex);
        }
    }
    LOGGER.debug("SYNCHRONIZATION: CONFIRMATION: expression for {} matched {} users.", currentShadow, list.size());
    return list;
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) ArrayList(java.util.ArrayList) SystemException(com.evolveum.midpoint.util.exception.SystemException) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException)

Aggregations

CommunicationException (com.evolveum.midpoint.util.exception.CommunicationException)105 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)90 ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)84 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)83 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)72 SecurityViolationException (com.evolveum.midpoint.util.exception.SecurityViolationException)70 ExpressionEvaluationException (com.evolveum.midpoint.util.exception.ExpressionEvaluationException)62 SystemException (com.evolveum.midpoint.util.exception.SystemException)42 GenericFrameworkException (com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException)37 ObjectAlreadyExistsException (com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)35 PrismObject (com.evolveum.midpoint.prism.PrismObject)29 Task (com.evolveum.midpoint.task.api.Task)29 PolicyViolationException (com.evolveum.midpoint.util.exception.PolicyViolationException)24 AsynchronousOperationResult (com.evolveum.midpoint.schema.result.AsynchronousOperationResult)20 Collection (java.util.Collection)17 ArrayList (java.util.ArrayList)16 QName (javax.xml.namespace.QName)16 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)13 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)13 List (java.util.List)13