Search in sources :

Example 86 with FaultMessage

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

the class ModelWebServiceTest method getNonexistingObject.

@Test(expectedExceptions = FaultMessage.class)
public void getNonexistingObject() throws FaultMessage, ObjectNotFoundException, SchemaException, IOException, JAXBException {
    final UserType expectedUser = (UserType) PrismTestUtil.parseObject(new File(TEST_FOLDER_CONTROLLER, "./addObject/add-user-without-name.xml")).asObjectable();
    setSecurityContext(expectedUser);
    try {
        final String oid = "abababab-abab-abab-abab-000000000001";
        when(repositoryService.getObject(any(Class.class), eq(oid), any(Collection.class), any(OperationResult.class))).thenThrow(new ObjectNotFoundException("Object with oid '" + oid + "' not found."));
        modelService.getObject(UserType.COMPLEX_TYPE, oid, new SelectorQualifiedGetOptionsType(), new Holder<ObjectType>(), new Holder<OperationResultType>());
    } catch (FaultMessage ex) {
        ModelTUtil.assertObjectNotFoundFault(ex);
    } finally {
        SecurityContextHolder.getContext().setAuthentication(null);
    }
    Assert.fail("get must fail");
}
Also used : OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) FaultMessage(com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultMessage) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) Collection(java.util.Collection) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) File(java.io.File) SelectorQualifiedGetOptionsType(com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType) Test(org.testng.annotations.Test)

Example 87 with FaultMessage

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

the class ModelWebServiceTest method nonExistingUidModify.

@Test(expectedExceptions = FaultMessage.class)
public void nonExistingUidModify() throws FaultMessage, ObjectNotFoundException, SchemaException, JAXBException, IOException {
    final String oid = "1";
    ObjectDeltaType objectDeltaType = new ObjectDeltaType();
    objectDeltaType.setChangeType(ChangeTypeType.MODIFY);
    objectDeltaType.setObjectType(UserType.COMPLEX_TYPE);
    objectDeltaType.setOid(oid);
    ItemDeltaType mod1 = new ItemDeltaType();
    mod1.setModificationType(ModificationTypeType.ADD);
    //        ItemDeltaType.Value value = new ItemDeltaType.Value();
    //        value.getAny().add(DOMUtil.createElement(DOMUtil.getDocument(), new QName(SchemaConstants.NS_C, "fullName")));
    mod1.setPath(new ItemPathType(new ItemPath(UserType.F_FULL_NAME)));
    objectDeltaType.getItemDelta().add(mod1);
    when(repositoryService.getObject(any(Class.class), eq(oid), any(Collection.class), any(OperationResult.class))).thenThrow(new ObjectNotFoundException("Oid '" + oid + "' not found."));
    final UserType user = (UserType) PrismTestUtil.parseObject(new File(TEST_FOLDER_CONTROLLER, "./addObject/add-user-without-name.xml")).asObjectable();
    setSecurityContext(user);
    ObjectDeltaListType deltaListType = new ObjectDeltaListType();
    deltaListType.getDelta().add(objectDeltaType);
    try {
        modelService.executeChanges(deltaListType, null);
    } catch (FaultMessage ex) {
        ModelTUtil.assertObjectNotFoundFault(ex);
    } finally {
        SecurityContextHolder.getContext().setAuthentication(null);
    }
}
Also used : ItemPathType(com.evolveum.prism.xml.ns._public.types_3.ItemPathType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ItemDeltaType(com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType) ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) FaultMessage(com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultMessage) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) Collection(java.util.Collection) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) File(java.io.File) ObjectDeltaListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaListType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test)

Example 88 with FaultMessage

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

the class ControllerAddObjectTest method addResourceCorrect.

