コード例 #1
0
  private String buildTaskUrl(UriInfo uriInfo, DpsTask task, String topologyName) {

    StringBuilder taskUrl =
        new StringBuilder()
            .append(uriInfo.getBaseUri().toString())
            .append("topologies/")
            .append(topologyName)
            .append("/tasks/")
            .append(task.getTaskId());

    return taskUrl.toString();
  }
コード例 #2
0
  /**
   * 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();
  }