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/11/04 12:06:59 UTC

svn commit: r330793 - in /lenya/trunk: ./ lib/ src/cocoon/ src/java/org/apache/lenya/cms/migration/ src/modules/jackrabbit/ src/modules/jackrabbit/java/ src/modules/jackrabbit/java/src/ src/modules/jackrabbit/java/src/org/ src/modules/jackrabbit/java/s...

Author: andreas
Date: Fri Nov  4 03:06:13 2005
New Revision: 330793

URL: http://svn.apache.org/viewcvs?rev=330793&view=rev
Log:
First steps re. JCR-only approach: removed dependencies on JCR block, added own JCR libs, started JCR facade objects and content migration build target.

Added:
    lenya/trunk/lib/jackrabbit-1.0-LCR330244.jar   (with props)
    lenya/trunk/lib/jackrabbit-commons-1.0-LCR330244.jar   (with props)
    lenya/trunk/lib/jcr-1.0.jar   (with props)
    lenya/trunk/src/java/org/apache/lenya/cms/migration/
    lenya/trunk/src/java/org/apache/lenya/cms/migration/Migrate14.java
    lenya/trunk/src/modules/jackrabbit/
    lenya/trunk/src/modules/jackrabbit/java/
    lenya/trunk/src/modules/jackrabbit/java/src/
    lenya/trunk/src/modules/jackrabbit/java/src/org/
    lenya/trunk/src/modules/jackrabbit/java/src/org/apache/
    lenya/trunk/src/modules/jackrabbit/java/src/org/apache/lenya/
    lenya/trunk/src/modules/jackrabbit/java/src/org/apache/lenya/cms/
    lenya/trunk/src/modules/jackrabbit/java/src/org/apache/lenya/cms/jcr/
    lenya/trunk/src/modules/jackrabbit/java/src/org/apache/lenya/cms/jcr/jackrabbit/
    lenya/trunk/src/modules/jackrabbit/java/src/org/apache/lenya/cms/jcr/jackrabbit/JackrabbitRepositoryFactory.java
    lenya/trunk/src/modules/jackrabbit/repository/
    lenya/trunk/src/modules/jackrabbit/repository/jaas.config
    lenya/trunk/src/modules/jackrabbit/repository/repository/
    lenya/trunk/src/modules/jackrabbit/repository/repository.xml
    lenya/trunk/src/modules/jackrabbit/repository/repository/nodetypes/
    lenya/trunk/src/modules/jackrabbit/repository/repository/nodetypes/custom_nodetypes.xml
    lenya/trunk/src/modules/jcr/java/src/org/apache/lenya/cms/jcr/JCRArea.java
    lenya/trunk/src/modules/jcr/java/src/org/apache/lenya/cms/jcr/JCRPublication.java
    lenya/trunk/src/modules/jcr/java/src/org/apache/lenya/cms/jcr/RepositoryFacade.java
    lenya/trunk/src/modules/jcr/java/src/org/apache/lenya/cms/jcr/RepositoryFactory.java
    lenya/trunk/src/modules/jcr/java/src/org/apache/lenya/cms/jcr/RepositorySession.java
    lenya/trunk/src/targets/migration-build.xml
Removed:
    lenya/trunk/src/modules/jcr/config/repository.xconf
    lenya/trunk/src/modules/jcr/config/sourcefactory.xconf
    lenya/trunk/src/modules/jcr/java/src/org/apache/lenya/cms/jcr/LenyaJCRSourceFactory.java
    lenya/trunk/src/modules/jcr/java/src/org/apache/lenya/cms/jcr/LenyaRepository.java
Modified:
    lenya/trunk/build.properties
    lenya/trunk/build.xml
    lenya/trunk/src/cocoon/local.blocks.properties
    lenya/trunk/src/modules/jcr/java/src/org/apache/lenya/cms/jcr/metadata/JCRMetaData.java

Modified: lenya/trunk/build.properties
URL: http://svn.apache.org/viewcvs/lenya/trunk/build.properties?rev=330793&r1=330792&r2=330793&view=diff
==============================================================================
--- lenya/trunk/build.properties (original)
+++ lenya/trunk/build.properties Fri Nov  4 03:06:13 2005
@@ -125,3 +125,7 @@
 
 xopus.context=Xopus2.1.64
 xopus.path=../../ROOT
+
+#------------------------------------------------------------------------------------
+# JCR repository factory
+repository.factory=org.apache.lenya.cms.jcr.jackrabbit.JackrabbitRepositoryFactory
\ No newline at end of file

