com.evolveum.midpoint.task.api.TaskManager.modifyTask()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(3.4k)|赞(0)|评价(0)|浏览(125)

本文整理了Java中com.evolveum.midpoint.task.api.TaskManager.modifyTask()方法的一些代码示例,展示了TaskManager.modifyTask()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TaskManager.modifyTask()方法的具体详情如下:
包路径:com.evolveum.midpoint.task.api.TaskManager
类名称:TaskManager
方法名:modifyTask

TaskManager.modifyTask介绍

[英]Modifies task using relative change description. Must fail if object with provided OID does not exists. Must fail if any of the described changes cannot be applied. Should be atomic. If two or more modify operations are executed in parallel, the operations should be merged. In case that the operations are in conflict (e.g. one operation adding a value and the other removing the same value), the result is not deterministic. The operation may fail if the modified object does not conform to the underlying schema of the storage system or the schema enforced by the implementation. HOWEVER, the preferred way of modifying tasks is to use methods in Task interface.
[中]使用相对更改描述修改任务。如果提供OID的对象不存在,则必须失败。如果无法应用任何描述的更改,则必须失败。应该是原子的。如果两个或多个修改操作并行执行,则应合并这些操作。如果操作发生冲突(例如,一个操作添加一个值,另一个操作删除相同的值),结果是不确定的。如果修改的对象不符合存储系统的基础架构或实现强制执行的架构,则操作可能会失败。然而,修改任务的首选方法是使用任务接口中的方法。

代码示例

代码示例来源:origin: Evolveum/midpoint

  1. public void deleteWorkersAndWorkState(String coordinatorTaskOid, long subtasksWaitTime, OperationResult result)
  2. throws SchemaException, ObjectNotFoundException {
  3. Task coordinatorTask = taskManager.getTask(coordinatorTaskOid, result);
  4. if (coordinatorTask.getKind() != TaskKindType.COORDINATOR) {
  5. throw new IllegalArgumentException("Task is not a coordinator task: " + coordinatorTask);
  6. }
  7. if (coordinatorTask.getExecutionStatus() == TaskExecutionStatus.WAITING) {
  8. throw new IllegalStateException("Couldn't delete workers and work state while operation is in progress (coordinator state is WAITING): " + coordinatorTask);
  9. }
  10. if (coordinatorTask.getExecutionStatus() == TaskExecutionStatus.RUNNABLE && coordinatorTask.getNodeAsObserved() != null) {
  11. throw new IllegalStateException("Couldn't delete workers and work state while operation is in progress (coordinator "
  12. + "state is RUNNABLE and it is executing on " + coordinatorTask.getNodeAsObserved() + "): " + coordinatorTask);
  13. }
  14. List<Task> subtasks = coordinatorTask.listSubtasks(true, result);
  15. taskManager.suspendAndDeleteTasks(TaskUtil.tasksToOids(subtasks), subtasksWaitTime, true, result);
  16. List<ItemDelta<?, ?>> itemDeltas = prismContext.deltaFor(TaskType.class)
  17. .item(TaskType.F_WORK_STATE).replace()
  18. .asItemDeltas();
  19. try {
  20. taskManager.modifyTask(coordinatorTaskOid, itemDeltas, result);
  21. } catch (ObjectAlreadyExistsException e) {
  22. throw new IllegalStateException("Unexpected exception: " + e.getMessage(), e);
  23. }
  24. }
  25. }

代码示例来源:origin: Evolveum/midpoint

  1. private void moveWorker(Task worker, WorkerKey shouldBe, OperationResult result)
  2. throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException {
  3. List<ItemDelta<?, ?>> itemDeltas = prismContext.deltaFor(TaskType.class)
  4. .item(TaskType.F_EXECUTION_CONSTRAINTS, TaskExecutionConstraintsType.F_GROUP).replace(shouldBe.group)
  5. .item(TaskType.F_NAME).replace(PolyString.fromOrig(shouldBe.name))
  6. .asItemDeltas();
  7. LOGGER.info("Moving worker task {} to {} as {}", worker, shouldBe.group, shouldBe.name);
  8. taskManager.modifyTask(worker.getOid(), itemDeltas, result);
  9. }

代码示例来源:origin: Evolveum/midpoint

  1. taskManager.modifyTask(delta.getOid(), delta.getModifications(), result);
  2. } else if (NodeType.class.isAssignableFrom(objectTypeClass)) {
  3. throw new UnsupportedOperationException("NodeType is not modifiable using model interface");

相关文章