jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r597420 - in /jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr: RootCollection.java WorkspaceResourceImpl.java
Date Thu, 22 Nov 2007 15:04:04 GMT
Author: angela
Date: Thu Nov 22 07:04:03 2007
New Revision: 597420

URL: http://svn.apache.org/viewvc?rev=597420&view=rev
Log:
JCR-1230

Modified:
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/RootCollection.java
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/WorkspaceResourceImpl.java

Modified: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/RootCollection.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/RootCollection.java?rev=597420&r1=597419&r2=597420&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/RootCollection.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/RootCollection.java
Thu Nov 22 07:04:03 2007
@@ -31,10 +31,14 @@
 import org.slf4j.LoggerFactory;
 
 import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.Repository;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Date;
 import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.OutputStreamWriter;
 
 /**
  * <code>RootCollection</code> represent the WebDAV root resource that does not
@@ -123,8 +127,44 @@
      * @throws IOException
      */
     public void spool(OutputContext outputContext) throws IOException {
-        outputContext.setContentLength(0);
-        outputContext.setModificationTime(getModificationTime());
+        if (outputContext.hasStream()) {
+            Session session = getRepositorySession();
+            Repository rep = session.getRepository();
+            String repName = rep.getDescriptor(Repository.REP_NAME_DESC);
+            String repURL = rep.getDescriptor(Repository.REP_VENDOR_URL_DESC);
+            String repVersion = rep.getDescriptor(Repository.REP_VERSION_DESC);
+            String repostr = repName + " " + repVersion;
+
+            StringBuffer sb = new StringBuffer();
+            sb.append("<html><head><title>");
+            sb.append(repostr);
+            sb.append("</title></head>");
+            sb.append("<body><h2>").append(repostr).append("</h2>");
+            sb.append("<h3>Available Workspace Resources:</h3><ul>");
+
+            DavResourceIterator it = getMembers();
+            while (it.hasNext()) {
+                DavResource res = it.nextResource();
+                sb.append("<li><a href=\"");
+                sb.append(res.getHref());
+                sb.append("\">");
+                sb.append(res.getDisplayName());
+                sb.append("</a></li>");
+            }
+            sb.append("</ul><hr size=\"1\"><em>Powered by <a href=\"");
+            sb.append(repURL).append("\">").append(repName);
+            sb.append("</a> ").append(repVersion);
+            sb.append("</em></body></html>");
+
+            outputContext.setContentLength(sb.length());
+            outputContext.setModificationTime(getModificationTime());
+            PrintWriter writer = new PrintWriter(new OutputStreamWriter(outputContext.getOutputStream(),
"utf8"));
+            writer.print(sb.toString());
+            writer.close();
+        } else {
+            outputContext.setContentLength(0);
+            outputContext.setModificationTime(getModificationTime());
+        }
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/WorkspaceResourceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/WorkspaceResourceImpl.java?rev=597420&r1=597419&r2=597420&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/WorkspaceResourceImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/WorkspaceResourceImpl.java
Thu Nov 22 07:04:03 2007
@@ -49,6 +49,7 @@
 import javax.jcr.Workspace;
 import javax.jcr.Item;
 import javax.jcr.Session;
+import javax.jcr.Repository;
 import javax.jcr.version.Version;
 import javax.jcr.observation.EventListener;
 import java.util.Iterator;
@@ -58,6 +59,8 @@
 import java.util.Map;
 import java.util.HashMap;
 import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.OutputStreamWriter;
 
 /**
  * <code>WorkspaceResourceImpl</code>...
@@ -136,8 +139,43 @@
      * @throws IOException
      */
     public void spool(OutputContext outputContext) throws IOException {
-        outputContext.setContentLength(0);
-        outputContext.setModificationTime(getModificationTime());
+        if (outputContext.hasStream()) {
+            Session session = getRepositorySession();
+            Repository rep = session.getRepository();
+            String repName = rep.getDescriptor(Repository.REP_NAME_DESC);
+            String repURL = rep.getDescriptor(Repository.REP_VENDOR_URL_DESC);
+            String repVersion = rep.getDescriptor(Repository.REP_VERSION_DESC);
+            String repostr = repName + " " + repVersion;
+
+            StringBuffer sb = new StringBuffer();
+            sb.append("<html><head><title>");
+            sb.append(repostr);
+            sb.append("</title></head>");
+            sb.append("<body><h2>").append(repostr).append("</h2><ul>");
+            sb.append("<li><a href=\"..\">..</a></li>");
+            DavResourceIterator it = getMembers();
+            while (it.hasNext()) {
+                DavResource res = it.nextResource();
+                sb.append("<li><a href=\"");
+                sb.append(res.getHref());
+                sb.append("\">");
+                sb.append(res.getDisplayName());
+                sb.append("</a></li>");
+            }
+            sb.append("</ul><hr size=\"1\"><em>Powered by <a href=\"");
+            sb.append(repURL).append("\">").append(repName);
+            sb.append("</a> ").append(repVersion);
+            sb.append("</em></body></html>");
+
+            outputContext.setContentLength(sb.length());
+            outputContext.setModificationTime(getModificationTime());
+            PrintWriter writer = new PrintWriter(new OutputStreamWriter(outputContext.getOutputStream(),
"utf8"));
+            writer.print(sb.toString());
+            writer.close();
+        } else {
+            outputContext.setContentLength(0);
+            outputContext.setModificationTime(getModificationTime());
+        }
     }
 
     /**
@@ -397,7 +435,7 @@
         super.initSupportedReports();
         supportedReports.addReportType(JcrPrivilegeReport.PRIVILEGES_REPORT);
     }
-    
+
     protected String getWorkspaceHref() {
         return getHref();
     }



Mime
View raw message