Search in sources :

Example 11 with GenericFrameworkException

use of com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException in project midpoint by Evolveum.

the class GenericErrorHandler method handleError.

//	@Autowired
//	private OperationFinisher operationFinisher;
@Override
public <T extends ShadowType> T handleError(T shadow, FailedOperation op, Exception ex, boolean doDiscovery, boolean compensate, Task task, OperationResult parentResult) throws SchemaException, GenericFrameworkException, CommunicationException, ObjectNotFoundException, ObjectAlreadyExistsException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException {
    if (!doDiscovery) {
        parentResult.recordFatalError(ex);
        if (ex instanceof GenericFrameworkException) {
            throw (GenericFrameworkException) ex;
        } else {
            throw new GenericFrameworkException(ex.getMessage(), ex);
        }
    }
    //		OperationResult result = OperationResult.createOperationResult(shadow.getResult());
    String operation = (shadow.getFailedOperationType() == null ? "null" : shadow.getFailedOperationType().name());
    OperationResult result = parentResult.createSubresult(COMPENSATE_OPERATION);
    result.addContext("compensatedOperation", operation);
    result.addContext("operationType", op.name());
    result.addParam("shadow", shadow);
    result.addParam("currentOperation", op);
    result.addParam("reconciled", true);
    switch(op) {
        case GET:
            if (ShadowUtil.isDead(shadow) || ResourceTypeUtil.isDown(shadow.getResource()) || !compensate) {
                result.recordStatus(OperationResultStatus.PARTIAL_ERROR, "Unable to get object from the resource. Probably it has not been created yet because of previous unavailability of the resource.");
                result.computeStatus();
                shadow.setFetchResult(parentResult.createOperationResultType());
                return shadow;
            }
            if (shadow.getFailedOperationType() == null) {
                String message = "Generic error in the connector. Can't process shadow " + ObjectTypeUtil.toShortString(shadow) + ": " + ex.getMessage();
                result.recordFatalError(message, ex);
                throw new GenericFrameworkException(message, ex);
            }
            try {
                //ProvisioningOperationOptions.createCompletePostponed(false);
                provisioningService.refreshShadow(shadow.asPrismObject(), null, task, result);
                result.computeStatus();
                if (result.isSuccess()) {
                    LOGGER.trace("Postponed operation was finished successfully while getting shadow. Getting new object.");
                    PrismObject prismShadow = provisioningService.getObject(shadow.getClass(), shadow.getOid(), null, task, result);
                    if (!prismShadow.hasCompleteDefinition()) {
                        LOGGER.trace("applying definitions to shadow");
                        provisioningService.applyDefinition(prismShadow, task, result);
                    }
                    if (LOGGER.isTraceEnabled()) {
                        LOGGER.trace("Got {} after finishing postponed operation.", prismShadow.debugDump());
                    }
                    shadow = (T) prismShadow.asObjectable();
                }
            //				} catch(Exception e){
            //					result.recordFatalError("Could not finish operation " + operation + ". Reason: " + e.getMessage()));
            //					// just throw the origin exception
            //					throw new GenericFrameworkException(ex);
            } finally {
                result.computeStatus();
            }
            return shadow;
        case MODIFY:
            if (shadow.getFailedOperationType() == null) {
                String message = "Generic error in the connector. Can't process shadow " + ObjectTypeUtil.toShortString(shadow) + ". ";
                result.recordFatalError(message, ex);
                throw new GenericFrameworkException(message, ex);
            }
            // get the modifications from the shadow before the account
            // is created, because after successful creation of account,
            // the modification will be lost
            Collection<? extends ItemDelta> modifications = null;
            if (shadow.getObjectChange() != null) {
                ObjectDeltaType deltaType = shadow.getObjectChange();
                modifications = DeltaConvertor.toModifications(deltaType.getItemDelta(), shadow.asPrismObject().getDefinition());
            }
            PropertyDelta.applyTo(modifications, shadow.asPrismObject());
            provisioningService.refreshShadow(shadow.asPrismObject(), null, task, result);
            result.computeStatus();
            if (!result.isSuccess()) {
                // account wasn't created, probably resource is
                // still down, or there is other reason.just save the
                // pending modifications to the shadow in the
                // repository..next time by processing this shadow, we can try again
                // TODO: probably there is a need to union current changes with previous
                ConstraintsChecker.onShadowModifyOperation(modifications);
                cacheRepositoryService.modifyObject(ShadowType.class, shadow.getOid(), modifications, result);
                result.recordHandledError("Modifications not applied to the object, because resource is unreachable. They are stored to the shadow and will be applied when the resource goes online.");
            }
            return shadow;
        case DELETE:
            cacheRepositoryService.deleteObject(shadow.getClass(), shadow.getOid(), result);
            result.recordStatus(OperationResultStatus.HANDLED_ERROR, "Object has been not created on the resource yet. Shadow deleted from the repository");
            return shadow;
        default:
            result.recordFatalError("Can't process " + ObjectTypeUtil.toShortString(shadow) + ": " + ex.getMessage(), ex);
            if (shadow.getOid() == null) {
                throw new GenericFrameworkException("Can't process " + ObjectTypeUtil.toShortString(shadow) + ": " + ex.getMessage(), ex);
            }
            Collection<ItemDelta> modification = createAttemptModification(shadow, null);
            ConstraintsChecker.onShadowModifyOperation(modification);
            cacheRepositoryService.modifyObject(shadow.asPrismObject().getCompileTimeClass(), shadow.getOid(), modification, parentResult);
            String message = "Can't process " + ObjectTypeUtil.toShortString(shadow) + ". ";
            result.recordFatalError(message, ex);
            throw new GenericFrameworkException(message, ex);
    }
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) GenericFrameworkException(com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta)

