Java 类javax.ws.rs.core.Context 实例源码

项目:redirector    文件:RedirectorUI.java   
@GET
@Produces(MediaType.TEXT_HTML)
public Response defaultPage(@Context UriInfo ui) throws URISyntaxException {
    /*
    * This redirect is required due to change of "Jersey" version from "1.17" to "2.13".
    * The "1.*" version of jersey has property "FEATURE_REDIRECT".
    * For example, when making request "localhost:8888/context/dev", Jersey checks whether "FEATURE_REDIRECT" is set to "true" in ServletContainer and request does not end with '/'.
    * If so, trailing slash is added and redirect is occurred to "localhost:8888/context/dev/"
    *
    * Jersey "2.*" does not contain property "FEATURE_REDIRECT".
    * The code that made redirect in "1.*" jersey is commented out in ServletContainer.java:504
    * Jersey "2.*" resolves request even if '/' was not present in the end.
    * But all links in our *.jsp and *.html to *.js and *.css are relative. So without adding '/' in the end, files can not be opened.
    * To solve it, we introduced this redirect
    */
    if (!ui.getAbsolutePath().toString().endsWith("/")) {
        return Response.temporaryRedirect(new URI(ui.getAbsolutePath().toString() + "/")).build();
    } else {
        return Response.ok(new Viewable("/index.jsp", new HashMap<String, Object>())).build();
    }
}
项目:swaggy-jenkins    文件:BlueApi.java   
@GET
@Path("/rest/organizations/{organization}/scm/{scm}")

@Produces({ "application/json" })
@io.swagger.annotations.ApiOperation(value = "", notes = "Retrieve SCM details for an organization", response = GithubScm.class, authorizations = {
    @io.swagger.annotations.Authorization(value = "jenkins_auth")
}, tags={ "blueOcean", })
@io.swagger.annotations.ApiResponses(value = { 
    @io.swagger.annotations.ApiResponse(code = 200, message = "Successfully retrieved SCM details", response = GithubScm.class),

    @io.swagger.annotations.ApiResponse(code = 401, message = "Authentication failed - incorrect username and/or password", response = GithubScm.class),

    @io.swagger.annotations.ApiResponse(code = 403, message = "Jenkins requires authentication - please set username and password", response = GithubScm.class) })
public Response getSCM( @PathParam("organization") String organization, @PathParam("scm") String scm,@Context SecurityContext securityContext)
throws NotFoundException {
    return delegate.getSCM(organization,scm,securityContext);
}
项目:opencps-v2    文件:PaymentFileManagement.java   
@PUT
@Path("/{id}/payments/{referenceUid}/confirm/noattachment")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED})
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED})
@ApiOperation(value = "Update PaymentFile")
@ApiResponses(value = {
        @ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns"),
        @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Unauthorized", response = ExceptionModel.class),
        @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not found", response = ExceptionModel.class),
        @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class) })
public Response updatePaymentFileConfirmNoAttachment(@Context HttpServletRequest request, @Context HttpHeaders header,
        @Context Company company, @Context Locale locale, @Context User user,
        @Context ServiceContext serviceContext, 
        @ApiParam(value = "id of payments", required = true) @PathParam("id") String id,
        @ApiParam(value = "reference of paymentFile", required = true) @PathParam("referenceUid") String referenceUid,
        @BeanParam PaymentFileInputModel input);
项目:swaggy-jenkins    文件:JobApi.java   
@POST
@Path("/{name}/disable")


@io.swagger.annotations.ApiOperation(value = "", notes = "Disable a job", response = Void.class, authorizations = {
    @io.swagger.annotations.Authorization(value = "jenkins_auth")
}, tags={ "remoteAccess", })
@io.swagger.annotations.ApiResponses(value = { 
    @io.swagger.annotations.ApiResponse(code = 200, message = "Successfully disabled the job", response = Void.class),

    @io.swagger.annotations.ApiResponse(code = 401, message = "Authentication failed - incorrect username and/or password", response = Void.class),

    @io.swagger.annotations.ApiResponse(code = 403, message = "Jenkins requires authentication - please set username and password", response = Void.class),

    @io.swagger.annotations.ApiResponse(code = 404, message = "Job cannot be found on Jenkins instance", response = Void.class) })
public Response postJobDisable( @PathParam("name") String name,@ApiParam(value = "CSRF protection token" )@HeaderParam("Jenkins-Crumb") String jenkinsCrumb,@Context SecurityContext securityContext)
throws NotFoundException {
    return delegate.postJobDisable(name,jenkinsCrumb,securityContext);
}
项目:osc-core    文件:VirtualSystemApis.java   
@ApiOperation(value = "Retrieves the Traffic Policy Mapping",
        notes = "Retrieves a Traffic Policy Mappings specified by its owning Virtual System and Traffic Policy Mapping Id",
        response = SecurityGroupInterfaceDto.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Successful operation"),
        @ApiResponse(code = 400, message = "In case of any error", response = ErrorCodeDto.class) })
