[Yanel-commits] rev 20306 - in public/yanel/trunk/src: build core/java/org/wyona/yanel/core/api/attributes core/java/org/wyona/yanel/servlet resources/file/src/java/org/wyona/yanel/impl/resources resources/xml/src/java/org/wyona/yanel/impl/resources

david at wyona.com david at wyona.com
Fri Nov 24 14:24:29 CET 2006


Author: david
Date: 2006-11-24 14:24:28 +0100 (Fri, 24 Nov 2006)
New Revision: 20306

Added:
   public/yanel/trunk/src/core/java/org/wyona/yanel/core/api/attributes/VersionableV2.java
Modified:
   public/yanel/trunk/src/build/dependencies.xml
   public/yanel/trunk/src/core/java/org/wyona/yanel/servlet/YanelServlet.java
   public/yanel/trunk/src/resources/file/src/java/org/wyona/yanel/impl/resources/FileResource.java
   public/yanel/trunk/src/resources/xml/src/java/org/wyona/yanel/impl/resources/XMLResource.java
Log:
added VersionalbleV2 interface and implemented it in fileresource and xmlresource. revision data is diplayed in the meta data. see bug #4953

Modified: public/yanel/trunk/src/build/dependencies.xml
===================================================================
--- public/yanel/trunk/src/build/dependencies.xml	2006-11-24 13:17:27 UTC (rev 20305)
+++ public/yanel/trunk/src/build/dependencies.xml	2006-11-24 13:24:28 UTC (rev 20306)
@@ -58,6 +58,8 @@
                   
       <dependency groupId="spring" artifactId="spring"
                   version="2.0"/>
+      <dependency groupId="svnkit" artifactId="svnkit"
+                  version="1.1.0"/>
     </artifact:dependencies>
 
     <property name="maven2.cp" refid="maven2.classpath"/>

Added: public/yanel/trunk/src/core/java/org/wyona/yanel/core/api/attributes/VersionableV2.java
===================================================================
--- public/yanel/trunk/src/core/java/org/wyona/yanel/core/api/attributes/VersionableV2.java	2006-11-24 13:17:27 UTC (rev 20305)
+++ public/yanel/trunk/src/core/java/org/wyona/yanel/core/api/attributes/VersionableV2.java	2006-11-24 13:24:28 UTC (rev 20306)
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2006 Wyona
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.wyona.org/licenses/APACHE-LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.wyona.yanel.core.api.attributes;
+
+import java.io.OutputStream;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.wyona.yanel.core.Path;
+import org.wyona.yanel.core.attributes.viewable.View;
+
+/**
+ * DEV (not released yet, this interface still might change ...)
+ */
+public interface VersionableV2 {
+
+    public String[] getRevisions(Path path);
+    
+    /*
+     * Methods which could be added to this interface:
+     * 
+     * public View getView(Path path, OutputStream out, String viewId, String revision) throws Exception;
+     * public void getView(HttpServletRequest request, HttpServletResponse response, String viewId, String revision) throws Exception;
+     * public void rollback(String revision) throws Exception;
+     *
+     * getDiff(Path path, String rev1, String rev2) throws Exception;
+     * getHeadRevisionNumber() ?
+     * 
+     * open questions:
+     * - how to tag a revision? (user can tag a revision with a message like e.g. 'added paragraph about ...')
+     * - how to retrieve information associated to a certain revision (date, tag, etc.)?
+     * - how to integrate versioning with workflow: tag specific revision as live, etc.
+     * 
+     */
+    
+}

Modified: public/yanel/trunk/src/core/java/org/wyona/yanel/servlet/YanelServlet.java
===================================================================
--- public/yanel/trunk/src/core/java/org/wyona/yanel/servlet/YanelServlet.java	2006-11-24 13:17:27 UTC (rev 20305)
+++ public/yanel/trunk/src/core/java/org/wyona/yanel/servlet/YanelServlet.java	2006-11-24 13:24:28 UTC (rev 20306)
@@ -22,6 +22,7 @@
 import org.wyona.yanel.core.Yanel;
 import org.wyona.yanel.core.api.attributes.ModifiableV1;
 import org.wyona.yanel.core.api.attributes.ModifiableV2;
+import org.wyona.yanel.core.api.attributes.VersionableV2;
 import org.wyona.yanel.core.api.attributes.ViewableV1;
 import org.wyona.yanel.core.api.attributes.ViewableV2;
 import org.wyona.yanel.core.attributes.viewable.View;
@@ -265,6 +266,19 @@
                     } else {
                         Element noLastModifiedElement = (Element) resourceElement.appendChild(doc.createElement("no-last-modified"));
                     }
