use of com.enonic.xp.task.TaskId in project xp by enonic.
the class TaskResource method getTask.
@GET
@Path("/{taskId}")
public TaskInfoJson getTask(@PathParam("taskId") final String taskIdString) {
final TaskId taskId = TaskId.from(taskIdString);
final TaskInfo taskInfo = taskService.getTaskInfo(taskId);
if (taskInfo == null) {
throw new WebApplicationException(String.format("Task [%s] was not found", taskIdString), Response.Status.NOT_FOUND);
}
return new TaskInfoJson(taskInfo);
}
use of com.enonic.xp.task.TaskId in project xp by enonic.
the class CleanUpAuditLogCommand method execute.
public TaskResultJson execute() {
PropertyTree config = new PropertyTree();
if (params.getAgeThreshold() != null) {
config.addString("ageThreshold", params.getAgeThreshold());
}
final TaskId taskId = taskService.submitTask(SubmitTaskParams.create().descriptorKey(DescriptorKey.from("com.enonic.xp.app.system:audit-log-cleanup")).data(config).build());
return new TaskResultJson(taskId);
}
use of com.enonic.xp.task.TaskId in project xp by enonic.
the class ContentResourceTest method reprocess_task_skip_children.
@Test
public void reprocess_task_skip_children() throws Exception {
Content content = createContent("content-id", ContentPath.from("/path/to/content"));
Content reprocessedContent = Content.create(content).displayName("new name").build();
TaskId taskId = TaskId.from("task-id");
Mockito.when(this.contentService.getByPath(content.getPath())).thenReturn(content);
Mockito.when(this.contentService.reprocess(content.getId())).thenReturn(reprocessedContent);
Mockito.when(this.taskService.submitTask(Mockito.any(RunnableTask.class), Mockito.anyString())).thenReturn(taskId);
final String result = request().path("content/reprocessTask").entity(readFromFile("reprocess_params_skip_children.json"), MediaType.APPLICATION_JSON_TYPE).post().getAsString();
assertEquals("{\"taskId\":\"task-id\"}", result);
}
use of com.enonic.xp.task.TaskId in project xp by enonic.
the class ExecuteFunctionHandler method executeFunction.
public String executeFunction() {
final TaskService taskService = taskServiceSupplier.get();
final TaskWrapper taskWrapper = new TaskWrapper(taskFunction, description);
final TaskId taskId = taskService.submitTask(taskWrapper, description);
return taskId.toString();
}
use of com.enonic.xp.task.TaskId in project xp by enonic.
the class SubmitTaskHandler method submitTask.
public String submitTask() {
descriptor = descriptor == null ? "" : descriptor;
final DescriptorKey taskKey;
if (descriptor.contains(":")) {
taskKey = DescriptorKey.from(descriptor);
} else {
final ApplicationKey app = getApplication();
if (app == null) {
throw new RuntimeException("Could not resolve current application for descriptord task: '" + descriptor + "'");
}
taskKey = DescriptorKey.from(app, descriptor);
}
final TaskService taskService = taskServiceSupplier.get();
PropertyTree data = propertyTreeMarshallerServiceSupplier.get().marshal(Optional.ofNullable(config).map(ScriptValue::getMap).orElse(Map.of()));
final SubmitTaskParams params = SubmitTaskParams.create().descriptorKey(taskKey).data(data).build();
final TaskId taskId = taskService.submitTask(params);
return taskId.toString();
}
Aggregations