Search in sources :

Example 41 with GenericFrameworkException

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

the class SchemaExceptionHandler method handleError.

@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 {
    if (!doDiscovery) {
        parentResult.recordFatalError(ex);
        if (ex instanceof SchemaException) {
            throw (SchemaException) ex;
        } else {
            throw new SchemaException(ex.getMessage(), ex);
        }
    }
    ObjectDelta delta = null;
    switch(op) {
        case ADD:
            delta = ObjectDelta.createAddDelta(shadow.asPrismObject());
            break;
        case DELETE:
            delta = ObjectDelta.createDeleteDelta(shadow.getClass(), shadow.getOid(), prismContext);
            break;
        case MODIFY:
            Collection<? extends ItemDelta> modifications = null;
            if (shadow.getObjectChange() != null) {
                ObjectDeltaType deltaType = shadow.getObjectChange();
                modifications = DeltaConvertor.toModifications(deltaType.getItemDelta(), shadow.asPrismObject().getDefinition());
            }
            delta = ObjectDelta.createModifyDelta(shadow.getOid(), modifications, shadow.getClass(), prismContext);
            break;
    }
    if (op != FailedOperation.GET) {
        //			Task task = taskManager.createTaskInstance();
        ResourceOperationDescription operationDescription = createOperationDescription(shadow, ex, shadow.getResource(), delta, task, parentResult);
        changeNotificationDispatcher.notifyFailure(operationDescription, task, parentResult);
    }
    if (shadow.getOid() == null) {
        parentResult.recordFatalError("Schema violation during processing shadow: " + ObjectTypeUtil.toShortString(shadow) + ": " + ex.getMessage(), ex);
        throw new SchemaException("Schema violation during processing shadow: " + ObjectTypeUtil.toShortString(shadow) + ": " + ex.getMessage(), ex);
    }
    Collection<ItemDelta> modification = createAttemptModification(shadow, null);
    try {
        ConstraintsChecker.onShadowModifyOperation(modification);
        cacheRepositoryService.modifyObject(shadow.asPrismObject().getCompileTimeClass(), shadow.getOid(), modification, parentResult);
    } catch (Exception e) {
    //this should not happen. But if it happens, we should return original exception
    //			throw new SchemaException("Schema violation during processing shadow: "
    //					+ ObjectTypeUtil.toShortString(shadow) + ": " + ex.getMessage(), ex);
    }
    parentResult.recordFatalError("Schema violation during processing shadow: " + ObjectTypeUtil.toShortString(shadow) + ": " + ex.getMessage(), ex);
    throw new SchemaException("Schema violation during processing shadow: " + ObjectTypeUtil.toShortString(shadow) + ": " + ex.getMessage(), ex);
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) ResourceOperationDescription(com.evolveum.midpoint.provisioning.api.ResourceOperationDescription) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) GenericFrameworkException(com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException)

Example 42 with GenericFrameworkException

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

the class SecurityViolationHandler method handleError.

@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 {
    if (!doDiscovery) {
        parentResult.recordFatalError(ex);
        if (ex instanceof SecurityViolationException) {
            throw (SecurityViolationException) ex;
        } else {
            throw new SecurityViolationException(ex.getMessage(), ex);
        }
    }
    ObjectDelta delta = null;
    switch(op) {
        case ADD:
            delta = ObjectDelta.createAddDelta(shadow.asPrismObject());
            break;
        case DELETE:
            delta = ObjectDelta.createDeleteDelta(shadow.getClass(), shadow.getOid(), prismContext);
            break;
        case MODIFY:
            Collection<? extends ItemDelta> modifications = null;
            if (shadow.getObjectChange() != null) {
                ObjectDeltaType deltaType = shadow.getObjectChange();
                modifications = DeltaConvertor.toModifications(deltaType.getItemDelta(), shadow.asPrismObject().getDefinition());
            }
            delta = ObjectDelta.createModifyDelta(shadow.getOid(), modifications, shadow.getClass(), prismContext);
            break;
    }
    if (op != FailedOperation.GET) {
        //		Task task = taskManager.createTaskInstance();
        ResourceOperationDescription operationDescription = createOperationDescription(shadow, ex, shadow.getResource(), delta, task, parentResult);
        changeNotificationDispatcher.notifyFailure(operationDescription, task, parentResult);
    }
    if (shadow.getOid() == null) {
        throw new SecurityViolationException("Security violation during processing shadow " + ObjectTypeUtil.toShortString(shadow) + ": " + ex.getMessage(), ex);
    }
    Collection<ItemDelta> modification = createAttemptModification(shadow, null);
    try {
        ConstraintsChecker.onShadowModifyOperation(modification);
        cacheRepositoryService.modifyObject(shadow.asPrismObject().getCompileTimeClass(), shadow.getOid(), modification, parentResult);
    } catch (Exception e) {
    //this should not happen. But if it happens, we should return original exception
    }
    throw new SecurityViolationException("Security violation during processing shadow " + ObjectTypeUtil.toShortString(shadow) + ": " + ex.getMessage(), ex);
}
Also used : ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) ResourceOperationDescription(com.evolveum.midpoint.provisioning.api.ResourceOperationDescription) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) GenericFrameworkException(com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException)

