Search in sources :

Example 1 with ObjectType

use of com.evolveum.midpoint.cli.ninja.util.ObjectType 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 ObjectType

use of com.evolveum.midpoint.cli.ninja.util.ObjectType 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 ObjectType

use of com.evolveum.midpoint.cli.ninja.util.ObjectType in project midpoint by Evolveum.

the class ObjectTypeConverter method createMessage.

private StringBuilder createMessage(Object value) {
    StringBuilder sb = new StringBuilder();
    sb.append("Unknown value '").append(value).append("', possible values are: ");
    List<String> values = new ArrayList<>();
    for (ObjectType type : ObjectType.values()) {
        values.add(type.getParameterName());
    }
    sb.append(StringUtils.join(values, ", "));
    sb.append('.');
    return sb;
}
Also used : ObjectType(com.evolveum.midpoint.cli.ninja.util.ObjectType) ArrayList(java.util.ArrayList)

Aggregations

ObjectType (com.evolveum.midpoint.cli.ninja.util.ObjectType)3 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)2 SelectorQualifiedGetOptionsType (com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType)2 QName (javax.xml.namespace.QName)2 Holder (javax.xml.ws.Holder)2 ObjectListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType)1 QueryType (com.evolveum.prism.xml.ns._public.query_3.QueryType)1 ArrayList (java.util.ArrayList)1