Search in sources :

Example 1 with ObjectDeltaOperationListType

use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaOperationListType 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 ObjectDeltaOperationListType

use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaOperationListType in project midpoint by Evolveum.

the class ModelWebServiceRaw method invokeAllowingFaults.

public DOMSource invokeAllowingFaults(DOMSource request) throws FaultMessage {
    Node rootNode = request.getNode();
    Element rootElement;
    if (rootNode instanceof Document) {
        rootElement = ((Document) rootNode).getDocumentElement();
    } else if (rootNode instanceof Element) {
        rootElement = (Element) rootNode;
    } else {
        throw ws.createIllegalArgumentFault("Unexpected DOM node type: " + rootNode);
    }
    Object requestObject;
    try {
        requestObject = prismContext.parserFor(rootElement).parseRealValue();
    } catch (SchemaException e) {
        throw ws.createIllegalArgumentFault("Couldn't parse SOAP request body because of schema exception: " + e.getMessage());
    }
    Node response;
    Holder<OperationResultType> operationResultTypeHolder = new Holder<>();
    try {
        PrismSerializer<Element> serializer = prismContext.domSerializer().options(SerializationOptions.createSerializeReferenceNames());
        if (requestObject instanceof GetObjectType) {
            GetObjectType g = (GetObjectType) requestObject;
            Holder<ObjectType> objectTypeHolder = new Holder<>();
            ws.getObject(g.getObjectType(), g.getOid(), g.getOptions(), objectTypeHolder, operationResultTypeHolder);
            GetObjectResponseType gr = new GetObjectResponseType();
            gr.setObject(objectTypeHolder.value);
            gr.setResult(operationResultTypeHolder.value);
            response = serializer.serializeAnyData(gr, ModelPort.GET_OBJECT_RESPONSE);
        } else if (requestObject instanceof SearchObjectsType) {
            SearchObjectsType s = (SearchObjectsType) requestObject;
            Holder<ObjectListType> objectListTypeHolder = new Holder<>();
            ws.searchObjects(s.getObjectType(), s.getQuery(), s.getOptions(), objectListTypeHolder, operationResultTypeHolder);
            SearchObjectsResponseType sr = new SearchObjectsResponseType();
            sr.setObjectList(objectListTypeHolder.value);
            sr.setResult(operationResultTypeHolder.value);
            response = serializer.serializeAnyData(sr, ModelPort.SEARCH_OBJECTS_RESPONSE);
        } else if (requestObject instanceof ExecuteChangesType) {
            ExecuteChangesType e = (ExecuteChangesType) requestObject;
            ObjectDeltaOperationListType objectDeltaOperationListType = ws.executeChanges(e.getDeltaList(), e.getOptions());
            ExecuteChangesResponseType er = new ExecuteChangesResponseType();
            er.setDeltaOperationList(objectDeltaOperationListType);
            response = serializer.serializeAnyData(er, ModelPort.EXECUTE_CHANGES_RESPONSE);
        } else if (requestObject instanceof FindShadowOwnerType) {
            FindShadowOwnerType f = (FindShadowOwnerType) requestObject;
            Holder<UserType> userTypeHolder = new Holder<>();
            ws.findShadowOwner(f.getShadowOid(), userTypeHolder, operationResultTypeHolder);
            FindShadowOwnerResponseType fsr = new FindShadowOwnerResponseType();
            fsr.setUser(userTypeHolder.value);
            fsr.setResult(operationResultTypeHolder.value);
            response = serializer.serializeAnyData(fsr, ModelPort.FIND_SHADOW_OWNER_RESPONSE);
        } else if (requestObject instanceof TestResourceType) {
            TestResourceType tr = (TestResourceType) requestObject;
            OperationResultType operationResultType = ws.testResource(tr.getResourceOid());
            TestResourceResponseType trr = new TestResourceResponseType();
            trr.setResult(operationResultType);
            response = serializer.serializeAnyData(trr, ModelPort.TEST_RESOURCE_RESPONSE);
        } else if (requestObject instanceof ExecuteScriptsType) {
            ExecuteScriptsType es = (ExecuteScriptsType) requestObject;
            ExecuteScriptsResponseType esr = ws.executeScripts(es);
            response = serializer.serializeAnyData(esr, ModelPort.EXECUTE_SCRIPTS_RESPONSE);
        } else if (requestObject instanceof ImportFromResourceType) {
            ImportFromResourceType ifr = (ImportFromResourceType) requestObject;
            TaskType taskType = ws.importFromResource(ifr.getResourceOid(), ifr.getObjectClass());
            ImportFromResourceResponseType ifrr = new ImportFromResourceResponseType();
            ifrr.setTask(taskType);
            response = serializer.serializeAnyData(ifrr, ModelPort.IMPORT_FROM_RESOURCE_RESPONSE);
        } else if (requestObject instanceof NotifyChangeType) {
            NotifyChangeType nc = (NotifyChangeType) requestObject;
            TaskType taskType = ws.notifyChange(nc.getChangeDescription());
            NotifyChangeResponseType ncr = new NotifyChangeResponseType();
            ncr.setTask(taskType);
            response = serializer.serializeAnyData(ncr, ModelPort.NOTIFY_CHANGE_RESPONSE);
        } else {
            throw ws.createIllegalArgumentFault("Unsupported request type: " + requestObject);
        }
    } catch (SchemaException e) {
        throwFault(e, operationResultTypeHolder.value);
        // not reached
        return null;
    }
    return new DOMSource(response);
}
Also used : ExecuteChangesResponseType(com.evolveum.midpoint.xml.ns._public.model.model_3.ExecuteChangesResponseType) DOMSource(javax.xml.transform.dom.DOMSource) Node(org.w3c.dom.Node) Element(org.w3c.dom.Element) ExecuteChangesType(com.evolveum.midpoint.xml.ns._public.model.model_3.ExecuteChangesType) FindShadowOwnerResponseType(com.evolveum.midpoint.xml.ns._public.model.model_3.FindShadowOwnerResponseType) Document(org.w3c.dom.Document) FindShadowOwnerType(com.evolveum.midpoint.xml.ns._public.model.model_3.FindShadowOwnerType) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) GetObjectType(com.evolveum.midpoint.xml.ns._public.model.model_3.GetObjectType) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) GetObjectType(com.evolveum.midpoint.xml.ns._public.model.model_3.GetObjectType) ImportFromResourceType(com.evolveum.midpoint.xml.ns._public.model.model_3.ImportFromResourceType) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) NotifyChangeType(com.evolveum.midpoint.xml.ns._public.model.model_3.NotifyChangeType) GetObjectResponseType(com.evolveum.midpoint.xml.ns._public.model.model_3.GetObjectResponseType) Holder(javax.xml.ws.Holder) NotifyChangeResponseType(com.evolveum.midpoint.xml.ns._public.model.model_3.NotifyChangeResponseType) TestResourceType(com.evolveum.midpoint.xml.ns._public.model.model_3.TestResourceType) SearchObjectsType(com.evolveum.midpoint.xml.ns._public.model.model_3.SearchObjectsType) ImportFromResourceResponseType(com.evolveum.midpoint.xml.ns._public.model.model_3.ImportFromResourceResponseType) ExecuteScriptsResponseType(com.evolveum.midpoint.xml.ns._public.model.model_3.ExecuteScriptsResponseType) ExecuteScriptsType(com.evolveum.midpoint.xml.ns._public.model.model_3.ExecuteScriptsType) SearchObjectsResponseType(com.evolveum.midpoint.xml.ns._public.model.model_3.SearchObjectsResponseType) TestResourceResponseType(com.evolveum.midpoint.xml.ns._public.model.model_3.TestResourceResponseType) ObjectDeltaOperationListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaOperationListType)