Example 43 with GenericFrameworkException

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

the class ConnectorManager method createConfiguredConnectorInstance.

private ConnectorInstance createConfiguredConnectorInstance(ConnectorSpec connectorSpec, OperationResult result) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException {
    ConnectorType connectorType = getConnectorTypeReadOnly(connectorSpec, result);
    ConnectorFactory connectorFactory = determineConnectorFactory(connectorType);
    ConnectorInstance connector = null;
    try {
        connector = connectorFactory.createConnectorInstance(connectorType, ResourceTypeUtil.getResourceNamespace(connectorSpec.getResource()), connectorSpec.toString());
    } catch (ObjectNotFoundException e) {
        result.recordFatalError(e.getMessage(), e);
        throw new ObjectNotFoundException(e.getMessage(), e);
    }
    PrismContainerValue<ConnectorConfigurationType> connectorConfigurationVal = connectorSpec.getConnectorConfiguration().getValue();
    if (connectorConfigurationVal == null) {
        SchemaException e = new SchemaException("No connector configuration in " + connectorSpec);
        result.recordFatalError(e);
        throw e;
    }
    try {
        connector.configure(connectorConfigurationVal, result);
        ResourceSchema resourceSchema = RefinedResourceSchemaImpl.getResourceSchema(connectorSpec.getResource(), prismContext);
        Collection<Object> capabilities = ResourceTypeUtil.getNativeCapabilitiesCollection(connectorSpec.getResource().asObjectable());
        connector.initialize(resourceSchema, capabilities, ResourceTypeUtil.isCaseIgnoreAttributeNames(connectorSpec.getResource().asObjectable()), result);
        InternalMonitor.recordConnectorInstanceInitialization();
    } catch (GenericFrameworkException e) {
        // Not expected. Transform to system exception
        result.recordFatalError("Generic provisioning framework error", e);
        throw new SystemException("Generic provisioning framework error: " + e.getMessage(), e);
    } catch (CommunicationException e) {
        result.recordFatalError(e);
        throw e;
    } catch (ConfigurationException e) {
        result.recordFatalError(e);
        throw e;
    }
    // This log message should be INFO level. It happens only occasionally.
    // If it happens often, it may be an
    // indication of a problem. Therefore it is good for admin to see it.
    LOGGER.info("Created new connector instance for {}: {} v{}", connectorSpec, connectorType.getConnectorType(), connectorType.getConnectorVersion());
    return connector;
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ConnectorType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType) RefinedResourceSchema(com.evolveum.midpoint.common.refinery.RefinedResourceSchema) ResourceSchema(com.evolveum.midpoint.schema.processor.ResourceSchema) GenericFrameworkException(com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) ConnectorConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorConfigurationType) ConnectorInstance(com.evolveum.midpoint.provisioning.ucf.api.ConnectorInstance) ConnectorFactory(com.evolveum.midpoint.provisioning.ucf.api.ConnectorFactory) SystemException(com.evolveum.midpoint.util.exception.SystemException) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) PrismObject(com.evolveum.midpoint.prism.PrismObject)

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