@Path("/{vsId}/securityGroupInterfaces/{sgiId}")
@GET
public SecurityGroupInterfaceDto getSecurityGroupInterface(@Context HttpHeaders headers,
        @ApiParam(value = "The Virtual System Id") @PathParam("vsId") Long vsId,
        @ApiParam(value = "The Traffic Policy Mapping Id") @PathParam("sgiId") Long sgiId) {
    logger.info("Getting Security Group Interface " + sgiId);
    this.userContext.setUser(OscAuthFilter.getUsername(headers));
    GetDtoFromEntityRequest getDtoRequest = new GetDtoFromEntityRequest();
    getDtoRequest.setEntityId(sgiId);
    getDtoRequest.setEntityName("SecurityGroupInterface");
    GetDtoFromEntityServiceApi<SecurityGroupInterfaceDto> getDtoService = this.getDtoFromEntityServiceFactory.getService(SecurityGroupInterfaceDto.class);
    SecurityGroupInterfaceDto dto = this.apiUtil.submitBaseRequestToService(getDtoService, getDtoRequest).getDto();

    this.apiUtil.validateParentIdMatches(dto, vsId, "SecurityGroupInterface");

    return dto;
}
项目:swaggy-jenkins    文件:JobApi.java   
@POST
    @Path("/{name}/config.xml")

    @Produces({ "text/xml" })
    @io.swagger.annotations.ApiOperation(value = "", notes = "Update job configuration", response = void.class, authorizations = {
        @io.swagger.annotations.Authorization(value = "jenkins_auth")
    }, tags={ "remoteAccess", })
    @io.swagger.annotations.ApiResponses(value = { 
        @io.swagger.annotations.ApiResponse(code = 200, message = "Successfully retrieved job configuration in config.xml format", response = void.class),

        @io.swagger.annotations.ApiResponse(code = 400, message = "An error has occurred - error message is embedded inside the HTML response", response = void.class),

        @io.swagger.annotations.ApiResponse(code = 401, message = "Authentication failed - incorrect username and/or password", response = void.class),

        @io.swagger.annotations.ApiResponse(code = 403, message = "Jenkins requires authentication - please set username and password", response = void.class),

        @io.swagger.annotations.ApiResponse(code = 404, message = "Job cannot be found on Jenkins instance", response = void.class) })
    public Response postJobConfig(@ApiParam(value = "Name of the job",required=true) @PathParam("name") String name
,@ApiParam(value = "Job configuration in config.xml format" ,required=true) String body
,@ApiParam(value = "CSRF protection token" )@HeaderParam("Jenkins-Crumb") String jenkinsCrumb
,@Context SecurityContext securityContext)
    throws NotFoundException {
        return delegate.postJobConfig(name,body,jenkinsCrumb,securityContext);
    }
项目:swaggy-jenkins    文件:BlueApi.java   
@DELETE
    @Path("/rest/organizations/{organization}/pipelines/{pipeline}/queue/{queue}")

    @Produces({ "application/json" })
    @io.swagger.annotations.ApiOperation(value = "", notes = "Delete queue item from an organization pipeline queue", response = void.class, authorizations = {
        @io.swagger.annotations.Authorization(value = "jenkins_auth")
    }, tags={ "blueOcean", })
    @io.swagger.annotations.ApiResponses(value = { 
        @io.swagger.annotations.ApiResponse(code = 200, message = "Successfully deleted queue item", response = void.class),

        @io.swagger.annotations.ApiResponse(code = 401, message = "Authentication failed - incorrect username and/or password", response = void.class),

        @io.swagger.annotations.ApiResponse(code = 403, message = "Jenkins requires authentication - please set username and password", response = void.class) })
    public Response deletePipelineQueueItem(@ApiParam(value = "Name of the organization",required=true) @PathParam("organization") String organization
,@ApiParam(value = "Name of the pipeline",required=true) @PathParam("pipeline") String pipeline
,@ApiParam(value = "Name of the queue item",required=true) @PathParam("queue") String queue
,@Context SecurityContext securityContext)
    throws NotFoundException {
        return delegate.deletePipelineQueueItem(organization,pipeline,queue,securityContext);
    }
项目:hadoop    文件:RMWebServices.java   
/**
 * Generates a new ApplicationId which is then sent to the client
 * 
 * @param hsr
 *          the servlet request
 * @return Response containing the app id and the maximum resource
 *         capabilities
 * @throws AuthorizationException
 * @throws IOException
 * @throws InterruptedException
 */
