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/12/14 18:00:31 UTC
svn commit: r487257 [1/2] - in /lenya/trunk/src:
impl/java/org/apache/lenya/cms/publication/
impl/test/org/apache/lenya/cms/site/ java/org/apache/lenya/cms/site/
java/org/apache/lenya/cms/site/simple/ java/org/apache/lenya/util/
modules/export/java/src...
Author: andreas
Date: Thu Dec 14 09:00:30 2006
New Revision: 487257
URL: http://svn.apache.org/viewvc?view=rev&rev=487257
Log:
Providing alternative sitetree implementation with better performance.
Added:
lenya/trunk/src/java/org/apache/lenya/util/StringUtil.java
lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/
lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/RootNode.java
lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/SiteTreeFactory.java
lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/SiteTreeImpl.java
lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/SiteTreeLink.java
lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/TreeNode.java
lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/TreeNodeImpl.java
lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/TreeSiteManager.java
Modified:
lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/AreaImpl.java
lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentImpl.java
lenya/trunk/src/impl/test/org/apache/lenya/cms/site/SimpleSiteManagerTest.java
lenya/trunk/src/java/org/apache/lenya/cms/site/AbstractLink.java
lenya/trunk/src/java/org/apache/lenya/cms/site/NodeIterator.java
lenya/trunk/src/java/org/apache/lenya/cms/site/SiteNode.java
lenya/trunk/src/java/org/apache/lenya/cms/site/simple/SimpleSiteNode.java
lenya/trunk/src/modules/export/java/src/org/apache/lenya/cms/export/Importer.java
lenya/trunk/src/modules/export/java/test/org/apache/lenya/cms/export/ImportTest.java
lenya/trunk/src/modules/sitetree/config/cocoon-xconf/module.xconf
lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/cocoon/generation/SitetreeFragmentGenerator.java
lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/DefaultSiteTree.java
lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/SiteTree.java
lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/SiteTreeLink.java
lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/SiteTreeNode.java
lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/SiteTreeNodeImpl.java
lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/TreeSiteManager.java
Modified: lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/AreaImpl.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/AreaImpl.java?view=diff&rev=487257&r1=487256&r2=487257
==============================================================================
--- lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/AreaImpl.java (original)
+++ lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/AreaImpl.java Thu Dec 14 09:00:30 2006
@@ -77,7 +77,7 @@
public Publication getPublication() {
return this.pub;
}
-
+
public SiteStructure getSite() {
SiteManager siteManager = null;
ServiceSelector selector = null;
Modified: lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentImpl.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentImpl.java?view=diff&rev=487257&r1=487256&r2=487257
==============================================================================
--- lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentImpl.java (original)
+++ lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentImpl.java Thu Dec 14 09:00:30 2006
@@ -56,8 +56,9 @@
public static final String METADATA_NAMESPACE = "http://apache.org/lenya/metadata/document/1.0";
/**
- * The name of the resource type attribute. A resource has a resource type; this information can
- * be used e.g. for different rendering of different types.
+ * The name of the resource type attribute. A resource has a resource type;
+ * this information can be used e.g. for different rendering of different
+ * types.
*/
public static final String METADATA_RESOURCE_TYPE = "resourceType";
@@ -67,13 +68,15 @@
public static final String METADATA_MIME_TYPE = "mimeType";
/**
- * The name of the content type attribute. Any content managed by Lenya has a type; this
- * information can be used e.g. to provide an appropriate management interface.
+ * The name of the content type attribute. Any content managed by Lenya has
+ * a type; this information can be used e.g. to provide an appropriate
+ * management interface.
*/
public static final String METADATA_CONTENT_TYPE = "contentType";
/**
- * The number of seconds from the request that a document can be cached before it expires
+ * The number of seconds from the request that a document can be cached
+ * before it expires
*/
public static final String METADATA_EXPIRES = "expires";
@@ -94,8 +97,9 @@
ContainerUtil.enableLogging(this, _logger);
if (getLogger().isDebugEnabled()) {
- getLogger().debug("DefaultDocument() creating new instance with id ["
- + identifier.getUUID() + "], language [" + identifier.getLanguage() + "]");
+ getLogger().debug(
+ "DefaultDocument() creating new instance with id [" + identifier.getUUID()
+ + "], language [" + identifier.getLanguage() + "]");
}
this.manager = manager;
@@ -107,8 +111,9 @@
this.factory = map;
if (getLogger().isDebugEnabled()) {
- getLogger().debug("DefaultDocument() done building instance with _id ["
- + identifier.getUUID() + "], _language [" + identifier.getLanguage() + "]");
+ getLogger().debug(
+ "DefaultDocument() done building instance with _id [" + identifier.getUUID()
+ + "], _language [" + identifier.getLanguage() + "]");
}
}
@@ -148,7 +153,8 @@
* @see org.apache.lenya.cms.publication.Document#getId()
*/
public String getId() {
- // throw new IllegalStateException("Use getUUID() or getPath() instead");
+ // throw new IllegalStateException("Use getUUID() or getPath()
+ // instead");
return this.identifier.getUUID();
}
@@ -182,9 +188,7 @@
}
public File getFile() {
- return getPublication().getPathMapper().getFile(getPublication(),
- getArea(),
- getUUID(),
+ return getPublication().getPathMapper().getFile(getPublication(), getArea(), getUUID(),
getLanguage());
}
@@ -257,8 +261,9 @@
throw new RuntimeException(e);
}
if (sourceExtension == null) {
- getLogger().warn("No source extension for document [" + this + "]. The extension \""
- + defaultSourceExtension + "\" will be used as default!");
+ getLogger().warn(
+ "No source extension for document [" + this + "]. The extension \""
+ + defaultSourceExtension + "\" will be used as default!");
sourceExtension = defaultSourceExtension;
}
return sourceExtension;
@@ -292,16 +297,20 @@
if (languages.length > 0) {
if (getLogger().isDebugEnabled()) {
- getLogger().debug("Document (" + this + ") exists in at least one language: "
- + languages.length);
+ getLogger().debug(
+ "Document (" + this + ") exists in at least one language: "
+ + languages.length);
}
String[] allLanguages = getPublication().getLanguages();
if (languages.length == allLanguages.length)
- // TODO: This is not entirely true, because the publication could assume the
- // languages EN and DE, but the document could exist for the languages DE and FR!
+ // TODO: This is not entirely true, because the publication
+ // could assume the
+ // languages EN and DE, but the document could exist for the
+ // languages DE and FR!
if (getLogger().isDebugEnabled()) {
- getLogger().debug("Document (" + this
- + ") exists even in all languages of this publication");
+ getLogger().debug(
+ "Document (" + this
+ + ") exists even in all languages of this publication");
}
return true;
} else {
@@ -407,7 +416,8 @@
private ResourceType resourceType;
/**
- * Convenience method to read the document's resource type from the meta-data.
+ * Convenience method to read the document's resource type from the
+ * meta-data.
* @see Document#getResourceType()
*/
public ResourceType getResourceType() throws DocumentException {
@@ -471,10 +481,8 @@
+ "] is not referenced in the site structure.");
}
try {
- return DocumentLocator.getLocator(getPublication().getId(),
- getArea(),
- structure.getByUuid(getUUID(), getLanguage()).getNode().getPath(),
- getLanguage());
+ return DocumentLocator.getLocator(getPublication().getId(), getArea(), structure
+ .getByUuid(getUUID(), getLanguage()).getNode().getPath(), getLanguage());
} catch (SiteException e) {
throw new RuntimeException(e);
}
@@ -573,15 +581,16 @@
public Link getLink() throws DocumentException {
SiteStructure structure = area().getSite();
- if (structure.containsByUuid(getUUID(), getLanguage())) {
- try {
+ try {
+ if (structure.containsByUuid(getUUID(), getLanguage())) {
return structure.getByUuid(getUUID(), getLanguage());
- } catch (SiteException e) {
- throw new DocumentException(e);
+ } else {
+ throw new DocumentException("The document [" + this
+ + "] is not referenced in the site structure!");
}
+ } catch (Exception e) {
+ throw new DocumentException(e);
}
- throw new DocumentException("The document [" + this
- + "] is not referenced in the site structure!");
}
public boolean hasLink() {
Modified: lenya/trunk/src/impl/test/org/apache/lenya/cms/site/SimpleSiteManagerTest.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/impl/test/org/apache/lenya/cms/site/SimpleSiteManagerTest.java?view=diff&rev=487257&r1=487256&r2=487257
==============================================================================
--- lenya/trunk/src/impl/test/org/apache/lenya/cms/site/SimpleSiteManagerTest.java (original)
+++ lenya/trunk/src/impl/test/org/apache/lenya/cms/site/SimpleSiteManagerTest.java Thu Dec 14 09:00:30 2006
@@ -155,6 +155,7 @@
assertEquals(docUuid, nodeUuid);
assertEquals(doc.getLanguage(), link.getLanguage());
+ // it may not be allowed to insert the doc twice
try {
siteManager.add("/sidebar", doc);
assertTrue("No exception thrown", false);
Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/AbstractLink.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/site/AbstractLink.java?view=diff&rev=487257&r1=487256&r2=487257
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/AbstractLink.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/AbstractLink.java Thu Dec 14 09:00:30 2006
@@ -113,5 +113,12 @@
public SiteNode getNode() {
return this.node;
}
+
+ public void setLabel(String label) {
+ this.label = label;
+ save();
+ }
+ protected void save() {}
+
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/NodeIterator.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/site/NodeIterator.java?view=diff&rev=487257&r1=487256&r2=487257
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/NodeIterator.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/NodeIterator.java Thu Dec 14 09:00:30 2006
@@ -21,6 +21,8 @@
import java.util.Collection;
import java.util.Iterator;
+import org.apache.lenya.util.Assert;
+
/**
* Node iterator.
*/
@@ -32,6 +34,7 @@
* @param collection The collection to iterate over.
*/
public NodeIterator(Collection collection) {
+ Assert.notNull("collection", collection);
this.delegate = collection.iterator();
}
@@ -39,6 +42,7 @@
* @param nodes The nodes to iterate over.
*/
public NodeIterator(SiteNode[] nodes) {
+ Assert.notNull("nodes", nodes);
this.delegate = Arrays.asList(nodes).iterator();
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/SiteNode.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/site/SiteNode.java?view=diff&rev=487257&r1=487256&r2=487257
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/SiteNode.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/SiteNode.java Thu Dec 14 09:00:30 2006
@@ -93,4 +93,19 @@
*/
SiteNode[] getChildren();
+ /**
+ * @return if the node has an external link.
+ */
+ boolean hasLink();
+
+ /**
+ * @return The external link.
+ */
+ String getHref();
+
+ /**
+ * @return The suffix.
+ */
+ String getSuffix();
+
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/simple/SimpleSiteNode.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/site/simple/SimpleSiteNode.java?view=diff&rev=487257&r1=487256&r2=487257
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/simple/SimpleSiteNode.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/simple/SimpleSiteNode.java Thu Dec 14 09:00:30 2006
@@ -89,4 +89,16 @@
return new SiteNode[0];
}
+ public String getHref() {
+ return null;
+ }
+
+ public String getSuffix() {
+ return null;
+ }
+
+ public boolean hasLink() {
+ return false;
+ }
+
}
Added: lenya/trunk/src/java/org/apache/lenya/util/StringUtil.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/util/StringUtil.java?view=auto&rev=487257
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/util/StringUtil.java (added)
+++ lenya/trunk/src/java/org/apache/lenya/util/StringUtil.java Thu Dec 14 09:00:30 2006
@@ -0,0 +1,42 @@
+/*
+ * 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.util;
+
+/**
+ * String utility.
+ */
+public final class StringUtil {
+
+ /**
+ * Joins an array of objects into a string.
+ * @param objects The objects.
+ * @param delimiter The delimiter to use.
+ * @return A string.
+ */
+ public static final String join(Object[] objects, String delimiter) {
+ StringBuffer buffer = new StringBuffer();
+ for (int i = 0; i < objects.length; i++) {
+ if (i > 0) {
+ buffer.append(delimiter);
+ }
+ buffer.append(objects[i].toString());
+ }
+ return buffer.toString();
+ }
+
+}
Modified: lenya/trunk/src/modules/export/java/src/org/apache/lenya/cms/export/Importer.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/export/java/src/org/apache/lenya/cms/export/Importer.java?view=diff&rev=487257&r1=487256&r2=487257
==============================================================================
--- lenya/trunk/src/modules/export/java/src/org/apache/lenya/cms/export/Importer.java (original)
+++ lenya/trunk/src/modules/export/java/src/org/apache/lenya/cms/export/Importer.java Thu Dec 14 09:00:30 2006
@@ -77,7 +77,6 @@
* @throws Exception if an error occurs.
*/
public void importContent(Publication srcPub, Area area, String path) throws Exception {
-
getLogger().info("Importing documents into area [" + area + "]");
String baseUri = "file://" + path;
@@ -194,7 +193,6 @@
protected void convertLinks(Publication srcPub, Document examinedDocument) {
boolean linksRewritten = false;
-
LinkResolver linkResolver = null;
try {
ResourceType type = examinedDocument.getResourceType();
Modified: lenya/trunk/src/modules/export/java/test/org/apache/lenya/cms/export/ImportTest.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/export/java/test/org/apache/lenya/cms/export/ImportTest.java?view=diff&rev=487257&r1=487256&r2=487257
==============================================================================
--- lenya/trunk/src/modules/export/java/test/org/apache/lenya/cms/export/ImportTest.java (original)
+++ lenya/trunk/src/modules/export/java/test/org/apache/lenya/cms/export/ImportTest.java Thu Dec 14 09:00:30 2006
@@ -34,7 +34,6 @@
public void testImport() throws Exception {
login("lenya");
-
Publication pub = getPublication("test");
Area area = pub.getArea("authoring");
Modified: lenya/trunk/src/modules/sitetree/config/cocoon-xconf/module.xconf
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/sitetree/config/cocoon-xconf/module.xconf?view=diff&rev=487257&r1=487256&r2=487257
==============================================================================
--- lenya/trunk/src/modules/sitetree/config/cocoon-xconf/module.xconf (original)
+++ lenya/trunk/src/modules/sitetree/config/cocoon-xconf/module.xconf Thu Dec 14 09:00:30 2006
@@ -21,6 +21,6 @@
<xconf xpath="/cocoon/site-managers" unless="/cocoon/site-managers/component-instance[@name = 'tree']">
<component-instance name="tree" logger="lenya.site"
- class="org.apache.lenya.cms.site.tree.TreeSiteManager"/>
+ class="org.apache.lenya.cms.site.tree2.TreeSiteManager"/>
</xconf>
Modified: lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/cocoon/generation/SitetreeFragmentGenerator.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/cocoon/generation/SitetreeFragmentGenerator.java?view=diff&rev=487257&r1=487256&r2=487257
==============================================================================
--- lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/cocoon/generation/SitetreeFragmentGenerator.java (original)
+++ lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/cocoon/generation/SitetreeFragmentGenerator.java Thu Dec 14 09:00:30 2006
@@ -38,8 +38,6 @@
import org.apache.lenya.cms.site.SiteManager;
import org.apache.lenya.cms.site.SiteNode;
import org.apache.lenya.cms.site.SiteStructure;
-import org.apache.lenya.cms.site.tree.SiteTree;
-import org.apache.lenya.cms.site.tree.SiteTreeNode;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
@@ -229,7 +227,7 @@
SiteStructure site = this.publication.getArea(this.area).getSite();
- SiteTreeNode node = (SiteTreeNode) site.getNode(this.path);
+ SiteNode node = site.getNode(this.path);
if (this.getLogger().isDebugEnabled()) {
this.getLogger().debug("Node with path " + this.path + " found.");
}
@@ -248,6 +246,7 @@
* Adds the given nodes (not recursive).
* @param children
* @throws SAXException
+ * @throws SiteException
*/
protected void addNodes(SiteNode[] children) throws SAXException, SiteException {
for (int i = 0; i < children.length; i++) {
@@ -273,7 +272,7 @@
try {
selector = (ServiceSelector) this.manager.lookup(SiteManager.ROLE + "Selector");
siteManager = (SiteManager) selector.select(this.publication.getSiteManagerHint());
- SiteTree siteTree = (SiteTree) this.publication.getArea(siteArea).getSite();
+ SiteStructure siteTree = this.publication.getArea(siteArea).getSite();
String label = "";
String isFolder = "";
@@ -290,7 +289,7 @@
if (siteArea.equals(Publication.STAGING_AREA))
label = "Staging";
- if (siteTree.getTopNodes().length > 0)
+ if (siteTree.getTopLevelNodes().length > 0)
isFolder = "true";
else
isFolder = "false";
@@ -303,7 +302,7 @@
startNode(NODE_SITE);
if (this.area.equals(siteArea)) {
- generateFragmentRecursive(siteTree.getTopNodes(), this.path);
+ generateFragmentRecursive(siteTree.getTopLevelNodes(), this.path);
}
endNode(NODE_SITE);
@@ -381,6 +380,7 @@
* @param nodeName the name of the new node
* @param node The attributes are taken from this node
* @throws SAXException if an error occurs while creating the node
+ * @throws SiteException
*/
protected void startNode(String nodeName, SiteNode node) throws SAXException, SiteException {
setNodeAttributes(node);
@@ -392,15 +392,16 @@
* language-suffix.
* @param node
* @throws SAXException if an error occurs while setting the attributes
+ * @throws SiteException
*/
protected void setNodeAttributes(SiteNode node) throws SAXException, SiteException {
this.attributes.clear();
String id = node.getName();
// String isVisible = Boolean.toString(node.visibleInNav());
- String hasLink = Boolean.toString(((SiteTreeNode) node).hasLink());
- String href = ((SiteTreeNode) node).getHref();
- String suffix = ((SiteTreeNode) node).getSuffix();
+ String hasLink = Boolean.toString(node.hasLink());
+ String href = node.getHref();
+ String suffix = node.getSuffix();
String isFolder = Boolean.toString(isFolder(node));
String uuid = node.getUuid();
Modified: lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/DefaultSiteTree.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/DefaultSiteTree.java?view=diff&rev=487257&r1=487256&r2=487257
==============================================================================
--- lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/DefaultSiteTree.java (original)
+++ lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/DefaultSiteTree.java Thu Dec 14 09:00:30 2006
@@ -112,16 +112,17 @@
}
/**
- * Checks if the tree file has been modified externally and reloads the site tree. protected
- * synchronized void checkModified() { if (this.area.equals(Publication.LIVE_AREA) &&
- * this.treefile.lastModified() > this.lastModified) {
+ * Checks if the tree file has been modified externally and reloads the site
+ * tree. protected synchronized void checkModified() { if
+ * (this.area.equals(Publication.LIVE_AREA) && this.treefile.lastModified() >
+ * this.lastModified) {
*
- * if (getLogger().isDebugEnabled()) { getLogger().debug("Sitetree [" + this.treefile + "] has
- * changed: reloading."); }
+ * if (getLogger().isDebugEnabled()) { getLogger().debug("Sitetree [" +
+ * this.treefile + "] has changed: reloading."); }
*
- * try { this.document = DocumentHelper.readDocument(this.treefile); } catch (Exception e) {
- * throw new IllegalStateException(e.getMessage()); } this.lastModified =
- * this.treefile.lastModified(); } }
+ * try { this.document = DocumentHelper.readDocument(this.treefile); } catch
+ * (Exception e) { throw new IllegalStateException(e.getMessage()); }
+ * this.lastModified = this.treefile.lastModified(); } }
*/
/**
@@ -134,15 +135,16 @@
Element root = document.getDocumentElement();
root.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
- root.setAttribute("xsi:schemaLocation",
- "http://apache.org/cocoon/lenya/sitetree/1.0 ../../../../resources/entities/sitetree.xsd");
+ root
+ .setAttribute("xsi:schemaLocation",
+ "http://apache.org/cocoon/lenya/sitetree/1.0 ../../../../resources/entities/sitetree.xsd");
return document;
}
/**
- * Find a node in a subtree. The search is started at the given node. The list of ids contains
- * the document-id split by "/".
+ * Find a node in a subtree. The search is started at the given node. The
+ * list of ids contains the document-id split by "/".
* @param node where to start the search
* @param ids list of node ids
* @return the node that matches the path given in the list of ids
@@ -170,19 +172,9 @@
return null;
}
- /**
- * @see org.apache.lenya.cms.site.tree.SiteTree#addNode(org.apache.lenya.cms.site.tree.SiteTreeNode,
- * java.lang.String)
- */
- public synchronized void addNode(SiteTreeNode node, String refpath) throws SiteException {
- SiteTreeNode target = addNode(node.getParent().getPath(),
- node.getName(),
- node.getUuid(),
- node.visibleInNav(),
- node.getHref(),
- node.getSuffix(),
- node.hasLink(),
- refpath);
+ protected synchronized void addNode(SiteTreeNode node, String refpath) throws SiteException {
+ SiteTreeNode target = addNode(node.getParent().getPath(), node.getName(), node.getUuid(),
+ node.isVisible(), node.getHref(), node.getSuffix(), node.hasLink(), refpath);
copyLinks(node, target);
}
@@ -193,23 +185,16 @@
}
}
- /**
- * @see org.apache.lenya.cms.site.tree.SiteTree#addNode(java.lang.String, java.lang.String,
- * String, boolean)
- */
- public synchronized void addNode(String parentid, String id, String uuid, boolean visibleInNav)
+ protected synchronized void addNode(String parentid, String id, String uuid, boolean visibleInNav)
throws SiteException {
addNode(parentid, id, uuid, visibleInNav, null, null, false);
}
- /**
- * @see org.apache.lenya.cms.site.tree.SiteTree#addNode(org.apache.lenya.cms.site.tree.SiteTreeNode)
- */
- public synchronized void addNode(SiteTreeNode node) throws SiteException {
+ protected synchronized void addNode(SiteTreeNode node) throws SiteException {
addNode(node, null);
}
- public synchronized SiteTreeNode addNode(String path, String uuid, boolean visibleInNav,
+ protected synchronized SiteTreeNodeImpl addNode(String path, String uuid, boolean visibleInNav,
String href, String suffix, boolean link, String refpath) throws SiteException {
StringBuffer buf = new StringBuffer();
StringTokenizer st = new StringTokenizer(path, "/");
@@ -223,16 +208,16 @@
return addNode(parentid, id, uuid, visibleInNav, href, suffix, link, refpath);
}
- public synchronized SiteTreeNode addNode(String path, String uuid, boolean visibleInNav,
+ protected synchronized SiteTreeNodeImpl addNode(String path, String uuid, boolean visibleInNav,
String href, String suffix, boolean link) throws SiteException {
return addNode(path, uuid, visibleInNav, href, suffix, link, null);
}
- public synchronized SiteTreeNode addNode(String parentid, String id, String uuid,
+ protected synchronized SiteTreeNodeImpl addNode(String parentid, String id, String uuid,
boolean visibleInNav, String href, String suffix, boolean link) throws SiteException {
return addNode(parentid + "/" + id, uuid, visibleInNav, href, suffix, link, null);
}
-
+
protected void createParents(final String path) throws SiteException {
String[] steps = path.substring(1).split("/");
int s = 0;
@@ -246,10 +231,10 @@
}
}
- public synchronized SiteTreeNode addNode(String parentPath, String name, String uuid,
+ protected synchronized SiteTreeNodeImpl addNode(String parentPath, String name, String uuid,
boolean visibleInNav, String href, String suffix, boolean link, String refpath)
throws SiteException {
-
+
String path = parentPath + "/" + name;
createParents(path);
@@ -263,7 +248,7 @@
if (childNode != null) {
getLogger().info("This node: " + path + " has already been inserted");
- return (SiteTreeNode) getNode(path);
+ return (SiteTreeNodeImpl) getNode(path);
}
// Create node
@@ -305,15 +290,12 @@
}
getLogger().debug("Tree has been modified: " + document.getDocumentElement());
saveDocument();
- return (SiteTreeNode) getNode(path);
+ return (SiteTreeNodeImpl) getNode(path);
}
- /**
- * @see org.apache.lenya.cms.site.tree.SiteTree#addLabel(String, String, String)
- */
- public synchronized void addLabel(String path, String language, String label) {
+ protected synchronized void addLabel(String path, String language, String label) {
try {
- SiteTreeNode node = (SiteTreeNode) getNode(path);
+ SiteTreeNodeImpl node = (SiteTreeNodeImpl) getNode(path);
if (node != null) {
node.addLabel(language, label);
}
@@ -323,12 +305,9 @@
}
}
- /**
- * @see org.apache.lenya.cms.site.tree.SiteTree#removeLabel(String, String)
- */
- public synchronized void removeLabel(String path, String language) {
+ protected synchronized void removeLabel(String path, String language) {
try {
- SiteTreeNode node = (SiteTreeNode) getNode(path);
+ SiteTreeNodeImpl node = (SiteTreeNodeImpl) getNode(path);
node.removeLabel(language);
saveDocument();
} catch (SiteException e) {
@@ -336,10 +315,7 @@
}
}
- /**
- * @see org.apache.lenya.cms.site.tree.SiteTree#removeNode(java.lang.String)
- */
- public synchronized SiteTreeNode removeNode(String path) {
+ protected synchronized SiteTreeNode removeNode(String path) {
assert path != null;
Node node;
@@ -372,7 +348,7 @@
} catch (SiteException e) {
throw new RuntimeException(e);
}
-
+
return newNode;
}
@@ -381,7 +357,8 @@
*
* @param path the document-id of the Node that we're trying to get
*
- * @return the Node if there is a Node for the given document-id, null otherwise
+ * @return the Node if there is a Node for the given document-id, null
+ * otherwise
* @throws SiteException
*/
private synchronized Node getNodeInternal(String path) throws SiteException {
@@ -421,28 +398,6 @@
}
/**
- * @see org.apache.lenya.cms.site.tree.SiteTree#getTopNodes()
- */
- public SiteTreeNode[] getTopNodes() {
- List childElements = new ArrayList();
-
- NamespaceHelper helper = new NamespaceHelper(NAMESPACE_URI, "", this.document);
-
- Element[] elements = helper.getChildren(this.document.getDocumentElement(),
- SiteTreeNodeImpl.NODE_NAME);
-
- for (int i = 0; i < elements.length; i++) {
- SiteTreeNode newNode = new SiteTreeNodeImpl(this.factory,
- this,
- elements[i],
- getLogger());
- childElements.add(newNode);
- }
-
- return (SiteTreeNode[]) childElements.toArray(new SiteTreeNode[childElements.size()]);
- }
-
- /**
* Move up the node amongst its siblings.
* @param path The document id for the node.
* @throws SiteException if the moving failed.
@@ -508,48 +463,7 @@
saveDocument();
}
- /**
- * @see org.apache.lenya.cms.site.tree.SiteTree#importSubtree(org.apache.lenya.cms.site.tree.SiteTreeNode,
- * org.apache.lenya.cms.site.tree.SiteTreeNode, java.lang.String, java.lang.String)
- */
- public synchronized void importSubtree(SiteTreeNode newParent, SiteTreeNode subtreeRoot,
- String newid, String refpath) throws SiteException {
- assert subtreeRoot != null;
- assert newParent != null;
- String parentId = newParent.getPath();
- String id = newid;
-
- String uuid = subtreeRoot.getUuid();
-
- SiteTreeNode targetRoot = this.addNode(parentId,
- id,
- uuid,
- subtreeRoot.visibleInNav(),
- subtreeRoot.getHref(),
- subtreeRoot.getSuffix(),
- subtreeRoot.hasLink(),
- refpath);
- copyLinks(subtreeRoot, targetRoot);
-
- newParent = (SiteTreeNode) this.getNode(parentId + "/" + id);
- if (newParent == null) {
- throw new SiteException("The added node was not found.");
- }
- SiteNode[] children = subtreeRoot.getChildren();
- if (children == null) {
- getLogger().info("The node " + subtreeRoot.toString() + " has no children");
- return;
- }
- for (int i = 0; i < children.length; i++) {
- importSubtree(newParent, (SiteTreeNode) children[i], children[i].getName(), null);
- }
- saveDocument();
- }
-
- /**
- * @see org.apache.lenya.cms.site.tree.SiteTree#setLabel(String, String, String)
- */
- public synchronized void setLabel(String path, String language, String label) {
+ protected synchronized void setLabel(String path, String language, String label) {
try {
SiteTreeNode node = (SiteTreeNode) getNode(path);
node.getLink(language).setLabel(label);
@@ -580,10 +494,7 @@
}
}
- /**
- * @see org.apache.lenya.cms.site.tree.SiteTree#save()
- */
- public void save() throws SiteException {
+ protected void save() throws SiteException {
saveDocument();
}
@@ -608,26 +519,14 @@
}
protected SiteNode getByUuidInternal(String uuid, String language) {
- // FIXME remove when UUID introduction is complete
- if (uuid.startsWith("/")) {
- if (contains(uuid)) {
- try {
- return getNode(uuid);
- } catch (SiteException e) {
- throw new RuntimeException(e);
- }
- }
- return null;
- } else {
- String xPath = "//*[@uuid = '" + uuid + "']";
- SiteNode[] nodes = getNodesByXpath(xPath);
- for (int i = 0; i < nodes.length; i++) {
- if (nodes[i].hasLink(language)) {
- return nodes[i];
- }
+ String xPath = "//*[@uuid = '" + uuid + "']";
+ SiteNode[] nodes = getNodesByXpath(xPath);
+ for (int i = 0; i < nodes.length; i++) {
+ if (nodes[i].hasLink(language)) {
+ return nodes[i];
}
- return null;
}
+ return null;
}
protected SiteNode getNodeByXpath(String xPath) {
@@ -680,7 +579,7 @@
}
}
- SiteTreeNode node = addNode(path, doc.getUUID(), true, null, "", false);
+ SiteTreeNodeImpl node = addNode(path, doc.getUUID(), true, null, "", false);
node.addLabel(doc.getLanguage(), "");
if (node.getLanguages().length == 1) {
@@ -715,10 +614,10 @@
return getRootNode().getChildren();
}
- protected SiteTreeNode getRootNode() {
- SiteTreeNode root;
+ protected SiteTreeNodeImpl getRootNode() {
+ SiteTreeNodeImpl root;
try {
- root = (SiteTreeNode) getNode("/");
+ root = (SiteTreeNodeImpl) getNode("/");
} catch (SiteException e) {
throw new RuntimeException(e);
}
Modified: lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/SiteTree.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/SiteTree.java?view=diff&rev=487257&r1=487256&r2=487257
==============================================================================
--- lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/SiteTree.java (original)
+++ lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/SiteTree.java Thu Dec 14 09:00:30 2006
@@ -34,157 +34,6 @@
String IDENTIFIABLE_TYPE = "site";
/**
- * Add a node.
- *
- * @param parentid where the node is to be added
- * @param id e.g. "concepts"
- * @param uuid The UUID.
- * @param labels the labels of the node that is to be added
- * @param visibleInNav the visibility of a node in the navigation. It is meant to hide specific nodes within the "public" navigation whereas the node is visible within the info/site area.
- *
- * @throws SiteException if the addition failed
- */
- void addNode(String parentid, String id, String uuid, boolean visibleInNav) throws SiteException;
-
- /**
- * Add a node. TODO: Lenya 1.2.X supports argument visibleInNav
- *
- * @param parentid the node where the new node is to be inserted
- * @param id the node id
- * @param uuid The UUID.
- * @param visibleInNav determines the visibility of a node in the navigation. It is meant to hide specific nodes within the "public" navigation whereas the node is visible within the info/site area.
- * @param href the href of the new node (internal and external references)
- * @param suffix the suffix of the new node
- * @param link Visibility of link respectively href. It is meant to support "grouping" nodes in the navigation which do not relate to a document (internal) or external link (www).
- * @return A node.
- *
- * @throws SiteException if the addition failed
- */
- SiteTreeNode addNode(String parentid, String id, String uuid, boolean visibleInNav, String href, String suffix,
- boolean link) throws SiteException;
-
- /**
- * Insert a node before a given node
- *
- * @param parentid the node where the new node is to be inserted
- * @param id the node id
- * @param uuid The UUID.
- * @param visibleInNav determines the visibility of a node in the navigation
- * @param href the href of the new node
- * @param suffix the suffix of the new node
- * @param link the link
- * @param refPath path of the node, before which the new node will be inserted.
- * @return A node.
- *
- * @throws SiteException if the addition failed
- */
- SiteTreeNode addNode(String parentid, String id, String uuid, boolean visibleInNav, String href, String suffix,
- boolean link, String refPath) throws SiteException;
-
- /**
- * Add a node. Compute the parent id and the id of the node from the path
- *
- * @param path the path of the new node. From this the parent-id and the id are
- * computed
- * @param uuid The UUID.
- * @param visibleInNav determines the visibility of a node in the navigation
- * @param href the href
- * @param suffix the suffix
- * @param link the link
- * @return A node.
- *
- * @throws SiteException if the addition failed
- */
- SiteTreeNode addNode(String path, String uuid, boolean visibleInNav, String href, String suffix, boolean link)
- throws SiteException;
-
- /**
- * Insert a node before a given node Compute the parent id and the id of the node from the
- * path
- *
- * @param path the path of the new node. From this the parent-id and the id are
- * computed
- * @param uuid The UUID.
- * @param visibleInNav determines the visibility of a node in the navigation
- * @param href the href
- * @param suffix the suffix
- * @param link the link
- * @param refpath path of the node, before which the new node will be inserted.
- * @return A node.
- *
- * @throws SiteException if the addition failed
- */
- SiteTreeNode addNode(String path, String uuid, boolean visibleInNav, String href, String suffix, boolean link,
- String refpath) throws SiteException;
-
- /**
- * Add a node. This method is typically used when publishing, i.e. when copying a node from the
- * authoring tree to the live tree. The existing node already has a parent node (in the
- * authoring tree). The node that is added will be a copy of the original node and will be
- * inserted at the same parentid as the original node.
- *
- * @param node the <code>SiteTreeNode</code> that is to be added
- *
- * @throws SiteException if the addition failed
- */
- void addNode(SiteTreeNode node) throws SiteException;
-
- /**
- * Add a node. This method is typically used when publishing, i.e. when copying a node from the
- * authoring tree to the live tree. The existing node already has a parent node (in the
- * authoring tree). The node that is added will be a copy of the original node and will be
- * inserted at the same parentid as the original node.
- *
- * @param node the <code>SiteTreeNode</code> that is to be added
- * @param refpath path of the node, before which the new node will be inserted.
- *
- * @throws SiteException if the addition failed
- */
- void addNode(SiteTreeNode node, String refpath) throws SiteException;
-
- /**
- * Add a label to an existing node
- *
- * @param path the path to which the label is to be added.
- * @param language The language.
- * @param label the label to add
- */
- void addLabel(String path, String language, String label);
-
- /**
- * Sets a label of an existing node. If the label does not exist, it is added. Otherwise, the
- * existing label is replaced.
- *
- * @param path the path to which the label is to be added.
- * @param language The language.
- * @param label the label to add
- */
- void setLabel(String path, String language, String label);
-
- /**
- * Remove a label from a node
- *
- * @param path the path from which the label is to be removed.
- * @param language The language.
- */
- void removeLabel(String path, String language);
-
- /**
- * Removes the node corresponding to the given path from the tree, and returns it.
- *
- * @param path the path of the node that is to be removed
- *
- * @return the removed node
- */
- SiteTreeNode removeNode(String path);
-
- /**
- * Return the top level nodes in the sitetree.
- * @return the top nodes in the sitetree, or empty array if there are none
- */
- SiteTreeNode[] getTopNodes();
-
- /**
* Move up the node amongst its siblings.
*
* @param path The document id of the node.
@@ -199,23 +48,4 @@
*/
void moveDown(String path) throws SiteException;
- /**
- * Imports a subtree (from this or from another tree) at a certain position.
- * @param subtreeRoot The root of the subtree to import.
- * @param newParent The node where the subtree shall be inserted.
- * @param newid The new id of the inserted subtreeRoot node (to not overwrite
- * @param refpath The path corresponding to the reference node, before which the
- * subtree should be inserted. If null, the subtree is inserted at the end. in case
- * there is already a node with the same id in the tree).
- * @throws SiteException when an error occurs.
- */
- void importSubtree(SiteTreeNode subtreeRoot, SiteTreeNode newParent, String newid,
- String refpath) throws SiteException;
-
- /**
- * Saves the tree. Call this method after a node has been changed.
- * @throws SiteException if an error occurs.
- */
- void save() throws SiteException;
-
}
Modified: lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/SiteTreeLink.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/SiteTreeLink.java?view=diff&rev=487257&r1=487256&r2=487257
==============================================================================
--- lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/SiteTreeLink.java (original)
+++ lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/SiteTreeLink.java Thu Dec 14 09:00:30 2006
@@ -35,7 +35,7 @@
}
public void delete() {
- SiteTreeNode node = (SiteTreeNode) getNode();
+ SiteTreeNodeImpl node = (SiteTreeNodeImpl) getNode();
node.removeLabel(getLanguage());
}
Modified: lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/SiteTreeNode.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/SiteTreeNode.java?view=diff&rev=487257&r1=487256&r2=487257
==============================================================================
--- lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/SiteTreeNode.java (original)
+++ lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/SiteTreeNode.java Thu Dec 14 09:00:30 2006
@@ -20,10 +20,6 @@
package org.apache.lenya.cms.site.tree;
-import java.util.List;
-
-import org.apache.lenya.cms.publication.DocumentException;
-import org.apache.lenya.cms.site.SiteException;
import org.apache.lenya.cms.site.SiteNode;
/**
@@ -34,81 +30,6 @@
public interface SiteTreeNode extends SiteNode {
/**
- * Returns the parent node of this node or null if the parent has no label for the given language.
- * @param language A language string.
- * @return A sitetree node.
- */
- SiteTreeNode getParent(String language);
-
- /**
- * Add a label to this node iff the node does not have this label already.
- * @param language The language.
- * @param label the label to be added.
- * @throws SiteException if the label is already contained.
- */
- void addLabel(String language, String label) throws SiteException;
-
- /**
- * Remove a label from this node.
- *
- * @param language the label to be removed.
- */
- void removeLabel(String language);
-
- /**
- * Check whether this node is visible in the navigation
- *
- * @return true if this node is visible. The method should also
- * return true if the attribute is not set. That means a node missing
- * this attribute becomes visible by default.
- */
- boolean visibleInNav();
-
- /**
- * Get the href of this node.
- *
- * @return the href.
- */
- String getHref();
-
- /**
- * Get the suffix of this node.
- *
- * @return the suffix.
- */
- String getSuffix();
-
- /**
- * Check whether this node has a link.
- *
- * @return true if this node has a link.
- */
- boolean hasLink();
-
- /**
- * Get the sitetreenodes, which are children of this node
- *
- * @return the children.
- */
- SiteNode[] getChildren();
-
- /**
- * Get the sitetreenodes, which are children of this node
- * and contain a label for the given language.
- *
- * @param language A language string.
- * @return the children.
- */
- SiteTreeNode[] getChildren(String language);
-
- /**
- * Remove the children of the node
- *
- * @return the removed node
- */
- SiteTreeNode[] removeChildren();
-
- /**
* Get the sitetreenodes, which are the siblings preceding this node
*
* @return the children.
@@ -121,72 +42,5 @@
* @return the children.
*/
SiteTreeNode[] getNextSiblings();
-
- /**
- * @return string. The document-id corresponding to the next sibling node.
- */
- String getNextSiblingDocumentId();
-
- /**
- * Call the visit method of the visitor, that mean
- * the operation that shall be perfoemed on this node
- * (Visitor pattern)
- * @param visitor The visitor.
- *
- * @throws DocumentException if an error occurs
- */
- void accept(SiteTreeNodeVisitor visitor) throws DocumentException;
-
- /**
- * Traverse the node ant its children and call the
- * accept method.
- * @param visitor The visitor.
- *
- * @throws DocumentException if an error occurs
- */
- void acceptSubtree(SiteTreeNodeVisitor visitor) throws DocumentException;
-
- /**
- * Traverse in a reverse way the node ant its children and call the
- * accept method.
- * @param visitor The visitor.
- *
- * @throws DocumentException if an error occurs
- */
- void acceptReverseSubtree(SiteTreeNodeVisitor visitor) throws DocumentException;
-
- /**
- * Sets an attribute of this node. If the attribute already exists its value will be overwritten
- *
- * @param attributeName name of the attribute
- * @param attributeValue the value of the respective attribute
- */
- void setNodeAttribute (String attributeName, String attributeValue);
-
- /**
- * Returns an attribute of this node.
- *
- * @param attributeName name of the attribute
- * @return The value.
- */
- String getNodeAttribute (String attributeName);
-
- /**
- * Give a list of the children and this node in a pre order way
- * @return The list
- */
- List preOrder();
-
- /**
- * Give a list of the children and this node in a post order way
- * @return The list
- */
- List postOrder();
-
- /**
- * Sets the UUID of a node.
- * @param uuid The UUID.
- */
- void setUUID(String uuid);
}
Modified: lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/SiteTreeNodeImpl.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/SiteTreeNodeImpl.java?view=diff&rev=487257&r1=487256&r2=487257
==============================================================================
--- lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/SiteTreeNodeImpl.java (original)
+++ lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/SiteTreeNodeImpl.java Thu Dec 14 09:00:30 2006
@@ -83,7 +83,7 @@
public static final String LABEL_NAME = "label";
private Element node = null;
- private SiteTree tree;
+ private DefaultSiteTree tree;
private DocumentFactory factory;
@@ -96,7 +96,7 @@
*
* @param _node the node which is to be wrapped by this SiteTreeNode
*/
- protected SiteTreeNodeImpl(DocumentFactory factory, SiteTree tree, Element node, Logger logger) {
+ protected SiteTreeNodeImpl(DocumentFactory factory, DefaultSiteTree tree, Element node, Logger logger) {
ContainerUtil.enableLogging(this, logger);
this.node = node;
this.tree = tree;
@@ -384,17 +384,14 @@
return;
}
for (int i = 0; i < children.length; i++) {
- ((SiteTreeNode) children[i]).acceptSubtree(visitor);
+ ((SiteTreeNodeImpl) children[i]).acceptSubtree(visitor);
}
}
- /**
- * @see org.apache.lenya.cms.site.tree.SiteTreeNode#acceptReverseSubtree(org.apache.lenya.cms.site.tree.SiteTreeNodeVisitor)
- */
- public void acceptReverseSubtree(SiteTreeNodeVisitor visitor) throws DocumentException {
+ protected void acceptReverseSubtree(SiteTreeNodeVisitor visitor) throws DocumentException {
List orderedNodes = this.postOrder();
for (int i = 0; i < orderedNodes.size(); i++) {
- SiteTreeNode _node = (SiteTreeNode) orderedNodes.get(i);
+ SiteTreeNodeImpl _node = (SiteTreeNodeImpl) orderedNodes.get(i);
_node.accept(visitor);
}
}
@@ -406,7 +403,7 @@
List list = new ArrayList();
SiteNode[] children = this.getChildren();
for (int i = 0; i < children.length; i++) {
- List orderedChildren = ((SiteTreeNode) children[i]).postOrder();
+ List orderedChildren = ((SiteTreeNodeImpl) children[i]).postOrder();
list.addAll(orderedChildren);
}
list.add(this);
@@ -490,7 +487,7 @@
list.add(this);
SiteNode[] children = this.getChildren();
for (int i = 0; i < children.length; i++) {
- List orderedChildren = ((SiteTreeNode) children[i]).preOrder();
+ List orderedChildren = ((SiteTreeNodeImpl) children[i]).preOrder();
list.addAll(orderedChildren);
}
return list;
@@ -509,7 +506,7 @@
return getTree();
}
- protected SiteTree getTree() {
+ protected DefaultSiteTree getTree() {
return this.tree;
}
Modified: lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/TreeSiteManager.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/TreeSiteManager.java?view=diff&rev=487257&r1=487256&r2=487257
==============================================================================
--- lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/TreeSiteManager.java (original)
+++ lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/TreeSiteManager.java Thu Dec 14 09:00:30 2006
@@ -60,7 +60,7 @@
* @return A site tree.
* @throws SiteException if an error occurs.
*/
- public SiteTree getTree(DocumentFactory map, Publication publication, String area)
+ public DefaultSiteTree getTree(DocumentFactory map, Publication publication, String area)
throws SiteException {
String key = getKey(publication, area);
@@ -75,7 +75,7 @@
return sitetree;
}
- protected SiteTree getTree(Document document) throws SiteException {
+ protected DefaultSiteTree getTree(Document document) throws SiteException {
return getTree(document.getFactory(), document.getPublication(), document.getArea());
}
@@ -139,7 +139,7 @@
String area = resource.getStructure().getArea();
SiteTree tree = getTree(map, pub, area);
- SiteTreeNode node = (SiteTreeNode) tree.getNode(resource.getPath());
+ SiteTreeNodeImpl node = (SiteTreeNodeImpl) tree.getNode(resource.getPath());
if (node != null) {
List preOrder = node.preOrder();
@@ -180,7 +180,7 @@
* org.apache.lenya.cms.publication.Document)
*/
public void copy(Document sourceDocument, Document destinationDocument) throws SiteException {
- SiteTree destinationTree = getTree(destinationDocument);
+ DefaultSiteTree destinationTree = getTree(destinationDocument);
try {
SiteTreeNode sourceNode = (SiteTreeNode) sourceDocument.getLink().getNode();
@@ -218,7 +218,7 @@
if (siblingPath == null) {
destinationTree.addNode(destinationDocument.getPath(),
destinationDocument.getUUID(),
- sourceNode.visibleInNav(),
+ sourceNode.isVisible(),
sourceNode.getHref(),
sourceNode.getSuffix(),
sourceNode.hasLink());
@@ -228,7 +228,7 @@
} else {
destinationTree.addNode(destinationDocument.getPath(),
destinationDocument.getUUID(),
- sourceNode.visibleInNav(),
+ sourceNode.isVisible(),
sourceNode.getHref(),
sourceNode.getSuffix(),
sourceNode.hasLink(),
@@ -251,19 +251,6 @@
}
/**
- * @see org.apache.lenya.cms.site.SiteManager#setLabel(org.apache.lenya.cms.publication.Document,
- * java.lang.String)
- */
- public void setLabel(Document document, String label) throws SiteException {
- SiteTree tree = getTree(document);
- try {
- tree.setLabel(document.getPath(), document.getLanguage(), label);
- } catch (DocumentException e) {
- throw new SiteException(e);
- }
- }
-
- /**
* @see org.apache.lenya.cms.site.SiteManager#setVisibleInNav(org.apache.lenya.cms.publication.Document,
* boolean)
*/
@@ -309,7 +296,7 @@
public Document[] getDocuments(DocumentFactory map, Publication publication, String area)
throws SiteException {
try {
- SiteTreeNode root = (SiteTreeNode) getTree(map, publication, area).getNode("/");
+ SiteTreeNodeImpl root = (SiteTreeNodeImpl) getTree(map, publication, area).getNode("/");
List allNodes = root.preOrder();
List documents = new ArrayList();
@@ -327,15 +314,12 @@
}
}
- /**
- * @see org.apache.lenya.cms.site.SiteManager#add(org.apache.lenya.cms.publication.Document)
- */
public void add(String path, Document document) throws SiteException {
if (contains(document)) {
throw new SiteException("The document [" + document + "] is already contained!");
}
- SiteTree tree = getTree(document);
+ DefaultSiteTree tree = getTree(document);
SiteTreeNode node;
if (!tree.contains(path)) {
@@ -349,16 +333,13 @@
tree.addLabel(path, document.getLanguage(), "");
}
- /**
- * @see org.apache.lenya.cms.site.SiteManager#set(org.apache.lenya.cms.publication.Document)
- */
public void set(String path, Document document) throws SiteException {
if (contains(document)) {
throw new SiteException("The document [" + document + "] is already contained!");
}
- SiteTree tree = getTree(document);
- SiteTreeNode node = (SiteTreeNode) tree.getNode(path);
+ DefaultSiteTree tree = getTree(document);
+ SiteTreeNodeImpl node = (SiteTreeNodeImpl) tree.getNode(path);
node.setUUID(document.getUUID());
tree.save();
}
@@ -395,8 +376,8 @@
/**
* compute an unique document id
- *
- * @param document The document.
+ * @param factory The factory.
+ * @param locator The locator.
* @return the unique documentid
* @throws SiteException if an error occurs.
*/
Added: lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/RootNode.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/RootNode.java?view=auto&rev=487257
==============================================================================
--- lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/RootNode.java (added)
+++ lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/RootNode.java Thu Dec 14 09:00:30 2006
@@ -0,0 +1,64 @@
+/*
+ * 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.cms.site.tree2;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.lenya.cms.site.SiteNode;
+
+/**
+ * Root node.
+ */
+public class RootNode extends TreeNodeImpl {
+
+ private SiteTreeImpl tree;
+
+ /**
+ * @param tree The tree.
+ * @param logger The logger.
+ */
+ public RootNode(SiteTreeImpl tree, Logger logger) {
+ super(null, "", false, logger);
+ this.tree = tree;
+ }
+
+ public SiteTreeImpl getTree() {
+ return this.tree;
+ }
+
+ public String getPath() {
+ return "";
+ }
+
+ public SiteNode[] preOrder() {
+ List preOrder = new ArrayList();
+ SiteNode[] children = getChildren();
+ for (int i = 0; i < children.length; i++) {
+ TreeNode child = (TreeNode) children[i];
+ preOrder.addAll(Arrays.asList(child.preOrder()));
+ }
+ return (SiteNode[]) preOrder.toArray(new SiteNode[preOrder.size()]);
+ }
+
+ protected void deleteIfEmpty() {
+ }
+
+}
Added: lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/SiteTreeFactory.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/SiteTreeFactory.java?view=auto&rev=487257
==============================================================================
--- lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/SiteTreeFactory.java (added)
+++ lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/SiteTreeFactory.java Thu Dec 14 09:00:30 2006
@@ -0,0 +1,73 @@
+/*
+ * 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.cms.site.tree2;
+
+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.ServiceManager;
+import org.apache.lenya.cms.publication.Area;
+import org.apache.lenya.cms.publication.DocumentFactory;
+import org.apache.lenya.cms.publication.DocumentUtil;
+import org.apache.lenya.cms.publication.Publication;
+import org.apache.lenya.cms.repository.RepositoryException;
+import org.apache.lenya.cms.repository.RepositoryItem;
+import org.apache.lenya.cms.repository.RepositoryItemFactory;
+import org.apache.lenya.cms.repository.Session;
+import org.apache.lenya.cms.site.tree.SiteTree;
+
+/**
+ * Factory for sitetree objects.
+ *
+ * @version $Id: SiteTreeFactory.java 179568 2005-06-02 09:27:26Z jwkaltz $
+ */
+public class SiteTreeFactory extends AbstractLogEnabled implements RepositoryItemFactory {
+
+ protected ServiceManager manager;
+
+ /**
+ * Ctor.
+ * @param manager The service manager.
+ * @param logger The logger.
+ */
+ public SiteTreeFactory(ServiceManager manager, Logger logger) {
+ this.manager = manager;
+ ContainerUtil.enableLogging(this, logger);
+ }
+
+ public RepositoryItem buildItem(Session session, String key) throws RepositoryException {
+ String[] snippets = key.split(":");
+ String publicationId = snippets[0];
+ String areaName = snippets[1];
+ SiteTreeImpl tree;
+ try {
+ DocumentFactory factory = DocumentUtil.createDocumentFactory(this.manager, session);
+ Publication publication = factory.getPublication(publicationId);
+ Area area = publication.getArea(areaName);
+ tree = new SiteTreeImpl(this.manager, area, getLogger());
+ } catch (Exception e) {
+ throw new RepositoryException(e);
+ }
+ return tree;
+ }
+
+ public String getItemType() {
+ return SiteTree.IDENTIFIABLE_TYPE;
+ }
+
+}
\ No newline at end of file
Added: lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/SiteTreeImpl.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/SiteTreeImpl.java?view=auto&rev=487257
==============================================================================
--- lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/SiteTreeImpl.java (added)
+++ lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/SiteTreeImpl.java Thu Dec 14 09:00:30 2006
@@ -0,0 +1,385 @@
+/*
+ * 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.cms.site.tree2;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+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.ServiceManager;
+import org.apache.excalibur.source.SourceResolver;
+import org.apache.lenya.cms.cocoon.source.RepositorySource;
+import org.apache.lenya.cms.cocoon.source.SourceUtil;
+import org.apache.lenya.cms.publication.Area;
+import org.apache.lenya.cms.publication.Document;
+import org.apache.lenya.cms.publication.Publication;
+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.cms.site.tree.SiteTree;
+import org.apache.lenya.util.Assert;
+import org.apache.lenya.xml.DocumentHelper;
+import org.apache.lenya.xml.NamespaceHelper;
+import org.w3c.dom.Element;
+
+/**
+ * Simple site tree implementation.
+ */
+public class SiteTreeImpl extends AbstractLogEnabled implements SiteStructure, SiteTree {
+
+ private Area area;
+ protected ServiceManager manager;
+ private RootNode root;
+
+ /**
+ * @param manager The service manager.
+ * @param area The area.
+ * @param logger The logger.
+ */
+ public SiteTreeImpl(ServiceManager manager, Area area, Logger logger) {
+ ContainerUtil.enableLogging(this, logger);
+ this.area = area;
+ this.manager = manager;
+ this.root = new RootNode(this, getLogger());
+ nodeAdded(root);
+ }
+
+ private String sourceUri;
+
+ protected String getSourceUri() {
+ if (this.sourceUri == null) {
+ String baseUri = this.area.getPublication().getContentURI(this.area.getName());
+ this.sourceUri = baseUri + "/sitetree.xml";
+ }
+ return this.sourceUri;
+ }
+
+ private boolean loaded = false;
+
+ protected static final String NAMESPACE = "http://apache.org/cocoon/lenya/sitetree/1.0";
+
+ private static final boolean DEFAULT_VISIBILITY = true;
+
+ protected void load() {
+ try {
+ if (!loaded) {
+ if (SourceUtil.exists(getSourceUri(), this.manager)) {
+ org.w3c.dom.Document xml = SourceUtil.readDOM(getSourceUri(), this.manager);
+ NamespaceHelper helper = new NamespaceHelper(NAMESPACE, "", xml);
+ Assert.isTrue("document element is site", xml.getDocumentElement()
+ .getLocalName().equals("site"));
+ loadNodes(getRoot(), helper, xml.getDocumentElement());
+ }
+ loaded = true;
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ protected RootNode getRoot() {
+ return this.root;
+ }
+
+ protected void loadNodes(TreeNode parent, NamespaceHelper helper, Element element) {
+ Element[] nodeElements = helper.getChildren(element, "node");
+ for (int n = 0; n < nodeElements.length; n++) {
+ String name = nodeElements[n].getAttribute("id");
+ boolean visible = DEFAULT_VISIBILITY;
+ if (nodeElements[n].hasAttribute("visibleinnav")) {
+ String visibleString = nodeElements[n].getAttribute("visibleinnav");
+ visible = Boolean.valueOf(visibleString).booleanValue();
+ }
+ TreeNodeImpl node = (TreeNodeImpl) parent.addChild(name, visible);
+ if (nodeElements[n].hasAttribute("uuid")) {
+ String uuid = nodeElements[n].getAttribute("uuid");
+ node.setUuid(uuid);
+ }
+ loadLinks(node, helper, nodeElements[n]);
+ loadNodes(node, helper, nodeElements[n]);
+ }
+ }
+
+ protected void loadLinks(TreeNodeImpl node, NamespaceHelper helper, Element element) {
+ Element[] linkElements = helper.getChildren(element, "label");
+ for (int l = 0; l < linkElements.length; l++) {
+ String lang = linkElements[l].getAttribute("xml:lang");
+ String label = DocumentHelper.getSimpleElementText(linkElements[l]);
+ node.addLink(lang, label);
+ }
+ }
+
+ protected void save() {
+ if (!loaded) {
+ return;
+ }
+ try {
+ NamespaceHelper helper = new NamespaceHelper(NAMESPACE, "", "site");
+ saveNodes(getRoot(), helper, helper.getDocument().getDocumentElement());
+ SourceUtil.writeDOM(helper.getDocument(), getSourceUri(), this.manager);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+
+ }
+
+ protected void saveNodes(TreeNode parent, NamespaceHelper helper, Element parentElement)
+ throws SiteException {
+ SiteNode[] children = parent.getChildren();
+ for (int i = 0; i < children.length; i++) {
+ Element nodeElement = helper.createElement("node");
+ nodeElement.setAttribute("id", children[i].getName());
+ String uuid = children[i].getUuid();
+ if (uuid != null) {
+ nodeElement.setAttribute("uuid", uuid);
+ }
+ nodeElement.setAttribute("visibleinnav", Boolean.toString(children[i].isVisible()));
+ saveLinks(children[i], helper, nodeElement);
+ saveNodes((TreeNode) children[i], helper, nodeElement);
+ parentElement.appendChild(nodeElement);
+ }
+ }
+
+ protected void saveLinks(SiteNode node, NamespaceHelper helper, Element nodeElement)
+ throws SiteException {
+ String[] languages = node.getLanguages();
+ for (int i = 0; i < languages.length; i++) {
+ Link link = node.getLink(languages[i]);
+ Element linkElement = helper.createElement("label", link.getLabel());
+ linkElement.setAttribute("xml:lang", languages[i]);
+ nodeElement.appendChild(linkElement);
+ }
+ }
+
+ public Link add(String path, Document doc) throws SiteException {
+
+ if (containsByUuid(doc.getUUID(), doc.getLanguage())) {
+ throw new SiteException("The document [" + doc + "] is already contained!");
+ }
+
+ TreeNodeImpl node;
+ if (contains(path)) {
+ node = getTreeNode(path);
+ if (node.getUuid() == null) {
+ node.setUuid(doc.getUUID());
+ } else if (!node.getUuid().equals(doc.getUUID())) {
+ throw new SiteException("The node already has a different UUID!");
+ }
+ } else {
+ node = (TreeNodeImpl) add(path);
+ node.setUuid(doc.getUUID());
+ }
+ return node.addLink(doc.getLanguage(), "");
+ }
+
+ protected TreeNodeImpl getTreeNode(String path) throws SiteException {
+ return (TreeNodeImpl) getNode(path);
+ }
+
+ public SiteNode add(String path) throws SiteException {
+ String parentPath = getParentPath(path);
+ String nodeName = path.substring(parentPath.length() + 1);
+ if (!contains(parentPath)) {
+ add(parentPath);
+ }
+ return getTreeNode(parentPath).addChild(nodeName, DEFAULT_VISIBILITY);
+ }
+
+ public SiteNode add(String path, String followingSiblingPath) throws SiteException {
+ String parentPath = getParentPath(path);
+ String nodeName = path.substring(parentPath.length() + 1);
+
+ if (!followingSiblingPath.startsWith(parentPath + "/")) {
+ throw new SiteException("Invalid following sibling path [" + followingSiblingPath + "]");
+ }
+
+ String followingNodeName = followingSiblingPath.substring(parentPath.length() + 1);
+
+ if (!contains(parentPath)) {
+ add(parentPath);
+ }
+ return getTreeNode(parentPath).addChild(nodeName, followingNodeName, DEFAULT_VISIBILITY);
+ }
+
+ protected String getParentPath(String path) {
+ int lastIndex = path.lastIndexOf("/");
+ String parentPath = path.substring(0, lastIndex);
+ return parentPath;
+ }
+
+ private Map path2node = new HashMap();
+ private Map uuidLanguage2link = new HashMap();
+
+ protected void nodeAdded(SiteNode node) {
+ this.path2node.put(node.getPath(), node);
+ }
+
+ protected void linkAdded(Link link) {
+ this.uuidLanguage2link.put(getKey(link), link);
+ }
+
+ protected String getKey(Link link) {
+ String uuid = link.getDocument().getUUID();
+ Assert.notNull("uuid", uuid);
+ String language = link.getLanguage();
+ Assert.notNull("language", language);
+ return getKey(uuid, language);
+ }
+
+ protected String getKey(String uuid, String language) {
+ Assert.notNull("uuid", uuid);
+ Assert.notNull("language", language);
+ return uuid + ":" + language;
+ }
+
+ protected void nodeRemoved(String path) {
+ Assert.notNull("path", path);
+ Assert.isTrue("path [" + path + "] contained", this.path2node.containsKey(path));
+ this.path2node.remove(path);
+ }
+
+ protected Map getUuidLanguage2Link() {
+ load();
+ return this.uuidLanguage2link;
+ }
+
+ protected Map getPath2Node() {
+ load();
+ return this.path2node;
+ }
+
+ public boolean contains(String path) {
+ load();
+ Assert.notNull("path", path);
+ return this.path2node.containsKey(path);
+ }
+
+ public boolean containsByUuid(String uuid, String language) {
+ Assert.notNull("uuid", uuid);
+ Assert.notNull("language", language);
+ return getUuidLanguage2Link().containsKey(getKey(uuid, language));
+ }
+
+ public boolean containsInAnyLanguage(String uuid) {
+ Assert.notNull("uuid", uuid);
+ Set set = getUuidLanguage2Link().keySet();
+ String[] keys = (String[]) set.toArray(new String[set.size()]);
+ for (int i = 0; i < keys.length; i++) {
+ if (keys[i].startsWith(uuid + ":")) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public String getArea() {
+ return this.area.getName();
+ }
+
+ public Link getByUuid(String uuid, String language) throws SiteException {
+ Assert.notNull("uuid", uuid);
+ Assert.notNull("language", language);
+ String key = getKey(uuid, language);
+ if (!getUuidLanguage2Link().containsKey(key)) {
+ throw new SiteException("No link for [" + key + "]");
+ }
+ return (Link) getUuidLanguage2Link().get(key);
+ }
+
+ public SiteNode getNode(String path) throws SiteException {
+ Assert.notNull("path", path);
+ if (!getPath2Node().containsKey(path)) {
+ throw new SiteException("No node for path [" + path + "]");
+ }
+ return (SiteNode) this.path2node.get(path);
+ }
+
+ public SiteNode[] getNodes() {
+ return getRoot().preOrder();
+ }
+
+ public Publication getPublication() {
+ return this.area.getPublication();
+ }
+
+ private Node repositoryNode;
+
+ public Node getRepositoryNode() {
+ if (this.repositoryNode == null) {
+ SourceResolver resolver = null;
+ RepositorySource source = null;
+ try {
+ resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
+ source = (RepositorySource) resolver.resolveURI(getSourceUri());
+ this.repositoryNode = source.getNode();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ } finally {
+ if (resolver != null) {
+ if (source != null) {
+ resolver.release(source);
+ }
+ this.manager.release(resolver);
+ }
+ }
+ }
+ return this.repositoryNode;
+ }
+
+ public SiteNode[] getTopLevelNodes() {
+ return getRoot().getChildren();
+ }
+
+ protected void linkRemoved(String uuid, String language) {
+ Assert.notNull("uuid", uuid);
+ Assert.notNull("language", language);
+ String key = getKey(uuid, language);
+ Assert.isTrue("contained", this.uuidLanguage2link.containsKey(key));
+ this.uuidLanguage2link.remove(key);
+ }
+
+ protected String getPath() {
+ return "";
+ }
+
+ /**
+ * @return The nodes in pre-order enumeration.
+ */
+ public SiteNode[] preOrder() {
+ return getRoot().preOrder();
+ }
+
+ public void moveDown(String path) throws SiteException {
+ TreeNode node = getTreeNode(path);
+ TreeNode parent = (TreeNode) node.getParent();
+ parent.moveDown(node.getName());
+
+ }
+
+ public void moveUp(String path) throws SiteException {
+ TreeNode node = getTreeNode(path);
+ TreeNode parent = (TreeNode) node.getParent();
+ parent.moveUp(node.getName());
+ }
+
+}
Added: lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/SiteTreeLink.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/SiteTreeLink.java?view=auto&rev=487257
==============================================================================
--- lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/SiteTreeLink.java (added)
+++ lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/SiteTreeLink.java Thu Dec 14 09:00:30 2006
@@ -0,0 +1,44 @@
+/*
+ * 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.cms.site.tree2;
+
+import org.apache.lenya.cms.publication.DocumentFactory;
+import org.apache.lenya.cms.site.AbstractLink;
+import org.apache.lenya.cms.site.SiteNode;
+
+/**
+ * SiteTree link.
+ */
+public class SiteTreeLink extends AbstractLink {
+
+ protected SiteTreeLink(DocumentFactory factory, SiteNode node,
+ String label, String language) {
+ super(factory, node, label, language);
+ }
+
+ public void delete() {
+ TreeNodeImpl node = (TreeNodeImpl) getNode();
+ node.removeLink(getLanguage());
+ }
+
+ public void save() {
+ TreeNodeImpl node = (TreeNodeImpl) getNode();
+ node.changed();
+ }
+
+}
Added: lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/TreeNode.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/TreeNode.java?view=auto&rev=487257
==============================================================================
--- lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/TreeNode.java (added)
+++ lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/TreeNode.java Thu Dec 14 09:00:30 2006
@@ -0,0 +1,73 @@
+/*
+ * 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.cms.site.tree2;
+
+import org.apache.lenya.cms.site.SiteNode;
+import org.apache.lenya.cms.site.tree.SiteTreeNode;
+
+/**
+ * A parent for nodes.
+ */
+public interface TreeNode extends SiteNode, SiteTreeNode {
+
+ /**
+ * @return The children.
+ */
+ SiteNode[] getChildren();
+
+ /**
+ * @return Preorder enumeration.
+ */
+ SiteNode[] preOrder();
+
+ /**
+ * @param name The name.
+ * @param visible The navigation visibility.
+ * @return A site node.
+ */
+ SiteNode addChild(String name, boolean visible);
+
+ /**
+ * @param nodeName
+ * @param followingNodeName
+ * @param visible The navigation visibility.
+ * @return A site node.
+ */
+ SiteNode addChild(String nodeName, String followingNodeName, boolean visible);
+
+ /**
+ * @return The tree.
+ */
+ SiteTreeImpl getTree();
+
+ /**
+ * @return The path.
+ */
+ String getPath();
+
+ /**
+ * @param name The name.
+ */
+ void moveDown(String name);
+
+ /**
+ * @param name The name.
+ */
+ void moveUp(String name);
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org