You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by mi...@apache.org on 2005/04/14 14:54:25 UTC
svn commit: r161268 - in lenya/sandbox/jcrsitetree/src: data/repository/
data/repository/repository/ data/repository/repository/nodetypes/
data/repository/workspaces/ data/repository/workspaces/archive/
data/repository/workspaces/authoring/ data/repository/workspaces/default/
data/repository/workspaces/live/ data/repository/workspaces/trash/
java/org/apache/lenya/cms/publication/ webapp/lenya/pubs/default/config/
Author: michi
Date: Thu Apr 14 05:54:23 2005
New Revision: 161268
URL: http://svn.apache.org/viewcvs?view=rev&rev=161268
Log:
thanks to Felix Roethenbacher it's now independent of the default publication
Added:
lenya/sandbox/jcrsitetree/src/data/repository/
lenya/sandbox/jcrsitetree/src/data/repository/jaas.config
lenya/sandbox/jcrsitetree/src/data/repository/repository/
lenya/sandbox/jcrsitetree/src/data/repository/repository.xml
lenya/sandbox/jcrsitetree/src/data/repository/repository/nodetypes/
lenya/sandbox/jcrsitetree/src/data/repository/repository/nodetypes/custom_nodetypes.xml
lenya/sandbox/jcrsitetree/src/data/repository/workspaces/
lenya/sandbox/jcrsitetree/src/data/repository/workspaces/archive/
lenya/sandbox/jcrsitetree/src/data/repository/workspaces/archive/workspace.xml
lenya/sandbox/jcrsitetree/src/data/repository/workspaces/authoring/
lenya/sandbox/jcrsitetree/src/data/repository/workspaces/authoring/workspace.xml
lenya/sandbox/jcrsitetree/src/data/repository/workspaces/default/
lenya/sandbox/jcrsitetree/src/data/repository/workspaces/default/workspace.xml
lenya/sandbox/jcrsitetree/src/data/repository/workspaces/live/
lenya/sandbox/jcrsitetree/src/data/repository/workspaces/live/workspace.xml
lenya/sandbox/jcrsitetree/src/data/repository/workspaces/trash/
lenya/sandbox/jcrsitetree/src/data/repository/workspaces/trash/workspace.xml
lenya/sandbox/jcrsitetree/src/java/org/apache/lenya/cms/publication/RepositoryFactory.java
lenya/sandbox/jcrsitetree/src/java/org/apache/lenya/cms/publication/RepositoryFactoryException.java
Modified:
lenya/sandbox/jcrsitetree/src/java/org/apache/lenya/cms/publication/AbstractPublication.java
lenya/sandbox/jcrsitetree/src/java/org/apache/lenya/cms/publication/ClearRepository.java
lenya/sandbox/jcrsitetree/src/java/org/apache/lenya/cms/publication/ImportSiteTree.java
lenya/sandbox/jcrsitetree/src/java/org/apache/lenya/cms/publication/ImportSiteTree.xsl
lenya/sandbox/jcrsitetree/src/java/org/apache/lenya/cms/publication/JCRSiteTree.java
lenya/sandbox/jcrsitetree/src/java/org/apache/lenya/cms/publication/SiteTreeFactory.java
lenya/sandbox/jcrsitetree/src/java/org/apache/lenya/cms/publication/ViewRepository.java
lenya/sandbox/jcrsitetree/src/webapp/lenya/pubs/default/config/publication.xconf
Added: lenya/sandbox/jcrsitetree/src/data/repository/jaas.config
URL: http://svn.apache.org/viewcvs/lenya/sandbox/jcrsitetree/src/data/repository/jaas.config?view=auto&rev=161268
==============================================================================
--- lenya/sandbox/jcrsitetree/src/data/repository/jaas.config (added)
+++ lenya/sandbox/jcrsitetree/src/data/repository/jaas.config Thu Apr 14 05:54:23 2005
@@ -0,0 +1,3 @@
+Jackrabbit {
+ org.apache.jackrabbit.core.security.SimpleLoginModule required anonymousId="anonymous";
+};
\ No newline at end of file
Added: lenya/sandbox/jcrsitetree/src/data/repository/repository.xml
URL: http://svn.apache.org/viewcvs/lenya/sandbox/jcrsitetree/src/data/repository/repository.xml?view=auto&rev=161268
==============================================================================
--- lenya/sandbox/jcrsitetree/src/data/repository/repository.xml (added)
+++ lenya/sandbox/jcrsitetree/src/data/repository/repository.xml Thu Apr 14 05:54:23 2005
@@ -0,0 +1,203 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!-- <!DOCTYPE Repository PUBLIC "-//The Apache Software Foundation//DTD Repository//EN" "file://config.dtd"> -->
+<!DOCTYPE Repository [
+ <!--
+ the Repository element configures a repository instance;
+ individual workspaces of the repository are configured through
+ separate configuration files called workspace.xml which are
+ located in a subfolder of the workspaces root directory
+ (see Workspaces element).
+
+ it consists of
+
+ a FileSystem element (the virtual file system
+ used by the repository to persist global state such as
+ registered namespaces, custom node types, etc..
+
+ a Security element that specifies the name of the app-entry
+ in the JAAS config and the access manager
+
+ a Workspaces element that specifies to the location of
+ workspaces root directory and the name of default workspace
+
+ a Workspace element that is used as a workspace configuration
+ template; it is used to create the initial workspace if there's
+ no workspace yet and for creating additional workspaces through
+ the api
+
+ a SearchIndex element that is used for configuring per workspace
+ Indexing-related settings
+
+ a Versioning element that is used for configuring
+ versioning-related settings
+ -->
+ <!ELEMENT Repository (FileSystem,Workspaces,Workspace,Versioning)>
+
+ <!--
+ a virtual file system
+ -->
+ <!ELEMENT FileSystem (param*)>
+ <!ATTLIST FileSystem
+ class CDATA #REQUIRED>
+
+ <!--
+ the Security element specifies the name (appName attribute)
+ of the JAAS configuration app-entry for this repository.
+ it also specifies the access manager to be used (AccessManager element).
+ -->
+ <!ELEMENT Security (AccessManager)>
+ <!ATTLIST Security
+ appName CDATA #REQUIRED>
+
+ <!--
+ the AccessManager element configures the access manager to be used by
+ this repository instance; the class attribute specifies the FQN of the
+ class implementing the AccessManager interface
+ -->
+ <!ELEMENT AccessManager (param*)>
+ <!ATTLIST AccessManager
+ class CDATA #REQUIRED>
+
+ <!--
+ generic parameter (name/value pair)
+ -->
+ <!ELEMENT param EMPTY>
+ <!ATTLIST param
+ name CDATA #REQUIRED
+ value CDATA #REQUIRED>
+
+ <!--
+ the Workspaces element specifies the workspaces root directory
+ (rootPath attribute) and the name of the default workspace
+ (defaultWorkspace attribute).
+
+ individual workspaces are configured through individual workspace.xml
+ files located in a subfolder each of the workspaces root directory.
+ -->
+ <!ELEMENT Workspaces EMPTY>
+ <!ATTLIST Workspaces
+ rootPath CDATA #REQUIRED
+ defaultWorkspace CDATA #REQUIRED>
+
+ <!--
+ the Workspace element serves as a workspace configuration template;
+ it is used to create the initial workspace if there's no workspace yet
+ and for creating additional workspaces through the api
+ -->
+ <!ELEMENT Workspace (FileSystem,PersistenceManager,SearchIndex?)>
+ <!ATTLIST Workspace
+ name CDATA #REQUIRED>
+
+ <!--
+ the PersistenceManager element configures the persistence manager
+ to be used for the workspace; the class attribute specifies the
+ FQN of the class implementing PersistenceManager interface
+ -->
+ <!ELEMENT PersistenceManager (param*)>
+ <!ATTLIST PersistenceManager
+ class CDATA #REQUIRED>
+
+ <!--
+ the SearchIndex element specifies the locaction of the search index
+ (used by the QueryHandler); the class attribute specifies the
+ FQN of the class implementing the QueryHandler interface.
+ -->
+ <!ELEMENT SearchIndex (param*,FileSystem)>
+ <!ATTLIST SearchIndex
+ class CDATA #REQUIRED>
+
+ <!--
+ the Versioning element configures the persistence manager
+ to be used for persisting version state
+ -->
+ <!ELEMENT Versioning (FileSystem, PersistenceManager)>
+ <!ATTLIST Versioning
+ rootPath CDATA #REQUIRED
+ >
+]>
+<Repository>
+ <!--
+ virtual file system where the repository stores global state
+ (e.g. registered namespaces, custom node types, etc.)
+ -->
+ <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+ <param name="path" value="${rep.home}/repository"/>
+ </FileSystem>
+ <!--
+ security configuration
+ -->
+ <Security appName="Jackrabbit">
+ <!--
+ access manager:
+ class: FQN of class implementing the AccessManager interface
+ -->
+ <AccessManager class="org.apache.jackrabbit.core.security.SimpleAccessManager">
+ <!-- <param name="config" value="${rep.home}/access.xml"/> -->
+ </AccessManager>
+ </Security>
+
+ <!--
+ location of workspaces root directory and name of default workspace
+ -->
+ <Workspaces rootPath="${rep.home}/workspaces" defaultWorkspace="default"/>
+ <!--
+ workspace configuration template:
+ used to create the initial workspace if there's no workspace yet
+ -->
+ <Workspace name="${wsp.name}">
+ <!--
+ virtual file system of the workspace:
+ class: FQN of class implementing FileSystem interface
+ -->
+ <FileSystem class="com.day.jackrabbit.fs.cq.CQFileSystem">
+ <param name="path" value="${wsp.home}/wspStore.dat"/>
+ <param name="autoRepair" value="false"/>
+ <param name="blockSize" value="128"/>
+ <param name="autoSync" value="false"/>
+ </FileSystem>
+ <!--
+ persistence of the workspace:
+ class: FQN of class implementing PersistenceManager interface
+ -->
+ <PersistenceManager class="org.apache.jackrabbit.core.state.obj.ObjectPersistenceManager"/>
+ <!--
+ Search index and the file system it uses.
+ -->
+ <SearchIndex class="org.apache.jackrabbit.core.search.lucene.SearchIndex">
+ <param name="useCompoundFile" value="true"/>
+ <param name="minMergeDocs" value="1000"/>
+ <param name="maxMergeDocs" value="10000"/>
+ <param name="mergeFactor" value="10"/>
+
+ <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+ <param name="path" value="${wsp.home}/index"/>
+ </FileSystem>
+ </SearchIndex>
+ </Workspace>
+
+ <!--
+ Configures the versioning
+ -->
+ <Versioning rootPath="${rep.home}/version">
+ <!--
+ Configures the filesystem to use for versioning for the respective
+ persistence manager
+ -->
+ <FileSystem class="com.day.jackrabbit.fs.cq.CQFileSystem">
+ <param name="path" value="${rep.home}/version/version.dat"/>
+ <param name="autoRepair" value="false"/>
+ <param name="blockSize" value="128"/>
+ <param name="autoSync" value="false"/>
+ </FileSystem>
+
+ <!--
+ Configures the persistence manager to be used for persisting version state.
+ Please note that the current versioning implementation is based on
+ a 'normal' persistence manager, but this could change in future
+ implementations.
+ -->
+ <PersistenceManager class="org.apache.jackrabbit.core.state.obj.ObjectPersistenceManager"/>
+
+ </Versioning>
+
+</Repository>
Added: lenya/sandbox/jcrsitetree/src/data/repository/repository/nodetypes/custom_nodetypes.xml
URL: http://svn.apache.org/viewcvs/lenya/sandbox/jcrsitetree/src/data/repository/repository/nodetypes/custom_nodetypes.xml?view=auto&rev=161268
==============================================================================
--- lenya/sandbox/jcrsitetree/src/data/repository/repository/nodetypes/custom_nodetypes.xml (added)
+++ lenya/sandbox/jcrsitetree/src/data/repository/repository/nodetypes/custom_nodetypes.xml Thu Apr 14 05:54:23 2005
@@ -0,0 +1,84 @@
+<?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:lpu="http://apache.org/cocoon/lenya/jcr/usr/1.0" xmlns:lps="http://apache.org/cocoon/lenya/jcr/sys/1.0" xmlns:mix="http://www.jcp.org/jcr/mix/1.0" xmlns:xml="http://www.w3.org/XML/1998/namespace">
+
+ <nodeType name="jcr:content" isMixin="false" hasOrderableChildNodes="false" primaryItemName="">
+ <supertypes>
+ <supertype>nt:unstructured</supertype>
+ <supertype>mix:referenceable</supertype>
+ </supertypes>
+ </nodeType>
+
+ <nodeType name="lps:document" isMixin="false" hasOrderableChildNodes="false" primaryItemName="jcr:content">
+ <supertypes>
+ <supertype>nt:file</supertype>
+ <supertype>mix:versionable</supertype>
+ </supertypes>
+ <propertyDef name="xml:lang" requiredType="String" autoCreate="false" mandatory="true" onParentVersion="COPY" protected="false"/>
+ <propertyDef name="lps:label" requiredType="String" autoCreate="false" mandatory="true" onParentVersion="COPY" protected="false"/>
+ </nodeType>
+
+ <nodeType name="lps:node" isMixin="false" hasOrderableChildNodes="true" primaryItemName="">
+ <supertypes>
+ <supertype>nt:hierarchyNode</supertype>
+ <supertype>mix:referenceable</supertype>
+ </supertypes>
+ <propertyDef name="*" requiredType="String" autoCreate="false" mandatory="false" onParentVersion="ABORT" protected="false" multiple="false"/>
+ <propertyDef name="lps:visibleinnav" requiredType="Boolean" autoCreate="false" mandatory="true" onParentVersion="ABORT" protected="false" multiple="false"/>
+ <propertyDef name="lps:href" requiredType="String" autoCreate="false" mandatory="false" onParentVersion="ABORT" protected="false" multiple="false"/>
+ <propertyDef name="lps:suffix" requiredType="String" autoCreate="false" mandatory="false" onParentVersion="ABORT" protected="false" multiple="false"/>
+ <propertyDef name="lps:link" requiredType="Boolean" autoCreate="false" mandatory="false" onParentVersion="ABORT" protected="false" multiple="false"/>
+ <childNodeDef name="lps:document" defaultPrimaryType="lps:document" autoCreate="false" mandatory="true" onParentVersion="ABORT" protected="false" sameNameSibs="true">
+ <requiredPrimaryTypes>
+ <requiredPrimaryType>lps:document</requiredPrimaryType>
+ </requiredPrimaryTypes>
+ </childNodeDef>
+ <childNodeDef name="*" defaultPrimaryType="lps:node" autoCreate="false" mandatory="false" onParentVersion="ABORT" protected="false" sameNameSibs="false">
+ <requiredPrimaryTypes>
+ <requiredPrimaryType>lps:node</requiredPrimaryType>
+ </requiredPrimaryTypes>
+ </childNodeDef>
+ </nodeType>
+
+ <nodeType name="lps:site" isMixin="false" hasOrderableChildNodes="true" primaryItemName="">
+ <supertypes>
+ <supertype>nt:hierarchyNode</supertype>
+ <supertype>mix:referenceable</supertype>
+ </supertypes>
+ <propertyDef name="lps:label" requiredType="String" autoCreate="false" mandatory="true" onParentVersion="ABORT" protected="false"/>
+ <childNodeDef name="*" defaultPrimaryType="lps:node" autoCreate="false" mandatory="false" onParentVersion="ABORT" protected="false" sameNameSibs="false">
+ <requiredPrimaryTypes>
+ <requiredPrimaryType>lps:node</requiredPrimaryType>
+ </requiredPrimaryTypes>
+ </childNodeDef>
+ </nodeType>
+
+ <nodeType name="lps:publication" isMixin="false" hasOrderableChildNodes="false" primaryItemName="">
+ <supertypes>
+ <supertype>nt:hierarchyNode</supertype>
+ <supertype>mix:referenceable</supertype>
+ </supertypes>
+ <childNodeDef name="*" defaultPrimaryType="" autoCreate="false" mandatory="false" onParentVersion="ABORT" protected="false" sameNameSibs="false">
+ <requiredPrimaryTypes>
+ <requiredPrimaryType>lps:site</requiredPrimaryType>
+ </requiredPrimaryTypes>
+ </childNodeDef>
+ </nodeType>
+</nodeTypes>
Added: lenya/sandbox/jcrsitetree/src/data/repository/workspaces/archive/workspace.xml
URL: http://svn.apache.org/viewcvs/lenya/sandbox/jcrsitetree/src/data/repository/workspaces/archive/workspace.xml?view=auto&rev=161268
==============================================================================
--- lenya/sandbox/jcrsitetree/src/data/repository/workspaces/archive/workspace.xml (added)
+++ lenya/sandbox/jcrsitetree/src/data/repository/workspaces/archive/workspace.xml Thu Apr 14 05:54:23 2005
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Workspace name="archive">
+ <!--
+ virtual file system of the workspace:
+ class: FQN of class implementing FileSystem interface
+ -->
+ <FileSystem class="com.day.jackrabbit.fs.cq.CQFileSystem">
+ <param name="path" value="${wsp.home}/wspStore.dat" />
+ <param name="autoRepair" value="false" />
+ <param name="blockSize" value="128" />
+ <param name="autoSync" value="false" />
+ </FileSystem>
+ <!--
+ persistence of the workspace:
+ class: FQN of class implementing PersistenceManager interface
+ -->
+ <PersistenceManager class="org.apache.jackrabbit.core.state.obj.ObjectPersistenceManager" />
+ <!--
+ Search index and the file system it uses.
+ -->
+ <SearchIndex class="org.apache.jackrabbit.core.search.lucene.SearchIndex">
+ <param name="useCompoundFile" value="true" />
+ <param name="minMergeDocs" value="1000" />
+ <param name="maxMergeDocs" value="10000" />
+ <param name="mergeFactor" value="10" />
+ <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+ <param name="path" value="${wsp.home}/index" />
+ </FileSystem>
+ </SearchIndex>
+</Workspace>
+
Added: lenya/sandbox/jcrsitetree/src/data/repository/workspaces/authoring/workspace.xml
URL: http://svn.apache.org/viewcvs/lenya/sandbox/jcrsitetree/src/data/repository/workspaces/authoring/workspace.xml?view=auto&rev=161268
==============================================================================
--- lenya/sandbox/jcrsitetree/src/data/repository/workspaces/authoring/workspace.xml (added)
+++ lenya/sandbox/jcrsitetree/src/data/repository/workspaces/authoring/workspace.xml Thu Apr 14 05:54:23 2005
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Workspace name="authoring">
+ <!--
+ virtual file system of the workspace:
+ class: FQN of class implementing FileSystem interface
+ -->
+ <FileSystem class="com.day.jackrabbit.fs.cq.CQFileSystem">
+ <param name="path" value="${wsp.home}/wspStore.dat" />
+ <param name="autoRepair" value="false" />
+ <param name="blockSize" value="128" />
+ <param name="autoSync" value="false" />
+ </FileSystem>
+ <!--
+ persistence of the workspace:
+ class: FQN of class implementing PersistenceManager interface
+ -->
+ <PersistenceManager class="org.apache.jackrabbit.core.state.obj.ObjectPersistenceManager" />
+ <!--
+ Search index and the file system it uses.
+ -->
+ <SearchIndex class="org.apache.jackrabbit.core.search.lucene.SearchIndex">
+ <param name="useCompoundFile" value="true" />
+ <param name="minMergeDocs" value="1000" />
+ <param name="maxMergeDocs" value="10000" />
+ <param name="mergeFactor" value="10" />
+ <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+ <param name="path" value="${wsp.home}/index" />
+ </FileSystem>
+ </SearchIndex>
+</Workspace>
+
Added: lenya/sandbox/jcrsitetree/src/data/repository/workspaces/default/workspace.xml
URL: http://svn.apache.org/viewcvs/lenya/sandbox/jcrsitetree/src/data/repository/workspaces/default/workspace.xml?view=auto&rev=161268
==============================================================================
--- lenya/sandbox/jcrsitetree/src/data/repository/workspaces/default/workspace.xml (added)
+++ lenya/sandbox/jcrsitetree/src/data/repository/workspaces/default/workspace.xml Thu Apr 14 05:54:23 2005
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Workspace name="default">
+ <!--
+ virtual file system of the workspace:
+ class: FQN of class implementing FileSystem interface
+ -->
+ <FileSystem class="com.day.jackrabbit.fs.cq.CQFileSystem">
+ <param name="path" value="${wsp.home}/wspStore.dat" />
+ <param name="autoRepair" value="false" />
+ <param name="blockSize" value="128" />
+ <param name="autoSync" value="false" />
+ </FileSystem>
+ <!--
+ persistence of the workspace:
+ class: FQN of class implementing PersistenceManager interface
+ -->
+ <PersistenceManager class="org.apache.jackrabbit.core.state.obj.ObjectPersistenceManager" />
+ <!--
+ Search index and the file system it uses.
+ -->
+ <SearchIndex class="org.apache.jackrabbit.core.search.lucene.SearchIndex">
+ <param name="useCompoundFile" value="true" />
+ <param name="minMergeDocs" value="1000" />
+ <param name="maxMergeDocs" value="10000" />
+ <param name="mergeFactor" value="10" />
+ <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+ <param name="path" value="${wsp.home}/index" />
+ </FileSystem>
+ </SearchIndex>
+</Workspace>
+
Added: lenya/sandbox/jcrsitetree/src/data/repository/workspaces/live/workspace.xml
URL: http://svn.apache.org/viewcvs/lenya/sandbox/jcrsitetree/src/data/repository/workspaces/live/workspace.xml?view=auto&rev=161268
==============================================================================
--- lenya/sandbox/jcrsitetree/src/data/repository/workspaces/live/workspace.xml (added)
+++ lenya/sandbox/jcrsitetree/src/data/repository/workspaces/live/workspace.xml Thu Apr 14 05:54:23 2005
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Workspace name="live">
+ <!--
+ virtual file system of the workspace:
+ class: FQN of class implementing FileSystem interface
+ -->
+ <FileSystem class="com.day.jackrabbit.fs.cq.CQFileSystem">
+ <param name="path" value="${wsp.home}/wspStore.dat" />
+ <param name="autoRepair" value="false" />
+ <param name="blockSize" value="128" />
+ <param name="autoSync" value="false" />
+ </FileSystem>
+ <!--
+ persistence of the workspace:
+ class: FQN of class implementing PersistenceManager interface
+ -->
+ <PersistenceManager class="org.apache.jackrabbit.core.state.obj.ObjectPersistenceManager" />
+ <!--
+ Search index and the file system it uses.
+ -->
+ <SearchIndex class="org.apache.jackrabbit.core.search.lucene.SearchIndex">
+ <param name="useCompoundFile" value="true" />
+ <param name="minMergeDocs" value="1000" />
+ <param name="maxMergeDocs" value="10000" />
+ <param name="mergeFactor" value="10" />
+ <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+ <param name="path" value="${wsp.home}/index" />
+ </FileSystem>
+ </SearchIndex>
+</Workspace>
+
Added: lenya/sandbox/jcrsitetree/src/data/repository/workspaces/trash/workspace.xml
URL: http://svn.apache.org/viewcvs/lenya/sandbox/jcrsitetree/src/data/repository/workspaces/trash/workspace.xml?view=auto&rev=161268
==============================================================================
--- lenya/sandbox/jcrsitetree/src/data/repository/workspaces/trash/workspace.xml (added)
+++ lenya/sandbox/jcrsitetree/src/data/repository/workspaces/trash/workspace.xml Thu Apr 14 05:54:23 2005
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Workspace name="trash">
+ <!--
+ virtual file system of the workspace:
+ class: FQN of class implementing FileSystem interface
+ -->
+ <FileSystem class="com.day.jackrabbit.fs.cq.CQFileSystem">
+ <param name="path" value="${wsp.home}/wspStore.dat" />
+ <param name="autoRepair" value="false" />
+ <param name="blockSize" value="128" />
+ <param name="autoSync" value="false" />
+ </FileSystem>
+ <!--
+ persistence of the workspace:
+ class: FQN of class implementing PersistenceManager interface
+ -->
+ <PersistenceManager class="org.apache.jackrabbit.core.state.obj.ObjectPersistenceManager" />
+ <!--
+ Search index and the file system it uses.
+ -->
+ <SearchIndex class="org.apache.jackrabbit.core.search.lucene.SearchIndex">
+ <param name="useCompoundFile" value="true" />
+ <param name="minMergeDocs" value="1000" />
+ <param name="maxMergeDocs" value="10000" />
+ <param name="mergeFactor" value="10" />
+ <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+ <param name="path" value="${wsp.home}/index" />
+ </FileSystem>
+ </SearchIndex>
+</Workspace>
+
Modified: lenya/sandbox/jcrsitetree/src/java/org/apache/lenya/cms/publication/AbstractPublication.java
URL: http://svn.apache.org/viewcvs/lenya/sandbox/jcrsitetree/src/java/org/apache/lenya/cms/publication/AbstractPublication.java?view=diff&r1=161267&r2=161268
==============================================================================
--- lenya/sandbox/jcrsitetree/src/java/org/apache/lenya/cms/publication/AbstractPublication.java (original)
+++ lenya/sandbox/jcrsitetree/src/java/org/apache/lenya/cms/publication/AbstractPublication.java Thu Apr 14 05:54:23 2005
@@ -328,7 +328,7 @@
sitetree = (SiteTree) siteTrees.get(area);
} else {
try {
- sitetree = SiteTreeFactory.getSiteTree(config, getDirectory(), area);
+ sitetree = SiteTreeFactory.getSiteTree(config, this, area);
} catch (SiteTreeFactoryException e) {
throw new SiteTreeException("Unable to create sitetree.", e);
}
Modified: lenya/sandbox/jcrsitetree/src/java/org/apache/lenya/cms/publication/ClearRepository.java
URL: http://svn.apache.org/viewcvs/lenya/sandbox/jcrsitetree/src/java/org/apache/lenya/cms/publication/ClearRepository.java?view=diff&r1=161267&r2=161268
==============================================================================
--- lenya/sandbox/jcrsitetree/src/java/org/apache/lenya/cms/publication/ClearRepository.java (original)
+++ lenya/sandbox/jcrsitetree/src/java/org/apache/lenya/cms/publication/ClearRepository.java Thu Apr 14 05:54:23 2005
@@ -17,16 +17,8 @@
package org.apache.lenya.cms.publication;
-import java.io.File;
-import java.util.Hashtable;
-
import javax.jcr.*;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-
-import org.apache.jackrabbit.core.jndi.RegistryHelper;
-
/**
* Clear all nodes
*/
@@ -37,15 +29,15 @@
*
*/
public static void main(String[] args) {
- String repoHomeDir = args[0];
+ String servletRootDir = args[0];
- new ClearRepository().clear(repoHomeDir);
+ new ClearRepository().clear(servletRootDir);
}
- public void clear(String repoHomeDir) {
- System.out.println("Clear repository " + repoHomeDir);
+ public void clear(String servletRootDir) {
+ System.out.println("Clear repository of " + servletRootDir);
try {
- Repository repo = getRepository(repoHomeDir);
+ Repository repo = RepositoryFactory.getRepository(servletRootDir);
clearWorkspace(repo, Publication.AUTHORING_AREA);
clearWorkspace(repo, Publication.LIVE_AREA);
clearWorkspace(repo, Publication.TRASH_AREA);
@@ -54,21 +46,6 @@
e.printStackTrace(System.err);
}
- }
-
- /**
- *
- */
- private Repository getRepository(String repHomeDir) throws Exception {
- String configFile = repHomeDir + File.separator + "repository.xml";
-
- Hashtable env = new Hashtable();
- env.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.jackrabbit.core.jndi.provider.DummyInitialContextFactory");
- env.put(Context.PROVIDER_URL, "localhost");
- InitialContext ctx = new InitialContext(env);
-
- RegistryHelper.registerRepository(ctx, "repo", configFile, repHomeDir, true);
- return (Repository) ctx.lookup("repo");
}
private void clearWorkspace(Repository repo, String workspace) {
Modified: lenya/sandbox/jcrsitetree/src/java/org/apache/lenya/cms/publication/ImportSiteTree.java
URL: http://svn.apache.org/viewcvs/lenya/sandbox/jcrsitetree/src/java/org/apache/lenya/cms/publication/ImportSiteTree.java?view=diff&r1=161267&r2=161268
==============================================================================
--- lenya/sandbox/jcrsitetree/src/java/org/apache/lenya/cms/publication/ImportSiteTree.java (original)
+++ lenya/sandbox/jcrsitetree/src/java/org/apache/lenya/cms/publication/ImportSiteTree.java Thu Apr 14 05:54:23 2005
@@ -18,71 +18,229 @@
package org.apache.lenya.cms.publication;
import java.io.File;
+import java.io.FileFilter;
import java.io.FileInputStream;
-import java.util.Hashtable;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PipedInputStream;
+import java.io.PipedOutputStream;
import javax.jcr.*;
-import javax.jcr.nodetype.NodeTypeManager;
+import javax.xml.parsers.FactoryConfigurationError;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.TransformerFactoryConfigurationError;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-
-import org.apache.jackrabbit.core.jndi.RegistryHelper;
+import org.xml.sax.SAXException;
/**
* Import lenya sitetree into jackrabbit repository.
*/
public class ImportSiteTree {
- private final static String DOCUMENT_NT = "document";
+ private final static String XSL_FILE = "ImportSiteTree.xsl";
+ private final static String PUBLICATION_PATH = "lenya" + File.separator + "pubs";
+ private final static String CONTENT_DIR = "content";
+ private final static String SITETREE_FILE = "sitetree.xml";
+
+ // Node type names.
+ private final static String PUBLICATION_NT_NAME = "publication";
+ // private final static String DOCUMENT_NT_NAME = "document"; Needed??
+
+ private final static String PUBLICATION_NAME = "publication";
+
private final static String SITE_NAME = "site";
private final static String DOCUMENT_NAME = "document";
+
+ // XSL parameter for publication name.
+ private final static String PUBLICATION_XSL_PARAMETER = "publicationName";
+
private final static String REPO_USER = "lenya";
+ private final static String[] WORKSPACES = {Publication.AUTHORING_AREA, Publication.LIVE_AREA,
+ Publication.ARCHIVE_AREA, Publication.TRASH_AREA};
+
+ private File servletRoot;
+ private File publicationRoot;
+
+ private Repository repository;
+
+ /**
+ * Class for transforming existing sitetree file to repository readable xml.
+ */
+ class SitetreeTransformer extends Thread {
+ Transformer tf;
+ Source input;
+ Result outputTarget;
+ OutputStream outputStream;
+
+ SitetreeTransformer(Source xslSource, InputStream input, OutputStream outputStream, String publicationName)
+ throws TransformerConfigurationException, TransformerFactoryConfigurationError,
+ ParserConfigurationException, SAXException, FactoryConfigurationError, IOException
+ {
+ tf = TransformerFactory.newInstance().newTransformer(xslSource);
+ tf.setParameter(PUBLICATION_XSL_PARAMETER, publicationName);
+ this.input = new StreamSource(input);
+ this.outputStream = outputStream;
+ this.outputTarget = new StreamResult(outputStream);
+ }
+
+ public void run() {
+ try {
+ tf.transform(input, outputTarget);
+ outputStream.close();
+ } catch (TransformerException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
/**
*
*/
public static void main(String[] args) {
- String repoHomeDir = args[0];
- String defaultPubDir = args[1];
+ // Check parameters.
+ if (args.length != 1) {
+ System.out.println("Usage: java org.apache.lenya.cms.publication.ImportSiteTree <SERVLET_ROOT>");
+ System.exit(-1);
+ }
+
+ // Check if servlet root directory exists.
+ File servletRoot = new File(args[0]);
+ if (!servletRoot.exists() || !servletRoot.isDirectory()) {
+ System.out.println("Servlet root directory not found: " + servletRoot.getAbsolutePath());
+ System.exit(-1);
+ }
+
+ String publicationPath = servletRoot.getAbsolutePath() + File.separator + PUBLICATION_PATH;
+
+ // Check if publication directory exists.
+ File publicationRoot = new File(publicationPath);
+ if (!publicationRoot.exists() || !publicationRoot.isDirectory()) {
+ System.out.println("Publication path not found: " + publicationPath);
+ System.exit(-1);
+ }
- new ImportSiteTree().importSitetree(repoHomeDir, defaultPubDir);
+ new ImportSiteTree(servletRoot, publicationRoot);
+ }
+
+ public ImportSiteTree(File servletRoot, File publicationRoot) {
+ this.servletRoot = servletRoot;
+ this.publicationRoot = publicationRoot;
+
+ try {
+ repository = RepositoryFactory.getRepository(servletRoot.getAbsolutePath());
+ } catch (RepositoryFactoryException e) {
+ System.out.println("Unable to open repository: " + e.getMessage());
+ System.exit(-1);
+ }
+
+ FileFilter directoryFilter = new FileFilter() {
+ public boolean accept(File pathname) {
+ if (pathname.isDirectory())
+ return true;
+ else
+ return false;
+ }
+ };
+
+ for (int i=0; i<WORKSPACES.length; i++) {
+ addPublicationNode(WORKSPACES[i]);
+ }
+
+ File[] publications = publicationRoot.listFiles(directoryFilter);
+ for (int i=0; i<publications.length; i++) {
+ importPublication(publications[i]);
+ }
+ }
+
+ private void addPublicationNode(String workspace) {
+ String nsPrefixSys = null;
+ Session session = null;
+ try {
+ session = repository.login(new SimpleCredentials(REPO_USER, "".toCharArray()), workspace);
+ nsPrefixSys = getNamespacePrefix(session, JCRSiteTree.NS_URI_SYSTEM, JCRSiteTree.NS_PREFIX_SYSTEM);
+ Node publicationNode = null;
+ if (!session.getRootNode().hasNode(nsPrefixSys + ":" + PUBLICATION_NAME)) {
+ session.getRootNode().addNode(nsPrefixSys + ":" + PUBLICATION_NAME,
+ nsPrefixSys + ":" + PUBLICATION_NT_NAME);
+ }
+ session.save();
+ session.logout();
+ } catch (Exception e) {
+ e.printStackTrace(System.err);
+ } finally {
+ if (session != null)
+ session.logout();
+ }
+ }
+
+ public void importPublication(File publication) {
+ for (int i=0; i<WORKSPACES.length; i++) {
+ importSitetree(publication, WORKSPACES[i]);
+ }
}
/**
*
*/
- public void importSitetree(String repoHomeDir, String defaultPubDir) {
- String nsPrefixAuthSys = null;
- String nsPrefixAuthUser = null;
- String nsPrefixLiveSys = null;
- String nsPrefixLiveUser = null;
- String nsPrefixDefaultSys = null;
- String nsPrefixDefaultUser = null;
- String nsPrefixTrashSys = null;
- String nsPrefixTrashUser = null;
- String nsPrefixArchiveSys = null;
- String nsPrefixArchiveUser = null;
-
- System.out.println("Import Authoring and Live Sitetree from " + defaultPubDir + " into " + repoHomeDir);
+ public void importSitetree(File publication, String area) {
+ String nsPrefixSys = null;
+ String nsPrefixUser = null;
+
+ File siteTreePath = new File(publication.getAbsolutePath() + File.separator +
+ CONTENT_DIR + File.separator + area + File.separator + SITETREE_FILE);
+
+ if (!siteTreePath.exists() || !siteTreePath.isFile()) {
+ System.out.println("Unable to open sitetree file for area '" + area + "' in publication '" +
+ publication.getAbsolutePath() + "'");
+ return;
+ }
+
+ System.out.println("Importing sitetree of area '" + area + "' from publication '" +
+ publication.getName() + "' into repository.");
+
+ Session session = null;
try {
- Repository repo = getRepository(repoHomeDir);
+ session = repository.login(new SimpleCredentials(REPO_USER, "".toCharArray()), area);
+ nsPrefixSys = getNamespacePrefix(session, JCRSiteTree.NS_URI_SYSTEM, JCRSiteTree.NS_PREFIX_SYSTEM);
+ nsPrefixUser = getNamespacePrefix(session, JCRSiteTree.NS_URI_USER, JCRSiteTree.NS_PREFIX_USER);
- // Import authoring sitetree.
- Session authSession = repo.login(new SimpleCredentials(REPO_USER, "".toCharArray()), Publication.AUTHORING_AREA);
- nsPrefixAuthSys = getNamespacePrefix(authSession, JCRSiteTree.NS_URI_SYSTEM, JCRSiteTree.NS_PREFIX_SYSTEM);
- nsPrefixAuthUser = getNamespacePrefix(authSession, JCRSiteTree.NS_URI_USER, JCRSiteTree.NS_PREFIX_USER);
-
- authSession.importXML("/", new FileInputStream(defaultPubDir + "/content/authoring/sitetree.xml.import"));
+ // Get root node for publications.
+ Node publicationRoot = session.getRootNode().getNode(nsPrefixSys + ":" + PUBLICATION_NAME);
- // Remove empty text nodes and add referenceable/versionable mixinType
- NodeIterator iter = authSession.getRootNode().getNodes(nsPrefixAuthSys + ":*");
- iter = authSession.getRootNode().getNodes(nsPrefixAuthSys + ":*");
+ // Get XSL file.
+ StreamSource xslSource = new StreamSource(getClass().getResourceAsStream(XSL_FILE));
+
+ // Pipe transformation result.
+ PipedInputStream pipedTfResult = new PipedInputStream();
+ OutputStream transformationResult = new PipedOutputStream(pipedTfResult);
+
+ new SitetreeTransformer(xslSource, new FileInputStream(siteTreePath), transformationResult,
+ publication.getName()).start();
+
+ session.importXML(publicationRoot.getPath(), pipedTfResult);
+
+ // Remove empty text nodes.
+ NodeIterator iter = session.getRootNode().getNodes(nsPrefixSys + ":*");
while (iter.hasNext()) {
Node node = iter.nextNode();
removeXMLTextNodes(node);
}
- authSession.save();
+ session.save();
+
+ /*
+ // TODO: cloning
// Clone authoring sitetree to live workspace
System.out.println("Cloning authoring area to live area.");
@@ -115,56 +273,17 @@
defaultSession.refresh(false);
// Save changes in live area.
liveSession.save();
-
- // Creating trash workspace.
- System.out.println("Creating 'trash' workspace.");
- Session trashSession = repo.login(new SimpleCredentials(REPO_USER, "".toCharArray()), Publication.TRASH_AREA);
- nsPrefixTrashSys = getNamespacePrefix(trashSession, JCRSiteTree.NS_URI_SYSTEM, JCRSiteTree.NS_PREFIX_SYSTEM);
- nsPrefixTrashUser = getNamespacePrefix(trashSession, JCRSiteTree.NS_URI_USER, JCRSiteTree.NS_PREFIX_USER);
-
- // Create sitetree root node.
- trashSession.getRootNode().addNode(nsPrefixTrashSys + ":site");
-
- trashSession.save();
-
- // Creating archive workspace.
- System.out.println("Creating 'archive' workspace.");
- Session archiveSession = repo.login(new SimpleCredentials(REPO_USER, "".toCharArray()), Publication.ARCHIVE_AREA);
- nsPrefixArchiveSys = getNamespacePrefix(archiveSession, JCRSiteTree.NS_URI_SYSTEM, JCRSiteTree.NS_PREFIX_SYSTEM);
- nsPrefixArchiveUser = getNamespacePrefix(archiveSession, JCRSiteTree.NS_URI_USER, JCRSiteTree.NS_PREFIX_USER);
-
- // Create sitetree root node.
- archiveSession.getRootNode().addNode(nsPrefixTrashSys + ":site");
-
- archiveSession.save();
-
- // Close sessions.
- liveSession.logout();
- authSession.logout();
- defaultSession.logout();
- trashSession.logout();
- archiveSession.logout();
+ */
} catch (Exception e) {
e.printStackTrace(System.err);
+ } finally {
+ if (session != null) {
+ session.logout();
+ }
}
}
/**
- *
- */
- private Repository getRepository(String repHomeDir) throws Exception {
- String configFile = repHomeDir + File.separator + "repository.xml";
-
- Hashtable env = new Hashtable();
- env.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.jackrabbit.core.jndi.provider.DummyInitialContextFactory");
- env.put(Context.PROVIDER_URL, "localhost");
- InitialContext ctx = new InitialContext(env);
-
- RegistryHelper.registerRepository(ctx, "repo", configFile, repHomeDir, true);
- return (Repository) ctx.lookup("repo");
- }
-
- /**
* Get namespace prefix for given namespace URI.
* @param session Session object
* @param namespace namespace URI of the prefix you want
@@ -246,15 +365,5 @@
while (iter.hasNext()) {
cleanupLiveArea(tmpSession, dst, iter.nextNode(), searchPrefix);
}
- }
-
- private NodeTypeManager getNodeTypeManager(Workspace workspace) {
- NodeTypeManager mgr = null;
- try {
- mgr = workspace.getNodeTypeManager();
- } catch (RepositoryException e) {
- e.printStackTrace();
- }
- return mgr;
}
}
Modified: lenya/sandbox/jcrsitetree/src/java/org/apache/lenya/cms/publication/ImportSiteTree.xsl
URL: http://svn.apache.org/viewcvs/lenya/sandbox/jcrsitetree/src/java/org/apache/lenya/cms/publication/ImportSiteTree.xsl?view=diff&r1=161267&r2=161268
==============================================================================
--- lenya/sandbox/jcrsitetree/src/java/org/apache/lenya/cms/publication/ImportSiteTree.xsl (original)
+++ lenya/sandbox/jcrsitetree/src/java/org/apache/lenya/cms/publication/ImportSiteTree.xsl Thu Apr 14 05:54:23 2005
@@ -20,43 +20,125 @@
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:sitetree="http://apache.org/cocoon/lenya/sitetree/1.0"
- xmlns:sitetree-system="http://apache.org/cocoon/lenya/sitetree/system/1.0"
+ xmlns:lps="http://apache.org/cocoon/lenya/jcr/sys/1.0"
+ xmlns:lpu="http://apache.org/cocoon/lenya/jcr/usr/1.0"
xmlns:xalan="http://xml.apache.org/xslt"
xmlns:jcr="http://www.jcp.org/jcr/1.0"
>
<xsl:output encoding="UTF-8" indent="yes"
xalan:indent-amount="4"/>
+
+ <xsl:param name="publicationName"/>
<xsl:template match="sitetree:site">
- <xsl:element name="sitetree-system:site">
- <xsl:attribute name="jcr:primaryType">sitetree-system:site</xsl:attribute>
- <xsl:attribute name="sitetree-system:label"><xsl:value-of select="@label"/></xsl:attribute>
+ <xsl:element name="lpu:{$publicationName}">
+ <xsl:attribute name="jcr:primaryType">lps:site</xsl:attribute>
+ <xsl:attribute name="lps:label"><xsl:value-of select="@label"/></xsl:attribute>
<xsl:apply-templates select="sitetree:node/@id"/>
</xsl:element>
</xsl:template>
<xsl:template match="sitetree:node/@id">
- <xsl:variable name="nodeId"><xsl:value-of select="."/></xsl:variable>
+ <xsl:call-template name="escape-sitetree-node">
+ <xsl:with-param name="nodeId" select="."/>
+ </xsl:call-template>
+ </xsl:template>
+
+ <xsl:template name="escape-sitetree-node">
+ <xsl:param name="nodeId"/>
- <xsl:element name="sitetree:{$nodeId}">
- <xsl:attribute name="jcr:primaryType">sitetree-system:node</xsl:attribute>
+ <xsl:choose>
+ <xsl:when test="starts-with($nodeId, '0')">
+ <xsl:call-template name="write-sitetree-node">
+ <xsl:with-param name="nodeId">_x0030_<xsl:value-of select="substring-after($nodeId, '0')"/></xsl:with-param>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="starts-with($nodeId, '1')">
+ <xsl:call-template name="write-sitetree-node">
+ <xsl:with-param name="nodeId">_x0031_<xsl:value-of select="substring-after($nodeId, '1')"/></xsl:with-param>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="starts-with($nodeId, '2')">
+ <xsl:call-template name="write-sitetree-node">
+ <xsl:with-param name="nodeId">_x0032_<xsl:value-of select="substring-after($nodeId, '2')"/></xsl:with-param>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="starts-with($nodeId, '3')">
+ <xsl:call-template name="write-sitetree-node">
+ <xsl:with-param name="nodeId">_x0033_<xsl:value-of select="substring-after($nodeId, '3')"/></xsl:with-param>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="starts-with($nodeId, '4')">
+ <xsl:call-template name="write-sitetree-node">
+ <xsl:with-param name="nodeId">_x0034_<xsl:value-of select="substring-after($nodeId, '4')"/></xsl:with-param>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="starts-with($nodeId, '5')">
+ <xsl:call-template name="write-sitetree-node">
+ <xsl:with-param name="nodeId">_x0035_<xsl:value-of select="substring-after($nodeId, '5')"/></xsl:with-param>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="starts-with($nodeId, '6')">
+ <xsl:call-template name="write-sitetree-node">
+ <xsl:with-param name="nodeId">_x0036_<xsl:value-of select="substring-after($nodeId, '6')"/></xsl:with-param>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="starts-with($nodeId, '7')">
+ <xsl:call-template name="write-sitetree-node">
+ <xsl:with-param name="nodeId">_x0037_<xsl:value-of select="substring-after($nodeId, '7')"/></xsl:with-param>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="starts-with($nodeId, '8')">
+ <xsl:call-template name="write-sitetree-node">
+ <xsl:with-param name="nodeId">_x0038_<xsl:value-of select="substring-after($nodeId, '8')"/></xsl:with-param>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="starts-with($nodeId, '9')">
+ <xsl:call-template name="write-sitetree-node">
+ <xsl:with-param name="nodeId">_x0039_<xsl:value-of select="substring-after($nodeId, '9')"/></xsl:with-param>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="starts-with($nodeId, 'xml')">
+ <xsl:call-template name="write-sitetree-node">
+ <xsl:with-param name="nodeId">_x0078_ml<xsl:value-of select="substring-after($nodeId, 'xml')"/></xsl:with-param>
+ </xsl:call-template>
+ </xsl:when>
+ <!-- TODO: escaping needed for full string -->
+ <xsl:when test="contains($nodeId, '_x')">
+ <xsl:call-template name="write-sitetree-node">
+ <xsl:with-param name="nodeId"><xsl:value-of select="substring-before($nodeId, '_x')"/>_x005F_x<xsl:value-of select="substring-after($nodeId, '_x')"/></xsl:with-param>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="write-sitetree-node">
+ <xsl:with-param name="nodeId" select="$nodeId"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template name="write-sitetree-node">
+ <xsl:param name="nodeId"/>
+
+ <xsl:element name="lpu:{$nodeId}">
+ <xsl:attribute name="jcr:primaryType">lps:node</xsl:attribute>
<xsl:if test="../@href">
- <xsl:attribute name="sitetree-system:href"><xsl:value-of select="../@href"/></xsl:attribute>
+ <xsl:attribute name="lps:href"><xsl:value-of select="../@href"/></xsl:attribute>
</xsl:if>
<xsl:if test="../@link">
- <xsl:attribute name="sitetree-system:link"><xsl:value-of select="../@link"/></xsl:attribute>
+ <xsl:attribute name="lps:link"><xsl:value-of select="../@link"/></xsl:attribute>
</xsl:if>
<xsl:choose>
<xsl:when test="../@visibleinnav">
- <xsl:attribute name="sitetree-system:visibleinnav"><xsl:value-of select="../@visibleinnav"/></xsl:attribute>
+ <xsl:attribute name="lps:visibleinnav"><xsl:value-of select="../@visibleinnav"/></xsl:attribute>
</xsl:when>
<xsl:otherwise>
- <xsl:attribute name="sitetree-system:visibleinnav">true</xsl:attribute>
+ <xsl:attribute name="lps:visibleinnav">true</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="../@suffix">
- <xsl:attribute name="sitetree-system:suffix"><xsl:value-of select="../@suffix"/></xsl:attribute>
+ <xsl:attribute name="lps:suffix"><xsl:value-of select="../@suffix"/></xsl:attribute>
</xsl:if>
<xsl:apply-templates select="../sitetree:label"/>
<xsl:apply-templates select="../sitetree:node/@id"/>
@@ -64,10 +146,10 @@
</xsl:template>
<xsl:template match="sitetree:label">
- <xsl:element name="sitetree-system:document">
- <xsl:attribute name="jcr:primaryType">sitetree-system:document</xsl:attribute>
+ <xsl:element name="lps:document">
+ <xsl:attribute name="jcr:primaryType">lps:document</xsl:attribute>
<xsl:attribute name="xml:lang"><xsl:value-of select="@xml:lang"/></xsl:attribute>
- <xsl:attribute name="sitetree-system:label"><xsl:value-of select="."/></xsl:attribute>
+ <xsl:attribute name="lps:label"><xsl:value-of select="."/></xsl:attribute>
<xsl:element name="jcr:content">
<xsl:attribute name="jcr:primaryType">nt:unstructured</xsl:attribute>
</xsl:element>
Modified: lenya/sandbox/jcrsitetree/src/java/org/apache/lenya/cms/publication/JCRSiteTree.java
URL: http://svn.apache.org/viewcvs/lenya/sandbox/jcrsitetree/src/java/org/apache/lenya/cms/publication/JCRSiteTree.java?view=diff&r1=161267&r2=161268
==============================================================================
--- lenya/sandbox/jcrsitetree/src/java/org/apache/lenya/cms/publication/JCRSiteTree.java (original)
+++ lenya/sandbox/jcrsitetree/src/java/org/apache/lenya/cms/publication/JCRSiteTree.java Thu Apr 14 05:54:23 2005
@@ -19,10 +19,8 @@
package org.apache.lenya.cms.publication;
-import java.io.File;
import java.util.ArrayList;
import java.util.Date;
-import java.util.Hashtable;
import java.util.List;
import java.util.StringTokenizer;
@@ -47,14 +45,8 @@
import javax.jcr.observation.EventListener;
import javax.jcr.version.VersionException;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-
-import org.apache.jackrabbit.core.jndi.RegistryHelper;
-
import org.apache.log4j.Logger;
-
/**
* Sitetree implementation based on JSR-170.
*/
@@ -68,13 +60,13 @@
private final static String REPO_USER = "lenya";
// Namespace declarations.
- public static final String NS_URI_USER = "http://apache.org/cocoon/lenya/sitetree/1.0";
- public static final String NS_PREFIX_USER = "lust"; // lenya user site tree
- public static final String NS_URI_SYSTEM = "http://apache.org/cocoon/lenya/sitetree/system/1.0";
- public static final String NS_PREFIX_SYSTEM = "lst"; // lenya system site tree
+ public static final String NS_URI_USER = "http://apache.org/cocoon/lenya/jcr/usr/1.0";
+ public static final String NS_PREFIX_USER = "lpu"; // lenya publication user namespace
+ public static final String NS_URI_SYSTEM = "http://apache.org/cocoon/lenya/jcr/sys/1.0";
+ public static final String NS_PREFIX_SYSTEM = "lps"; // lenya publication system namespace
// Repository node names
- public static final String SITETREE_NAME = "site";
+ public static final String PUBLICATION_NAME = "publication";
public static final String DOCUMENT_NAME = "document";
protected static final String Q_CONTENT_NAME = "jcr:content";
@@ -83,28 +75,28 @@
protected static final String DOCUMENT_NT_NAME = "document";
protected static final String Q_CONTENT_NT_NAME = "jcr:content";
- public static final String REPOSITORY_HOME = "repos" + File.separator + "repo-sitetree";
+ private String prefixSys;
+ private String prefixUser;
- private String prefixSys = null;
- private String prefixUser = null;
-
- private static Repository repository = null;
- private Session session = null;
-
- private String workspace = null;
+ private Session session;
+
+ private String workspace;
+ private String publicationId;
/**
* Create a JCRSiteTree
*
- * @param pubDir the publication directory
- * @param area the area
+ * @param publication The publication this sitetree belongs to.
+ * @param area The area
*
* @throws SiteTreeException if an error occurs
*/
- protected JCRSiteTree(File pubDir, String area) throws SiteTreeException {
+ protected JCRSiteTree(Publication publication, String area) throws SiteTreeException {
this.workspace = area;
+ this.publicationId = publication.getId();
try {
- Repository repo = getRepository(pubDir.getAbsolutePath() + File.separator + REPOSITORY_HOME);
+ Repository repo = RepositoryFactory.getRepository(
+ publication.getServletContext().getAbsolutePath());
String userId = REPO_USER;
char[] password = "".toCharArray();
session = repo.login(new SimpleCredentials(userId, password), area);
@@ -113,19 +105,22 @@
if (prefixUser == null || prefixSys == null) {
throw new SiteTreeException("Unable to get namespace prefixes");
}
- Node siteNode = null;
- // Add sitetree root node if it does not exist already
- if (!session.getRootNode().hasNode(prefixSys + ":" + SITETREE_NAME)) {
- siteNode = session.getRootNode().addNode(prefixSys + ":" + SITETREE_NAME);
- session.save();
+ Node publicationNode = null;
+ if (!session.getRootNode().hasNode(prefixSys + ":" + PUBLICATION_NAME)) {
+ throw new SiteTreeException("Publication root path not found.");
+ } else if (!session.getRootNode().getNode(prefixSys + ":" + PUBLICATION_NAME).
+ hasNode(prefixUser + ":" + publication.getId())) {
+ throw new SiteTreeException("Publication '" + publication.getId() + "' not found.");
} else {
- siteNode = session.getRootNode().getNode(prefixSys + ":" + SITETREE_NAME);
+ publicationNode = session.getRootNode().getNode(prefixSys + ":" + PUBLICATION_NAME).
+ getNode(prefixUser + ":" + publication.getId());
}
- // Stay informed about workspace changes.
+
+ // Stay informed about publication modifications.
int eventFilter = Event.NODE_ADDED | Event.NODE_REMOVED | Event.PROPERTY_ADDED | Event.PROPERTY_CHANGED |
Event.PROPERTY_REMOVED;
session.getWorkspace().getObservationManager().
- addEventListener(this, eventFilter, siteNode.getPath(), true, null, null, false);
+ addEventListener(this, eventFilter, publicationNode.getPath(), true, null, null, false);
} catch (UnsupportedRepositoryOperationException e) {
throw new SiteTreeException("Could not register workspace event listener.", e);
} catch (RepositoryException e) {
@@ -227,6 +222,7 @@
// Try to clone node from authoring area.
if (clone(parentNode, id))
return;
+ // TODO: Delegate node creation to JCRSiteTreeNodeImpl
// Create node.
Node newNode = parentNode.addNode(prefixUser + ":" + id, prefixSys + ":" + NODE_NT_NAME);
// Add properties.
@@ -479,11 +475,8 @@
protected String mapDocumentIdToJCRAbsolute(String documentId) {
assert documentId != null;
- String mapping = "/" + prefixSys + ":" + SITETREE_NAME;
- StringTokenizer tokenizer = new StringTokenizer(documentId, "/");
- while (tokenizer.hasMoreTokens()) {
- mapping += "/" + prefixUser + ":" + tokenizer.nextToken();
- }
+ String mapping = "/" + prefixSys + ":" + PUBLICATION_NAME + "/" + prefixUser + ":" + publicationId;
+ mapping += mapDocumentIdToJCRRelative(documentId);
return mapping;
}
@@ -498,8 +491,9 @@
}
protected String mapJCRToDocumentId(String path) {
- String mapping = path.replaceAll(prefixUser + ":", "");
- mapping = mapping.replaceAll("/" + prefixSys + ":" + SITETREE_NAME, "");
+ String mapping = path.replaceAll("/" + prefixSys + ":" + PUBLICATION_NAME +
+ "/" + prefixUser + ":" + publicationId, "");
+ mapping = mapping.replaceAll(prefixUser + ":", "");
return mapping;
}
@@ -554,30 +548,6 @@
session.logout();
}
- /**
- * Get Repository
- * @param repHomeDir Path to repository
- */
- private static synchronized Repository getRepository(String repHomeDir) throws Exception {
- if (repository == null) {
- String configFile = repHomeDir + File.separator + "repository.xml";
-
- Hashtable env = new Hashtable();
- env.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.jackrabbit.core.jndi.provider.DummyInitialContextFactory");
- env.put(Context.PROVIDER_URL, "localhost");
- InitialContext ctx = new InitialContext(env);
-
- try {
- RegistryHelper.registerRepository(ctx, "repo", configFile, repHomeDir, true);
- } catch (Exception e) {
- e.printStackTrace();
- throw e;
- }
- repository = (Repository) ctx.lookup("repo");
- }
- return repository;
- }
-
public String getWorkspace() {
return workspace;
}
Added: lenya/sandbox/jcrsitetree/src/java/org/apache/lenya/cms/publication/RepositoryFactory.java
URL: http://svn.apache.org/viewcvs/lenya/sandbox/jcrsitetree/src/java/org/apache/lenya/cms/publication/RepositoryFactory.java?view=auto&rev=161268
==============================================================================
--- lenya/sandbox/jcrsitetree/src/java/org/apache/lenya/cms/publication/RepositoryFactory.java (added)
+++ lenya/sandbox/jcrsitetree/src/java/org/apache/lenya/cms/publication/RepositoryFactory.java Thu Apr 14 05:54:23 2005
@@ -0,0 +1,78 @@
+/*
+ * 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:$ */
+package org.apache.lenya.cms.publication;
+
+import java.io.File;
+import java.util.Hashtable;
+
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.apache.jackrabbit.core.jndi.RegistryHelper;
+import org.apache.log4j.Logger;
+
+/**
+ * Factory class for getting a JSR-170 repository.
+ */
+public class RepositoryFactory {
+ private static Logger log = Logger.getLogger(RepositoryFactory.class);
+
+ private static final String REPOSITORY_HOME = "lenya" + File.separator + "repository";
+ private static final String REPOSITORY_CONFIG = "repository.xml";
+ private static final String JNDI_REPOSITORY_NAME = "lenya-repository";
+
+
+ private static Repository repository = null;
+
+ public static synchronized Repository getRepository(String servletRootDir)
+ throws RepositoryFactoryException
+ {
+ if (repository == null) {
+ String repositoryHomeDir = servletRootDir + File.separator + REPOSITORY_HOME;
+ String configFile = repositoryHomeDir + File.separator + REPOSITORY_CONFIG;
+
+ Hashtable env = new Hashtable();
+ env.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.jackrabbit.core.jndi.provider.DummyInitialContextFactory");
+ env.put(Context.PROVIDER_URL, "localhost");
+ InitialContext ctx;
+ try {
+ ctx = new InitialContext(env);
+ } catch (NamingException e) {
+ throw new RepositoryFactoryException("Error creating initial context.", e);
+ }
+ try {
+ RegistryHelper.registerRepository(ctx, "lenya-repository", configFile,
+ repositoryHomeDir, false);
+ } catch (NamingException e) {
+ throw new RepositoryFactoryException("Unable to register repository.", e);
+ } catch (RepositoryException e) {
+ throw new RepositoryFactoryException("Repository exception.", e);
+ }
+ try {
+ repository = (Repository) ctx.lookup(JNDI_REPOSITORY_NAME);
+ } catch (NamingException e) {
+ throw new RepositoryFactoryException("Unable to look up repository.", e);
+ }
+ }
+ return repository;
+ }
+}
Added: lenya/sandbox/jcrsitetree/src/java/org/apache/lenya/cms/publication/RepositoryFactoryException.java
URL: http://svn.apache.org/viewcvs/lenya/sandbox/jcrsitetree/src/java/org/apache/lenya/cms/publication/RepositoryFactoryException.java?view=auto&rev=161268
==============================================================================
--- lenya/sandbox/jcrsitetree/src/java/org/apache/lenya/cms/publication/RepositoryFactoryException.java (added)
+++ lenya/sandbox/jcrsitetree/src/java/org/apache/lenya/cms/publication/RepositoryFactoryException.java Thu Apr 14 05:54:23 2005
@@ -0,0 +1,50 @@
+/*
+ * 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$ */
+
+package org.apache.lenya.cms.publication;
+
+/**
+ * RepositoryFactoryException.
+ */
+public class RepositoryFactoryException extends Exception {
+ /**
+ * Constructor.
+ * @param message
+ */
+ public RepositoryFactoryException(String message) {
+ super(message);
+ }
+
+ /**
+ * Constructor.
+ * @param cause
+ */
+ public RepositoryFactoryException(Throwable cause) {
+ super(cause);
+ }
+
+ /**
+ * Constructor.
+ * @param message
+ * @param cause
+ */
+ public RepositoryFactoryException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
Modified: lenya/sandbox/jcrsitetree/src/java/org/apache/lenya/cms/publication/SiteTreeFactory.java
URL: http://svn.apache.org/viewcvs/lenya/sandbox/jcrsitetree/src/java/org/apache/lenya/cms/publication/SiteTreeFactory.java?view=diff&r1=161267&r2=161268
==============================================================================
--- lenya/sandbox/jcrsitetree/src/java/org/apache/lenya/cms/publication/SiteTreeFactory.java (original)
+++ lenya/sandbox/jcrsitetree/src/java/org/apache/lenya/cms/publication/SiteTreeFactory.java Thu Apr 14 05:54:23 2005
@@ -19,8 +19,6 @@
package org.apache.lenya.cms.publication;
-import java.io.File;
-
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.log4j.Logger;
@@ -39,13 +37,13 @@
/**
* Get sitetree specified in config.
* @param config Configuration to read parameter from
- * @param pubDir Publication directory
+ * @param publication Publication
* @param area Area the sitetree is created for.
* @return SiteTree object
* @throws SiteTreeFactoryException
*/
- public static SiteTree getSiteTree(Configuration config, File pubDir, String area)
- throws SiteTreeFactoryException
+ public static SiteTree getSiteTree(Configuration config, Publication publication, String area)
+ throws SiteTreeFactoryException
{
assert config != null;
assert area != null;
@@ -75,11 +73,11 @@
try {
// TODO: look for an improved implementation for admin area
if (area.equals(Publication.ADMIN_AREA)) {
- sitetree = new DefaultSiteTree(pubDir, area);
+ sitetree = new DefaultSiteTree(publication.getDirectory(), area);
} else if (siteTreeClass.getName().equals(DEFAULT_SITETREE)) {
- sitetree = new DefaultSiteTree(pubDir, area);
+ sitetree = new DefaultSiteTree(publication.getDirectory(), area);
} else if (siteTreeClass.getName().equals(JCR_SITETREE)) {
- sitetree = new JCRSiteTree(pubDir, area);
+ sitetree = new JCRSiteTree(publication, area);
}
} catch (SiteTreeException e) {
throw new SiteTreeFactoryException("Unable to instantiate sitetree class.", e);
Modified: lenya/sandbox/jcrsitetree/src/java/org/apache/lenya/cms/publication/ViewRepository.java
URL: http://svn.apache.org/viewcvs/lenya/sandbox/jcrsitetree/src/java/org/apache/lenya/cms/publication/ViewRepository.java?view=diff&r1=161267&r2=161268
==============================================================================
--- lenya/sandbox/jcrsitetree/src/java/org/apache/lenya/cms/publication/ViewRepository.java (original)
+++ lenya/sandbox/jcrsitetree/src/java/org/apache/lenya/cms/publication/ViewRepository.java Thu Apr 14 05:54:23 2005
@@ -17,9 +17,6 @@
package org.apache.lenya.cms.publication;
-import java.io.File;
-import java.util.Hashtable;
-
import javax.jcr.Node;
import javax.jcr.NodeIterator;
import javax.jcr.Property;
@@ -29,10 +26,6 @@
import javax.jcr.Session;
import javax.jcr.SimpleCredentials;
import javax.jcr.Value;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-
-import org.apache.jackrabbit.core.jndi.RegistryHelper;
/**
* View content of a workspace.
@@ -45,14 +38,14 @@
*/
public static void main(String[] args) {
if (args.length != 2) {
- System.out.println("Usage: java org.apache.lenya.cms.publication.ViewRepository REPOSITORY_HOME WORKSPACE");
+ System.out.println("Usage: java org.apache.lenya.cms.publication.ViewRepository <SERVLET ROOT>");
return;
}
- String repoHomeDir = args[0];
+ String servletRoot = args[0];
String workspace = args[1];
- new ViewRepository().viewWorkspace(repoHomeDir, workspace);
+ new ViewRepository().viewWorkspace(servletRoot, workspace);
}
@@ -60,10 +53,10 @@
* @param repoHomeDir
* @param workspace
*/
- public void viewWorkspace(String repoHomeDir, String workspace) {
- System.out.println("View workspace " + workspace + " in repository " + repoHomeDir);
+ public void viewWorkspace(String servletRoot, String workspace) {
+ System.out.println("View workspace " + workspace + " in repository " + servletRoot);
try {
- Repository repo = getRepository(repoHomeDir);
+ Repository repo = RepositoryFactory.getRepository(servletRoot);
Session session = repo.login(new SimpleCredentials(REPO_USER, "".toCharArray()), workspace);
String[] prefixes = session.getNamespacePrefixes();
for (int i = 0; i < prefixes.length; i++) {
@@ -112,22 +105,5 @@
}
}
- }
-
- /**
- * @param repHomeDir
- * @return
- * @throws Exception
- */
- private Repository getRepository(String repHomeDir) throws Exception {
- String configFile = repHomeDir + File.separator + "repository.xml";
-
- Hashtable env = new Hashtable();
- env.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.jackrabbit.core.jndi.provider.DummyInitialContextFactory");
- env.put(Context.PROVIDER_URL, "localhost");
- InitialContext ctx = new InitialContext(env);
-
- RegistryHelper.registerRepository(ctx, "repo", configFile, repHomeDir, true);
- return (Repository) ctx.lookup("repo");
}
}
Modified: lenya/sandbox/jcrsitetree/src/webapp/lenya/pubs/default/config/publication.xconf
URL: http://svn.apache.org/viewcvs/lenya/sandbox/jcrsitetree/src/webapp/lenya/pubs/default/config/publication.xconf?view=diff&r1=161267&r2=161268
==============================================================================
--- lenya/sandbox/jcrsitetree/src/webapp/lenya/pubs/default/config/publication.xconf (original)
+++ lenya/sandbox/jcrsitetree/src/webapp/lenya/pubs/default/config/publication.xconf Thu Apr 14 05:54:23 2005
@@ -22,15 +22,26 @@
<language default="true">en</language>
<language>de</language>
</languages>
-<!--
- <site-tree>org.apache.lenya.cms.publication.DefaultSiteTree</site-tree>
--->
- <site-tree>org.apache.lenya.cms.publication.JCRSiteTree</site-tree>
+
<path-mapper>org.apache.lenya.cms.publication.DefaultDocumentIdToPathMapper</path-mapper>
-<!--
- <document-builder>org.apache.lenya.cms.publication.DefaultDocumentBuilder</document-builder>
--->
+
+ <!--
+ | Set sitetree implementation used for this publication.
+ | Default is to use DefaultSiteTree if not set.
+ | Currently available sitetree implementations:
+ | - org.apache.lenya.cms.publication.DefaultSiteTree (default) (based on DOM)
+ | - org.apache.lenya.cms.publication.JCRSiteTree (based on Jackrabbit)
+ -->
+ <site-tree>org.apache.lenya.cms.publication.JCRSiteTree</site-tree>
+
+ <!--
+ | Set document builder implementation used for this publication.
+ | Currently available document builder implementations:
+ | - org.apache.lenya.cms.publication.DefaultDocumentBuilder (default)
+ | - org.apache.lenya.cms.publication.JCRDocumentBuilder (for sitetrees based on Jackrabbit)
+ -->
<document-builder>org.apache.lenya.cms.publication.JCRDocumentBuilder</document-builder>
+
<breadcrumb-prefix/>
<!--
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org