use of com.evolveum.midpoint.xml.ns._public.common.api_types_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;
}
}
use of com.evolveum.midpoint.xml.ns._public.common.api_types_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);
}
use of com.evolveum.midpoint.xml.ns._public.common.api_types_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());
}
use of com.evolveum.midpoint.xml.ns._public.common.api_types_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;
}
use of com.evolveum.midpoint.xml.ns._public.common.api_types_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);
}
Aggregations