Class TaskRestController
- java.lang.Object
 - 
- org.neotropic.kuwaiba.northbound.rest.aem.TaskRestController
 
 
- 
- All Implemented Interfaces:
 TaskRestOpenApi
@RestController @RequestMapping("/v2.1.1/task-manager/") public class TaskRestController extends Object implements TaskRestOpenApiTask Rest Controller.- Author:
 - Mauricio Ruiz Beltrán <mauricio.ruiz@kuwaiba.org>
 
 
- 
- 
Constructor Summary
Constructors Constructor Description TaskRestController() 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longcreateTask(Task task, String sessionId)Creates and schedule a task.voiddeleteTask(long id, String sessionId)Deletes a task and unsubscribes all users from it.TaskResultexecuteTask(long id, String sessionId)Executes a task on demand.List<UserProfileLight>getSubscribersForTask(long id, String sessionId)Gets the subscribers of a particular task.TaskgetTask(long id, String sessionId)Retrieves the information about a particular task.List<Task>getTasks(String sessionId)Gets all registered tasks.List<Task>getTasksForUser(long userId, String sessionId)Gets the tasks associated to a particular user.ChangeDescriptorsubscribeUserToTask(long userId, long id, String sessionId)Subscribes a user to a task, so it will be notified of the result of its execution.ChangeDescriptorunsubscribeUserFromTask(long userId, long id, String sessionId)Unsubscribes a user from a task, so it will no longer be notified about the result of its execution.ChangeDescriptorupdateTaskNotificationType(long id, TaskNotificationDescriptor notificationType, String sessionId)Updates a task notification type.ChangeDescriptorupdateTaskParameters(long id, List<StringPair> parameters, String sessionId)Updates the parameters of a task.ChangeDescriptorupdateTaskProperties(long id, String property, String value, String sessionId)Updates any of these properties from a task: name, description, enabled and script.ChangeDescriptorupdateTaskSchedule(long id, TaskScheduleDescriptor schedule, String sessionId)Updates a task schedule. 
 - 
 
- 
- 
Field Detail
- 
PATH
public static final String PATH
Path that includes the Kuwaiba version and the module id- See Also:
 - Constant Field Values
 
 
 - 
 
- 
Method Detail
- 
createTask
@RequestMapping(method=POST, value="createTask/{sessionId}", produces="application/json") public long createTask(@RequestBody Task task, @PathVariable("sessionId") String sessionId)Creates and schedule a task. A task is an application entity that allows to run jobs that will be executed depending on certain schedule.- Specified by:
 createTaskin interfaceTaskRestOpenApi- Parameters:
 task- The task that contains, name, description, is the task enabled?, commitOnExecute Should this task commit the changes made (if any) after executing it?, the script to be executed, the parameters for the script, schedule When the task should be executed, notificationType How the result of the task should be notified to the associated users. With the following structure:{ "name" : "", "description" : "", "enabled" : boolean, "commitOnExecute" : boolean, "script" : "", "parameters" : [ { "key": "", "value": "" }, { "key": "", "value": "" } ], "schedule" : { "startTime": long, "everyXMinutes": int, "executionType": int }, "notificationType": { "email": "", "notificationType": int } }sessionId- The session token id.- Returns:
 - The id of the newly created task.
 
 
- 
updateTaskProperties
@RequestMapping(method=PUT, value="updateTaskProperties/{id}/{property}/{value}/{sessionId}", produces="application/json") public ChangeDescriptor updateTaskProperties(@PathVariable("id") long id, @PathVariable("property") String property, @PathVariable("value") String value, @PathVariable("sessionId") String sessionId)Updates any of these properties from a task: name, description, enabled and script.- Specified by:
 updateTaskPropertiesin interfaceTaskRestOpenApi- Parameters:
 id- Task id.property- Property name. Possible values: "name", "description", "enabled" and "script".value- The value of the property. For the property "enabled", the allowed values are "true" and "false".sessionId- The session token id.- Returns:
 - The summary of the changes.
 
 
- 
updateTaskParameters
@RequestMapping(method=PUT, value="updateTaskParameters/{id}/{sessionId}", produces="application/json") public ChangeDescriptor updateTaskParameters(@PathVariable("id") long id, @RequestBody List<StringPair> parameters, @PathVariable("sessionId") String sessionId)Updates the parameters of a task. If any of the values is null, that parameter will be deleted, if the parameter does not exist, it will be created.- Specified by:
 updateTaskParametersin interfaceTaskRestOpenApi- Parameters:
 id- Task id.parameters- The parameters to be modified as pairs paramName/paramValue.sessionId- The session token id.- Returns:
 - The summary of the changes.
 
 
