Search in sources :

Example 46 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 47 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 48 with CommunicationException

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

the class TestOpenDjNegative method test522SearchAccountsIterative.

@Test
public void test522SearchAccountsIterative() throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, Exception {
    final String TEST_NAME = "test522SearchAccountsIterative";
    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);
    ResultHandler handler = new ResultHandler<ObjectType>() {

        @Override
        public boolean handle(PrismObject<ObjectType> prismObject, OperationResult parentResult) {
            AssertJUnit.fail("handler called unexpectedly");
            return false;
        }
    };
    try {
        // WHEN
        provisioningService.searchObjectsIterative(ShadowType.class, query, null, handler, null, result);
        AssertJUnit.fail("searchObjectsIterative succeeded unexpectedly");
    } catch (CommunicationException e) {
        // This is expected
        display("Expected exception", e);
    }
    result.computeStatus();
    display(result);
    TestUtil.assertFailure(result);
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) QName(javax.xml.namespace.QName) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResultHandler(com.evolveum.midpoint.schema.ResultHandler) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) Test(org.testng.annotations.Test)

Example 49 with CommunicationException

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

the class ResourceContentPanel method updateResourceObjectStatusPerformed.

protected void updateResourceObjectStatusPerformed(ShadowType selected, AjaxRequestTarget target, boolean enabled) {
    List<ShadowType> selectedShadow = getSelectedShadowsList(selected);
    OperationResult result = new OperationResult(OPERATION_UPDATE_STATUS);
    Task task = pageBase.createSimpleTask(OPERATION_UPDATE_STATUS);
    if (selectedShadow == null || selectedShadow.isEmpty()) {
        result.recordWarning("Nothing selected to update status");
        getPageBase().showResult(result);
        target.add(getPageBase().getFeedbackPanel());
        return;
    }
    ModelExecuteOptions opts = createModelOptions();
    for (ShadowType shadow : selectedShadow) {
        ActivationStatusType status = enabled ? ActivationStatusType.ENABLED : ActivationStatusType.DISABLED;
        try {
            ObjectDelta<ShadowType> deleteDelta = ObjectDelta.createModificationReplaceProperty(ShadowType.class, shadow.getOid(), SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, getPageBase().getPrismContext(), status);
            getPageBase().getModelService().executeChanges(WebComponentUtil.createDeltaCollection(deleteDelta), opts, task, result);
        } catch (ObjectAlreadyExistsException | ObjectNotFoundException | SchemaException | ExpressionEvaluationException | CommunicationException | ConfigurationException | PolicyViolationException | SecurityViolationException e) {
            // TODO Auto-generated catch block
            result.recordPartialError("Could not update status (to " + status + ") for " + shadow, e);
            LOGGER.error("Could not update status (to {}) for {}, using option {}", status, shadow, opts, e);
            continue;
        }
    }
    result.computeStatusIfUnknown();
    getPageBase().showResult(result);
    getTable().refreshTable(null, target);
    target.add(getPageBase().getFeedbackPanel());
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Task(com.evolveum.midpoint.task.api.Task) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ActivationStatusType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType) ModelExecuteOptions(com.evolveum.midpoint.model.api.ModelExecuteOptions) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) PolicyViolationException(com.evolveum.midpoint.util.exception.PolicyViolationException) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)

Example 50 with CommunicationException

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

the class ResourceContentPanel method importResourceObject.

protected void importResourceObject(ShadowType selected, AjaxRequestTarget target) {
    List<ShadowType> selectedShadow = null;
    if (selected != null) {
        selectedShadow = new ArrayList<>();
        selectedShadow.add(selected);
    } else {
        selectedShadow = getTable().getSelectedObjects();
    }
    OperationResult result = new OperationResult(OPERATION_IMPORT_OBJECT);
    Task task = pageBase.createSimpleTask(OPERATION_IMPORT_OBJECT);
    if (selectedShadow == null || selectedShadow.isEmpty()) {
        result.recordWarning("Nothing select to import");
        getPageBase().showResult(result);
        target.add(getPageBase().getFeedbackPanel());
        return;
    }
    for (ShadowType shadow : selectedShadow) {
        try {
            getPageBase().getModelService().importFromResource(shadow.getOid(), task, result);
        } catch (ObjectNotFoundException | SchemaException | SecurityViolationException | CommunicationException | ConfigurationException | ExpressionEvaluationException e) {
            result.recordPartialError("Could not import account " + shadow, e);
            LOGGER.error("Could not import account {} ", shadow, e);
            continue;
        }
    }
    result.computeStatusIfUnknown();
    getPageBase().showResult(result);
    getTable().refreshTable(null, target);
    target.add(getPageBase().getFeedbackPanel());
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Task(com.evolveum.midpoint.task.api.Task) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Aggregations

CommunicationException (com.evolveum.midpoint.util.exception.CommunicationException)108 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)87 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)87 ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)86 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)82 ExpressionEvaluationException (com.evolveum.midpoint.util.exception.ExpressionEvaluationException)69 SecurityViolationException (com.evolveum.midpoint.util.exception.SecurityViolationException)67 ObjectAlreadyExistsException (com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)39 SystemException (com.evolveum.midpoint.util.exception.SystemException)38 GenericFrameworkException (com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException)36 Task (com.evolveum.midpoint.task.api.Task)30 PrismObject (com.evolveum.midpoint.prism.PrismObject)29 PolicyViolationException (com.evolveum.midpoint.util.exception.PolicyViolationException)24 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)21 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)21 AsynchronousOperationResult (com.evolveum.midpoint.schema.result.AsynchronousOperationResult)19 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)18 QName (javax.xml.namespace.QName)18 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)14 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)13