Search in sources :

Example 1 with OperationResultType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType in project midpoint by Evolveum.

the class ExportAction method executeSearch.

private void executeSearch(ModelPortType port, Writer writer) throws FaultMessage, IOException, JAXBException, SAXException {
    SelectorQualifiedGetOptionsType options = createOptions();
    QName type = ObjectType.getType(getParams().getType());
    if (type == null) {
        type = ObjectType.OBJECT.getType();
    }
    int count = 0;
    int currentSize = 1;
    Holder<ObjectListType> list = new Holder<>();
    Holder<OperationResultType> result = new Holder<>();
    while (currentSize > 0) {
        QueryType query = createQuery(count);
        port.searchObjects(type, query, options, list, result);
        OperationResultType res = result.value;
        if (!OperationResultStatusType.SUCCESS.equals(res.getStatus()) && !getParams().isIgnore()) {
            printInfoMessage("Search returned {}, reason: ", res.getStatus(), res.getMessage());
            if (getParams().isVerbose()) {
                printInfoMessage("Operation result:\n{}", ToolsUtils.serializeObject(res));
            }
            break;
        }
        ObjectListType objList = list.value;
        if (getParams().isVerbose()) {
            printInfoMessage("Search returned {}, status: {}/{}", res.getStatus(), count, objList.getCount());
        }
        List<com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType> objects = objList.getObject();
        currentSize = objects.size();
        for (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType object : objects) {
            ToolsUtils.serializeObject(object, writer);
            writer.write('\n');
        }
        count += currentSize;
    }
}
Also used : QName(javax.xml.namespace.QName) Holder(javax.xml.ws.Holder) ObjectListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType) ObjectType(com.evolveum.midpoint.cli.ninja.util.ObjectType) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType) SelectorQualifiedGetOptionsType(com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType)

Example 2 with OperationResultType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType in project midpoint by Evolveum.

the class ExportAction method executeGet.

private void executeGet(ModelPortType port, Writer writer) throws FaultMessage, IOException, JAXBException {
    SelectorQualifiedGetOptionsType options = createOptions();
    QName type = ObjectType.getType(getParams().getType());
    if (type == null) {
        type = ObjectType.OBJECT.getType();
    }
    Holder<com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType> object = new Holder<>();
    Holder<OperationResultType> result = new Holder<>();
    port.getObject(type, getParams().getOid(), options, object, result);
    ToolsUtils.serializeObject(object.value, writer);
}
Also used : ObjectType(com.evolveum.midpoint.cli.ninja.util.ObjectType) QName(javax.xml.namespace.QName) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) Holder(javax.xml.ws.Holder) SelectorQualifiedGetOptionsType(com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType)

Example 3 with OperationResultType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType 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 4 with OperationResultType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType in project midpoint by Evolveum.

the class ResourceContentPanel method getResultLabel.

private String getResultLabel(IModel<SelectableBean<ShadowType>> model) {
    OperationResultType result = getResult(model);
    if (result == null) {
        return "";
    }
    StringBuilder b = new StringBuilder(createStringResource("FailedOperationTypeType." + getShadow(model).getFailedOperationType()).getObject());
    b.append(":");
    b.append(createStringResource("OperationResultStatusType." + result.getStatus()).getObject());
    return b.toString();
}
Also used : OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)

Example 5 with OperationResultType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType in project midpoint by Evolveum.

the class TestUtil method assertSuccess.

public static void assertSuccess(String message, OperationResultType result) {
    if (!checkResults) {
        return;
    }
    assertNotNull(message + ": null result", result);
    // Ignore top-level if the operation name is not set
    if (result.getOperation() != null) {
        if (result.getStatus() == null || result.getStatus() == OperationResultStatusType.UNKNOWN) {
            fail(message + ": undefined status (" + result.getStatus() + ") on operation " + result.getOperation());
        }
        if (result.getStatus() != OperationResultStatusType.SUCCESS && result.getStatus() != OperationResultStatusType.NOT_APPLICABLE && result.getStatus() != OperationResultStatusType.HANDLED_ERROR) {
            fail(message + ": " + result.getMessage() + " (" + result.getStatus() + ")");
        }
    }
    List<OperationResultType> partialResults = result.getPartialResults();
    for (OperationResultType subResult : partialResults) {
        if (subResult == null) {
            fail(message + ": null subresult under operation " + result.getOperation());
        }
        if (subResult.getOperation() == null) {
            fail(message + ": null subresult operation under operation " + result.getOperation());
        }
        assertSuccess(message, subResult);
    }
}
Also used : OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)

Aggregations

OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)172 Test (org.testng.annotations.Test)106 Holder (javax.xml.ws.Holder)78 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)75 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)63 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)57 PrismAsserts.assertEqualsPolyString (com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString)56 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)53 ObjectDeltaType (com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType)49 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)47 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)34 SelectorQualifiedGetOptionsType (com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType)34 ChangeRecordEntry (org.opends.server.util.ChangeRecordEntry)32 ObjectListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType)26 SystemConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType)23 LogfileTestTailer (com.evolveum.midpoint.test.util.LogfileTestTailer)21 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)18 FaultMessage (com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultMessage)18 QName (javax.xml.namespace.QName)18 GenericObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.GenericObjectType)17