Modified: lenya/trunk/build.xml
URL: http://svn.apache.org/viewcvs/lenya/trunk/build.xml?rev=330793&r1=330792&r2=330793&view=diff
==============================================================================
--- lenya/trunk/build.xml (original)
+++ lenya/trunk/build.xml Fri Nov  4 03:06:13 2005
@@ -67,6 +67,8 @@
   <import file="src/targets/export-build.xml" />
   <!-- module targets          -->
   <import file="src/targets/modules-build.xml" />
+  <!-- migration targets          -->
+  <import file="src/targets/migration-build.xml" />
   <!-- Publication tests       -->
   <import file="src/targets/publication-test-build.xml" />
   <!-- Successfully Built Message       -->

Added: lenya/trunk/lib/jackrabbit-1.0-LCR330244.jar
URL: http://svn.apache.org/viewcvs/lenya/trunk/lib/jackrabbit-1.0-LCR330244.jar?rev=330793&view=auto
==============================================================================
Binary file - no diff available.

Propchange: lenya/trunk/lib/jackrabbit-1.0-LCR330244.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: lenya/trunk/lib/jackrabbit-commons-1.0-LCR330244.jar
URL: http://svn.apache.org/viewcvs/lenya/trunk/lib/jackrabbit-commons-1.0-LCR330244.jar?rev=330793&view=auto
==============================================================================
Binary file - no diff available.

Propchange: lenya/trunk/lib/jackrabbit-commons-1.0-LCR330244.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: lenya/trunk/lib/jcr-1.0.jar
URL: http://svn.apache.org/viewcvs/lenya/trunk/lib/jcr-1.0.jar?rev=330793&view=auto
==============================================================================
Binary file - no diff available.

Propchange: lenya/trunk/lib/jcr-1.0.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: lenya/trunk/src/cocoon/local.blocks.properties
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/cocoon/local.blocks.properties?rev=330793&r1=330792&r2=330793&view=diff
==============================================================================
--- lenya/trunk/src/cocoon/local.blocks.properties (original)
+++ lenya/trunk/src/cocoon/local.blocks.properties Fri Nov  4 03:06:13 2005
@@ -155,7 +155,7 @@
 #include.block.forms=false
 #-----[dependency]: "javaflow" depends on "forms", "ojb".
 include.block.javaflow=false
-include.block.jcr=true
+include.block.jcr=false
 #-----[dependency]: "jms" depends on "cron", "databases" (for samples), "hsqldb".
 #-----[dependency]: "jms" is needed by "eventcache", "slide".
 include.block.jms=false

