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 2007/04/11 17:22:14 UTC
svn commit: r527520 - in /lenya/trunk/src:
impl/test/org/apache/lenya/cms/publication/util/
java/org/apache/lenya/cms/publication/
java/org/apache/lenya/cms/publication/util/
java/org/apache/lenya/cms/site/simple/ modules/collection/
modules/collection...
Author: andreas
Date: Wed Apr 11 08:22:11 2007
New Revision: 527520
URL: http://svn.apache.org/viewvc?view=rev&rev=527520
Log:
Refactoring: moved SimpleSiteManager to module, moved collection classes to collection module; Made number of news items to appear on overview page configurable
Added:
lenya/trunk/src/modules/collection/java/
lenya/trunk/src/modules/collection/java/src/
lenya/trunk/src/modules/collection/java/src/org/
lenya/trunk/src/modules/collection/java/src/org/apache/
lenya/trunk/src/modules/collection/java/src/org/apache/lenya/
lenya/trunk/src/modules/collection/java/src/org/apache/lenya/modules/
lenya/trunk/src/modules/collection/java/src/org/apache/lenya/modules/collection/
lenya/trunk/src/modules/collection/java/src/org/apache/lenya/modules/collection/CollectionWrapper.java
lenya/trunk/src/modules/collection/java/test/
lenya/trunk/src/modules/collection/java/test/org/
lenya/trunk/src/modules/collection/java/test/org/apache/
lenya/trunk/src/modules/collection/java/test/org/apache/lenya/
lenya/trunk/src/modules/collection/java/test/org/apache/lenya/modules/
lenya/trunk/src/modules/collection/java/test/org/apache/lenya/modules/collection/
lenya/trunk/src/modules/collection/java/test/org/apache/lenya/modules/collection/CollectionWrapperTest.java
lenya/trunk/src/modules/news/config/cocoon-xconf/usecase-news-edit.xconf
lenya/trunk/src/modules/news/java/
lenya/trunk/src/modules/news/java/src/
lenya/trunk/src/modules/news/java/src/org/
lenya/trunk/src/modules/news/java/src/org/apache/
lenya/trunk/src/modules/news/java/src/org/apache/lenya/
lenya/trunk/src/modules/news/java/src/org/apache/lenya/modules/
lenya/trunk/src/modules/news/java/src/org/apache/lenya/modules/news/
lenya/trunk/src/modules/news/java/src/org/apache/lenya/modules/news/NewsWrapper.java
lenya/trunk/src/modules/news/java/src/org/apache/lenya/modules/news/usecases/
lenya/trunk/src/modules/news/java/src/org/apache/lenya/modules/news/usecases/Edit.java
lenya/trunk/src/modules/news/usecases/
lenya/trunk/src/modules/news/usecases/edit.jx
lenya/trunk/src/modules/simplesite/
lenya/trunk/src/modules/simplesite/config/
lenya/trunk/src/modules/simplesite/config/cocoon-xconf/
lenya/trunk/src/modules/simplesite/config/cocoon-xconf/site-managers.xconf
- copied, changed from r527065, lenya/trunk/src/webapp/lenya/config/cocoon-xconf/misc/site-managers.xconf
lenya/trunk/src/modules/simplesite/java/
lenya/trunk/src/modules/simplesite/java/src/
lenya/trunk/src/modules/simplesite/java/src/org/
lenya/trunk/src/modules/simplesite/java/src/org/apache/
lenya/trunk/src/modules/simplesite/java/src/org/apache/lenya/
lenya/trunk/src/modules/simplesite/java/src/org/apache/lenya/cms/
lenya/trunk/src/modules/simplesite/java/src/org/apache/lenya/cms/site/
lenya/trunk/src/modules/simplesite/java/src/org/apache/lenya/cms/site/simple/
lenya/trunk/src/modules/simplesite/java/src/org/apache/lenya/cms/site/simple/DocumentStore.java
- copied, changed from r527065, lenya/trunk/src/java/org/apache/lenya/cms/site/simple/DocumentStore.java
lenya/trunk/src/modules/simplesite/java/src/org/apache/lenya/cms/site/simple/DocumentStoreFactory.java
- copied, changed from r527065, lenya/trunk/src/java/org/apache/lenya/cms/site/simple/DocumentStoreFactory.java
lenya/trunk/src/modules/simplesite/java/src/org/apache/lenya/cms/site/simple/SimpleLink.java
- copied unchanged from r527065, lenya/trunk/src/java/org/apache/lenya/cms/site/simple/SimpleLink.java
lenya/trunk/src/modules/simplesite/java/src/org/apache/lenya/cms/site/simple/SimpleSiteManager.java
- copied unchanged from r527065, lenya/trunk/src/java/org/apache/lenya/cms/site/simple/SimpleSiteManager.java
lenya/trunk/src/modules/simplesite/java/src/org/apache/lenya/cms/site/simple/SimpleSiteNode.java
- copied unchanged from r527065, lenya/trunk/src/java/org/apache/lenya/cms/site/simple/SimpleSiteNode.java
lenya/trunk/src/modules/simplesite/module.xml
Removed:
lenya/trunk/src/impl/test/org/apache/lenya/cms/publication/util/XLinkCollectionTest.java
lenya/trunk/src/java/org/apache/lenya/cms/publication/util/CollectionImpl.java
lenya/trunk/src/java/org/apache/lenya/cms/publication/util/XlinkCollection.java
lenya/trunk/src/java/org/apache/lenya/cms/site/simple/DocumentStore.java
lenya/trunk/src/java/org/apache/lenya/cms/site/simple/DocumentStoreFactory.java
lenya/trunk/src/java/org/apache/lenya/cms/site/simple/SimpleLink.java
lenya/trunk/src/java/org/apache/lenya/cms/site/simple/SimpleSiteManager.java
lenya/trunk/src/java/org/apache/lenya/cms/site/simple/SimpleSiteNode.java
Modified:
lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentManager.java
lenya/trunk/src/java/org/apache/lenya/cms/publication/util/Collection.java
lenya/trunk/src/modules/collection/module.xml
lenya/trunk/src/modules/news/config/menu.xsp
lenya/trunk/src/modules/news/resources/i18n/cmsui.xml
lenya/trunk/src/modules/news/resources/i18n/cmsui_de.xml
lenya/trunk/src/pubs/blog/sitemap.xmap
lenya/trunk/src/pubs/default/config/ac/usecase-policies.xml
lenya/trunk/src/pubs/default/example-content/news/index_de
lenya/trunk/src/pubs/default/example-content/news/index_en
lenya/trunk/src/webapp/lenya/config/cocoon-xconf/misc/site-managers.xconf
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentManager.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentManager.java?view=diff&rev=527520&r1=527519&r2=527520
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentManager.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentManager.java Wed Apr 11 08:22:11 2007
@@ -120,7 +120,6 @@
* @param contentSourceUri The URI to read the content from.
* @param pub The publication.
* @param area The area.
- * @param path The path.
* @param language The language.
* @param extension The extension to use for the document source, without the leading dot.
* @return The added document.
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/util/Collection.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/publication/util/Collection.java?view=diff&rev=527520&r1=527519&r2=527520
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/util/Collection.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/util/Collection.java Wed Apr 11 08:22:11 2007
@@ -45,6 +45,11 @@
String ATTRIBUTE_UUID = "uuid";
/**
+ * Name of the type attribute.
+ */
+ String ATTRIBUTE_TYPE = "type";
+
+ /**
* Returns the documents in this collection.
* @return An array of documents.
* @throws DocumentException when something went wrong.
@@ -109,4 +114,23 @@
*/
Document getDelegate();
+ /**
+ * Type for automatic inclusion of child documents.
+ */
+ String TYPE_CHILDREN = "children";
+
+ /**
+ * Type for manual addition of documents.
+ */
+ String TYPE_MANUAL = "manual";
+
+ /**
+ * @param type One of {@link #TYPE_CHILDREN}, {@link #TYPE_MANUAL}.
+ */
+ void setType(String type);
+
+ /**
+ * @return One of {@link #TYPE_CHILDREN}, {@link #TYPE_MANUAL}.
+ */
+ public String getType();
}
Added: lenya/trunk/src/modules/collection/java/src/org/apache/lenya/modules/collection/CollectionWrapper.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/collection/java/src/org/apache/lenya/modules/collection/CollectionWrapper.java?view=auto&rev=527520
==============================================================================
--- lenya/trunk/src/modules/collection/java/src/org/apache/lenya/modules/collection/CollectionWrapper.java (added)
+++ lenya/trunk/src/modules/collection/java/src/org/apache/lenya/modules/collection/CollectionWrapper.java Wed Apr 11 08:22:11 2007
@@ -0,0 +1,320 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.modules.collection;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.TransformerException;
+
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.lenya.cms.publication.Document;
+import org.apache.lenya.cms.publication.DocumentBuildException;
+import org.apache.lenya.cms.publication.DocumentException;
+import org.apache.lenya.cms.publication.util.Collection;
+import org.apache.lenya.xml.DocumentHelper;
+import org.apache.lenya.xml.NamespaceHelper;
+import org.apache.xpath.XPathAPI;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+/**
+ * Document wrapper for collection functionality.
+ */
+public class CollectionWrapper extends AbstractLogEnabled implements Collection {
+
+ private Document delegate;
+
+ protected static final String[] TYPES = { TYPE_CHILDREN, TYPE_MANUAL };
+
+ /**
+ * Ctor.
+ * @param doc The document.
+ * @param logger The logger.
+ */
+ public CollectionWrapper(Document doc, Logger logger) {
+ enableLogging(logger);
+ this.delegate = doc;
+ }
+
+ public Document getDelegate() {
+ return this.delegate;
+ }
+
+ private List documentsList;
+
+ /**
+ * Returns the list that holds the documents. Use this method to invoke lazy
+ * loading.
+ * @return A list.
+ * @throws DocumentException when something went wrong.
+ */
+ protected List documents() throws DocumentException {
+ load();
+ return this.documentsList;
+ }
+
+ /**
+ * @see org.apache.lenya.cms.publication.util.Collection#getDocuments()
+ */
+ public Document[] getDocuments() throws DocumentException {
+ return (Document[]) documents().toArray(new Document[documents().size()]);
+ }
+
+ /**
+ * @see org.apache.lenya.cms.publication.util.Collection#add(org.apache.lenya.cms.publication.Document)
+ */
+ public void add(Document document) throws DocumentException {
+ documents().add(document);
+ }
+
+ /**
+ * @see org.apache.lenya.cms.publication.util.Collection#add(int,
+ * org.apache.lenya.cms.publication.Document)
+ */
+ public void add(int position, Document document) throws DocumentException {
+ documents().add(position, document);
+ }
+
+ /**
+ * @see org.apache.lenya.cms.publication.util.Collection#remove(org.apache.lenya.cms.publication.Document)
+ */
+ public void remove(Document document) throws DocumentException {
+ if (!documents().contains(document)) {
+ throw new DocumentException("Collection [" + this + "] does not contain document ["
+ + document + "]");
+ }
+ documents().remove(document);
+ }
+
+ private boolean isLoaded = false;
+
+ /**
+ * Loads the collection from its XML source.
+ */
+ protected final void load() {
+ if (!this.isLoaded) {
+ getLogger().debug("Loading: ");
+ NamespaceHelper helper;
+ try {
+ helper = getNamespaceHelper();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ loadXml(helper);
+ this.isLoaded = true;
+ }
+ }
+
+ protected void loadXml(NamespaceHelper helper) {
+ try {
+ this.documentsList = new ArrayList();
+
+ Element collectionElement = helper.getDocument().getDocumentElement();
+ Element[] documentElements = helper
+ .getChildren(collectionElement, ELEMENT_DOCUMENT);
+
+ for (int i = 0; i < documentElements.length; i++) {
+ Element documentElement = documentElements[i];
+ Document document = loadDocument(documentElement);
+ this.documentsList.add(document);
+ }
+
+ if (collectionElement.hasAttribute(ATTRIBUTE_TYPE)) {
+ this.type = collectionElement.getAttribute(ATTRIBUTE_TYPE);
+ }
+ } catch (RuntimeException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * Loads a document from an XML element.
+ * @param documentElement The XML element.
+ * @return A document.
+ * @throws DocumentBuildException when something went wrong.
+ */
+ protected Document loadDocument(Element documentElement) throws DocumentBuildException {
+ String documentId = documentElement.getAttribute(ATTRIBUTE_UUID);
+ Document document = getDelegate().getFactory().get(getDelegate().getPublication(),
+ getDelegate().getArea(), documentId, getDelegate().getLanguage());
+ return document;
+ }
+
+ /**
+ * Saves the collection.
+ */
+ public final void save() {
+ try {
+ NamespaceHelper helper = getNamespaceHelper();
+ saveXml(helper);
+ DocumentHelper.writeDocument(helper.getDocument(), getDelegate().getOutputStream());
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * @param helper Save the XML to the provided namespace helper.
+ * @throws TransformerException if an error occurs.
+ * @throws DocumentException if an error occurs.
+ */
+ protected void saveXml(NamespaceHelper helper) throws TransformerException, DocumentException {
+ Element collectionElement = helper.getDocument().getDocumentElement();
+ if (collectionElement.getAttributeNS(null, ATTRIBUTE_UUID) == null
+ | collectionElement.getAttribute(ATTRIBUTE_UUID).equals("")) {
+ collectionElement.setAttributeNS(null, ATTRIBUTE_UUID, getDelegate().getUUID());
+ }
+ Element[] existingDocumentElements = helper.getChildren(collectionElement,
+ ELEMENT_DOCUMENT);
+ for (int i = 0; i < existingDocumentElements.length; i++) {
+ collectionElement.removeChild(existingDocumentElements[i]);
+ }
+
+ collectionElement.setAttribute(ATTRIBUTE_TYPE, getType());
+
+ collectionElement.normalize();
+
+ NodeList emptyTextNodes = XPathAPI.selectNodeList(collectionElement, "text()");
+ for (int i = 0; i < emptyTextNodes.getLength(); i++) {
+ Node node = emptyTextNodes.item(i);
+ node = collectionElement.removeChild(node);
+ }
+
+ Document[] documents = getDocuments();
+ for (int i = 0; i < documents.length; i++) {
+ Element documentElement = createDocumentElement(documents[i], helper);
+ collectionElement.appendChild(documentElement);
+ }
+ }
+
+ public String getType() {
+ load();
+ return this.type;
+ }
+
+ /**
+ * Creates an element to store a document.
+ * @param helper The namespace helper of the document.
+ * @param document The document.
+ * @return An XML element.
+ * @throws DocumentException when something went wrong.
+ */
+ protected Element createDocumentElement(Document document, NamespaceHelper helper)
+ throws DocumentException {
+ try {
+ Element documentElement = helper.createElement(ELEMENT_DOCUMENT);
+ documentElement.setAttributeNS(null, ATTRIBUTE_UUID, document.getUUID());
+ return documentElement;
+ } catch (final DOMException e) {
+ throw new DocumentException(e);
+ }
+ }
+
+ /**
+ * Returns the namespace helper for the XML source.
+ * @return A namespace helper.
+ * @throws DocumentException when something went wrong.
+ * @throws ParserConfigurationException when something went wrong.
+ * @throws SAXException when something went wrong.
+ * @throws IOException when something went wrong.
+ * @throws ServiceException
+ */
+ protected NamespaceHelper getNamespaceHelper() throws DocumentException,
+ ParserConfigurationException, SAXException, IOException, ServiceException {
+
+ NamespaceHelper helper;
+
+ if (getDelegate().exists()) {
+ org.w3c.dom.Document document = DocumentHelper.readDocument(getDelegate()
+ .getInputStream());
+ helper = new NamespaceHelper(Collection.NAMESPACE, Collection.DEFAULT_PREFIX, document);
+ } else {
+ helper = initializeNamespaceHelper();
+ }
+ return helper;
+ }
+
+ /**
+ * @return A new, empty namespace helper.
+ */
+ protected NamespaceHelper initializeNamespaceHelper() {
+ NamespaceHelper helper;
+ try {
+ helper = new NamespaceHelper(Collection.NAMESPACE, Collection.DEFAULT_PREFIX,
+ ELEMENT_COLLECTION);
+ } catch (ParserConfigurationException e) {
+ throw new RuntimeException(e);
+ }
+ return helper;
+ }
+
+ /**
+ * @see org.apache.lenya.cms.publication.util.Collection#contains(org.apache.lenya.cms.publication.Document)
+ */
+ public boolean contains(Document document) throws DocumentException {
+ return documents().contains(document);
+ }
+
+ /**
+ * @see org.apache.lenya.cms.publication.util.Collection#clear()
+ */
+ public void clear() throws DocumentException {
+ documents().clear();
+ }
+
+ /**
+ * @see org.apache.lenya.cms.publication.util.Collection#getFirstPosition(org.apache.lenya.cms.publication.Document)
+ */
+ public int getFirstPosition(Document document) throws DocumentException {
+ load();
+ if (!contains(document)) {
+ throw new DocumentException("The collection [" + this
+ + "] does not contain the document [" + document + "]");
+ }
+ return documents().indexOf(document);
+ }
+
+ /**
+ * @see org.apache.lenya.cms.publication.util.Collection#size()
+ */
+ public int size() throws DocumentException {
+ return documents().size();
+ }
+
+ private String type = TYPE_MANUAL;
+
+ public void setType(String type) {
+ load();
+ if (!Arrays.asList(TYPES).contains(type)) {
+ throw new IllegalArgumentException("The type [" + type + "] is not supported!");
+ }
+ this.type = type;
+ }
+
+}
Added: lenya/trunk/src/modules/collection/java/test/org/apache/lenya/modules/collection/CollectionWrapperTest.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/collection/java/test/org/apache/lenya/modules/collection/CollectionWrapperTest.java?view=auto&rev=527520
==============================================================================
--- lenya/trunk/src/modules/collection/java/test/org/apache/lenya/modules/collection/CollectionWrapperTest.java (added)
+++ lenya/trunk/src/modules/collection/java/test/org/apache/lenya/modules/collection/CollectionWrapperTest.java Wed Apr 11 08:22:11 2007
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.modules.collection;
+
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceSelector;
+import org.apache.lenya.ac.AccessControlException;
+import org.apache.lenya.ac.impl.AbstractAccessControlTest;
+import org.apache.lenya.cms.publication.Document;
+import org.apache.lenya.cms.publication.DocumentBuildException;
+import org.apache.lenya.cms.publication.DocumentFactory;
+import org.apache.lenya.cms.publication.DocumentManager;
+import org.apache.lenya.cms.publication.DocumentUtil;
+import org.apache.lenya.cms.publication.Publication;
+import org.apache.lenya.cms.publication.PublicationException;
+import org.apache.lenya.cms.publication.ResourceType;
+import org.apache.lenya.cms.repository.Session;
+import org.apache.lenya.cms.site.SiteManager;
+import org.apache.lenya.cms.site.SiteStructure;
+import org.apache.lenya.transaction.TransactionException;
+
+/**
+ * Collection wrapper test.
+ */
+public class CollectionWrapperTest extends AbstractAccessControlTest {
+
+ /**
+ * @throws PublicationException
+ * @throws AccessControlException
+ * @throws TransactionException
+ * @throws ServiceException
+ */
+ public void testXLinkCollection() throws PublicationException, AccessControlException,
+ TransactionException, ServiceException {
+
+ Session session = login("lenya");
+ DocumentFactory map = DocumentUtil.createDocumentFactory(getManager(), session);
+
+ Publication pub = getPublication("test");
+
+ Document collectionDoc = createCollectionDocument(pub);
+
+ CollectionWrapper collection = new CollectionWrapper(collectionDoc, getLogger());
+
+ SiteStructure structure = pub.getArea("authoring").getSite();
+ structure.getRepositoryNode().lock();
+
+ SiteManager siteManager = null;
+ ServiceSelector selector = null;
+ try {
+ selector = (ServiceSelector) getManager().lookup(SiteManager.ROLE + "Selector");
+ siteManager = (SiteManager) selector.select(pub.getSiteManagerHint());
+
+ siteManager.add("/collection", collection.getDelegate());
+ } finally {
+ selector.release(siteManager);
+ getManager().release(selector);
+ }
+
+ Document doc = map.get(pub, Publication.AUTHORING_AREA, "/index", "en");
+ collection.add(doc);
+ collection.save();
+
+ collection.getDelegate().getRepositoryNode().unlock();
+ structure.getRepositoryNode().unlock();
+
+ CollectionWrapper coll2 = new CollectionWrapper(collectionDoc, getLogger());
+
+ assertSame(collection.getDelegate().getRepositoryNode(), coll2.getDelegate()
+ .getRepositoryNode());
+
+ assertEquals(coll2.size(), 1);
+ assertTrue(coll2.contains(doc));
+
+ }
+
+ protected Document createCollectionDocument(Publication pub) throws ServiceException,
+ DocumentBuildException, PublicationException {
+ ServiceSelector typeSelector = null;
+ ResourceType type = null;
+ DocumentManager docMgr = null;
+ Document doc;
+ try {
+ typeSelector = (ServiceSelector) getManager().lookup(ResourceType.ROLE + "Selector");
+ type = (ResourceType) typeSelector.select("collection");
+ docMgr = (DocumentManager) getManager().lookup(DocumentManager.ROLE);
+ String sampleUri = type.getSampleURI(type.getSampleNames()[0]);
+ doc = docMgr.add(getFactory(), type, sampleUri, pub, "authoring", "en", "xml");
+ } finally {
+ if (docMgr != null) {
+ getManager().release(docMgr);
+ }
+ if (typeSelector != null) {
+ getManager().release(typeSelector);
+ }
+ }
+ return doc;
+ }
+
+}
Modified: lenya/trunk/src/modules/collection/module.xml
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/collection/module.xml?view=diff&rev=527520&r1=527519&r2=527520
==============================================================================
--- lenya/trunk/src/modules/collection/module.xml (original)
+++ lenya/trunk/src/modules/collection/module.xml Wed Apr 11 08:22:11 2007
@@ -20,6 +20,7 @@
<module xmlns="http://apache.org/lenya/module/1.0">
<id>org.apache.lenya.modules.collection</id>
+ <export package="org.apache.lenya.modules.collection"/>
<package>org.apache.lenya.modules</package>
<version>0.1-dev</version>
<name>Collection</name>
Added: lenya/trunk/src/modules/news/config/cocoon-xconf/usecase-news-edit.xconf
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/news/config/cocoon-xconf/usecase-news-edit.xconf?view=auto&rev=527520
==============================================================================
--- lenya/trunk/src/modules/news/config/cocoon-xconf/usecase-news-edit.xconf (added)
+++ lenya/trunk/src/modules/news/config/cocoon-xconf/usecase-news-edit.xconf Wed Apr 11 08:22:11 2007
@@ -0,0 +1,30 @@
+<?xml version="1.0"?>
+<!--
+ 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.
+-->
+
+<!--
+ This file defines the publication specific use-cases
+-->
+
+ <xconf xpath="/cocoon/usecases" unless="/cocoon/usecases/component-instance[@name = 'news.edit']">
+
+ <component-instance name="news.edit" logger="lenya.news"
+ class="org.apache.lenya.modules.news.usecases.Edit">
+ <view template="modules/news/usecases/edit.jx" menu="false"/>
+ <event id="edit"/>
+ </component-instance>
+
+ </xconf>
Modified: lenya/trunk/src/modules/news/config/menu.xsp
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/news/config/menu.xsp?view=diff&rev=527520&r1=527519&r2=527520
==============================================================================
--- lenya/trunk/src/modules/news/config/menu.xsp (original)
+++ lenya/trunk/src/modules/news/config/menu.xsp Wed Apr 11 08:22:11 2007
@@ -29,6 +29,10 @@
xmlns="http://apache.org/cocoon/lenya/menubar/1.0"
>
+ <xsp:structure>
+ <xsp:include>org.apache.lenya.cms.publication.Document</xsp:include>
+ </xsp:structure>
+
<menu>
<menus>
<menu i18n:attr="name" name="File">
@@ -41,6 +45,26 @@
</item>
</block>
</menu>
+
+ <menu i18n:attr="name" name="Edit">
+ <xsp:logic>
+ try {
+ Object doc = <input:get-attribute module="page-envelope" as="object" name="document"/>;
+ if (doc instanceof Document && ((Document) doc).exists()) {
+ String doctype = <input:get-attribute module="page-envelope" as="string" name="document-type"/>;
+ if ("news".equals(doctype)) {
+ <block areas="authoring">
+ <item uc:usecase="news.edit" href="?"><i18n:text>news-settings</i18n:text></item>
+ </block>
+ }
+ }
+ }
+ catch (Exception e) {
+ throw new ProcessingException("Error during menu generation: ", e);
+ }
+ </xsp:logic>
+ </menu>
+
</menus>
</menu>
Added: lenya/trunk/src/modules/news/java/src/org/apache/lenya/modules/news/NewsWrapper.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/news/java/src/org/apache/lenya/modules/news/NewsWrapper.java?view=auto&rev=527520
==============================================================================
--- lenya/trunk/src/modules/news/java/src/org/apache/lenya/modules/news/NewsWrapper.java (added)
+++ lenya/trunk/src/modules/news/java/src/org/apache/lenya/modules/news/NewsWrapper.java Wed Apr 11 08:22:11 2007
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.modules.news;
+
+import javax.xml.transform.TransformerException;
+
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.lenya.cms.publication.Document;
+import org.apache.lenya.cms.publication.DocumentException;
+import org.apache.lenya.modules.collection.CollectionWrapper;
+import org.apache.lenya.xml.NamespaceHelper;
+import org.w3c.dom.Element;
+
+/**
+ * Wrapper for a news document.
+ */
+public class NewsWrapper extends CollectionWrapper {
+
+ protected static final int DEFAULT_INCLUDE_ITEMS = 3;
+ protected static final String ATTRIBUTE_INCLUDE_ITEMS = "includeItems";
+
+ private short includeItemNumber = DEFAULT_INCLUDE_ITEMS;
+
+ /**
+ * @param doc The document to wrap.
+ * @param logger The logger.
+ */
+ public NewsWrapper(Document doc, Logger logger) {
+ super(doc, logger);
+ }
+
+ protected void loadXml(NamespaceHelper helper) {
+ super.loadXml(helper);
+ Element docElement = helper.getDocument().getDocumentElement();
+ if (docElement.hasAttribute(ATTRIBUTE_INCLUDE_ITEMS)) {
+ String number = docElement.getAttribute(ATTRIBUTE_INCLUDE_ITEMS);
+ this.includeItemNumber = Short.parseShort(number);
+ }
+ }
+
+ protected void saveXml(NamespaceHelper helper) throws TransformerException, DocumentException {
+ super.saveXml(helper);
+ Element docElement = helper.getDocument().getDocumentElement();
+ docElement.setAttribute(ATTRIBUTE_INCLUDE_ITEMS, Short.toString(this.includeItemNumber));
+ }
+
+ /**
+ * @return The number of items to appear on overviews which are generated
+ * using the "include" format.
+ */
+ public short getIncludeItemNumber() {
+ load();
+ return this.includeItemNumber;
+ }
+
+ /**
+ * @param number The number of items to appear on overviews which are
+ * generated using the "include" format.
+ */
+ public void setIncludeItemNumber(short number) {
+ load();
+ this.includeItemNumber = number;
+ }
+
+ protected NamespaceHelper initializeNamespaceHelper() {
+ NamespaceHelper helper = super.initializeNamespaceHelper();
+ Element docElement = helper.getDocument().getDocumentElement();
+ docElement.setAttribute(ATTRIBUTE_INCLUDE_ITEMS, Short.toString(getIncludeItemNumber()));
+ return helper;
+ }
+
+}
Added: lenya/trunk/src/modules/news/java/src/org/apache/lenya/modules/news/usecases/Edit.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/news/java/src/org/apache/lenya/modules/news/usecases/Edit.java?view=auto&rev=527520
==============================================================================
--- lenya/trunk/src/modules/news/java/src/org/apache/lenya/modules/news/usecases/Edit.java (added)
+++ lenya/trunk/src/modules/news/java/src/org/apache/lenya/modules/news/usecases/Edit.java Wed Apr 11 08:22:11 2007
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.modules.news.usecases;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.lenya.cms.workflow.usecases.InvokeWorkflow;
+import org.apache.lenya.modules.news.NewsWrapper;
+
+/**
+ * Edit the properties of a news document.
+ */
+public class Edit extends InvokeWorkflow {
+
+ protected static final String INCLUDE_ITEM_NUMBER = "includeItems";
+ protected static final String NEWS_WRAPPER = "newsWrapper";
+ protected static final String NUMBERS = "numbers";
+
+ protected void initParameters() {
+ super.initParameters();
+ NewsWrapper news = new NewsWrapper(getSourceDocument(), getLogger());
+ setParameter(NEWS_WRAPPER, news);
+
+ setParameter(INCLUDE_ITEM_NUMBER, Short.valueOf(news.getIncludeItemNumber()));
+
+ List numbers = new ArrayList();
+ for (int i = 1; i <= 10; i++) {
+ numbers.add(Integer.valueOf(i));
+ }
+ setParameter(NUMBERS, numbers);
+ }
+
+ protected void doExecute() throws Exception {
+ super.doExecute();
+
+ String numberString = getParameterAsString(INCLUDE_ITEM_NUMBER);
+ short number = Short.parseShort(numberString);
+
+ // we must create a new wrapper, because a new (modifiable) session is used
+ NewsWrapper news = new NewsWrapper(getSourceDocument(), getLogger());
+ news.setIncludeItemNumber(number);
+ news.save();
+ }
+
+}
Modified: lenya/trunk/src/modules/news/resources/i18n/cmsui.xml
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/news/resources/i18n/cmsui.xml?view=diff&rev=527520&r1=527519&r2=527520
==============================================================================
--- lenya/trunk/src/modules/news/resources/i18n/cmsui.xml (original)
+++ lenya/trunk/src/modules/news/resources/i18n/cmsui.xml Wed Apr 11 08:22:11 2007
@@ -21,5 +21,7 @@
<catalogue xml:lang="en" xmlns:xhtml="http://www.w3.org/1999/xhtml">
<message key="new-news-message-hint">To add a new news message, choose 'File' -> 'New XHTML Document'.</message>
+ <message key="news-settings">News Settings</message>
+ <message key="include-items">Number of items to display on overview page</message>
</catalogue>
Modified: lenya/trunk/src/modules/news/resources/i18n/cmsui_de.xml
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/news/resources/i18n/cmsui_de.xml?view=diff&rev=527520&r1=527519&r2=527520
==============================================================================
--- lenya/trunk/src/modules/news/resources/i18n/cmsui_de.xml (original)
+++ lenya/trunk/src/modules/news/resources/i18n/cmsui_de.xml Wed Apr 11 08:22:11 2007
@@ -24,5 +24,7 @@
Um eine neue News-Meldung zu erstellen,
wählen Sie 'Datei' -> 'Neues News-Dokument'.
</message>
+ <message key="news-settings">News-Einstellungen</message>
+ <message key="include-items">Anzahl der Meldungen, die auf der Ãbersicht dargestellt werden sollen</message>
</catalogue>
Added: lenya/trunk/src/modules/news/usecases/edit.jx
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/news/usecases/edit.jx?view=auto&rev=527520
==============================================================================
--- lenya/trunk/src/modules/news/usecases/edit.jx (added)
+++ lenya/trunk/src/modules/news/usecases/edit.jx Wed Apr 11 08:22:11 2007
@@ -0,0 +1,63 @@
+<?xml version="1.0"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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: oneform.jx 510073 2007-02-21 16:01:52Z andreas $ -->
+<page:page
+ xmlns:jx="http://apache.org/cocoon/templates/jx/1.0"
+ xmlns:page="http://apache.org/cocoon/lenya/cms-page/1.0"
+ xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:i18n="http://apache.org/cocoon/i18n/2.1"
+ xmlns:cinclude="http://apache.org/cocoon/include/1.0"
+ >
+
+ <page:title><i18n:text>news-settings</i18n:text></page:title>
+ <page:body>
+
+ <jx:import uri="fallback://lenya/modules/usecase/templates/messages.jx"/>
+
+ <form method="post" id="form-news-edit">
+ <input type="hidden" name="lenya.continuation" value="${continuation.id}"/>
+ <input type="hidden" name="lenya.usecase" value="${usecase.getName()}"/>
+
+ <jx:set var="newsWrapper" value="${usecase.getParameter('newsWrapper')}"/>
+ <jx:set var="includeItems" value="${usecase.getParameter('includeItems')}"/>
+
+ <p>
+ <label for="includeItems"><i18n:text>include-items</i18n:text>:</label>
+ <select name="includeItems">
+ <jx:forEach var="number" items="${usecase.getParameter('numbers')}">
+ <jx:choose>
+ <jx:when test="${includeItems == number}">
+ <option value="${number}" selected="selected"><jx:out value="${number}"/></option>
+ </jx:when>
+ <jx:otherwise>
+ <option value="${number}"><jx:out value="${number}"/></option>
+ </jx:otherwise>
+ </jx:choose>
+ </jx:forEach>
+ </select>
+ </p>
+
+ <p>
+ <input type="submit" value="Save" name="submit" i18n:attr="value"/>
+ <input type="submit" value="Cancel" name="cancel" i18n:attr="value"/>
+ </p>
+
+ </form>
+
+ </page:body>
+</page:page>
\ No newline at end of file
Copied: lenya/trunk/src/modules/simplesite/config/cocoon-xconf/site-managers.xconf (from r527065, lenya/trunk/src/webapp/lenya/config/cocoon-xconf/misc/site-managers.xconf)
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/simplesite/config/cocoon-xconf/site-managers.xconf?view=diff&rev=527520&p1=lenya/trunk/src/webapp/lenya/config/cocoon-xconf/misc/site-managers.xconf&r1=527065&p2=lenya/trunk/src/modules/simplesite/config/cocoon-xconf/site-managers.xconf&r2=527520
==============================================================================
--- lenya/trunk/src/webapp/lenya/config/cocoon-xconf/misc/site-managers.xconf (original)
+++ lenya/trunk/src/modules/simplesite/config/cocoon-xconf/site-managers.xconf Wed Apr 11 08:22:11 2007
@@ -21,9 +21,7 @@
This file defines the publication specific use-cases
-->
- <xconf xpath="/cocoon" unless="/cocoon/site-managers">
- <site-managers>
- <component-instance name="simple" logger="lenya.site"
- class="org.apache.lenya.cms.site.simple.SimpleSiteManager"/>
- </site-managers>
+ <xconf xpath="/cocoon/site-managers" unless="/cocoon/site-managers/component-instance[@name = 'simple']">
+ <component-instance name="simple" logger="lenya.site"
+ class="org.apache.lenya.cms.site.simple.SimpleSiteManager"/>
</xconf>
Copied: lenya/trunk/src/modules/simplesite/java/src/org/apache/lenya/cms/site/simple/DocumentStore.java (from r527065, lenya/trunk/src/java/org/apache/lenya/cms/site/simple/DocumentStore.java)
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/simplesite/java/src/org/apache/lenya/cms/site/simple/DocumentStore.java?view=diff&rev=527520&p1=lenya/trunk/src/java/org/apache/lenya/cms/site/simple/DocumentStore.java&r1=527065&p2=lenya/trunk/src/modules/simplesite/java/src/org/apache/lenya/cms/site/simple/DocumentStore.java&r2=527520
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/simple/DocumentStore.java (original)
+++ lenya/trunk/src/modules/simplesite/java/src/org/apache/lenya/cms/site/simple/DocumentStore.java Wed Apr 11 08:22:11 2007
@@ -27,19 +27,16 @@
import java.util.WeakHashMap;
import org.apache.avalon.framework.logger.Logger;
-import org.apache.avalon.framework.service.ServiceManager;
import org.apache.lenya.cms.publication.Document;
import org.apache.lenya.cms.publication.DocumentBuildException;
import org.apache.lenya.cms.publication.DocumentException;
-import org.apache.lenya.cms.publication.DocumentFactory;
-import org.apache.lenya.cms.publication.DocumentIdentifier;
import org.apache.lenya.cms.publication.Publication;
-import org.apache.lenya.cms.publication.util.CollectionImpl;
import org.apache.lenya.cms.repository.Node;
import org.apache.lenya.cms.site.Link;
import org.apache.lenya.cms.site.SiteException;
import org.apache.lenya.cms.site.SiteNode;
import org.apache.lenya.cms.site.SiteStructure;
+import org.apache.lenya.modules.collection.CollectionWrapper;
import org.apache.lenya.transaction.TransactionException;
import org.apache.lenya.util.Assert;
import org.apache.lenya.xml.NamespaceHelper;
@@ -50,7 +47,7 @@
*
* @version $Id$
*/
-public class DocumentStore extends CollectionImpl implements SiteStructure {
+public class DocumentStore extends CollectionWrapper implements SiteStructure {
/**
* The identifiable type.
@@ -60,21 +57,13 @@
protected static final Object SITE_PATH = "/sitestructure";
/**
- * @param manager The service manager.
- * @param map The identity map.
- * @param pub The publication.
- * @param area The area.
- * @param uuid The UUID.
- * @param _logger The logger.
+ * @param doc The document where the collection is stored.
+ * @param logger The logger.
* @throws DocumentException if an error occurs.
*/
- public DocumentStore(ServiceManager manager, DocumentFactory map, Publication pub, String area,
- String uuid, Logger _logger) throws DocumentException {
- super(manager,
- map,
- new DocumentIdentifier(pub, area, uuid, pub.getDefaultLanguage()),
- _logger);
- this.doc2path.put(getKey(uuid, pub.getDefaultLanguage()), SITE_PATH);
+ public DocumentStore(Document doc, Logger logger) throws DocumentException {
+ super(doc, logger);
+ this.doc2path.put(getKey(doc.getUUID(), doc.getLanguage()), SITE_PATH);
}
protected static final String NAMESPACE = "http://apache.org/lenya/sitemanagement/simple/1.0";
@@ -97,7 +86,7 @@
}
/**
- * @see org.apache.lenya.cms.publication.util.CollectionImpl#createDocumentElement(org.apache.lenya.cms.publication.Document,
+ * @see org.apache.lenya.modules.collection.CollectionWrapper#createDocumentElement(org.apache.lenya.cms.publication.Document,
* org.apache.lenya.xml.NamespaceHelper)
*/
protected Element createDocumentElement(Document document, NamespaceHelper helper)
@@ -110,16 +99,14 @@
}
/**
- * @see org.apache.lenya.cms.publication.util.CollectionImpl#loadDocument(org.w3c.dom.Element)
+ * @see org.apache.lenya.modules.collection.CollectionWrapper#loadDocument(org.w3c.dom.Element)
*/
protected Document loadDocument(Element documentElement) throws DocumentBuildException {
String uuid = documentElement.getAttribute(ATTRIBUTE_UUID);
String language = documentElement.getAttribute(ATTRIBUTE_LANGUAGE);
String path = documentElement.getAttribute(ATTRIBUTE_PATH);
Document document = getDelegate().getFactory().get(getDelegate().getPublication(),
- getDelegate().getArea(),
- uuid,
- language);
+ getDelegate().getArea(), uuid, language);
String key = getKey(uuid, language);
if (!this.doc2path.containsKey(key)) {
this.doc2path.put(key, path);
@@ -228,6 +215,7 @@
doc2path().put(key, path);
}
super.add(document);
+ save();
} catch (DocumentException e) {
throw new SiteException(e);
}
@@ -250,11 +238,7 @@
}
protected Map doc2path() {
- try {
- load();
- } catch (DocumentException e) {
- throw new RuntimeException(e);
- }
+ load();
return this.doc2path;
}
@@ -284,6 +268,7 @@
public void remove(Document document) throws DocumentException {
super.remove(document);
this.doc2path.remove(getKey(document.getUUID(), document.getLanguage()));
+ save();
}
public SiteNode add(String path, String followingSiblingPath) throws SiteException {
Copied: lenya/trunk/src/modules/simplesite/java/src/org/apache/lenya/cms/site/simple/DocumentStoreFactory.java (from r527065, lenya/trunk/src/java/org/apache/lenya/cms/site/simple/DocumentStoreFactory.java)
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/simplesite/java/src/org/apache/lenya/cms/site/simple/DocumentStoreFactory.java?view=diff&rev=527520&p1=lenya/trunk/src/java/org/apache/lenya/cms/site/simple/DocumentStoreFactory.java&r1=527065&p2=lenya/trunk/src/modules/simplesite/java/src/org/apache/lenya/cms/site/simple/DocumentStoreFactory.java&r2=527520
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/simple/DocumentStoreFactory.java (original)
+++ lenya/trunk/src/modules/simplesite/java/src/org/apache/lenya/cms/site/simple/DocumentStoreFactory.java Wed Apr 11 08:22:11 2007
@@ -20,10 +20,15 @@
import org.apache.avalon.framework.container.ContainerUtil;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.logger.Logger;
+import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.lenya.cms.publication.Area;
+import org.apache.lenya.cms.publication.Document;
import org.apache.lenya.cms.publication.DocumentFactory;
+import org.apache.lenya.cms.publication.DocumentManager;
import org.apache.lenya.cms.publication.DocumentUtil;
import org.apache.lenya.cms.publication.Publication;
+import org.apache.lenya.cms.publication.PublicationException;
import org.apache.lenya.cms.repository.RepositoryException;
import org.apache.lenya.cms.repository.RepositoryItem;
import org.apache.lenya.cms.repository.RepositoryItemFactory;
@@ -62,21 +67,45 @@
*/
public RepositoryItem buildItem(Session session, String key) throws RepositoryException {
String[] snippets = key.split(":");
-
+
Assert.isTrue("key [" + key + "] is invalid!", snippets.length == 3);
-
+
String publicationId = snippets[0];
- String area = snippets[1];
+ String areaName = snippets[1];
String uuid = snippets[2];
DocumentStore store;
try {
DocumentFactory factory = DocumentUtil.createDocumentFactory(this.manager, session);
Publication publication = factory.getPublication(publicationId);
- store = new DocumentStore(this.manager, factory, publication, area, uuid, getLogger());
+ Area area = publication.getArea(areaName);
+ String lang = publication.getDefaultLanguage();
+
+ if (!area.contains(uuid, lang)) {
+ createAreaVersion(publication, areaName, uuid, lang);
+ }
+
+ Document doc = area.getDocument(uuid, lang);
+
+ store = new DocumentStore(doc, getLogger());
} catch (Exception e) {
throw new RepositoryException(e);
}
return store;
+ }
+
+ protected void createAreaVersion(Publication publication, String areaName, String uuid,
+ String lang) throws PublicationException, ServiceException {
+ DocumentManager docManager = null;
+ try {
+ Area authoring = publication.getArea(Publication.AUTHORING_AREA);
+ Document authoringDoc = authoring.getDocument(uuid, lang);
+ docManager = (DocumentManager) this.manager.lookup(DocumentManager.ROLE);
+ docManager.copyToArea(authoringDoc, areaName);
+ } finally {
+ if (docManager != null) {
+ this.manager.release(docManager);
+ }
+ }
}
public boolean isSharable() {
Added: lenya/trunk/src/modules/simplesite/module.xml
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/simplesite/module.xml?view=auto&rev=527520
==============================================================================
--- lenya/trunk/src/modules/simplesite/module.xml (added)
+++ lenya/trunk/src/modules/simplesite/module.xml Wed Apr 11 08:22:11 2007
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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: publication.xml 374687 2006-02-03 15:24:55Z michi $ -->
+
+<module xmlns="http://apache.org/lenya/module/1.0">
+ <id>org.apache.lenya.modules.simplesite</id>
+ <export package="org.apache.lenya.cms.site.simple"/>
+ <depends module="org.apache.lenya.modules.collection"/>
+ <package>org.apache.lenya.modules</package>
+ <version>0.1-dev</version>
+ <name>Simple Site Manager</name>
+ <lenya-version>@lenya.version@</lenya-version>
+ <description>Collection-based site manager implementation</description>
+</module>
\ No newline at end of file
Modified: lenya/trunk/src/pubs/blog/sitemap.xmap
URL: http://svn.apache.org/viewvc/lenya/trunk/src/pubs/blog/sitemap.xmap?view=diff&rev=527520&r1=527519&r2=527520
==============================================================================
--- lenya/trunk/src/pubs/blog/sitemap.xmap (original)
+++ lenya/trunk/src/pubs/blog/sitemap.xmap Wed Apr 11 08:22:11 2007
@@ -102,7 +102,7 @@
<map:transform src="fallback://lenya/xslt/rc/toDoc.xsl"/>
</map:when>
<map:otherwise>
- <map:generate src="site:/en/entries/{2}/{3}/{4}/{5}/index"/>
+ <map:generate src="site://{page-envelope:publication-id}/{1}/en/entries/{2}/{3}/{4}/{5}/index"/>
</map:otherwise>
</map:select>
<map:serialize type="xml"/>
@@ -116,7 +116,7 @@
<map:transform src="fallback://lenya/xslt/rc/toDoc.xsl"/>
</map:when>
<map:otherwise>
- <map:generate src="site:/en/entries/{2}/{3}/{4}/{5}/index"/>
+ <map:generate src="site://{page-envelope:publication-id}/{1}/en/entries/{2}/{3}/{4}/{5}/index"/>
<map:transform src="xslt/feed/atom2other.xsl">
<map:parameter name="type" value="rss"/>
<map:parameter name="url" value="{global:blog-url}"/>
Modified: lenya/trunk/src/pubs/default/config/ac/usecase-policies.xml
URL: http://svn.apache.org/viewvc/lenya/trunk/src/pubs/default/config/ac/usecase-policies.xml?view=diff&rev=527520&r1=527519&r2=527520
==============================================================================
--- lenya/trunk/src/pubs/default/config/ac/usecase-policies.xml (original)
+++ lenya/trunk/src/pubs/default/config/ac/usecase-policies.xml Wed Apr 11 08:22:11 2007
@@ -364,5 +364,8 @@
<usecase id="neutron.checkin">
<role id="edit" method="grant"/>
</usecase>
+ <usecase id="news.edit">
+ <role id="edit" method="grant"/>
+ </usecase>
</usecases>
Modified: lenya/trunk/src/pubs/default/example-content/news/index_de
URL: http://svn.apache.org/viewvc/lenya/trunk/src/pubs/default/example-content/news/index_de?view=diff&rev=527520&r1=527519&r2=527520
==============================================================================
--- lenya/trunk/src/pubs/default/example-content/news/index_de (original)
+++ lenya/trunk/src/pubs/default/example-content/news/index_de Wed Apr 11 08:22:11 2007
@@ -1,2 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
-<collection xmlns="http://apache.org/cocoon/lenya/collection/1.0" type="children"/>
+<collection xmlns="http://apache.org/cocoon/lenya/collection/1.0" type="children" includeItems="3"/>
Modified: lenya/trunk/src/pubs/default/example-content/news/index_en
URL: http://svn.apache.org/viewvc/lenya/trunk/src/pubs/default/example-content/news/index_en?view=diff&rev=527520&r1=527519&r2=527520
==============================================================================
--- lenya/trunk/src/pubs/default/example-content/news/index_en (original)
+++ lenya/trunk/src/pubs/default/example-content/news/index_en Wed Apr 11 08:22:11 2007
@@ -1,2 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
-<collection xmlns="http://apache.org/cocoon/lenya/collection/1.0" type="children"/>
+<collection xmlns="http://apache.org/cocoon/lenya/collection/1.0" type="children" includeItems="3"/>
Modified: lenya/trunk/src/webapp/lenya/config/cocoon-xconf/misc/site-managers.xconf
URL: http://svn.apache.org/viewvc/lenya/trunk/src/webapp/lenya/config/cocoon-xconf/misc/site-managers.xconf?view=diff&rev=527520&r1=527519&r2=527520
==============================================================================
--- lenya/trunk/src/webapp/lenya/config/cocoon-xconf/misc/site-managers.xconf (original)
+++ lenya/trunk/src/webapp/lenya/config/cocoon-xconf/misc/site-managers.xconf Wed Apr 11 08:22:11 2007
@@ -22,8 +22,5 @@
-->
<xconf xpath="/cocoon" unless="/cocoon/site-managers">
- <site-managers>
- <component-instance name="simple" logger="lenya.site"
- class="org.apache.lenya.cms.site.simple.SimpleSiteManager"/>
- </site-managers>
+ <site-managers/>
</xconf>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org