Package org.eclipse.orion.server.core.tasks

Examples of org.eclipse.orion.server.core.tasks.ITaskService


      handleException(resp, "Invalid request paramethers, try {" + TaskStatus.ABORT.toString() + ":true}", e1, HttpServletResponse.SC_BAD_REQUEST);
    }

    boolean isKeep = "id".equals(path.segment(0));
    String taskId = path.segment(1);
    ITaskService taskService = taskTracker.getService();
    try {
      taskService.cancelTask(TaskJobHandler.getUserId(req), taskId, isKeep);
    } catch (TaskDoesNotExistException e) {
      handleException(resp, "Could not cancel task that does not exist: " + e.getTaskId(), e, HttpServletResponse.SC_NOT_FOUND);
      return;
    } catch (TaskOperationException e) {
      handleException(resp, e.getMessage(), e);
View Full Code Here


  @Override
  protected void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    traceRequest(req);
    String pathInfo = req.getPathInfo();
    IPath path = pathInfo == null ? Path.EMPTY : new Path(pathInfo);
    ITaskService taskService = taskTracker.getService();
    if (path.segmentCount() == 0) {
      taskService.removeCompletedTasks(TaskJobHandler.getUserId(req));
      List<TaskInfo> tasks = taskService.getTasks(TaskJobHandler.getUserId(req));
      List<String> locations = new ArrayList<String>();
      try {
        for (TaskInfo task : tasks) {
          locations.add(getJsonWithLocation(req, task).optString(ProtocolConstants.KEY_LOCATION));
        }
      } catch (Exception e) {
        handleException(resp, e.getMessage(), e);
      }
      writeJSONResponse(req, resp, new JSONArray(locations));
      return;
    }

    if (path.segmentCount() != 2 || (!"id".equals(path.segment(0)) && !"temp".equals(path.segment(0)))) {//$NON-NLS-1$
      handleException(resp, "Invalid request path: " + EncodingUtils.encodeForHTML(path.toString()), null, HttpServletResponse.SC_BAD_REQUEST);
      return;
    }

    boolean isKeep = "id".equals(path.segment(0));

    String taskId = path.segment(1);
    try {
      taskService.removeTask(TaskJobHandler.getUserId(req), taskId, isKeep);
    } catch (TaskDoesNotExistException e) {
      handleException(resp, "Could not remove task that does not exist: " + e.getTaskId(), e, HttpServletResponse.SC_NOT_FOUND);
      return;
    } catch (TaskOperationException e) {
      handleException(resp, e.getMessage(), e);
View Full Code Here

  @Override
  protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    traceRequest(req);
    String pathInfo = req.getPathInfo();
    IPath path = pathInfo == null ? Path.EMPTY : new Path(pathInfo);
    ITaskService taskService = taskTracker.getService();

    if (path.segmentCount() == 0) {

      List<TaskInfo> tasks = taskService.getTasks(TaskJobHandler.getUserId(req));
      try {
        writeJSONResponse(req, resp, getTasksList(tasks, req, resp));
      } catch (JSONException e) {
        handleException(resp, e.getMessage(), e);
        return;
      } catch (URISyntaxException e) {
        handleException(resp, e.getMessage(), e);
        return;
      }

      return;
    }

    if (path.segmentCount() != 2 || (!"id".equals(path.segment(0)) && !"temp".equals(path.segment(0)))) {//$NON-NLS-1$
      handleException(resp, "Invalid request path: " + EncodingUtils.encodeForHTML(path.toString()), null, HttpServletResponse.SC_BAD_REQUEST);
      return;
    }
    if (taskService == null) {
      handleException(resp, "Task service is unavailable", null);
      return;
    }
    String taskId = path.segment(1);
    boolean keep = "id".equals(path.segment(0));
    TaskInfo task = taskService.getTask(TaskJobHandler.getUserId(req), taskId, keep);

    if (task == null) {
      JSONObject errorDescription = new JSONObject();
      try {
        errorDescription.put("taskNotFound", taskId);
View Full Code Here

    }
  }

  @Test
  public void testUniqueTaskInfo() throws InterruptedException { //see Bug 370729
    final ITaskService taskService = new TaskService(new Path(tempDir.getAbsolutePath()));
    int numberOfChecks = 100;
    Job[] jobs = new Job[numberOfChecks];
    final TaskInfo[] taskInfos = new TaskInfo[numberOfChecks];
    for (int i = 0; i < numberOfChecks; i++) {
      jobs[i] = new TaskStoreTestJob(taskService, taskInfos, i);
View Full Code Here

TOP

Related Classes of org.eclipse.orion.server.core.tasks.ITaskService

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.