- Have a collection resource and a specific resource that is delegated to (ie: UsersResource and UserResource where UsersResource delegates to UserResource if a username is specified)
- Want to load up a User object for each UserResource so that the duplication is not done and if you request information for a User that doesn't exist, you get an error
- However, I would like to create a User using the same style (obviously just a different http method)
Here's a taste of the code:
UsersResource:
@UriTemplate("{username}")
public UserResource getUser(@UriParam("username") String username) {
User user = RealmManager.instance().getUser(username);
if (null == user) {
throw new WebApplicationException(new RuntimeException("user '" + username + "' does not exist."), 404);
}
return new UserResource(formatterFactory, uriInfo, user);
}
Tried this in UsersResource, but this was not executed:
@UriTemplate("{username}")
@HttpMethod("PUT")
public void addUser(@UriParam("username") String username) {
RealmManager.instance().createUser(username);
}
So there you have it...anyone have any ideas?
No comments:
Post a Comment