Web API to get information about the index
authorJan Lahoda <jlahoda@netbeans.org>
Sat, 07 Jul 2012 23:05:26 +0200
changeset 81469a1df845e0b
parent 813 cd06de37bc2f
child 815 ccd7045f1d10
Web API to get information about the index
remoting/server/web/base.web.api/src/org/netbeans/modules/jackpot30/backend/base/api/API.java
     1.1 --- a/remoting/server/web/base.web.api/src/org/netbeans/modules/jackpot30/backend/base/api/API.java	Fri Jul 06 23:11:32 2012 +0200
     1.2 +++ b/remoting/server/web/base.web.api/src/org/netbeans/modules/jackpot30/backend/base/api/API.java	Sat Jul 07 23:05:26 2012 +0200
     1.3 @@ -43,7 +43,11 @@
     1.4  import javax.ws.rs.GET;
     1.5  import javax.ws.rs.Path;
     1.6  import javax.ws.rs.Produces;
     1.7 +import javax.ws.rs.QueryParam;
     1.8 +import javax.ws.rs.core.Response;
     1.9 +import javax.ws.rs.core.Response.Status;
    1.10  import org.netbeans.modules.jackpot30.backend.base.CategoryStorage;
    1.11 +import org.openide.filesystems.FileObject;
    1.12  
    1.13  /**
    1.14   *
    1.15 @@ -70,7 +74,7 @@
    1.16  
    1.17      @GET
    1.18      @Path("/internal/indexUpdated")
    1.19 -    @Produces("test/plain")
    1.20 +    @Produces("text/plain")
    1.21      public String indexUpdated() throws IOException {
    1.22          //XXX: should allow individual providers to do their own cleanup:
    1.23          
    1.24 @@ -79,4 +83,19 @@
    1.25          return "Done";
    1.26      }
    1.27  
    1.28 +    @GET
    1.29 +    @Path("/info")
    1.30 +    @Produces("text/plain")
    1.31 +    public Response info(@QueryParam("path") String segment) throws IOException {
    1.32 +        CategoryStorage cat = CategoryStorage.forId(segment);
    1.33 +
    1.34 +        if (cat == null) {
    1.35 +            return Response.status(Status.NOT_FOUND).build();
    1.36 +        } else {
    1.37 +            FileObject info = cat.getCacheRoot().getFileObject("info");
    1.38 +            String content = info != null ? info.asText("UTF-8") : "{}";
    1.39 +            return Response.ok().entity(content).build();
    1.40 +        }
    1.41 +    }
    1.42 +
    1.43  }