Search in sources :

Example 1 with com.evolveum.midpoint.xml.ns._public.common.audit_3

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

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

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

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

the class XmlParser method parseObject.

private boolean parseObject(XMLStreamReader stream, XmlObjectHandler handler, int serial, Map<String, String> nsMap) {
    XmlObjectMetadata metadata = new XmlObjectMetadata();
    metadata.setSerialNumber(serial);
    metadata.setStartLine(stream.getLocation().getLineNumber());
    com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType object = null;
    try {
        Document objectDoc = domConverter.buildDocument(stream);
        Element objectElement = ToolsUtils.getFirstChildElement(objectDoc);
        ToolsUtils.setNamespaceDeclarations(objectElement, nsMap);
        Unmarshaller unmarshaller = ToolsUtils.JAXB_CONTEXT.createUnmarshaller();
        Object obj = unmarshaller.unmarshal(objectElement);
        if (!(obj instanceof com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)) {
            throw new XmlParserException("Xml object '" + obj.getClass().getName() + "' doesn't represent 'ObjectType'");
        }
        object = (ObjectType) obj;
    } catch (JAXBException | XMLStreamException | XmlParserException ex) {
        metadata.setException(ex);
    }
    metadata.setEndLine(stream.getLocation().getLineNumber());
    return handler.handleObject(object, metadata);
}
Also used : ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) Element(org.w3c.dom.Element) JAXBException(javax.xml.bind.JAXBException) Document(org.w3c.dom.Document) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) XMLStreamException(javax.xml.stream.XMLStreamException) Unmarshaller(javax.xml.bind.Unmarshaller)

Example 5 with com.evolveum.midpoint.xml.ns._public.common.audit_3

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

the class ParamsTypeUtil method createEntryElement.

/**
	 * Temporary workaround, brutally hacked -- so that the conversion 
	 * of OperationResult into OperationResultType 'somehow' works, at least to the point
	 * where when we:
	 * - have OR1
	 * - serialize it into ORT1
	 * - then deserialize into OR2
	 * - serialize again into ORT2
	 * so we get ORT1.equals(ORT2) - at least in our simple test case :)
	 * 
	 * FIXME: this should be definitely reworked
	 * 
	 * @param entry
	 * @return
	 */
private static EntryType createEntryElement(String key, Serializable value) {
    EntryType entryType = new EntryType();
    entryType.setKey(key);
    if (value != null) {
        Document doc = DOMUtil.getDocument();
        if (value instanceof ObjectType && ((ObjectType) value).getOid() != null) {
            // Store only reference on the OID. This is faster and getObject can be used to retrieve
            // the object if needed. Although is does not provide 100% accuracy, it is a good tradeoff.
            setObjectReferenceEntry(entryType, ((ObjectType) value));
        // these values should be put 'as they are', in order to be deserialized into themselves
        } else if (value instanceof String || value instanceof Integer || value instanceof Long) {
            entryType.setEntryValue(new JAXBElement<Serializable>(SchemaConstants.C_PARAM_VALUE, Serializable.class, value));
        } else if (XmlTypeConverter.canConvert(value.getClass())) {
        //				try {
        //					entryType.setEntryValue(new JXmlTypeConverter.toXsdElement(value, SchemaConstants.C_PARAM_VALUE, doc, true));
        //				} catch (SchemaException e) {
        //					LOGGER.error("Cannot convert value {} to XML: {}",value,e.getMessage());
        //					setUnknownJavaObjectEntry(entryType, value);
        //				}
        } else if (value instanceof Element || value instanceof JAXBElement<?>) {
            entryType.setEntryValue((JAXBElement<?>) value);
        // FIXME: this is really bad code ... it means that 'our' JAXB object should be put as is
        } else if ("com.evolveum.midpoint.xml.ns._public.common.common_3".equals(value.getClass().getPackage().getName())) {
            JAXBElement<Object> o = new JAXBElement<Object>(SchemaConstants.C_PARAM_VALUE, Object.class, value);
            entryType.setEntryValue(o);
        } else {
            setUnknownJavaObjectEntry(entryType, value);
        }
    }
    return entryType;
}
Also used : ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) UnknownJavaObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.UnknownJavaObjectType) EntryType(com.evolveum.midpoint.xml.ns._public.common.common_3.EntryType) JAXBElement(javax.xml.bind.JAXBElement) Element(org.w3c.dom.Element) JAXBElement(javax.xml.bind.JAXBElement) Document(org.w3c.dom.Document)

Aggregations

OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)3 ObjectType (com.evolveum.midpoint.cli.ninja.util.ObjectType)2 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)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 Document (org.w3c.dom.Document)2 Element (org.w3c.dom.Element)2 ObjectDeltaListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaListType)1 ObjectDeltaOperationListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaOperationListType)1 ObjectListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType)1 EntryType (com.evolveum.midpoint.xml.ns._public.common.common_3.EntryType)1 ModelExecuteOptionsType (com.evolveum.midpoint.xml.ns._public.common.common_3.ModelExecuteOptionsType)1 ObjectDeltaOperationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectDeltaOperationType)1 UnknownJavaObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.UnknownJavaObjectType)1 FaultMessage (com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultMessage)1 FaultType (com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultType)1 ModelPortType (com.evolveum.midpoint.xml.ns._public.model.model_3.ModelPortType)1 QueryType (com.evolveum.prism.xml.ns._public.query_3.QueryType)1 ObjectDeltaType (com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType)1