Example 3 with ObjectDeltaOperationListType

use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaOperationListType in project midpoint by Evolveum.

the class AbstractTestForExchangeConnector method assertExecuteChangesSuccess.

protected ObjectDeltaOperationType assertExecuteChangesSuccess(ObjectDeltaOperationListType odolist, ObjectDeltaType deltaType, boolean assertSuccess) {
    ObjectDeltaOperationType found = null;
    for (ObjectDeltaOperationType odo : odolist.getDeltaOperation()) {
        if (deltaType == null || deltaType.getOid().equals(odo.getObjectDelta().getOid())) {
            AssertJUnit.assertNotNull("Operation result is null", odo.getExecutionResult());
            found = odo;
            if (odo.getExecutionResult().getStatus() != OperationResultStatusType.SUCCESS) {
                System.out.println("!!! Operation result is " + odo.getExecutionResult().getStatus());
                System.out.println("!!! Message: " + odo.getExecutionResult().getMessage());
                System.out.println("!!! Details:\n" + odo.getExecutionResult());
                if (assertSuccess) {
                    AssertJUnit.assertEquals("Unexpected operation result status", OperationResultStatusType.SUCCESS, odo.getExecutionResult().getStatus());
                }
            }
        }
    }
    AssertJUnit.assertNotNull("ObjectDelta was not found in ObjectDeltaOperationList", found);
    return found;
}
Also used : ObjectDeltaOperationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectDeltaOperationType)

