Author: andreas
Date: Fri Jan 2 09:11:06 2009
New Revision: 730789
URL: http://svn.apache.org/viewvc?rev=730789&view=rev
Log:
Use SAX to load and save sitetree (better performance).
Added:
lenya/trunk/src/modules/sitetree/config/cocoon-xconf/TreeBuilder.xconf
lenya/trunk/src/modules/sitetree/config/cocoon-xconf/TreeSerializer.xconf
lenya/trunk/src/modules/sitetree/config/cocoon-xconf/TreeWriter.xconf
lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/SaxTreeBuilder.java
lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/SaxTreeWriter.java
lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/TreeBuilder.java
lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/TreeWriter.java
Modified:
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/TreeNodeImpl.java
Added: lenya/trunk/src/modules/sitetree/config/cocoon-xconf/TreeBuilder.xconf
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/sitetree/config/cocoon-xconf/TreeBuilder.xconf?rev=730789&view=auto
==============================================================================
--- lenya/trunk/src/modules/sitetree/config/cocoon-xconf/TreeBuilder.xconf (added)
+++ lenya/trunk/src/modules/sitetree/config/cocoon-xconf/TreeBuilder.xconf Fri Jan 2 09:11:06 2009
@@ -0,0 +1,24 @@
+<?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.
+-->
+
+<xconf xpath="/cocoon" unless="/cocoon/component[@role = 'org.apache.lenya.cms.site.tree2.TreeBuilder']">
+
+ <component role="org.apache.lenya.cms.site.tree2.TreeBuilder" logger="lenya.site"
+ class="org.apache.lenya.cms.site.tree2.SaxTreeBuilder"/>
+
+</xconf>
Added: lenya/trunk/src/modules/sitetree/config/cocoon-xconf/TreeSerializer.xconf
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/sitetree/config/cocoon-xconf/TreeSerializer.xconf?rev=730789&view=auto
==============================================================================
--- lenya/trunk/src/modules/sitetree/config/cocoon-xconf/TreeSerializer.xconf (added)
+++ lenya/trunk/src/modules/sitetree/config/cocoon-xconf/TreeSerializer.xconf Fri Jan 2 09:11:06 2009
@@ -0,0 +1,26 @@
+<?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.
+-->
+
+<xconf xpath="/cocoon" unless="/cocoon/component[@role = 'org.apache.lenya.cms.site.tree2.TreeWriterSerializer']">
+
+ <component role="org.apache.lenya.cms.site.tree2.TreeWriterSerializer" logger="lenya.site"
+ class="org.apache.cocoon.components.serializers.XMLSerializer">
+ <encoding>UTF-8</encoding>
+ </component>
+
+</xconf>
Added: lenya/trunk/src/modules/sitetree/config/cocoon-xconf/TreeWriter.xconf
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/sitetree/config/cocoon-xconf/TreeWriter.xconf?rev=730789&view=auto
==============================================================================
--- lenya/trunk/src/modules/sitetree/config/cocoon-xconf/TreeWriter.xconf (added)
+++ lenya/trunk/src/modules/sitetree/config/cocoon-xconf/TreeWriter.xconf Fri Jan 2 09:11:06 2009
@@ -0,0 +1,24 @@
+<?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.
+-->
+
+<xconf xpath="/cocoon" unless="/cocoon/component[@role = 'org.apache.lenya.cms.site.tree2.TreeWriter']">
+
+ <component role="org.apache.lenya.cms.site.tree2.TreeWriter" logger="lenya.site"
+ class="org.apache.lenya.cms.site.tree2.SaxTreeWriter"/>
+
+</xconf>
Added: lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/SaxTreeBuilder.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/SaxTreeBuilder.java?rev=730789&view=auto
==============================================================================
--- lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/SaxTreeBuilder.java (added)
+++ lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/SaxTreeBuilder.java Fri Jan 2 09:11:06 2009
@@ -0,0 +1,134 @@
+package org.apache.lenya.cms.site.tree2;
+
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.service.Serviceable;
+import org.apache.excalibur.xml.sax.SAXParser;
+import org.apache.lenya.cms.repository.Node;
+import org.apache.lenya.cms.site.Link;
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+
+public class SaxTreeBuilder extends AbstractLogEnabled implements TreeBuilder, Serviceable,
+ ContentHandler {
+
+ protected static final String ATTR_XML_LANG = "xml:lang";
+ protected static final String ELEM_SITE = "site";
+ protected static final String ELEM_NODE = "node";
+ protected static final String ELEM_LABEL = "label";
+ protected static final String ATTR_ID = "id";
+ protected static final String ATTR_UUID = "uuid";
+ protected static final String ATTR_VISIBLE_IN_NAV = "visibleinnav";
+ protected static final String ATTR_REVISION = "revision";
+
+ private ServiceManager manager;
+ private TreeNodeImpl currentNode;
+ private StringBuffer text = new StringBuffer();
+ private Link currentLink;
+
+ public void buildTree(SiteTreeImpl tree) throws Exception {
+ SAXParser parser = null;
+ try {
+ this.currentNode = tree.getRoot();
+ Node node = tree.getRepositoryNode();
+
+ if (node.exists() && node.getContentLength() > 0) {
+ parser = (SAXParser) this.manager.lookup(SAXParser.ROLE);
+ parser.parse(new InputSource(node.getInputStream()), this);
+ }
+ } finally {
+ if (parser != null) {
+ this.manager.release(parser);
+ }
+ }
+ }
+
+ public void service(ServiceManager manager) throws ServiceException {
+ this.manager = manager;
+ }
+
+ public void characters(char[] chars, int start, int length) throws SAXException {
+ this.text.append(chars, start, length);
+ }
+
+ public void endDocument() throws SAXException {
+ }
+
+ public void endPrefixMapping(String arg0) throws SAXException {
+ }
+
+ public void ignorableWhitespace(char[] arg0, int arg1, int arg2) throws SAXException {
+ }
+
+ public void processingInstruction(String arg0, String arg1) throws SAXException {
+ }
+
+ public void setDocumentLocator(Locator arg0) {
+ }
+
+ public void skippedEntity(String arg0) throws SAXException {
+ }
+
+ public void startDocument() throws SAXException {
+ }
+
+ public void startElement(String uri, String localName, String qName, Attributes attrs)
+ throws SAXException {
+ try {
+ if (localName.equals(ELEM_SITE)) {
+ int revision = Integer.valueOf(attrs.getValue("revision"));
+ SiteTreeImpl tree = this.currentNode.getTree();
+ int latestRevision = tree.getRevision(tree.getRepositoryNode());
+ if (revision != latestRevision) {
+ String message = "Trying to load outdated tree, revision should be "
+ + latestRevision + " but is " + revision;
+ getLogger().error(message);
+ }
+ tree.setRevision(revision);
+ }
+ if (localName.equals(ELEM_NODE)) {
+ String id = attrs.getValue(ATTR_ID);
+ String visibleString = attrs.getValue(ATTR_VISIBLE_IN_NAV);
+ boolean visible = visibleString == null ? true : Boolean.valueOf(visibleString);
+ TreeNodeImpl node = (TreeNodeImpl) this.currentNode.addChild(id, visible);
+ String uuid = attrs.getValue(ATTR_UUID);
+ if (uuid != null) {
+ node.setUuid(uuid);
+ }
+ this.currentNode = node;
+ } else if (localName.equals(ELEM_LABEL)) {
+ String lang = attrs.getValue(ATTR_XML_LANG);
+ this.currentLink = this.currentNode.addLink(lang, "");
+ }
+ this.text.setLength(0);
+ } catch (Exception e) {
+ throw new SAXException(e);
+ }
+ }
+
+ public void endElement(String uri, String localName, String qName) throws SAXException {
+ try {
+ if (localName.equals(ELEM_NODE)) {
+ TreeNodeImpl node = this.currentNode;
+ this.currentNode = node.isTopLevel() ? node.getTree().getRoot()
+ : (TreeNodeImpl) node.getParent();
+ }
+ if (localName.equals(ELEM_LABEL)) {
+ String label = this.text.toString();
+ this.currentLink.setLabel(label);
+ this.currentLink = null;
+ }
+ this.text.setLength(0);
+ } catch (Exception e) {
+ throw new SAXException(e);
+ }
+ }
+
+ public void startPrefixMapping(String arg0, String arg1) throws SAXException {
+ }
+
+}
Added: lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/SaxTreeWriter.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/SaxTreeWriter.java?rev=730789&view=auto
==============================================================================
--- lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/SaxTreeWriter.java (added)
+++ lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/SaxTreeWriter.java Fri Jan 2 09:11:06 2009
@@ -0,0 +1,136 @@
+/*
+ * 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.io.OutputStream;
+
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.service.Serviceable;
+import org.apache.cocoon.serialization.Serializer;
+import org.apache.excalibur.xml.sax.XMLizable;
+import org.apache.lenya.cms.repository.Node;
+import org.apache.lenya.cms.site.Link;
+import org.apache.lenya.cms.site.SiteNode;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.AttributesImpl;
+
+public class SaxTreeWriter extends AbstractLogEnabled implements TreeWriter, XMLizable, Serviceable {
+
+ protected static final String NS = SiteTreeImpl.NAMESPACE;
+ protected static final String TYPE_CDATA = "CDATA";
+ protected static final String ATTR_ID = SaxTreeBuilder.ATTR_ID;
+ protected static final String ATTR_UUID = SaxTreeBuilder.ATTR_UUID;
+ protected static final String ATTR_REVISION = SaxTreeBuilder.ATTR_REVISION;
+ protected static final String ATTR_VISIBLE = SaxTreeBuilder.ATTR_VISIBLE_IN_NAV;
+ protected static final String ATTR_LANG = SaxTreeBuilder.ATTR_XML_LANG;
+ protected static final String ELEM_SITE = SaxTreeBuilder.ELEM_SITE;
+ protected static final String ELEM_NODE = SaxTreeBuilder.ELEM_NODE;
+ protected static final String ELEM_LABEL = SaxTreeBuilder.ELEM_LABEL;
+
+ private SiteTreeImpl tree;
+ private ServiceManager manager;
+
+ public void writeTree(SiteTreeImpl tree) throws Exception {
+ this.tree = tree;
+
+ Serializer serializer = null;
+ OutputStream stream = null;
+ try {
+ serializer = (Serializer) this.manager.lookup(ROLE + "Serializer");
+ stream = tree.getRepositoryNode().getOutputStream();
+ serializer.setOutputStream(stream);
+ toSAX(serializer);
+ } finally {
+ if (stream != null) {
+ stream.close();
+ }
+ if (serializer != null) {
+ this.manager.release(serializer);
+ }
+ }
+ }
+
+ public void toSAX(ContentHandler handler) throws SAXException {
+ handler.startDocument();
+ handler.startPrefixMapping("", SiteTreeImpl.NAMESPACE);
+
+ Node repoNode = this.tree.getRepositoryNode();
+ int revision = this.tree.getRevision(repoNode) + 1;
+ AttributesImpl attrs = new AttributesImpl();
+ attrs
+ .addAttribute("", ATTR_REVISION, ATTR_REVISION, TYPE_CDATA, Integer
+ .toString(revision));
+ handler.startElement(NS, ELEM_SITE, ELEM_SITE, attrs);
+
+ try {
+ toSAX(handler, this.tree.getTopLevelNodes());
+ } catch (Exception e) {
+ throw new SAXException(e);
+ }
+
+ handler.endElement(NS, ELEM_SITE, ELEM_SITE);
+ handler.endPrefixMapping("");
+ handler.endDocument();
+ }
+
+ protected void toSAX(ContentHandler handler, SiteNode[] nodes) throws Exception {
+ for (int i = 0; i < nodes.length; i++) {
+ toSAX(handler, nodes[i]);
+ }
+ }
+
+ protected void toSAX(ContentHandler handler, SiteNode node) throws Exception {
+ AttributesImpl attrs = new AttributesImpl();
+ attrs.addAttribute("", ATTR_ID, ATTR_ID, TYPE_CDATA, node.getName());
+ String uuid = node.getUuid();
+ if (uuid != null) {
+ attrs.addAttribute("", ATTR_UUID, ATTR_UUID, TYPE_CDATA, uuid);
+ }
+ boolean visible = node.isVisible();
+ if (visible) {
+ attrs.addAttribute("", ATTR_VISIBLE, ATTR_VISIBLE, TYPE_CDATA, Boolean
+ .toString(visible));
+ }
+ handler.startElement(NS, ELEM_NODE, ELEM_NODE, attrs);
+
+ String[] languages = node.getLanguages();
+ for (int i = 0; i < languages.length; i++) {
+ toSAX(handler, node.getLink(languages[i]));
+ }
+
+ toSAX(handler, node.getChildren());
+ handler.endElement(NS, ELEM_NODE, ELEM_NODE);
+ }
+
+ protected void toSAX(ContentHandler handler, Link link) throws Exception {
+ AttributesImpl attrs = new AttributesImpl();
+ attrs.addAttribute("", ATTR_LANG, ATTR_LANG, TYPE_CDATA, link.getLanguage());
+ handler.startElement(NS, ELEM_LABEL, ELEM_LABEL, attrs);
+ char[] chars = link.getLabel().toCharArray();
+ handler.characters(chars, 0, chars.length);
+ handler.endElement(NS, ELEM_LABEL, ELEM_LABEL);
+ }
+
+ public void service(ServiceManager manager) throws ServiceException {
+ this.manager = manager;
+ }
+
+}
Modified: 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?rev=730789&r1=730788&r2=730789&view=diff
==============================================================================
--- lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/SiteTreeFactory.java (original)
+++ lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/SiteTreeFactory.java Fri Jan 2 09:11:06 2009
@@ -63,10 +63,11 @@
Area area = publication.getArea(areaName);
store = (SharedItemStore) this.manager.lookup(SharedItemStore.ROLE);
- if (session.isModifiable() || session == store.getSession()) {
+ Session storeSession = store.getSession();
+ if (session.isModifiable() || session == storeSession) {
tree = new SiteTreeImpl(this.manager, area, getLogger());
} else {
- tree = new DelegatingSiteTree(this.manager, area, this, store.getSession(), key);
+ tree = new DelegatingSiteTree(this.manager, area, this, storeSession, key);
}
} catch (Exception e) {
throw new RepositoryException(e);
Modified: 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?rev=730789&r1=730788&r2=730789&view=diff
==============================================================================
--- lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/SiteTreeImpl.java (original)
+++ lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/SiteTreeImpl.java Fri Jan 2 09:11:06 2009
@@ -40,9 +40,6 @@
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.
@@ -52,6 +49,7 @@
private Area area;
protected ServiceManager manager;
private RootNode root;
+ private int revision;
/**
* @param manager The service manager.
@@ -90,7 +88,7 @@
protected synchronized void load() {
- if (this.loaded) {
+ if (this.loaded || this.loading) {
return;
}
@@ -100,23 +98,26 @@
repoNode.setPersistable(this);
if (repoNode.exists()) {
- org.w3c.dom.Document xml = DocumentHelper.readDocument(repoNode.getInputStream());
-
- NamespaceHelper helper = new NamespaceHelper(NAMESPACE, "", xml);
- Assert.isTrue("document element is site", xml.getDocumentElement().getLocalName()
- .equals("site"));
- this.loading = true;
- reset();
- loadNodes(this.root, helper, xml.getDocumentElement());
- this.loading = false;
+ TreeBuilder builder = null;
+ try {
+ this.loading = true;
+ builder = (TreeBuilder) this.manager.lookup(TreeBuilder.ROLE);
+ reset();
+ builder.buildTree(this);
+ Assert.isTrue("Latest revision loaded", getRevision() == getRevision(getRepositoryNode()));
+ this.loaded = true;
+ } finally {
+ this.loading = false;
+ if (builder != null) {
+ this.manager.release(builder);
+ }
+ }
}
if (!repoNode.exists()) {
reset();
}
- this.loaded = true;
-
} catch (Exception e) {
throw new RuntimeException(e);
}
@@ -133,52 +134,23 @@
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);
- }
- }
-
public synchronized void save() throws RepositoryException {
if (loading || !changed) {
return;
}
+ TreeWriter writer = null;
try {
- Node repoNode = getRepositoryNode();
- NamespaceHelper helper = new NamespaceHelper(NAMESPACE, "", "site");
-
- int revision = getRevision(repoNode) + 1;
- helper.getDocument().getDocumentElement().setAttribute("revision",
- Integer.toString(revision));
-
- saveNodes(getRoot(), helper, helper.getDocument().getDocumentElement());
- helper.save(repoNode.getOutputStream());
+ writer = (TreeWriter) this.manager.lookup(TreeWriter.ROLE);
+ int revision = getRevision(getRepositoryNode()) + 1;
+ writer.writeTree(this);
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new RepositoryException(e);
+ } finally {
+ if (writer != null) {
+ this.manager.release(writer);
+ }
}
}
@@ -191,34 +163,6 @@
return revision;
}
- 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())) {
@@ -294,7 +238,7 @@
}
protected String getKey(Link link) {
- String uuid = link.getDocument().getUUID();
+ String uuid = link.getNode().getUuid();
Assert.notNull("uuid", uuid);
String language = link.getLanguage();
Assert.notNull("language", language);
@@ -476,4 +420,13 @@
public boolean isModified() {
return this.changed;
}
+
+ protected int getRevision() {
+ return this.revision;
+ }
+
+ protected void setRevision(int revision) {
+ this.revision = revision;
+ }
+
}
Added: lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/TreeBuilder.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/TreeBuilder.java?rev=730789&view=auto
==============================================================================
--- lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/TreeBuilder.java (added)
+++ lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/TreeBuilder.java Fri Jan 2 09:11:06 2009
@@ -0,0 +1,26 @@
+/*
+ * 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;
+
+public interface TreeBuilder {
+
+ String ROLE = TreeBuilder.class.getName();
+
+ void buildTree(SiteTreeImpl tree) throws Exception;
+
+}
Modified: lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/TreeNodeImpl.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/TreeNodeImpl.java?rev=730789&r1=730788&r2=730789&view=diff
==============================================================================
--- lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/TreeNodeImpl.java (original)
+++ lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/TreeNodeImpl.java Fri Jan 2 09:11:06 2009
@@ -348,5 +348,5 @@
public boolean hasLink() {
return false;
}
-
+
}
Added: lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/TreeWriter.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/TreeWriter.java?rev=730789&view=auto
==============================================================================
--- lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/TreeWriter.java (added)
+++ lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree2/TreeWriter.java Fri Jan 2 09:11:06 2009
@@ -0,0 +1,26 @@
+/*
+ * 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;
+
+public interface TreeWriter {
+
+ String ROLE = TreeWriter.class.getName();
+
+ void writeTree(SiteTreeImpl tree) throws Exception;
+
+}
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.