Return-Path: Delivered-To: apmail-jackrabbit-commits-archive@www.apache.org Received: (qmail 75483 invoked from network); 10 Mar 2009 14:07:03 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 10 Mar 2009 14:07:03 -0000 Received: (qmail 19939 invoked by uid 500); 10 Mar 2009 14:07:02 -0000 Delivered-To: apmail-jackrabbit-commits-archive@jackrabbit.apache.org Received: (qmail 19914 invoked by uid 500); 10 Mar 2009 14:07:02 -0000 Mailing-List: contact commits-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jackrabbit.apache.org Delivered-To: mailing list commits@jackrabbit.apache.org Received: (qmail 19905 invoked by uid 99); 10 Mar 2009 14:07:02 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 10 Mar 2009 07:07:02 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 10 Mar 2009 14:06:55 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 8435F2388886; Tue, 10 Mar 2009 14:06:35 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@jackrabbit.apache.org From: angela@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090310140635.8435F2388886@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 RetentionPolicy 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 RetentionPolicy that can be applied to a + * Node 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 Session from which the retention + * manager will be obtained. + * @return a new RetentionPolicy + * @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