17 |
@Path("/tasks") |
@Path("/tasks") |
18 |
public class TaskRestService { |
public class TaskRestService { |
19 |
|
|
20 |
|
@Context ServletContext context; |
21 |
|
|
22 |
|
|
23 |
@Path("/list") |
@Path("/list") |
24 |
@GET |
@GET |
25 |
@Produces(MediaType.APPLICATION_JSON) |
@Produces(MediaType.APPLICATION_JSON) |
26 |
public String listTasks(@Context ServletContext context ) { |
public String listTasks( ) { |
27 |
TaskManager taskManager = (TaskManager) context.getAttribute(TaskManager.TASKMANAGER); |
TaskManager taskManager = (TaskManager) context.getAttribute(TaskManager.TASKMANAGER); |
28 |
List<TaskBean> beans = taskManager.getTasks(); |
List<TaskBean> beans = taskManager.getTasks(); |
29 |
|
|
36 |
@Path("/log/{id}") |
@Path("/log/{id}") |
37 |
@GET |
@GET |
38 |
@Produces(MediaType.TEXT_PLAIN) |
@Produces(MediaType.TEXT_PLAIN) |
39 |
public String getLog(@Context ServletContext context, @PathParam("id") int taskId ) { |
public String getLog( @PathParam("id") int taskId ) { |
40 |
TaskManager taskManager = (TaskManager) context.getAttribute(TaskManager.TASKMANAGER); |
TaskManager taskManager = (TaskManager) context.getAttribute(TaskManager.TASKMANAGER); |
41 |
Task t = taskManager.getTaskById(taskId); |
Task t = taskManager.getTaskById(taskId); |
42 |
|
|
50 |
@Path("/remove/{id}") |
@Path("/remove/{id}") |
51 |
@GET |
@GET |
52 |
@Produces(MediaType.TEXT_PLAIN) |
@Produces(MediaType.TEXT_PLAIN) |
53 |
public String removeTask(@Context ServletContext context, @PathParam("id") int taskId ) { |
public String removeTask( @PathParam("id") int taskId ) { |
54 |
TaskManager taskManager = (TaskManager) context.getAttribute(TaskManager.TASKMANAGER); |
TaskManager taskManager = (TaskManager) context.getAttribute(TaskManager.TASKMANAGER); |
55 |
Task removeTask = taskManager.getTaskById(taskId); |
Task removeTask = taskManager.getTaskById(taskId); |
56 |
|
|