Example 4 with ObjectDeltaOperationListType

use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaOperationListType in project midpoint by Evolveum.

the class AbstractTestForExchangeConnector method createAccountOdo.

protected ObjectDeltaOperationType createAccountOdo(String givenName, String sn, String name, String recipientType, String overrideMail) throws FaultMessage {
    ShadowType shadowType = prepareShadowType(givenName, sn, name, recipientType, overrideMail, null, null, null);
    ObjectDeltaType deltaType = new ObjectDeltaType();
    deltaType.setObjectType(ModelClientUtil.getTypeQName(ShadowType.class));
    deltaType.setChangeType(ChangeTypeType.ADD);
    deltaType.setObjectToAdd(shadowType);
    ObjectDeltaListType deltaListType = new ObjectDeltaListType();
    deltaListType.getDelta().add(deltaType);
    ObjectDeltaOperationListType operationListType = modelPort.executeChanges(deltaListType, null);
    return ModelClientUtil.findInDeltaOperationList(operationListType, deltaType);
}
Also used : ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) 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 5 with ObjectDeltaOperationListType

use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaOperationListType in project midpoint by Evolveum.

the class AbstractTestForExchangeConnector method getOidFromDeltaOperationList.

/**
     * Retrieves OID and OperationResult created by model Web Service from the returned list of ObjectDeltaOperations.
     *
     * @param operationListType result of the model web service executeChanges call
     * @param originalDelta original request used to find corresponding ObjectDeltaOperationType instance. Must be of ADD type.
     * @param operationResultHolder where the result will be put
     * @return OID if found
     *
     * PRELIMINARY IMPLEMENTATION. Currently the first returned ADD delta with the same object type as original delta is returned.
     *
     * TODO move to ModelClientUtil
     */
public static String getOidFromDeltaOperationList(ObjectDeltaOperationListType operationListType, ObjectDeltaType originalDelta, Holder<OperationResultType> operationResultTypeHolder) {
    Validate.notNull(operationListType);
    Validate.notNull(originalDelta);
    if (originalDelta.getChangeType() != ChangeTypeType.ADD) {
        throw new IllegalArgumentException("Original delta is not of ADD type");
    }
    if (originalDelta.getObjectToAdd() == null) {
        throw new IllegalArgumentException("Original delta contains no object-to-be-added");
    }
    for (ObjectDeltaOperationType operationType : operationListType.getDeltaOperation()) {
        ObjectDeltaType objectDeltaType = operationType.getObjectDelta();
        if (objectDeltaType.getChangeType() == ChangeTypeType.ADD && objectDeltaType.getObjectToAdd() != null) {
            ObjectType objectAdded = (ObjectType) objectDeltaType.getObjectToAdd();
            if (objectAdded.getClass().equals(originalDelta.getObjectToAdd().getClass())) {
                operationResultTypeHolder.value = operationType.getExecutionResult();
                return objectAdded.getOid();
            }
        }
    }
    return null;
}
Also used : ObjectDeltaOperationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectDeltaOperationType) ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)

Aggregations

ObjectDeltaOperationListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaOperationListType)34 ObjectDeltaListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaListType)31 ObjectDeltaType (com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType)28 ObjectDeltaOperationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectDeltaOperationType)15 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)10 LogfileTestTailer (com.evolveum.midpoint.test.util.LogfileTestTailer)9 Test (org.testng.annotations.Test)9 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)7 ItemDeltaType (com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType)6 ModelExecuteOptionsType (com.evolveum.midpoint.xml.ns._public.common.common_3.ModelExecuteOptionsType)4 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)4 RoleType (com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType)3 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)3 GenericObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.GenericObjectType)2 FaultMessage (com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultMessage)2 ExecuteChangesType (com.evolveum.midpoint.xml.ns._public.model.model_3.ExecuteChangesType)2 ModelPortType (com.evolveum.midpoint.xml.ns._public.model.model_3.ModelPortType)2 ProtectedStringType (com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType)2 Collection (java.util.Collection)2 QName (javax.xml.namespace.QName)2