use of javax.ws.rs.core.Context in project indy by Commonjava.
the class DeprecatedFoloContentAccessResource method doCreate.
@ApiOperation("Store and track file/artifact content under the given artifact store (type/name) and path.")
@ApiResponses({ @ApiResponse(code = 201, message = "Content was stored successfully"), @ApiResponse(code = 400, message = "No appropriate storage location was found in the specified store (this store, or a member if a group is specified).") })
@PUT
@Path("/{path: (.*)}")
public Response doCreate(@ApiParam("User-assigned tracking session key") @PathParam("id") final String id, @ApiParam(allowableValues = "hosted,group,remote", required = true) @PathParam("type") final String type, @PathParam("name") final String name, @PathParam("path") final String path, @Context final HttpServletRequest request, @Context final UriInfo uriInfo) {
final TrackingKey tk = new TrackingKey(id);
EventMetadata metadata = new EventMetadata().set(TRACKING_KEY, tk).set(ACCESS_CHANNEL, AccessChannel.MAVEN_REPO);
final Supplier<URI> uriSupplier = () -> uriInfo.getBaseUriBuilder().path(getClass()).path(path).build(id, type, name);
final Consumer<Response.ResponseBuilder> deprecation = builder -> {
String alt = Paths.get("/api/folo/track/", id, MAVEN_PKG_KEY, type, name, path).toString();
responseHelper.markDeprecated(builder, alt);
};
return handler.doCreate(MAVEN_PKG_KEY, type, name, path, request, metadata, uriSupplier, deprecation);
}
use of javax.ws.rs.core.Context in project indy by Commonjava.
the class DeprecatedContentAccessResource method doGet.
@ApiOperation("Retrieve root listing under the given artifact store (type/name).")
@ApiResponses({ @ApiResponse(code = 200, response = String.class, message = "Rendered root content listing"), @ApiResponse(code = 200, response = StreamingOutput.class, message = "Content stream") })
@GET
@Path("/")
public Response doGet(@ApiParam(allowableValues = "hosted,group,remote", required = true) @PathParam("type") final String type, @ApiParam(required = true) @PathParam("name") final String name, @Context final UriInfo uriInfo, @Context final HttpServletRequest request) {
String packageType = MavenPackageTypeDescriptor.MAVEN_PKG_KEY;
final String baseUri = uriInfo.getBaseUriBuilder().path(IndyDeployment.API_PREFIX).build().toString();
final Consumer<Response.ResponseBuilder> deprecated = builder -> {
String alt = Paths.get("/api/maven", type, name).toString();
responseHelper.markDeprecated(builder, alt);
};
return handler.doGet(packageType, type, name, "", baseUri, request, new EventMetadata(), deprecated);
}
use of javax.ws.rs.core.Context in project cxf by apache.
the class ResourceUtils method getParameter.
// CHECKSTYLE:OFF
public static Parameter getParameter(int index, Annotation[] anns, Class<?> type) {
Context ctx = AnnotationUtils.getAnnotation(anns, Context.class);
if (ctx != null) {
return new Parameter(ParameterType.CONTEXT, index, null);
}
boolean isEncoded = AnnotationUtils.getAnnotation(anns, Encoded.class) != null;
BeanParam bp = AnnotationUtils.getAnnotation(anns, BeanParam.class);
if (bp != null) {
return new Parameter(ParameterType.BEAN, index, null, isEncoded, null);
}
String dValue = AnnotationUtils.getDefaultParameterValue(anns);
PathParam a = AnnotationUtils.getAnnotation(anns, PathParam.class);
if (a != null) {
return new Parameter(ParameterType.PATH, index, a.value(), isEncoded, dValue);
}
QueryParam q = AnnotationUtils.getAnnotation(anns, QueryParam.class);
if (q != null) {
return new Parameter(ParameterType.QUERY, index, q.value(), isEncoded, dValue);
}
MatrixParam m = AnnotationUtils.getAnnotation(anns, MatrixParam.class);
if (m != null) {
return new Parameter(ParameterType.MATRIX, index, m.value(), isEncoded, dValue);
}
FormParam f = AnnotationUtils.getAnnotation(anns, FormParam.class);
if (f != null) {
return new Parameter(ParameterType.FORM, index, f.value(), isEncoded, dValue);
}
HeaderParam h = AnnotationUtils.getAnnotation(anns, HeaderParam.class);
if (h != null) {
return new Parameter(ParameterType.HEADER, index, h.value(), isEncoded, dValue);
}
CookieParam c = AnnotationUtils.getAnnotation(anns, CookieParam.class);
if (c != null) {
return new Parameter(ParameterType.COOKIE, index, c.value(), isEncoded, dValue);
}
return new Parameter(ParameterType.REQUEST_BODY, index, null);
}
use of javax.ws.rs.core.Context in project cxf by apache.
the class BookServer20 method createServer.
@Override
protected Server createServer(Bus bus) throws Exception {
JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
sf.setResourceClasses(BookStore.class);
List<Object> providers = new ArrayList<>();
providers.add(new PreMatchContainerRequestFilter2());
providers.add(new PreMatchContainerRequestFilter());
providers.add(new PostMatchContainerResponseFilter());
providers.add((Feature) context -> {
context.register(new PostMatchContainerResponseFilter3());
return true;
});
providers.add(new PostMatchContainerResponseFilter2());
providers.add(new CustomReaderBoundInterceptor());
providers.add(new CustomReaderInterceptor());
providers.add(new CustomWriterInterceptor());
providers.add(new CustomDynamicFeature());
providers.add(new PostMatchContainerRequestFilter());
providers.add(new FaultyContainerRequestFilter());
providers.add(new PreMatchReplaceStreamOrAddress());
providers.add(new ServerTestFeature());
providers.add(new JacksonJaxbJsonProvider());
providers.add(new IOExceptionMapper());
providers.add(new GregorianCalendarMessageBodyWriter());
sf.setApplication(new Application());
sf.setProviders(providers);
sf.setResourceProvider(BookStore.class, new SingletonResourceProvider(new BookStore(), true));
sf.setAddress("http://localhost:" + PORT + "/");
return sf.create();
}
use of javax.ws.rs.core.Context in project cxf by apache.
the class JAXRS20ClientServerBookTest method testGetSetEntityStreamLambda.
@Test
public void testGetSetEntityStreamLambda() {
String address = "http://localhost:" + PORT + "/bookstore/entityecho";
String entity = "BOOKSTORE";
Client client = ClientBuilder.newClient();
client.register((ClientRequestFilter) context -> {
context.setEntityStream(new ReplacingOutputStream(context.getEntityStream(), 'X', 'O'));
});
WebTarget target = client.target(address);
Response response = target.request().post(Entity.entity(entity.replace('O', 'X'), "text/plain"));
assertEquals(entity, response.readEntity(String.class));
}
Aggregations