@Override public String toString() { return serializeQuietly(prismContext, object); } };
public static String serializeQuietly(PrismContext prismContext, Object object) { if (object == null) { return null; } if (object instanceof Collection) { return ((Collection<?>) object).stream() .map(o -> serializeQuietly(prismContext, o)) .collect(Collectors.joining("; ")); } try { PrismSerializer<String> serializer = prismContext.xmlSerializer(); if (object instanceof Item) { return serializer.serialize((Item) object); } else { return serializer.serializeRealValue(object, new QName("value")); } } catch (Throwable t) { return "Couldn't serialize (" + t.getMessage() + "): " + object; } }
@Override protected String getBody(Event event, GeneralNotifierType generalNotifierType, String transport, Task task, OperationResult result) throws SchemaException { CaseWorkItemEvent workItemEvent = (CaseWorkItemEvent) event; boolean techInfo = isTrue(generalNotifierType.isShowTechnicalInformation()); StringBuilder body = new StringBuilder(); body.append(getSubject(event, generalNotifierType, transport, task, result)); body.append("\n\n"); appendGeneralInformation(body, workItemEvent); // process instance name, work item name, stage, escalation level appendAssigneeInformation(body, workItemEvent, result); appendDeadlineInformation(body, workItemEvent); body.append("\nNotification created on: ").append(new Date()).append("\n\n"); if (techInfo) { body.append("----------------------------------------\n"); body.append("Technical information:\n\n"); body.append("WorkItem:\n") .append(PrismUtil.serializeQuietly(prismContext, workItemEvent.getWorkItem())) .append("\n"); body.append("Case:\n") .append(PrismUtil.serializeQuietly(prismContext, workItemEvent.getCase())); } return body.toString(); }
@Override public void assertModification(PrismObject<ResourceType> resource, int iteration) { if (!schemaHandling.equals(resource.asObjectable().getSchemaHandling())) { System.out.println("Expected: " + PrismUtil.serializeQuietly(prismContext, schemaHandling)); System.out.println("Real: " + PrismUtil.serializeQuietly(prismContext, resource.asObjectable().getSchemaHandling())); fail("Wrong schemaHandling in iteration" + iteration); } //assertEquals("Wrong schemaHandling in iteration "+iteration, schemaHandling, resource.asObjectable().getSchemaHandling()); } });
WorkItemEvent workItemEvent = (WorkItemEvent) workflowEvent; body.append("WorkItem:\n") .append(PrismUtil.serializeQuietly(prismContext, workItemEvent.getWorkItem())) .append("\n"); .append(PrismUtil.serializeQuietly(prismContext, ((WorkflowEvent) event).getWorkflowContext()));
protected WorkItemType getWorkItem(Task task, OperationResult result) throws SchemaException, SecurityViolationException, ConfigurationException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException { //Collection<SelectorOptions<GetOperationOptions>> options = GetOperationOptions.resolveItemsNamed(WorkItemType.F_TASK_REF); SearchResultList<WorkItemType> itemsAll = modelService.searchContainers(WorkItemType.class, null, null, task, result); if (itemsAll.size() != 1) { System.out.println("Unexpected # of work items: " + itemsAll.size()); for (WorkItemType workItem : itemsAll) { System.out.println(PrismUtil.serializeQuietly(prismContext, workItem)); } } assertEquals("Wrong # of total work items", 1, itemsAll.size()); return itemsAll.get(0); }