Hi
First of all, thanks for an amazing product. It has transformed the way I design and build web applications.
I am having a little problems achieving something that would simplify things further. I am trying to combine sub resource locators with HTTP methods.
I'm supplying an exemple where i try to get ContainerResource to manage the access, creation and deletion of items and leave everything else to the ItemResource. This would simplify the code of ItemResource considerably (moving PUT and DELETE into the ItemResource forces me to call DB.lookup in all other methods...)
The following example gives 504 for a GET to /someItemId (at least my real code similar to the example does). I realize that this is probably by design, but is there a way to achieve what I'm trying to do or would it make sense to support it?
I'm using version 1.1.5.
@Path("/")
public class ContainerResource {
@GET
public Response getAllItems() {
reurn new GenericType......
}
@Path("{itemId})
public ItemResource item(@PathParam("itemId) final String itemId) {
if (!authorized()) {
throw new WebApplicationException(....);
}
try {
return new ItemResource(DB.lookupItem(itemId));
} catch (ItemNotFound e) {
throw new WebApplicationException(.....);
}
}
@PUT
@Path("{itemId})
public Response addItem(@PathParam("itemId") final String itemId) {
DB.addItem(new Item(itemId))
return Response.ok().build();
}
@DELETE
@Path("{itemId})
public Response deleteItem(@PathParam("itemId") final String itemId) {
DB.deleteItem(itemId);
return Response.ok().build();
}
}
public class ItemResource {
public ItemResource(final Item item) {
this.item = item;
}
@GET
@Produces(....)
public Item get() {
return item;
}
@Path
public SomeOtherResource otherResource() {...}
....
....
}