You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rave.apache.org by un...@apache.org on 2012/06/09 09:29:54 UTC

svn commit: r1348327 - in /rave/sandbox/content-services/rave-jcr-config/src: main/java/org/apache/rave/jcr/bootstrapping/ test/java/org/apache/rave/jcr/bootstrapping/ test/resources/META-INF/rave/

Author: unico
Date: Sat Jun  9 07:29:53 2012
New Revision: 1348327

URL: http://svn.apache.org/viewvc?rev=1348327&view=rev
Log:
RAVE-603 use a version string instead of a version number for modules

Modified:
    rave/sandbox/content-services/rave-jcr-config/src/main/java/org/apache/rave/jcr/bootstrapping/Module.java
    rave/sandbox/content-services/rave-jcr-config/src/main/java/org/apache/rave/jcr/bootstrapping/ModuleRegistry.java
    rave/sandbox/content-services/rave-jcr-config/src/main/java/org/apache/rave/jcr/bootstrapping/ModuleScanner.java
    rave/sandbox/content-services/rave-jcr-config/src/test/java/org/apache/rave/jcr/bootstrapping/ModuleRegistryTest.java
    rave/sandbox/content-services/rave-jcr-config/src/test/java/org/apache/rave/jcr/bootstrapping/ModuleScannerTest.java
    rave/sandbox/content-services/rave-jcr-config/src/test/resources/META-INF/rave/module.json

