Add support for plugin REST endpoints without view names

With this change it is possible to bind REST endpoints in plugins with empty
view names:

  @Override
  protected void configure() {
    install(new RestApiModule() {
      @Override
      protected void configure() {
        delete(REVISION_KIND).to(HelloWorldAction.class);
      }
    });
  }

So defined endpoint can be accessed in two ways: with and without plugin
namespace:

 DELETE /changes/1/revisions/1/
 DELETE /changes/1/revisions/1/cookbook~

The last case is important to support because UiActions always prefix the view
name with the plugin name.

Change-Id: Ifd32fd7f33edcc7fcf763cdd780fb0a95e111519
This commit is contained in:
David Ostrovsky
2013-09-18 23:58:58 +02:00
parent 9ef5abd5cf
commit 164423f8e8

View File

@@ -788,8 +788,12 @@ public class RestApiServlet extends HttpServlet {
List<String> p = splitProjection(projection);
if (p.size() == 2) {
String viewname = p.get(1);
if (Strings.isNullOrEmpty(viewname)) {
viewname = "/";
}
RestView<RestResource> view =
views.get(p.get(0), method + "." + p.get(1));
views.get(p.get(0), method + "." + viewname);
if (view != null) {
return new ViewData(p.get(0), view);
}