@POST
@Path("/apps/new-application")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response createNewApplication(@Context HttpServletRequest hsr)
    throws AuthorizationException, IOException, InterruptedException {
  init();
  UserGroupInformation callerUGI = getCallerUserGroupInformation(hsr, true);
  if (callerUGI == null) {
    throw new AuthorizationException("Unable to obtain user name, "
        + "user not authenticated");
  }
  if (UserGroupInformation.isSecurityEnabled() && isStaticUser(callerUGI)) {
    String msg = "The default static user cannot carry out this operation.";
    return Response.status(Status.FORBIDDEN).entity(msg).build();
  }

  NewApplication appId = createNewApplication();
  return Response.status(Status.OK).entity(appId).build();

}
项目:osc-core    文件:ManagerConnectorApis.java   
@ApiOperation(value = "Retrieves the Manager Connector by Id",
        notes = "Password/API Key information is not returned as it is sensitive information",
        response = ApplianceManagerConnectorDto.class)
@Path("/{applianceManagerConnectorId}")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Successful operation"),
        @ApiResponse(code = 400, message = "In case of any error", response = ErrorCodeDto.class) })
@GET
public ApplianceManagerConnectorDto getApplianceManagerConnector(@Context HttpHeaders headers,
                                                                 @ApiParam(value = "Id of the Appliance Manager Connector",
                                                                         required = true) @PathParam("applianceManagerConnectorId") Long amcId) {

    logger.info("getting Appliance Manager Connector " + amcId);
    this.userContext.setUser(OscAuthFilter.getUsername(headers));

    GetDtoFromEntityRequest getDtoRequest = new GetDtoFromEntityRequest();
    getDtoRequest.setEntityId(amcId);
    getDtoRequest.setEntityName("ApplianceManagerConnector");
    GetDtoFromEntityServiceApi<ApplianceManagerConnectorDto> getDtoService = this.getDtoFromEntityServiceFactory.getService(ApplianceManagerConnectorDto.class);
    return this.apiUtil.submitBaseRequestToService(getDtoService, getDtoRequest).getDto();
}
项目:swaggy-jenkins    文件:BlueApi.java   
@GET
    @Path("/rest/search/")

    @Produces({ "application/json" })
    @io.swagger.annotations.ApiOperation(value = "", notes = "Search for any resource details", response = String.class, authorizations = {
        @io.swagger.annotations.Authorization(value = "jenkins_auth")
    }, tags={ "blueOcean", })
    @io.swagger.annotations.ApiResponses(value = { 
        @io.swagger.annotations.ApiResponse(code = 200, message = "Successfully retrieved search result", response = String.class),

        @io.swagger.annotations.ApiResponse(code = 401, message = "Authentication failed - incorrect username and/or password", response = String.class),

        @io.swagger.annotations.ApiResponse(code = 403, message = "Jenkins requires authentication - please set username and password", response = String.class) })
    public Response search(@ApiParam(value = "Query string",required=true) @QueryParam("q") String q
,@Context SecurityContext securityContext)
    throws NotFoundException {
        return delegate.search(q,securityContext);
    }
项目:opencps-v2    文件:RegistrationFormManagement.java   
@PUT
@Path("/registrations/{id}/forms/{referenceUid}/formdata")
@Consumes({ MediaType.APPLICATION_FORM_URLENCODED })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@ApiOperation(value = "update RegistrationForm")
@ApiResponses(value = { @ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns"),
        @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Unauthorized", response = ExceptionModel.class),
        @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not found", response = ExceptionModel.class),
        @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class) })
public Response updateRegFormFormData(@Context HttpServletRequest request, @Context HttpHeaders header,
        @Context Company company, @Context Locale locale, @Context User user,
        @Context ServiceContext serviceContext,
        @ApiParam(value = "registrationId", required = true) @PathParam("id") long id,
        @ApiParam(value = "referenceUid", required = true) @PathParam("referenceUid") String referenceUid,
        @ApiParam(value = "formdata of registrationForm", required = true) @FormParam("formdata") String formdata)
        throws PortalException;
