Search in sources :

Example 46 with ConfigurationException

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

the class ConnIdConfigurationTransformer method transformConnectorConfigurationProperties.

private void transformConnectorConfigurationProperties(ConfigurationProperties configProps, PrismContainer<?> configurationPropertiesContainer, String connectorConfNs) throws ConfigurationException, SchemaException {
    if (configurationPropertiesContainer == null || configurationPropertiesContainer.getValue() == null) {
        throw new SchemaException("No configuration properties container in " + connectorType);
    }
    int numConfingProperties = 0;
    List<QName> wrongNamespaceProperties = new ArrayList<>();
    for (PrismProperty prismProperty : configurationPropertiesContainer.getValue().getProperties()) {
        QName propertyQName = prismProperty.getElementName();
        // namespace.
        if (propertyQName.getNamespaceURI() == null || !propertyQName.getNamespaceURI().equals(connectorConfNs)) {
            LOGGER.warn("Found element with a wrong namespace ({}) in {}", propertyQName.getNamespaceURI(), connectorType);
            wrongNamespaceProperties.add(propertyQName);
        } else {
            numConfingProperties++;
            // Local name of the element is the same as the name
            // of ConnId configuration property
            String propertyName = propertyQName.getLocalPart();
            ConfigurationProperty property = configProps.getProperty(propertyName);
            if (property == null) {
                throw new ConfigurationException("Unknown configuration property " + propertyName);
            }
            Class<?> type = property.getType();
            if (type.isArray()) {
                Object[] connIdArray = convertToConnIdfArray(prismProperty, type.getComponentType());
                if (connIdArray != null && connIdArray.length != 0) {
                    property.setValue(connIdArray);
                }
            } else {
                Object connIdValue = convertToConnIdSingle(prismProperty, type);
                if (connIdValue != null) {
                    property.setValue(connIdValue);
                }
            }
        }
    }
    // empty configuration is OK e.g. when creating a new resource using wizard
    if (numConfingProperties == 0 && !wrongNamespaceProperties.isEmpty()) {
        throw new SchemaException("No configuration properties found. Wrong namespace? (expected: " + connectorConfNs + ", present e.g. " + wrongNamespaceProperties.get(0) + ")");
    }
}
Also used : ConfigurationProperty(org.identityconnectors.framework.api.ConfigurationProperty) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) PrismProperty(com.evolveum.midpoint.prism.PrismProperty) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) GuardedString(org.identityconnectors.common.security.GuardedString) PolyString(com.evolveum.midpoint.prism.polystring.PolyString)

Example 47 with ConfigurationException

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

the class TestOpenDjNegative method test150ModifyObject.

@Test
public void test150ModifyObject() throws Exception {
    final String TEST_NAME = "test150ModifyObject";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    OperationResult result = new OperationResult(TestOpenDjNegative.class.getName() + "." + TEST_NAME);
    ObjectModificationType objectChange = PrismTestUtil.parseAtomicValue(ACCOUNT_JACK_CHANGE_FILE, ObjectModificationType.COMPLEX_TYPE);
    ObjectDelta<ShadowType> delta = DeltaConvertor.createObjectDelta(objectChange, ShadowType.class, PrismTestUtil.getPrismContext());
    display("Object change", delta);
    try {
        provisioningService.modifyObject(ShadowType.class, objectChange.getOid(), delta.getModifications(), 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 : ObjectModificationType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType) 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 48 with ConfigurationException

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

the class TestOpenDjNegative method test120ListResourceObjects.

@Test
public void test120ListResourceObjects() throws Exception {
    final String TEST_NAME = "test120ListResourceObjects";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    OperationResult result = new OperationResult(TestOpenDjNegative.class.getName() + "." + TEST_NAME);
    try {
        // WHEN
        List<PrismObject<? extends ShadowType>> objectList = provisioningService.listResourceObjects(RESOURCE_OPENDJ_OID, RESOURCE_OPENDJ_ACCOUNT_OBJECTCLASS, null, null, result);
        AssertJUnit.fail("listResourceObjects succeeded unexpectedly");
    } catch (ConfigurationException e) {
        // This is expected
        display("Expected exception", e);
    }
    result.computeStatus();
    TestUtil.assertFailure(result);
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) 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 49 with ConfigurationException

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

the class TestOpenDjNegative method test121SearchAccounts.

@Test
public void test121SearchAccounts() throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, Exception {
    final String TEST_NAME = "test121SearchAccounts";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    OperationResult result = new OperationResult(TestOpenDjNegative.class.getName() + "." + TEST_NAME);
    final String resourceNamespace = ResourceTypeUtil.getResourceNamespace(resource);
    QName objectClass = new QName(resourceNamespace, OBJECT_CLASS_INETORGPERSON_NAME);
    ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(resource.getOid(), objectClass, prismContext);
    try {
        // WHEN
        provisioningService.searchObjects(ShadowType.class, query, null, null, result);
        AssertJUnit.fail("searchObjectsIterative succeeded unexpectedly");
    } catch (ConfigurationException e) {
        // This is expected
        display("Expected exception", e);
    }
    result.computeStatus();
    display(result);
    TestUtil.assertFailure(result);
}
Also used : ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) QName(javax.xml.namespace.QName) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) Test(org.testng.annotations.Test)