Example 12 with GenericFrameworkException

use of com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException in project midpoint by Evolveum.

the class ResourceManager method testConnectionConnector.

public void testConnectionConnector(ConnectorSpec connectorSpec, Map<String, Collection<Object>> capabilityMap, Task task, OperationResult parentResult) {
    // === test INITIALIZATION ===
    OperationResult initResult = parentResult.createSubresult(ConnectorTestOperation.CONNECTOR_INITIALIZATION.getOperation());
    ConnectorInstance connector;
    try {
        // TODO: this returns configured instance. Then there is another configuration down below.
        // this means double configuration of the connector. TODO: clean this up
        connector = connectorManager.getConfiguredConnectorInstance(connectorSpec, true, initResult);
        initResult.recordSuccess();
    } catch (ObjectNotFoundException e) {
        // The connector was not found. The resource definition is either
        // wrong or the connector is not
        // installed.
        modifyResourceAvailabilityStatus(connectorSpec.getResource(), AvailabilityStatusType.BROKEN, parentResult);
        initResult.recordFatalError("The connector was not found: " + e.getMessage(), e);
        return;
    } catch (SchemaException e) {
        modifyResourceAvailabilityStatus(connectorSpec.getResource(), AvailabilityStatusType.BROKEN, parentResult);
        initResult.recordFatalError("Schema error while dealing with the connector definition: " + e.getMessage(), e);
        return;
    } catch (RuntimeException | Error e) {
        modifyResourceAvailabilityStatus(connectorSpec.getResource(), AvailabilityStatusType.BROKEN, parentResult);
        initResult.recordFatalError("Unexpected runtime error: " + e.getMessage(), e);
        return;
    } catch (CommunicationException e) {
        modifyResourceAvailabilityStatus(connectorSpec.getResource(), AvailabilityStatusType.BROKEN, parentResult);
        initResult.recordFatalError("Communication error: " + e.getMessage(), e);
        return;
    } catch (ConfigurationException e) {
        modifyResourceAvailabilityStatus(connectorSpec.getResource(), AvailabilityStatusType.BROKEN, parentResult);
        initResult.recordFatalError("Configuration error: " + e.getMessage(), e);
        return;
    }
    LOGGER.debug("Testing connection using {}", connectorSpec);
    // === test CONFIGURATION ===
    OperationResult configResult = parentResult.createSubresult(ConnectorTestOperation.CONNECTOR_CONFIGURATION.getOperation());
    try {
        PrismObject<ResourceType> resource = connectorSpec.getResource();
        PrismObjectDefinition<ResourceType> newResourceDefinition = resource.getDefinition().clone();
        applyConnectorSchemaToResource(connectorSpec, newResourceDefinition, resource, task, configResult);
        PrismContainerValue<ConnectorConfigurationType> connectorConfiguration = connectorSpec.getConnectorConfiguration().getValue();
        connector.configure(connectorConfiguration, configResult);
        configResult.recordSuccess();
    } catch (CommunicationException e) {
        modifyResourceAvailabilityStatus(connectorSpec.getResource(), AvailabilityStatusType.BROKEN, parentResult);
        configResult.recordFatalError("Communication error", e);
        return;
    } catch (GenericFrameworkException e) {
        modifyResourceAvailabilityStatus(connectorSpec.getResource(), AvailabilityStatusType.BROKEN, parentResult);
        configResult.recordFatalError("Generic error", e);
        return;
    } catch (SchemaException e) {
        modifyResourceAvailabilityStatus(connectorSpec.getResource(), AvailabilityStatusType.BROKEN, parentResult);
        configResult.recordFatalError("Schema error", e);
        return;
    } catch (ConfigurationException e) {
        modifyResourceAvailabilityStatus(connectorSpec.getResource(), AvailabilityStatusType.BROKEN, parentResult);
        configResult.recordFatalError("Configuration error", e);
        return;
    } catch (ObjectNotFoundException e) {
        modifyResourceAvailabilityStatus(connectorSpec.getResource(), AvailabilityStatusType.BROKEN, parentResult);
        configResult.recordFatalError("Object not found", e);
        return;
    } catch (ExpressionEvaluationException e) {
        modifyResourceAvailabilityStatus(connectorSpec.getResource(), AvailabilityStatusType.BROKEN, parentResult);
        configResult.recordFatalError("Expression error", e);
        return;
    } catch (RuntimeException | Error e) {
        modifyResourceAvailabilityStatus(connectorSpec.getResource(), AvailabilityStatusType.BROKEN, parentResult);
        configResult.recordFatalError("Unexpected runtime error", e);
        return;
    }
    // === test CONNECTION ===
    // delegate the main part of the test to the connector
    connector.test(parentResult);
    parentResult.computeStatus();
    if (!parentResult.isAcceptable()) {
        modifyResourceAvailabilityStatus(connectorSpec.getResource(), AvailabilityStatusType.DOWN, parentResult);
        // messages.
        return;
    } else {
        modifyResourceAvailabilityStatus(connectorSpec.getResource(), AvailabilityStatusType.UP, parentResult);
    }
    OperationResult capabilitiesResult = parentResult.createSubresult(ConnectorTestOperation.CONNECTOR_CAPABILITIES.getOperation());
    try {
        InternalMonitor.recordConnectorCapabilitiesFetchCount();
        Collection<Object> capabilities = connector.fetchCapabilities(capabilitiesResult);
        capabilityMap.put(connectorSpec.getConnectorName(), capabilities);
        capabilitiesResult.recordSuccess();
    } catch (CommunicationException e) {
        modifyResourceAvailabilityStatus(connectorSpec.getResource(), AvailabilityStatusType.BROKEN, parentResult);
        capabilitiesResult.recordFatalError("Communication error", e);
        return;
    } catch (GenericFrameworkException e) {
        modifyResourceAvailabilityStatus(connectorSpec.getResource(), AvailabilityStatusType.BROKEN, parentResult);
        capabilitiesResult.recordFatalError("Generic error", e);
        return;
    } catch (ConfigurationException e) {
        modifyResourceAvailabilityStatus(connectorSpec.getResource(), AvailabilityStatusType.BROKEN, parentResult);
        capabilitiesResult.recordFatalError("Configuration error", e);
        return;
    } catch (RuntimeException | Error e) {
        modifyResourceAvailabilityStatus(connectorSpec.getResource(), AvailabilityStatusType.BROKEN, parentResult);
        capabilitiesResult.recordFatalError("Unexpected runtime error", e);
        return;
    }
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) GenericFrameworkException(com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) ConnectorConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorConfigurationType) ConnectorInstance(com.evolveum.midpoint.provisioning.ucf.api.ConnectorInstance) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException)