项目:hadoop    文件:RMWebServices.java   
@GET
@Path("/get-node-to-labels")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public NodeToLabelsInfo getNodeToLabels(@Context HttpServletRequest hsr) 
  throws IOException {
  init();

  NodeToLabelsInfo ntl = new NodeToLabelsInfo();
  HashMap<String, NodeLabelsInfo> ntlMap = ntl.getNodeToLabels();
  Map<NodeId, Set<String>> nodeIdToLabels =   
    rm.getRMContext().getNodeLabelManager().getNodeLabels();

  for (Map.Entry<NodeId, Set<String>> nitle : nodeIdToLabels.entrySet()) {
    ntlMap.put(nitle.getKey().toString(), 
      new NodeLabelsInfo(nitle.getValue()));
  }

  return ntl;
}
项目:hadoop    文件:AMWebServices.java   
@GET
@Path("/jobs/{jobid}/tasks/{taskid}/attempts/{attemptid}")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public TaskAttemptInfo getJobTaskAttemptId(@Context HttpServletRequest hsr,
    @PathParam("jobid") String jid, @PathParam("taskid") String tid,
    @PathParam("attemptid") String attId) {

  init();
  Job job = getJobFromJobIdString(jid, appCtx);
  checkAccess(job, hsr);
  Task task = getTaskFromTaskIdString(tid, job);
  TaskAttempt ta = getTaskAttemptFromTaskAttemptString(attId, task);
  if (task.getType() == TaskType.REDUCE) {
    return new ReduceTaskAttemptInfo(ta, task.getType());
  } else {
    return new TaskAttemptInfo(ta, task.getType(), true);
  }
}
项目:swaggy-jenkins    文件:ComputerApi.java   
public ComputerApi(@Context ServletConfig servletContext) {
   ComputerApiService delegate = null;

   if (servletContext != null) {
      String implClass = servletContext.getInitParameter("ComputerApi.implementation");
      if (implClass != null && !"".equals(implClass.trim())) {
         try {
            delegate = (ComputerApiService) Class.forName(implClass).newInstance();
         } catch (Exception e) {
            throw new RuntimeException(e);
         }
      } 
   }

   if (delegate == null) {
      delegate = ComputerApiServiceFactory.getComputerApi();
   }

   this.delegate = delegate;
}
项目:swaggy-jenkins    文件:JobApi.java   
@POST
    @Path("/{name}/disable")


    @io.swagger.annotations.ApiOperation(value = "", notes = "Disable a job", response = void.class, authorizations = {
        @io.swagger.annotations.Authorization(value = "jenkins_auth")
    }, tags={ "remoteAccess", })
    @io.swagger.annotations.ApiResponses(value = { 
        @io.swagger.annotations.ApiResponse(code = 200, message = "Successfully disabled the job", response = void.class),

        @io.swagger.annotations.ApiResponse(code = 401, message = "Authentication failed - incorrect username and/or password", response = void.class),

        @io.swagger.annotations.ApiResponse(code = 403, message = "Jenkins requires authentication - please set username and password", response = void.class),

        @io.swagger.annotations.ApiResponse(code = 404, message = "Job cannot be found on Jenkins instance", response = void.class) })
    public Response postJobDisable(@ApiParam(value = "Name of the job",required=true) @PathParam("name") String name
,@ApiParam(value = "CSRF protection token" )@HeaderParam("Jenkins-Crumb") String jenkinsCrumb
,@Context SecurityContext securityContext)
    throws NotFoundException {
        return delegate.postJobDisable(name,jenkinsCrumb,securityContext);
    }
项目:osc-core    文件:AlertApis.java   
@ApiOperation(value = "Retrieves the Alert by Id", response = AlertDto.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Successful operation"),
        @ApiResponse(code = 400, message = "In case of any error", response = ErrorCodeDto.class) })
@Path("/{alertId}")
@GET
public AlertDto getAlert(@Context HttpHeaders headers, @PathParam("alertId") Long alertId) {

    logger.info("getting Alert " + alertId);
    this.userContext.setUser(OscAuthFilter.getUsername(headers));

    GetDtoFromEntityRequest getDtoRequest = new GetDtoFromEntityRequest();
    getDtoRequest.setEntityId(alertId);
    getDtoRequest.setEntityName("Alert");

    GetDtoFromEntityServiceApi<AlertDto> getDtoService = this.getDtoFromEntityServiceFactory.getService(AlertDto.class);
    return this.apiUtil.submitBaseRequestToService(getDtoService, getDtoRequest).getDto();
}
项目:docker-restful-java    文件:AuthorizationService.java   
public AuthorizationService(@Context HttpHeaders headers) {
    authorization = false;

    String token = headers.getHeaderString("Authorization");
    if (token != null) {
        try {
            Session session = HibernateUtil.getSessionFactory().openSession();

            CriteriaBuilder builder = session.getCriteriaBuilder();

            CriteriaQuery<User> criteria = builder.createQuery(User.class);
            Root<User> root = criteria.from(User.class);
            criteria.select(root);
            criteria.where(builder.equal(root.get(User_.token), token));

            authenticate = session.createQuery(criteria).getSingleResult();

            if (authenticate != null)
                authorization = true;
        } catch (Exception e) {
        }
    }
}
项目:swaggy-jenkins    文件:BlueApi.java   
@GET
@Path("/rest/organizations/{organization}/pipelines/{pipeline}/branches")

@Produces({ "application/json" })
@io.swagger.annotations.ApiOperation(value = "", notes = "Retrieve all branches details for an organization pipeline", response = MultibranchPipeline.class, authorizations = {
    @io.swagger.annotations.Authorization(value = "jenkins_auth")
}, tags={ "blueOcean", })
@io.swagger.annotations.ApiResponses(value = { 
    @io.swagger.annotations.ApiResponse(code = 200, message = "Successfully retrieved all branches details", response = MultibranchPipeline.class),

    @io.swagger.annotations.ApiResponse(code = 401, message = "Authentication failed - incorrect username and/or password", response = MultibranchPipeline.class),

    @io.swagger.annotations.ApiResponse(code = 403, message = "Jenkins requires authentication - please set username and password", response = MultibranchPipeline.class) })
