You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2005/08/05 14:17:21 UTC

svn commit: r230451 - in /lenya/trunk/src/java/org/apache/lenya/cms: jcr/JCRSourceNode.java publication/DefaultDocument.java repository/Node.java repository/SourceNode.java

Author: andreas
Date: Fri Aug  5 05:17:15 2005
New Revision: 230451

URL: http://svn.apache.org/viewcvs?rev=230451&view=rev
Log:
The repository node is now MetaDataOwner, which allows to provide custom MetaDataManagers at the repository layer.

Modified:
    lenya/trunk/src/java/org/apache/lenya/cms/jcr/JCRSourceNode.java
    lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocument.java
    lenya/trunk/src/java/org/apache/lenya/cms/repository/Node.java
    lenya/trunk/src/java/org/apache/lenya/cms/repository/SourceNode.java

Modified: lenya/trunk/src/java/org/apache/lenya/cms/jcr/JCRSourceNode.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/jcr/JCRSourceNode.java?rev=230451&r1=230450&r2=230451&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/jcr/JCRSourceNode.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/jcr/JCRSourceNode.java Fri Aug  5 05:17:15 2005
@@ -18,6 +18,9 @@
 
 import org.apache.avalon.framework.logger.Logger;
 import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.lenya.cms.jcr.metadata.JCRMetaDataManager;
+import org.apache.lenya.cms.metadata.MetaDataManager;
+import org.apache.lenya.cms.publication.DocumentException;
 import org.apache.lenya.cms.repository.SourceNode;
 import org.apache.lenya.transaction.IdentityMap;
 
@@ -46,6 +49,15 @@
     protected String getRealSourceURI() {
         String path = this.sourceUri.substring(LENYA_PROTOCOL.length());
         return "jcr://" + path;
+    }
+    
+    private MetaDataManager metaDataManager;
+
+    public MetaDataManager getMetaDataManager() throws DocumentException {
+        if (this.metaDataManager == null) {
+            this.metaDataManager = new JCRMetaDataManager(getRealSourceURI(), this.manager, getLogger());
+        }
+        return this.metaDataManager;
     }
 
 }

Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocument.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocument.java?rev=230451&r1=230450&r2=230451&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocument.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocument.java Fri Aug  5 05:17:15 2005
@@ -30,13 +30,10 @@
 import org.apache.excalibur.source.SourceResolver;
 import org.apache.lenya.cms.cocoon.source.RepositorySource;
 import org.apache.lenya.cms.cocoon.source.SourceUtil;
-import org.apache.lenya.cms.jcr.JCRSourceNode;
-import org.apache.lenya.cms.jcr.metadata.JCRMetaDataManager;
 import org.apache.lenya.cms.metadata.LenyaMetaData;
 import org.apache.lenya.cms.metadata.MetaDataManager;
 import org.apache.lenya.cms.publication.util.DocumentVisitor;
 import org.apache.lenya.cms.repository.Node;
