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 2006/02/03 16:52:28 UTC
svn commit: r374695 - in /lenya/trunk/src/modules: jcr/config/
jcr/java/src/org/apache/lenya/cms/jcr/metadata/
jcr/java/src/org/apache/lenya/cms/jcr/usecases/ jcr/usecases/ jcrsource/
jcrsource/config/ jcrsource/config/cocoon-xconf/ jcrsource/java/ jcr...
Author: andreas
Date: Fri Feb 3 07:52:11 2006
New Revision: 374695
URL: http://svn.apache.org/viewcvs?rev=374695&view=rev
Log:
Moved JCRSourceNode related code to jcrsource module, restored JCRSourceNode related classes
Added:
lenya/trunk/src/modules/jcrsource/
lenya/trunk/src/modules/jcrsource/config/
- copied from r374661, lenya/trunk/src/modules/jcr/config/
lenya/trunk/src/modules/jcrsource/config/cocoon-xconf/repository.xconf
lenya/trunk/src/modules/jcrsource/config/cocoon-xconf/sourcefactory.xconf
lenya/trunk/src/modules/jcrsource/java/
lenya/trunk/src/modules/jcrsource/java/src/
lenya/trunk/src/modules/jcrsource/java/src/org/
lenya/trunk/src/modules/jcrsource/java/src/org/apache/
lenya/trunk/src/modules/jcrsource/java/src/org/apache/lenya/
lenya/trunk/src/modules/jcrsource/java/src/org/apache/lenya/cms/
lenya/trunk/src/modules/jcrsource/java/src/org/apache/lenya/cms/jcr/
lenya/trunk/src/modules/jcrsource/java/src/org/apache/lenya/cms/jcr/JCRNodeFactory.java
lenya/trunk/src/modules/jcrsource/java/src/org/apache/lenya/cms/jcr/JCRSourceNode.java
lenya/trunk/src/modules/jcrsource/java/src/org/apache/lenya/cms/jcr/LenyaJCRSourceFactory.java
lenya/trunk/src/modules/jcrsource/java/src/org/apache/lenya/cms/jcr/LenyaRepository.java
lenya/trunk/src/modules/jcrsource/java/src/org/apache/lenya/cms/jcr/metadata/
- copied from r374661, lenya/trunk/src/modules/jcr/java/src/org/apache/lenya/cms/jcr/metadata/
lenya/trunk/src/modules/jcrsource/java/src/org/apache/lenya/cms/jcr/usecases/
- copied from r374661, lenya/trunk/src/modules/jcr/java/src/org/apache/lenya/cms/jcr/usecases/
lenya/trunk/src/modules/jcrsource/sitemap.xmap
lenya/trunk/src/modules/jcrsource/usecases/
- copied from r374661, lenya/trunk/src/modules/jcr/usecases/
Removed:
lenya/trunk/src/modules/jcr/config/
lenya/trunk/src/modules/jcr/java/src/org/apache/lenya/cms/jcr/metadata/
lenya/trunk/src/modules/jcr/java/src/org/apache/lenya/cms/jcr/usecases/
lenya/trunk/src/modules/jcr/usecases/
lenya/trunk/src/modules/jcrsource/java/src/org/apache/lenya/cms/jcr/metadata/JCRMetaData.java
lenya/trunk/src/modules/jcrsource/usecases/importExport/usecase.xmap
Modified:
lenya/trunk/src/modules/jcrsource/config/cocoon-xconf/usecase-export.xconf
lenya/trunk/src/modules/jcrsource/config/cocoon-xconf/usecase-import.xconf
lenya/trunk/src/modules/jcrsource/config/cocoon-xconf/usecase-importExport.xconf
lenya/trunk/src/modules/jcrsource/java/src/org/apache/lenya/cms/jcr/usecases/Import.java
Added: lenya/trunk/src/modules/jcrsource/config/cocoon-xconf/repository.xconf
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/modules/jcrsource/config/cocoon-xconf/repository.xconf?rev=374695&view=auto
==============================================================================
--- lenya/trunk/src/modules/jcrsource/config/cocoon-xconf/repository.xconf (added)
+++ lenya/trunk/src/modules/jcrsource/config/cocoon-xconf/repository.xconf Fri Feb 3 07:52:11 2006
@@ -0,0 +1,36 @@
+<?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: doctypes.xconf 164635 2005-04-25 20:01:43Z tschlabach $ -->
+
+ <xconf xpath="/cocoon"
+ remove="/cocoon/component[@role = 'javax.jcr.Repository']"
+ unless="/cocoon/component[@role = 'javax.jcr.Repository'][@class = 'org.apache.lenya.cms.jcr.LenyaRepository']">
+
+ <component class="org.apache.lenya.cms.jcr.LenyaRepository" logger="jcr" role="javax.jcr.Repository">
+ <credentials login="anonymous" password=""/>
+ <jaas src="context://jcr-repository/jaas.config"/>
+ <home src="context://jcr-repository/repository"/>
+ <configuration src="context://jcr-repository/repository.xml"/>
+
+ <namespace prefix="dc" uri="http://purl.org/dc/elements/1.1/"/>
+ <namespace prefix="dcterms" uri="http://purl.org/dc/terms/"/>
+ <namespace prefix="lenya" uri="http://apache.org/cocoon/lenya/page-envelope/1.0"/>
+ </component>
+
+ </xconf>
+
\ No newline at end of file
Added: lenya/trunk/src/modules/jcrsource/config/cocoon-xconf/sourcefactory.xconf
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/modules/jcrsource/config/cocoon-xconf/sourcefactory.xconf?rev=374695&view=auto
==============================================================================
--- lenya/trunk/src/modules/jcrsource/config/cocoon-xconf/sourcefactory.xconf (added)
+++ lenya/trunk/src/modules/jcrsource/config/cocoon-xconf/sourcefactory.xconf Fri Feb 3 07:52:11 2006
@@ -0,0 +1,38 @@
+<?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: doctypes.xconf 164635 2005-04-25 20:01:43Z tschlabach $ -->
+
+ <xconf xpath="/cocoon/source-factories"
+ remove="/cocoon/source-factories/component-instance[@name = 'jcr']"
+ unless="/cocoon/source-factories/component-instance[@name = 'jcr'][@class = 'org.apache.lenya.cms.jcr.LenyaJCRSourceFactory']">
+
+ <component-instance class="org.apache.lenya.cms.jcr.LenyaJCRSourceFactory" name="jcr">
+ <folder-node new-file="nt:file" new-folder="nt:folder" type="rep:root"/>
+ <folder-node new-file="nt:file" new-folder="nt:unstructured" type="nt:unstructured"/>
+ <folder-node type="nt:folder" new-file="nt:file"/>
+ <file-node content-path="jcr:content" content-type="nt:resource" type="nt:file"/>
+ <file-node content-ref="jcr:content" type="nt:linkedFile"/>
+ <content-node type="nt:resource"
+ content-prop="jcr:data"
+ mimetype-prop="jcr:mimeType"
+ lastmodified-prop="jcr:lastModified"
+ validity-prop="jcr:lastModified"/>
+ </component-instance>
+
+ </xconf>
+
\ No newline at end of file
Modified: lenya/trunk/src/modules/jcrsource/config/cocoon-xconf/usecase-export.xconf
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/modules/jcrsource/config/cocoon-xconf/usecase-export.xconf?rev=374695&r1=374661&r2=374695&view=diff
==============================================================================
--- lenya/trunk/src/modules/jcrsource/config/cocoon-xconf/usecase-export.xconf (original)
+++ lenya/trunk/src/modules/jcrsource/config/cocoon-xconf/usecase-export.xconf Fri Feb 3 07:52:11 2006
@@ -21,7 +21,7 @@
<component-instance name="jcr.export" logger="lenya.jcr"
class="org.apache.lenya.cms.usecase.DummyUsecase">
- <view uri="/core/modules/jcr/importExport/lenya-repository-content.xml" menu="false"/>
+ <view uri="cocoon://modules/jcrsource/lenya-repository-content.xml" menu="false"/>
</component-instance>
</xconf>
Modified: lenya/trunk/src/modules/jcrsource/config/cocoon-xconf/usecase-import.xconf
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/modules/jcrsource/config/cocoon-xconf/usecase-import.xconf?rev=374695&r1=374661&r2=374695&view=diff
==============================================================================
--- lenya/trunk/src/modules/jcrsource/config/cocoon-xconf/usecase-import.xconf (original)
+++ lenya/trunk/src/modules/jcrsource/config/cocoon-xconf/usecase-import.xconf Fri Feb 3 07:52:11 2006
@@ -21,7 +21,7 @@
<component-instance name="jcr.import" logger="lenya.jcr"
class="org.apache.lenya.cms.jcr.usecases.Import">
- <view template="modules/jcr/usecases/import.jx" menu="false"/>
+ <view template="modules/jcrsource/usecases/import.jx" menu="false"/>
</component-instance>
</xconf>
Modified: lenya/trunk/src/modules/jcrsource/config/cocoon-xconf/usecase-importExport.xconf
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/modules/jcrsource/config/cocoon-xconf/usecase-importExport.xconf?rev=374695&r1=374661&r2=374695&view=diff
==============================================================================
--- lenya/trunk/src/modules/jcrsource/config/cocoon-xconf/usecase-importExport.xconf (original)
+++ lenya/trunk/src/modules/jcrsource/config/cocoon-xconf/usecase-importExport.xconf Fri Feb 3 07:52:11 2006
@@ -21,7 +21,7 @@
<component-instance name="jcr.importExport" logger="lenya.jcr"
class="org.apache.lenya.cms.jcr.usecases.JCRImport">
- <view template="modules/jcr/usecases/importExport/importExport.jx" menu="true">
+ <view template="modules/jcrsource/usecases/importExport/importExport.jx" menu="true">
<tab group="admin" name="jcr"/>
</view>
</component-instance>
Added: lenya/trunk/src/modules/jcrsource/java/src/org/apache/lenya/cms/jcr/JCRNodeFactory.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/modules/jcrsource/java/src/org/apache/lenya/cms/jcr/JCRNodeFactory.java?rev=374695&view=auto
==============================================================================
--- lenya/trunk/src/modules/jcrsource/java/src/org/apache/lenya/cms/jcr/JCRNodeFactory.java (added)
+++ lenya/trunk/src/modules/jcrsource/java/src/org/apache/lenya/cms/jcr/JCRNodeFactory.java Fri Feb 3 07:52:11 2006
@@ -0,0 +1,54 @@
+/*
+ * 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 org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.service.Serviceable;
+import org.apache.lenya.cms.repository.Node;
+import org.apache.lenya.cms.repository.NodeFactory;
+import org.apache.lenya.cms.repository.Session;
+import org.apache.lenya.transaction.Identifiable;
+import org.apache.lenya.transaction.IdentityMap;
+
+/**
+ * JCR node factory.
+ */
+public class JCRNodeFactory extends AbstractLogEnabled implements NodeFactory, Serviceable {
+
+ public Identifiable build(IdentityMap map, String key) throws Exception {
+ return new JCRSourceNode(this.session, key, this.manager, getLogger());
+ }
+
+ public String getType() {
+ return Node.IDENTIFIABLE_TYPE;
+ }
+
+ private ServiceManager manager;
+
+ public void service(ServiceManager manager) throws ServiceException {
+ this.manager = manager;
+ }
+
+ private Session session;
+
+ public void setSession(Session session) {
+ this.session = session;
+ }
+
+}
\ No newline at end of file
Added: lenya/trunk/src/modules/jcrsource/java/src/org/apache/lenya/cms/jcr/JCRSourceNode.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/modules/jcrsource/java/src/org/apache/lenya/cms/jcr/JCRSourceNode.java?rev=374695&view=auto
==============================================================================
--- lenya/trunk/src/modules/jcrsource/java/src/org/apache/lenya/cms/jcr/JCRSourceNode.java (added)
+++ lenya/trunk/src/modules/jcrsource/java/src/org/apache/lenya/cms/jcr/JCRSourceNode.java Fri Feb 3 07:52:11 2006
@@ -0,0 +1,71 @@
+/*
+ * 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 org.apache.avalon.framework.logger.Logger;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.lenya.cms.jcr.metadata.JCRMetaDataManager;
+import org.apache.lenya.cms.metadata.MetaDataManager;
+import org.apache.lenya.cms.publication.DocumentException;
+import org.apache.lenya.cms.repository.RepositoryException;
+import org.apache.lenya.cms.repository.Session;
+import org.apache.lenya.cms.repository.SourceNode;
+
+/**
+ * JCR based source node.
+ */
+public class JCRSourceNode extends SourceNode {
+
+ private String sourceUri;
+
+ /**
+ * Ctor.
+ * @param session The session.
+ * @param sourceURI The source URI.
+ * @param manager The service manager.
+ * @param logger The logger.
+ */
+ public JCRSourceNode(Session session, String sourceURI, ServiceManager manager, Logger logger) {
+ super(session, sourceURI, manager, logger);
+ this.sourceUri = sourceURI;
+ }
+
+ /**
+ * @see org.apache.lenya.cms.repository.SourceNode#getRealSourceURI()
+ */
+ protected String getRealSourceURI() {
+ String path = this.sourceUri.substring(LENYA_PROTOCOL.length());
+ return "jcr://" + path;
+ }
+
+ private MetaDataManager metaDataManager;
+
+ public MetaDataManager getMetaDataManager() throws DocumentException {
+ if (this.metaDataManager == null) {
+ this.metaDataManager = new JCRMetaDataManager(getRealSourceURI(), this.manager, getLogger());
+ }
+ return this.metaDataManager;
+ }
+
+ /**
+ * No separate meta data node, so no locking is required.
+ * @see org.apache.lenya.cms.repository.SourceNode#lockMetaData()
+ */
+ protected void lockMetaData() throws RepositoryException {
+ }
+
+}
Added: lenya/trunk/src/modules/jcrsource/java/src/org/apache/lenya/cms/jcr/LenyaJCRSourceFactory.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/modules/jcrsource/java/src/org/apache/lenya/cms/jcr/LenyaJCRSourceFactory.java?rev=374695&view=auto
==============================================================================
--- lenya/trunk/src/modules/jcrsource/java/src/org/apache/lenya/cms/jcr/LenyaJCRSourceFactory.java (added)
+++ lenya/trunk/src/modules/jcrsource/java/src/org/apache/lenya/cms/jcr/LenyaJCRSourceFactory.java Fri Feb 3 07:52:11 2006
@@ -0,0 +1,50 @@
+/*
+ * 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.Node;
+import javax.jcr.RepositoryException;
+
+import org.apache.cocoon.jcr.source.JCRSourceFactory;
+import org.apache.lenya.cms.metadata.LenyaMetaData;
+
+public class LenyaJCRSourceFactory extends JCRSourceFactory {
+
+ public Node createFileNode(Node folderNode, String name) throws RepositoryException {
+ Node node = super.createFileNode(folderNode, name);
+ String prefix = node.getSession().getNamespacePrefix(LenyaMetaData.NAMESPACE);
+ if (!prefix.equals("")) {
+ prefix = prefix + ":";
+ }
+
+ node.addMixin(prefix + LenyaRepository.CONTENT_NODE);
+ return node;
+ }
+/*
+ public Node createContentNode(Node fileNode) throws RepositoryException {
+ Node node = super.createContentNode(fileNode);
+
+ String prefix = node.getSession().getNamespacePrefix(LenyaMetaData.NAMESPACE);
+ if (!prefix.equals("")) {
+ prefix = prefix + ":";
+ }
+
+ node.addMixin(prefix + LenyaRepository.CONTENT_NODE);
+ return node;
+ }
+*/
+}
Added: lenya/trunk/src/modules/jcrsource/java/src/org/apache/lenya/cms/jcr/LenyaRepository.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/modules/jcrsource/java/src/org/apache/lenya/cms/jcr/LenyaRepository.java?rev=374695&view=auto
==============================================================================
--- lenya/trunk/src/modules/jcrsource/java/src/org/apache/lenya/cms/jcr/LenyaRepository.java (added)
+++ lenya/trunk/src/modules/jcrsource/java/src/org/apache/lenya/cms/jcr/LenyaRepository.java Fri Feb 3 07:52:11 2006
@@ -0,0 +1,169 @@
+/*
+ * 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 java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.jcr.AccessDeniedException;
+import javax.jcr.LoginException;
+import javax.jcr.NamespaceException;
+import javax.jcr.NamespaceRegistry;
+import javax.jcr.NoSuchWorkspaceException;
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.UnsupportedRepositoryOperationException;
+
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.cocoon.components.ContextHelper;
+import org.apache.cocoon.environment.ObjectModelHelper;
+import org.apache.cocoon.environment.Request;
+import org.apache.cocoon.environment.Session;
+import org.apache.jackrabbit.core.nodetype.InvalidNodeTypeDefException;
+import org.apache.jackrabbit.core.nodetype.NodeTypeDef;
+import org.apache.jackrabbit.core.nodetype.NodeTypeManagerImpl;
+import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
+import org.apache.jackrabbit.core.nodetype.PropDef;
+import org.apache.jackrabbit.core.nodetype.PropDefImpl;
+import org.apache.jackrabbit.name.QName;
+import org.apache.lenya.cms.metadata.LenyaMetaData;
+import org.apache.lenya.cms.metadata.dublincore.DublinCoreImpl;
+
+/**
+ * Lenya-specific repository implementation.
+ */
+public class LenyaRepository extends org.apache.cocoon.jcr.JackrabbitRepository {
+
+ protected static final String CONTENT_NODE = "contentNode";
+
+ protected static final String SESSION_ATTRIBUTE = javax.jcr.Session.class.getName();
+
+ private Map namespaces = new HashMap();
+
+ /**
+ * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
+ */
+ public void configure(Configuration config) throws ConfigurationException {
+ super.configure(config);
+
+ Configuration[] namespaceConfigs = config.getChildren("namespace");
+ for (int i = 0; i < namespaceConfigs.length; i++) {
+ String prefix = namespaceConfigs[i].getAttribute("prefix");
+ String uri = namespaceConfigs[i].getAttribute("uri");
+ this.namespaces.put(prefix, uri);
+ }
+ }
+
+ /**
+ * @see javax.jcr.Repository#login()
+ */
+ public javax.jcr.Session login() throws LoginException, NoSuchWorkspaceException,
+ RepositoryException {
+
+ javax.jcr.Session jcrSession = null;
+
+ Map objectModel = ContextHelper.getObjectModel(this.context);
+ Request request = ObjectModelHelper.getRequest(objectModel);
+ Session session = request.getSession(false);
+ if (session != null) {
+ jcrSession = (javax.jcr.Session) session.getAttribute(SESSION_ATTRIBUTE);
+ if (jcrSession == null) {
+ jcrSession = super.login();
+ session.setAttribute(SESSION_ATTRIBUTE, jcrSession);
+
+ registerNamespaces(jcrSession);
+ try {
+ registerNodeTypes(jcrSession);
+ } catch (InvalidNodeTypeDefException e) {
+ throw new RepositoryException(e);
+ }
+ }
+ }
+
+ return jcrSession;
+ }
+
+ /**
+ * Registers the Lenya-specific namespaces at the JCR workspace.
+ * @param jcrSession The JCR session.
+ * @throws RepositoryException if an error occurs.
+ * @throws NamespaceException if an error occurs.
+ * @throws UnsupportedRepositoryOperationException if an error occurs.
+ * @throws AccessDeniedException if an error occurs.
+ */
+ protected void registerNamespaces(javax.jcr.Session jcrSession) throws RepositoryException,
+ NamespaceException, UnsupportedRepositoryOperationException, AccessDeniedException {
+ for (Iterator i = this.namespaces.keySet().iterator(); i.hasNext();) {
+ String prefix = (String) i.next();
+ String uri = (String) this.namespaces.get(prefix);
+ NamespaceRegistry registry = jcrSession.getWorkspace().getNamespaceRegistry();
+ if (!Arrays.asList(registry.getPrefixes()).contains(prefix)) {
+ registry.registerNamespace(prefix, uri);
+ }
+ }
+ }
+
+ protected void registerNodeTypes(javax.jcr.Session jcrSession) throws RepositoryException,
+ InvalidNodeTypeDefException {
+
+ NodeTypeManagerImpl nodeTypeManager = (NodeTypeManagerImpl) jcrSession.getWorkspace()
+ .getNodeTypeManager();
+ NodeTypeRegistry registry = nodeTypeManager.getNodeTypeRegistry();
+ if (!registry.isRegistered(new QName(LenyaMetaData.NAMESPACE, CONTENT_NODE))) {
+
+ List propDefs = new ArrayList();
+ Map key2namespace = new HashMap();
+
+ String[] lenyaKeys = LenyaMetaData.ELEMENTS;
+ for (int i = 0; i < lenyaKeys.length; i++) {
+ key2namespace.put(lenyaKeys[i], LenyaMetaData.NAMESPACE);
+ }
+
+ List dcKeyList = DublinCoreImpl.getAttributeNames();
+ String[] dcKeys = (String[]) dcKeyList.toArray(new String[dcKeyList.size()]);
+ for (int i = 0; i < dcKeys.length; i++) {
+ key2namespace.put(dcKeys[i], DublinCoreImpl.DC_NAMESPACE);
+ }
+
+ NodeTypeDef def = new NodeTypeDef();
+ def.setMixin(true);
+ def.setName(new QName(LenyaMetaData.NAMESPACE, CONTENT_NODE));
+
+ for (Iterator i = key2namespace.keySet().iterator(); i.hasNext();) {
+ String key = (String) i.next();
+ String namespace = (String) key2namespace.get(key);
+ PropDefImpl propDef = new PropDefImpl();
+ propDef.setDeclaringNodeType(def.getName());
+ propDef.setName(new QName(namespace, key));
+ propDef.setMandatory(false);
+ propDef.setRequiredType(PropertyType.STRING);
+ propDef.setMultiple(true);
+ propDefs.add(propDef);
+ }
+
+ def.setPropertyDefs((PropDef[]) propDefs.toArray(new PropDef[propDefs.size()]));
+
+ registry.registerNodeType(def);
+ }
+ }
+
+}
Modified: lenya/trunk/src/modules/jcrsource/java/src/org/apache/lenya/cms/jcr/usecases/Import.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/modules/jcrsource/java/src/org/apache/lenya/cms/jcr/usecases/Import.java?rev=374695&r1=374661&r2=374695&view=diff
==============================================================================
--- lenya/trunk/src/modules/jcrsource/java/src/org/apache/lenya/cms/jcr/usecases/Import.java (original)
+++ lenya/trunk/src/modules/jcrsource/java/src/org/apache/lenya/cms/jcr/usecases/Import.java Fri Feb 3 07:52:11 2006
@@ -81,7 +81,9 @@
final String lenyaUri = docs[j].getSourceURI();
final String sourcePath = lenyaUri.substring("lenya://".length());
final String contextUri = "context://" + sourcePath + ".meta";
- MetaDataManager meta = new MetaDataManager(contextUri, this.manager, getLogger());
+ MetaDataManager meta = new MetaDataManager(contextUri,
+ this.manager,
+ getLogger());
uri2meta.put(docs[j].getSourceURI(), meta);
}
nodes.add(siteManager.getSiteStructure(map, pub, areas[i]).getRepositoryNode());
@@ -93,14 +95,18 @@
final String sourcePath = lenyaUri.substring("lenya://".length());
final String contextUri = "context://" + sourcePath;
final String jcrUri = "jcr://" + sourcePath;
- SourceUtil.copy(resolver, contextUri, jcrUri);
+ if (SourceUtil.exists(contextUri, this.manager)) {
+ SourceUtil.copy(resolver, contextUri, jcrUri);
- MetaDataManager sourceMgr = (MetaDataManager) uri2meta.get(lenyaUri);
- if (sourceMgr != null) {
- MetaDataManager jcrMgr = new JCRMetaDataManager(jcrUri,
- this.manager,
- getLogger());
- jcrMgr.replaceMetaData(sourceMgr);
+ MetaDataManager sourceMgr = (MetaDataManager) uri2meta.get(lenyaUri);
+ if (sourceMgr != null) {
+ MetaDataManager jcrMgr = new JCRMetaDataManager(jcrUri,
+ this.manager,
+ getLogger());
+ jcrMgr.replaceMetaData(sourceMgr);
+ }
+ } else {
+ addInfoMessage("The source [" + contextUri + "] does not exist.");
}
}
Added: lenya/trunk/src/modules/jcrsource/sitemap.xmap
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/modules/jcrsource/sitemap.xmap?rev=374695&view=auto
==============================================================================
--- lenya/trunk/src/modules/jcrsource/sitemap.xmap (added)
+++ lenya/trunk/src/modules/jcrsource/sitemap.xmap Fri Feb 3 07:52:11 2006
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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$ -->
+
+<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
+
+ <map:components>
+ <map:generators default="file">
+ <map:generator name="jcr-sys-view" label="content,data" logger="sitemap.generator.jcr-sys-view" pool-grow="2" pool-max="5" pool-min="2" src="org.apache.lenya.cms.cocoon.generation.JCRSysViewGenerator"/>
+ </map:generators>
+ </map:components>
+
+ <map:pipelines>
+
+ <map:pipeline>
+
+ <map:match pattern="lenya-repository-content.xml">
+ <map:select type="parameter">
+ <map:parameter name="parameter-selector-test" value="{request-param:scope}"/>
+ <map:when test="repository">
+ <map:generate type="jcr-sys-view">
+ <map:parameter name="root" value="/lenya"/>
+ </map:generate>
+ </map:when>
+ <map:otherwise>
+ <map:generate type="jcr-sys-view">
+ <map:parameter name="root" value="/lenya/pubs/{page-envelope:publication-id}"/>
+ </map:generate>
+ </map:otherwise>
+ </map:select>
+ <map:serialize type="xml"/>
+ </map:match>
+
+ </map:pipeline>
+
+ </map:pipelines>
+
+</map:sitemap>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org