use of com.evolveum.midpoint.xml.ns._public.common.common_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.common_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.common_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.common_3 in project midpoint by Evolveum.
the class NotificationsTest method test160LocalizedMessageTemplateAttachmentInheritance.
@Test
public void test160LocalizedMessageTemplateAttachmentInheritance() throws Exception {
OperationResult result = getTestOperationResult();
given("localized message template with attachment");
String objectName = "messageTemplate" + getTestNumber();
String templateOid = repositoryService.addObject(new MessageTemplateType(prismContext).name(objectName).defaultContent(new MessageTemplateContentType(prismContext).bodyExpression(velocityExpression("template-body-default")).attachmentExpression(groovyExpression("def a = new com.evolveum.midpoint.xml.ns._public.common.common_3.NotificationMessageAttachmentType();\n" + "a.setContentType(\"text/plain\");\n" + "a.setContent(\"default-content1\");\n" + "return a;")).attachment(new NotificationMessageAttachmentType().contentType("text/plain").content("default-content2"))).localizedContent(new LocalizedMessageTemplateContentType(prismContext).language("sk").bodyExpression(velocityExpression("template-body-sk")).attachment(new NotificationMessageAttachmentType().contentType("text/plain").content("sk-content2"))).localizedContent(new LocalizedMessageTemplateContentType(prismContext).language("cz").bodyExpression(velocityExpression("template-body-cz")).attachmentExpression(groovyExpression("def a = new com.evolveum.midpoint.xml.ns._public.common.common_3.NotificationMessageAttachmentType();\n" + "a.setContentType(\"text/plain\");\n" + "a.setContent(\"cz-content1\");\n" + "return a;"))).asPrismObject(), null, result);
and("configuration with transport and notifier using the template");
Collection<? extends ItemDelta<?, ?>> modifications = systemConfigModificationWithTestTransport("test").item(SystemConfigurationType.F_NOTIFICATION_CONFIGURATION).replace(new NotificationConfigurationType(prismContext).handler(new EventHandlerType().generalNotifier(new GeneralNotifierType().messageTemplateRef(createObjectReference(templateOid, MessageTemplateType.COMPLEX_TYPE, null)).transport("test")))).asItemDeltas();
repositoryService.modifyObject(SystemConfigurationType.class, SYS_CONFIG_OID, modifications, result);
TestMessageTransport testTransport = (TestMessageTransport) transportService.getTransport("test");
assertThat(testTransport.getMessages()).isEmpty();
when("event is sent to notification manager, recipient has no language set");
CustomEventImpl event = createCustomEvent();
// This is used as default recipient, no recipient results in no message.
event.setRequestee(new SimpleObjectRefImpl(notificationFunctions, new UserType(prismContext).emailAddress("user@example.com")));
notificationManager.processEvent(event, getTestTask(), result);
then("transport sends the message with default template content");
Message message = getSingleMessage(testTransport);
assertThat(message.getAttachments()).hasSize(2).anyMatch(// from expression
a -> getRawValue(a.getContent()).equals("default-content1")).anyMatch(a -> getRawValue(a.getContent()).equals("default-content2"));
// now when-then for sk language (attachment expression inherited)
when("recipient has 'sk' language set");
event = createCustomEvent();
event.setRequestee(new SimpleObjectRefImpl(notificationFunctions, new UserType(prismContext).emailAddress("user2@example.com").preferredLanguage("sk")));
testTransport.clearMessages();
notificationManager.processEvent(event, getTestTask(), result);
then("message uses attachment expression from default content");
message = getSingleMessage(testTransport);
assertThat(message.getAttachments()).hasSize(2).anyMatch(// from expression
a -> getRawValue(a.getContent()).equals("default-content1")).anyMatch(a -> getRawValue(a.getContent()).equals("sk-content2"));
// now when-then for cz language (attachment inherited)
when("event is sent to notification manager, recipient has 'cz' language set");
event = createCustomEvent();
event.setRequestee(new SimpleObjectRefImpl(notificationFunctions, new UserType(prismContext).emailAddress("user3@example.com").preferredLanguage("cz")));
testTransport.clearMessages();
notificationManager.processEvent(event, getTestTask(), result);
then("transport sends the message with default template content, because no localized content for specified language is found");
message = getSingleMessage(testTransport);
assertThat(message.getAttachments()).hasSize(2).anyMatch(// from expression
a -> getRawValue(a.getContent()).equals("cz-content1")).anyMatch(a -> getRawValue(a.getContent()).equals("default-content2"));
}
use of com.evolveum.midpoint.xml.ns._public.common.common_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;
}
Aggregations