Search in sources :

Example 1 with FaultType

use of com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultType in project midpoint by Evolveum.

the class ImportAction method executeAction.

@Override
protected void executeAction() {
    ModelPortType port = createModelPort();
    ModelExecuteOptionsType options = new ModelExecuteOptionsType();
    options.setRaw(getParams().isRaw());
    com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType object = readObject();
    ObjectDeltaType delta = createAddDelta(object);
    ObjectDeltaListType deltas = createDeltaList(delta);
    OperationResultType resultType;
    try {
        ObjectDeltaOperationListType result = port.executeChanges(deltas, options);
        List<ObjectDeltaOperationType> operations = result.getDeltaOperation();
        ObjectDeltaOperationType operation = operations.get(0);
        resultType = operation.getExecutionResult();
    } catch (FaultMessage ex) {
        //todo error handling
        FaultType fault = ex.getFaultInfo();
        resultType = fault.getOperationResult();
    }
    STD_OUT.info("Status: {}", resultType.getStatus());
}
Also used : ModelPortType(com.evolveum.midpoint.xml.ns._public.model.model_3.ModelPortType) ModelExecuteOptionsType(com.evolveum.midpoint.xml.ns._public.common.common_3.ModelExecuteOptionsType) FaultType(com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultType) ObjectDeltaOperationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectDeltaOperationType) ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) FaultMessage(com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultMessage) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) ObjectDeltaOperationListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaOperationListType) ObjectDeltaListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaListType)

Example 2 with FaultType

use of com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultType in project midpoint by Evolveum.

the class TestSanityLegacy method test029ModifyAccountDjBadPath.

@Test
public void test029ModifyAccountDjBadPath() throws Exception {
    final String TEST_NAME = "test029ModifyAccountDjBadPath";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    assertNoRepoCache();
    ObjectDeltaType objectChange = unmarshallValueFromFile(REQUEST_ACCOUNT_MODIFY_BAD_PATH_FILE, ObjectDeltaType.class);
    objectChange.setOid(accountShadowOidOpendj);
    OperationResultType result;
    try {
        // WHEN
        result = modifyObjectViaModelWS(objectChange);
        AssertJUnit.fail("Unexpected success");
    } catch (FaultMessage f) {
        // this is expected
        FaultType faultInfo = f.getFaultInfo();
        result = faultInfo.getOperationResult();
    }
    // THEN
    assertNoRepoCache();
    displayJaxb("modifyObject result:", result, SchemaConstants.C_RESULT);
    TestUtil.assertFailure(result);
    OperationResult repoResult = new OperationResult("getObject");
    PrismObject<ShadowType> repoShadow = repositoryService.getObject(ShadowType.class, accountShadowOidOpendj, null, repoResult);
    repoResult.computeStatus();
    TestUtil.assertSuccess("getObject(repo) has failed", repoResult);
    display("repository shadow", repoShadow);
    AssertJUnit.assertNotNull(repoShadow);
    ShadowType repoShadowType = repoShadow.asObjectable();
    AssertJUnit.assertEquals(RESOURCE_OPENDJ_OID, repoShadowType.getResourceRef().getOid());
    // check attributes in the shadow: should be only identifiers (ICF UID)
    String uid = checkRepoShadow(repoShadow);
    // Check if LDAP account was updated
    Entry jackLdapEntry = assertOpenDJAccountJack(uid, "jack");
    OpenDJController.assertAttribute(jackLdapEntry, "roomNumber", "upperdeck");
}
Also used : ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) ChangeRecordEntry(org.opends.server.util.ChangeRecordEntry) FaultMessage(com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultMessage) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PrismAsserts.assertEqualsPolyString(com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString) ObjectAlreadyExistsFaultType(com.evolveum.midpoint.xml.ns._public.common.fault_3.ObjectAlreadyExistsFaultType) FaultType(com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultType) Test(org.testng.annotations.Test) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Example 3 with FaultType

use of com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultType in project midpoint by Evolveum.

the class TestSanity method test029ModifyAccountDjBadPath.

