How to design a generic RestClient using jersey 2.0.0 version and above?

I want to make a RestClient class using jersey API version 2.0.0 and above, that provides methods for all kinds of HTTP methods like GET/POST/PUT/DELETE and can support all functionalities like uri-parameters, setting cookies etc.

My initial thought is to design certain overridden methods in the class which can support varying type of arguments as shown below and provide one method which aggregates all of the parameters and performs the rest call and return the Generic Response.

method 1:

public Response callServer(Map<String,Object> queryParams, String restEndpointURL){} 

method 2:

public Response callServer(Map<String,Object> queryParams, String restEndpointURL, Cookies cookies){} 

method 3:

private actualCall(Map<String,Object> queryParams, String restEndpointURL, Cookies cookies, ...){     //perform the actual call to the server by making checks on all of the parameters provided by the calling methods     } 

The issue I am facing is in structuring the design of the Class which includes -what parameters should i provide support for other than queryParams,URI params and Cookies -how to validate these arguments in the actualCall

jersey api index per role

Jersey 2.x rest api. I’m looking for a way to make an API call that would return a list of all the endpoints and verbs based on my user role. Client side sends an api request with a JWT, in API server I parse the JWT, find the user in the local DB, get the roles and create the securityContext in my auth filter that gets passed along to my endpoints which are annotated with @RolesAllowed at both class and method level.

For the client side I would like to send an initial “what do I have access to in the API” request that would list all of my api endpoints based on my role.

I’ve found most of this on stack overflow(kudos to the submitters) and have found a way to extract the value in the RolesAllowed, but was hoping to avoid duplication of the existing jersey logic that evaluates the class and method level roles allowed/permitall/denyall.

Is there some sort of jersey class I can pass an endpoint to and security context and it return true or false if allowed to invoke it? Without generating http errors?

Something like:

boolean hasAccess = checkEndpoint(SecurityContext myUser, String path);

Or maybe:

boolean hasAccess = checkEndpoint(SecurityContext myUser, Class c);

Any ideas?

REST using Jersey 2 (on GAE java application using Guice) not working on server

We are integrating REST using Jersey 2 in a GAE Java application which uses Guice for DI. we are able to do so on the local Dev server. When we deploy it to app-engine, it is unable to find beans (Rest classes) in the provided package whereas it can find the beans (Rest classes) when it’s running on local.

The code looks like this

**** Code to add all available bean classes in the package. **** rest("/api/*").packages("");  **** Code being used to read all beans in the package provided. **** String resourcePath = packge.replace(".", "/"); URL resource = getClass().getClassLoader().getResource(resourcePath); 

It returns resource URL correctly on local dev server but returns null when its running App-Engine server.

Please suggest what is the issue here?

Thanks Aadhaar