@DELETE @Path("{taskId}/results/{bufferId}") @Produces(MediaType.APPLICATION_JSON) public void abortResults(@PathParam("taskId") TaskId taskId, @PathParam("bufferId") OutputBufferId bufferId, @Context UriInfo uriInfo) { requireNonNull(taskId, "taskId is null"); requireNonNull(bufferId, "bufferId is null"); taskManager.abortTaskResults(taskId, bufferId); }
@GET @Produces(MediaType.APPLICATION_JSON) public List<TaskInfo> getAllTaskInfo(@Context UriInfo uriInfo) { List<TaskInfo> allTaskInfo = taskManager.getAllTaskInfo(); if (shouldSummarize(uriInfo)) { allTaskInfo = ImmutableList.copyOf(transform(allTaskInfo, TaskInfo::summarize)); } return allTaskInfo; }
@POST @Path("/offsets/end") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response setEndOffsetsHTTP( Map<Integer, Long> offsets, @Context final HttpServletRequest req ) throws InterruptedException { authorizationCheck(req, Action.WRITE); return setEndOffsets(offsets); }
@GET public Response redirectIndexHtml( @HeaderParam(X_FORWARDED_PROTO) String proto, @Context UriInfo uriInfo) { if (isNullOrEmpty(proto)) { proto = uriInfo.getRequestUri().getScheme(); } return Response.status(MOVED_PERMANENTLY) .location(uriInfo.getRequestUriBuilder().scheme(proto).path("/ui/").build()) .build(); } }
@Path("start") @POST public Response post(@DefaultValue("0") @QueryParam("testSources") int testSources, @Context Sse sse) { final Process process = new Process(testSources, sse); processes.put(process.getId(), process); Executors.newSingleThreadExecutor().execute(process); final URI processIdUri = UriBuilder.fromResource(DomainResource.class).path("process/{id}").build(process.getId()); return Response.created(processIdUri).build(); }
@GET public Response getIndex(@Context ContainerRequest request, @Context HttpHeaders headers) { final URI originalLocation = request.getRequestUri(); if (originalLocation.getPath().endsWith("/")) { return get(request, headers, originalLocation.getPath()); } final URI redirect = UriBuilder.fromPath(originalLocation.getPath() + "/").build(); return Response.temporaryRedirect(redirect).build(); }
@Service public class DubboSwaggerApiListingResource extends BaseApiListingResource implements DubboSwaggerService { @Context ServletContext context; @Override public Response getListingJson(Application app, ServletConfig sc, HttpHeaders headers, UriInfo uriInfo) throws JsonProcessingException { Response response = getListingJsonResponse(app, context, sc, headers, uriInfo); response.getHeaders().add("Access-Control-Allow-Origin", "*"); response.getHeaders().add("Access-Control-Allow-Headers", "x-requested-with, ssi-token"); response.getHeaders().add("Access-Control-Max-Age", "3600"); response.getHeaders().add("Access-Control-Allow-Methods","GET,POST,PUT,DELETE,OPTIONS"); return response; } }
@Override public Injectable<Injectable> getInjectable(ComponentContext ic, Context a, Type c) { if (c instanceof ParameterizedType) { ParameterizedType pt = (ParameterizedType)c; if (pt.getRawType() == Injectable.class) { if (pt.getActualTypeArguments().length == 1) { final Injectable<?> i = injectableFactory.getInjectable( a.annotationType(), ic, a, pt.getActualTypeArguments()[0], ComponentScope.PERREQUEST_UNDEFINED_SINGLETON); if (i == null) return null; return new Injectable<Injectable>() { @Override public Injectable getValue() { return i; } }; } } } return null; } });
@Path("/chat/{id}") public Object doTaskChat(@PathParam("id") String handlerId, @Context HttpHeaders headers) { if (taskId != null) { List<String> requestTaskId = headers.getRequestHeader(TASK_ID_HEADER); if (requestTaskId != null && !requestTaskId.contains(StringUtils.urlEncode(taskId))) { return null; } } final Optional<ChatHandler> handler = handlers.get(handlerId); if (handler.isPresent()) { return handler.get(); } return null; } }
@Service public class DubboSwaggerApiListingResource extends BaseApiListingResource implements DubboSwaggerService { @Context ServletContext context; @Override public Response getListingJson(Application app, ServletConfig sc, HttpHeaders headers, UriInfo uriInfo) throws JsonProcessingException { Response response = getListingJsonResponse(app, context, sc, headers, uriInfo); response.getHeaders().add("Access-Control-Allow-Origin", "*"); response.getHeaders().add("Access-Control-Allow-Headers", "x-requested-with, ssi-token"); response.getHeaders().add("Access-Control-Max-Age", "3600"); response.getHeaders().add("Access-Control-Allow-Methods","GET,POST,PUT,DELETE,OPTIONS"); return response; } }