public Response getPipelineBranches( @PathParam("organization") String organization, @PathParam("pipeline") String pipeline,@Context SecurityContext securityContext)
throws NotFoundException {
    return delegate.getPipelineBranches(organization,pipeline,securityContext);
}
项目:ditb    文件:NamespacesInstanceResource.java   
/**
 * Build a response for POST create namespace with no properties specified.
 * @param message value not used.
 * @param headers value not used.
 * @return response code.
 */
@POST
public Response postNoBody(final byte[] message,
    final @Context UriInfo uriInfo, final @Context HttpHeaders headers) {
  if (LOG.isDebugEnabled()) {
    LOG.debug("POST " + uriInfo.getAbsolutePath());
  }
  servlet.getMetrics().incrementRequests(1);
  try{
    NamespacesInstanceModel model = new NamespacesInstanceModel(namespace);
    return processUpdate(model, false, uriInfo);
  }catch(IOException ioe){
    servlet.getMetrics().incrementFailedPutRequests(1);
    throw new RuntimeException("Cannot retrieve info for '" + namespace + "'.");
  }
}
项目:swaggy-jenkins    文件:BlueApi.java   
@GET
@Path("/rest/classes/")

@Produces({ "application/json" })
@io.swagger.annotations.ApiOperation(value = "", notes = "Get classes details", response = String.class, authorizations = {
    @io.swagger.annotations.Authorization(value = "jenkins_auth")
}, tags={ "blueOcean", })
@io.swagger.annotations.ApiResponses(value = { 
    @io.swagger.annotations.ApiResponse(code = 200, message = "Successfully retrieved search result", response = String.class),

    @io.swagger.annotations.ApiResponse(code = 401, message = "Authentication failed - incorrect username and/or password", response = String.class),

    @io.swagger.annotations.ApiResponse(code = 403, message = "Jenkins requires authentication - please set username and password", response = String.class) })
public Response searchClasses( @NotNull  @QueryParam("q") String q,@Context SecurityContext securityContext)
throws NotFoundException {
    return delegate.searchClasses(q,securityContext);
}
项目:swaggy-jenkins    文件:BlueApi.java   
public BlueApi(@Context ServletConfig servletContext) {
   BlueApiService delegate = null;

   if (servletContext != null) {
      String implClass = servletContext.getInitParameter("BlueApi.implementation");
      if (implClass != null && !"".equals(implClass.trim())) {
         try {
            delegate = (BlueApiService) Class.forName(implClass).newInstance();
         } catch (Exception e) {
            throw new RuntimeException(e);
         }
      } 
   }

   if (delegate == null) {
      delegate = BlueApiServiceFactory.getBlueApi();
   }

   this.delegate = delegate;
}
项目:jobson    文件:JobResource.java   
@GET
@Path("/{job-id}/spec")
@ApiOperation(
        value = "Get the spec the job was submitted against",
        notes = "Get the spec the job was submitted against. Note: This returns the exact spec the job was submitted" +
                " against. Any updates to the spec will not be reflected.")
@PermitAll
public Optional<APIJobSpec> fetchJobSpecJobWasSubmittedAgainst(
        @Context
                SecurityContext context,
        @ApiParam(value = "ID of the job to get the spec for")
        @PathParam("job-id")
        @NotNull
                JobId jobId) {

    if (jobId == null)
        throw new WebApplicationException("Job ID cannot be null", 400);

    return jobDAO.getSpecJobWasSubmittedAgainst(jobId)
            .map(APIJobSpec::fromJobSpec);
}
项目:Java-EE-8-Sampler    文件:ServerSentEventsResource.java   
@POST
@Path("domains/{id}")
@Produces(MediaType.SERVER_SENT_EVENTS)
public void startDomain(@PathParam("id") final String id, @Context SseEventSink eventSink) {

    executorService.submit(() -> {
        try {
            eventSink.send(sse.newEventBuilder().name("domain-progress").data(String.class, "starting domain " + id + " ...").build());
            Thread.sleep(200);
            eventSink.send(sse.newEvent("domain-progress", "50%"));
            Thread.sleep(200);
            eventSink.send(sse.newEvent("domain-progress", "60%"));
            Thread.sleep(200);
            eventSink.send(sse.newEvent("domain-progress", "70%"));
            Thread.sleep(200);
            eventSink.send(sse.newEvent("domain-progress", "99%"));
            Thread.sleep(200);
            eventSink.send(sse.newEvent("domain-progress", "Done."));
            eventSink.close();
        } catch (final InterruptedException e) {
            e.printStackTrace();
        }
    });
}
项目:redpipe    文件:MyResource.java   
@Path("8")
@GET
public Single<String> hello8(@Context io.vertx.rxjava.core.Vertx rxVertx){
    System.err.println("Creating client");
    WebClientOptions options = new WebClientOptions();
    options.setSsl(true);
    options.setTrustAll(true);
    options.setVerifyHost(false);
    WebClient client = WebClient.create(rxVertx, options);
    Single<HttpResponse<io.vertx.rxjava.core.buffer.Buffer>> responseHandler = client.get(443,
            "www.google.com", 
            "/robots.txt").rxSend();

    System.err.println("Created client");
    return responseHandler.map(body -> {
        System.err.println("Got body");
        return body.body().toString();
    });
}
项目:swaggy-jenkins    文件:BlueApi.java   
@GET
@Path("/rest/organizations/{organization}/pipelines/{pipeline}/activities")

