jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From resc...@apache.org
Subject svn commit: r771344 - in /jackrabbit/trunk: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/ jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/ jackrabbit-jcr-tests/src...
Date Mon, 04 May 2009 16:05:31 GMT
Author: reschke
Date: Mon May  4 16:05:30 2009
New Revision: 771344

URL: http://svn.apache.org/viewvc?rev=771344&view=rev
Log:
JCR-2085: RetentionPolicy now obtained from a pre-populated node, see new property "retentionpolicyholder";
change cleanup so that it cleans up retention policies as well.

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/JackrabbitRepositoryStub.java
    jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/JackrabbitRepositoryStub.properties
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/AbstractJCRTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/JNDIRepositoryStub.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/RepositoryHelper.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/RepositoryStub.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/retention/AbstractRetentionTest.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/JackrabbitRepositoryStub.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/JackrabbitRepositoryStub.java?rev=771344&r1=771343&r2=771344&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/JackrabbitRepositoryStub.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/JackrabbitRepositoryStub.java
Mon May  4 16:05:30 2009
@@ -43,8 +43,6 @@
 import org.apache.jackrabbit.api.JackrabbitWorkspace;
 import org.apache.jackrabbit.core.config.RepositoryConfig;
 import org.apache.jackrabbit.core.retention.RetentionPolicyImpl;
-import org.apache.jackrabbit.core.retention.RetentionRegistryImpl;
-import org.apache.jackrabbit.test.NotExecutableException;
 import org.apache.jackrabbit.test.RepositoryStub;
 import org.apache.jackrabbit.test.RepositoryStubException;
 
@@ -176,10 +174,6 @@
         return repository;
     }
 
-    public RetentionPolicy getRetentionPolicy(Session session) throws NotExecutableException,
RepositoryException {
-        return RetentionPolicyImpl.createRetentionPolicy(RepositoryStub.RETENTION_POLICY_NAME,
session);
-    }
-
     private void prepareTestContent(Session session)
             throws RepositoryException, IOException {
         JackrabbitWorkspace workspace =
@@ -206,10 +200,7 @@
         addQueryTestData(getOrAddNode(data, "query"));
         addNodeTestData(getOrAddNode(data, "node"));
         addExportTestData(getOrAddNode(data, "docViewTest"));
-        
-        // add a policy
-        // TODO check we're doing the right thing here
-        RetentionPolicyImpl.createRetentionPolicy("retentionPolicyName", session);
+        addRetentionTestData(getOrAddNode(data, "retentionTest"));
         
         session.save();
     }
@@ -240,6 +231,14 @@
     }
 
     /**
+     * Creates a node with a RetentionPolicy
+     */
+    private void addRetentionTestData(Node node) throws RepositoryException {
+        RetentionPolicy rp = RetentionPolicyImpl.createRetentionPolicy("testRetentionPolicy",
node.getSession());
+        node.getSession().getRetentionManager().setRetentionPolicy(node.getPath(), rp);
+    }
+
+    /**
      * Creates four nodes under the given node. Each node has a String
      * property named "prop1" with some content set.
      */

Modified: jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/JackrabbitRepositoryStub.properties
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/JackrabbitRepositoryStub.properties?rev=771344&r1=771343&r2=771344&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/JackrabbitRepositoryStub.properties
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/JackrabbitRepositoryStub.properties
Mon May  4 16:05:30 2009
@@ -505,3 +505,7 @@
 #         OPV behaviour in order to successfully test Node.restore and Workspace.restore
with uuid conflict.
 javax.jcr.tck.simple.nodename4=childNodeName
 
+# ==============================================================================
+# JAVAX.JCR.RETENTION CONFIGURATION
+# ==============================================================================
+javax.jcr.tck.retentionpolicyholder=/testdata/retentionTest

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/AbstractJCRTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/AbstractJCRTest.java?rev=771344&r1=771343&r2=771344&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/AbstractJCRTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/AbstractJCRTest.java
Mon May  4 16:05:30 2009
@@ -27,6 +27,7 @@
 import javax.jcr.Repository;
 import javax.jcr.NamespaceException;
 import javax.jcr.RangeIterator;
+import javax.jcr.UnsupportedRepositoryOperationException;
 import javax.jcr.Value;
 import javax.jcr.ValueFactory;
 import javax.jcr.nodetype.NoSuchNodeTypeException;
@@ -34,6 +35,8 @@
 import javax.jcr.nodetype.ConstraintViolationException;
 import javax.jcr.nodetype.NodeType;
 import javax.jcr.nodetype.PropertyDefinition;
