protected void addTriggers(String oid, Collection<XMLGregorianCalendar> timestamps, String uri) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".addTriggers"); OperationResult result = task.getResult(); Collection<TriggerType> triggers = timestamps.stream() .map(ts -> new TriggerType().timestamp(ts).handlerUri(uri)) .collect(Collectors.toList()); ObjectDelta<ObjectType> delta = prismContext.deltaFor(ObjectType.class) .item(ObjectType.F_TRIGGER).addRealValues(triggers) .asObjectDeltaCast(oid); executeChanges(delta, null, task, result); result.computeStatus(); TestUtil.assertSuccess(result); }
protected void replaceTriggers(String oid, Collection<XMLGregorianCalendar> timestamps, String uri) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".replaceTriggers"); OperationResult result = task.getResult(); Collection<TriggerType> triggers = timestamps.stream() .map(ts -> new TriggerType().timestamp(ts).handlerUri(uri)) .collect(Collectors.toList()); ObjectDelta<ObjectType> delta = prismContext.deltaFor(ObjectType.class) .item(ObjectType.F_TRIGGER).replaceRealValues(triggers) .asObjectDeltaCast(oid); executeChanges(delta, null, task, result); result.computeStatus(); TestUtil.assertSuccess(result); }
@Override public void close(OperationResult taskResult, boolean saveState, OperationResult parentResult) throws ObjectNotFoundException, SchemaException { List<ItemDelta<?, ?>> deltas = new ArrayList<>(); if (taskResult != null) { addIgnoreNull(deltas, setResultAndPrepareDelta(taskResult)); addIgnoreNull(deltas, setResultStatusTypeAndPrepareDelta(taskResult.getStatus() != null ? taskResult.getStatus().createStatusType() : null)); } addIgnoreNull(deltas, setExecutionStatusAndPrepareDelta(TaskExecutionStatus.CLOSED)); addIgnoreNull(deltas, setCompletionTimestampAndPrepareDelta(System.currentTimeMillis())); Duration cleanupAfterCompletion = taskPrism.asObjectable().getCleanupAfterCompletion(); if (cleanupAfterCompletion != null) { TriggerType trigger = new TriggerType(getPrismContext()) .timestamp(XmlTypeConverter.fromNow(cleanupAfterCompletion)) .handlerUri(SchemaConstants.COMPLETED_TASK_CLEANUP_TRIGGER_HANDLER_URI); addIgnoreNull(deltas, addTriggerAndPrepareDelta( trigger)); // we just ignore any other triggers (they will do nothing if launched too early) } if (saveState) { try { processModificationsNow(deltas, parentResult); } catch (ObjectAlreadyExistsException e) { throw new SystemException(e); } } else { pendingModifications.addAll(deltas); } }