@Produces({ "application/json" })
@io.swagger.annotations.ApiOperation(value = "", notes = "Retrieve all activities details for an organization pipeline", response = PipelineActivities.class, authorizations = {
    @io.swagger.annotations.Authorization(value = "jenkins_auth")
}, tags={ "blueOcean", })
@io.swagger.annotations.ApiResponses(value = { 
    @io.swagger.annotations.ApiResponse(code = 200, message = "Successfully retrieved all activities details", response = PipelineActivities.class),

    @io.swagger.annotations.ApiResponse(code = 401, message = "Authentication failed - incorrect username and/or password", response = PipelineActivities.class),

    @io.swagger.annotations.ApiResponse(code = 403, message = "Jenkins requires authentication - please set username and password", response = PipelineActivities.class) })
public Response getPipelineActivities( @PathParam("organization") String organization, @PathParam("pipeline") String pipeline,@Context SecurityContext securityContext)
throws NotFoundException {
    return delegate.getPipelineActivities(organization,pipeline,securityContext);
}
项目:swaggy-jenkins    文件:BlueApi.java   
@GET
@Path("/rest/organizations/{organization}/users/{user}")

@Produces({ "application/json" })
@io.swagger.annotations.ApiOperation(value = "", notes = "Retrieve user details for an organization", response = User.class, authorizations = {
    @io.swagger.annotations.Authorization(value = "jenkins_auth")
}, tags={ "blueOcean", })
@io.swagger.annotations.ApiResponses(value = { 
    @io.swagger.annotations.ApiResponse(code = 200, message = "Successfully retrieved users details", response = User.class),

    @io.swagger.annotations.ApiResponse(code = 401, message = "Authentication failed - incorrect username and/or password", response = User.class),

    @io.swagger.annotations.ApiResponse(code = 403, message = "Jenkins requires authentication - please set username and password", response = User.class) })
public Response getUser( @PathParam("organization") String organization, @PathParam("user") String user,@Context SecurityContext securityContext)
throws NotFoundException {
    return delegate.getUser(organization,user,securityContext);
}
项目:ditb    文件:RootResource.java   
@GET
@Produces({MIMETYPE_TEXT, MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF,
  MIMETYPE_PROTOBUF_IETF})
public Response get(final @Context UriInfo uriInfo) {
  if (LOG.isDebugEnabled()) {
    LOG.debug("GET " + uriInfo.getAbsolutePath());
  }
  servlet.getMetrics().incrementRequests(1);
  try {
    ResponseBuilder response = Response.ok(getTableList());
    response.cacheControl(cacheControl);
    servlet.getMetrics().incrementSucessfulGetRequests(1);
    return response.build();
  } catch (Exception e) {
    servlet.getMetrics().incrementFailedGetRequests(1);
    return processException(e);
  }
}
项目:osc-core    文件:ApplianceApis.java   
@ApiOperation(value = "Retrieves a Software Function Software Version",
        notes = "Retrieves a Software Function Software Version specified by the Id",
        response = ApplianceSoftwareVersionDto.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Successful operation"),
        @ApiResponse(code = 400, message = "In case of any error", response = ErrorCodeDto.class) })