//	@Test
@SuppressWarnings("unchecked")
public void addResourceCorrect() throws JAXBException, FaultMessage, ObjectAlreadyExistsException, SchemaException, CommunicationException, ObjectNotFoundException, ExpressionEvaluationException, IOException, ConfigurationException, PolicyViolationException, SecurityViolationException {
    TestUtil.displayTestTile("addResourceCorrect");
    Task task = taskManager.createTaskInstance();
    final PrismObject<ResourceType> expectedResource = PrismTestUtil.parseObject(new File(TEST_FOLDER, "add-resource-correct.xml"));
    final ResourceType expectedResourceType = expectedResource.asObjectable();
    AssertJUnit.assertNotNull("resource to add must not be null", expectedResource);
    final String oid = "abababab-abab-abab-abab-000000000002";
    when(provisioning.addObject(argThat(new ObjectTypeNameMatcher(expectedResourceType.getName())), any(OperationProvisioningScriptsType.class), any(ProvisioningOperationOptions.class), any(Task.class), any(OperationResult.class))).thenAnswer(new Answer<String>() {

        @Override
        public String answer(InvocationOnMock invocation) throws Throwable {
            PrismObject<ResourceType> resource = (PrismObject<ResourceType>) invocation.getArguments()[0];
            PrismAsserts.assertEquivalent("Wrong argument to addObject", expectedResource, resource);
            return oid;
        }
    });
    OperationResult result = new OperationResult("Test Operation");
    try {
        String resourceOid = controller.addObject(expectedResource, null, task, result);
        assertEquals(oid, resourceOid);
    } finally {
        LOGGER.debug(result.debugDump());
        verify(provisioning, times(1)).addObject(argThat(new ObjectTypeNameMatcher(expectedResourceType.getName())), any(OperationProvisioningScriptsType.class), any(ProvisioningOperationOptions.class), any(Task.class), any(OperationResult.class));
    }
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ProvisioningOperationOptions(com.evolveum.midpoint.provisioning.api.ProvisioningOperationOptions) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PrismObject(com.evolveum.midpoint.prism.PrismObject) OperationProvisioningScriptsType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationProvisioningScriptsType) ObjectTypeNameMatcher(com.evolveum.midpoint.model.impl.util.ObjectTypeNameMatcher) InvocationOnMock(org.mockito.invocation.InvocationOnMock) File(java.io.File)

Example 89 with FaultMessage

use of com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultMessage 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)

Example 90 with FaultMessage

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

the class BulkAction method executeAction.

@Override
protected void executeAction() throws Exception {
    ModelPortType port = createModelPort();
    try {
        ExecuteScriptsOptionsType options = new ExecuteScriptsOptionsType();
        options.setExecuteAsynchronously(getParams().isAsync());
        options.setObjectLimit(getParams().getLimit());
        options.setOutputFormat(getParams().getOutput());
        ExecuteScriptsType parameters = new ExecuteScriptsType();
        parameters.setOptions(options);
        parameters.setMslScripts(getParams().getMslScript());
        //todo implement xml support
        //parameters.setXmlScripts(xml);
        ExecuteScriptsResponseType response = port.executeScripts(parameters);
    //todo implement
    } catch (FaultMessage ex) {
        handleError("Couldn't execute scripts", ex);
    }
}
Also used : FaultMessage(com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultMessage) ModelPortType(com.evolveum.midpoint.xml.ns._public.model.model_3.ModelPortType) ExecuteScriptsResponseType(com.evolveum.midpoint.xml.ns._public.model.model_3.ExecuteScriptsResponseType) ExecuteScriptsType(com.evolveum.midpoint.xml.ns._public.model.model_3.ExecuteScriptsType) ExecuteScriptsOptionsType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ExecuteScriptsOptionsType)

Aggregations

OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)46 ObjectDeltaType (com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType)36 ObjectDeltaListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaListType)33 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)32 Holder (javax.xml.ws.Holder)32 SelectorQualifiedGetOptionsType (com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType)25 ObjectDeltaOperationListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaOperationListType)22 FaultMessage (com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultMessage)22 Test (org.testng.annotations.Test)22 ObjectListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType)21 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)17 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)16 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)16 QName (javax.xml.namespace.QName)15 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)13 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)13 Document (org.w3c.dom.Document)13 ModelExecuteOptionsType (com.evolveum.midpoint.xml.ns._public.common.common_3.ModelExecuteOptionsType)10 QueryType (com.evolveum.prism.xml.ns._public.query_3.QueryType)10 ItemDeltaType (com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType)10