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());
}
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");
}
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");
}
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());
}
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;
}
Aggregations