jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r1794276 - in /jackrabbit/commons/filevault/trunk/vault-core/src: main/java/org/apache/jackrabbit/vault/packaging/impl/ test/java/org/apache/jackrabbit/vault/packaging/integration/ test/resources/org/apache/jackrabbit/vault/packaging/integr...
Date Mon, 08 May 2017 02:18:31 GMT
Author: tripod
Date: Mon May  8 02:18:31 2017
New Revision: 1794276

URL: http://svn.apache.org/viewvc?rev=1794276&view=rev
Log:
JVRVLT-155 only transfer state of the old package to the new one in case created date is identical

(this closes #8)

Added:
    jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/tmp_with_modified_created_date.zip
Modified:
    jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/JcrPackageManagerImpl.java
    jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestPackageInstall.java

Modified: jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/JcrPackageManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/JcrPackageManagerImpl.java?rev=1794276&r1=1794275&r2=1794276&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/JcrPackageManagerImpl.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/JcrPackageManagerImpl.java
Mon May  8 02:18:31 2017
@@ -256,12 +256,14 @@ public class JcrPackageManagerImpl exten
 
         // remember installation state properties (GRANITE-2018)
         JcrPackageDefinitionImpl.State state = null;
+        Calendar oldCreatedDate = null;
 
         if (parent.hasNode(name)) {
             JcrPackage oldPackage = new JcrPackageImpl(this, parent.getNode(name));
             JcrPackageDefinitionImpl oldDef = (JcrPackageDefinitionImpl) oldPackage.getDefinition();
             if (oldDef != null) {
                 state = oldDef.getState();
+                oldCreatedDate = oldDef.getCreated();
             }
 
             if (replace) {
@@ -274,7 +276,8 @@ public class JcrPackageManagerImpl exten
         try {
             jcrPack = createNew(parent, pid, bin, archive);
             JcrPackageDefinitionImpl def = (JcrPackageDefinitionImpl) jcrPack.getDefinition();
-            if (state != null) {
+            // only transfer the old package state to the new state in case both packages
have the same create date
+            if (state != null && oldCreatedDate != null && oldCreatedDate.compareTo(def.getCreated())
== 0) {
                 def.setState(state);
             }
             dispatch(PackageEvent.Type.UPLOAD, pid, null);

Modified: jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestPackageInstall.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestPackageInstall.java?rev=1794276&r1=1794275&r2=1794276&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestPackageInstall.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestPackageInstall.java
Mon May  8 02:18:31 2017
@@ -38,6 +38,7 @@ import org.junit.Test;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.fail;
 
 /**
@@ -80,6 +81,7 @@ public class TestPackageInstall extends
      */
     @Test
     public void testUnwrapPreserveInstall() throws RepositoryException, IOException, PackageException
{
+        
         JcrPackage pack = packMgr.upload(getStream("testpackages/tmp.zip"), true, true);
         assertNotNull(pack);
         assertTrue(pack.isValid());
@@ -103,6 +105,12 @@ public class TestPackageInstall extends
         assertTrue(pack.isValid());
         assertTrue(pack.isInstalled());
         assertEquals(lastUnpacked, pack.getDefinition().getLastUnpacked().getTimeInMillis());
+        
+        // a package with a different created date should not preserve the status!
+        pack = packMgr.upload(getStream("testpackages/tmp_with_modified_created_date.zip"),
true, true);
+        assertNotNull(pack);
+        assertTrue(pack.isValid());
+        assertFalse(pack.isInstalled());
     }
 
     /**

Added: jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/tmp_with_modified_created_date.zip
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/tmp_with_modified_created_date.zip?rev=1794276&view=auto
==============================================================================
Binary files jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/tmp_with_modified_created_date.zip
(added) and jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/tmp_with_modified_created_date.zip
Mon May  8 02:18:31 2017 differ



Mime
View raw message