@Override public String toString() { return serializeQuietly(prismContext, object); } };
public static <T> void recomputePrismPropertyValue(PrismPropertyValue<T> pValue, PrismContext prismContext) { if (pValue == null) { return; } recomputeRealValue(pValue.getValue(), prismContext); }
public static <O extends Objectable> void setDeltaOldValue(PrismObject<O> oldObject, Collection<? extends ItemDelta> itemDeltas) { for(ItemDelta itemDelta: itemDeltas) { setDeltaOldValue(oldObject, itemDelta); } }
@NotNull List<ItemDelta<?, ?>> getDeltasToCreateTriggersForTimedActions(String campaignOid, int escalationLevel, Date workItemCreateTime, Date workItemDeadline, List<WorkItemTimedActionsType> timedActionsList) { LOGGER.trace("Creating triggers for timed actions for certification campaign {}, escalation level {}, create time {}, deadline {}, {} timed action(s)", campaignOid, escalationLevel, workItemCreateTime, workItemDeadline, timedActionsList.size()); try { List<TriggerType> triggers = WfContextUtil.createTriggers(escalationLevel, workItemCreateTime, workItemDeadline, timedActionsList, prismContext, LOGGER, null, AccCertTimedActionTriggerHandler.HANDLER_URI); LOGGER.trace("Created {} triggers for campaign {}:\n{}", triggers.size(), campaignOid, PrismUtil.serializeQuietlyLazily(prismContext, triggers)); if (triggers.isEmpty()) { return Collections.emptyList(); } else { return prismContext.deltaFor(AccessCertificationCampaignType.class) .item(TaskType.F_TRIGGER).add(PrismContainerValue.toPcvList(triggers)) .asItemDeltas(); } } catch (SchemaException | RuntimeException e) { throw new SystemException("Couldn't create deltas for creating trigger(s) for campaign " + campaignOid + ": " + e.getMessage(), e); } }
public static void debugDumpWithLabelLn(StringBuilder sb, String label, Containerable cc, int indent) { debugDumpWithLabel(sb, label, cc, indent); sb.append("\n"); } }
private <TV,TA> ObjectQuery createQuery(RefinedAssociationDefinition assocDefType, RefinedAttributeDefinition<TA> assocAttrDef, ResourceAttribute<TV> valueAttr) throws SchemaException{ MatchingRule<TA> matchingRule = matchingRuleRegistry.getMatchingRule(assocDefType.getResourceObjectAssociationType().getMatchingRule(), assocAttrDef.getTypeName()); if (valueAttr.size() > 1) { throw new IllegalStateException("Attributes with more than 1 values are not supported here"); } PrismPropertyValue<TA> converted = PrismUtil.convertPropertyValue(valueAttr.getAnyValue(), valueAttr.getDefinition(), assocAttrDef, prismContext); TA normalizedRealValue = matchingRule.normalize(converted.getValue()); PrismPropertyValue<TA> normalized = prismContext.itemFactory().createPropertyValue(normalizedRealValue); LOGGER.trace("Converted entitlement filter value: {} ({}) def={}", normalized, normalized.getValue().getClass(), assocAttrDef); ObjectQuery query = prismContext.queryFor(ShadowType.class) .item(ItemPath.create(ShadowType.F_ATTRIBUTES, assocAttrDef.getName()), assocAttrDef).eq(normalized) .build(); query.setAllowPartialResults(true); return query; }
PrismProperty<TA> changedAssocAttr = PrismUtil.convertProperty(valueAttr, assocAttrDef, prismContext);
public void prepareStartInstruction(WfTaskCreationInstruction instruction) { instruction.setProcessName(PROCESS_DEFINITION_KEY); instruction.setSimple(false); instruction.setSendStartConfirmation(true); instruction.setProcessInterfaceBean(this); if (LOGGER.isDebugEnabled() && instruction instanceof PcpChildWfTaskCreationInstruction) { PcpChildWfTaskCreationInstruction instr = (PcpChildWfTaskCreationInstruction) instruction; LOGGER.debug("About to start approval process instance '{}'", instr.getProcessInstanceName()); if (instr.getProcessContent() instanceof ItemApprovalSpecificContent) { ItemApprovalSpecificContent iasc = (ItemApprovalSpecificContent) instr.getProcessContent(); LOGGER.debug("Approval schema XML:\n{}", PrismUtil.serializeQuietlyLazily(prismContext, iasc.approvalSchemaType)); LOGGER.debug("Attached rules:\n{}", PrismUtil.serializeQuietlyLazily(prismContext, iasc.policyRules)); } } }
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; } }
public static <X> Collection<PrismPropertyValue<X>> toPrismPropertyValues(PrismContext prismContext, X... realValues) { Collection<PrismPropertyValue<X>> pvalues = new ArrayList<>(realValues.length); for (X val: realValues) { PrismUtil.recomputeRealValue(val, prismContext); PrismPropertyValue<X> pval = prismContext.itemFactory().createPropertyValue(val); pvalues.add(pval); } return pvalues; }
PrismUtil.setDeltaOldValue(targetObject, itemDelta);
public static void createTriggersForTimedActions(String workItemId, int escalationLevel, Date workItemCreateTime, Date workItemDeadline, Task wfTask, List<WorkItemTimedActionsType> timedActionsList, OperationResult result) { LOGGER.trace("Creating triggers for timed actions for work item {}, escalation level {}, create time {}, deadline {}, {} timed action(s)", workItemId, escalationLevel, workItemCreateTime, workItemDeadline, timedActionsList.size()); try { PrismContext prismContext = getPrismContext(); List<TriggerType> triggers = WfContextUtil.createTriggers(escalationLevel, workItemCreateTime, workItemDeadline, timedActionsList, prismContext, LOGGER, workItemId, WfTimedActionTriggerHandler.HANDLER_URI); LOGGER.trace("Adding {} triggers to {}:\n{}", triggers.size(), wfTask, PrismUtil.serializeQuietlyLazily(prismContext, triggers)); if (!triggers.isEmpty()) { List<ItemDelta<?, ?>> itemDeltas = prismContext.deltaFor(TaskType.class) .item(TaskType.F_TRIGGER).add(PrismContainerValue.toPcvList(triggers)) .asItemDeltas(); getCacheRepositoryService().modifyObject(TaskType.class, wfTask.getOid(), itemDeltas, result); } } catch (ObjectNotFoundException | SchemaException | ObjectAlreadyExistsException | RuntimeException e) { throw new SystemException("Couldn't add trigger(s) to " + wfTask + ": " + e.getMessage(), e); } }
@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()); } });
public static <O extends Objectable, C extends Containerable> Collection<PrismContainerValue<C>> toPrismContainerValues( Class<O> type, ItemPath path, PrismContext prismContext, C... containerValues) throws SchemaException { Collection<PrismContainerValue<C>> pvalues = new ArrayList<>(containerValues.length); for (C val: containerValues) { prismContext.adopt(val, type, path); PrismUtil.recomputeRealValue(val, prismContext); PrismContainerValue<C> pval = val.asPrismContainerValue(); pvalues.add(pval); } return pvalues; } }
PrismUtil.setDeltaOldValue(preReadShadow, sideEffectDeltas); } else { PrismUtil.setDeltaOldValue(repoShadow, sideEffectDeltas);
@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 recompute(PrismContext prismContext) { if (isRaw()) { return; } T realValue = getValue(); if (realValue == null) { return; } checkMutability(); // TODO reconsider this PrismUtil.recomputeRealValue(realValue, prismContext); }
WorkItemEvent workItemEvent = (WorkItemEvent) workflowEvent; body.append("WorkItem:\n") .append(PrismUtil.serializeQuietly(prismContext, workItemEvent.getWorkItem())) .append("\n"); .append(PrismUtil.serializeQuietly(prismContext, ((WorkflowEvent) event).getWorkflowContext()));
PrismUtil.recomputeRealValue(convertedVal, prismContext); return convertedVal;
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); }