@Path("/{applianceId}/versions/{ApplianceSoftwareVersionId}")
@GET
public ApplianceSoftwareVersionDto getApplianceSoftwareVersion(@Context HttpHeaders headers,
        @ApiParam(value = "Id of the Appliance Model", required = true) @PathParam("applianceId") Long applianceId,
        @ApiParam(value = "Id of the Appliance Software Version",
        required = true) @PathParam("ApplianceSoftwareVersionId") Long applianceSoftwareVersionId) {

    logger.info(
            "getting Appliance Software Version " + applianceSoftwareVersionId + " from appliance " + applianceId);
    this.userContext.setUser(OscAuthFilter.getUsername(headers));

    GetDtoFromEntityRequest getDtoRequest = new GetDtoFromEntityRequest();
    getDtoRequest.setEntityName("ApplianceSoftwareVersion");
    getDtoRequest.setEntityId(applianceSoftwareVersionId);
    getDtoRequest.setParentId(applianceId);

    GetDtoFromEntityServiceApi<ApplianceSoftwareVersionDto> getDtoService = this.getDtoFromEntityServiceFactory.getService(ApplianceSoftwareVersionDto.class);
    return this.apiUtil.submitBaseRequestToService(getDtoService, getDtoRequest).getDto();
}
项目:outland    文件:FeatureResource.java   
@POST
@Path("/{group}/{feature_key}")
@PermitAll
@Timed(name = "updateFeature")
public Response updateFeature(
    @Auth AuthPrincipal principal,
    @PathParam("group") String group,
    @PathParam("feature_key") String featureKey,
    Feature feature,
    @Context HttpHeaders httpHeaders
) throws AuthenticationException {

  final long start = System.currentTimeMillis();

  grantedGuard(principal, group);
  groupValidGuard(group, featureKey, feature);

  final Optional<String> maybeSeen = idempotencyChecker.extractKey(httpHeaders);
  if (maybeSeen.isPresent() && idempotencyChecker.seen(maybeSeen.get())) {
    return alreadyUpdated(feature, start, maybeSeen);
  }

  return headers.enrich(Response.ok(update(group, feature)), start).build();
}
项目:ctsms    文件:IndexResource.java   
@GET
@Produces(MediaType.APPLICATION_JSON)
public ResourceIndex index(@Context Application application,
        @Context HttpServletRequest request) throws Exception {
    // String basePath = request.getRequestURL().toString();
    // String basePath = getBasePath(request);
    JsonObject rootNode = new JsonObject();
    JsonArray classesNode = new JsonArray();
    rootNode.addProperty(JS_TITLE_FIELD, Settings.getString(SettingCodes.API_TITLE, Bundle.SETTINGS, DefaultSettings.API_TITLE));
    rootNode.addProperty(JS_INSTANCE_FIELD, WebUtil.getInstanceName());
    rootNode.addProperty(JS_VERSION_FIELD, Settings.getString(SettingCodes.API_VERSION, Bundle.SETTINGS, DefaultSettings.API_VERSION));
    rootNode.addProperty(JS_JVM_FIELD, System.getProperty("java.version"));
    rootNode.addProperty(JS_REALM_FIELD, Settings.getString(SettingCodes.API_REALM, Bundle.SETTINGS, DefaultSettings.API_REALM));
    AnnouncementVO announcement = WebUtil.getServiceLocator().getToolsService().getAnnouncement();
    if (announcement != null) {
        rootNode.addProperty(JS_ANNOUNCEMENT_FIELD, announcement.getMessage());
    }
    rootNode.add(JS_CLASSES_FIELD, classesNode);
    ArrayList<Class> classes = new ArrayList<Class>(application.getClasses());
    Collections.sort(classes, RESOURCE_CLASS_COMPARATOR);
    Iterator<Class> classesIt = classes.iterator();
    while (classesIt.hasNext()) {
        Class resourceClass = classesIt.next();
        if (isAnnotatedResourceClass(resourceClass)) {
            classesNode.add(getResourceIndexNode(resourceClass, request)); // basePath));
        }
    }
    // return Response.ok().entity(rootNode).build();
    return new ResourceIndex(rootNode);
}
项目:agilion    文件:SessionApi.java   
@POST

@Consumes({ "application/json" })
@Produces({ "application/json" })
@io.swagger.annotations.ApiOperation(value = "create a session", notes = "Creates new session with given metadata", response = Session.class, tags={ "sessions",  })
@io.swagger.annotations.ApiResponses(value = { 
    @io.swagger.annotations.ApiResponse(code = 201, message = "session created", response = Session.class),
    @io.swagger.annotations.ApiResponse(code = 400, message = "invalid input, object invalid", response = Session.class),
    @io.swagger.annotations.ApiResponse(code = 409, message = "an existing request already exists", response = Session.class) })
public Response createSession(
    @ApiParam(value = "Session to add" ) Session session,
    @Context SecurityContext securityContext)
throws NotFoundException {
    return delegate.createSession(session,securityContext);
}
项目:redirector    文件:RedirectorTestSuiteController.java   
@POST
@Path("{serviceName}/{testName}/")
@Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public Response saveTestCase(@PathParam("serviceName") final String serviceName,
                             @PathParam("testName") final String testName,
                             final RedirectorTestCase testCase,
                             @Context UriInfo ui) {
    testSuiteService.saveTestCase(serviceName, testCase);
    return Response.created(ui.getRequestUri()).entity(testCase).build();
}
项目:ctsms    文件:JournalResource.java   
@GET
@Produces({ MediaType.APPLICATION_JSON })
@Path("user")
public Page<JournalEntryOutVO> getUserJournal(@Context UriInfo uriInfo)
        throws AuthenticationException, AuthorisationException, ServiceException {
    PSFUriPart psf;
    return new Page<JournalEntryOutVO>(WebUtil.getServiceLocator().getJournalService().getJournal(auth, JournalModule.USER_JOURNAL, null, psf = new PSFUriPart(uriInfo)), psf);
}
项目:opencps-v2    文件:RegistrationManagement.java   
@POST
@Path("/registrations/syncs")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED })
public Response registrationSyncs(@Context HttpServletRequest request, @Context HttpHeaders header,
        @Context Company company, @Context Locale locale, @Context User user,
        @Context ServiceContext serviceContext, @BeanParam RegistrationInputModel input,
        @FormParam("submitting") boolean submitting, @FormParam("uuid_") String uuid);