+                    if (ResourceAttributeHelper.hasAttributeImplemented(res, "Versionable", "2")) {
+                        // retrieve the revisions, but only in the meta usecase (for performance reasons):
+                        if (request.getParameter("yanel.resource.meta") != null) {
+                            String[] revisions = ((VersionableV2)res).getRevisions(new Path(request.getServletPath()));
+                            Element revisionsElement = (Element) resourceElement.appendChild(doc.createElement("revisions"));
+                            if (revisions != null) {
+                                for (int i=0; i<revisions.length; i++) {
+                                    Element revisionElement = (Element) revisionsElement.appendChild(doc.createElement("revision"));
+                                    revisionElement.appendChild(doc.createTextNode(revisions[i]));
+                                }
+                            }
+                        }
+                    }
                 } else {
                         Element resourceIsNullElement = (Element) rootElement.appendChild(doc.createElement("resource-is-null"));
                 }

Modified: public/yanel/trunk/src/resources/file/src/java/org/wyona/yanel/impl/resources/FileResource.java
===================================================================
--- public/yanel/trunk/src/resources/file/src/java/org/wyona/yanel/impl/resources/FileResource.java	2006-11-24 13:17:27 UTC (rev 20305)
+++ public/yanel/trunk/src/resources/file/src/java/org/wyona/yanel/impl/resources/FileResource.java	2006-11-24 13:24:28 UTC (rev 20306)
@@ -20,6 +20,7 @@
 import org.wyona.yanel.core.Resource;
 import org.wyona.yanel.core.Topic;
 import org.wyona.yanel.core.api.attributes.ModifiableV2;
+import org.wyona.yanel.core.api.attributes.VersionableV2;
 import org.wyona.yanel.core.api.attributes.ViewableV1;
 import org.wyona.yanel.core.attributes.viewable.View;
 import org.wyona.yanel.core.attributes.viewable.ViewDescriptor;
@@ -40,7 +41,7 @@
 /**
  *
  */
-public class FileResource extends Resource implements ViewableV1, ModifiableV2 {
+public class FileResource extends Resource implements ViewableV1, ModifiableV2, VersionableV2 {
 
     private static Category log = Category.getInstance(FileResource.class);
 
@@ -64,6 +65,7 @@
         View defaultView = new View();
         
             org.wyona.yarep.util.RepoPath rp = new org.wyona.yarep.util.YarepUtil().getRepositoryPath(new org.wyona.yarep.core.Path(path.toString()), getRepositoryFactory());
+            
             defaultView.setInputStream(rp.getRepo().getInputStream(new org.wyona.yarep.core.Path(rp.getPath().toString())));
 
             defaultView.setMimeType(getMimeType(path, viewId));
@@ -238,6 +240,16 @@
         }
     }
     
+    public String[] getRevisions(Path path) {
+        try {
+            RepoPath rp = new org.wyona.yarep.util.YarepUtil().getRepositoryPath(new org.wyona.yarep.core.Path(path.toString()), getRepositoryFactory());
+            return rp.getRepo().getRevisions(new org.wyona.yarep.core.Path(rp.getPath().toString()));
+        } catch(Exception e) {
+            log.error(e);
+            return null;
+        }
+    }
+
     protected RepositoryFactory getRepositoryFactory() {
         return yanel.getRepositoryFactory("DefaultRepositoryFactory");
     }    

Modified: public/yanel/trunk/src/resources/xml/src/java/org/wyona/yanel/impl/resources/XMLResource.java
===================================================================
--- public/yanel/trunk/src/resources/xml/src/java/org/wyona/yanel/impl/resources/XMLResource.java	2006-11-24 13:17:27 UTC (rev 20305)
+++ public/yanel/trunk/src/resources/xml/src/java/org/wyona/yanel/impl/resources/XMLResource.java	2006-11-24 13:24:28 UTC (rev 20306)
@@ -22,6 +22,7 @@
 import org.wyona.yanel.core.Yanel;
 import org.wyona.yanel.core.api.attributes.ModifiableV1;
 import org.wyona.yanel.core.api.attributes.ModifiableV2;
+import org.wyona.yanel.core.api.attributes.VersionableV2;
 import org.wyona.yanel.core.api.attributes.ViewableV1;
 import org.wyona.yanel.core.attributes.viewable.View;
 import org.wyona.yanel.core.attributes.viewable.ViewDescriptor;
@@ -53,7 +54,7 @@
 /**
  *
  */
-public class XMLResource extends Resource implements ViewableV1, ModifiableV1, ModifiableV2 {
+public class XMLResource extends Resource implements ViewableV1, ModifiableV1, ModifiableV2, VersionableV2 {
 
     private static Category log = Category.getInstance(XMLResource.class);
 
@@ -314,8 +315,17 @@
         return property;
     }
     
+    public String[] getRevisions(Path path) {
+        try {
+            RepoPath rp = new org.wyona.yarep.util.YarepUtil().getRepositoryPath(new org.wyona.yarep.core.Path(path.toString()), getRepositoryFactory());
+            return rp.getRepo().getRevisions(new org.wyona.yarep.core.Path(rp.getPath().toString()));
+        } catch(Exception e) {
+            log.error(e);
+            return null;
+        }
+    }
+
     protected RepositoryFactory getRepositoryFactory() {
         return yanel.getRepositoryFactory("DefaultRepositoryFactory");
     }
-    
 }




More information about the Yanel-commits mailing list