jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r752115 - in /jackrabbit/trunk/jackrabbit-core/src: main/java/org/apache/jackrabbit/core/retention/RetentionPolicyImpl.java test/java/org/apache/jackrabbit/api/jsr283/retention/AbstractRetentionTest.java
Date Tue, 10 Mar 2009 14:06:34 GMT
Author: angela
Date: Tue Mar 10 14:06:33 2009
New Revision: 752115

URL: http://svn.apache.org/viewvc?rev=752115&view=rev
Log:
JCR-1589: JSR 283 Retention & Hold Management

- replace public constructor by static create
- replace spi-commons dependency from create method by usage of Session

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/retention/RetentionPolicyImpl.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/retention/AbstractRetentionTest.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/retention/RetentionPolicyImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/retention/RetentionPolicyImpl.java?rev=752115&r1=752114&r2=752115&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/retention/RetentionPolicyImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/retention/RetentionPolicyImpl.java
Tue Mar 10 14:06:33 2009
@@ -21,9 +21,11 @@
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.commons.conversion.NameResolver;
 import org.apache.jackrabbit.spi.commons.conversion.IllegalNameException;
+import org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver;
 
 import javax.jcr.RepositoryException;
 import javax.jcr.NamespaceException;
+import javax.jcr.Session;
 
 /**
  * Basic implementation of the <code>RetentionPolicy</code> interface.
@@ -35,9 +37,26 @@
     private final NameResolver resolver;
 
     private int hashCode = 0;
-    
-    public RetentionPolicyImpl(String jcrName, NameResolver resolver) throws IllegalNameException,
NamespaceException {
-        this(resolver.getQName(jcrName), null, resolver);
+
+    /**
+     * Creates a new <code>RetentionPolicy</code> that can be applied to a
+     * <code>Node</code> using {@link org.apache.jackrabbit.api.jsr283.retention.RetentionManager#setRetentionPolicy(String,
org.apache.jackrabbit.api.jsr283.retention.RetentionPolicy)}.
+     *
+     * @param jcrName The name of the policy. It must be a valid JCR name.
+     * @param session The editing <code>Session</code> from which the retention
+     * manager will be obtained.
+     * @return a new <code>RetentionPolicy</code>
+     * @throws RepositoryException If the jcr name isn't valid or if same other
+     * error occurs.
+     */
+    public static RetentionPolicy createRetentionPolicy(String jcrName, Session session)
throws RepositoryException {
+        NameResolver resolver;
+        if (session instanceof NameResolver) {
+            resolver = (NameResolver) session;
+        } else {
+            resolver = new DefaultNamePathResolver(session);
+        }
+        return new RetentionPolicyImpl(jcrName, null, resolver);
     }
 
     RetentionPolicyImpl(String jcrName, NodeId nodeId, NameResolver resolver) throws IllegalNameException,
NamespaceException {
@@ -53,7 +72,7 @@
     NodeId getNodeId() {
         return nodeId;
     }
-    
+
     //----------------------------------------------------< RetentionPolicy >---
     /**
      * @see org.apache.jackrabbit.api.jsr283.retention.RetentionPolicy#getName()

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/retention/AbstractRetentionTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/retention/AbstractRetentionTest.java?rev=752115&r1=752114&r2=752115&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/retention/AbstractRetentionTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/retention/AbstractRetentionTest.java
Tue Mar 10 14:06:33 2009
@@ -58,7 +58,7 @@
 
     protected RetentionPolicy getApplicableRetentionPolicy(String jcrName) throws NotExecutableException,
RepositoryException {
         // TODO: move to repositoryStub/helper and adjust accordingly
-        return new RetentionPolicyImpl(jcrName, (SessionImpl)superuser);
+        return RetentionPolicyImpl.createRetentionPolicy(jcrName, superuser);
     }
 
     protected static RetentionManager getRetentionManager(Session s) throws RepositoryException,
NotExecutableException {
@@ -83,4 +83,4 @@
             throw new NotExecutableException();
         }
     }
-}
+}
\ No newline at end of file



Mime
View raw message