/**
   * Retrieves a task with the given taskId from the specified topology. <br>
   * <br>
   * <div style='border-left: solid 5px #999999; border-radius: 10px; padding: 6px;'>
   * <strong>Required permissions:</strong>
   *
   * <ul>
   *   <li>Authenticated user
   *   <li>Read permission for selected task
   * </ul>
   *
   * </div>
   *
   * @summary Task retrieval
   * @param topologyName <strong>REQUIRED</strong> Name of the topology where the task is submitted.
   * @param taskId <strong>REQUIRED</strong> Unique id that identifies the task.
   * @return The requested task.
   */
  @GET
  @PreAuthorize("hasPermission(#taskId,'" + TASK_PREFIX + "', read)")
  @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
  @Path("/{taskId}")
  public DpsTask getTask(
      @PathParam("topologyName") String topologyName, @PathParam("taskId") String taskId) {

    LOGGER.info("Fetching task");
    DpsTask task = submitService.fetchTask(topologyName, Long.valueOf(taskId));
    return task;
  }
  /**
   * Submits a Task for execution. Each Task execution is associated with a specific plugin.
   *
   * <p><strong>Write permissions required</strong>.
   *
   * @summary Submit Task
   * @param task <strong>REQUIRED</strong> Task to be executed. Should contain links to input data,
   *     either in form of cloud-records or cloud-datasets.
   * @param topologyName <strong>REQUIRED</strong> Name of the topology where the task is submitted.
   * @return URI with information about the submitted task execution.
   */
  @POST
  @Consumes({MediaType.APPLICATION_JSON})
  @PreAuthorize("hasPermission(#topologyName,'" + TOPOLOGY_PREFIX + "', write)")
  @Path("/")
  public Response submitTask(
      DpsTask task, @PathParam("topologyName") String topologyName, @Context UriInfo uriInfo) {

    LOGGER.info("Submiting task");

    if (task != null) {
      submitService.submitTask(task, topologyName);
      grantPermissionsForTask(task.getTaskId() + "");
      String createdTaskUrl = buildTaskUrl(uriInfo, task, topologyName);
      try {
        LOGGER.info("Task submitted succesfully");
        return Response.created(new URI(createdTaskUrl)).build();
      } catch (URISyntaxException e) {
        LOGGER.error("Task submition failed");
        e.printStackTrace();
        return Response.serverError().build();
      }
    }
    return Response.notModified().build();
  }