项目:opencps-v2    文件:JobposManagement.java   
@GET
@Path("/{id}")
@Consumes({ MediaType.APPLICATION_FORM_URLENCODED })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response read(@Context HttpServletRequest request, @Context HttpHeaders header,
        @Context Company company, @Context Locale locale, @Context User user, @Context ServiceContext serviceContext,
        @DefaultValue("0") @PathParam("id") long id);
项目:opencps-v2    文件:DataManagement.java   
@POST
@Path("/{code}/dictgroups/{groupCode}/dictitems")
@Consumes({ MediaType.APPLICATION_FORM_URLENCODED })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response addDictgroupsDictItems(@Context HttpServletRequest request, @Context HttpHeaders header,
        @Context Company company, @Context Locale locale, @Context User user, @Context ServiceContext serviceContext,
        @PathParam("code") String code, @PathParam("groupCode") String groupCode, @FormParam("itemCode") String itemCode);
项目:oryx2    文件:ErrorResource.java   
@GET
@Produces(MediaType.WILDCARD)
public Response errorEmpty(@Context HttpServletRequest request) {
  Number statusCode = (Number) request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE);
  Response.Status finalStatus = statusCode == null ?
      Response.Status.OK : Response.Status.fromStatusCode(statusCode.intValue());
  return Response.status(finalStatus).build();
}
项目:ctsms    文件:UserResource.java   
@GET
@Produces({ MediaType.APPLICATION_JSON })
@Path("{id}/journal")
public Page<JournalEntryOutVO> getJournal(@PathParam("id") Long id, @Context UriInfo uriInfo)
        throws AuthenticationException, AuthorisationException, ServiceException {
    PSFUriPart psf;
    return new Page<JournalEntryOutVO>(WebUtil.getServiceLocator().getJournalService().getJournal(auth, journalModule, id, psf = new PSFUriPart(uriInfo)), psf);
}
项目:fuck_zookeeper    文件:ZNodeResource.java   
@PUT
@Produces( { MediaType.APPLICATION_JSON, "application/javascript",
        MediaType.APPLICATION_XML })
@Consumes(MediaType.APPLICATION_OCTET_STREAM)
public Response setZNode(
        @PathParam("path") String path,
        @QueryParam("callback") String callback,
        @DefaultValue("-1") @QueryParam("version") String versionParam,
        @DefaultValue("base64") @QueryParam("dataformat") String dataformat,
        @DefaultValue("false") @QueryParam("null") String setNull,
        @Context UriInfo ui, byte[] data) throws InterruptedException,
        KeeperException {
    ensurePathNotNull(path);

    int version;
    try {
        version = Integer.parseInt(versionParam);
    } catch (NumberFormatException e) {
        throw new WebApplicationException(Response.status(
                Response.Status.BAD_REQUEST).entity(
                new ZError(ui.getRequestUri().toString(), path
                        + " bad version " + versionParam)).build());
    }

    if (setNull.equals("true")) {
        data = null;
    }

    Stat stat = zk.setData(path, data, version);

    ZStat zstat = new ZStat(path, ui.getAbsolutePath().toString(), null,
            null, stat.getCzxid(), stat.getMzxid(), stat.getCtime(), stat
                    .getMtime(), stat.getVersion(), stat.getCversion(),
            stat.getAversion(), stat.getEphemeralOwner(), stat
                    .getDataLength(), stat.getNumChildren(), stat
                    .getPzxid());

    return Response.status(Response.Status.OK).entity(
            new JSONWithPadding(zstat, callback)).build();
}
项目:opencps-v2    文件:ServiceConfigManagement.java   
@GET
@Path("/{id}")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED })
@ApiOperation(value = "Get a ServiceConfig by id", response = ServiceConfigDetailModel.class)
@ApiResponses(value = {
        @ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns a ServiceConfig", response = ServiceConfigDetailModel.class),
        @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Unauthorized", response = ExceptionModel.class),
        @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not found", response = ExceptionModel.class),
        @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class) })
public Response getServiceConfig(@Context HttpServletRequest request, @Context HttpHeaders header,
        @Context Company company, @Context Locale locale, @Context User user,
        @Context ServiceContext serviceContext,
        @ApiParam(value = "serviceconfigId for get detail") @PathParam("id") long input);