Search in sources :

Example 51 with ConfigurationException

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

the class AbstractManagedConnectorInstance method applyConfigurationToConfigurationClass.

private void applyConfigurationToConfigurationClass(PrismContainerValue<?> configurationContainer) throws ConfigurationException {
    BeanWrapper connectorBean = new BeanWrapperImpl(this);
    PropertyDescriptor connectorConfigurationProp = UcfUtil.findAnnotatedProperty(connectorBean, ManagedConnectorConfiguration.class);
    if (connectorConfigurationProp == null) {
        return;
    }
    Class<?> configurationClass = connectorConfigurationProp.getPropertyType();
    Object configurationObject;
    try {
        configurationObject = configurationClass.newInstance();
    } catch (InstantiationException | IllegalAccessException e) {
        throw new ConfigurationException("Cannot instantiate configuration " + configurationClass);
    }
    BeanWrapper configurationClassBean = new BeanWrapperImpl(configurationObject);
    for (Item<?, ?> configurationItem : configurationContainer.getItems()) {
        if (!(configurationItem instanceof PrismProperty<?>)) {
            throw new ConfigurationException("Only properties are supported for now");
        }
        PrismProperty<?> configurationProperty = (PrismProperty<?>) configurationItem;
        Object realValue = configurationProperty.getRealValue();
        configurationClassBean.setPropertyValue(configurationProperty.getElementName().getLocalPart(), realValue);
    }
    connectorBean.setPropertyValue(connectorConfigurationProp.getName(), configurationObject);
}
Also used : BeanWrapper(org.springframework.beans.BeanWrapper) PrismProperty(com.evolveum.midpoint.prism.PrismProperty) BeanWrapperImpl(org.springframework.beans.BeanWrapperImpl) PropertyDescriptor(java.beans.PropertyDescriptor) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException)

Example 52 with ConfigurationException

use of com.evolveum.midpoint.util.exception.ConfigurationException 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 53 with ConfigurationException

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

the class TestOpenDjNegative method test111GetObjectShadow.

/**
	 * This is using the shadow to go to the resource. But it cannot as OpenDJ is down.
	 * It even cannot fetch schema. If there is no schema it does not even know how to process
	 * identifiers in the shadow. Therefore the expected result is ConfigurationException (CommunicationException).
	 * It must not be ObjectNotFound as we do NOT know that the shadow does not exist. 
	 */
@Test
public void test111GetObjectShadow() throws Exception {
    final String TEST_NAME = "test111GetObjectShadow";
    TestUtil.displayTestTile(TEST_NAME);
    OperationResult result = new OperationResult(TestOpenDjNegative.class.getName() + "." + TEST_NAME);
    try {
        ShadowType acct = provisioningService.getObject(ShadowType.class, ACCOUNT_JBOND_OID, null, taskManager.createTaskInstance(), result).asObjectable();
        AssertJUnit.fail("getObject succeeded unexpectedly");
    //		} catch (CommunicationException e) {
    } catch (ConfigurationException e) {
        // This is expected
        display("Expected exception", e);
    }
    result.computeStatus();
    TestUtil.assertFailure(result);
}
Also used : ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test)

Example 54 with ConfigurationException

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

the class TestOpenDjNegative method test130AddAccountWill.

@Test
public void test130AddAccountWill() throws Exception {
    final String TEST_NAME = "test130AddAccountWill";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    OperationResult result = new OperationResult(TestOpenDjNegative.class.getName() + "." + TEST_NAME);
    ShadowType object = parseObjectType(ACCOUNT_WILL_FILE, ShadowType.class);
    display("Account to add", object);
    try {
        // WHEN
        String addedObjectOid = provisioningService.addObject(object.asPrismObject(), null, null, taskManager.createTaskInstance(), result);
        AssertJUnit.fail("addObject succeeded unexpectedly");
    } catch (ConfigurationException e) {
        // This is expected
        display("Expected exception", e);
    }
    result.computeStatus();
    TestUtil.assertFailure(result);
}
Also used : ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test)

Example 55 with ConfigurationException

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

the class ConnectorInstanceConnIdImpl method initialize.

@Override
public void initialize(ResourceSchema resourceSchema, Collection<Object> capabilities, boolean caseIgnoreAttributeNames, OperationResult parentResult) throws CommunicationException, GenericFrameworkException, ConfigurationException {
    // Result type for this operation
    OperationResult result = parentResult.createSubresult(ConnectorInstance.OPERATION_INITIALIZE);
    result.addContext("connector", connectorType);
    result.addContext(OperationResult.CONTEXT_IMPLEMENTATION_CLASS, ConnectorFactoryConnIdImpl.class);
    if (connIdConnectorFacade == null) {
        result.recordFatalError("Attempt to use unconfigured connector");
        throw new IllegalStateException("Attempt to use unconfigured connector " + ObjectTypeUtil.toShortString(connectorType));
    }
    setResourceSchema(resourceSchema);
    this.capabilities = capabilities;
    this.caseIgnoreAttributeNames = caseIgnoreAttributeNames;
    if (resourceSchema != null && legacySchema == null) {
        legacySchema = detectLegacySchema(resourceSchema);
    }
    if (resourceSchema == null || capabilities == null) {
        try {
            boolean supportsSchema = processOperationCapabilities(result);
            if (supportsSchema) {
                retrieveResourceSchema(null, result);
            }
        } catch (CommunicationException ex) {
            // This is in fact fatal. There is not schema. Not even the pre-cached one. 
            // The connector will not be able to work.
            result.recordFatalError(ex);
            throw ex;
        } catch (ConfigurationException ex) {
            result.recordFatalError(ex);
            throw ex;
        } catch (GenericFrameworkException ex) {
            result.recordFatalError(ex);
            throw ex;
        }
    }
    result.recordSuccess();
}
Also used : CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) GenericFrameworkException(com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) AsynchronousOperationResult(com.evolveum.midpoint.schema.result.AsynchronousOperationResult)

Aggregations

ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)110 CommunicationException (com.evolveum.midpoint.util.exception.CommunicationException)86 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)84 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)81 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)81 ExpressionEvaluationException (com.evolveum.midpoint.util.exception.ExpressionEvaluationException)71 SecurityViolationException (com.evolveum.midpoint.util.exception.SecurityViolationException)65 ObjectAlreadyExistsException (com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)35 PrismObject (com.evolveum.midpoint.prism.PrismObject)33 SystemException (com.evolveum.midpoint.util.exception.SystemException)29 Task (com.evolveum.midpoint.task.api.Task)27 GenericFrameworkException (com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException)26 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)25 PolicyViolationException (com.evolveum.midpoint.util.exception.PolicyViolationException)24 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)20 QName (javax.xml.namespace.QName)20 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)18 ArrayList (java.util.ArrayList)15 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)13 SelectorOptions (com.evolveum.midpoint.schema.SelectorOptions)13