Author: reto
Date: Thu Apr  5 13:34:49 2012
New Revision: 1309851

URL: http://svn.apache.org/viewvc?rev=1309851&view=rev
Log:
added support to list the entries for the seleced category

Added:
    
incubator/stanbol/branches/ontonet-showcase/featured-vfolders/src/main/java/org/apache/stanbol/contenthub/vfolders/CountResource.java
Modified:
    
incubator/stanbol/branches/ontonet-showcase/featured-vfolders/src/main/java/org/apache/stanbol/contenthub/vfolders/FacetedResource.java

Added: 
incubator/stanbol/branches/ontonet-showcase/featured-vfolders/src/main/java/org/apache/stanbol/contenthub/vfolders/CountResource.java
URL: 
http://svn.apache.org/viewvc/incubator/stanbol/branches/ontonet-showcase/featured-vfolders/src/main/java/org/apache/stanbol/contenthub/vfolders/CountResource.java?rev=1309851&view=auto
==============================================================================
--- 
incubator/stanbol/branches/ontonet-showcase/featured-vfolders/src/main/java/org/apache/stanbol/contenthub/vfolders/CountResource.java
 (added)
+++ 
incubator/stanbol/branches/ontonet-showcase/featured-vfolders/src/main/java/org/apache/stanbol/contenthub/vfolders/CountResource.java
 Thu Apr  5 13:34:49 2012
@@ -0,0 +1,100 @@
+package org.apache.stanbol.contenthub.vfolders;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.solr.client.solrj.response.FacetField.Count;
+import org.apache.stanbol.webdav.resources.AbstractCollectionResource;
+
+import com.bradmcevoy.http.Auth;
+import com.bradmcevoy.http.CollectionResource;
+import com.bradmcevoy.http.GetableResource;
+import com.bradmcevoy.http.PropFindableResource;
+import com.bradmcevoy.http.Range;
+import com.bradmcevoy.http.Request;
+import com.bradmcevoy.http.Request.Method;
+import com.bradmcevoy.http.Resource;
+import com.bradmcevoy.http.exceptions.BadRequestException;
+import com.bradmcevoy.http.exceptions.NotAuthorizedException;
+
+public class CountResource extends AbstractCollectionResource implements 
PropFindableResource, GetableResource, CollectionResource {
+
+
+       private static final String MESSAGE = "Hello world";
+       private Count value;
+       
+       public CountResource(Count value) {
+               this.value = value;
+       }
+
+
+       public String getUniqueId() {
+               return value.getName();
+       }
+ 
+
+       public String getName() {
+               return value.getName();
+       }
+ 
+       public Object authenticate(String user, String password) {
+               return "anonymous";
+       }
+ 
+       public boolean authorise(Request request, Method method, Auth auth) {
+               return true;
+       }
+ 
+       public String getRealm() {
+               return null;
+       }
+ 
+       public Date getCreateDate() {
+               return new Date();
+       }
+ 
+       public Date getModifiedDate() {
+               return new Date();
+       }
+ 
+
+       public String checkRedirect(Request request) {
+               return null;
+       }
+ 
+
+       public Long getMaxAgeSeconds(Auth auth) {
+               return null;
+       }
+ 
+       public String getContentType(String accepts) {
+               return "text/plain";
+       }
+ 
+       public Long getContentLength() {
+               return Long.valueOf(MESSAGE.length());
+       }
+       
+       @Override
+       public void sendContent(OutputStream out, Range range, Map<String, 
String>  params, String contentType) throws IOException, 
NotAuthorizedException, BadRequestException {
+               out.write(MESSAGE.getBytes());
+       }
+
+
+
+       @Override
+       public List<? extends Resource> getChildren()
+                       throws NotAuthorizedException, BadRequestException {
+               // TODO Auto-generated method stub
+               List<Resource> resources = new ArrayList<Resource>();
+               //TODO here we should add:
+               //- The categories as in root for the categories that have an 
entry that can reduce the current set of matching documents (but not to the 
empty set) 
+               //- Add the matching items
+               return resources;
+       }
+
+}

Modified: 
incubator/stanbol/branches/ontonet-showcase/featured-vfolders/src/main/java/org/apache/stanbol/contenthub/vfolders/FacetedResource.java
URL: 
http://svn.apache.org/viewvc/incubator/stanbol/branches/ontonet-showcase/featured-vfolders/src/main/java/org/apache/stanbol/contenthub/vfolders/FacetedResource.java?rev=1309851&r1=1309850&r2=1309851&view=diff
==============================================================================
--- 
incubator/stanbol/branches/ontonet-showcase/featured-vfolders/src/main/java/org/apache/stanbol/contenthub/vfolders/FacetedResource.java
 (original)
+++ 
incubator/stanbol/branches/ontonet-showcase/featured-vfolders/src/main/java/org/apache/stanbol/contenthub/vfolders/FacetedResource.java
 Thu Apr  5 13:34:49 2012
@@ -111,6 +111,9 @@ public class FacetedResource extends Abs
                // TODO Auto-generated method stub
                List<Resource> resources = new ArrayList<Resource>();
                List<Count> values = fr.getFacetField().getValues();
+               for (Count value : values) {
+                       resources.add(new CountResource(value));
+               }
        /*      resources.add(new FacetedResource("bar1"));
                resources.add(new FacetedResource("bar2"));
                resources.add(new FacetedResource("bar3") {});*/


Reply via email to