Search in sources :

Example 21 with Configuration

use of javax.ws.rs.core.Configuration in project graylog2-server by Graylog2.

the class PrefixAddingModelProcessor method processResourceModel.

@Override
public ResourceModel processResourceModel(ResourceModel model, Configuration config) {
    // Create new resource model.
    final ResourceModel.Builder resourceModelBuilder = new ResourceModel.Builder(false);
    for (final Resource resource : model.getResources()) {
        for (Class handlerClass : resource.getHandlerClasses()) {
            final String packageName = handlerClass.getPackage().getName();
            final Optional<String> packagePrefix = packagePrefixes.entrySet().stream().filter(entry -> packageName.startsWith(entry.getKey())).sorted((o1, o2) -> -o1.getKey().compareTo(o2.getKey())).map(Map.Entry::getValue).findFirst();
            if (packagePrefix.isPresent()) {
                final String prefixedPath = prefixPath(packagePrefix.get(), resource.getPath());
                final Resource newResource = Resource.builder(resource).path(prefixedPath).build();
                resourceModelBuilder.addResource(newResource);
            } else {
                resourceModelBuilder.addResource(resource);
            }
        }
    }
    return resourceModelBuilder.build();
}
Also used : Provider(javax.ws.rs.ext.Provider) ImmutableMap(com.google.common.collect.ImmutableMap) Configuration(javax.ws.rs.core.Configuration) Map(java.util.Map) ResourceModel(org.glassfish.jersey.server.model.ResourceModel) Optional(java.util.Optional) ModelProcessor(org.glassfish.jersey.server.model.ModelProcessor) Resource(org.glassfish.jersey.server.model.Resource) Resource(org.glassfish.jersey.server.model.Resource) ResourceModel(org.glassfish.jersey.server.model.ResourceModel) ImmutableMap(com.google.common.collect.ImmutableMap) Map(java.util.Map)

Aggregations

Configuration (javax.ws.rs.core.Configuration)21 Map (java.util.Map)2 SSLContext (javax.net.ssl.SSLContext)2 ServletContext (javax.servlet.ServletContext)2 AbstractBinder (org.glassfish.jersey.internal.inject.AbstractBinder)2 JacksonJaxbJsonProvider (com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Bootstrap (io.netty.bootstrap.Bootstrap)1 Channel (io.netty.channel.Channel)1 ChannelPipeline (io.netty.channel.ChannelPipeline)1 SocketChannel (io.netty.channel.socket.SocketChannel)1 NioSocketChannel (io.netty.channel.socket.nio.NioSocketChannel)1 DefaultFullHttpRequest (io.netty.handler.codec.http.DefaultFullHttpRequest)1 DefaultHttpRequest (io.netty.handler.codec.http.DefaultHttpRequest)1 HttpChunkedInput (io.netty.handler.codec.http.HttpChunkedInput)1 HttpClientCodec (io.netty.handler.codec.http.HttpClientCodec)1 HttpContentDecompressor (io.netty.handler.codec.http.HttpContentDecompressor)1 HttpRequest (io.netty.handler.codec.http.HttpRequest)1 HttpProxyHandler (io.netty.handler.proxy.HttpProxyHandler)1 JdkSslContext (io.netty.handler.ssl.JdkSslContext)1