@Test
public void test029ModifyAccountDjBadPath() throws Exception {
    final String TEST_NAME = "test029ModifyAccountDjBadPath";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    assertNoRepoCache();
    ObjectDeltaType objectChange = unmarshallValueFromFile(REQUEST_ACCOUNT_MODIFY_BAD_PATH_FILE, ObjectDeltaType.class);
    objectChange.setOid(accountShadowOidOpendj);
    OperationResultType result;
    try {
        // WHEN
        result = modifyObjectViaModelWS(objectChange);
        AssertJUnit.fail("Unexpected success");
    } catch (FaultMessage f) {
        // this is expected
        FaultType faultInfo = f.getFaultInfo();
        result = faultInfo.getOperationResult();
    }
    // THEN
    assertNoRepoCache();
    displayJaxb("modifyObject result:", result, SchemaConstants.C_RESULT);
    TestUtil.assertFailure(result);
    OperationResult repoResult = new OperationResult("getObject");
    PrismObject<ShadowType> repoShadow = repositoryService.getObject(ShadowType.class, accountShadowOidOpendj, null, repoResult);
    repoResult.computeStatus();
    TestUtil.assertSuccess("getObject(repo) has failed", repoResult);
    display("repository shadow", repoShadow);
    AssertJUnit.assertNotNull(repoShadow);
    ShadowType repoShadowType = repoShadow.asObjectable();
    AssertJUnit.assertEquals(RESOURCE_OPENDJ_OID, repoShadowType.getResourceRef().getOid());
    // check attributes in the shadow: should be only identifiers (ICF UID)
    String uid = checkRepoShadow(repoShadow);
    // Check if LDAP account was updated
    Entry jackLdapEntry = assertOpenDJAccountJack(uid, "jack");
    OpenDJController.assertAttribute(jackLdapEntry, "roomNumber", "upperdeck");
}
Also used : ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) ChangeRecordEntry(org.opends.server.util.ChangeRecordEntry) FaultMessage(com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultMessage) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PrismAsserts.assertEqualsPolyString(com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString) ObjectAlreadyExistsFaultType(com.evolveum.midpoint.xml.ns._public.common.fault_3.ObjectAlreadyExistsFaultType) FaultType(com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultType) Test(org.testng.annotations.Test) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Example 4 with FaultType

use of com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultType in project midpoint by Evolveum.

the class AbstractWebserviceTest method assertFaultMessage.

protected <F extends FaultType> void assertFaultMessage(FaultMessage fault, Class<F> expectedFaultInfoClass, String expectedMessage) {
    FaultType faultInfo = fault.getFaultInfo();
    assertNotNull("No fault info in " + fault);
    if (expectedFaultInfoClass != null && !expectedFaultInfoClass.isAssignableFrom(faultInfo.getClass())) {
        AssertJUnit.fail("Expected that faultInfo will be of type " + expectedFaultInfoClass + ", but it was " + faultInfo.getClass());
    }
    if (expectedMessage != null) {
        assertTrue("Wrong message in fault: " + fault.getMessage(), fault.getMessage().contains(expectedMessage));
        assertTrue("Wrong message in fault info: " + faultInfo.getMessage(), faultInfo.getMessage().contains(expectedMessage));
    }
    OperationResultType result = faultInfo.getOperationResult();
    assertNotNull("No result in faultInfo in " + fault, result);
    assertEquals("Expected that resut in FaultInfo will be fatal error, but it was " + result.getStatus(), OperationResultStatusType.FATAL_ERROR, result.getStatus());
}
Also used : FaultType(com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultType)

Example 5 with FaultType

use of com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultType in project midpoint by Evolveum.

the class Action method handleError.

protected void handleError(String message, Exception ex) throws Exception {
    STD_ERR.info(message);
    STD_ERR.info("Error occurred: {}", ex.getMessage());
    if (ex instanceof FaultMessage) {
        FaultMessage faultMessage = (FaultMessage) ex;
        FaultType fault = faultMessage.getFaultInfo();
        if (fault != null && fault.getOperationResult() != null) {
            OperationResultType result = fault.getOperationResult();
            STD_ERR.info("Operation result: {}", result.getMessage());
            if (getParams().isVerbose()) {
                try {
                    STD_ERR.debug(ToolsUtils.serializeObject(result));
                } catch (JAXBException e) {
                    STD_ERR.debug("Couldn't serialize operation result, reason: {}", e.getMessage());
                }
            }
        }
    }
    if (getParams().isVerbose()) {
        STD_ERR.debug("Error details", ex);
    }
    throw ex;
}
Also used : FaultMessage(com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultMessage) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) JAXBException(javax.xml.bind.JAXBException) FaultType(com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultType)

Aggregations

FaultType (com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultType)5 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)4 FaultMessage (com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultMessage)4 ObjectDeltaType (com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType)3 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)2 PrismAsserts.assertEqualsPolyString (com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString)2 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)2 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)2 ObjectAlreadyExistsFaultType (com.evolveum.midpoint.xml.ns._public.common.fault_3.ObjectAlreadyExistsFaultType)2 ChangeRecordEntry (org.opends.server.util.ChangeRecordEntry)2 Test (org.testng.annotations.Test)2 ObjectDeltaListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaListType)1 ObjectDeltaOperationListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaOperationListType)1 ModelExecuteOptionsType (com.evolveum.midpoint.xml.ns._public.common.common_3.ModelExecuteOptionsType)1 ObjectDeltaOperationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectDeltaOperationType)1 ModelPortType (com.evolveum.midpoint.xml.ns._public.model.model_3.ModelPortType)1 JAXBException (javax.xml.bind.JAXBException)1