- 
updateTaskSchedule
@RequestMapping(method=PUT, value="updateTaskSchedule/{id}/{sessionId}", produces="application/json") public ChangeDescriptor updateTaskSchedule(@PathVariable("id") long id, @RequestBody TaskScheduleDescriptor schedule, @PathVariable("sessionId") String sessionId)Updates a task schedule.- Specified by:
 updateTaskSchedulein interfaceTaskRestOpenApi- Parameters:
 id- Task id.schedule- New schedule.sessionId- The session token id.- Returns:
 - The summary of the changes.
 
 
- 
updateTaskNotificationType
@RequestMapping(method=PUT, value="updateTaskNotificationType/{id}/{sessionId}", produces="application/json") public ChangeDescriptor updateTaskNotificationType(@PathVariable("id") long id, @RequestBody TaskNotificationDescriptor notificationType, @PathVariable("sessionId") String sessionId)Updates a task notification type.- Specified by:
 updateTaskNotificationTypein interfaceTaskRestOpenApi- Parameters:
 id- Task id.notificationType- New notification type.sessionId- The session token id.- Returns:
 - The summary of the changes.
 
 
- 
deleteTask
@RequestMapping(method=DELETE, value="deleteTask/{id}/{sessionId}", produces="application/json") public void deleteTask(@PathVariable("id") long id, @PathVariable("sessionId") String sessionId)Deletes a task and unsubscribes all users from it.- Specified by:
 deleteTaskin interfaceTaskRestOpenApi- Parameters:
 id- Task id.sessionId- The session token id.
 
- 
subscribeUserToTask
@RequestMapping(method=PUT, value="subscribeUserToTask/{userId}/{id}/{sessionId}", produces="application/json") public ChangeDescriptor subscribeUserToTask(@PathVariable("userId") long userId, @PathVariable("id") long id, @PathVariable("sessionId") String sessionId)Subscribes a user to a task, so it will be notified of the result of its execution.- Specified by:
 subscribeUserToTaskin interfaceTaskRestOpenApi- Parameters:
 userId- Id of the user.id- Id of the task.sessionId- The session token id.- Returns:
 - The summary of the changes.
 
 
- 
unsubscribeUserFromTask
@RequestMapping(method=PUT, value="unsubscribeUserFromTask/{userId}/{id}/{sessionId}", produces="application/json") public ChangeDescriptor unsubscribeUserFromTask(@PathVariable("userId") long userId, @PathVariable("id") long id, @PathVariable("sessionId") String sessionId)Unsubscribes a user from a task, so it will no longer be notified about the result of its execution.- Specified by:
 unsubscribeUserFromTaskin interfaceTaskRestOpenApi- Parameters:
 userId- Id of the user.id- Id of the task.sessionId- The session token id.- Returns:
 - The summary of the changes.
 
 
- 
getTask
@RequestMapping(method=GET, value="getTask/{id}/{sessionId}", produces="application/json") public Task getTask(@PathVariable("id") long id, @PathVariable("sessionId") String sessionId)Retrieves the information about a particular task.- Specified by:
 getTaskin interfaceTaskRestOpenApi- Parameters:
 id- Id of the task.sessionId- The session token id.- Returns:
 - A list with the task objects.
 
 
- 
getSubscribersForTask
@RequestMapping(method=GET, value="getSubscribersForTask/{id}/{sessionId}", produces="application/json") public List<UserProfileLight> getSubscribersForTask(@PathVariable("id") long id, @PathVariable("sessionId") String sessionId)Gets the subscribers of a particular task.- Specified by:
 getSubscribersForTaskin interfaceTaskRestOpenApi- Parameters:
 id- Task id.sessionId- The session token id.- Returns:
 - The list of users subscribers to the task identified with the id taskId.
 
 
- 
getTasks
@RequestMapping(method=GET, value="getTasks/{sessionId}", produces="application/json") public List<Task> getTasks(@PathVariable("sessionId") String sessionId)Gets all registered tasks.- Specified by:
 getTasksin interfaceTaskRestOpenApi- Parameters:
 sessionId- The session token id.- Returns:
 - A list with the task objects.
 
 
- 
getTasksForUser
@RequestMapping(method=GET, value="getTasksForUser/{userId}/{sessionId}", produces="application/json") public List<Task> getTasksForUser(@PathVariable("userId") long userId, @PathVariable("sessionId") String sessionId)Gets the tasks associated to a particular user.- Specified by:
 getTasksForUserin interfaceTaskRestOpenApi- Parameters:
 userId- Id of the user.sessionId- The session token id.- Returns:
 - A list with the task objects.
 
 
- 
executeTask
@RequestMapping(method=PUT, value="executeTask/{id}/{sessionId}", produces="application/json") public TaskResult executeTask(@PathVariable("id") long id, @PathVariable("sessionId") String sessionId)Executes a task on demand. The task may have user-defined parameters that must be set using#updateTaskParameters(long, java.util.List)before running the task.- Specified by:
 executeTaskin interfaceTaskRestOpenApi- Parameters:
 id- Id of the task. Could be known by calling#getTasks()first.sessionId- The session token id.- Returns:
 - An 
TaskResultinstance representing the task result. 
 
 - 
 
 -