Search in sources :

Example 26 with CommunicationException

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

the class ConnectorInstanceConnIdImpl method fetchCurrentToken.

@Override
public <T> PrismProperty<T> fetchCurrentToken(ObjectClassComplexTypeDefinition objectClassDef, StateReporter reporter, OperationResult parentResult) throws CommunicationException, GenericFrameworkException {
    OperationResult result = parentResult.createSubresult(ConnectorInstance.class.getName() + ".fetchCurrentToken");
    result.addParam("objectClass", objectClassDef);
    ObjectClass icfObjectClass;
    if (objectClassDef == null) {
        icfObjectClass = ObjectClass.ALL;
    } else {
        icfObjectClass = connIdNameMapper.objectClassToIcf(objectClassDef, getSchemaNamespace(), connectorType, legacySchema);
    }
    OperationResult icfResult = result.createSubresult(ConnectorFacade.class.getName() + ".sync");
    icfResult.addContext("connector", connIdConnectorFacade.getClass());
    icfResult.addArbitraryObjectAsParam("icfObjectClass", icfObjectClass);
    SyncToken syncToken = null;
    try {
        InternalMonitor.recordConnectorOperation("getLatestSyncToken");
        recordIcfOperationStart(reporter, ProvisioningOperation.ICF_GET_LATEST_SYNC_TOKEN, objectClassDef);
        syncToken = connIdConnectorFacade.getLatestSyncToken(icfObjectClass);
        recordIcfOperationEnd(reporter, ProvisioningOperation.ICF_GET_LATEST_SYNC_TOKEN, objectClassDef);
        icfResult.recordSuccess();
        icfResult.addReturn("syncToken", syncToken == null ? null : String.valueOf(syncToken.getValue()));
    } catch (Throwable ex) {
        recordIcfOperationEnd(reporter, ProvisioningOperation.ICF_GET_LATEST_SYNC_TOKEN, objectClassDef, ex);
        Throwable midpointEx = processIcfException(ex, this, icfResult);
        result.computeStatus();
        // exception
        if (midpointEx instanceof CommunicationException) {
            throw (CommunicationException) midpointEx;
        } else if (midpointEx instanceof GenericFrameworkException) {
            throw (GenericFrameworkException) midpointEx;
        } else if (midpointEx instanceof RuntimeException) {
            throw (RuntimeException) midpointEx;
        } else if (midpointEx instanceof Error) {
            throw (Error) midpointEx;
        } else {
            throw new SystemException("Got unexpected exception: " + ex.getClass().getName() + ": " + ex.getMessage(), ex);
        }
    }
    if (syncToken == null) {
        result.recordWarning("Resource have not provided a current sync token");
        return null;
    }
    PrismProperty<T> property = getToken(syncToken);
    result.recordSuccess();
    return property;
}
Also used : SyncToken(org.identityconnectors.framework.common.objects.SyncToken) ObjectClass(org.identityconnectors.framework.common.objects.ObjectClass) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) GenericFrameworkException(com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException) SystemException(com.evolveum.midpoint.util.exception.SystemException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) AsynchronousOperationResult(com.evolveum.midpoint.schema.result.AsynchronousOperationResult)

Example 27 with CommunicationException

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

the class AbstractManualConnectorInstance method deleteObject.

@Override
public AsynchronousOperationResult deleteObject(ObjectClassComplexTypeDefinition objectClass, Collection<Operation> additionalOperations, Collection<? extends ResourceAttribute<?>> identifiers, StateReporter reporter, OperationResult parentResult) throws ObjectNotFoundException, CommunicationException, GenericFrameworkException, SchemaException, ConfigurationException {
    OperationResult result = parentResult.createSubresult(OPERATION_DELETE);
    String ticketIdentifier = null;
    try {
        ticketIdentifier = createTicketDelete(objectClass, identifiers, result);
    } catch (ObjectNotFoundException | CommunicationException | GenericFrameworkException | SchemaException | ConfigurationException | RuntimeException | Error e) {
        result.recordFatalError(e);
        throw e;
    }
    result.recordInProgress();
    result.setAsynchronousOperationReference(ticketIdentifier);
    return AsynchronousOperationResult.wrap(result);
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) GenericFrameworkException(com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) AsynchronousOperationResult(com.evolveum.midpoint.schema.result.AsynchronousOperationResult)

Example 28 with CommunicationException

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

the class ApprovalSchemaHelper method prepareStage.

public void prepareStage(ApprovalStageDefinitionType stageDef, RelationResolver relationResolver, ReferenceResolver referenceResolver) {
    try {
        // resolves filters in approvers
        List<ObjectReferenceType> resolvedApprovers = new ArrayList<>();
        for (ObjectReferenceType ref : stageDef.getApproverRef()) {
            resolvedApprovers.addAll(referenceResolver.resolveReference(ref, "approver ref"));
        }
        // resolves approver relations
        resolvedApprovers.addAll(relationResolver.getApprovers(stageDef.getApproverRelation()));
        stageDef.getApproverRef().clear();
        stageDef.getApproverRef().addAll(resolvedApprovers);
        stageDef.getApproverRelation().clear();
        // default values
        if (stageDef.getOutcomeIfNoApprovers() == null) {
            stageDef.setOutcomeIfNoApprovers(ApprovalLevelOutcomeType.REJECT);
        }
        if (stageDef.getGroupExpansion() == null) {
            stageDef.setGroupExpansion(GroupExpansionType.BY_CLAIMING_WORK_ITEMS);
        }
    } catch (ExpressionEvaluationException | ObjectNotFoundException | SchemaException | CommunicationException | ConfigurationException | SecurityViolationException e) {
        // todo propagate these exceptions?
        throw new SystemException("Couldn't prepare approval schema for execution: " + e.getMessage(), e);
    }
}
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) ArrayList(java.util.ArrayList)