Added: lenya/trunk/src/java/org/apache/lenya/cms/migration/Migrate14.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/migration/Migrate14.java?rev=330793&view=auto
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/migration/Migrate14.java (added)
+++ lenya/trunk/src/java/org/apache/lenya/cms/migration/Migrate14.java Fri Nov  4 03:06:13 2005
@@ -0,0 +1,177 @@
+/*
+ * Copyright  1999-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.lenya.cms.migration;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.util.Arrays;
+
+import javax.jcr.NamespaceRegistry;
+import javax.jcr.Node;
+import javax.jcr.PathNotFoundException;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.SimpleCredentials;
+import javax.jcr.query.Query;
+import javax.jcr.query.QueryResult;
+
+import org.apache.jackrabbit.core.security.SimpleLoginModule;
+import org.apache.lenya.cms.jcr.JCRArea;
+import org.apache.lenya.cms.jcr.JCRPublication;
+import org.apache.lenya.cms.jcr.RepositoryFacade;
+import org.apache.lenya.cms.jcr.RepositoryFactory;
+import org.apache.lenya.cms.jcr.RepositorySession;
+import org.apache.lenya.cms.publication.Publication;
+import org.apache.lenya.cms.publication.PublicationImpl;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+
+/**
+ * Migrate Lenya 1.4-dev content.
+ */
+public class Migrate14 {
+
+    public static void main(String[] args) {
+
+        if (args.length != 2) {
+            System.out.println("Usage: Migrate14 <webapp-directory> <repository-factory-class>");
+        }
+
+        Migrate14 migrate = new Migrate14();
+        migrate.setWebappDirectory(args[0]);
+        migrate.setRepositoryFactory(args[1]);
+        migrate.execute();
+    }
+
+    private String webappDirectory;
+    private String repositoryFactory;
+
+    /**
+     * @param webappDirectory The web application directory.
+     */
+    public void setWebappDirectory(String webappDirectory) {
+        this.webappDirectory = webappDirectory;
+    }
+
+    /**
+     * @return The web application directory.
+     */
+    public String getWebappDirectory() {
+        return this.webappDirectory;
+    }
+
+    /**
+     * @return The repository factory classname.
+     */
+    public String getRepositoryFactory() {
+        return repositoryFactory;
+    }
+
+    /**
+     * @param repositoryFactory The repository factory classname.
+     */
+    public void setRepositoryFactory(String repositoryFactory) {
+        this.repositoryFactory = repositoryFactory;
+    }
+
+    private RepositoryFacade repo;
+    private RepositorySession session;
+    private Node contentNode;
+
+    protected RepositoryFacade getRepository() {
+        return this.repo;
+    }
+
+    protected RepositorySession getSession() {
+        return this.session;
+    }
+
+    public void execute() throws BuildException {
+
+        try {
+            this.repo = new RepositoryFacade(getWebappDirectory(), getRepositoryFactory());
+            this.session = this.repo.createSession();
+
+            File publicationsDirectory = new File(webappDirectory, Publication.PUBLICATION_PREFIX);
+            File[] pubDirs = publicationsDirectory.listFiles(new FileFilter() {
+                public boolean accept(File file) {
+                    return file.isDirectory()
+                            && new File(file, PublicationImpl.CONFIGURATION_FILE).exists();
+                }
+            });
+
+            for (int i = 0; i < pubDirs.length; i++) {
+                importPublication(pubDirs[i]);
+            }
+
+        } catch (Exception e) {
+            e.printStackTrace(System.err);
+            if (e.getCause() != null) {
+                e.getCause().printStackTrace(System.err);
+            }
+            throw new BuildException(e);
+        }
+
+    }
+
+    protected static final FileFilter directoryFilter = new FileFilter() {
+        public boolean accept(File file) {
+            return file.isDirectory();
+        }
+    };
+
+    protected void importPublication(File pubDir) throws RepositoryException {
+        String pubId = pubDir.getName();
+        JCRPublication pub = new JCRPublication(getSession(), pubId);
+
+        File contentDir = new File(pubDir, "content");
+        File[] areaDirs = contentDir.listFiles(directoryFilter);
+        for (int i = 0; i < areaDirs.length; i++) {
+            importContent(areaDirs[i], pub);
+        }
+    }
+
+    protected void importContent(File contentDir, JCRPublication pub) throws RepositoryException {
+        String area = contentDir.getName();
+        JCRArea jcrArea = pub.getArea(area);
+        
+        System.out.println("pub node:  " + jcrArea.getPublicationNode().getPath());
+        System.out.println("site node: " + jcrArea.getSiteNode().getPath());
+        
+        importChildren(contentDir, jcrArea.getSiteNode());
+    }
+
+    protected void importDocument(File docDir, Node parent)
+            throws RepositoryException {
+        String nodeId = docDir.getName();
+        String documentId = parent.getPath() + "/" + nodeId;
+        System.out.println("Importing [" + documentId + "]");
+
+        Node node = parent.addNode(nodeId);
+
+        importChildren(docDir, node);
+    }
+
+    protected void importChildren(File docDir, Node parent)
+            throws RepositoryException {
+        File[] childDirs = docDir.listFiles(directoryFilter);
+        for (int i = 0; i < childDirs.length; i++) {
+            importDocument(childDirs[i], parent);
+        }
+    }
+}

Added: lenya/trunk/src/modules/jackrabbit/java/src/org/apache/lenya/cms/jcr/jackrabbit/JackrabbitRepositoryFactory.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/modules/jackrabbit/java/src/org/apache/lenya/cms/jcr/jackrabbit/JackrabbitRepositoryFactory.java?rev=330793&view=auto
==============================================================================
--- lenya/trunk/src/modules/jackrabbit/java/src/org/apache/lenya/cms/jcr/jackrabbit/JackrabbitRepositoryFactory.java (added)
+++ lenya/trunk/src/modules/jackrabbit/java/src/org/apache/lenya/cms/jcr/jackrabbit/JackrabbitRepositoryFactory.java Fri Nov  4 03:06:13 2005
@@ -0,0 +1,48 @@
+/*
+ * Copyright  1999-2005 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.lenya.cms.jcr.jackrabbit;
+
+import java.io.File;
+
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+
+import org.apache.jackrabbit.core.RepositoryImpl;
+import org.apache.jackrabbit.core.config.RepositoryConfig;
+import org.apache.lenya.cms.jcr.RepositoryFactory;
+
+/**
+ * Jackrabbit-based repository factory.
+ */
+public class JackrabbitRepositoryFactory implements RepositoryFactory {
+
+    protected static final String homePath = "lenya/modules/jackrabbit/repository".replace('/',
+            File.separatorChar);
+    protected static final String configFilePath = "repository.xml";
+
+    public Repository getRepository(String webappPath) throws RepositoryException {
+        File webappDirectory = new File(webappPath);
+        File repoDirectory = new File(webappDirectory, homePath);
+        File configFile = new File(repoDirectory, configFilePath);
+        RepositoryConfig repoConfig = RepositoryConfig.create(configFile.getAbsolutePath(),
+                repoDirectory.getAbsolutePath());
+        Repository repo = RepositoryImpl.create(repoConfig);
+        
+        return repo;
+    }
+
+}