Example 50 with ConfigurationException

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

the class ConnectorInstanceConnIdImpl method fetchConnectorObject.

/**
	 * Returns null if nothing is found.
	 */
private ConnectorObject fetchConnectorObject(StateReporter reporter, ObjectClassComplexTypeDefinition objectClassDefinition, ObjectClass icfObjectClass, Uid uid, OperationOptions options, OperationResult parentResult) throws ObjectNotFoundException, CommunicationException, GenericFrameworkException, SecurityViolationException, SchemaException, ConfigurationException {
    // Connector operation cannot create result for itself, so we need to
    // create result for it
    OperationResult icfResult = parentResult.createMinorSubresult(ConnectorFacade.class.getName() + ".getObject");
    icfResult.addParam("objectClass", icfObjectClass.toString());
    icfResult.addParam("uid", uid.getUidValue());
    icfResult.addArbitraryObjectAsParam("options", options);
    icfResult.addContext("connector", connIdConnectorFacade.getClass());
    if (LOGGER.isTraceEnabled()) {
        LOGGER.trace("Fetching connector object ObjectClass={}, UID={}, options={}", new Object[] { icfObjectClass, uid, ConnIdUtil.dumpOptions(options) });
    }
    ConnectorObject co = null;
    try {
        // Invoke the ICF connector
        InternalMonitor.recordConnectorOperation("getObject");
        recordIcfOperationStart(reporter, ProvisioningOperation.ICF_GET, objectClassDefinition, uid);
        co = connIdConnectorFacade.getObject(icfObjectClass, uid, options);
        recordIcfOperationEnd(reporter, ProvisioningOperation.ICF_GET, objectClassDefinition, uid);
        icfResult.recordSuccess();
    } catch (Throwable ex) {
        recordIcfOperationEnd(reporter, ProvisioningOperation.ICF_GET, objectClassDefinition, ex, uid);
        String desc = this.getHumanReadableName() + " while getting object identified by ICF UID '" + uid.getUidValue() + "'";
        Throwable midpointEx = processIcfException(ex, desc, icfResult);
        icfResult.computeStatus("Add object failed");
        // exception
        if (midpointEx instanceof CommunicationException) {
            icfResult.muteError();
            throw (CommunicationException) midpointEx;
        } else if (midpointEx instanceof GenericFrameworkException) {
            throw (GenericFrameworkException) midpointEx;
        } else if (midpointEx instanceof ConfigurationException) {
            throw (ConfigurationException) midpointEx;
        } else if (midpointEx instanceof SecurityViolationException) {
            throw (SecurityViolationException) midpointEx;
        } else if (midpointEx instanceof ObjectNotFoundException) {
            LOGGER.trace("Got ObjectNotFoundException while looking for resource object ConnId UID: {}", uid);
            return null;
        } else if (midpointEx instanceof RuntimeException) {
            throw (RuntimeException) midpointEx;
        } else if (midpointEx instanceof Error) {
            // This should not happen. But some connectors are very strange.
            throw new SystemException("ERROR: " + midpointEx.getClass().getName() + ": " + midpointEx.getMessage(), midpointEx);
        } else {
            throw new SystemException(midpointEx.getClass().getName() + ": " + midpointEx.getMessage(), midpointEx);
        }
    }
    return co;
}
Also used : CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) GenericFrameworkException(com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) SystemException(com.evolveum.midpoint.util.exception.SystemException) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) ConnectorObject(org.identityconnectors.framework.common.objects.ConnectorObject) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) AsynchronousOperationResult(com.evolveum.midpoint.schema.result.AsynchronousOperationResult) GuardedString(org.identityconnectors.common.security.GuardedString)

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