Modified: rave/sandbox/content-services/rave-jcr-config/src/main/java/org/apache/rave/jcr/bootstrapping/Module.java
URL: http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-jcr-config/src/main/java/org/apache/rave/jcr/bootstrapping/Module.java?rev=1348327&r1=1348326&r2=1348327&view=diff
==============================================================================
--- rave/sandbox/content-services/rave-jcr-config/src/main/java/org/apache/rave/jcr/bootstrapping/Module.java (original)
+++ rave/sandbox/content-services/rave-jcr-config/src/main/java/org/apache/rave/jcr/bootstrapping/Module.java Sat Jun  9 07:29:53 2012
@@ -88,7 +88,7 @@ public final class Module {
 
     private final String name;
     private final String baseUrl;
-    private final long version;
+    private final String version;
 
     private Status status;
 
@@ -98,7 +98,7 @@ public final class Module {
     private List<Content> contents;
     private List<Resource> resources;
 
-    public Module(final String name, final String baseUrl, final long version) {
+    public Module(final String name, final String baseUrl, final String version) {
         this.name = name;
         this.baseUrl = baseUrl;
         this.version = version;
@@ -108,7 +108,7 @@ public final class Module {
         return name;
     }
 
-    public long getVersion() {
+    public String getVersion() {
         return version;
     }
 
@@ -240,7 +240,7 @@ public final class Module {
     public int hashCode() {
         int result = name.hashCode();
         result = 31 * result + baseUrl.hashCode();
-        result = 31 * result + (int) (version ^ (version >>> 32));
+        result = 31 * result + version.hashCode();
         result = 31 * result + (dependencies != null ? dependencies.hashCode() : 0);
         result = 31 * result + (namespaces != null ? namespaces.hashCode() : 0);
         result = 31 * result + (cnds != null ? cnds.hashCode() : 0);

Modified: rave/sandbox/content-services/rave-jcr-config/src/main/java/org/apache/rave/jcr/bootstrapping/ModuleRegistry.java
URL: http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-jcr-config/src/main/java/org/apache/rave/jcr/bootstrapping/ModuleRegistry.java?rev=1348327&r1=1348326&r2=1348327&view=diff
==============================================================================
--- rave/sandbox/content-services/rave-jcr-config/src/main/java/org/apache/rave/jcr/bootstrapping/ModuleRegistry.java (original)
+++ rave/sandbox/content-services/rave-jcr-config/src/main/java/org/apache/rave/jcr/bootstrapping/ModuleRegistry.java Sat Jun  9 07:29:53 2012
@@ -101,13 +101,18 @@ public final class ModuleRegistry {
         final Node node = modulesNode.getNode(current.getName());
 
         try {
-            if (current.getVersion() != previous.getVersion()) {
-                node.setProperty(VERSION, current.getVersion());
-                setStatusProperty(node, Module.Status.GRADED);
-                current.setStatus(Module.Status.GRADED);
+            if (current.getVersion() != null ? !current.getVersion().equals(previous.getVersion()) : previous.getVersion() != null) {
+                if (current.getVersion() == null) {
+//                    assert node.hasProperty(VERSION);
+                    node.getProperty(VERSION).remove();
+                } else {
+                    node.setProperty(VERSION, current.getVersion());
+                    setStatusProperty(node, Module.Status.GRADED);
+                    current.setStatus(Module.Status.GRADED);
+                }
             }
 
-            if (current.getBaseUrl().equals(previous.getBaseUrl())) {
+            if (!current.getBaseUrl().equals(previous.getBaseUrl())) {
                 node.setProperty(BASEURL, current.getBaseUrl());
             }
 
@@ -208,7 +213,9 @@ public final class ModuleRegistry {
         final Node moduleNode = getOrCreateNode(modulesNode, module.getName());
 
         try {
-            moduleNode.setProperty(VERSION, module.getVersion());
+            if (module.getVersion() != null) {
+                moduleNode.setProperty(VERSION, module.getVersion());
+            }
             moduleNode.setProperty(BASEURL, module.getBaseUrl());
             moduleNode.setProperty(STATUS, Module.Status.NEW.toString());
 
@@ -307,7 +314,7 @@ public final class ModuleRegistry {
     private Module readModule(Node node) throws RepositoryException {
         final String name = node.getName();
         final String baseUrl = node.getProperty(BASEURL).getString();
-        final long version = node.getProperty(VERSION).getLong();
+        final String version = node.hasProperty(VERSION) ? node.getProperty(VERSION).getString() : null;
 
         final Module module = new Module(name, baseUrl, version);
 

Modified: rave/sandbox/content-services/rave-jcr-config/src/main/java/org/apache/rave/jcr/bootstrapping/ModuleScanner.java
URL: http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-jcr-config/src/main/java/org/apache/rave/jcr/bootstrapping/ModuleScanner.java?rev=1348327&r1=1348326&r2=1348327&view=diff
==============================================================================
--- rave/sandbox/content-services/rave-jcr-config/src/main/java/org/apache/rave/jcr/bootstrapping/ModuleScanner.java (original)
+++ rave/sandbox/content-services/rave-jcr-config/src/main/java/org/apache/rave/jcr/bootstrapping/ModuleScanner.java Sat Jun  9 07:29:53 2012
@@ -100,7 +100,7 @@ public final class ModuleScanner {
         }
         final String moduleName = object.get(NAME).textValue();
 
-        final long newVersion = object.has(VERSION) ? object.get(VERSION).numberValue().longValue() : -1;
+        final String newVersion = object.has(VERSION) ? object.get(VERSION).textValue() : null;
 
         final Module module = new Module(moduleName, baseUrl, newVersion);
 

Modified: rave/sandbox/content-services/rave-jcr-config/src/test/java/org/apache/rave/jcr/bootstrapping/ModuleRegistryTest.java
URL: http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-jcr-config/src/test/java/org/apache/rave/jcr/bootstrapping/ModuleRegistryTest.java?rev=1348327&r1=1348326&r2=1348327&view=diff
==============================================================================
--- rave/sandbox/content-services/rave-jcr-config/src/test/java/org/apache/rave/jcr/bootstrapping/ModuleRegistryTest.java (original)
+++ rave/sandbox/content-services/rave-jcr-config/src/test/java/org/apache/rave/jcr/bootstrapping/ModuleRegistryTest.java Sat Jun  9 07:29:53 2012
@@ -74,7 +74,7 @@ public class ModuleRegistryTest extends 
         // module properties
         Node moduleNode = session.getNode("/rave:system/modules/foo");
         assertTrue(moduleNode.hasProperty("version"));
-        assertEquals(1, moduleNode.getProperty("version").getLong());
+        assertEquals("v1", moduleNode.getProperty("version").getString());
         assertTrue(moduleNode.hasProperty("baseUrl"));
 
         // namespaces
@@ -137,7 +137,7 @@ public class ModuleRegistryTest extends 
 
     public void testRemoveModule() throws Exception {
         final ModuleRegistry moduleRegistry = new ModuleRegistry(session, "/rave:system");
-        final Module module = new Module("foo", "foo", -1);
+        final Module module = new Module("foo", "foo", "");
         moduleRegistry.writeModule(module);
         moduleRegistry.removeModule(module);
         assertFalse(session.nodeExists("/rave:system/modules/foo"));

Modified: rave/sandbox/content-services/rave-jcr-config/src/test/java/org/apache/rave/jcr/bootstrapping/ModuleScannerTest.java
URL: http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-jcr-config/src/test/java/org/apache/rave/jcr/bootstrapping/ModuleScannerTest.java?rev=1348327&r1=1348326&r2=1348327&view=diff
==============================================================================
--- rave/sandbox/content-services/rave-jcr-config/src/test/java/org/apache/rave/jcr/bootstrapping/ModuleScannerTest.java (original)
+++ rave/sandbox/content-services/rave-jcr-config/src/test/java/org/apache/rave/jcr/bootstrapping/ModuleScannerTest.java Sat Jun  9 07:29:53 2012
@@ -47,7 +47,7 @@ public class ModuleScannerTest {
     private void checkModule(Module module) {
         assertEquals("foo", module.getName());
         assertTrue(module.getBaseUrl().endsWith("target/test-classes/"));
-        assertEquals(1, module.getVersion());
+        assertEquals("v1", module.getVersion());
 
         assertEquals(2, module.getDependencies().size());
         assertTrue(module.getDependencies().contains("bar"));

Modified: rave/sandbox/content-services/rave-jcr-config/src/test/resources/META-INF/rave/module.json
URL: http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-jcr-config/src/test/resources/META-INF/rave/module.json?rev=1348327&r1=1348326&r2=1348327&view=diff
==============================================================================
--- rave/sandbox/content-services/rave-jcr-config/src/test/resources/META-INF/rave/module.json (original)
+++ rave/sandbox/content-services/rave-jcr-config/src/test/resources/META-INF/rave/module.json Sat Jun  9 07:29:53 2012
@@ -1,6 +1,6 @@
 {
   "name" : "foo",
-  "version" : 1,
+  "version" : "v1",
   "dependencies" : [ "bar", "quz" ],
   "namespaces" : {
       "foo" : "http://foo.com/1.0"