+import javax.jcr.retention.RetentionManager;
+import javax.jcr.retention.RetentionPolicy;
 
 import java.util.StringTokenizer;
 import java.util.Random;
@@ -743,11 +746,29 @@
         s.refresh(false);
         Node root = s.getRootNode();
         Node testRootNode;
+        
+        RetentionManager rm;
+        try {
+            rm = s.getRetentionManager();
+        } catch (UnsupportedRepositoryOperationException ex) {
+            rm = null;
+        }
+        
         if (root.hasNode(testPath)) {
             // clean test root
             testRootNode = root.getNode(testPath);
             for (NodeIterator children = testRootNode.getNodes(); children.hasNext();) {
                 Node child = children.nextNode();
+
+                // Remove retention policy if needed
+                if (rm != null) {
+                    RetentionPolicy pol = rm.getRetentionPolicy(child.getPath());
+                    if (pol != null) {
+                        rm.removeRetentionPolicy(child.getPath());
+                        s.save();
+                    }
+                }
+                
                 NodeDefinition nodeDef = child.getDefinition();
                 if (!nodeDef.isMandatory() && !nodeDef.isProtected()) {
                     // try to remove child

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/JNDIRepositoryStub.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/JNDIRepositoryStub.java?rev=771344&r1=771343&r2=771344&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/JNDIRepositoryStub.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/JNDIRepositoryStub.java
Mon May  4 16:05:30 2009
@@ -16,14 +16,12 @@
  */
 package org.apache.jackrabbit.test;
 
+import java.util.Properties;
+
 import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.retention.RetentionPolicy;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
 import javax.rmi.PortableRemoteObject;
-import java.util.Properties;
 
 /**
  * Implements the abstract class <code>RepositoryStub</code> and uses JNDI
@@ -65,10 +63,4 @@
         }
         return repository;
     }
-
-    public RetentionPolicy getRetentionPolicy(Session session) throws NotExecutableException,
RepositoryException {
-        // TODO
-        throw new NotExecutableException("");
-    }
-
 }

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/RepositoryHelper.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/RepositoryHelper.java?rev=771344&r1=771343&r2=771344&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/RepositoryHelper.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/RepositoryHelper.java
Mon May  4 16:05:30 2009
@@ -16,14 +16,13 @@
  */
 package org.apache.jackrabbit.test;
 
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.jcr.Credentials;
 import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
-import javax.jcr.Credentials;
-import javax.jcr.retention.RetentionPolicy;
-
-import java.util.Map;
-import java.util.HashMap;
 
 /**
  * Utility class to get access to {@link javax.jcr.Session} instances.
@@ -188,9 +187,4 @@
     public Credentials getSuperuserCredentials() {
         return repoStub.getSuperuserCredentials();
     }
-    
-    public RetentionPolicy getRetentionPolicy(Session session) throws NotExecutableException,
RepositoryException {
-        return repoStub.getRetentionPolicy(session);
-    }
-    
 }

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/RepositoryStub.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/RepositoryStub.java?rev=771344&r1=771343&r2=771344&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/RepositoryStub.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/RepositoryStub.java
Mon May  4 16:05:30 2009
@@ -118,7 +118,7 @@
      */
     public static final String PROP_HOLD_NAME = "holdname";
     
-    public static final String RETENTION_POLICY_NAME = "retentionPolicyName";
+    public static final String RETENTION_POLICY_HOLDER = "retentionpolicyholder";
 
     /**
      * @since JCR 2.0
@@ -301,10 +301,4 @@
     public String getProperty(String name) {
         return environment.getProperty(name);
     }
-    
-    /**
-     * Return a retention policy for testing.
-     * @return retention policy
-     */
-    public abstract RetentionPolicy getRetentionPolicy(Session session) throws NotExecutableException,
RepositoryException;
 }

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/retention/AbstractRetentionTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/retention/AbstractRetentionTest.java?rev=771344&r1=771343&r2=771344&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/retention/AbstractRetentionTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/retention/AbstractRetentionTest.java
Mon May  4 16:05:30 2009
@@ -53,7 +53,7 @@
     }
 
     protected RetentionPolicy getApplicableRetentionPolicy() throws NotExecutableException,
RepositoryException {
-        return helper.getRetentionPolicy(superuser);
+        return superuser.getRetentionManager().getRetentionPolicy(getProperty(RepositoryStub.RETENTION_POLICY_HOLDER));
     }
 
     protected static RetentionManager getRetentionManager(Session s) throws RepositoryException,
NotExecutableException {



Mime
View raw message