Example 13 with GenericFrameworkException

use of com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException in project midpoint by Evolveum.

the class ResourceManager method testConnection.

public void testConnection(PrismObject<ResourceType> resource, Task task, OperationResult parentResult) {
    List<ConnectorSpec> allConnectorSpecs;
    try {
        allConnectorSpecs = getAllConnectorSpecs(resource);
    } catch (SchemaException e) {
        modifyResourceAvailabilityStatus(resource, AvailabilityStatusType.BROKEN, parentResult);
        parentResult.recordFatalError("Configuration error: " + e.getMessage(), e);
        return;
    }
    Map<String, Collection<Object>> capabilityMap = new HashMap<>();
    for (ConnectorSpec connectorSpec : allConnectorSpecs) {
        OperationResult connectorTestResult = parentResult.createSubresult(ConnectorTestOperation.CONNECTOR_TEST.getOperation());
        connectorTestResult.addParam(OperationResult.PARAM_NAME, connectorSpec.getConnectorName());
        connectorTestResult.addParam(OperationResult.PARAM_OID, connectorSpec.getConnectorOid());
        testConnectionConnector(connectorSpec, capabilityMap, task, connectorTestResult);
        connectorTestResult.computeStatus();
    }
    // === test SCHEMA ===
    OperationResult schemaResult = parentResult.createSubresult(ConnectorTestOperation.RESOURCE_SCHEMA.getOperation());
    ResourceSchema schema = null;
    try {
        schema = fetchResourceSchema(resource, capabilityMap, task, schemaResult);
    } catch (CommunicationException e) {
        modifyResourceAvailabilityStatus(resource, AvailabilityStatusType.BROKEN, parentResult);
        schemaResult.recordFatalError("Communication error: " + e.getMessage(), e);
        return;
    } catch (GenericFrameworkException e) {
        modifyResourceAvailabilityStatus(resource, AvailabilityStatusType.BROKEN, parentResult);
        schemaResult.recordFatalError("Generic error: " + e.getMessage(), e);
        return;
    } catch (ConfigurationException e) {
        modifyResourceAvailabilityStatus(resource, AvailabilityStatusType.BROKEN, parentResult);
        schemaResult.recordFatalError("Configuration error: " + e.getMessage(), e);
        return;
    } catch (ObjectNotFoundException e) {
        modifyResourceAvailabilityStatus(resource, AvailabilityStatusType.BROKEN, parentResult);
        schemaResult.recordFatalError("Configuration error: " + e.getMessage(), e);
        return;
    } catch (SchemaException e) {
        modifyResourceAvailabilityStatus(resource, AvailabilityStatusType.BROKEN, parentResult);
        schemaResult.recordFatalError("Configuration error: " + e.getMessage(), e);
        return;
    }
    if (schema == null || schema.isEmpty()) {
        // If there is a static schema in resource definition this may still be OK
        try {
            schema = RefinedResourceSchemaImpl.getResourceSchema(resource, prismContext);
        } catch (SchemaException e) {
            modifyResourceAvailabilityStatus(resource, AvailabilityStatusType.BROKEN, parentResult);
            schemaResult.recordFatalError(e);
            return;
        }
        if (schema == null || schema.isEmpty()) {
            modifyResourceAvailabilityStatus(resource, AvailabilityStatusType.BROKEN, parentResult);
            schemaResult.recordFatalError("Connector does not support schema and no static schema available");
            return;
        }
    }
    // capability.
    try {
        resource = completeResource(resource, schema, true, capabilityMap, null, task, schemaResult);
    } catch (ObjectNotFoundException e) {
        modifyResourceAvailabilityStatus(resource, AvailabilityStatusType.BROKEN, parentResult);
        schemaResult.recordFatalError("Object not found (unexpected error, probably a bug): " + e.getMessage(), e);
        return;
    } catch (SchemaException e) {
        modifyResourceAvailabilityStatus(resource, AvailabilityStatusType.BROKEN, parentResult);
        schemaResult.recordFatalError("Schema processing error (probably connector bug): " + e.getMessage(), e);
        return;
    } catch (CommunicationException e) {
        modifyResourceAvailabilityStatus(resource, AvailabilityStatusType.BROKEN, parentResult);
        schemaResult.recordFatalError("Communication error: " + e.getMessage(), e);
        return;
    } catch (ConfigurationException e) {
        modifyResourceAvailabilityStatus(resource, AvailabilityStatusType.BROKEN, parentResult);
        schemaResult.recordFatalError("Configuration error: " + e.getMessage(), e);
        return;
    } catch (ExpressionEvaluationException e) {
        modifyResourceAvailabilityStatus(resource, AvailabilityStatusType.BROKEN, parentResult);
        schemaResult.recordFatalError("Expression error: " + e.getMessage(), e);
        return;
    }
    schemaResult.recordSuccess();
// TODO: connector sanity (e.g. refined schema, at least one account type, identifiers
// in schema, etc.)
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) GenericFrameworkException(com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException) HashMap(java.util.HashMap) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) Collection(java.util.Collection)