Example 29 with CommunicationException

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

the class AssignmentPolicyAspectPart method extractAssignmentBasedInstructions.

void extractAssignmentBasedInstructions(ObjectTreeDeltas<?> objectTreeDeltas, PrismObject<? extends FocusType> requester, List<PcpStartInstruction> instructions, ModelInvocationContext<?> ctx, OperationResult parentResult) throws SchemaException, ObjectNotFoundException {
    OperationResult result = parentResult.subresult(OP_EXTRACT_ASSIGNMENT_BASED_INSTRUCTIONS).setMinor().build();
    ApprovalProcessStartInstructionCreationTraceType trace;
    if (result.isTracingNormal(ApprovalProcessStartInstructionCreationTraceType.class)) {
        trace = new ApprovalProcessStartInstructionCreationTraceType(prismContext);
        result.addTrace(trace);
    } else {
        trace = null;
    }
    try {
        DeltaSetTriple<? extends EvaluatedAssignment<?>> evaluatedAssignmentTriple = ((LensContext<?>) ctx.modelContext).getEvaluatedAssignmentTriple();
        LOGGER.trace("Processing evaluatedAssignmentTriple:\n{}", DebugUtil.debugDumpLazily(evaluatedAssignmentTriple));
        if (evaluatedAssignmentTriple == null) {
            return;
        }
        List<PcpStartInstruction> newInstructions = new ArrayList<>();
        for (EvaluatedAssignment<?> assignmentAdded : evaluatedAssignmentTriple.union()) {
            addIgnoreNull(newInstructions, createInstructionFromAssignment(assignmentAdded, objectTreeDeltas, requester, ctx, result));
        }
        int newInstructionsCount = newInstructions.size();
        if (trace != null) {
            for (PcpStartInstruction newInstruction : newInstructions) {
                trace.getCaseRef().add(ObjectTypeUtil.createObjectRefWithFullObject(newInstruction.getCase(), prismContext));
            }
        }
        instructions.addAll(newInstructions);
        CompiledGuiProfile adminGuiConfiguration;
        try {
            adminGuiConfiguration = modelInteractionService.getCompiledGuiProfile(ctx.task, result);
        } catch (CommunicationException | ConfigurationException | SecurityViolationException | ExpressionEvaluationException e) {
            throw new SystemException(e.getMessage(), e);
        }
        Integer limit = adminGuiConfiguration.getRoleManagement() != null ? adminGuiConfiguration.getRoleManagement().getAssignmentApprovalRequestLimit() : null;
        LOGGER.trace("Assignment-related approval instructions: {}; limit is {}", newInstructionsCount, limit);
        if (limit != null && newInstructionsCount > limit) {
            // TODO think about better error reporting
            throw new IllegalStateException("Assignment approval request limit (" + limit + ") exceeded: you are trying to submit " + newInstructionsCount + " requests");
        }
        if (limit != null) {
            result.addContext("assignmentApprovalRequestLimit", limit);
        }
        result.addReturn("instructionsCreated", newInstructions.size());
    } catch (Throwable t) {
        result.recordFatalError(t);
        throw t;
    } finally {
        result.computeStatusIfUnknown();
    }
}
Also used : 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) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) LensContext(com.evolveum.midpoint.model.impl.lens.LensContext) SystemException(com.evolveum.midpoint.util.exception.SystemException) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) PcpStartInstruction(com.evolveum.midpoint.wf.impl.processors.primary.PcpStartInstruction) CompiledGuiProfile(com.evolveum.midpoint.model.api.authentication.CompiledGuiProfile)

Example 30 with CommunicationException

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

the class DiscoverConnectorsExecutor method rebindResources.

private void rebindResources(Map<String, String> rebindMap, ExecutionContext context, OperationResult result) throws ScriptExecutionException {
    List<PrismObject<ResourceType>> resources;
    try {
        resources = modelService.searchObjects(ResourceType.class, null, null, null, result);
    } catch (SchemaException | ConfigurationException | ObjectNotFoundException | CommunicationException | SecurityViolationException | ExpressionEvaluationException e) {
        throw new ScriptExecutionException("Couldn't list resources: " + e.getMessage(), e);
    }
    for (PrismObject<ResourceType> resource : resources) {
        if (resource.asObjectable().getConnectorRef() != null) {
            String connectorOid = resource.asObjectable().getConnectorRef().getOid();
            String newOid = rebindMap.get(connectorOid);
            if (newOid != null) {
                String msg = "resource " + resource + " from connector " + connectorOid + " to new one: " + newOid;
                LOGGER.info("Rebinding {}", msg);
                ReferenceDelta refDelta = prismContext.deltaFactory().reference().createModificationReplace(ResourceType.F_CONNECTOR_REF, resource.getDefinition(), newOid);
                ObjectDelta<ResourceType> objDelta = prismContext.deltaFactory().object().createModifyDelta(resource.getOid(), refDelta, ResourceType.class);
                operationsHelper.applyDelta(objDelta, context, result);
                context.println("Rebound " + msg);
            }
        }
    }
}
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) ScriptExecutionException(com.evolveum.midpoint.util.exception.ScriptExecutionException) ReferenceDelta(com.evolveum.midpoint.prism.delta.ReferenceDelta) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) 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