Ejemplo n.º 1
0
  @GET
  @Path("{queryId}")
  @Produces(MediaType.APPLICATION_JSON)
  public Response getQuery(
      @PathParam("queryId") String queryId,
      @DefaultValue(defaultQueryInfoPrintType) @QueryParam("print") String printType) {
    if (LOG.isDebugEnabled()) {
      LOG.debug("Client sent a get query request.");
    }

    Response response = null;

    try {
      initializeContext();
      JerseyResourceDelegateContextKey<String> queryIdKey =
          JerseyResourceDelegateContextKey.valueOf(queryIdKeyName, String.class);
      context.put(queryIdKey, queryId);
      JerseyResourceDelegateContextKey<String> printTypeKey =
          JerseyResourceDelegateContextKey.valueOf(printTypeKeyName, String.class);

      context.put(printTypeKey, printType);

      response =
          JerseyResourceDelegateUtil.runJerseyResourceDelegate(
              new GetQueryDelegate(), application, context, LOG);
    } catch (Throwable e) {
      LOG.error(e.getMessage(), e);

      response = ResourcesUtil.createExceptionResponse(null, e.getMessage());
    }

    return response;
  }
Ejemplo n.º 2
0
  @DELETE
  @Path("{queryId}")
  public Response terminateQuery(@PathParam("queryId") String queryId) {
    if (LOG.isDebugEnabled()) {
      LOG.debug("Client sent a terminate query request.");
    }

    Response response = null;

    try {
      initializeContext();
      JerseyResourceDelegateContextKey<String> queryIdKey =
          JerseyResourceDelegateContextKey.valueOf(queryIdKeyName, String.class);
      context.put(queryIdKey, queryId);

      response =
          JerseyResourceDelegateUtil.runJerseyResourceDelegate(
              new TerminateQueryDelegate(), application, context, LOG);
    } catch (Throwable e) {
      LOG.error(e.getMessage(), e);

      response = ResourcesUtil.createExceptionResponse(null, e.getMessage());
    }

    return response;
  }
Ejemplo n.º 3
0
  @POST
  @Consumes(MediaType.APPLICATION_JSON)
  public Response submitQuery(
      @HeaderParam(tajoSessionIdHeaderName) String sessionId, SubmitQueryRequest request) {
    if (LOG.isDebugEnabled()) {
      LOG.debug("Client sent a submit query request.");
    }

    Response response = null;

    try {
      initializeContext();
      JerseyResourceDelegateContextKey<String> sessionIdKey =
          JerseyResourceDelegateContextKey.valueOf(sessionIdKeyName, String.class);
      context.put(sessionIdKey, sessionId);
      JerseyResourceDelegateContextKey<SubmitQueryRequest> submitQueryRequestKey =
          JerseyResourceDelegateContextKey.valueOf(
              submitQueryRequestKeyName, SubmitQueryRequest.class);
      context.put(submitQueryRequestKey, request);

      response =
          JerseyResourceDelegateUtil.runJerseyResourceDelegate(
              new SubmitQueryDelegate(), application, context, LOG);

    } catch (Throwable e) {
      LOG.error(e.getMessage(), e);

      response = ResourcesUtil.createExceptionResponse(null, e.getMessage());
    }

    return response;
  }
Ejemplo n.º 4
0
  @GET
  @Produces(MediaType.APPLICATION_JSON)
  public Response getAllQueries(
      @QueryParam("state") String state,
      @QueryParam("startTime") long startTime,
      @QueryParam("endTime") long endTime) {
    if (LOG.isDebugEnabled()) {
      LOG.debug("Client sent a get all queries request.");
    }

    Response response = null;

    try {
      initializeContext();
      JerseyResourceDelegateContextKey<String> stateKey =
          JerseyResourceDelegateContextKey.valueOf(stateKeyName, String.class);
      if (state != null && !state.isEmpty()) {
        context.put(stateKey, state);
      }
      JerseyResourceDelegateContextKey<Long> startTimeKey =
          JerseyResourceDelegateContextKey.valueOf(startTimeKeyName, Long.class);
      if (startTime > 0) {
        context.put(startTimeKey, startTime);
      }
      JerseyResourceDelegateContextKey<Long> endTimeKey =
          JerseyResourceDelegateContextKey.valueOf(endTimeKeyName, Long.class);
      if (endTime > 0) {
        context.put(endTimeKey, endTime);
      }

      response =
          JerseyResourceDelegateUtil.runJerseyResourceDelegate(
              new GetAllQueriesDelegate(), application, context, LOG);
    } catch (Throwable e) {
      LOG.error(e.getMessage(), e);

      response = ResourcesUtil.createExceptionResponse(null, e.getMessage());
    }

    return response;
  }