Added: lenya/trunk/src/modules/jackrabbit/repository/jaas.config
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/modules/jackrabbit/repository/jaas.config?rev=330793&view=auto
==============================================================================
--- lenya/trunk/src/modules/jackrabbit/repository/jaas.config (added)
+++ lenya/trunk/src/modules/jackrabbit/repository/jaas.config Fri Nov  4 03:06:13 2005
@@ -0,0 +1,3 @@
+Jackrabbit {
+   org.apache.jackrabbit.core.security.SimpleLoginModule required anonymousId="michi";
+};

Added: lenya/trunk/src/modules/jackrabbit/repository/repository.xml
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/modules/jackrabbit/repository/repository.xml?rev=330793&view=auto
==============================================================================
--- lenya/trunk/src/modules/jackrabbit/repository/repository.xml (added)
+++ lenya/trunk/src/modules/jackrabbit/repository/repository.xml Fri Nov  4 03:06:13 2005
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<Repository>
+  <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+    <param name="path" value="${rep.home}/repository"/>
+  </FileSystem>
+  <Security appName="Jackrabbit">
+    <AccessManager class="org.apache.jackrabbit.core.security.SimpleAccessManager"/>
+  </Security>
+  <Workspaces rootPath="${rep.home}/workspaces" defaultWorkspace="default"/>
+  <Workspace name="${wsp.name}">
+    <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+      <param name="path" value="${wsp.home}"/>
+    </FileSystem>
+    <PersistenceManager class="org.apache.jackrabbit.core.state.xml.XMLPersistenceManager"/>
+    <SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
+      <param name="path" value="${wsp.home}/index"/>
+    </SearchIndex>
+  </Workspace>
+  <Versioning rootPath="${rep.home}/versions">
+    <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+      <param name="path" value="${rep.home}/versions"/>
+    </FileSystem>
+    <PersistenceManager class="org.apache.jackrabbit.core.state.xml.XMLPersistenceManager"/>
+  </Versioning>
+</Repository>

