Search in sources :

Example 66 with Path

use of javax.ws.rs.Path in project feign by OpenFeign.

the class JAXRSContract method processAnnotationOnClass.

@Override
protected void processAnnotationOnClass(MethodMetadata data, Class<?> clz) {
    Path path = clz.getAnnotation(Path.class);
    if (path != null) {
        String pathValue = emptyToNull(path.value());
        checkState(pathValue != null, "Path.value() was empty on type %s", clz.getName());
        if (!pathValue.startsWith("/")) {
            pathValue = "/" + pathValue;
        }
        if (pathValue.endsWith("/")) {
            // Strip off any trailing slashes, since the template has already had slashes appropriately added
            pathValue = pathValue.substring(0, pathValue.length() - 1);
        }
        data.template().insert(0, pathValue);
    }
    Consumes consumes = clz.getAnnotation(Consumes.class);
    if (consumes != null) {
        handleConsumesAnnotation(data, consumes, clz.getName());
    }
    Produces produces = clz.getAnnotation(Produces.class);
    if (produces != null) {
        handleProducesAnnotation(data, produces, clz.getName());
    }
}
Also used : Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

Example 67 with Path

use of javax.ws.rs.Path in project jersey by jersey.

the class InjectLinkFieldDescriptor method getLinkTemplate.

/**
     * TODO javadoc.
     */
public static String getLinkTemplate(ResourceMappingContext rmc, InjectLink link) {
    String template = null;
    if (!link.resource().equals(Class.class)) {
        ResourceMappingContext.Mapping map = rmc.getMapping(link.resource());
        if (map != null) {
            template = map.getTemplate().getTemplate().toString();
        } else {
            // extract template from specified class' @Path annotation
            Path path = link.resource().getAnnotation(Path.class);
            template = path == null ? "" : path.value();
        }
        // extract template from specified class' @Path annotation
        if (link.method().length() > 0) {
            // append value of method's @Path annotation
            MethodList methods = new MethodList(link.resource());
            methods = methods.withMetaAnnotation(HttpMethod.class);
            Iterator<AnnotatedMethod> iterator = methods.iterator();
            while (iterator.hasNext()) {
                AnnotatedMethod method = iterator.next();
                if (!method.getMethod().getName().equals(link.method())) {
                    continue;
                }
                StringBuilder builder = new StringBuilder();
                builder.append(template);
                Path methodPath = method.getAnnotation(Path.class);
                if (methodPath != null) {
                    String methodTemplate = methodPath.value();
                    if (!(template.endsWith("/") || methodTemplate.startsWith("/"))) {
                        builder.append("/");
                    }
                    builder.append(methodTemplate);
                }
                CharSequence querySubString = extractQueryParams(method);
                if (querySubString.length() > 0) {
                    builder.append("{?");
                    builder.append(querySubString);
                    builder.append("}");
                }
                template = builder.toString();
                break;
            }
        }
    } else {
        template = link.value();
    }
    return template;
}
Also used : Path(javax.ws.rs.Path) ResourceMappingContext(org.glassfish.jersey.linking.mapping.ResourceMappingContext) AnnotatedMethod(org.glassfish.jersey.server.model.AnnotatedMethod) MethodList(org.glassfish.jersey.server.model.MethodList) HttpMethod(javax.ws.rs.HttpMethod)

Example 68 with Path

use of javax.ws.rs.Path in project jersey by jersey.

the class ClientShutdownLeakResource method invokeClient.

@POST
@Path("invoke")
public String invokeClient() {
    WebTarget target2 = target.property("Washington", "Irving");
    Invocation.Builder req = target2.request().property("how", "now");
    req.buildGet().property("Irving", "Washington");
    return target.toString();
}
Also used : Invocation(javax.ws.rs.client.Invocation) WebTarget(javax.ws.rs.client.WebTarget) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST)

Example 69 with Path

use of javax.ws.rs.Path in project jersey by jersey.

the class DomainResource method post.

@Path("start")
@POST
public Response post(@DefaultValue("0") @QueryParam("testSources") int testSources) {
    final Process process = new Process(testSources);
    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();
}
Also used : URI(java.net.URI) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST)

Example 70 with Path

use of javax.ws.rs.Path in project jersey by jersey.

the class SparklinesResource method smooth.

@Path("smooth")
@GET
public Response smooth(@DefaultValue("2") @QueryParam("step") final int step, @DefaultValue("true") @QueryParam("min-m") final boolean hasMin, @DefaultValue("true") @QueryParam("max-m") final boolean hasMax, @DefaultValue("true") @QueryParam("last-m") final boolean hasLast, @DefaultValue("blue") @QueryParam("min-color") final ColorParam minColor, @DefaultValue("green") @QueryParam("max-color") final ColorParam maxColor, @DefaultValue("red") @QueryParam("last-color") final ColorParam lastColor) {
    final BufferedImage image = new BufferedImage(data.size() * step - 4, imageHeight, BufferedImage.TYPE_INT_RGB);
    final Graphics2D g = image.createGraphics();
    g.setBackground(Color.WHITE);
    g.clearRect(0, 0, image.getWidth(), image.getHeight());
    g.setColor(Color.gray);
    final int[] xs = new int[data.size()];
    final int[] ys = new int[data.size()];
    final int gap = 4;
    final float d = (limits.width() + 1) / (float) (imageHeight - gap);
    for (int i = 0, x = 0; i < data.size(); i++, x += step) {
        final int v = data.get(i);
        xs[i] = x;
        ys[i] = imageHeight - 3 - (int) ((v - limits.lower()) / d);
    }
    g.drawPolyline(xs, ys, data.size());
    if (hasMin) {
        final int i = data.indexOf(Collections.min(data));
        g.setColor(minColor);
        g.fillRect(xs[i] - step / 2, ys[i] - step / 2, step, step);
    }
    if (hasMax) {
        final int i = data.indexOf(Collections.max(data));
        g.setColor(maxColor);
        g.fillRect(xs[i] - step / 2, ys[i] - step / 2, step, step);
    }
    if (hasMax) {
        g.setColor(lastColor);
        g.fillRect(xs[xs.length - 1] - step / 2, ys[ys.length - 1] - step / 2, step, step);
    }
    return Response.ok(image).tag(tag).build();
}
Also used : BufferedImage(java.awt.image.BufferedImage) Graphics2D(java.awt.Graphics2D) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Aggregations

Path (javax.ws.rs.Path)6273 Produces (javax.ws.rs.Produces)3678 GET (javax.ws.rs.GET)3072 POST (javax.ws.rs.POST)1783 Consumes (javax.ws.rs.Consumes)1440 ApiOperation (io.swagger.annotations.ApiOperation)1213 ApiResponses (io.swagger.annotations.ApiResponses)997 PUT (javax.ws.rs.PUT)850 IOException (java.io.IOException)677 DELETE (javax.ws.rs.DELETE)662 ArrayList (java.util.ArrayList)591 WebApplicationException (javax.ws.rs.WebApplicationException)556 Response (javax.ws.rs.core.Response)540 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)490 HashMap (java.util.HashMap)394 Timed (com.codahale.metrics.annotation.Timed)383 URI (java.net.URI)374 List (java.util.List)287 Map (java.util.Map)259 NotFoundException (javax.ws.rs.NotFoundException)258