1

As I understand, it's possible to get resource class and method using injected ResourceInfo, but I need to execute some method of my resource class in request filter, so I need to get this object.

Or maybe the whole idea of getting exact object is wrong in this case?

UPD: Here is a description of the original problem:

For example I have resource that returns all users and it also can return a subresource for particular user:

@Path("users") public class UsersResource {
    @GET List<User> getUsers() {...}
    @Path("{id}") UserSubresource getById(PathParam("id") String id) {
        return new UserSubresource(getUserById(id));
    }
}

Here is UserSubresource:

public class UserSubresource {
    User user;

    @GET public User getUser() {return user;}
    ...
    public boolean isAccessible() {
        return user.isAccessibleByCurrentUser();
    } 
}

And I need to check access rights for getUser() method, I can't check permissions before I find out actual user. I understand that I can add this check in getUser() method itself, but this situation is the same for some other entities in my application, so I want more common solution.

anna239
  • 71
  • 6
  • _"Or maybe the whole idea of getting exact object is wrong in this case? "_ - Probably. Maybe if you describe the problem in detail, with some code snippets, we can help you think of another solution. – Paul Samsotha Jan 22 '15 at 14:35
  • My resource has method _isAccessible()_ I want to invoke this method in RequestFilter and return 403 if it returns false. – anna239 Jan 22 '15 at 14:50
  • How is the truth/falseness determined? Is this not something that can be determined in the filter? Sounds like you are trying to implement some security feature, in which most cases should be able to be completely handled in the filter class ([for example, the use of an annotation](http://stackoverflow.com/a/27863284/2587435)). That's why I asked for more detail. It would help to understand exactly what you are trying to accomplish. Helps to avoid an [X/Y problem](http://meta.stackexchange.com/questions/66377/what-is-the-xy-problem) – Paul Samsotha Jan 22 '15 at 15:11
  • And code snippets really do help us understand the problem better. – Paul Samsotha Jan 22 '15 at 15:17
  • Code snippets added. – anna239 Jan 26 '15 at 08:51

0 Answers0