Added: lenya/trunk/src/modules/jackrabbit/repository/repository/nodetypes/custom_nodetypes.xml
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/modules/jackrabbit/repository/repository/nodetypes/custom_nodetypes.xml?rev=330793&view=auto
==============================================================================
--- lenya/trunk/src/modules/jackrabbit/repository/repository/nodetypes/custom_nodetypes.xml (added)
+++ lenya/trunk/src/modules/jackrabbit/repository/repository/nodetypes/custom_nodetypes.xml Fri Nov  4 03:06:13 2005
@@ -0,0 +1,175 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  /*
+  * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+  *                     as applicable.
+  *
+  * Licensed under the Apache License, Version 2.0 (the "License");
+  * you may not use this file except in compliance with the License.
+  * You may obtain a copy of the License at
+  *
+  *      http://www.apache.org/licenses/LICENSE-2.0
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+-->
+<nodeTypes xmlns:nt="http://www.jcp.org/jcr/nt/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
+  xmlns:rep="internal" xmlns:sv="http://www.jcp.org/jcr/sv/1.0"
+  xmlns:lnt="http://apache.org/cocoon/lenya/jcr/nodetype/1.0"
+  xmlns:lenya="http://apache.org/cocoon/lenya/jcr/1.0"
+  xmlns:mix="http://www.jcp.org/jcr/mix/1.0"
+  xmlns:xml="http://www.w3.org/XML/1998/namespace"
+  xmlns:dc="http://purl.org/dc/elements/1.1"
+  xmlns:dcterms="http://purl.org/dc/terms/">
+
+  <!--
+  General
+  -->  
+  <nodeType name="jcr:content" isMixin="false" hasOrderableChildNodes="false" primaryItemName="">
+    <supertypes>
+      <supertype>nt:resource</supertype>
+    </supertypes>
+  </nodeType>
+
+  <!--
+  Publication root node
+  -->  
+  <nodeType name="lnt:publication" isMixin="false" hasOrderableChildNodes="false" primaryItemName="">
+    <supertypes>
+      <supertype>nt:hierarchyNode</supertype>
+      <supertype>mix:referenceable</supertype>
+    </supertypes>
+    <propertyDef name="lenya:id" autoCreate="false" mandatory="true" onParentVersion="ABORT" protected="false"
+      multiple="false" requiredType="String"/>
+    <childNodeDef name="lenya:content" defaultPrimaryType="lnt:content" autoCreate="false" mandatory="false"
+      onParentVersion="ABORT" protected="false" sameNameSibs="false">
+      <requiredPrimaryTypes>
+        <requiredPrimaryType>lnt:content</requiredPrimaryType>
+      </requiredPrimaryTypes>
+    </childNodeDef>
+    <childNodeDef name="lenya:site" defaultPrimaryType="lnt:site" autoCreate="false" mandatory="false"
+      onParentVersion="ABORT" protected="false" sameNameSibs="false">
+      <requiredPrimaryTypes>
+        <requiredPrimaryType>lnt:site</requiredPrimaryType>
+      </requiredPrimaryTypes>
+    </childNodeDef>
+  </nodeType>
+  
+  <!--
+    Root node for content subtree
+  -->
+  <nodeType name="lnt:content" isMixin="false" hasOrderableChildNodes="true" primaryItemName="">
+    <supertypes>
+      <supertype>nt:hierarchyNode</supertype>
+      <supertype>mix:referenceable</supertype>
+      <supertype>mix:lockable</supertype>
+    </supertypes>
+    <childNodeDef name="lenya:node" defaultPrimaryType="lnt:node" autoCreate="false" mandatory="false"
+      onParentVersion="ABORT" protected="false" sameNameSibs="true">
+      <requiredPrimaryTypes>
+        <requiredPrimaryType>lnt:node</requiredPrimaryType>
+      </requiredPrimaryTypes>
+    </childNodeDef>
+  </nodeType>
+  
+  
+  <!-- node in content subtree -->
+  <nodeType name="lnt:node" isMixin="false" hasOrderableChildNodes="true" primaryItemName="">
+    <supertypes>
+      <supertype>nt:hierarchyNode</supertype>
+      <supertype>mix:referenceable</supertype>
+      <supertype>mix:lockable</supertype>
+    </supertypes>
+    <propertyDef name="*" requiredType="String" autoCreate="false" mandatory="false"
+      onParentVersion="ABORT" protected="false" multiple="false"/>
+    <propertyDef name="lenya:visibleinnav" requiredType="Boolean" autoCreate="false" mandatory="true"
+      onParentVersion="ABORT" protected="false" multiple="false"/>
+    <propertyDef name="lenya:href" requiredType="String" autoCreate="false" mandatory="false"
+      onParentVersion="ABORT" protected="false" multiple="false"/>
+    <propertyDef name="lenya:suffix" requiredType="String" autoCreate="false" mandatory="false"
+      onParentVersion="ABORT" protected="false" multiple="false"/>
+    <childNodeDef name="lenya:document" defaultPrimaryType="lnt:document" autoCreate="false"
+      mandatory="false" onParentVersion="ABORT" protected="false" sameNameSibs="true">
+      <requiredPrimaryTypes>
+        <requiredPrimaryType>lnt:document</requiredPrimaryType>
+      </requiredPrimaryTypes>
+    </childNodeDef>
+  </nodeType>
+  
+  <!--
+  document node in content subtree
+  -->
+  <nodeType name="lnt:document" isMixin="false" hasOrderableChildNodes="false" primaryItemName="jcr:content">
+    <supertypes>
+      <supertype>nt:file</supertype>
+      <supertype>mix:versionable</supertype>
+      <supertype>mix:lockable</supertype>
+    </supertypes>
+    <propertyDef name="xml:lang" requiredType="String" autoCreate="false" mandatory="true"
+      onParentVersion="COPY" protected="false" multiple="false"/>
+    <propertyDef name="lenya:label" requiredType="String" autoCreate="false" mandatory="true"
+      onParentVersion="COPY" protected="false" multiple="false"/>
+    <childNodeDef name="lenya:meta" defaultPrimaryType="lnt:meta" autoCreate="true" mandatory="true"
+      onParentVersion="COPY" protected="false" sameNameSibs="true">
+      <requiredPrimaryTypes>
+        <requiredPrimaryType>lnt:meta</requiredPrimaryType>
+      </requiredPrimaryTypes>
+    </childNodeDef>
+  </nodeType>
+  
+  <!--
+  meta data
+  -->
+  <nodeType name="lnt:meta" isMixin="false" hasOrderableChildNodes="false" primaryItemName="">
+    <supertypes>
+      <supertype>nt:unstructured</supertype>
+      <!--
+      <supertype>lps:dc</supertype>
+      <supertype>lps:dcterms</supertype>
+      -->
+    </supertypes>
+    <propertyDef name="lenya:namespace" requiredType="String" autoCreate="false" mandatory="true"
+      onParentVersion="ABORT" multiple="false" protected="false"/>
+  </nodeType>
+  
+  <!--
+  Root node for site subtree
+  -->
+  <nodeType name="lnt:site" isMixin="false" hasOrderableChildNodes="true" primaryItemName="">
+    <supertypes>
+      <supertype>nt:hierarchyNode</supertype>
+      <supertype>mix:referenceable</supertype>
+      <supertype>mix:lockable</supertype>
+    </supertypes>
+    <childNodeDef name="*" defaultPrimaryType="lnt:item" autoCreate="false" mandatory="false"
+      onParentVersion="ABORT" protected="false" sameNameSibs="false">
+      <requiredPrimaryTypes>
+        <requiredPrimaryType>lnt:item</requiredPrimaryType>
+      </requiredPrimaryTypes>
+    </childNodeDef>
+  </nodeType>
+  
+  <!--
+  Site structure item
+  -->
+  <nodeType name="lnt:item" isMixin="false" hasOrderableChildNodes="true" primaryItemName="">
+    <supertypes>
+      <supertype>nt:hierarchyNode</supertype>
+      <supertype>mix:referenceable</supertype>
+      <supertype>mix:lockable</supertype>
+    </supertypes>
+    <propertyDef name="lenya:node" mandatory="false" autoCreate="false" multiple="false" onParentVersion="ABORT"
+      protected="false" requiredType="Reference"/>
+    <childNodeDef name="*" defaultPrimaryType="lnt:item" autoCreate="false" mandatory="false"
+      onParentVersion="ABORT" protected="false" sameNameSibs="false">
+      <requiredPrimaryTypes>
+        <requiredPrimaryType>lnt:item</requiredPrimaryType>
+      </requiredPrimaryTypes>
+    </childNodeDef>
+  </nodeType>
+  
+</nodeTypes>

Added: lenya/trunk/src/modules/jcr/java/src/org/apache/lenya/cms/jcr/JCRArea.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/modules/jcr/java/src/org/apache/lenya/cms/jcr/JCRArea.java?rev=330793&view=auto
==============================================================================
--- lenya/trunk/src/modules/jcr/java/src/org/apache/lenya/cms/jcr/JCRArea.java (added)
+++ lenya/trunk/src/modules/jcr/java/src/org/apache/lenya/cms/jcr/JCRArea.java Fri Nov  4 03:06:13 2005
@@ -0,0 +1,87 @@
+/*
+ * Copyright  1999-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.lenya.cms.jcr;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.query.Query;
+import javax.jcr.query.QueryResult;
+
+public class JCRArea {
+
+    private String area;
+    private JCRPublication publication;
+
+    public JCRArea(JCRPublication publication, String area) {
+        this.publication = publication;
+        this.area = area;
+    }
+
+    protected JCRPublication getPublication() {
+        return this.publication;
+    }
+
+    protected String getArea() {
+        return this.area;
+    }
+
+    public Session getSession() throws RepositoryException {
+        return getPublication().getSession().getSession(getArea());
+    }
+
+    public Node getPublicationNode() throws RepositoryException {
+        Node rootNode = getSession().getRootNode();
+
+        Node pubNode = null;
+
+        for (NodeIterator pubNodes = rootNode.getNodes("lenya:publication"); pubNodes.hasNext();) {
+            Node node = pubNodes.nextNode();
+            if (node.getProperty("lenya:id")
+                    .getString()
+                    .equals(getPublication().getPublicationId())) {
+                pubNode = node;
+            }
+        }
+        if (pubNode == null) {
+            pubNode = rootNode.addNode("lenya:publication");
+            pubNode.setProperty("lenya:id", getPublication().getPublicationId());
+        }
+
+        return pubNode;
+    }
+
+    protected Node getSubNode(Node parent, String childName) throws RepositoryException {
+        Node child = null;
+        if (parent.hasNode(childName)) {
+            child = parent.getNode(childName);
+        } else {
+            child = parent.addNode(childName);
+        }
+        return child;
+    }
+
+    public Node getContentNode() throws RepositoryException {
+        return getSubNode(getPublicationNode(), "lenya:content");
+    }
+
+    public Node getSiteNode() throws RepositoryException {
+        return getSubNode(getPublicationNode(), "lenya:site");
+    }
+
+}

Added: lenya/trunk/src/modules/jcr/java/src/org/apache/lenya/cms/jcr/JCRPublication.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/modules/jcr/java/src/org/apache/lenya/cms/jcr/JCRPublication.java?rev=330793&view=auto
==============================================================================
--- lenya/trunk/src/modules/jcr/java/src/org/apache/lenya/cms/jcr/JCRPublication.java (added)
+++ lenya/trunk/src/modules/jcr/java/src/org/apache/lenya/cms/jcr/JCRPublication.java Fri Nov  4 03:06:13 2005
@@ -0,0 +1,58 @@
+/*
+ * Copyright  1999-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.lenya.cms.jcr;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.query.Query;
+import javax.jcr.query.QueryResult;
+
+public class JCRPublication {
+
+    private String pubId;
+    private RepositorySession session;
+
+    public JCRPublication(RepositorySession session, String pubId) {
+        this.pubId = pubId;
+        this.session = session;
+    }
+
+    protected String getPublicationId() {
+        return this.pubId;
+    }
+
+    protected RepositorySession getSession() {
+        return this.session;
+    }
+    
+    private Map areas = new HashMap();
+    
+    public JCRArea getArea(String area) {
+        JCRArea jcrArea = (JCRArea) this.areas.get(area);
+        if (jcrArea == null) {
+            jcrArea = new JCRArea(this, area);
+            this.areas.put(area, jcrArea);
+        }
+        return jcrArea;
+    }
+
+}

Added: lenya/trunk/src/modules/jcr/java/src/org/apache/lenya/cms/jcr/RepositoryFacade.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/modules/jcr/java/src/org/apache/lenya/cms/jcr/RepositoryFacade.java?rev=330793&view=auto
==============================================================================
--- lenya/trunk/src/modules/jcr/java/src/org/apache/lenya/cms/jcr/RepositoryFacade.java (added)
+++ lenya/trunk/src/modules/jcr/java/src/org/apache/lenya/cms/jcr/RepositoryFacade.java Fri Nov  4 03:06:13 2005
@@ -0,0 +1,79 @@
+/*
+ * Copyright  1999-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.lenya.cms.jcr;
+
+import java.io.File;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.query.Query;
+import javax.jcr.query.QueryResult;
+
+/**
+ * Facade to the JCR repository, providing Lenya-specific access.
+ */
+public class RepositoryFacade {
+
+    public RepositoryFacade(String webappDirectoryPath, String repositoryFactoryClass)
+            throws RepositoryException {
+        try {
+            Class repoFactoryClass = Class.forName(repositoryFactoryClass);
+            RepositoryFactory repoFactory = (RepositoryFactory) repoFactoryClass.newInstance();
+
+            File webappDirectory = new File(webappDirectoryPath);
+
+            String jaasPath = "lenya/modules/jackrabbit/repository/jaas.config";
+            System.setProperty("java.security.auth.login.config", new File(webappDirectory,
+                    jaasPath).getAbsolutePath());
+
+            this.repository = repoFactory.getRepository(webappDirectoryPath);
+        } catch (RepositoryException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new RepositoryException(e);
+        }
+    }
+
+    private Repository repository;
+
+    public Repository getRepository() {
+        return this.repository;
+    }
+
+    /**
+     * @return The repository session.
+     */
+    public RepositorySession createSession() {
+        return new RepositorySession(this);
+    }
+
+    protected Node getSubNode(Session session, Node parent, String childName)
+            throws RepositoryException {
+
+        Node child = null;
+        if (parent.hasNode(childName)) {
+            child = parent.getNode(childName);
+        } else {
+            child = parent.addNode(childName);
+        }
+        return child;
+    }
+
+}