Example 14 with GenericFrameworkException

use of com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException in project midpoint by Evolveum.

the class EntitlementConverter method postProcessEntitlementEntitlementToSubject.

private <S extends ShadowType, T> void postProcessEntitlementEntitlementToSubject(ProvisioningContext subjectCtx, final PrismObject<S> resourceObject, RefinedAssociationDefinition assocDefType, final ProvisioningContext entitlementCtx, ResourceAttributeContainer attributesContainer, final PrismContainer<ShadowAssociationType> associationContainer, OperationResult parentResult) throws SchemaException, CommunicationException, ObjectNotFoundException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException {
    ResourceType resourceType = subjectCtx.getResource();
    final QName associationName = assocDefType.getName();
    final RefinedObjectClassDefinition entitlementDef = entitlementCtx.getObjectClassDefinition();
    if (associationName == null) {
        throw new SchemaException("No name in entitlement association " + assocDefType + " in " + resourceType);
    }
    QName associationAuxiliaryObjectClass = assocDefType.getAuxiliaryObjectClass();
    if (associationAuxiliaryObjectClass != null && associationAuxiliaryObjectClass.getNamespaceURI() != null && !associationAuxiliaryObjectClass.getNamespaceURI().equals(ResourceTypeUtil.getResourceNamespace(resourceType))) {
        LOGGER.warn("Auxiliary object class {} in association {} does not have namespace that matches {}", associationAuxiliaryObjectClass, assocDefType.getName(), resourceType);
    }
    if (associationAuxiliaryObjectClass != null && !subjectCtx.getObjectClassDefinition().hasAuxiliaryObjectClass(associationAuxiliaryObjectClass)) {
        LOGGER.trace("Ignoring association {} because subject does not have auxiliary object class {}, it has {}", associationName, associationAuxiliaryObjectClass, subjectCtx.getObjectClassDefinition().getAuxiliaryObjectClassDefinitions());
        return;
    }
    QName assocAttrName = assocDefType.getResourceObjectAssociationType().getAssociationAttribute();
    if (assocAttrName == null) {
        throw new SchemaException("No association attribute defined in entitlement association '" + associationName + "' in " + resourceType);
    }
    RefinedAttributeDefinition assocAttrDef = entitlementDef.findAttributeDefinition(assocAttrName);
    if (assocAttrDef == null) {
        throw new SchemaException("Association attribute '" + assocAttrName + "'defined in entitlement association '" + associationName + "' was not found in schema for " + resourceType);
    }
    QName valueAttrName = assocDefType.getResourceObjectAssociationType().getValueAttribute();
    if (valueAttrName == null) {
        throw new SchemaException("No value attribute defined in entitlement association '" + associationName + "' in " + resourceType);
    }
    ResourceAttribute<T> valueAttr = attributesContainer.findAttribute(valueAttrName);
    if (valueAttr == null || valueAttr.isEmpty()) {
        LOGGER.trace("Ignoring association {} because subject does not have any value in attribute {}", associationName, valueAttrName);
        return;
    }
    if (valueAttr.size() > 1) {
        throw new SchemaException("Value attribute " + valueAttrName + " has no more than one value; attribute defined in entitlement association '" + associationName + "' in " + resourceType);
    }
    ObjectQuery query = createQuery(assocDefType, assocAttrDef, valueAttr);
    AttributesToReturn attributesToReturn = ProvisioningUtil.createAttributesToReturn(entitlementCtx);
    SearchHierarchyConstraints searchHierarchyConstraints = null;
    ResourceObjectReferenceType baseContextRef = entitlementDef.getBaseContext();
    if (baseContextRef != null) {
        // TODO: this should be done once per search. Not in every run of postProcessEntitlementEntitlementToSubject
        // this has to go outside of this method
        PrismObject<ShadowType> baseContextShadow = resourceObjectReferenceResolver.resolve(subjectCtx, baseContextRef, null, "base context specification in " + entitlementDef, parentResult);
        RefinedObjectClassDefinition baseContextObjectClassDefinition = subjectCtx.getRefinedSchema().determineCompositeObjectClassDefinition(baseContextShadow);
        ResourceObjectIdentification baseContextIdentification = ShadowUtil.getResourceObjectIdentification(baseContextShadow, baseContextObjectClassDefinition);
        searchHierarchyConstraints = new SearchHierarchyConstraints(baseContextIdentification, null);
    }
    ResultHandler<ShadowType> handler = new ResultHandler<ShadowType>() {

        @Override
        public boolean handle(PrismObject<ShadowType> entitlementShadow) {
            PrismContainerValue<ShadowAssociationType> associationCVal = associationContainer.createNewValue();
            associationCVal.asContainerable().setName(associationName);
            Collection<ResourceAttribute<?>> entitlementIdentifiers = ShadowUtil.getAllIdentifiers(entitlementShadow);
            try {
                ResourceAttributeContainer identifiersContainer = new ResourceAttributeContainer(ShadowAssociationType.F_IDENTIFIERS, entitlementDef.toResourceAttributeContainerDefinition(), prismContext);
                associationCVal.add(identifiersContainer);
                identifiersContainer.getValue().addAll(ResourceAttribute.cloneCollection(entitlementIdentifiers));
                // Remember the full shadow in user data. This is used later as an optimization to create the shadow in repo 
                identifiersContainer.setUserData(ResourceObjectConverter.FULL_SHADOW_KEY, entitlementShadow);
                if (LOGGER.isTraceEnabled()) {
                    LOGGER.trace("Processed entitlement-to-subject association for account {} and entitlement {}", ShadowUtil.getHumanReadableName(resourceObject), ShadowUtil.getHumanReadableName(entitlementShadow));
                }
            } catch (SchemaException e) {
                throw new TunnelException(e);
            }
            return true;
        }
    };
    ConnectorInstance connector = subjectCtx.getConnector(ReadCapabilityType.class, parentResult);
    try {
        if (LOGGER.isTraceEnabled()) {
            LOGGER.trace("Processed entitlement-to-subject association for account {}: query {}", ShadowUtil.getHumanReadableName(resourceObject), query);
        }
        try {
            connector.search(entitlementDef, query, handler, attributesToReturn, null, searchHierarchyConstraints, subjectCtx, parentResult);
        } catch (GenericFrameworkException e) {
            throw new GenericConnectorException("Generic error in the connector " + connector + ". Reason: " + e.getMessage(), e);
        }
    } catch (TunnelException e) {
        throw (SchemaException) e.getCause();
    }
}
Also used : AttributesToReturn(com.evolveum.midpoint.provisioning.ucf.api.AttributesToReturn) ResourceAttributeContainer(com.evolveum.midpoint.schema.processor.ResourceAttributeContainer) ResultHandler(com.evolveum.midpoint.provisioning.ucf.api.ResultHandler) PrismObject(com.evolveum.midpoint.prism.PrismObject) TunnelException(com.evolveum.midpoint.util.exception.TunnelException) SearchHierarchyConstraints(com.evolveum.midpoint.schema.processor.SearchHierarchyConstraints) ResourceObjectIdentification(com.evolveum.midpoint.schema.processor.ResourceObjectIdentification) GenericConnectorException(com.evolveum.midpoint.provisioning.api.GenericConnectorException) ResourceObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectReferenceType) ResourceAttribute(com.evolveum.midpoint.schema.processor.ResourceAttribute) ShadowAssociationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowAssociationType) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) GenericFrameworkException(com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException) QName(javax.xml.namespace.QName) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) ConnectorInstance(com.evolveum.midpoint.provisioning.ucf.api.ConnectorInstance)

