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 2005/03/08 19:16:11 UTC
svn commit: r156558 - in lenya/trunk/src: java/org/apache/lenya/
java/org/apache/lenya/cms/ant/
java/org/apache/lenya/cms/cocoon/components/modules/input/
java/org/apache/lenya/cms/cocoon/generation/
java/org/apache/lenya/cms/cocoon/transformation/
java/org/apache/lenya/cms/publication/
java/org/apache/lenya/cms/publication/task/
java/org/apache/lenya/cms/publication/util/ java/org/apache/lenya/cms/site/
java/org/apache/lenya/cms/site/topicmap/ java/org/apache/lenya/cms/site/tree/
java/org/apache/lenya/cms/site/usecases/
webapp/lenya/pubs/default/java/src/org/apache/lenya/defaultpub/cms/usecases/
Author: andreas
Date: Tue Mar 8 10:16:05 2005
New Revision: 156558
URL: http://svn.apache.org/viewcvs?view=rev&rev=156558
Log:
store site structure objects in document identity map
Modified:
lenya/trunk/src/java/org/apache/lenya/cms/ant/PublicationTask.java
lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/SitetreeModule.java
lenya/trunk/src/java/org/apache/lenya/cms/cocoon/generation/SitetreeFragmentGenerator.java
lenya/trunk/src/java/org/apache/lenya/cms/cocoon/transformation/DocumentIndexTransformer.java
lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocument.java
lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentIdentityMap.java
lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentManagerImpl.java
lenya/trunk/src/java/org/apache/lenya/cms/publication/Publication.java
lenya/trunk/src/java/org/apache/lenya/cms/publication/PublicationImpl.java
lenya/trunk/src/java/org/apache/lenya/cms/publication/task/PublicationTask.java
lenya/trunk/src/java/org/apache/lenya/cms/publication/util/OrderedDocumentSet.java
lenya/trunk/src/java/org/apache/lenya/cms/publication/util/PublicationHelper.java
lenya/trunk/src/java/org/apache/lenya/cms/publication/util/UniqueDocumentId.java
lenya/trunk/src/java/org/apache/lenya/cms/site/AbstractSiteManager.java
lenya/trunk/src/java/org/apache/lenya/cms/site/SiteManager.java
lenya/trunk/src/java/org/apache/lenya/cms/site/topicmap/TopicMapSiteManager.java
lenya/trunk/src/java/org/apache/lenya/cms/site/tree/TreeSiteManager.java
lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/ChangeLabel.java
lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/Create.java
lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/Delete.java
lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/LinkRewriterImpl.java
lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/Nudge.java
lenya/trunk/src/java/org/apache/lenya/lenya.roles
lenya/trunk/src/webapp/lenya/pubs/default/java/src/org/apache/lenya/defaultpub/cms/usecases/Deactivate.java
lenya/trunk/src/webapp/lenya/pubs/default/java/src/org/apache/lenya/defaultpub/cms/usecases/Delete.java
lenya/trunk/src/webapp/lenya/pubs/default/java/src/org/apache/lenya/defaultpub/cms/usecases/Publish.java
Modified: lenya/trunk/src/java/org/apache/lenya/cms/ant/PublicationTask.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/ant/PublicationTask.java?view=diff&r1=156557&r2=156558
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/ant/PublicationTask.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/ant/PublicationTask.java Tue Mar 8 10:16:05 2005
@@ -118,11 +118,11 @@
protected SiteTree getSiteTree(String area) {
SiteTree tree;
try {
- SiteManager manager = getPublication().getSiteManager(getIdentityMap());
+ SiteManager manager = getPublication().getSiteManager();
if (!(manager instanceof TreeSiteManager)) {
throw new RuntimeException("Only supported for site trees.");
}
- tree = ((TreeSiteManager) manager).getTree(area);
+ tree = ((TreeSiteManager) manager).getTree(getIdentityMap(), area);
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
Modified: lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/SitetreeModule.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/SitetreeModule.java?view=diff&r1=156557&r2=156558
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/SitetreeModule.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/SitetreeModule.java Tue Mar 8 10:16:05 2005
@@ -67,26 +67,26 @@
try {
PageEnvelope envelope = getEnvelope(objectModel);
Publication publication = envelope.getPublication();
- DocumentIdentityMap map = envelope.getIdentityMap();
- TreeSiteManager _manager = (TreeSiteManager) publication.getSiteManager(map);
+ DocumentIdentityMap map = new DocumentIdentityMap(publication);
+ TreeSiteManager _manager = (TreeSiteManager) publication.getSiteManager();
if (name.equals(AUTHORING_NODE)) {
- SiteTree authoringTree = _manager.getTree(Publication.AUTHORING_AREA);
+ SiteTree authoringTree = _manager.getTree(map, Publication.AUTHORING_AREA);
value = authoringTree.getNode(envelope.getDocument().getId());
}
if (name.equals(LIVE_NODE)) {
- SiteTree liveTree = _manager.getTree(Publication.LIVE_AREA);
+ SiteTree liveTree = _manager.getTree(map, Publication.LIVE_AREA);
value = liveTree.getNode(envelope.getDocument().getId());
}
if (name.equals(TRASH_NODE)) {
- SiteTree trashTree = _manager.getTree(Publication.TRASH_AREA);
+ SiteTree trashTree = _manager.getTree(map, Publication.TRASH_AREA);
value = trashTree.getNode(envelope.getDocument().getId());
}
if (name.equals(ARCHIVE_NODE)) {
- SiteTree archiveTree = _manager.getTree(Publication.ARCHIVE_AREA);
+ SiteTree archiveTree = _manager.getTree(map, Publication.ARCHIVE_AREA);
value = archiveTree.getNode(envelope.getDocument().getId());
}
} catch (Exception e) {
Modified: lenya/trunk/src/java/org/apache/lenya/cms/cocoon/generation/SitetreeFragmentGenerator.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/generation/SitetreeFragmentGenerator.java?view=diff&r1=156557&r2=156558
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/cocoon/generation/SitetreeFragmentGenerator.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/cocoon/generation/SitetreeFragmentGenerator.java Tue Mar 8 10:16:05 2005
@@ -44,40 +44,44 @@
import org.xml.sax.helpers.AttributesImpl;
/**
- * Generates a fragment of the navigation XML from the sitetree,
- * corresponding to a given node.
- * The node is specified by the sitemap parameters area/documentid.
- * If the sitemap parameter initialTree is true, the top nodes
- * of the tree will be generated and the node given by the sitemap
- * parameters area/documentid will be unfolded.
- * If initialTree is false, only the children of the selected node
- * will be generated.
+ * Generates a fragment of the navigation XML from the sitetree, corresponding
+ * to a given node. The node is specified by the sitemap parameters
+ * area/documentid. If the sitemap parameter initialTree is true, the top nodes
+ * of the tree will be generated and the node given by the sitemap parameters
+ * area/documentid will be unfolded. If initialTree is false, only the children
+ * of the selected node will be generated.
*/
public class SitetreeFragmentGenerator extends AbstractGenerator {
protected Publication publication;
private DocumentIdentityMap identityMap;
-
- /** Parameter which denotes the documentid of the clicked node */
+
+ /** Parameter which denotes the documentid of the clicked node */
protected String documentid;
-
+
/** Parameter which denotes the area of the clicked node */
protected String area;
-
- /** Parameter which decides if the initial tree with the root nodes is generated */
+
+ /**
+ * Parameter which decides if the initial tree with the root nodes is
+ * generated
+ */
protected boolean initialTree;
-
+
/** FIXME: should pass this as a parameter */
protected String[] areas = null;
-
- /** Convenience object, so we don't need to create an AttributesImpl for every element. */
+
+ /**
+ * Convenience object, so we don't need to create an AttributesImpl for
+ * every element.
+ */
protected AttributesImpl attributes;
-
+
protected static final String PARAM_AREA = "area";
protected static final String PARAM_DOCUMENTID = "documentid";
protected static final String PARAM_INITIAL = "initial";
protected static final String PARAM_AREAS = "areas";
-
+
/** The URI of the namespace of this generator. */
protected static final String URI = "http://apache.org/cocoon/lenya/sitetree/1.0";
protected static final String XML_URI = "http://www.w3.org/XML/1998/namespace";
@@ -85,7 +89,7 @@
/** The namespace prefix for this namespace. */
protected static final String PREFIX = "site";
protected static final String XML_PREFIX = "xml";
-
+
protected static final String NODE_NODE = "node";
protected static final String NODE_LABEL = "label";
protected static final String NODE_SITE = "site";
@@ -101,13 +105,14 @@
protected static final String ATTR_SUFFIX = "suffix";
protected static final String ATTR_HREF = "href";
protected static final String ATTR_LANG = "lang";
-
+
/**
- * @see org.apache.cocoon.sitemap.SitemapModelComponent#setup(org.apache.cocoon.environment.SourceResolver, java.util.Map, java.lang.String, org.apache.avalon.framework.parameters.Parameters)
+ * @see org.apache.cocoon.sitemap.SitemapModelComponent#setup(org.apache.cocoon.environment.SourceResolver,
+ * java.util.Map, java.lang.String,
+ * org.apache.avalon.framework.parameters.Parameters)
*/
- public void setup(SourceResolver _resolver, Map _objectModel, String src,
- Parameters par) throws ProcessingException, SAXException,
- IOException {
+ public void setup(SourceResolver _resolver, Map _objectModel, String src, Parameters par)
+ throws ProcessingException, SAXException, IOException {
super.setup(_resolver, _objectModel, src, par);
PageEnvelope envelope = null;
@@ -119,43 +124,45 @@
this.area = par.getParameter(PARAM_AREA, null);
this.documentid = par.getParameter(PARAM_DOCUMENTID, null);
-
+
if (par.isParameter(PARAM_INITIAL)) {
- this.initialTree = Boolean.valueOf(par.getParameter(PARAM_INITIAL, null)).booleanValue();
+ this.initialTree = Boolean.valueOf(par.getParameter(PARAM_INITIAL, null))
+ .booleanValue();
} else {
this.initialTree = false;
}
-
+
if (par.isParameter(PARAM_AREAS)) {
String parAreas = par.getParameter(PARAM_AREAS, null);
this.areas = parAreas.split(",");
} else {
- String temp[] = {"authoring", "archive", "trash"};
+ String temp[] = { "authoring", "archive", "trash" };
this.areas = temp;
}
-
+
if (this.getLogger().isDebugEnabled()) {
this.getLogger().debug("Parameter area: " + this.area);
this.getLogger().debug("Parameter documentid: " + this.documentid);
this.getLogger().debug("Parameter initialTree: " + this.initialTree);
String areasStr = "";
- for (int i=0; i<this.areas.length; i++) {
- areasStr += this.areas[i]+" ";
+ for (int i = 0; i < this.areas.length; i++) {
+ areasStr += this.areas[i] + " ";
}
this.getLogger().debug("Parameter areas: " + areasStr);
}
-
+
try {
PublicationFactory factory = PublicationFactory.getInstance(getLogger());
Publication pub = factory.getPublication(_objectModel);
this.identityMap = new DocumentIdentityMap(pub);
- envelope = PageEnvelopeFactory.getInstance().getPageEnvelope(this.identityMap, _objectModel);
+ envelope = PageEnvelopeFactory.getInstance().getPageEnvelope(this.identityMap,
+ _objectModel);
} catch (final PublicationException e) {
throw new ProcessingException("Resolving page envelope failed: ", e);
} catch (final PageEnvelopeException e) {
throw new ProcessingException("Resolving page envelope failed: ", e);
- }
-
+ }
+
this.publication = envelope.getPublication();
this.attributes = new AttributesImpl();
@@ -165,9 +172,9 @@
* @see org.apache.cocoon.generation.Generator#generate()
*/
public void generate() throws IOException, SAXException, ProcessingException {
-
+
try {
-
+
this.contentHandler.startDocument();
this.contentHandler.startPrefixMapping(PREFIX, URI);
@@ -176,11 +183,14 @@
this.attributes.addAttribute("", ATTR_AREA, ATTR_AREA, "CDATA", this.area);
this.attributes.addAttribute("", ATTR_BASE, ATTR_BASE, "CDATA", this.documentid);
}
-
- this.contentHandler.startElement(URI, NODE_FRAGMENT, PREFIX + ':' + NODE_FRAGMENT, this.attributes);
-
+
+ this.contentHandler.startElement(URI,
+ NODE_FRAGMENT,
+ PREFIX + ':' + NODE_FRAGMENT,
+ this.attributes);
+
if (this.initialTree) {
- for (int i=0; i<this.areas.length; i++) {
+ for (int i = 0; i < this.areas.length; i++) {
generateFragmentInitial(this.areas[i]);
}
} else {
@@ -188,129 +198,140 @@
}
this.contentHandler.endElement(URI, NODE_FRAGMENT, PREFIX + ':' + NODE_FRAGMENT);
-
+
this.contentHandler.endPrefixMapping(PREFIX);
this.contentHandler.endDocument();
-
+
} catch (final SAXException e) {
throw new ProcessingException(e);
} catch (final SiteException e) {
throw new ProcessingException(e);
}
-
-
+
}
-
+
/**
- * Generates a fragment of the tree which contains the children of a given node.
+ * Generates a fragment of the tree which contains the children of a given
+ * node.
* @throws SiteException
* @throws SAXException
* @throws ProcessingException
*/
- protected void generateFragment()
- throws SiteException, SAXException, ProcessingException {
-
+ protected void generateFragment() throws SiteException, SAXException, ProcessingException {
+
SiteTree siteTree = null;
- if (!this.area.equals(Publication.AUTHORING_AREA) &&
- !this.area.equals(Publication.ARCHIVE_AREA) &&
- !this.area.equals(Publication.TRASH_AREA) &&
- !this.area.equals(Publication.LIVE_AREA) &&
- !this.area.equals(Publication.STAGING_AREA)) {
- throw new ProcessingException("Invalid area: "+this.area);
+ if (!this.area.equals(Publication.AUTHORING_AREA)
+ && !this.area.equals(Publication.ARCHIVE_AREA)
+ && !this.area.equals(Publication.TRASH_AREA)
+ && !this.area.equals(Publication.LIVE_AREA)
+ && !this.area.equals(Publication.STAGING_AREA)) {
+ throw new ProcessingException("Invalid area: " + this.area);
}
- siteTree = ((TreeSiteManager)this.publication.getSiteManager(this.identityMap)).getTree(this.area);
-
+ siteTree = ((TreeSiteManager) this.publication.getSiteManager()).getTree(this.identityMap,
+ this.area);
+
SiteTreeNode node = siteTree.getNode(this.documentid);
if (this.getLogger().isDebugEnabled()) {
- this.getLogger().debug("Node with documentid "+this.documentid+" found.");
+ this.getLogger().debug("Node with documentid " + this.documentid + " found.");
}
- if (node==null) throw new SiteException("Node with documentid "+this.documentid+" not found.");
-
+ if (node == null)
+ throw new SiteException("Node with documentid " + this.documentid + " not found.");
+
SiteTreeNode[] children = node.getChildren();
-
- for (int i=0; i<children.length; i++) {
+
+ for (int i = 0; i < children.length; i++) {
startNode(NODE_NODE, children[i]);
addLabels(children[i]);
endNode(NODE_NODE);
- }
+ }
}
-
+
/**
* Generates the top node of the given area and then calls a recursive
- * method to traverse the tree, if the node given by area/documentid is
- * in this area.
+ * method to traverse the tree, if the node given by area/documentid is in
+ * this area.
* @param siteArea
* @throws SiteException
* @throws SAXException
*/
- protected void generateFragmentInitial(String siteArea)
- throws SiteException, SAXException {
+ protected void generateFragmentInitial(String siteArea) throws SiteException, SAXException {
+
+ SiteTree siteTree = ((TreeSiteManager) this.publication.getSiteManager())
+ .getTree(this.identityMap, siteArea);
- SiteTree siteTree = ((TreeSiteManager)this.publication.getSiteManager(this.identityMap)).getTree(siteArea);
-
String label = "";
String isFolder = "";
-
+
// FIXME: don't hardcode area label
- if (siteArea.equals(Publication.AUTHORING_AREA)) label = "Authoring";
- if (siteArea.equals(Publication.ARCHIVE_AREA)) label = "Archive";
- if (siteArea.equals(Publication.TRASH_AREA)) label = "Trash";
- if (siteArea.equals(Publication.LIVE_AREA)) label = "Live";
- if (siteArea.equals(Publication.STAGING_AREA)) label = "Staging";
-
- if (siteTree.getTopNodes().length>0) isFolder = "true";
- else isFolder = "false";
-
+ if (siteArea.equals(Publication.AUTHORING_AREA))
+ label = "Authoring";
+ if (siteArea.equals(Publication.ARCHIVE_AREA))
+ label = "Archive";
+ if (siteArea.equals(Publication.TRASH_AREA))
+ label = "Trash";
+ if (siteArea.equals(Publication.LIVE_AREA))
+ label = "Live";
+ if (siteArea.equals(Publication.STAGING_AREA))
+ label = "Staging";
+
+ if (siteTree.getTopNodes().length > 0)
+ isFolder = "true";
+ else
+ isFolder = "false";
+
this.attributes.clear();
this.attributes.addAttribute("", ATTR_AREA, ATTR_AREA, "CDATA", siteArea);
this.attributes.addAttribute("", ATTR_FOLDER, ATTR_FOLDER, "CDATA", isFolder);
this.attributes.addAttribute("", ATTR_LABEL, ATTR_LABEL, "CDATA", label);
-
+
startNode(NODE_SITE);
-
+
if (this.area.equals(siteArea)) {
generateFragmentRecursive(siteTree.getTopNodes(), this.documentid);
}
-
+
endNode(NODE_SITE);
}
-
+
/**
- * Follows the documentid to find the way in the sitetree to the specified node
- * and opens all folders on its way.
+ * Follows the documentid to find the way in the sitetree to the specified
+ * node and opens all folders on its way.
* @param nodes
* @param docid
* @throws SiteException
* @throws SAXException
*/
- protected void generateFragmentRecursive(SiteTreeNode[] nodes, String docid) throws SiteException, SAXException {
+ protected void generateFragmentRecursive(SiteTreeNode[] nodes, String docid)
+ throws SiteException, SAXException {
String nodeid;
String childid;
-
- if (nodes==null) return;
- if (docid.startsWith("/")) docid = docid.substring(1);
- if (docid.indexOf("/")!=-1) {
+
+ if (nodes == null)
+ return;
+ if (docid.startsWith("/"))
+ docid = docid.substring(1);
+ if (docid.indexOf("/") != -1) {
nodeid = docid.substring(0, docid.indexOf("/"));
- childid = docid.substring(docid.indexOf("/")+1);
+ childid = docid.substring(docid.indexOf("/") + 1);
} else {
nodeid = docid;
childid = "";
}
-
- for (int i=0; i<nodes.length; i++) {
+
+ for (int i = 0; i < nodes.length; i++) {
startNode(NODE_NODE, nodes[i]);
addLabels(nodes[i]);
if (nodes[i].getId().equals(nodeid)) {
generateFragmentRecursive(nodes[i].getChildren(), childid);
}
- endNode(NODE_NODE);
- }
+ endNode(NODE_NODE);
+ }
}
-
+
/**
* Begins a named node and calls setNodeAttributes to set its attributes.
- * @param nodeName the name of the new node
- * @throws SAXException if an error occurs while creating the node
+ * @param nodeName the name of the new node
+ * @throws SAXException if an error occurs while creating the node
*/
protected void startNode(String nodeName) throws SAXException {
this.contentHandler.startElement(URI, nodeName, PREFIX + ':' + nodeName, this.attributes);
@@ -318,9 +339,9 @@
/**
* Begins a named node and calls setNodeAttributes to set its attributes.
- * @param nodeName the name of the new node
+ * @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 SAXException if an error occurs while creating the node
*/
protected void startNode(String nodeName, SiteTreeNode node) throws SAXException {
setNodeAttributes(node);
@@ -331,7 +352,7 @@
* Sets the attributes for a given node. Sets attributes id, href, folder,
* suffix, basic-url, language-suffix.
* @param node
- * @throws SAXException if an error occurs while setting the attributes
+ * @throws SAXException if an error occurs while setting the attributes
*/
protected void setNodeAttributes(SiteTreeNode node) throws SAXException {
this.attributes.clear();
@@ -342,41 +363,47 @@
String href = node.getHref();
String suffix = node.getSuffix();
String isFolder = isFolder(node);
-
+
if (this.getLogger().isDebugEnabled()) {
this.getLogger().debug("adding attribute id: " + id);
- //this.getLogger().debug("adding attribute visibleinnav: " + isVisible);
+ //this.getLogger().debug("adding attribute visibleinnav: " +
+ // isVisible);
this.getLogger().debug("adding attribute link: " + hasLink);
- if (href!=null) this.getLogger().debug("adding attribute href: " + href);
- if (suffix!=null) this.getLogger().debug("adding attribute suffix: " + suffix);
+ if (href != null)
+ this.getLogger().debug("adding attribute href: " + href);
+ if (suffix != null)
+ this.getLogger().debug("adding attribute suffix: " + suffix);
this.getLogger().debug("adding attribute folder: " + isFolder);
}
this.attributes.addAttribute("", ATTR_ID, ATTR_ID, "CDATA", id);
- //attributes.addAttribute("", ATTR_VISIBLEINNAV, ATTR_VISIBLEINNAV, "CDATA", isVisible);
+ //attributes.addAttribute("", ATTR_VISIBLEINNAV, ATTR_VISIBLEINNAV,
+ // "CDATA", isVisible);
this.attributes.addAttribute("", ATTR_LINK, ATTR_LINK, "CDATA", hasLink);
- if (href!=null) this.attributes.addAttribute("", ATTR_HREF, ATTR_HREF, "CDATA", href);
- if (suffix!=null) this.attributes.addAttribute("", ATTR_SUFFIX, ATTR_SUFFIX, "CDATA", suffix);
+ if (href != null)
+ this.attributes.addAttribute("", ATTR_HREF, ATTR_HREF, "CDATA", href);
+ if (suffix != null)
+ this.attributes.addAttribute("", ATTR_SUFFIX, ATTR_SUFFIX, "CDATA", suffix);
this.attributes.addAttribute("", ATTR_FOLDER, ATTR_FOLDER, "CDATA", isFolder);
- }
-
+ }
+
/**
- * Returns a value to indicate whether a node is a folder (contains subnodes).
- * With the incremental sitetree loading, we sometimes load nodes which are
- * folders, but we don't load their children. But we still have to know if
- * it's a folder or not, i.e. if it can be opened.
- * @param node
+ * Returns a value to indicate whether a node is a folder (contains
+ * subnodes). With the incremental sitetree loading, we sometimes load nodes
+ * which are folders, but we don't load their children. But we still have to
+ * know if it's a folder or not, i.e. if it can be opened.
+ * @param node
* @return "true" or "false"
*/
protected String isFolder(SiteTreeNode node) {
- if (node.getChildren().length>0) return "true";
+ if (node.getChildren().length > 0)
+ return "true";
return "false";
}
-
-
+
/**
* Ends the named node.
- * @param nodeName the name of the new node
- * @throws SAXException if an error occurs while closing the node
+ * @param nodeName the name of the new node
+ * @throws SAXException if an error occurs while closing the node
*/
protected void endNode(String nodeName) throws SAXException {
this.contentHandler.endElement(URI, nodeName, PREFIX + ':' + nodeName);
@@ -389,14 +416,15 @@
*/
protected void addLabels(SiteTreeNode node) throws SAXException {
Label[] labels = node.getLabels();
-
- for (int i=0; i<labels.length; i++) {
+
+ for (int i = 0; i < labels.length; i++) {
String lang = labels[i].getLanguage();
- if (lang==null) lang="";
+ if (lang == null)
+ lang = "";
addLabel(labels[i].getLabel(), lang);
}
}
-
+
/**
* Adds a label element of a given language.
* @param label the value of the label
@@ -405,12 +433,19 @@
*/
protected void addLabel(String label, String language) throws SAXException {
this.attributes.clear();
- this.attributes.addAttribute(XML_URI, ATTR_LANG, XML_PREFIX+":"+ATTR_LANG, "CDATA", language);
-
- this.contentHandler.startElement(URI, NODE_LABEL, PREFIX + ':' + NODE_LABEL, this.attributes);
+ this.attributes.addAttribute(XML_URI,
+ ATTR_LANG,
+ XML_PREFIX + ":" + ATTR_LANG,
+ "CDATA",
+ language);
+
+ this.contentHandler.startElement(URI,
+ NODE_LABEL,
+ PREFIX + ':' + NODE_LABEL,
+ this.attributes);
char[] labelArray = label.toCharArray();
this.contentHandler.characters(labelArray, 0, labelArray.length);
- this.contentHandler.endElement(URI, NODE_LABEL, PREFIX + ':' + NODE_LABEL);
+ this.contentHandler.endElement(URI, NODE_LABEL, PREFIX + ':' + NODE_LABEL);
}
-
-}
+
+}
\ No newline at end of file
Modified: lenya/trunk/src/java/org/apache/lenya/cms/cocoon/transformation/DocumentIndexTransformer.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/transformation/DocumentIndexTransformer.java?view=diff&r1=156557&r2=156558
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/cocoon/transformation/DocumentIndexTransformer.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/cocoon/transformation/DocumentIndexTransformer.java Tue Mar 8 10:16:05 2005
@@ -50,12 +50,13 @@
import org.xml.sax.helpers.AttributesImpl;
/**
- * This transformer lists the children of a document if the tag <namespaceURI:children>is present in
- * this document. The list of the children is in the form :<namespaceURI:children><child
- * href="....html> <ci:include src="..." element="included"/> </child> ... </namespaceURI:children>
- * Multiple language : if a child doesn't exist in the parent language, then the version in the
- * default language will be considered. If it doesn't exist too, any other existent language will be
- * considered.
+ * This transformer lists the children of a document if the tag
+ * <namespaceURI:children>is present in this document. The list of the children
+ * is in the form :<namespaceURI:children><child href="....html> <ci:include
+ * src="..." element="included"/> </child> ... </namespaceURI:children> Multiple
+ * language : if a child doesn't exist in the parent language, then the version
+ * in the default language will be considered. If it doesn't exist too, any
+ * other existent language will be considered.
*/
public class DocumentIndexTransformer extends AbstractSAXTransformer implements Parameterizable {
@@ -96,12 +97,13 @@
/**
* @see org.apache.cocoon.sitemap.SitemapModelComponent#setup(org.apache.cocoon.environment.SourceResolver,
- * java.util.Map, java.lang.String, org.apache.avalon.framework.parameters.Parameters)
+ * java.util.Map, java.lang.String,
+ * org.apache.avalon.framework.parameters.Parameters)
*/
public void setup(SourceResolver _resolver, Map _objectModel, String src, Parameters _parameters)
throws ProcessingException, SAXException, IOException {
- try {
+ try {
super.setup(_resolver, _objectModel, src, _parameters);
parameterize(_parameters);
@@ -118,9 +120,8 @@
setArea(this.document.getArea());
setBuilder(this.document.getPublication().getDocumentBuilder());
- TreeSiteManager _manager = (TreeSiteManager) this.publication
- .getSiteManager(this.identityMap);
- setSiteTree(_manager.getTree(this.area));
+ TreeSiteManager _manager = (TreeSiteManager) this.publication.getSiteManager();
+ setSiteTree(_manager.getTree(this.identityMap, this.area));
} catch (final ProcessingException e) {
throw new ProcessingException(e);
} catch (final ParameterException e) {
@@ -137,12 +138,11 @@
throw new ProcessingException(e);
}
-
}
/**
- * @see org.xml.sax.ContentHandler#startElement(java.lang.String, java.lang.String,
- * java.lang.String, org.xml.sax.Attributes)
+ * @see org.xml.sax.ContentHandler#startElement(java.lang.String,
+ * java.lang.String, java.lang.String, org.xml.sax.Attributes)
*/
public void startElement(String uri, String localName, String raw, Attributes attr)
throws SAXException {
@@ -170,7 +170,8 @@
for (int i = 0; i < children.length; i++) {
String childId = documentId + "/" + children[i].getId();
- //get child document with the same language than the parent document
+ //get child document with the same language than the parent
+ // document
Document doc;
try {
doc = this.identityMap.getFactory().get(this.area, childId, language);
@@ -180,13 +181,13 @@
String url = doc.getCanonicalWebappURL();
if (!doc.exists()) {
- //get first the child document in the default language and then in any
+ //get first the child document in the default language
+ // and then in any
// other
// existent language
- getLogger().debug(
- "There is no child document [" + doc
- + "] in the same language as the parent document ["
- + language + "]");
+ getLogger().debug("There is no child document [" + doc
+ + "] in the same language as the parent document [" + language
+ + "]");
//available language
String[] availableLanguages = null;
@@ -199,8 +200,8 @@
List languages = new ArrayList();
for (int l = 0; l < availableLanguages.length; l++) {
if (availableLanguages[l].equals(language)) {
- getLogger().debug(
- "Do nothing because language was already tested: ["
+ getLogger()
+ .debug("Do nothing because language was already tested: ["
+ availableLanguages[l] + "]");
} else if (availableLanguages[l].equals(defaultLanguage)) {
languages.add(0, availableLanguages[l]);
@@ -213,7 +214,9 @@
while (!doc.exists() && j < languages.size()) {
String newlanguage = (String) languages.get(j);
try {
- doc = this.identityMap.getFactory().get(this.area, childId, newlanguage);
+ doc = this.identityMap.getFactory().get(this.area,
+ childId,
+ newlanguage);
} catch (final DocumentBuildException e) {
throw new SAXException(e);
}
@@ -242,8 +245,8 @@
super.endElement(NAMESPACE, "child", PREFIX + "child");
} else {
//do nothing for this child
- getLogger().warn(
- "There are no existing file for the child with id " + childId);
+ getLogger().warn("There are no existing file for the child with id "
+ + childId);
}
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocument.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocument.java?view=diff&r1=156557&r2=156558
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocument.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocument.java Tue Mar 8 10:16:05 2005
@@ -187,7 +187,7 @@
public String getLabel() throws DocumentException {
String labelString = "";
try {
- SiteManager siteManager = getPublication().getSiteManager(getIdentityMap());
+ SiteManager siteManager = getPublication().getSiteManager();
if (siteManager != null) {
labelString = siteManager.getLabel(this);
}
@@ -260,7 +260,7 @@
public boolean exists() throws DocumentException {
boolean exists;
try {
- SiteManager manager = getPublication().getSiteManager(getIdentityMap());
+ SiteManager manager = getPublication().getSiteManager();
if (manager != null) {
exists = manager.contains(this);
} else {
@@ -278,7 +278,7 @@
public boolean existsInAnyLanguage() throws DocumentException {
boolean exists;
try {
- SiteManager manager = getPublication().getSiteManager(getIdentityMap());
+ SiteManager manager = getPublication().getSiteManager();
if (manager != null) {
exists = manager.containsInAnyLanguage(this);
} else {
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentIdentityMap.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentIdentityMap.java?view=diff&r1=156557&r2=156558
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentIdentityMap.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentIdentityMap.java Tue Mar 8 10:16:05 2005
@@ -34,6 +34,8 @@
private Publication publication;
private Map key2document = new HashMap();
private DocumentFactory factory;
+
+ private Map key2siteStructure = new HashMap();
/**
* Ctor.
@@ -60,6 +62,32 @@
*/
public Publication getPublication() {
return this.publication;
+ }
+
+ /**
+ * Returns a site structure object.
+ * @param publication The publication.
+ * @param area The area.
+ * @return The site structure object.
+ */
+ public Object getSiteStructure(Publication publication, String area) {
+ String key = getSiteStructureKey(publication, area);
+ return this.key2siteStructure.get(key);
+ }
+
+ /**
+ * Adds a site structure object.
+ * @param publication The publication.
+ * @param area The area.
+ * @param siteStructure The site structure to add.
+ */
+ public void putSiteStructure(Publication publication, String area, Object siteStructure) {
+ String key = getSiteStructureKey(publication, area);
+ this.key2siteStructure.put(key, siteStructure);
+ }
+
+ protected String getSiteStructureKey(Publication publication, String area) {
+ return publication.getId() + ":" + area;
}
/**
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentManagerImpl.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentManagerImpl.java?view=diff&r1=156557&r2=156558
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentManagerImpl.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentManagerImpl.java Tue Mar 8 10:16:05 2005
@@ -51,7 +51,7 @@
public void addDocument(Document document) throws PublicationException {
Publication publication = document.getPublication();
- SiteManager siteManager = publication.getSiteManager(document.getIdentityMap());
+ SiteManager siteManager = publication.getSiteManager();
if (siteManager.contains(document)) {
throw new PublicationException("The document [" + document
+ "] is already contained in this publication!");
@@ -84,8 +84,7 @@
Publication publication = sourceDocument.getPublication();
copyDocumentSource(sourceDocument, destinationDocument);
- publication.getSiteManager(sourceDocument.getIdentityMap()).copy(sourceDocument,
- destinationDocument);
+ publication.getSiteManager().copy(sourceDocument, destinationDocument);
ResourcesManager resourcesManager = sourceDocument.getResourcesManager();
WorkflowManager workflowManager = null;
@@ -111,7 +110,7 @@
throw new PublicationException("Document [" + document + "] does not exist!");
}
Publication publication = document.getPublication();
- publication.getSiteManager(document.getIdentityMap()).delete(document);
+ publication.getSiteManager().delete(document);
deleteDocumentSource(document);
ResourcesManager resourcesManager = document.getResourcesManager();
@@ -276,7 +275,7 @@
*/
public void copyAll(Document source, Document target) throws PublicationException {
DocumentIdentityMap identityMap = source.getIdentityMap();
- SiteManager manager = identityMap.getPublication().getSiteManager(identityMap);
+ SiteManager manager = identityMap.getPublication().getSiteManager();
Document[] descendantsArray = manager.getRequiringResources(source);
OrderedDocumentSet descendants = new OrderedDocumentSet(descendantsArray);
descendants.add(source);
@@ -443,7 +442,7 @@
*/
public void deleteAll(Document document) throws PublicationException {
DocumentIdentityMap identityMap = document.getIdentityMap();
- SiteManager manager = identityMap.getPublication().getSiteManager(identityMap);
+ SiteManager manager = identityMap.getPublication().getSiteManager();
Document[] descendantsArray = manager.getRequiringResources(document);
OrderedDocumentSet descendants = new OrderedDocumentSet(descendantsArray);
descendants.add(document);
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/Publication.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/Publication.java?view=diff&r1=156557&r2=156558
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/Publication.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/Publication.java Tue Mar 8 10:16:05 2005
@@ -198,11 +198,10 @@
/**
* Returns a site manager of this publication for a certain document identity map.
- * @param map The document identity map.
* @return A site manager.
* @throws SiteException if an error occurs
*/
- SiteManager getSiteManager(DocumentIdentityMap map) throws SiteException;
+ SiteManager getSiteManager() throws SiteException;
/**
* Returns the document builder of this instance.
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/PublicationImpl.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/PublicationImpl.java?view=diff&r1=156557&r2=156558
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/PublicationImpl.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/PublicationImpl.java Tue Mar 8 10:16:05 2005
@@ -352,9 +352,9 @@
private Class siteManagerClass;
/**
- * @see org.apache.lenya.cms.publication.Publication#getSiteManager(org.apache.lenya.cms.publication.DocumentIdentityMap)
+ * @see org.apache.lenya.cms.publication.Publication#getSiteManager()
*/
- public SiteManager getSiteManager(DocumentIdentityMap map) throws SiteException {
+ public SiteManager getSiteManager() throws SiteException {
SiteManager manager;
try {
manager = (SiteManager) this.siteManagerClass.newInstance();
@@ -362,7 +362,6 @@
} catch (Exception e) {
throw new SiteException(e);
}
- manager.setIdentityMap(map);
return manager;
}
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/task/PublicationTask.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/task/PublicationTask.java?view=diff&r1=156557&r2=156558
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/task/PublicationTask.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/task/PublicationTask.java Tue Mar 8 10:16:05 2005
@@ -312,11 +312,11 @@
protected SiteTree getSiteTree(String area) {
SiteTree tree;
try {
- SiteManager manager = getPublication().getSiteManager(getIdentityMap());
+ SiteManager manager = getPublication().getSiteManager();
if (!(manager instanceof TreeSiteManager)) {
throw new RuntimeException("Only supported for site trees.");
}
- tree = ((TreeSiteManager) manager).getTree(area);
+ tree = ((TreeSiteManager) manager).getTree(getIdentityMap(), area);
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/util/OrderedDocumentSet.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/util/OrderedDocumentSet.java?view=diff&r1=156557&r2=156558
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/util/OrderedDocumentSet.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/util/OrderedDocumentSet.java Tue Mar 8 10:16:05 2005
@@ -76,7 +76,7 @@
Publication publication = document.getPublication();
try {
- SiteManager manager = publication.getSiteManager(document.getIdentityMap());
+ SiteManager manager = publication.getSiteManager();
if (manager == null) {
throw new RuntimeException("The site manager must not be null!");
@@ -123,7 +123,7 @@
boolean isAntisymmetric = true;
for (int i = 0; i < resources.length; i++) {
Publication publication = resources[i].getPublication();
- SiteManager manager = publication.getSiteManager(resources[i].getIdentityMap());
+ SiteManager manager = publication.getSiteManager();
for (int j = i + 1; j < resources.length; j++) {
if (manager.requires(resources[i], resources[j])
&& manager.requires(resources[j], resources[i])
@@ -145,7 +145,7 @@
boolean isTransitive = true;
for (int i = 0; i < resources.length; i++) {
Publication publication = resources[i].getPublication();
- SiteManager manager = publication.getSiteManager(resources[i].getIdentityMap());
+ SiteManager manager = publication.getSiteManager();
for (int j = i + 1; j < resources.length; j++) {
for (int k = j + 1; k < resources.length; k++) {
if (manager.requires(resources[i], resources[j])
@@ -169,7 +169,7 @@
boolean isIrreflexive = true;
for (int i = 0; i < resources.length; i++) {
Publication publication = resources[i].getPublication();
- SiteManager manager = publication.getSiteManager(resources[i].getIdentityMap());
+ SiteManager manager = publication.getSiteManager();
if (manager.requires(resources[i], resources[i])) {
isIrreflexive = false;
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/util/PublicationHelper.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/util/PublicationHelper.java?view=diff&r1=156557&r2=156558
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/util/PublicationHelper.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/util/PublicationHelper.java Tue Mar 8 10:16:05 2005
@@ -55,7 +55,7 @@
public Document[] getAllDocuments(DocumentIdentityMap map, String area, String language)
throws DocumentException {
try {
- Document[] allDocuments = getPublication().getSiteManager(map).getDocuments(area);
+ Document[] allDocuments = getPublication().getSiteManager().getDocuments(map, area);
List documents = new ArrayList();
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/util/UniqueDocumentId.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/util/UniqueDocumentId.java?view=diff&r1=156557&r2=156558
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/util/UniqueDocumentId.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/util/UniqueDocumentId.java Tue Mar 8 10:16:05 2005
@@ -43,14 +43,13 @@
public String computeUniqueDocumentId(Publication publication, String area, String documentid) {
try {
- DocumentIdentityMap map = new DocumentIdentityMap(publication);
- SiteManager manager = publication.getSiteManager(map);
+ SiteManager manager = publication.getSiteManager();
if (!(manager instanceof TreeSiteManager)) {
throw new RuntimeException("Only supported for site trees!");
}
-
- SiteTree tree = ((TreeSiteManager) manager).getTree(area);
+ DocumentIdentityMap map = new DocumentIdentityMap(publication);
+ SiteTree tree = ((TreeSiteManager) manager).getTree(map, area);
SiteTreeNode node = tree.getNode(documentid);
String suffix = null;
int version = 0;
Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/AbstractSiteManager.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/site/AbstractSiteManager.java?view=diff&r1=156557&r2=156558
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/AbstractSiteManager.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/AbstractSiteManager.java Tue Mar 8 10:16:05 2005
@@ -18,7 +18,6 @@
package org.apache.lenya.cms.site;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
-import org.apache.lenya.cms.publication.DocumentIdentityMap;
/**
* Abstract base class for site managers.
@@ -26,29 +25,11 @@
* @version $Id$
*/
public abstract class AbstractSiteManager extends AbstractLogEnabled implements SiteManager {
-
- private DocumentIdentityMap map;
-
+
/**
* Ctor.
*/
public AbstractSiteManager() {
- // do nothing
- }
-
- /**
- * @see org.apache.lenya.cms.site.SiteManager#setIdentityMap(org.apache.lenya.cms.publication.DocumentIdentityMap)
- */
- public void setIdentityMap(DocumentIdentityMap _map) {
- this.map = _map;
- }
-
- /**
- * Returns the identity map.
- * @return A resource identity map.
- */
- public DocumentIdentityMap getIdentityMap() {
- return this.map;
}
-}
+}
\ No newline at end of file
Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/SiteManager.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/site/SiteManager.java?view=diff&r1=156557&r2=156558
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/SiteManager.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/SiteManager.java Tue Mar 8 10:16:05 2005
@@ -38,6 +38,11 @@
* @version $Id$
*/
public interface SiteManager {
+
+ /**
+ * The Avalon role.
+ */
+ String ROLE = SiteManager.ROLE;
/**
* Checks if a resource requires another one.
@@ -121,16 +126,11 @@
/**
* Returns all documents in a certain area.
+ * @param identityMap The identityMap to use.
* @param area The area.
* @return An array of documents.
* @throws SiteException if an error occurs.
*/
- Document[] getDocuments(String area) throws SiteException;
-
- /**
- * Sets the identity map.
- * @param map A resource identity map.
- */
- void setIdentityMap(DocumentIdentityMap map);
+ Document[] getDocuments(DocumentIdentityMap identityMap, String area) throws SiteException;
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/topicmap/TopicMapSiteManager.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/site/topicmap/TopicMapSiteManager.java?view=diff&r1=156557&r2=156558
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/topicmap/TopicMapSiteManager.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/topicmap/TopicMapSiteManager.java Tue Mar 8 10:16:05 2005
@@ -111,19 +111,12 @@
}
/**
- * @see org.apache.lenya.cms.site.SiteManager#getDocuments(java.lang.String)
+ * @see org.apache.lenya.cms.site.SiteManager#getDocuments(org.apache.lenya.cms.publication.DocumentIdentityMap,
+ * java.lang.String)
*/
- public Document[] getDocuments(String area) throws SiteException {
+ public Document[] getDocuments(DocumentIdentityMap map, String area) throws SiteException {
// TODO Auto-generated method stub
return null;
- }
-
- /**
- * @see org.apache.lenya.cms.site.SiteManager#setIdentityMap(org.apache.lenya.cms.publication.DocumentIdentityMap)
- */
- public void setIdentityMap(DocumentIdentityMap map) {
- // TODO Auto-generated method stub
-
}
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/tree/TreeSiteManager.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/site/tree/TreeSiteManager.java?view=diff&r1=156557&r2=156558
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/tree/TreeSiteManager.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/tree/TreeSiteManager.java Tue Mar 8 10:16:05 2005
@@ -18,13 +18,12 @@
package org.apache.lenya.cms.site.tree;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import org.apache.avalon.framework.container.ContainerUtil;
import org.apache.lenya.cms.publication.Document;
import org.apache.lenya.cms.publication.DocumentBuildException;
+import org.apache.lenya.cms.publication.DocumentIdentityMap;
import org.apache.lenya.cms.publication.PublicationException;
import org.apache.lenya.cms.site.AbstractSiteManager;
import org.apache.lenya.cms.site.Label;
@@ -37,31 +36,27 @@
*/
public class TreeSiteManager extends AbstractSiteManager {
- private Map siteTrees = new HashMap();
-
/**
* Ctor.
*/
public TreeSiteManager() {
- // do nothing
+ // do nothing
}
/**
- * Returns the sitetree for a specific area of this publication. Sitetrees are created on demand
- * and are cached.
+ * Returns the sitetree for a specific area of this publication. Sitetrees
+ * are created on demand and are cached.
+ * @param map The document identity map.
* @param area The area.
* @return A site tree.
* @throws SiteException if an error occurs.
*/
- public SiteTree getTree(String area) throws SiteException {
- DefaultSiteTree sitetree = null;
-
- if (this.siteTrees.containsKey(area)) {
- sitetree = (DefaultSiteTree) this.siteTrees.get(area);
- } else {
- sitetree = new DefaultSiteTree(getIdentityMap().getPublication().getDirectory(), area);
+ public SiteTree getTree(DocumentIdentityMap map, String area) throws SiteException {
+ DefaultSiteTree sitetree = (DefaultSiteTree) map.getSiteStructure(map.getPublication(), area);
+ if (sitetree == null) {
+ sitetree = new DefaultSiteTree(map.getPublication().getDirectory(), area);
ContainerUtil.enableLogging(sitetree, getLogger());
- this.siteTrees.put(area, sitetree);
+ map.putSiteStructure(map.getPublication(), area, sitetree);
}
return sitetree;
}
@@ -76,7 +71,7 @@
List ancestors = new ArrayList();
Document parent;
try {
- parent = getIdentityMap().getFactory().getParent(resource);
+ parent = resource.getIdentityMap().getFactory().getParent(resource);
} catch (DocumentBuildException e) {
throw new SiteException(e);
}
@@ -113,7 +108,7 @@
getLogger().debug("Obtaining requiring resources of [" + resource + "]");
}
- SiteTree tree = getTree(resource.getArea());
+ SiteTree tree = getTree(resource.getIdentityMap(), resource.getArea());
SiteTreeNode node = tree.getNode(resource.getId());
List preOrder = node.preOrder();
@@ -126,7 +121,7 @@
try {
for (int i = 0; i < resources.length; i++) {
SiteTreeNode descendant = (SiteTreeNode) preOrder.get(i);
- resources[i] = getIdentityMap().getFactory().get(resource.getArea(),
+ resources[i] = resource.getIdentityMap().getFactory().get(resource.getArea(),
descendant.getAbsoluteId());
if (getLogger().isDebugEnabled()) {
getLogger().debug(" Descendant: [" + resources[i] + "]");
@@ -147,7 +142,8 @@
* @see org.apache.lenya.cms.site.SiteManager#contains(org.apache.lenya.cms.publication.Document)
*/
public boolean contains(Document resource) throws SiteException {
- SiteTreeNode node = getTree(resource.getArea()).getNode(resource.getId());
+ SiteTree tree = getTree(resource.getIdentityMap(), resource.getArea());
+ SiteTreeNode node = tree.getNode(resource.getId());
return node != null && node.getLabel(resource.getLanguage()) != null;
}
@@ -155,7 +151,8 @@
* @see org.apache.lenya.cms.site.SiteManager#containsInAnyLanguage(org.apache.lenya.cms.publication.Document)
*/
public boolean containsInAnyLanguage(Document resource) throws SiteException {
- SiteTreeNode node = getTree(resource.getArea()).getNode(resource.getId());
+ SiteTree tree = getTree(resource.getIdentityMap(), resource.getArea());
+ SiteTreeNode node = tree.getNode(resource.getId());
return node != null;
}
@@ -164,8 +161,9 @@
* org.apache.lenya.cms.publication.Document)
*/
public void copy(Document sourceDocument, Document destinationDocument) throws SiteException {
- SiteTree sourceTree = getTree(sourceDocument.getArea());
- SiteTree destinationTree = getTree(destinationDocument.getArea());
+ SiteTree sourceTree = getTree(sourceDocument.getIdentityMap(), sourceDocument.getArea());
+ SiteTree destinationTree = getTree(destinationDocument.getIdentityMap(),
+ destinationDocument.getArea());
SiteTreeNode sourceNode = sourceTree.getNode(sourceDocument.getId());
if (sourceNode == null) {
@@ -206,11 +204,17 @@
Label[] labels = { label };
if (siblingDocId == null) {
- destinationTree.addNode(destinationDocument.getId(), labels, sourceNode
- .getHref(), sourceNode.getSuffix(), sourceNode.hasLink());
+ destinationTree.addNode(destinationDocument.getId(),
+ labels,
+ sourceNode.getHref(),
+ sourceNode.getSuffix(),
+ sourceNode.hasLink());
} else {
- destinationTree.addNode(destinationDocument.getId(), labels, sourceNode
- .getHref(), sourceNode.getSuffix(), sourceNode.hasLink(),
+ destinationTree.addNode(destinationDocument.getId(),
+ labels,
+ sourceNode.getHref(),
+ sourceNode.getSuffix(),
+ sourceNode.hasLink(),
siblingDocId);
}
@@ -221,8 +225,6 @@
destinationTree.setLabel(destinationDocument.getId(), label);
}
-
-
destinationTree.save();
}
@@ -230,7 +232,7 @@
* @see org.apache.lenya.cms.site.SiteManager#delete(org.apache.lenya.cms.publication.Document)
*/
public void delete(Document document) throws SiteException {
- SiteTree tree = getTree(document.getArea());
+ SiteTree tree = getTree(document.getIdentityMap(), document.getArea());
SiteTreeNode node = tree.getNode(document.getId());
@@ -274,8 +276,8 @@
public void setLabel(Document document, String label) throws SiteException {
Label labelObject = getLabelObject(document);
labelObject.setLabel(label);
-
- SiteTree tree = getTree(document.getArea());
+
+ SiteTree tree = getTree(document.getIdentityMap(), document.getArea());
tree.setLabel(document.getId(), labelObject);
tree.save();
}
@@ -288,7 +290,7 @@
*/
protected Label getLabelObject(Document document) throws SiteException {
Label label = null;
- SiteTree siteTree = getTree(document.getArea());
+ SiteTree siteTree = getTree(document.getIdentityMap(), document.getArea());
if (siteTree != null) {
SiteTreeNode node = siteTree.getNode(document.getId());
if (node == null) {
@@ -305,16 +307,17 @@
}
/**
- * @see org.apache.lenya.cms.site.SiteManager#getDocuments(java.lang.String)
+ * @see org.apache.lenya.cms.site.SiteManager#getDocuments(org.apache.lenya.cms.publication.DocumentIdentityMap,
+ * java.lang.String)
*/
- public Document[] getDocuments(String area) throws SiteException {
+ public Document[] getDocuments(DocumentIdentityMap map, String area) throws SiteException {
try {
- List allNodes = getTree(area).getNode("/").preOrder();
+ List allNodes = getTree(map, area).getNode("/").preOrder();
Document[] documents = new Document[allNodes.size() - 1];
for (int i = 1; i < allNodes.size(); i++) {
SiteTreeNode node = (SiteTreeNode) allNodes.get(i);
- documents[i - 1] = getIdentityMap().getFactory().get(area, node.getAbsoluteId());
+ documents[i - 1] = map.getFactory().get(area, node.getAbsoluteId());
}
return documents;
} catch (DocumentBuildException e) {
@@ -330,16 +333,15 @@
if (contains(document)) {
throw new SiteException("The document [" + document + "] is already contained!");
}
- SiteTree tree = getTree(document.getArea());
+ SiteTree tree = getTree(document.getIdentityMap(), document.getArea());
Label label = new Label("", document.getLanguage());
-
+
SiteTreeNode node = tree.getNode(document.getId());
if (node == null) {
Label[] labels = { label };
tree.addNode(document.getId(), labels, null, null, false);
tree.save();
- }
- else {
+ } else {
tree.addLabel(document.getId(), label);
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/ChangeLabel.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/ChangeLabel.java?view=diff&r1=156557&r2=156558
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/ChangeLabel.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/ChangeLabel.java Tue Mar 8 10:16:05 2005
@@ -56,8 +56,7 @@
try {
if (document != null && document.exists()) {
setParameter(DOCUMENT_ID, document.getId());
- SiteManager _manager = document.getPublication().getSiteManager(document
- .getIdentityMap());
+ SiteManager _manager = document.getPublication().getSiteManager();
setParameter(LABEL, _manager.getLabel(document));
}
} catch (Exception e) {
@@ -72,7 +71,7 @@
super.doExecute();
Document document = getSourceDocument();
- SiteManager _manager = document.getPublication().getSiteManager(document.getIdentityMap());
+ SiteManager _manager = document.getPublication().getSiteManager();
String label = getParameterAsString(LABEL);
_manager.setLabel(document, label);
Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/Create.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/Create.java?view=diff&r1=156557&r2=156558
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/Create.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/Create.java Tue Mar 8 10:16:05 2005
@@ -85,7 +85,7 @@
Publication publication = document.getPublication();
getDocumentManager().addDocument(document);
- SiteManager _manager = publication.getSiteManager(document.getIdentityMap());
+ SiteManager _manager = publication.getSiteManager();
_manager.setLabel(document, getParameterAsString(DublinCore.ELEMENT_TITLE));
setMetaData(document);
Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/Delete.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/Delete.java?view=diff&r1=156557&r2=156558
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/Delete.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/Delete.java Tue Mar 8 10:16:05 2005
@@ -19,7 +19,6 @@
import org.apache.lenya.cms.publication.Document;
import org.apache.lenya.cms.publication.DocumentIdentityMap;
import org.apache.lenya.cms.publication.Publication;
-import org.apache.lenya.cms.publication.util.DocumentHelper;
import org.apache.lenya.cms.publication.util.DocumentSet;
import org.apache.lenya.cms.publication.util.UniqueDocumentId;
import org.apache.lenya.cms.site.SiteManager;
@@ -48,7 +47,7 @@
Document document = getSourceDocument();
DocumentIdentityMap identityMap = getUnitOfWork().getIdentityMap();
- SiteManager manager = document.getPublication().getSiteManager(identityMap);
+ SiteManager manager = document.getPublication().getSiteManager();
DocumentSet set = new DocumentSet(manager.getRequiringResources(document));
set.add(document);
Document[] documents = set.getDocuments();
Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/LinkRewriterImpl.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/LinkRewriterImpl.java?view=diff&r1=156557&r2=156558
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/LinkRewriterImpl.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/LinkRewriterImpl.java Tue Mar 8 10:16:05 2005
@@ -76,8 +76,8 @@
SiteManager siteManager;
Document[] documents;
try {
- siteManager = publication.getSiteManager(identityMap);
- documents = siteManager.getDocuments(area);
+ siteManager = publication.getSiteManager();
+ documents = siteManager.getDocuments(identityMap, area);
} catch (SiteException e) {
throw new RuntimeException(e);
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/Nudge.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/Nudge.java?view=diff&r1=156557&r2=156558
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/Nudge.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/Nudge.java Tue Mar 8 10:16:05 2005
@@ -26,11 +26,11 @@
/**
* Nudge a document one position up or down.
- *
+ *
* @version $Id:$
*/
public class Nudge extends DocumentUsecase {
-
+
protected static final String DIRECTION = "direction";
protected static final String UP = "up";
protected static final String DOWN = "down";
@@ -41,71 +41,69 @@
public boolean isInteractive() {
return false;
}
-
+
/**
* @see org.apache.lenya.cms.usecase.AbstractUsecase#doCheckPreconditions()
*/
protected void doCheckPreconditions() throws Exception {
super.doCheckPreconditions();
-
+
if (!getErrorMessages().isEmpty()) {
return;
}
-
+
DocumentIdentityMap identityMap = getUnitOfWork().getIdentityMap();
Publication publication = identityMap.getPublication();
- SiteManager manager = publication.getSiteManager(identityMap);
+ SiteManager manager = publication.getSiteManager();
if (manager instanceof TreeSiteManager) {
-
+
TreeSiteManager treeManager = (TreeSiteManager) manager;
- SiteTree tree = treeManager.getTree(getSourceDocument().getArea());
+ SiteTree tree = treeManager.getTree(getSourceDocument().getIdentityMap(),
+ getSourceDocument().getArea());
SiteTreeNode node = tree.getNode(getSourceDocument().getId());
SiteTreeNode[] siblings = null;
-
+
String direction = getParameterAsString(DIRECTION);
if (direction.equals(UP)) {
siblings = node.getPrecedingSiblings();
- }
- else if (direction.equals(DOWN)) {
+ } else if (direction.equals(DOWN)) {
siblings = node.getNextSiblings();
- }
- else {
+ } else {
addErrorMessage("The direction [" + direction + "] is not supported!");
}
-
+
if (siblings != null && siblings.length == 0) {
addErrorMessage("Cannot move the node in this direction.");
}
- }
- else {
+ } else {
addErrorMessage("This operation can only be invoked on site trees.");
}
}
-
+
/**
* @see org.apache.lenya.cms.usecase.AbstractUsecase#doExecute()
*/
protected void doExecute() throws Exception {
super.doExecute();
-
+
DocumentIdentityMap identityMap = getUnitOfWork().getIdentityMap();
Publication publication = identityMap.getPublication();
- SiteManager manager = publication.getSiteManager(identityMap);
+ SiteManager manager = publication.getSiteManager();
if (manager instanceof TreeSiteManager) {
-
+
TreeSiteManager treeManager = (TreeSiteManager) manager;
- SiteTree tree = treeManager.getTree(getSourceDocument().getArea());
-
+ SiteTree tree = treeManager.getTree(getSourceDocument().getIdentityMap(),
+ getSourceDocument().getArea());
+
String direction = getParameterAsString(DIRECTION);
if (direction.equals(UP)) {
tree.moveUp(getSourceDocument().getId());
- }
- else if (direction.equals(DOWN)) {
+ } else if (direction.equals(DOWN)) {
tree.moveDown(getSourceDocument().getId());
}
tree.save();
}
}
-
-}
+
+}
\ No newline at end of file
Modified: lenya/trunk/src/java/org/apache/lenya/lenya.roles
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/lenya.roles?view=diff&r1=156557&r2=156558
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/lenya.roles (original)
+++ lenya/trunk/src/java/org/apache/lenya/lenya.roles Tue Mar 8 10:16:05 2005
@@ -118,4 +118,8 @@
shorthand="document-manager"
default-class="org.apache.lenya.cms.publication.DocumentManagerImpl"/>
+ <role name="org.apache.lenya.cms.site.SiteManager"
+ shorthand="document-manager"
+ default-class="org.apache.lenya.cms.site.tree.TreeSiteManager"/>
+
</role-list>
Modified: lenya/trunk/src/webapp/lenya/pubs/default/java/src/org/apache/lenya/defaultpub/cms/usecases/Deactivate.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/webapp/lenya/pubs/default/java/src/org/apache/lenya/defaultpub/cms/usecases/Deactivate.java?view=diff&r1=156557&r2=156558
==============================================================================
--- lenya/trunk/src/webapp/lenya/pubs/default/java/src/org/apache/lenya/defaultpub/cms/usecases/Deactivate.java (original)
+++ lenya/trunk/src/webapp/lenya/pubs/default/java/src/org/apache/lenya/defaultpub/cms/usecases/Deactivate.java Tue Mar 8 10:16:05 2005
@@ -136,8 +136,7 @@
try {
OrderedDocumentSet set = new OrderedDocumentSet();
- SiteManager manager = document.getPublication().getSiteManager(document
- .getIdentityMap());
+ SiteManager manager = document.getPublication().getSiteManager();
Document[] descendants = manager.getRequiringResources(document);
set = new OrderedDocumentSet(descendants);
Modified: lenya/trunk/src/webapp/lenya/pubs/default/java/src/org/apache/lenya/defaultpub/cms/usecases/Delete.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/webapp/lenya/pubs/default/java/src/org/apache/lenya/defaultpub/cms/usecases/Delete.java?view=diff&r1=156557&r2=156558
==============================================================================
--- lenya/trunk/src/webapp/lenya/pubs/default/java/src/org/apache/lenya/defaultpub/cms/usecases/Delete.java (original)
+++ lenya/trunk/src/webapp/lenya/pubs/default/java/src/org/apache/lenya/defaultpub/cms/usecases/Delete.java Tue Mar 8 10:16:05 2005
@@ -17,7 +17,6 @@
package org.apache.lenya.defaultpub.cms.usecases;
import org.apache.lenya.cms.publication.Document;
-import org.apache.lenya.cms.publication.DocumentIdentityMap;
import org.apache.lenya.cms.publication.util.DocumentSet;
import org.apache.lenya.cms.site.SiteException;
import org.apache.lenya.cms.site.SiteManager;
@@ -82,8 +81,7 @@
*/
protected DocumentSet getSubset() throws SiteException {
Document document = getSourceDocument();
- DocumentIdentityMap identityMap = getUnitOfWork().getIdentityMap();
- SiteManager manager = document.getPublication().getSiteManager(identityMap);
+ SiteManager manager = document.getPublication().getSiteManager();
DocumentSet set = new DocumentSet(manager.getRequiringResources(document));
set.add(document);
return set;
Modified: lenya/trunk/src/webapp/lenya/pubs/default/java/src/org/apache/lenya/defaultpub/cms/usecases/Publish.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/webapp/lenya/pubs/default/java/src/org/apache/lenya/defaultpub/cms/usecases/Publish.java?view=diff&r1=156557&r2=156558
==============================================================================
--- lenya/trunk/src/webapp/lenya/pubs/default/java/src/org/apache/lenya/defaultpub/cms/usecases/Publish.java (original)
+++ lenya/trunk/src/webapp/lenya/pubs/default/java/src/org/apache/lenya/defaultpub/cms/usecases/Publish.java Tue Mar 8 10:16:05 2005
@@ -80,7 +80,7 @@
List missingDocuments = new ArrayList();
- SiteManager manager = publication.getSiteManager(document.getIdentityMap());
+ SiteManager manager = publication.getSiteManager();
Document[] requiredDocuments = manager.getRequiredResources(liveDocument);
for (int i = 0; i < requiredDocuments.length; i++) {
if (!manager.containsInAnyLanguage(requiredDocuments[i])) {
@@ -151,8 +151,7 @@
try {
OrderedDocumentSet set = new OrderedDocumentSet();
- SiteManager manager = document.getPublication().getSiteManager(document
- .getIdentityMap());
+ SiteManager manager = document.getPublication().getSiteManager();
Document[] descendants = manager.getRequiringResources(document);
set = new OrderedDocumentSet(descendants);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org