Added: lenya/trunk/src/modules/jcr/java/src/org/apache/lenya/cms/jcr/RepositoryFactory.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/modules/jcr/java/src/org/apache/lenya/cms/jcr/RepositoryFactory.java?rev=330793&view=auto
==============================================================================
--- lenya/trunk/src/modules/jcr/java/src/org/apache/lenya/cms/jcr/RepositoryFactory.java (added)
+++ lenya/trunk/src/modules/jcr/java/src/org/apache/lenya/cms/jcr/RepositoryFactory.java Fri Nov  4 03:06:13 2005
@@ -0,0 +1,34 @@
+/*
+ * Copyright  1999-2005 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.lenya.cms.jcr;
+
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+
+/**
+ * Factory for JCR repositories.
+ */
+public interface RepositoryFactory {
+
+    /**
+     * @param webappPath The absolute path to the Lenya web application.
+     * @return A repository.
+     * @throws RepositoryException if an error occurs.
+     */
+    Repository getRepository(String webappPath) throws RepositoryException;
+    
+}

Added: lenya/trunk/src/modules/jcr/java/src/org/apache/lenya/cms/jcr/RepositorySession.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/modules/jcr/java/src/org/apache/lenya/cms/jcr/RepositorySession.java?rev=330793&view=auto
==============================================================================
--- lenya/trunk/src/modules/jcr/java/src/org/apache/lenya/cms/jcr/RepositorySession.java (added)
+++ lenya/trunk/src/modules/jcr/java/src/org/apache/lenya/cms/jcr/RepositorySession.java Fri Nov  4 03:06:13 2005
@@ -0,0 +1,84 @@
+/*
+ * Copyright  1999-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.lenya.cms.jcr;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.jcr.LoginException;
+import javax.jcr.NamespaceRegistry;
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.SimpleCredentials;
+import javax.jcr.Workspace;
+import javax.jcr.query.Query;
+import javax.jcr.query.QueryResult;
+
+import org.apache.jackrabbit.core.WorkspaceImpl;
+
+/**
+ * Repository session.
+ */
+public class RepositorySession {
+
+    /**
+     * Ctor.
+     * @param repository The repository facade.
+     */
+    public RepositorySession(RepositoryFacade repository) {
+        this.repository = repository;
+    }
+
+    private RepositoryFacade repository;
+
+    protected RepositoryFacade getRepository() {
+        return this.repository;
+    }
+
+    private Map area2session = new HashMap();
+
+    public Session getSession(String area) throws RepositoryException {
+        Session session = (Session) this.area2session.get(area);
+        if (session == null) {
+
+            Session defaultWorkspaceSession = getRepository().getRepository()
+                    .login(new SimpleCredentials("john", "".toCharArray()));
+
+            WorkspaceImpl defaultWorkspace = (WorkspaceImpl) defaultWorkspaceSession.getWorkspace();
+            String[] workspaces = defaultWorkspace.getAccessibleWorkspaceNames();
+            if (!Arrays.asList(workspaces).contains(area)) {
+                defaultWorkspace.createWorkspace(area);
+            }
+
+            session = getRepository().getRepository().login(new SimpleCredentials("john",
+                    "".toCharArray()),
+                    area);
+
+            NamespaceRegistry registry = session.getWorkspace().getNamespaceRegistry();
+            String uri = "http://apache.org/cocoon/lenya/jcr/1.0";
+            if (!Arrays.asList(registry.getURIs()).contains(uri)) {
+                registry.registerNamespace("lenya", uri);
+            }
+            this.area2session.put(area, session);
+        }
+
+        return session;
+    }
+
+}