Example 15 with GenericFrameworkException

use of com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException in project midpoint by Evolveum.

the class ProvisioningServiceImpl method synchronize.

@SuppressWarnings("rawtypes")
@Override
public int synchronize(ResourceShadowDiscriminator shadowCoordinates, Task task, OperationResult parentResult) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException {
    Validate.notNull(shadowCoordinates, "Coordinates oid must not be null.");
    String resourceOid = shadowCoordinates.getResourceOid();
    Validate.notNull(resourceOid, "Resource oid must not be null.");
    Validate.notNull(task, "Task must not be null.");
    Validate.notNull(parentResult, "Operation result must not be null.");
    OperationResult result = parentResult.createSubresult(ProvisioningService.class.getName() + ".synchronize");
    result.addParam(OperationResult.PARAM_OID, resourceOid);
    result.addParam(OperationResult.PARAM_TASK, task.toString());
    int processedChanges = 0;
    try {
        // Resolve resource
        PrismObject<ResourceType> resource = getObject(ResourceType.class, resourceOid, null, task, result);
        ResourceType resourceType = resource.asObjectable();
        LOGGER.trace("**PROVISIONING: Start synchronization of resource {} ", resourceType);
        // getting token form task
        PrismProperty tokenProperty = getTokenProperty(shadowCoordinates, task, result);
        if (LOGGER.isTraceEnabled()) {
            LOGGER.trace("**PROVISIONING: Got token property: {} from the task extension.", SchemaDebugUtil.prettyPrint(tokenProperty));
        }
        processedChanges = getShadowCache(Mode.STANDARD).synchronize(shadowCoordinates, tokenProperty, task, result);
        LOGGER.debug("Synchronization of {} done, token {}, {} changes", resource, tokenProperty, processedChanges);
    } catch (ObjectNotFoundException e) {
        ProvisioningUtil.recordFatalError(LOGGER, result, "Synchronization error: object not found: " + e.getMessage(), e);
        throw e;
    } catch (CommunicationException e) {
        ProvisioningUtil.recordFatalError(LOGGER, result, "Synchronization error: communication problem: " + e.getMessage(), e);
        throw e;
    } catch (ObjectAlreadyExistsException e) {
        ProvisioningUtil.recordFatalError(LOGGER, result, "Synchronization error: object already exists problem: " + e.getMessage(), e);
        throw new SystemException(e);
    } catch (GenericFrameworkException e) {
        ProvisioningUtil.recordFatalError(LOGGER, result, "Synchronization error: generic connector framework error: " + e.getMessage(), e);
        throw new GenericConnectorException(e.getMessage(), e);
    } catch (SchemaException e) {
        ProvisioningUtil.recordFatalError(LOGGER, result, "Synchronization error: schema problem: " + e.getMessage(), e);
        throw e;
    } catch (SecurityViolationException e) {
        ProvisioningUtil.recordFatalError(LOGGER, result, "Synchronization error: security violation: " + e.getMessage(), e);
        throw e;
    } catch (ConfigurationException e) {
        ProvisioningUtil.recordFatalError(LOGGER, result, "Synchronization error: configuration problem: " + e.getMessage(), e);
        throw e;
    } catch (RuntimeException e) {
        ProvisioningUtil.recordFatalError(LOGGER, result, "Synchronization error: unexpected problem: " + e.getMessage(), e);
        throw e;
    } catch (ExpressionEvaluationException e) {
        ProvisioningUtil.recordFatalError(LOGGER, result, "Synchronization error: expression error: " + e.getMessage(), e);
        throw e;
    }
    result.recordSuccess();
    result.cleanupResult();
    return processedChanges;
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) GenericFrameworkException(com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) LabeledString(com.evolveum.midpoint.schema.LabeledString) PrismProperty(com.evolveum.midpoint.prism.PrismProperty) SystemException(com.evolveum.midpoint.util.exception.SystemException) GenericConnectorException(com.evolveum.midpoint.provisioning.api.GenericConnectorException) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)

Aggregations

GenericFrameworkException (com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException)43 CommunicationException (com.evolveum.midpoint.util.exception.CommunicationException)33 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)29 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)28 ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)23 AsynchronousOperationResult (com.evolveum.midpoint.schema.result.AsynchronousOperationResult)20 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)20 SystemException (com.evolveum.midpoint.util.exception.SystemException)18 ObjectAlreadyExistsException (com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)13 SecurityViolationException (com.evolveum.midpoint.util.exception.SecurityViolationException)13 GuardedString (org.identityconnectors.common.security.GuardedString)9 ObjectClass (org.identityconnectors.framework.common.objects.ObjectClass)9 ConnectorInstance (com.evolveum.midpoint.provisioning.ucf.api.ConnectorInstance)8 ExpressionEvaluationException (com.evolveum.midpoint.util.exception.ExpressionEvaluationException)8 QName (javax.xml.namespace.QName)8 OperationOptionsBuilder (org.identityconnectors.framework.common.objects.OperationOptionsBuilder)8 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)7 ConnectorObject (org.identityconnectors.framework.common.objects.ConnectorObject)7 PrismObject (com.evolveum.midpoint.prism.PrismObject)6 OperationOptions (org.identityconnectors.framework.common.objects.OperationOptions)6