-import org.apache.lenya.cms.repository.SourceNode;
 import org.apache.lenya.cms.site.SiteManager;
 
 /**
@@ -386,19 +383,10 @@
             try {
                 resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
                 source = (RepositorySource) resolver.resolveURI(getSourceURI());
-                Node node = source.getNode();
-                if (node instanceof JCRSourceNode) {
-                    String path = getSourceURI().substring(SourceNode.LENYA_PROTOCOL.length());
-                    String jcrUri = "jcr://" + path;
-                    this.metaDataManager = new JCRMetaDataManager(jcrUri, this.manager, getLogger());
-                }
-                else {
-                    this.metaDataManager = new MetaDataManager(getMetaSourceURI(), this.manager, getLogger());
-                }
+                this.metaDataManager = source.getNode().getMetaDataManager();
             } catch (Exception e) {
                 throw new RuntimeException(e);
-            }
-            finally {
+            } finally {
                 if (resolver != null) {
                     if (source != null) {
                         resolver.release(source);
@@ -432,8 +420,8 @@
     }
 
     /**
-     * When source URI has not been set by whoever created the document,
-     * provides a default mechanism for constructing the document's URI.
+     * When source URI has not been set by whoever created the document, provides a default
+     * mechanism for constructing the document's URI.
      * @return A URI.
      */
     private String getDefaultSourceURI() {

Modified: lenya/trunk/src/java/org/apache/lenya/cms/repository/Node.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/repository/Node.java?rev=230451&r1=230450&r2=230451&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/repository/Node.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/repository/Node.java Fri Aug  5 05:17:15 2005
@@ -20,6 +20,7 @@
 import java.io.OutputStream;
 import java.util.Collection;
 
+import org.apache.lenya.cms.metadata.MetaDataOwner;
 import org.apache.lenya.transaction.TransactionException;
 import org.apache.lenya.transaction.Transactionable;
 
@@ -28,7 +29,7 @@
  * 
  * @version $Id$
  */
-public interface Node extends Transactionable {
+public interface Node extends Transactionable, MetaDataOwner {
 
     /**
      * The protocol with which to find Lenya nodes

Modified: lenya/trunk/src/java/org/apache/lenya/cms/repository/SourceNode.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/repository/SourceNode.java?rev=230451&r1=230450&r2=230451&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/repository/SourceNode.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/repository/SourceNode.java Fri Aug  5 05:17:15 2005
@@ -35,6 +35,8 @@
 import org.apache.lenya.ac.Identity;
 import org.apache.lenya.ac.User;
 import org.apache.lenya.cms.cocoon.source.SourceUtil;
+import org.apache.lenya.cms.metadata.MetaDataManager;
+import org.apache.lenya.cms.publication.DocumentException;
 import org.apache.lenya.cms.publication.Publication;
 import org.apache.lenya.cms.publication.PublicationFactory;
 import org.apache.lenya.cms.rc.RCEnvironment;
@@ -52,7 +54,7 @@
 public class SourceNode extends AbstractLogEnabled implements Node {
 
     private String sourceURI;
-    private ServiceManager manager;
+    protected ServiceManager manager;
     private IdentityMap identityMap;
 
     /**
@@ -82,7 +84,8 @@
     }
 
     /**
-     * TODO: Replace by JCR of whatever
+     * Returns the URI of the actual source which is used.
+     * @return A string.
      */
     protected String getRealSourceURI() {
         return "context://" + this.sourceURI.substring(Node.LENYA_PROTOCOL.length());
@@ -125,7 +128,7 @@
     public boolean isCheckedOutByUser() throws TransactionException {
         try {
             RCMLEntry entry = getRevisionController().getRCML(getRCPath()).getLatestEntry();
-            if(entry.getIdentity().equals(getUserId())) 
+            if (entry.getIdentity().equals(getUserId()))
                 return true;
             else
                 return false;
@@ -134,8 +137,8 @@
         } catch (Exception e) {
             throw new TransactionException(e);
         }
-    }    
-    
+    }
+
     /**
      * @see org.apache.lenya.transaction.Transactionable#checkout()
      */
@@ -197,8 +200,8 @@
                     contextSource = resolver.resolveURI("context://");
                     File context = org.apache.excalibur.source.SourceUtil.getFile(contextSource);
                     PublicationFactory factory = PublicationFactory.getInstance(getLogger());
-                    Publication pub = factory.getPublication(publicationId, context
-                            .getAbsolutePath());
+                    Publication pub = factory.getPublication(publicationId,
+                            context.getAbsolutePath());
 
                     String publicationPath = pub.getDirectory().getCanonicalPath();
                     RCEnvironment rcEnvironment = RCEnvironment.getInstance(pub.getServletContext()
@@ -208,7 +211,8 @@
                     String backupDirectory = publicationPath + File.separator
                             + rcEnvironment.getBackupDirectory();
                     this.revisionController = new RevisionController(rcmlDirectory,
-                            backupDirectory, publicationPath);
+                            backupDirectory,
+                            publicationPath);
                 } finally {
                     if (resolver != null) {
                         if (contextSource != null) {
@@ -310,7 +314,7 @@
      */
     public void lock() throws TransactionException {
         if (isCheckedOut() && !isCheckedOutByUser()) {
-    	    throw new TransactionException("Cannot lock [" + this + "]: node is checked out.");
+            throw new TransactionException("Cannot lock [" + this + "]: node is checked out.");
         }
         if (getLogger().isDebugEnabled()) {
             getLogger().debug("Locking [" + this + "]");
@@ -382,7 +386,7 @@
     }
 
     /**
-     *
+     * 
      */
     public Collection getChildren() throws TransactionException {
         SourceResolver resolver = null;
@@ -395,7 +399,10 @@
             java.util.Vector newChildren = new java.util.Vector();
             while (iterator.hasNext()) {
                 TraversableSource child = (TraversableSource) iterator.next();
-                newChildren.add(new SourceNode(identityMap, sourceURI + "/" + child.getName(), this.manager, getLogger()));
+                newChildren.add(new SourceNode(identityMap,
+                        sourceURI + "/" + child.getName(),
+                        this.manager,
+                        getLogger()));
             }
             return newChildren;
         } catch (Exception e) {
@@ -404,7 +411,7 @@
     }
 
     /**
-     *
+     * 
      */
     public boolean isCollection() throws TransactionException {
         SourceResolver resolver = null;
@@ -578,5 +585,22 @@
         return sourceURI;
     }
 
+    protected String getMetaSourceURI() {
+        return getSourceURI() + ".meta";
+    }
+
+    private MetaDataManager metaDataManager;
+
+    /**
+     * @see org.apache.lenya.cms.metadata.MetaDataOwner#getMetaDataManager()
+     */
+    public MetaDataManager getMetaDataManager() throws DocumentException {
+        if (this.metaDataManager == null) {
+            this.metaDataManager = new MetaDataManager(getMetaSourceURI(),
+                    this.manager,
+                    getLogger());
+        }
+        return this.metaDataManager;
+    }
 
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org