Modified: lenya/trunk/src/modules/jcr/java/src/org/apache/lenya/cms/jcr/metadata/JCRMetaData.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/modules/jcr/java/src/org/apache/lenya/cms/jcr/metadata/JCRMetaData.java?rev=330793&r1=330792&r2=330793&view=diff
==============================================================================
--- lenya/trunk/src/modules/jcr/java/src/org/apache/lenya/cms/jcr/metadata/JCRMetaData.java (original)
+++ lenya/trunk/src/modules/jcr/java/src/org/apache/lenya/cms/jcr/metadata/JCRMetaData.java Fri Nov  4 03:06:13 2005
@@ -30,7 +30,6 @@
 import org.apache.avalon.framework.logger.AbstractLogEnabled;
 import org.apache.avalon.framework.logger.Logger;
 import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.cocoon.jcr.source.JCRNodeSource;
 import org.apache.excalibur.source.SourceResolver;
 import org.apache.lenya.cms.metadata.MetaData;
 import org.apache.lenya.cms.publication.DocumentException;
@@ -64,6 +63,7 @@
 
         this.key2values = new HashMap();
         SourceResolver resolver = null;
+        /*
         JCRNodeSource source = null;
         try {
             resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
@@ -102,10 +102,12 @@
                 this.manager.release(resolver);
             }
         }
+        */
     }
 
     public void save() throws DocumentException {
         SourceResolver resolver = null;
+        /*
         JCRNodeSource source = null;
         try {
             resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
@@ -143,6 +145,7 @@
                 this.manager.release(resolver);
             }
         }
+        */
     }
 
     public String[] getValues(String key) throws DocumentException {

Added: lenya/trunk/src/targets/migration-build.xml
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/targets/migration-build.xml?rev=330793&view=auto
==============================================================================
--- lenya/trunk/src/targets/migration-build.xml (added)
+++ lenya/trunk/src/targets/migration-build.xml Fri Nov  4 03:06:13 2005
@@ -0,0 +1,44 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<!-- $Id: webapp-build.xml 240255 2005-08-26 14:59:37Z andreas $ -->
+
+<project name="lenya-migration">
+
+  <description>
+    Migration targets
+  </description>
+
+  <target name="migrate-14">
+    <path id="migration.classpath">
+      <fileset dir="${lib.dir}">
+        <include name="*.jar"/>
+      </fileset>
+      <fileset dir="${build.webapp}/WEB-INF/lib">
+        <include name="*.jar"/>
+      </fileset>
+      <pathelement path="${build.webapp}/WEB-INF/classes"/>
+    </path>
+    
+    <java fork="true" classpathref="migration.classpath" classname="org.apache.lenya.cms.migration.Migrate14">
+      <arg value="${build.webapp}"/>
+      <arg value="${repository.factory}"/>
+    </java>
+    
+  </target>
+
+</project>



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