本文整理匯總了Java中javax.ws.rs.core.Context類的典型用法代碼示例。如果您正苦於以下問題:Java Context類的具體用法?Java Context怎麽用?Java Context使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Context類屬於javax.ws.rs.core包,在下文中一共展示了Context類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: updatePaymentFileConfirmNoAttachment
import javax.ws.rs.core.Context; //導入依賴的package包/類
@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);
示例2: defaultPage
import javax.ws.rs.core.Context; //導入依賴的package包/類
@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();
}
}
示例3: getSCM
import javax.ws.rs.core.Context; //導入依賴的package包/類
@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);
}
示例4: postJobDisable
import javax.ws.rs.core.Context; //導入依賴的package包/類
@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);
}
示例5: getSecurityGroupInterface
import javax.ws.rs.core.Context; //導入依賴的package包/類
@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;
}
示例6: postJobConfig
import javax.ws.rs.core.Context; //導入依賴的package包/類
@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);
}
示例7: deletePipelineQueueItem
import javax.ws.rs.core.Context; //導入依賴的package包/類
@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);
}
示例8: createNewApplication
import javax.ws.rs.core.Context; //導入依賴的package包/類
/**
* 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();
}
示例9: getApplianceManagerConnector
import javax.ws.rs.core.Context; //導入依賴的package包/類
@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();
}
示例10: search
import javax.ws.rs.core.Context; //導入依賴的package包/類
@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);
}
示例11: updateRegFormFormData
import javax.ws.rs.core.Context; //導入依賴的package包/類
@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;
示例12: getNodeToLabels
import javax.ws.rs.core.Context; //導入依賴的package包/類
@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;
}
示例13: getJobTaskAttemptId
import javax.ws.rs.core.Context; //導入依賴的package包/類
@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);
}
}
示例14: ComputerApi
import javax.ws.rs.core.Context; //導入依賴的package包/類
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;
}
示例15: postJobDisable
import javax.ws.rs.core.Context; //導入依賴的package包/類
@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);
}