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 2004/09/13 12:04:50 UTC
svn commit: rev 45961 - in incubator/lenya/trunk/src/java/org/apache/lenya/cms: ant authoring cocoon/acting cocoon/components/modules/input cocoon/transformation publication publication/xsp site site/tree
Author: andreas
Date: Mon Sep 13 03:04:48 2004
New Revision: 45961
Added:
incubator/lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentIdentityMap.java
incubator/lenya/trunk/src/java/org/apache/lenya/cms/site/
incubator/lenya/trunk/src/java/org/apache/lenya/cms/site/AbstractSiteManager.java
incubator/lenya/trunk/src/java/org/apache/lenya/cms/site/SiteException.java
incubator/lenya/trunk/src/java/org/apache/lenya/cms/site/SiteManager.java
incubator/lenya/trunk/src/java/org/apache/lenya/cms/site/tree/
incubator/lenya/trunk/src/java/org/apache/lenya/cms/site/tree/DefaultSiteTree.java
- copied, changed from rev 45959, incubator/lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultSiteTree.java
incubator/lenya/trunk/src/java/org/apache/lenya/cms/site/tree/Label.java
- copied, changed from rev 45951, incubator/lenya/trunk/src/java/org/apache/lenya/cms/publication/Label.java
incubator/lenya/trunk/src/java/org/apache/lenya/cms/site/tree/SiteTree.java
- copied, changed from rev 45951, incubator/lenya/trunk/src/java/org/apache/lenya/cms/publication/SiteTree.java
incubator/lenya/trunk/src/java/org/apache/lenya/cms/site/tree/SiteTreeNode.java
- copied, changed from rev 45951, incubator/lenya/trunk/src/java/org/apache/lenya/cms/publication/SiteTreeNode.java
incubator/lenya/trunk/src/java/org/apache/lenya/cms/site/tree/SiteTreeNodeImpl.java
- copied, changed from rev 45951, incubator/lenya/trunk/src/java/org/apache/lenya/cms/publication/SiteTreeNodeImpl.java
incubator/lenya/trunk/src/java/org/apache/lenya/cms/site/tree/SiteTreeNodeVisitor.java
- copied, changed from rev 45951, incubator/lenya/trunk/src/java/org/apache/lenya/cms/publication/SiteTreeNodeVisitor.java
incubator/lenya/trunk/src/java/org/apache/lenya/cms/site/tree/TreeSiteManager.java
Removed:
incubator/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/transformation/SimpleLinkRewritingTransformer.java
incubator/lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultSiteTree.java
incubator/lenya/trunk/src/java/org/apache/lenya/cms/publication/Label.java
incubator/lenya/trunk/src/java/org/apache/lenya/cms/publication/SiteTree.java
incubator/lenya/trunk/src/java/org/apache/lenya/cms/publication/SiteTreeException.java
incubator/lenya/trunk/src/java/org/apache/lenya/cms/publication/SiteTreeNode.java
incubator/lenya/trunk/src/java/org/apache/lenya/cms/publication/SiteTreeNodeImpl.java
incubator/lenya/trunk/src/java/org/apache/lenya/cms/publication/SiteTreeNodeVisitor.java
Modified:
incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/CopyContentTask.java
incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/CopyPoliciesTask.java
incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/CopyResourcesTask.java
incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/DeactivateResourcesTask.java
incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/DeleteContentTask.java
incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/DeleteLanguageNodeTask.java
incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/DeleteNodeTask.java
incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/DeletePoliciesTask.java
incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/DeleteRCTask.java
incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/DeleteResourcesTask.java
incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/DeleteSchedulerEntryTask.java
incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/DocumentOperationTask.java
incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/InitCopyWorkflowTask.java
incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/InitRCTask.java
incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/InsertCopyNode.java
incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/InsertLabelTask.java
incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/MoveDocumentTask.java
incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/MoveNode.java
incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/MoveSiteTreeNodeTask.java
incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/MoveWorkflowTask.java
incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/RemoveLabelTask.java
incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/RenameLabelTask.java
incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/SetIdentifier.java
incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/SiteTreeResetTask.java
incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/TreePublisher.java
incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/TwoNodesTask.java
incubator/lenya/trunk/src/java/org/apache/lenya/cms/authoring/DocumentCreator.java
incubator/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/DefaultCreatorAction.java
incubator/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/DocumentIdExistsAction.java
incubator/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/SitetreeModule.java
incubator/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/transformation/AccessControlSitetreeTransformer.java
incubator/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/transformation/DocumentIndexTransformer.java
incubator/lenya/trunk/src/java/org/apache/lenya/cms/publication/AbstractPublication.java
incubator/lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocument.java
incubator/lenya/trunk/src/java/org/apache/lenya/cms/publication/DublinCoreHelper.java
incubator/lenya/trunk/src/java/org/apache/lenya/cms/publication/Publication.java
incubator/lenya/trunk/src/java/org/apache/lenya/cms/publication/PublicationHelper.java
incubator/lenya/trunk/src/java/org/apache/lenya/cms/publication/UniqueDocumentId.java
incubator/lenya/trunk/src/java/org/apache/lenya/cms/publication/xsp/DocumentReferencesHelper.java
Log:
moved sitetree classes to their own package
Modified: incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/CopyContentTask.java
==============================================================================
--- incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/CopyContentTask.java (original)
+++ incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/CopyContentTask.java Mon Sep 13 03:04:48 2004
@@ -15,7 +15,7 @@
*
*/
-/* $Id: CopyContentTask.java,v 1.6 2004/03/03 12:56:30 gregor Exp $ */
+/* $Id$ */
package org.apache.lenya.cms.ant;
@@ -26,9 +26,9 @@
import org.apache.lenya.cms.publication.Document;
import org.apache.lenya.cms.publication.DocumentBuildException;
import org.apache.lenya.cms.publication.DocumentBuilder;
-import org.apache.lenya.cms.publication.Label;
import org.apache.lenya.cms.publication.Publication;
-import org.apache.lenya.cms.publication.SiteTreeNode;
+import org.apache.lenya.cms.site.tree.Label;
+import org.apache.lenya.cms.site.tree.SiteTreeNode;
import org.apache.lenya.util.FileUtil;
import org.apache.tools.ant.BuildException;
@@ -46,7 +46,7 @@
}
/** (non-Javadoc)
- * @see org.apache.lenya.cms.publication.SiteTreeNodeVisitor#visitSiteTreeNode(org.apache.lenya.cms.publication.SiteTreeNode)
+ * @see org.apache.lenya.cms.site.tree.SiteTreeNodeVisitor#visitSiteTreeNode(org.apache.lenya.cms.publication.SiteTreeNode)
*/
public void visitSiteTreeNode(SiteTreeNode node) {
Publication publication = getPublication();
Modified: incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/CopyPoliciesTask.java
==============================================================================
--- incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/CopyPoliciesTask.java (original)
+++ incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/CopyPoliciesTask.java Mon Sep 13 03:04:48 2004
@@ -15,7 +15,7 @@
*
*/
-/* $Id: CopyPoliciesTask.java,v 1.4 2004/03/03 12:56:30 gregor Exp $ */
+/* $Id$ */
package org.apache.lenya.cms.ant;
@@ -25,7 +25,7 @@
import org.apache.avalon.excalibur.io.FileUtil;
import org.apache.lenya.cms.publication.Publication;
-import org.apache.lenya.cms.publication.SiteTreeNode;
+import org.apache.lenya.cms.site.tree.SiteTreeNode;
import org.apache.tools.ant.BuildException;
/**
Modified: incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/CopyResourcesTask.java
==============================================================================
--- incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/CopyResourcesTask.java (original)
+++ incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/CopyResourcesTask.java Mon Sep 13 03:04:48 2004
@@ -15,7 +15,7 @@
*
*/
-/* $Id: CopyResourcesTask.java,v 1.7 2004/03/03 12:56:30 gregor Exp $ */
+/* $Id$ */
package org.apache.lenya.cms.ant;
@@ -29,10 +29,10 @@
import org.apache.lenya.cms.publication.Document;
import org.apache.lenya.cms.publication.DocumentBuildException;
import org.apache.lenya.cms.publication.DocumentBuilder;
-import org.apache.lenya.cms.publication.Label;
import org.apache.lenya.cms.publication.Publication;
import org.apache.lenya.cms.publication.ResourcesManager;
-import org.apache.lenya.cms.publication.SiteTreeNode;
+import org.apache.lenya.cms.site.tree.Label;
+import org.apache.lenya.cms.site.tree.SiteTreeNode;
import org.apache.tools.ant.BuildException;
/**
@@ -51,7 +51,7 @@
/**
* Copy the resources files belongs to the documents corresponding to this node
*
- * @see org.apache.lenya.cms.publication.SiteTreeNodeVisitor#visitSiteTreeNode(org.apache.lenya.cms.publication.SiteTreeNode)
+ * @see org.apache.lenya.cms.site.tree.SiteTreeNodeVisitor#visitSiteTreeNode(org.apache.lenya.cms.publication.SiteTreeNode)
*/
public void visitSiteTreeNode(SiteTreeNode node) {
Publication publication = getPublication();
Modified: incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/DeactivateResourcesTask.java
==============================================================================
--- incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/DeactivateResourcesTask.java (original)
+++ incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/DeactivateResourcesTask.java Mon Sep 13 03:04:48 2004
@@ -15,160 +15,153 @@
*
*/
-/* $Id: DeactivateResourcesTask.java,v 1.4 2004/08/16 12:00:55 andreas Exp $ */
+/* $Id$ */
package org.apache.lenya.cms.ant;
import java.io.File;
-import org.apache.lenya.cms.publication.DefaultSiteTree;
import org.apache.lenya.cms.publication.Document;
import org.apache.lenya.cms.publication.DocumentBuildException;
import org.apache.lenya.cms.publication.DocumentBuilder;
-import org.apache.lenya.cms.publication.Label;
import org.apache.lenya.cms.publication.Publication;
import org.apache.lenya.cms.publication.ResourcesManager;
-import org.apache.lenya.cms.publication.SiteTreeException;
-import org.apache.lenya.cms.publication.SiteTreeNode;
+import org.apache.lenya.cms.site.SiteException;
+import org.apache.lenya.cms.site.tree.DefaultSiteTree;
+import org.apache.lenya.cms.site.tree.Label;
+import org.apache.lenya.cms.site.tree.SiteTreeNode;
import org.apache.tools.ant.BuildException;
/**
* Ant task to remove the resources belonging to a document with document id <documentid>, area
- * <area>and language <language>. The resources are removed when no more version of this document
- * is available.
+ * <area>and language <language>. The resources are removed when no more version of this document is
+ * available.
*/
public class DeactivateResourcesTask extends PublicationTask {
- private String area;
- private String documentid;
- private String language;
-
- /**
- * Creates a new instance of DeactivateResourcesTask
- */
- public DeactivateResourcesTask() {
- super();
- }
-
- /**
- * Remove the resources belonging to the document with document id <documentid>, area <area>
- * and language <language>, when no more version of this document is available.
- *
- * @param language
- * The language
- * @param documentid
- * The document id
- * @param area
- * The area
- *
- * @throws SiteTreeException
- * if an error occurs
- */
- public void deactivateResources(String language, String documentid, String area)
- throws SiteTreeException {
- Publication publication = getPublication();
- DefaultSiteTree tree = null;
-
- try {
- tree = publication.getSiteTree(area);
- SiteTreeNode node = tree.getNode(documentid);
- Label[] labels = null;
- if (node != null) {
- labels = node.getLabels();
- }
- if (node == null || (labels != null && labels.length < 1)) {
-
- DocumentBuilder builder = publication.getDocumentBuilder();
- String url = builder.buildCanonicalUrl(publication, area, documentid, language);
- Document doc;
- try {
- doc = builder.buildDocument(publication, url);
- } catch (DocumentBuildException e) {
- throw new BuildException(e);
- }
- ResourcesManager resourcesMgr = new ResourcesManager(doc);
- File[] resources = resourcesMgr.getResources();
- for (int i = 0; i < resources.length; i++) {
- resources[i].delete();
- }
- File directory = resourcesMgr.getPath();
- directory.delete();
- }
- } catch (Exception e) {
- throw new SiteTreeException(e);
- }
- }
-
- /**
- * (non-Javadoc)
- *
- * @see org.apache.tools.ant.Task#execute()
- */
- public void execute() throws BuildException {
- try {
- log("document-id : " + getDocumentid());
- log("area: " + getArea());
- log("language : " + getArea());
- deactivateResources(getLanguage(), getDocumentid(), getArea());
- } catch (Exception e) {
- throw new BuildException(e);
- }
- }
-
- /**
- * Get the value of the area.
- *
- * @return The area.
- */
- public String getArea() {
- return area;
- }
-
- /**
- * Get the value of the document id.
- *
- * @return The document id.
- */
- public String getDocumentid() {
- return documentid;
- }
-
- /**
- * Get the value of the language.
- *
- * @return The language.
- */
- public String getLanguage() {
- return language;
- }
-
- /**
- * Set the value of the area.
- *
- * @param string
- * The area.
- */
- public void setArea(String string) {
- area = string;
- }
-
- /**
- * Set the value of the document id.
- *
- * @param string
- * The document id.
- */
- public void setDocumentid(String string) {
- documentid = string;
- }
-
- /**
- * Set the value of the language.
- *
- * @param string
- * The language.
- */
- public void setLanguage(String string) {
- language = string;
- }
+ private String area;
+ private String documentid;
+ private String language;
+
+ /**
+ * Creates a new instance of DeactivateResourcesTask
+ */
+ public DeactivateResourcesTask() {
+ super();
+ }
+
+ /**
+ * Remove the resources belonging to the document with document id <documentid>, area <area>and
+ * language <language>, when no more version of this document is available.
+ *
+ * @param language The language
+ * @param documentid The document id
+ * @param area The area
+ *
+ * @throws SiteException if an error occurs
+ */
+ public void deactivateResources(String language, String documentid, String area)
+ throws SiteException {
+ Publication publication = getPublication();
+ DefaultSiteTree tree = null;
+
+ try {
+ tree = publication.getSiteTree(area);
+ SiteTreeNode node = tree.getNode(documentid);
+ Label[] labels = null;
+ if (node != null) {
+ labels = node.getLabels();
+ }
+ if (node == null || (labels != null && labels.length < 1)) {
+
+ DocumentBuilder builder = publication.getDocumentBuilder();
+ String url = builder.buildCanonicalUrl(publication, area, documentid, language);
+ Document doc;
+ try {
+ doc = builder.buildDocument(publication, url);
+ } catch (DocumentBuildException e) {
+ throw new BuildException(e);
+ }
+ ResourcesManager resourcesMgr = new ResourcesManager(doc);
+ File[] resources = resourcesMgr.getResources();
+ for (int i = 0; i < resources.length; i++) {
+ resources[i].delete();
+ }
+ File directory = resourcesMgr.getPath();
+ directory.delete();
+ }
+ } catch (Exception e) {
+ throw new SiteException(e);
+ }
+ }
+
+ /**
+ * (non-Javadoc)
+ *
+ * @see org.apache.tools.ant.Task#execute()
+ */
+ public void execute() throws BuildException {
+ try {
+ log("document-id : " + getDocumentid());
+ log("area: " + getArea());
+ log("language : " + getArea());
+ deactivateResources(getLanguage(), getDocumentid(), getArea());
+ } catch (Exception e) {
+ throw new BuildException(e);
+ }
+ }
+
+ /**
+ * Get the value of the area.
+ *
+ * @return The area.
+ */
+ public String getArea() {
+ return area;
+ }
+
+ /**
+ * Get the value of the document id.
+ *
+ * @return The document id.
+ */
+ public String getDocumentid() {
+ return documentid;
+ }
+
+ /**
+ * Get the value of the language.
+ *
+ * @return The language.
+ */
+ public String getLanguage() {
+ return language;
+ }
+
+ /**
+ * Set the value of the area.
+ *
+ * @param string The area.
+ */
+ public void setArea(String string) {
+ area = string;
+ }
+
+ /**
+ * Set the value of the document id.
+ *
+ * @param string The document id.
+ */
+ public void setDocumentid(String string) {
+ documentid = string;
+ }
+
+ /**
+ * Set the value of the language.
+ *
+ * @param string The language.
+ */
+ public void setLanguage(String string) {
+ language = string;
+ }
-}
+}
\ No newline at end of file
Modified: incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/DeleteContentTask.java
==============================================================================
--- incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/DeleteContentTask.java (original)
+++ incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/DeleteContentTask.java Mon Sep 13 03:04:48 2004
@@ -15,7 +15,7 @@
*
*/
-/* $Id: DeleteContentTask.java,v 1.8 2004/03/03 12:56:30 gregor Exp $ */
+/* $Id$ */
package org.apache.lenya.cms.ant;
@@ -26,10 +26,10 @@
import org.apache.lenya.cms.publication.Document;
import org.apache.lenya.cms.publication.DocumentBuildException;
import org.apache.lenya.cms.publication.DocumentBuilder;
-import org.apache.lenya.cms.publication.Label;
import org.apache.lenya.cms.publication.Publication;
-import org.apache.lenya.cms.publication.SiteTree;
-import org.apache.lenya.cms.publication.SiteTreeNode;
+import org.apache.lenya.cms.site.tree.Label;
+import org.apache.lenya.cms.site.tree.SiteTree;
+import org.apache.lenya.cms.site.tree.SiteTreeNode;
import org.apache.tools.ant.BuildException;
/**
@@ -46,7 +46,7 @@
}
/** (non-Javadoc)
- * @see org.apache.lenya.cms.publication.SiteTreeNodeVisitor#visitSiteTreeNode(org.apache.lenya.cms.publication.SiteTreeNode)
+ * @see org.apache.lenya.cms.site.tree.SiteTreeNodeVisitor#visitSiteTreeNode(org.apache.lenya.cms.publication.SiteTreeNode)
*/
public void visitSiteTreeNode(SiteTreeNode node) {
Publication publication = getPublication();
Modified: incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/DeleteLanguageNodeTask.java
==============================================================================
--- incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/DeleteLanguageNodeTask.java (original)
+++ incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/DeleteLanguageNodeTask.java Mon Sep 13 03:04:48 2004
@@ -15,14 +15,14 @@
*
*/
-/* $Id: DeleteLanguageNodeTask.java,v 1.2 2004/03/03 12:56:30 gregor Exp $ */
+/* $Id$ */
package org.apache.lenya.cms.ant;
-import org.apache.lenya.cms.publication.DefaultSiteTree;
-import org.apache.lenya.cms.publication.Label;
-import org.apache.lenya.cms.publication.SiteTreeException;
-import org.apache.lenya.cms.publication.SiteTreeNode;
+import org.apache.lenya.cms.site.SiteException;
+import org.apache.lenya.cms.site.tree.DefaultSiteTree;
+import org.apache.lenya.cms.site.tree.Label;
+import org.apache.lenya.cms.site.tree.SiteTreeNode;
import org.apache.tools.ant.BuildException;
/**
@@ -49,10 +49,10 @@
* @param documentid The id of the document.
* @param area The area of the document.
*
- * @throws SiteTreeException if an error occurs
+ * @throws SiteException if an error occurs
*/
public void deleteLanguageNode(String language, String documentid, String area)
- throws SiteTreeException {
+ throws SiteException {
DefaultSiteTree tree = null;
try {
@@ -66,7 +66,7 @@
tree.save();
}
} catch (Exception e) {
- throw new SiteTreeException(e);
+ throw new SiteException(e);
}
}
/** (non-Javadoc)
Modified: incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/DeleteNodeTask.java
==============================================================================
--- incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/DeleteNodeTask.java (original)
+++ incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/DeleteNodeTask.java Mon Sep 13 03:04:48 2004
@@ -15,13 +15,13 @@
*
*/
-/* $Id: DeleteNodeTask.java,v 1.4 2004/03/03 12:56:30 gregor Exp $ */
+/* $Id$ */
package org.apache.lenya.cms.ant;
-import org.apache.lenya.cms.publication.DefaultSiteTree;
-import org.apache.lenya.cms.publication.SiteTreeException;
-import org.apache.lenya.cms.publication.SiteTreeNode;
+import org.apache.lenya.cms.site.SiteException;
+import org.apache.lenya.cms.site.tree.DefaultSiteTree;
+import org.apache.lenya.cms.site.tree.SiteTreeNode;
import org.apache.tools.ant.BuildException;
@@ -80,21 +80,21 @@
* @param documentid The id of the document corresponding to the node to delete.
* @param area the areaof the tree
*
- * @throws SiteTreeException if an error occurs
+ * @throws SiteException if an error occurs
*/
public void deleteNode(String documentid, String area)
- throws SiteTreeException {
+ throws SiteException {
DefaultSiteTree tree = null;
try {
tree = getPublication().getSiteTree(area);
SiteTreeNode node = tree.removeNode(documentid);
if (node == null) {
- throw new SiteTreeException("Node " + node + " couldn't be removed");
+ throw new SiteException("Node " + node + " couldn't be removed");
}
tree.save();
} catch (Exception e) {
- throw new SiteTreeException(e);
+ throw new SiteException(e);
}
}
/** (non-Javadoc)
Modified: incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/DeletePoliciesTask.java
==============================================================================
--- incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/DeletePoliciesTask.java (original)
+++ incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/DeletePoliciesTask.java Mon Sep 13 03:04:48 2004
@@ -15,7 +15,7 @@
*
*/
-/* $Id: DeletePoliciesTask.java,v 1.4 2004/03/03 12:56:30 gregor Exp $ */
+/* $Id$ */
package org.apache.lenya.cms.ant;
@@ -25,8 +25,8 @@
import org.apache.avalon.excalibur.io.FileUtil;
import org.apache.lenya.cms.publication.Publication;
-import org.apache.lenya.cms.publication.SiteTree;
-import org.apache.lenya.cms.publication.SiteTreeNode;
+import org.apache.lenya.cms.site.tree.SiteTree;
+import org.apache.lenya.cms.site.tree.SiteTreeNode;
import org.apache.tools.ant.BuildException;
/**
Modified: incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/DeleteRCTask.java
==============================================================================
--- incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/DeleteRCTask.java (original)
+++ incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/DeleteRCTask.java Mon Sep 13 03:04:48 2004
@@ -15,7 +15,7 @@
*
*/
-/* $Id: DeleteRCTask.java,v 1.5 2004/03/03 12:56:30 gregor Exp $ */
+/* $Id$ */
package org.apache.lenya.cms.ant;
@@ -24,8 +24,8 @@
import org.apache.avalon.excalibur.io.FileUtil;
import org.apache.lenya.cms.publication.Publication;
-import org.apache.lenya.cms.publication.SiteTree;
-import org.apache.lenya.cms.publication.SiteTreeNode;
+import org.apache.lenya.cms.site.tree.SiteTree;
+import org.apache.lenya.cms.site.tree.SiteTreeNode;
import org.apache.tools.ant.BuildException;
/**
@@ -45,7 +45,7 @@
}
/** (non-Javadoc)
- * @see org.apache.lenya.cms.publication.SiteTreeNodeVisitor#visitSiteTreeNode(org.apache.lenya.cms.publication.SiteTreeNode)
+ * @see org.apache.lenya.cms.site.tree.SiteTreeNodeVisitor#visitSiteTreeNode(org.apache.lenya.cms.publication.SiteTreeNode)
*/
public void visitSiteTreeNode(SiteTreeNode node) {
String publicationPath;
Modified: incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/DeleteResourcesTask.java
==============================================================================
--- incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/DeleteResourcesTask.java (original)
+++ incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/DeleteResourcesTask.java Mon Sep 13 03:04:48 2004
@@ -15,18 +15,18 @@
*
*/
-/* $Id: DeleteResourcesTask.java,v 1.3 2004/03/03 12:56:30 gregor Exp $ */
+/* $Id$ */
package org.apache.lenya.cms.ant;
import org.apache.lenya.cms.publication.Document;
import org.apache.lenya.cms.publication.DocumentBuildException;
import org.apache.lenya.cms.publication.DocumentBuilder;
-import org.apache.lenya.cms.publication.Label;
import org.apache.lenya.cms.publication.Publication;
import org.apache.lenya.cms.publication.ResourcesManager;
-import org.apache.lenya.cms.publication.SiteTree;
-import org.apache.lenya.cms.publication.SiteTreeNode;
+import org.apache.lenya.cms.site.tree.Label;
+import org.apache.lenya.cms.site.tree.SiteTree;
+import org.apache.lenya.cms.site.tree.SiteTreeNode;
import org.apache.tools.ant.BuildException;
/**
@@ -45,7 +45,7 @@
/**
* Delete the resources of the documents corresponding to this node
*
- * @see org.apache.lenya.cms.publication.SiteTreeNodeVisitor#visitSiteTreeNode(org.apache.lenya.cms.publication.SiteTreeNode)
+ * @see org.apache.lenya.cms.site.tree.SiteTreeNodeVisitor#visitSiteTreeNode(org.apache.lenya.cms.publication.SiteTreeNode)
*/
public void visitSiteTreeNode(SiteTreeNode node) {
Publication publication = getPublication();
Modified: incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/DeleteSchedulerEntryTask.java
==============================================================================
--- incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/DeleteSchedulerEntryTask.java (original)
+++ incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/DeleteSchedulerEntryTask.java Mon Sep 13 03:04:48 2004
@@ -15,7 +15,7 @@
*
*/
-/* $Id: DeleteSchedulerEntryTask.java,v 1.2 2004/03/03 12:56:30 gregor Exp $ */
+/* $Id$ */
package org.apache.lenya.cms.ant;
@@ -24,12 +24,12 @@
import org.apache.lenya.cms.publication.Document;
import org.apache.lenya.cms.publication.DocumentBuilder;
import org.apache.lenya.cms.publication.DocumentException;
-import org.apache.lenya.cms.publication.Label;
import org.apache.lenya.cms.publication.Publication;
-import org.apache.lenya.cms.publication.SiteTree;
-import org.apache.lenya.cms.publication.SiteTreeNode;
-import org.apache.lenya.cms.publication.SiteTreeNodeVisitor;
import org.apache.lenya.cms.scheduler.LoadQuartzServlet;
+import org.apache.lenya.cms.site.tree.Label;
+import org.apache.lenya.cms.site.tree.SiteTree;
+import org.apache.lenya.cms.site.tree.SiteTreeNode;
+import org.apache.lenya.cms.site.tree.SiteTreeNodeVisitor;
import org.apache.tools.ant.BuildException;
/**
@@ -80,7 +80,7 @@
}
/**
- * @see org.apache.lenya.cms.publication.SiteTreeNodeVisitor#visitSiteTreeNode(org.apache.lenya.cms.publication.SiteTreeNode)
+ * @see org.apache.lenya.cms.site.tree.SiteTreeNodeVisitor#visitSiteTreeNode(org.apache.lenya.cms.publication.SiteTreeNode)
*/
public void visitSiteTreeNode(SiteTreeNode node) throws DocumentException {
Publication publication = getPublication();
Modified: incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/DocumentOperationTask.java
==============================================================================
--- incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/DocumentOperationTask.java (original)
+++ incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/DocumentOperationTask.java Mon Sep 13 03:04:48 2004
@@ -15,14 +15,14 @@
*
*/
-/* $Id: DocumentOperationTask.java,v 1.3 2004/03/03 12:56:30 gregor Exp $ */
+/* $Id$ */
package org.apache.lenya.cms.ant;
import org.apache.lenya.cms.publication.Publication;
-import org.apache.lenya.cms.publication.SiteTree;
-import org.apache.lenya.cms.publication.SiteTreeNode;
-import org.apache.lenya.cms.publication.SiteTreeNodeVisitor;
+import org.apache.lenya.cms.site.tree.SiteTree;
+import org.apache.lenya.cms.site.tree.SiteTreeNode;
+import org.apache.lenya.cms.site.tree.SiteTreeNodeVisitor;
import org.apache.tools.ant.BuildException;
/**
@@ -73,7 +73,7 @@
/**
* To be overriden.
- * @see org.apache.lenya.cms.publication.SiteTreeNodeVisitor#visitSiteTreeNode(org.apache.lenya.cms.publication.SiteTreeNode)
+ * @see org.apache.lenya.cms.site.tree.SiteTreeNodeVisitor#visitSiteTreeNode(org.apache.lenya.cms.publication.SiteTreeNode)
*/
public abstract void visitSiteTreeNode(SiteTreeNode node);
Modified: incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/InitCopyWorkflowTask.java
==============================================================================
--- incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/InitCopyWorkflowTask.java (original)
+++ incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/InitCopyWorkflowTask.java Mon Sep 13 03:04:48 2004
@@ -15,16 +15,16 @@
*
*/
-/* $Id: InitCopyWorkflowTask.java,v 1.5 2004/03/03 12:56:30 gregor Exp $ */
+/* $Id$ */
package org.apache.lenya.cms.ant;
import org.apache.lenya.cms.publication.Document;
import org.apache.lenya.cms.publication.DocumentBuildException;
import org.apache.lenya.cms.publication.DocumentBuilder;
-import org.apache.lenya.cms.publication.Label;
import org.apache.lenya.cms.publication.Publication;
-import org.apache.lenya.cms.publication.SiteTreeNode;
+import org.apache.lenya.cms.site.tree.Label;
+import org.apache.lenya.cms.site.tree.SiteTreeNode;
import org.apache.lenya.cms.workflow.WorkflowFactory;
import org.apache.lenya.workflow.Situation;
import org.apache.lenya.workflow.WorkflowException;
@@ -81,7 +81,7 @@
}
/** (non-Javadoc)
- * @see org.apache.lenya.cms.publication.SiteTreeNodeVisitor#visitSiteTreeNode(org.apache.lenya.cms.publication.SiteTreeNode)
+ * @see org.apache.lenya.cms.site.tree.SiteTreeNodeVisitor#visitSiteTreeNode(org.apache.lenya.cms.publication.SiteTreeNode)
*/
public void visitSiteTreeNode(SiteTreeNode node) {
Publication publication = getPublication();
Modified: incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/InitRCTask.java
==============================================================================
--- incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/InitRCTask.java (original)
+++ incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/InitRCTask.java Mon Sep 13 03:04:48 2004
@@ -15,7 +15,7 @@
*
*/
-/* $Id: InitRCTask.java,v 1.3 2004/03/03 12:56:30 gregor Exp $ */
+/* $Id$ */
package org.apache.lenya.cms.ant;
@@ -24,10 +24,10 @@
import org.apache.lenya.cms.publication.Document;
import org.apache.lenya.cms.publication.DocumentBuilder;
-import org.apache.lenya.cms.publication.Label;
import org.apache.lenya.cms.publication.Publication;
-import org.apache.lenya.cms.publication.SiteTreeNode;
import org.apache.lenya.cms.rc.RevisionController;
+import org.apache.lenya.cms.site.tree.Label;
+import org.apache.lenya.cms.site.tree.SiteTreeNode;
import org.apache.tools.ant.BuildException;
/**
@@ -76,7 +76,7 @@
}
/**
- * @see org.apache.lenya.cms.publication.SiteTreeNodeVisitor#visitSiteTreeNode(org.apache.lenya.cms.publication.SiteTreeNode)
+ * @see org.apache.lenya.cms.site.tree.SiteTreeNodeVisitor#visitSiteTreeNode(org.apache.lenya.cms.publication.SiteTreeNode)
*/
public void visitSiteTreeNode(SiteTreeNode node) {
try {
Modified: incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/InsertCopyNode.java
==============================================================================
--- incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/InsertCopyNode.java (original)
+++ incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/InsertCopyNode.java Mon Sep 13 03:04:48 2004
@@ -15,77 +15,71 @@
*
*/
-/* $Id: InsertCopyNode.java,v 1.10 2004/03/03 12:56:30 gregor Exp $ */
+/* $Id$ */
package org.apache.lenya.cms.ant;
import java.util.StringTokenizer;
import org.apache.lenya.cms.publication.Publication;
-import org.apache.lenya.cms.publication.SiteTree;
-import org.apache.lenya.cms.publication.SiteTreeException;
-import org.apache.lenya.cms.publication.SiteTreeNode;
+import org.apache.lenya.cms.site.SiteException;
+import org.apache.lenya.cms.site.tree.SiteTree;
+import org.apache.lenya.cms.site.tree.SiteTreeNode;
/**
- * Ant task that copies a node of a tree and inserts it in tree
- **/
+ * Ant task that copies a node of a tree and inserts it in tree
+ */
public class InsertCopyNode extends TwoNodesTask {
- /**
- * Creates a new instance of InsertCopyNode
- */
- public InsertCopyNode() {
- super();
- }
-
- /**
- * copies a node corresponding to a document with id firstdocumentid and area firstarea
- * and inserts it like a node corresponding to a document with id secdocumentid and area secarea.
- * @param firstdocumentid The document-id of the document corresponding to the source node.
- * @param secdocumentid The document-id of the document corresponding to the destination node.
- * @param firstarea The area of the document corresponding to the source node.
- * @param secarea The area of the document corresponding to the destination node.
- * @throws SiteTreeException if there are problems with creating or saving the site tree.
- */
- public void manipulateTree(
- String firstdocumentid,
- String secdocumentid,
- String firstarea,
- String secarea)
- throws SiteTreeException {
-
- Publication publication = getPublication();
- SiteTree firsttree = publication.getSiteTree(firstarea);
- SiteTree sectree = publication.getSiteTree(secarea);
-
- String parentid = "";
- StringTokenizer st = new StringTokenizer(secdocumentid, "/");
- int length = st.countTokens();
-
- for (int i = 0; i < (length - 1); i++) {
- parentid = parentid + "/" + st.nextToken();
- }
- String newid = st.nextToken();
-
- SiteTreeNode node = firsttree.getNode(firstdocumentid);
-
- if (node != null) {
- SiteTreeNode parentNode = sectree.getNode(parentid);
- if (parentNode != null) {
- sectree.importSubtree(parentNode, node, newid, null);
- } else {
- throw new SiteTreeException(
- "The parent node "
- + parentNode
- + " where the copied node shall be inserted not found");
- }
- } else {
- throw new SiteTreeException("Node " + node + " couldn't be found");
- }
- if (firstarea.equals(secarea)) {
- firsttree.save();
- } else {
- firsttree.save();
- sectree.save();
- }
- }
-}
+ /**
+ * Creates a new instance of InsertCopyNode
+ */
+ public InsertCopyNode() {
+ super();
+ }
+
+ /**
+ * copies a node corresponding to a document with id firstdocumentid and area firstarea and
+ * inserts it like a node corresponding to a document with id secdocumentid and area secarea.
+ * @param firstdocumentid The document-id of the document corresponding to the source node.
+ * @param secdocumentid The document-id of the document corresponding to the destination node.
+ * @param firstarea The area of the document corresponding to the source node.
+ * @param secarea The area of the document corresponding to the destination node.
+ * @throws SiteException if there are problems with creating or saving the site tree.
+ */
+ public void manipulateTree(String firstdocumentid, String secdocumentid, String firstarea,
+ String secarea) throws SiteException {
+
+ Publication publication = getPublication();
+ SiteTree firsttree = publication.getSiteTree(firstarea);
+ SiteTree sectree = publication.getSiteTree(secarea);
+
+ String parentid = "";
+ StringTokenizer st = new StringTokenizer(secdocumentid, "/");
+ int length = st.countTokens();
+
+ for (int i = 0; i < (length - 1); i++) {
+ parentid = parentid + "/" + st.nextToken();
+ }
+ String newid = st.nextToken();
+
+ SiteTreeNode node = firsttree.getNode(firstdocumentid);
+
+ if (node != null) {
+ SiteTreeNode parentNode = sectree.getNode(parentid);
+ if (parentNode != null) {
+ sectree.importSubtree(parentNode, node, newid, null);
+ } else {
+ throw new SiteException("The parent node " + parentNode
+ + " where the copied node shall be inserted not found");
+ }
+ } else {
+ throw new SiteException("Node " + node + " couldn't be found");
+ }
+ if (firstarea.equals(secarea)) {
+ firsttree.save();
+ } else {
+ firsttree.save();
+ sectree.save();
+ }
+ }
+}
\ No newline at end of file
Modified: incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/InsertLabelTask.java
==============================================================================
--- incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/InsertLabelTask.java (original)
+++ incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/InsertLabelTask.java Mon Sep 13 03:04:48 2004
@@ -15,13 +15,13 @@
*
*/
-/* $Id: InsertLabelTask.java,v 1.4 2004/03/03 12:56:30 gregor Exp $ */
+/* $Id$ */
package org.apache.lenya.cms.ant;
-import org.apache.lenya.cms.publication.DefaultSiteTree;
-import org.apache.lenya.cms.publication.Label;
-import org.apache.lenya.cms.publication.SiteTreeException;
+import org.apache.lenya.cms.site.SiteException;
+import org.apache.lenya.cms.site.tree.DefaultSiteTree;
+import org.apache.lenya.cms.site.tree.Label;
import org.apache.tools.ant.BuildException;
/**
@@ -43,7 +43,7 @@
/**
* Get the area of the site tree.
*
- * @return the area of the tree.
+ * @return the area of the tree.
*/
protected String getArea() {
return area;
@@ -120,14 +120,10 @@
* @param language the language of the label that is to be inserted.
* @param area determines in which sitetree the label is to be inserted
*
- * @throws SiteTreeException if an error occurs
+ * @throws SiteException if an error occurs
*/
- public void insertLabel(
- String documentid,
- String labelName,
- String language,
- String area)
- throws SiteTreeException {
+ public void insertLabel(String documentid, String labelName, String language, String area)
+ throws SiteException {
DefaultSiteTree tree = null;
Label label = null;
@@ -137,17 +133,13 @@
tree.addLabel(documentid, label);
tree.save();
} catch (Exception e) {
- throw new SiteTreeException(
- "Cannot insert label "
- + label
- + " into tree "
- + area,
- e);
+ throw new SiteException("Cannot insert label " + label + " into tree " + area, e);
}
}
- /** (non-Javadoc)
+ /**
+ * (non-Javadoc)
* @see org.apache.tools.ant.Task#execute()
*/
public void execute() throws BuildException {
@@ -156,13 +148,9 @@
log("label name: " + getLabelName());
log("language: " + getLanguage());
log("area: " + getArea());
- insertLabel(
- getDocumentid(),
- getLabelName(),
- getLanguage(),
- getArea());
+ insertLabel(getDocumentid(), getLabelName(), getLanguage(), getArea());
} catch (Exception e) {
throw new BuildException(e);
}
}
-}
+}
\ No newline at end of file
Modified: incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/MoveDocumentTask.java
==============================================================================
--- incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/MoveDocumentTask.java (original)
+++ incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/MoveDocumentTask.java Mon Sep 13 03:04:48 2004
@@ -15,18 +15,18 @@
*
*/
-/* $Id: MoveDocumentTask.java,v 1.6 2004/03/03 12:56:30 gregor Exp $ */
+/* $Id$ */
package org.apache.lenya.cms.ant;
import org.apache.lenya.cms.publication.Document;
import org.apache.lenya.cms.publication.DocumentBuildException;
import org.apache.lenya.cms.publication.DocumentBuilder;
-import org.apache.lenya.cms.publication.Label;
import org.apache.lenya.cms.publication.Publication;
-import org.apache.lenya.cms.publication.SiteTree;
-import org.apache.lenya.cms.publication.SiteTreeNode;
-import org.apache.lenya.cms.publication.SiteTreeNodeVisitor;
+import org.apache.lenya.cms.site.tree.Label;
+import org.apache.lenya.cms.site.tree.SiteTree;
+import org.apache.lenya.cms.site.tree.SiteTreeNode;
+import org.apache.lenya.cms.site.tree.SiteTreeNodeVisitor;
import org.apache.lenya.cms.workflow.WorkflowFactory;
import org.apache.lenya.workflow.WorkflowException;
import org.apache.tools.ant.BuildException;
@@ -112,7 +112,7 @@
/**
* move the workflow files
*
- * @see org.apache.lenya.cms.publication.SiteTreeNodeVisitor#visitSiteTreeNode(org.apache.lenya.cms.publication.SiteTreeNode)
+ * @see org.apache.lenya.cms.site.tree.SiteTreeNodeVisitor#visitSiteTreeNode(org.apache.lenya.cms.publication.SiteTreeNode)
*/
public void visitSiteTreeNode(SiteTreeNode node) {
Publication publication = getPublication();
Modified: incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/MoveNode.java
==============================================================================
--- incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/MoveNode.java (original)
+++ incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/MoveNode.java Mon Sep 13 03:04:48 2004
@@ -15,95 +15,90 @@
*
*/
-/* $Id: MoveNode.java,v 1.9 2004/03/03 12:56:30 gregor Exp $ */
+/* $Id$ */
package org.apache.lenya.cms.ant;
import java.util.StringTokenizer;
import org.apache.lenya.cms.publication.Publication;
-import org.apache.lenya.cms.publication.SiteTree;
-import org.apache.lenya.cms.publication.SiteTreeException;
-import org.apache.lenya.cms.publication.SiteTreeNode;
+import org.apache.lenya.cms.site.SiteException;
+import org.apache.lenya.cms.site.tree.SiteTree;
+import org.apache.lenya.cms.site.tree.SiteTreeNode;
/**
* Ant task that moves a node in a tree.
*/
public class MoveNode extends TwoNodesTask {
- private String refdocumentid;
- /**
- *
- */
- public MoveNode() {
- super();
- }
-
- /**
- * Move a node.
- *
- * @param firstdocumentid The document-id of the document corresponding to the source node.
- * @param secdocumentid The document-id of the document corresponding to the destination node.
- * @param firstarea The area of the document corresponding to the source node.
- * @param secarea The area of the document corresponding to the destination node.
- * @throws SiteTreeException if there are problems with creating or saving the site tree.
- */
- public void manipulateTree(
- String firstdocumentid,
- String secdocumentid,
- String firstarea,
- String secarea)
- throws SiteTreeException {
-
- Publication publication = getPublication();
- SiteTree firsttree = publication.getSiteTree(firstarea);
- SiteTree sectree = publication.getSiteTree(secarea);
-
- String parentid = "";
- StringTokenizer st = new StringTokenizer(secdocumentid, "/");
- int length = st.countTokens();
-
- for (int i = 0; i < (length - 1); i++) {
- parentid = parentid + "/" + st.nextToken();
- }
- String newid = st.nextToken();
-
- SiteTreeNode node = firsttree.removeNode(firstdocumentid);
- if (node != null) {
- SiteTreeNode parentNode = sectree.getNode(parentid);
- if (parentNode != null) {
- sectree.importSubtree(parentNode, node, newid, this.getRefdocumentid());
- } else {
- throw new SiteTreeException(
- "The parent node "
- + parentNode
- + " where the removed node shall be inserted not found");
- }
- } else {
- throw new SiteTreeException(
- "Node " + node + " couldn't be removed");
- }
-
- if (firstarea.equals(secarea)) {
- firsttree.save();
- } else {
- firsttree.save();
- sectree.save();
- }
- }
- /**
- * @return string The document-id corresponding to the reference node, before which
- * the moved node shoul be inserted. If null, the node is inserted at the end.
- */
- public String getRefdocumentid() {
- return refdocumentid;
- }
-
- /**
- * @param string The document-id corresponding to the reference node, before which
- * the moved node shoul be inserted. If null, the node is inserted at the end.
- */
- public void setRefdocumentid(String string) {
- refdocumentid = string;
- }
+ private String refdocumentid;
-}
+ /**
+ *
+ */
+ public MoveNode() {
+ super();
+ }
+
+ /**
+ * Move a node.
+ *
+ * @param firstdocumentid The document-id of the document corresponding to the source node.
+ * @param secdocumentid The document-id of the document corresponding to the destination node.
+ * @param firstarea The area of the document corresponding to the source node.
+ * @param secarea The area of the document corresponding to the destination node.
+ * @throws SiteException if there are problems with creating or saving the site tree.
+ */
+ public void manipulateTree(String firstdocumentid, String secdocumentid, String firstarea,
+ String secarea) throws SiteException {
+
+ Publication publication = getPublication();
+ SiteTree firsttree = publication.getSiteTree(firstarea);
+ SiteTree sectree = publication.getSiteTree(secarea);
+
+ String parentid = "";
+ StringTokenizer st = new StringTokenizer(secdocumentid, "/");
+ int length = st.countTokens();
+
+ for (int i = 0; i < (length - 1); i++) {
+ parentid = parentid + "/" + st.nextToken();
+ }
+ String newid = st.nextToken();
+
+ SiteTreeNode node = firsttree.removeNode(firstdocumentid);
+ if (node != null) {
+ SiteTreeNode parentNode = sectree.getNode(parentid);
+ if (parentNode != null) {
+ sectree.importSubtree(parentNode, node, newid, this.getRefdocumentid());
+ } else {
+ throw new SiteException("The parent node " + parentNode
+ + " where the removed node shall be inserted not found");
+ }
+ } else {
+ throw new SiteException("Node " + node + " couldn't be removed");
+ }
+
+ if (firstarea.equals(secarea)) {
+ firsttree.save();
+ } else {
+ firsttree.save();
+ sectree.save();
+ }
+ }
+
+ /**
+ * @return string The document-id corresponding to the reference node, before which the moved
+ * node shoul be inserted. If null, the node is inserted at the end.
+ */
+ public String getRefdocumentid() {
+ return refdocumentid;
+ }
+
+ /**
+ * @param string The document-id corresponding to the reference node, before which the moved
+ * node shoul be inserted. If null, the node is inserted at the end.
+ */
+ public void setRefdocumentid(String string) {
+ refdocumentid = string;
+ }
+
+}
\ No newline at end of file
Modified: incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/MoveSiteTreeNodeTask.java
==============================================================================
--- incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/MoveSiteTreeNodeTask.java (original)
+++ incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/MoveSiteTreeNodeTask.java Mon Sep 13 03:04:48 2004
@@ -15,12 +15,12 @@
*
*/
-/* $Id: MoveSiteTreeNodeTask.java,v 1.2 2004/03/03 12:56:30 gregor Exp $ */
+/* $Id$ */
package org.apache.lenya.cms.ant;
-import org.apache.lenya.cms.publication.DefaultSiteTree;
import org.apache.lenya.cms.publication.Publication;
+import org.apache.lenya.cms.site.tree.DefaultSiteTree;
import org.apache.tools.ant.BuildException;
/**
Modified: incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/MoveWorkflowTask.java
==============================================================================
--- incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/MoveWorkflowTask.java (original)
+++ incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/MoveWorkflowTask.java Mon Sep 13 03:04:48 2004
@@ -15,16 +15,16 @@
*
*/
-/* $Id: MoveWorkflowTask.java,v 1.5 2004/03/03 12:56:30 gregor Exp $ */
+/* $Id$ */
package org.apache.lenya.cms.ant;
import org.apache.lenya.cms.publication.Document;
import org.apache.lenya.cms.publication.DocumentBuildException;
import org.apache.lenya.cms.publication.DocumentBuilder;
-import org.apache.lenya.cms.publication.Label;
import org.apache.lenya.cms.publication.Publication;
-import org.apache.lenya.cms.publication.SiteTreeNode;
+import org.apache.lenya.cms.site.tree.Label;
+import org.apache.lenya.cms.site.tree.SiteTreeNode;
import org.apache.lenya.cms.workflow.WorkflowFactory;
import org.apache.lenya.workflow.WorkflowException;
import org.apache.tools.ant.BuildException;
@@ -44,7 +44,7 @@
}
/** (non-Javadoc)
- * @see org.apache.lenya.cms.publication.SiteTreeNodeVisitor#visitSiteTreeNode(org.apache.lenya.cms.publication.SiteTreeNode)
+ * @see org.apache.lenya.cms.site.tree.SiteTreeNodeVisitor#visitSiteTreeNode(org.apache.lenya.cms.publication.SiteTreeNode)
*/
public void visitSiteTreeNode(SiteTreeNode node) {
Publication publication = getPublication();
Modified: incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/RemoveLabelTask.java
==============================================================================
--- incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/RemoveLabelTask.java (original)
+++ incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/RemoveLabelTask.java Mon Sep 13 03:04:48 2004
@@ -15,14 +15,14 @@
*
*/
-/* $Id: RemoveLabelTask.java,v 1.3 2004/03/03 12:56:30 gregor Exp $ */
+/* $Id$ */
package org.apache.lenya.cms.ant;
-import org.apache.lenya.cms.publication.DefaultSiteTree;
-import org.apache.lenya.cms.publication.Label;
-import org.apache.lenya.cms.publication.SiteTreeException;
-import org.apache.lenya.cms.publication.SiteTreeNode;
+import org.apache.lenya.cms.site.SiteException;
+import org.apache.lenya.cms.site.tree.DefaultSiteTree;
+import org.apache.lenya.cms.site.tree.Label;
+import org.apache.lenya.cms.site.tree.SiteTreeNode;
import org.apache.tools.ant.BuildException;
/**
@@ -44,7 +44,7 @@
/**
* Get the area of the site tree.
*
- * @return the area of the tree.
+ * @return the area of the tree.
*/
protected String getArea() {
return area;
@@ -123,22 +123,18 @@
}
/**
- * Remove a label in an existing node in the tree.
- * If this happens to be the last label it is not removed.
+ * Remove a label in an existing node in the tree. If this happens to be the last label it is
+ * not removed.
*
* @param documentid the document-id of the document.
* @param labelName the name of the label that is to be inserted.
* @param language the language of the label that is to be inserted.
* @param area determines in which sitetree the label is to be inserted
*
- * @throws SiteTreeException if an error occurs.
+ * @throws SiteException if an error occurs.
*/
- public void removeLabel(
- String documentid,
- String labelName,
- String language,
- String area)
- throws SiteTreeException {
+ public void removeLabel(String documentid, String labelName, String language, String area)
+ throws SiteException {
DefaultSiteTree tree = null;
Label label = null;
@@ -155,14 +151,13 @@
}
} catch (Exception e) {
- throw new SiteTreeException(
- "Cannot remove label " + label + " from tree " + area,
- e);
+ throw new SiteException("Cannot remove label " + label + " from tree " + area, e);
}
}
- /** (non-Javadoc)
+ /**
+ * (non-Javadoc)
* @see org.apache.tools.ant.Task#execute()
*/
public void execute() throws BuildException {
@@ -171,13 +166,9 @@
log("label name: " + getLabelName());
log("language: " + getLanguage());
log("area: " + getArea());
- removeLabel(
- getDocumentid(),
- getLabelName(),
- getLanguage(),
- getArea());
+ removeLabel(getDocumentid(), getLabelName(), getLanguage(), getArea());
} catch (Exception e) {
throw new BuildException(e);
}
}
-}
+}
\ No newline at end of file
Modified: incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/RenameLabelTask.java
==============================================================================
--- incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/RenameLabelTask.java (original)
+++ incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/RenameLabelTask.java Mon Sep 13 03:04:48 2004
@@ -15,15 +15,15 @@
*
*/
-/* $Id: RenameLabelTask.java,v 1.3 2004/03/03 12:56:30 gregor Exp $ */
+/* $Id$ */
package org.apache.lenya.cms.ant;
-import org.apache.lenya.cms.publication.DefaultSiteTree;
import org.apache.lenya.cms.publication.DocumentException;
-import org.apache.lenya.cms.publication.Label;
-import org.apache.lenya.cms.publication.SiteTreeException;
-import org.apache.lenya.cms.publication.SiteTreeNode;
+import org.apache.lenya.cms.site.SiteException;
+import org.apache.lenya.cms.site.tree.DefaultSiteTree;
+import org.apache.lenya.cms.site.tree.Label;
+import org.apache.lenya.cms.site.tree.SiteTreeNode;
import org.apache.tools.ant.BuildException;
/**
@@ -131,14 +131,15 @@
* @param language the language of the label that is to be renamed.
* @param area determines in which sitetree the label is to be renamed
*
- * @throws SiteTreeException if an error occurs.
+ * @throws SiteException if an error occurs.
+ * @throws DocumentException if an error occurs.
*/
public void renameLabel(
String documentid,
String labelName,
String language,
String area)
- throws SiteTreeException, DocumentException {
+ throws SiteException, DocumentException {
DefaultSiteTree tree = null;
tree = getPublication().getSiteTree(area);
Modified: incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/SetIdentifier.java
==============================================================================
--- incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/SetIdentifier.java (original)
+++ incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/SetIdentifier.java Mon Sep 13 03:04:48 2004
@@ -15,7 +15,7 @@
*
*/
-/* $Id: SetIdentifier.java,v 1.6 2004/03/03 12:56:30 gregor Exp $ */
+/* $Id$ */
package org.apache.lenya.cms.ant;
@@ -24,11 +24,11 @@
import org.apache.lenya.cms.publication.DocumentBuilder;
import org.apache.lenya.cms.publication.DocumentException;
import org.apache.lenya.cms.publication.DublinCore;
-import org.apache.lenya.cms.publication.Label;
import org.apache.lenya.cms.publication.Publication;
-import org.apache.lenya.cms.publication.SiteTree;
-import org.apache.lenya.cms.publication.SiteTreeException;
-import org.apache.lenya.cms.publication.SiteTreeNode;
+import org.apache.lenya.cms.site.SiteException;
+import org.apache.lenya.cms.site.tree.Label;
+import org.apache.lenya.cms.site.tree.SiteTree;
+import org.apache.lenya.cms.site.tree.SiteTreeNode;
import org.apache.tools.ant.BuildException;
/**
@@ -115,7 +115,7 @@
try {
tree = publication.getSiteTree(area);
- } catch (SiteTreeException e) {
+ } catch (SiteException e) {
throw new BuildException(e);
}
SiteTreeNode node = tree.getNode(documentid);
Modified: incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/SiteTreeResetTask.java
==============================================================================
--- incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/SiteTreeResetTask.java (original)
+++ incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/SiteTreeResetTask.java Mon Sep 13 03:04:48 2004
@@ -15,13 +15,13 @@
*
*/
-/* $Id: SiteTreeResetTask.java,v 1.2 2004/03/03 12:56:30 gregor Exp $ */
+/* $Id$ */
package org.apache.lenya.cms.ant;
import org.apache.lenya.cms.publication.Publication;
-import org.apache.lenya.cms.publication.SiteTree;
-import org.apache.lenya.cms.publication.SiteTreeNode;
+import org.apache.lenya.cms.site.tree.SiteTree;
+import org.apache.lenya.cms.site.tree.SiteTreeNode;
import org.apache.tools.ant.BuildException;
/**
Modified: incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/TreePublisher.java
==============================================================================
--- incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/TreePublisher.java (original)
+++ incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/TreePublisher.java Mon Sep 13 03:04:48 2004
@@ -15,17 +15,17 @@
*
*/
-/* $Id: TreePublisher.java,v 1.14 2004/08/16 12:06:45 andreas Exp $ */
+/* $Id$ */
package org.apache.lenya.cms.ant;
-import org.apache.lenya.cms.publication.Label;
import org.apache.lenya.cms.publication.Publication;
-import org.apache.lenya.cms.publication.SiteTree;
-import org.apache.lenya.cms.publication.SiteTreeException;
-import org.apache.lenya.cms.publication.SiteTreeNode;
import org.apache.lenya.cms.publishing.ParentNodeNotFoundException;
import org.apache.lenya.cms.publishing.PublishingException;
+import org.apache.lenya.cms.site.SiteException;
+import org.apache.lenya.cms.site.tree.Label;
+import org.apache.lenya.cms.site.tree.SiteTree;
+import org.apache.lenya.cms.site.tree.SiteTreeNode;
import org.apache.tools.ant.BuildException;
/**
@@ -113,7 +113,7 @@
// node including all languages.
try {
liveTree.addNode(authoringNode, siblingDocId);
- } catch (SiteTreeException e1) {
+ } catch (SiteException e1) {
throw new ParentNodeNotFoundException("Couldn't add document: " + documentId
+ " to live tree.", e1);
}
@@ -139,7 +139,7 @@
liveTree.addNode(documentId, labels, authoringNode.getHref(),
authoringNode.getSuffix(), authoringNode.hasLink(),
siblingDocId);
- } catch (SiteTreeException e1) {
+ } catch (SiteException e1) {
throw new ParentNodeNotFoundException("Couldn't add document: "
+ documentId + " to live tree.", e1);
}
Modified: incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/TwoNodesTask.java
==============================================================================
--- incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/TwoNodesTask.java (original)
+++ incubator/lenya/trunk/src/java/org/apache/lenya/cms/ant/TwoNodesTask.java Mon Sep 13 03:04:48 2004
@@ -15,11 +15,11 @@
*
*/
-/* $Id: TwoNodesTask.java,v 1.7 2004/03/03 12:56:30 gregor Exp $ */
+/* $Id$ */
package org.apache.lenya.cms.ant;
-import org.apache.lenya.cms.publication.SiteTreeException;
+import org.apache.lenya.cms.site.SiteException;
import org.apache.tools.ant.BuildException;
@@ -107,11 +107,11 @@
* @param firstarea : area of the tree of the first node
* @param secarea : area of the tree of the 2nd node
*
- * @throws SiteTreeException if an error occurs
+ * @throws SiteException if an error occurs
*/
public abstract void manipulateTree(String firstdocumentid, String secdocumentid,
String firstarea, String secarea)
- throws SiteTreeException;
+ throws SiteException;
/** (non-Javadoc)
* @see org.apache.tools.ant.Task#execute()
Modified: incubator/lenya/trunk/src/java/org/apache/lenya/cms/authoring/DocumentCreator.java
==============================================================================
--- incubator/lenya/trunk/src/java/org/apache/lenya/cms/authoring/DocumentCreator.java (original)
+++ incubator/lenya/trunk/src/java/org/apache/lenya/cms/authoring/DocumentCreator.java Mon Sep 13 03:04:48 2004
@@ -15,19 +15,19 @@
*
*/
-/* $Id: DocumentCreator.java,v 1.7 2004/03/03 12:56:32 gregor Exp $ */
+/* $Id$ */
package org.apache.lenya.cms.authoring;
import java.io.File;
import java.util.Collections;
-import org.apache.lenya.cms.publication.DefaultSiteTree;
import org.apache.lenya.cms.publication.DocumentType;
import org.apache.lenya.cms.publication.DocumentTypeBuildException;
import org.apache.lenya.cms.publication.DocumentTypeBuilder;
-import org.apache.lenya.cms.publication.Label;
import org.apache.lenya.cms.publication.Publication;
+import org.apache.lenya.cms.site.tree.DefaultSiteTree;
+import org.apache.lenya.cms.site.tree.Label;
public class DocumentCreator {
/**
Modified: incubator/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/DefaultCreatorAction.java
==============================================================================
--- incubator/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/DefaultCreatorAction.java (original)
+++ incubator/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/DefaultCreatorAction.java Mon Sep 13 03:04:48 2004
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-/* $Id: DefaultCreatorAction.java,v 1.12 2004/03/02 16:41:43 michi Exp $ */
+/* $Id$ */
package org.apache.lenya.cms.cocoon.acting;
@@ -38,10 +38,10 @@
import org.apache.cocoon.environment.Session;
import org.apache.cocoon.environment.SourceResolver;
import org.apache.lenya.cms.authoring.ParentChildCreatorInterface;
-import org.apache.lenya.cms.publication.DefaultSiteTree;
-import org.apache.lenya.cms.publication.Label;
import org.apache.lenya.cms.publication.Publication;
import org.apache.lenya.cms.publication.PublicationFactory;
+import org.apache.lenya.cms.site.tree.DefaultSiteTree;
+import org.apache.lenya.cms.site.tree.Label;
import org.apache.log4j.Category;
Modified: incubator/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/DocumentIdExistsAction.java
==============================================================================
--- incubator/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/DocumentIdExistsAction.java (original)
+++ incubator/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/acting/DocumentIdExistsAction.java Mon Sep 13 03:04:48 2004
@@ -15,35 +15,30 @@
*
*/
-/* $Id: DocumentIdExistsAction.java,v 1.3 2004/03/01 16:18:21 gregor Exp $ */
+/* $Id$ */
package org.apache.lenya.cms.cocoon.acting;
import java.util.Collections;
import java.util.Map;
-import org.apache.avalon.framework.parameters.ParameterException;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.cocoon.acting.AbstractAction;
import org.apache.cocoon.environment.Redirector;
import org.apache.cocoon.environment.SourceResolver;
import org.apache.lenya.cms.publication.PageEnvelope;
-import org.apache.lenya.cms.publication.PageEnvelopeException;
import org.apache.lenya.cms.publication.PageEnvelopeFactory;
import org.apache.lenya.cms.publication.Publication;
-import org.apache.lenya.cms.publication.SiteTree;
-import org.apache.lenya.cms.publication.SiteTreeException;
+import org.apache.lenya.cms.site.tree.SiteTree;
/**
- * Action that checks the sitetree if there is a node with the
- * current document-id. This is used to prevent creation of documents
- * with non-unique document-ids
+ * Action that checks the sitetree if there is a node with the current document-id. This is used to
+ * prevent creation of documents with non-unique document-ids
*/
public class DocumentIdExistsAction extends AbstractAction {
/**
- * Check if there is a doument in the site tree with the given
- * document-id.
+ * Check if there is a doument in the site tree with the given document-id.
*
* If yes return an empty map, if not return null.
*
@@ -52,24 +47,26 @@
* @param objectModel a <code>Map</code> value
* @param source a <code>String</code> value
* @param parameters a <code>Parameters</code> value
- *
- * @return an empty <code>Map</code> if there is a document
- * with the given document-id, null otherwiese
- *
- * @exception DocumentDoesNotExistException if there is no document with the specified document-id.
+ *
+ * @return an empty <code>Map</code> if there is a document with the given document-id, null
+ * otherwiese
+ *
+ * @exception DocumentDoesNotExistException if there is no document with the specified
+ * document-id.
* @exception PageEnvelopeException if the PageEnvelope could not be created.
- * @exception DocumentException if the language information could not be fetched from the document.
+ * @exception DocumentException if the language information could not be fetched from the
+ * document.
*/
public static final String DOCUMENT_ID_PARAMETER_NAME = "document-id";
- public Map act(
- Redirector redirector,
- SourceResolver resolver,
- Map objectModel,
- String source,
- Parameters parameters)
- throws PageEnvelopeException, SiteTreeException, ParameterException {
+ /**
+ * @see org.apache.cocoon.acting.Action#act(org.apache.cocoon.environment.Redirector,
+ * org.apache.cocoon.environment.SourceResolver, java.util.Map, java.lang.String,
+ * org.apache.avalon.framework.parameters.Parameters)
+ */
+ public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String source,
+ Parameters parameters) throws Exception {
String documentId = parameters.getParameter(DOCUMENT_ID_PARAMETER_NAME);
@@ -77,12 +74,9 @@
return null;
}
- PageEnvelope pageEnvelope =
- PageEnvelopeFactory.getInstance().getPageEnvelope(objectModel);
+ PageEnvelope pageEnvelope = PageEnvelopeFactory.getInstance().getPageEnvelope(objectModel);
- SiteTree siteTree =
- pageEnvelope.getPublication().getSiteTree(
- Publication.AUTHORING_AREA);
+ SiteTree siteTree = pageEnvelope.getPublication().getSiteTree(Publication.AUTHORING_AREA);
if (siteTree.getNode(documentId) == null) {
return Collections.EMPTY_MAP;
Modified: incubator/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/SitetreeModule.java
==============================================================================
--- incubator/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/SitetreeModule.java (original)
+++ incubator/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/SitetreeModule.java Mon Sep 13 03:04:48 2004
@@ -15,7 +15,7 @@
*
*/
-/* $Id: SitetreeModule.java,v 1.2 2004/03/01 16:18:24 gregor Exp $ */
+/* $Id$ */
package org.apache.lenya.cms.cocoon.components.modules.input;
@@ -29,7 +29,7 @@
import org.apache.lenya.cms.publication.PageEnvelope;
import org.apache.lenya.cms.publication.PageEnvelopeFactory;
import org.apache.lenya.cms.publication.Publication;
-import org.apache.lenya.cms.publication.SiteTree;
+import org.apache.lenya.cms.site.tree.SiteTree;
public class SitetreeModule extends AbstractInputModule {
Modified: incubator/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/transformation/AccessControlSitetreeTransformer.java
==============================================================================
--- incubator/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/transformation/AccessControlSitetreeTransformer.java (original)
+++ incubator/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/transformation/AccessControlSitetreeTransformer.java Mon Sep 13 03:04:48 2004
@@ -15,7 +15,7 @@
*
*/
-/* $Id: AccessControlSitetreeTransformer.java,v 1.7 2004/03/01 16:18:20 gregor Exp $ */
+/* $Id$ */
package org.apache.lenya.cms.cocoon.transformation;
@@ -41,8 +41,8 @@
import org.apache.lenya.ac.Role;
import org.apache.lenya.ac.impl.DefaultAccessController;
import org.apache.lenya.ac.impl.PolicyAuthorizer;
-import org.apache.lenya.cms.publication.DefaultSiteTree;
-import org.apache.lenya.cms.publication.SiteTreeNodeImpl;
+import org.apache.lenya.cms.site.tree.DefaultSiteTree;
+import org.apache.lenya.cms.site.tree.SiteTreeNodeImpl;
import org.apache.lenya.util.ServletHelper;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
Modified: incubator/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/transformation/DocumentIndexTransformer.java
==============================================================================
--- incubator/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/transformation/DocumentIndexTransformer.java (original)
+++ incubator/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/transformation/DocumentIndexTransformer.java Mon Sep 13 03:04:48 2004
@@ -15,7 +15,7 @@
*
*/
-/* $Id: DocumentIndexTransformer.java,v 1.7 2004/03/01 16:18:20 gregor Exp $ */
+/* $Id$ */
package org.apache.lenya.cms.cocoon.transformation;
@@ -38,8 +38,8 @@
import org.apache.lenya.cms.publication.PageEnvelope;
import org.apache.lenya.cms.publication.PageEnvelopeFactory;
import org.apache.lenya.cms.publication.Publication;
-import org.apache.lenya.cms.publication.SiteTree;
-import org.apache.lenya.cms.publication.SiteTreeNode;
+import org.apache.lenya.cms.site.tree.SiteTree;
+import org.apache.lenya.cms.site.tree.SiteTreeNode;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
Modified: incubator/lenya/trunk/src/java/org/apache/lenya/cms/publication/AbstractPublication.java
==============================================================================
--- incubator/lenya/trunk/src/java/org/apache/lenya/cms/publication/AbstractPublication.java (original)
+++ incubator/lenya/trunk/src/java/org/apache/lenya/cms/publication/AbstractPublication.java Mon Sep 13 03:04:48 2004
@@ -27,7 +27,11 @@
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
-import org.apache.lenya.cms.publishing.PublishingEnvironment;
+import org.apache.lenya.cms.site.SiteException;
+import org.apache.lenya.cms.site.tree.DefaultSiteTree;
+import org.apache.lenya.cms.site.tree.Label;
+import org.apache.lenya.cms.site.tree.SiteTree;
+import org.apache.lenya.cms.site.tree.SiteTreeNode;
import org.apache.log4j.Category;
/**
@@ -263,9 +267,9 @@
* @param area the area
* @return the sitetree for the specified area
*
- * @throws SiteTreeException if an error occurs
+ * @throws SiteException if an error occurs
*/
- public DefaultSiteTree getSiteTree(String area) throws SiteTreeException {
+ public DefaultSiteTree getSiteTree(String area) throws SiteException {
DefaultSiteTree sitetree = null;
@@ -417,7 +421,7 @@
}
destinationTree.save();
- } catch (SiteTreeException e) {
+ } catch (SiteException e) {
throw new PublicationException(e);
}
}
@@ -453,7 +457,7 @@
SiteTree tree;
try {
tree = getSiteTree(document.getArea());
- } catch (SiteTreeException e) {
+ } catch (SiteException e) {
throw new PublicationException(e);
}
@@ -484,7 +488,7 @@
try {
tree.save();
- } catch (SiteTreeException e) {
+ } catch (SiteException e) {
throw new PublicationException(e);
}
}
Modified: incubator/lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocument.java
==============================================================================
--- incubator/lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocument.java (original)
+++ incubator/lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocument.java Mon Sep 13 03:04:48 2004
@@ -23,6 +23,11 @@
import java.util.ArrayList;
import java.util.Date;
+import org.apache.lenya.cms.site.SiteException;
+import org.apache.lenya.cms.site.tree.Label;
+import org.apache.lenya.cms.site.tree.SiteTree;
+import org.apache.lenya.cms.site.tree.SiteTreeNode;
+
/**
* A typical CMS document.
*/
@@ -192,7 +197,7 @@
} else {
languages.add(getLanguage());
}
- } catch (SiteTreeException e) {
+ } catch (SiteException e) {
throw new DocumentException(e);
}
@@ -218,7 +223,7 @@
if (siteTree != null) {
label = siteTree.getNode(getId()).getLabel(getLanguage()).getLabel();
}
- } catch (SiteTreeException e) {
+ } catch (SiteException e) {
throw new DocumentException(e);
}
return label;
@@ -321,7 +326,7 @@
} else {
exists = getFile().exists();
}
- } catch (SiteTreeException e) {
+ } catch (SiteException e) {
throw new DocumentException(e);
}
return exists;
@@ -340,7 +345,7 @@
} else {
exists = getFile().exists();
}
- } catch (SiteTreeException e) {
+ } catch (SiteException e) {
throw new DocumentException(e);
}
return exists;
Added: incubator/lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentIdentityMap.java
==============================================================================
--- (empty file)
+++ incubator/lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentIdentityMap.java Mon Sep 13 03:04:48 2004
@@ -0,0 +1,96 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.lenya.cms.publication;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.lenya.cms.publication.Document;
+import org.apache.lenya.cms.publication.DocumentBuildException;
+import org.apache.lenya.cms.publication.DocumentBuilder;
+import org.apache.lenya.cms.publication.Publication;
+
+/**
+ * A DocumentIdentityMap avoids the multiple instanciation
+ * of a document object.
+ *
+ * @version $Id:$
+ */
+public class DocumentIdentityMap {
+
+ private Publication publication;
+ private Map key2document = new HashMap();
+
+ /**
+ * Ctor.
+ * @param publication The publication to use.
+ */
+ public DocumentIdentityMap(Publication publication) {
+ this.publication = publication;
+ }
+
+ /**
+ * Returns the publication.
+ * @return A publication.
+ */
+ public Publication getPublication() {
+ return publication;
+ }
+
+ /**
+ * Returns a document.
+ * @param area The area.
+ * @param documentId The document ID.
+ * @param language The language.
+ * @return A document.
+ * @throws DocumentBuildException if an error occurs.
+ */
+ public Document get(String area, String documentId, String language) throws DocumentBuildException {
+ String key = getKey(area, documentId, language);
+ Document document = (Document) key2document.get(key);
+ if (document == null) {
+ DocumentBuilder builder = getPublication().getDocumentBuilder();
+ String url = builder.buildCanonicalUrl(getPublication(), area, documentId, language);
+ document = builder.buildDocument(getPublication(), url);
+ key2document.put(key, document);
+ }
+ return document;
+ }
+
+ /**
+ * Returns a document.
+ * @param area The area.
+ * @param documentId The document ID.
+ * @return A document.
+ * @throws DocumentBuildException If an error occurs.
+ */
+ public Document get(String area, String documentId) throws DocumentBuildException {
+ return get(area, documentId, getPublication().getDefaultLanguage());
+ }
+
+ /**
+ * Calculates a map key.
+ * @param area The area.
+ * @param documentId The document ID.
+ * @param language The language.
+ * @return A string.
+ */
+ protected String getKey(String area, String documentId, String language) {
+ return area + ":" + documentId + ":" + language;
+ }
+
+}
Modified: incubator/lenya/trunk/src/java/org/apache/lenya/cms/publication/DublinCoreHelper.java
==============================================================================
--- incubator/lenya/trunk/src/java/org/apache/lenya/cms/publication/DublinCoreHelper.java (original)
+++ incubator/lenya/trunk/src/java/org/apache/lenya/cms/publication/DublinCoreHelper.java Mon Sep 13 03:04:48 2004
@@ -15,10 +15,14 @@
*
*/
-/* $Id: DublinCoreHelper.java,v 1.6 2004/08/16 12:27:23 andreas Exp $ */
+/* $Id$ */
package org.apache.lenya.cms.publication;
+import org.apache.lenya.cms.site.SiteException;
+import org.apache.lenya.cms.site.tree.Label;
+import org.apache.lenya.cms.site.tree.SiteTree;
+import org.apache.lenya.cms.site.tree.SiteTreeNode;
import org.apache.log4j.Category;
/**
@@ -26,64 +30,59 @@
*/
public final class DublinCoreHelper {
- /**
- *
- */
- private DublinCoreHelper() {
- }
-
- private static Category log = Category.getInstance(DublinCoreHelper.class);
-
- /**
- * Get the value of the DCIdentifier corresponding to a document id.
- *
- * @param publication
- * The publication the document(s) belongs to.
- * @param area
- * The area the document(s) belongs to.
- * @param documentId
- * The document id.
- * @return a String. The value of the DCIdentifier.
- * @throws SiteTreeException
- * when something with the sitetree went wrong.
- * @throws DocumentBuildException
- * when the building of a document failed.
- * @throws DocumentException
- * when something with the document went wrong.
- */
- public static String getDCIdentifier(Publication publication, String area, String documentId)
- throws SiteTreeException, DocumentBuildException, DocumentException {
- String identifier = null;
- String language = null;
- String url = null;
- Document document = null;
-
- SiteTree tree = publication.getSiteTree(area);
- SiteTreeNode node = tree.getNode(documentId);
-
- DocumentBuilder builder = publication.getDocumentBuilder();
-
- int i = 0;
- Label[] labels = node.getLabels();
- if (labels.length > 0) {
- while (identifier == null && i < labels.length) {
- language = labels[i].getLanguage();
- url = builder.buildCanonicalUrl(publication, area, documentId, language);
- document = builder.buildDocument(publication, url);
- log.debug("document file : " + document.getFile().getAbsolutePath());
- DublinCore dublincore = document.getDublinCore();
- log.debug("dublincore title : " + dublincore.getFirstValue(DublinCore.ELEMENT_TITLE));
- identifier = dublincore.getFirstValue(DublinCore.ELEMENT_IDENTIFIER);
- i = i + 1;
- }
- }
- if (labels.length < 1 || identifier == null) {
- url = builder.buildCanonicalUrl(publication, area, documentId);
- document = builder.buildDocument(publication, url);
- DublinCore dublincore = document.getDublinCore();
- identifier = dublincore.getFirstValue(DublinCore.ELEMENT_IDENTIFIER);
- }
-
- return identifier;
- }
-}
+ /**
+ *
+ */
+ private DublinCoreHelper() {
+ }
+
+ private static Category log = Category.getInstance(DublinCoreHelper.class);
+
+ /**
+ * Get the value of the DCIdentifier corresponding to a document id.
+ *
+ * @param publication The publication the document(s) belongs to.
+ * @param area The area the document(s) belongs to.
+ * @param documentId The document id.
+ * @return a String. The value of the DCIdentifier.
+ * @throws SiteException when something with the sitetree went wrong.
+ * @throws DocumentBuildException when the building of a document failed.
+ * @throws DocumentException when something with the document went wrong.
+ */
+ public static String getDCIdentifier(Publication publication, String area, String documentId)
+ throws SiteException, DocumentBuildException, DocumentException {
+ String identifier = null;
+ String language = null;
+ String url = null;
+ Document document = null;
+
+ SiteTree tree = publication.getSiteTree(area);
+ SiteTreeNode node = tree.getNode(documentId);
+
+ DocumentBuilder builder = publication.getDocumentBuilder();
+
+ int i = 0;
+ Label[] labels = node.getLabels();
+ if (labels.length > 0) {
+ while (identifier == null && i < labels.length) {
+ language = labels[i].getLanguage();
+ url = builder.buildCanonicalUrl(publication, area, documentId, language);
+ document = builder.buildDocument(publication, url);
+ log.debug("document file : " + document.getFile().getAbsolutePath());
+ DublinCore dublincore = document.getDublinCore();
+ log.debug("dublincore title : "
+ + dublincore.getFirstValue(DublinCore.ELEMENT_TITLE));
+ identifier = dublincore.getFirstValue(DublinCore.ELEMENT_IDENTIFIER);
+ i = i + 1;
+ }
+ }
+ if (labels.length < 1 || identifier == null) {
+ url = builder.buildCanonicalUrl(publication, area, documentId);
+ document = builder.buildDocument(publication, url);
+ DublinCore dublincore = document.getDublinCore();
+ identifier = dublincore.getFirstValue(DublinCore.ELEMENT_IDENTIFIER);
+ }
+
+ return identifier;
+ }
+}
\ No newline at end of file
Modified: incubator/lenya/trunk/src/java/org/apache/lenya/cms/publication/Publication.java
==============================================================================
--- incubator/lenya/trunk/src/java/org/apache/lenya/cms/publication/Publication.java (original)
+++ incubator/lenya/trunk/src/java/org/apache/lenya/cms/publication/Publication.java Mon Sep 13 03:04:48 2004
@@ -21,6 +21,9 @@
import java.io.File;
+import org.apache.lenya.cms.site.SiteException;
+import org.apache.lenya.cms.site.tree.DefaultSiteTree;
+
/**
* A Lenya publication.
*/
@@ -129,9 +132,9 @@
* @param area the area
* @return the sitetree for the specified area
*
- * @throws SiteTreeException if an error occurs
+ * @throws SiteException if an error occurs
*/
- DefaultSiteTree getSiteTree(String area) throws SiteTreeException;
+ DefaultSiteTree getSiteTree(String area) throws SiteException;
/**
* Returns the document builder of this instance.
Modified: incubator/lenya/trunk/src/java/org/apache/lenya/cms/publication/PublicationHelper.java
==============================================================================
--- incubator/lenya/trunk/src/java/org/apache/lenya/cms/publication/PublicationHelper.java (original)
+++ incubator/lenya/trunk/src/java/org/apache/lenya/cms/publication/PublicationHelper.java Mon Sep 13 03:04:48 2004
@@ -19,13 +19,20 @@
import java.util.List;
+import org.apache.lenya.cms.site.SiteException;
+import org.apache.lenya.cms.site.tree.SiteTreeNode;
+
/**
- * @version $Id: PublicationHelper.java,v 1.1 2004/08/26 22:18:19 roku Exp $
+ * @version $Id$
*/
public final class PublicationHelper {
private Publication publication;
+ /**
+ * Ctor.
+ * @param publication The publication.
+ */
public PublicationHelper(Publication publication) {
this.publication = publication;
}
@@ -33,7 +40,9 @@
/**
* Returns all documents of a publication.
* @param area
- * @return
+ * @param language
+ * @return An array of document.
+ * @throws DocumentException
* @see Document
* @see Publication
*/
@@ -47,7 +56,7 @@
((SiteTreeNode)allNodes.get(i)).getAbsoluteId(), language);
}
return documents;
- } catch(SiteTreeException e) {
+ } catch(SiteException e) {
throw new DocumentException("Can not access sitetree to get document ids.", e);
} catch(DocumentBuildException e) {
throw new DocumentException("Can not build document from id obtained from sitetree.", e);
Modified: incubator/lenya/trunk/src/java/org/apache/lenya/cms/publication/UniqueDocumentId.java
==============================================================================
--- incubator/lenya/trunk/src/java/org/apache/lenya/cms/publication/UniqueDocumentId.java (original)
+++ incubator/lenya/trunk/src/java/org/apache/lenya/cms/publication/UniqueDocumentId.java Mon Sep 13 03:04:48 2004
@@ -15,27 +15,28 @@
*
*/
-/* $Id: UniqueDocumentId.java,v 1.11 2004/08/16 13:01:46 andreas Exp $ */
+/* $Id$ */
package org.apache.lenya.cms.publication;
+import org.apache.lenya.cms.site.SiteException;
+import org.apache.lenya.cms.site.tree.SiteTree;
+import org.apache.lenya.cms.site.tree.SiteTreeNode;
+
/**
- * class to compute an unique document id for a document, if there is
- * already a node in the sitetree for a document with this id. It will
- * documentid_"number of version"
+ * class to compute an unique document id for a document, if there is already a node in the sitetree
+ * for a document with this id. It will documentid_"number of version"
*/
public class UniqueDocumentId {
- /** compute an unique document id
+ /**
+ * compute an unique document id
* @param publication The publication the document belongs to.
* @param area The area the document belongs to.
* @param documentid The documentid .
* @return the unique documentid
*/
- public String computeUniqueDocumentId(
- Publication publication,
- String area,
- String documentid) {
+ public String computeUniqueDocumentId(Publication publication, String area, String documentid) {
SiteTree tree;
try {
tree = publication.getSiteTree(area);
@@ -70,10 +71,10 @@
node = tree.getNode(documentid);
}
}
- } catch (SiteTreeException e) {
- e.printStackTrace();
+ } catch (SiteException e) {
+ throw new RuntimeException(e.getMessage(), e);
}
return documentid;
}
-}
+}
\ No newline at end of file
Modified: incubator/lenya/trunk/src/java/org/apache/lenya/cms/publication/xsp/DocumentReferencesHelper.java
==============================================================================
--- incubator/lenya/trunk/src/java/org/apache/lenya/cms/publication/xsp/DocumentReferencesHelper.java (original)
+++ incubator/lenya/trunk/src/java/org/apache/lenya/cms/publication/xsp/DocumentReferencesHelper.java Mon Sep 13 03:04:48 2004
@@ -15,7 +15,7 @@
*
*/
-/* $Id: DocumentReferencesHelper.java,v 1.17 2004/03/01 16:18:27 gregor Exp $ */
+/* $Id$ */
package org.apache.lenya.cms.publication.xsp;
@@ -36,9 +36,9 @@
import org.apache.lenya.cms.publication.PageEnvelopeFactory;
import org.apache.lenya.cms.publication.PathToDocumentIdMapper;
import org.apache.lenya.cms.publication.Publication;
-import org.apache.lenya.cms.publication.SiteTree;
-import org.apache.lenya.cms.publication.SiteTreeException;
-import org.apache.lenya.cms.publication.SiteTreeNode;
+import org.apache.lenya.cms.site.SiteException;
+import org.apache.lenya.cms.site.tree.SiteTree;
+import org.apache.lenya.cms.site.tree.SiteTreeNode;
import org.apache.lenya.search.Grep;
import org.apache.log4j.Category;
@@ -125,6 +125,7 @@
/**
* Find a list of document-ids which have references to the current
* document.
+ * @param area The area.
*
* @return an <code>array</code> of documents if there are references,
* an empty <code>array</code> otherwise
@@ -316,7 +317,7 @@
builder.buildDocument(publication, url));
}
}
- } catch (SiteTreeException e) {
+ } catch (SiteException e) {
throw new ProcessingException(e);
} catch (IOException e) {
throw new ProcessingException(e);
Added: incubator/lenya/trunk/src/java/org/apache/lenya/cms/site/AbstractSiteManager.java
==============================================================================
--- (empty file)
+++ incubator/lenya/trunk/src/java/org/apache/lenya/cms/site/AbstractSiteManager.java Mon Sep 13 03:04:48 2004
@@ -0,0 +1,47 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.lenya.cms.site;
+
+import org.apache.lenya.cms.publication.DocumentIdentityMap;
+
+/**
+ * Abstract base class for site managers.
+ *
+ * @version $Id: AbstractSiteManager.java,v 1.1 2004/02/18 18:47:07 andreas Exp $
+ */
+public abstract class AbstractSiteManager implements SiteManager {
+
+ private DocumentIdentityMap map;
+
+ /**
+ * Ctor.
+ * @param map The resource identity map.
+ */
+ public AbstractSiteManager(DocumentIdentityMap map) {
+ this.map = map;
+ }
+
+ /**
+ * Returns the identity map.
+ * @return A resource identity map.
+ */
+ public DocumentIdentityMap getIdentityMap() {
+ return map;
+ }
+
+}
Added: incubator/lenya/trunk/src/java/org/apache/lenya/cms/site/SiteException.java
==============================================================================
--- (empty file)
+++ incubator/lenya/trunk/src/java/org/apache/lenya/cms/site/SiteException.java Mon Sep 13 03:04:48 2004
@@ -0,0 +1,99 @@
+/*
+<License>
+
+ ============================================================================
+ The Apache Software License, Version 1.1
+ ============================================================================
+
+ Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without modifica-
+ tion, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. The end-user documentation included with the redistribution, if any, must
+ include the following acknowledgment: "This product includes software
+ developed by the Apache Software Foundation (http://www.apache.org/)."
+ Alternately, this acknowledgment may appear in the software itself, if
+ and wherever such third-party acknowledgments normally appear.
+
+ 4. The names "Apache Lenya" and "Apache Software Foundation" must not be
+ used to endorse or promote products derived from this software without
+ prior written permission. For written permission, please contact
+ apache@apache.org.
+
+ 5. Products derived from this software may not be called "Apache", nor may
+ "Apache" appear in their name, without prior written permission of the
+ Apache Software Foundation.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ This software consists of voluntary contributions made by many individuals
+ on behalf of the Apache Software Foundation and was originally created by
+ Michael Wechner <mi...@apache.org>. For more information on the Apache Soft-
+ ware Foundation, please see <http://www.apache.org/>.
+
+ Lenya includes software developed by the Apache Software Foundation, W3C,
+ DOM4J Project, BitfluxEditor, Xopus, and WebSHPINX.
+</License>
+*/
+package org.apache.lenya.cms.site;
+
+import org.apache.lenya.cms.publication.PublicationException;
+
+/**
+ * Site structure management exception.
+ *
+ * @author <a href="andreas@apache.org">Andreas Hartmann</a>
+ * @version $Id: SiteException.java,v 1.1 2004/02/18 18:47:07 andreas Exp $
+ */
+public class SiteException extends PublicationException {
+
+ /**
+ * Ctor.
+ */
+ public SiteException() {
+ super();
+ }
+
+ /**
+ * Ctor.
+ * @param message The message.
+ */
+ public SiteException(String message) {
+ super(message);
+ }
+
+ /**
+ * Ctor.
+ * @param cause The cause.
+ */
+ public SiteException(Throwable cause) {
+ super(cause);
+ }
+
+ /**
+ * Ctor.
+ * @param message The message.
+ * @param cause The cause.
+ */
+ public SiteException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+}
Added: incubator/lenya/trunk/src/java/org/apache/lenya/cms/site/SiteManager.java
==============================================================================
--- (empty file)
+++ incubator/lenya/trunk/src/java/org/apache/lenya/cms/site/SiteManager.java Mon Sep 13 03:04:48 2004
@@ -0,0 +1,70 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.lenya.cms.site;
+
+import org.apache.lenya.cms.publication.Document;
+
+/**
+ * <p>A site structure management component.</p>
+ *
+ * <p>Dependence on a set of resources must be a strict partial order <strong><</strong>:</p>
+ * <ul>
+ * <li><em>irreflexive:</em> d<strong><</strong>d does not hold for any resource d</li>
+ * <li><em>antisymmetric:</em> d<strong><</strong>e and e<strong><</strong>d implies d=e</li>
+ * <li><em>transitive:</em> d<strong><</strong>e and e<strong><</strong>f implies d<strong><</strong>f</li>
+ * </ul>
+
+ * * @author <a href="andreas@apache.org">Andreas Hartmann</a>
+ * @version $Id: SiteManager.java,v 1.1 2004/02/18 18:47:07 andreas Exp $
+ */
+public interface SiteManager {
+
+ /**
+ * Checks if a resource requires another one.
+ * @param dependingResource The depending resource.
+ * @param requiredResource The required resource.
+ * @return A boolean value.
+ * @throws SiteException if an error occurs.
+ */
+ boolean requires(Document dependingResource, Document requiredResource) throws SiteException;
+
+ /**
+ * Returns the resources which are required by a certain resource.
+ * @param resource The depending resource.
+ * @return An array of resources.
+ * @throws SiteException if an error occurs.
+ */
+ Document[] getRequiredResources(Document resource) throws SiteException;
+
+ /**
+ * Returns the resources which require a certain resource.
+ * @param resource The required resource.
+ * @return An array of resources.
+ * @throws SiteException if an error occurs.
+ */
+ Document[] getRequiringResources(Document resource) throws SiteException;
+
+ /**
+ * Checks if the site structure contains a certain resource in a certain area.
+ * @param resource The resource.
+ * @return A boolean value.
+ * @throws SiteException if an error occurs.
+ */
+ boolean contains(Document resource) throws SiteException;
+
+}
Copied: incubator/lenya/trunk/src/java/org/apache/lenya/cms/site/tree/DefaultSiteTree.java (from rev 45959, incubator/lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultSiteTree.java)
==============================================================================
--- incubator/lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultSiteTree.java (original)
+++ incubator/lenya/trunk/src/java/org/apache/lenya/cms/site/tree/DefaultSiteTree.java Mon Sep 13 03:04:48 2004
@@ -15,7 +15,7 @@
*
*/
-package org.apache.lenya.cms.publication;
+package org.apache.lenya.cms.site.tree;
import java.io.File;
import java.io.IOException;
@@ -26,6 +26,8 @@
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;
+import org.apache.lenya.cms.publication.Publication;
+import org.apache.lenya.cms.site.SiteException;
import org.apache.lenya.xml.DocumentHelper;
import org.apache.lenya.xml.NamespaceHelper;
import org.apache.log4j.Category;
@@ -40,7 +42,7 @@
/**
* Default sitetree implementation.
*
- * @version $Id:$
+ * @version $Id$
*/
public class DefaultSiteTree implements SiteTree {
private static Category log = Category.getInstance(DefaultSiteTree.class);
@@ -49,7 +51,7 @@
* The sitetree namespace.
*/
public static final String NAMESPACE_URI = "http://apache.org/cocoon/lenya/sitetree/1.0";
-
+
/**
* The name of the sitetree file.
*/
@@ -66,43 +68,37 @@
* @param pubDir the publication directory
* @param area the area
*
- * @throws SiteTreeException if an error occurs
+ * @throws SiteException if an error occurs
*/
- protected DefaultSiteTree(File pubDir, String area) throws SiteTreeException {
- this(
- new File(
- pubDir,
- Publication.CONTENT_PATH
- + File.separator
- + area
- + File.separator
- + SITE_TREE_FILENAME));
+ public DefaultSiteTree(File pubDir, String area) throws SiteException {
+ this(new File(pubDir, Publication.CONTENT_PATH + File.separator + area + File.separator
+ + SITE_TREE_FILENAME));
this.area = area;
}
/**
* Create a DefaultSiteTree from a filename.
- *
+ *
* @param treefilename file name of the tree
- *
- * @throws SiteTreeException if an error occurs
- *
+ *
+ * @throws SiteException if an error occurs
+ *
* @deprecated use the DefaultSiteTree(File pubDir, String area) constructor instead.
*/
- public DefaultSiteTree(String treefilename) throws SiteTreeException {
+ public DefaultSiteTree(String treefilename) throws SiteException {
this(new File(treefilename));
}
/**
* Create a DefaultSiteTree from a file.
- *
+ *
* @param treefile the file containing the tree
*
- * @throws SiteTreeException if an error occurs
+ * @throws SiteException if an error occurs
*
* @deprecated this constructor will be private in the future
*/
- public DefaultSiteTree(File treefile) throws SiteTreeException {
+ public DefaultSiteTree(File treefile) throws SiteException {
this.treefile = treefile;
try {
@@ -115,11 +111,11 @@
document = DocumentHelper.readDocument(treefile);
}
} catch (ParserConfigurationException e) {
- throw new SiteTreeException(e);
+ throw new SiteException(e);
} catch (SAXException e) {
- throw new SiteTreeException(e);
+ throw new SiteException(e);
} catch (IOException e) {
- throw new SiteTreeException(e);
+ throw new SiteException(e);
}
}
@@ -130,14 +126,13 @@
* Checks if the tree file has been modified externally and reloads the site tree.
*/
protected void checkModified() {
- if (area.equals(Publication.LIVE_AREA)
- && treefile.isFile()
- && treefile.lastModified() > lastModified) {
-
+ if (area.equals(Publication.LIVE_AREA) && treefile.isFile()
+ && treefile.lastModified() > lastModified) {
+
if (log.isDebugEnabled()) {
log.debug("Sitetree [" + treefile + "] has changed: reloading.");
}
-
+
try {
document = DocumentHelper.readDocument(treefile);
} catch (Exception e) {
@@ -149,7 +144,7 @@
/**
* Create a new DefaultSiteTree xml document.
- *
+ *
* @return the new site document
*
* @throws ParserConfigurationException if an error occurs
@@ -159,18 +154,17 @@
Element root = document.getDocumentElement();
root.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
- root.setAttribute(
- "xsi:schemaLocation",
- "http://apache.org/cocoon/lenya/sitetree/1.0 ../../../../resources/entities/sitetree.xsd");
+ root
+ .setAttribute("xsi:schemaLocation",
+ "http://apache.org/cocoon/lenya/sitetree/1.0 ../../../../resources/entities/sitetree.xsd");
return document;
}
/**
- * Find a node in a subtree. The search is started at the
- * given node. The list of ids contains the document-id
- * split by "/".
- *
+ * Find a node in a subtree. The search is started at the given node. The list of ids contains
+ * the document-id split by "/".
+ *
* @param node where to start the search
* @param ids list of node ids
*
@@ -191,9 +185,8 @@
if (attributes != null) {
Node idAttribute = attributes.getNamedItem("id");
- if (idAttribute != null
- && !"".equals(idAttribute.getNodeValue())
- && idAttribute.getNodeValue().equals(ids.get(0))) {
+ if (idAttribute != null && !"".equals(idAttribute.getNodeValue())
+ && idAttribute.getNodeValue().equals(ids.get(0))) {
return findNode(nodes.item(i), ids.subList(1, ids.size()));
}
}
@@ -204,44 +197,37 @@
return null;
}
- /** (non-Javadoc)
- * @see org.apache.lenya.cms.publication.SiteTree#addNode(org.apache.lenya.cms.publication.SiteTreeNode, java.lang.String)
+ /**
+ * @see org.apache.lenya.cms.site.tree.SiteTree#addNode(org.apache.lenya.cms.site.tree.SiteTreeNode,
+ * java.lang.String)
*/
- public void addNode(SiteTreeNode node, String refDocumentId) throws SiteTreeException {
- this.addNode(
- node.getAbsoluteParentId(),
- node.getId(),
- node.getLabels(),
- node.getHref(),
- node.getSuffix(),
- node.hasLink(),
- refDocumentId);
+ public void addNode(SiteTreeNode node, String refDocumentId) throws SiteException {
+ this.addNode(node.getAbsoluteParentId(), node.getId(), node.getLabels(), node.getHref(),
+ node.getSuffix(), node.hasLink(), refDocumentId);
}
- /** (non-Javadoc)
- * @see org.apache.lenya.cms.publication.SiteTree#addNode(java.lang.String, java.lang.String, org.apache.lenya.cms.publication.Label[])
+
+ /**
+ * @see org.apache.lenya.cms.site.tree.SiteTree#addNode(java.lang.String, java.lang.String,
+ * org.apache.lenya.cms.site.tree.Label[])
*/
- public void addNode(String parentid, String id, Label[] labels) throws SiteTreeException {
+ public void addNode(String parentid, String id, Label[] labels) throws SiteException {
addNode(parentid, id, labels, null, null, false);
}
- /** (non-Javadoc)
- * @see org.apache.lenya.cms.publication.SiteTree#addNode(org.apache.lenya.cms.publication.SiteTreeNode)
+ /**
+ * @see org.apache.lenya.cms.site.tree.SiteTree#addNode(org.apache.lenya.cms.site.tree.SiteTreeNode)
*/
- public void addNode(SiteTreeNode node) throws SiteTreeException {
+ public void addNode(SiteTreeNode node) throws SiteException {
this.addNode(node, null);
}
- /** (non-Javadoc)
- * @see org.apache.lenya.cms.publication.SiteTree#addNode(java.lang.String, org.apache.lenya.cms.publication.Label[], java.lang.String, java.lang.String, boolean, java.lang.String)
+ /**
+ * @see org.apache.lenya.cms.site.tree.SiteTree#addNode(java.lang.String,
+ * org.apache.lenya.cms.site.tree.Label[], java.lang.String, java.lang.String, boolean,
+ * java.lang.String)
*/
- public void addNode(
- String documentid,
- Label[] labels,
- String href,
- String suffix,
- boolean link,
- String refDocumentId)
- throws SiteTreeException {
+ public void addNode(String documentid, Label[] labels, String href, String suffix,
+ boolean link, String refDocumentId) throws SiteException {
String parentid = "";
StringTokenizer st = new StringTokenizer(documentid, "/");
int length = st.countTokens();
@@ -254,50 +240,36 @@
this.addNode(parentid, id, labels, href, suffix, link, refDocumentId);
}
- /** (non-Javadoc)
- * @see org.apache.lenya.cms.publication.SiteTree#addNode(java.lang.String, org.apache.lenya.cms.publication.Label[], java.lang.String, java.lang.String, boolean)
+ /**
+ * @see org.apache.lenya.cms.site.tree.SiteTree#addNode(java.lang.String,
+ * org.apache.lenya.cms.site.tree.Label[], java.lang.String, java.lang.String, boolean)
*/
- public void addNode(
- String documentid,
- Label[] labels,
- String href,
- String suffix,
- boolean link)
- throws SiteTreeException {
+ public void addNode(String documentid, Label[] labels, String href, String suffix, boolean link)
+ throws SiteException {
this.addNode(documentid, labels, href, suffix, link, null);
}
- /** (non-Javadoc)
- * @see org.apache.lenya.cms.publication.SiteTree#addNode(java.lang.String, java.lang.String, org.apache.lenya.cms.publication.Label[], java.lang.String, java.lang.String, boolean)
+
+ /**
+ * @see org.apache.lenya.cms.site.tree.SiteTree#addNode(java.lang.String, java.lang.String,
+ * org.apache.lenya.cms.site.tree.Label[], java.lang.String, java.lang.String, boolean)
*/
- public void addNode(
- String parentid,
- String id,
- Label[] labels,
- String href,
- String suffix,
- boolean link)
- throws SiteTreeException {
+ public void addNode(String parentid, String id, Label[] labels, String href, String suffix,
+ boolean link) throws SiteException {
this.addNode(parentid, id, labels, href, suffix, link, null);
}
/**
- * @see org.apache.lenya.cms.publication.SiteTree#addNode(java.lang.String, java.lang.String, org.apache.lenya.cms.publication.Label[], java.lang.String, java.lang.String, boolean, java.lang.String)
+ * @see org.apache.lenya.cms.site.tree.SiteTree#addNode(java.lang.String, java.lang.String,
+ * org.apache.lenya.cms.site.tree.Label[], java.lang.String, java.lang.String, boolean,
+ * java.lang.String)
*/
- public void addNode(
- String parentid,
- String id,
- Label[] labels,
- String href,
- String suffix,
- boolean link,
- String refDocumentId)
- throws SiteTreeException {
+ public void addNode(String parentid, String id, Label[] labels, String href, String suffix,
+ boolean link, String refDocumentId) throws SiteException {
Node parentNode = getNodeInternal(parentid);
if (parentNode == null) {
- throw new SiteTreeException(
- "Parentid: " + parentid + " in " + area + " tree not found");
+ throw new SiteException("Parentid: " + parentid + " in " + area + " tree not found");
}
log.debug("PARENT ELEMENT: " + parentNode);
@@ -340,7 +312,7 @@
child.appendChild(label);
}
- // Add Node
+ // Add Node
if (refDocumentId != null && !refDocumentId.equals("")) {
Node nextSibling = getNodeInternal(refDocumentId);
if (nextSibling != null) {
@@ -354,9 +326,10 @@
log.debug("Tree has been modified: " + document.getDocumentElement());
}
+
/**
- * (non-Javadoc)
- * @see org.apache.lenya.cms.publication.SiteTree#addLabel(java.lang.String, org.apache.lenya.cms.publication.Label)
+ * @see org.apache.lenya.cms.site.tree.SiteTree#addLabel(java.lang.String,
+ * org.apache.lenya.cms.site.tree.Label)
*/
public void addLabel(String documentId, Label label) {
SiteTreeNode node = getNode(documentId);
@@ -366,8 +339,8 @@
}
/**
- * (non-Javadoc)
- * @see org.apache.lenya.cms.publication.SiteTree#removeLabel(java.lang.String, org.apache.lenya.cms.publication.Label)
+ * @see org.apache.lenya.cms.site.tree.SiteTree#removeLabel(java.lang.String,
+ * org.apache.lenya.cms.site.tree.Label)
*/
public void removeLabel(String documentId, Label label) {
SiteTreeNode node = getNode(documentId);
@@ -376,8 +349,9 @@
}
}
- /** (non-Javadoc)
- * @see org.apache.lenya.cms.publication.SiteTree#removeNode(java.lang.String)
+ /**
+ * (non-Javadoc)
+ * @see org.apache.lenya.cms.site.tree.SiteTree#removeNode(java.lang.String)
*/
public SiteTreeNode removeNode(String documentId) {
assert documentId != null;
@@ -392,8 +366,7 @@
}
/**
- * removes the node corresponding to the given document-id
- * and returns it
+ * removes the node corresponding to the given document-id and returns it
*
* @param documentId the document-id of the Node to be removed
*
@@ -409,7 +382,7 @@
/**
* Find a node for a given document-id
- *
+ *
* @param documentId the document-id of the Node that we're trying to get
*
* @return the Node if there is a Node for the given document-id, null otherwise
@@ -427,7 +400,7 @@
}
/**
- * @see org.apache.lenya.cms.publication.SiteTree#getNode(java.lang.String)
+ * @see org.apache.lenya.cms.site.tree.SiteTree#getNode(java.lang.String)
*/
public SiteTreeNode getNode(String documentId) {
assert documentId != null;
@@ -446,27 +419,25 @@
* Move up the node amongst its siblings.
*
* @param documentid The document id for the node.
- * @throws SiteTreeException if the moving failed.
+ * @throws SiteException if the moving failed.
*/
- public void moveUp(String documentid) throws SiteTreeException {
+ public void moveUp(String documentid) throws SiteException {
Node node = this.getNodeInternal(documentid);
if (node == null) {
- throw new SiteTreeException("Node to move: " + documentid + " not found");
+ throw new SiteException("Node to move: " + documentid + " not found");
}
Node parentNode = node.getParentNode();
if (parentNode == null) {
- throw new SiteTreeException(
- "Parentid of node with documentid: " + documentid + " not found");
+ throw new SiteException("Parentid of node with documentid: " + documentid
+ + " not found");
}
Node previousNode;
try {
- previousNode =
- XPathAPI.selectSingleNode(
- node,
+ previousNode = XPathAPI.selectSingleNode(node,
"(preceding-sibling::*[local-name() = 'node'])[last()]");
} catch (TransformerException e) {
- throw new SiteTreeException(e);
+ throw new SiteException(e);
}
if (previousNode == null) {
@@ -481,26 +452,24 @@
* Move down the node amongst its siblings.
*
* @param documentid The document id for the node.
- * @throws SiteTreeException if the moving failed.
+ * @throws SiteException if the moving failed.
*/
- public void moveDown(String documentid) throws SiteTreeException {
+ public void moveDown(String documentid) throws SiteException {
Node node = this.getNodeInternal(documentid);
if (node == null) {
- throw new SiteTreeException("Node to move: " + documentid + " not found");
+ throw new SiteException("Node to move: " + documentid + " not found");
}
Node parentNode = node.getParentNode();
if (parentNode == null) {
- throw new SiteTreeException(
- "Parentid of node with documentid: " + documentid + " not found");
+ throw new SiteException("Parentid of node with documentid: " + documentid
+ + " not found");
}
Node nextNode;
try {
- nextNode =
- XPathAPI.selectSingleNode(
- node,
+ nextNode = XPathAPI.selectSingleNode(node,
"following-sibling::*[local-name() = 'node'][position()=2]");
} catch (TransformerException e) {
- throw new SiteTreeException(e);
+ throw new SiteException(e);
}
Node insertNode = parentNode.removeChild(node);
@@ -514,30 +483,21 @@
}
/**
- * @see org.apache.lenya.cms.publication.SiteTree#importSubtree(org.apache.lenya.cms.publication.SiteTreeNode, org.apache.lenya.cms.publication.SiteTreeNode, java.lang.String, java.lang.String)
+ * @see org.apache.lenya.cms.site.tree.SiteTree#importSubtree(org.apache.lenya.cms.site.tree.SiteTreeNode,
+ * org.apache.lenya.cms.site.tree.SiteTreeNode, java.lang.String, java.lang.String)
*/
- public void importSubtree(
- SiteTreeNode newParent,
- SiteTreeNode subtreeRoot,
- String newid,
- String refDocumentId)
- throws SiteTreeException {
+ public void importSubtree(SiteTreeNode newParent, SiteTreeNode subtreeRoot, String newid,
+ String refDocumentId) throws SiteException {
assert subtreeRoot != null;
assert newParent != null;
String parentId = newParent.getAbsoluteId();
String id = newid;
- this.addNode(
- parentId,
- id,
- subtreeRoot.getLabels(),
- subtreeRoot.getHref(),
- subtreeRoot.getSuffix(),
- subtreeRoot.hasLink(),
- refDocumentId);
+ this.addNode(parentId, id, subtreeRoot.getLabels(), subtreeRoot.getHref(), subtreeRoot
+ .getSuffix(), subtreeRoot.hasLink(), refDocumentId);
newParent = this.getNode(parentId + "/" + id);
if (newParent == null) {
- throw new SiteTreeException("The added node was not found.");
+ throw new SiteException("The added node was not found.");
}
SiteTreeNode[] children = subtreeRoot.getChildren();
if (children == null) {
@@ -550,23 +510,25 @@
}
}
- /** (non-Javadoc)
- * @see org.apache.lenya.cms.publication.SiteTree#save()
+ /**
+ * (non-Javadoc)
+ * @see org.apache.lenya.cms.site.tree.SiteTree#save()
*/
- public void save() throws SiteTreeException {
+ public void save() throws SiteException {
try {
DocumentHelper.writeDocument(document, treefile);
} catch (TransformerException e) {
- throw new SiteTreeException(
- "The document [" + document.getLocalName() + "] could not be transformed");
+ throw new SiteException("The document [" + document.getLocalName()
+ + "] could not be transformed");
} catch (IOException e) {
- throw new SiteTreeException(
- "The saving of document [" + document.getLocalName() + "] failed");
+ throw new SiteException("The saving of document [" + document.getLocalName()
+ + "] failed");
}
}
/**
- * @see org.apache.lenya.cms.publication.SiteTree#setLabel(java.lang.String, org.apache.lenya.cms.publication.Label)
+ * @see org.apache.lenya.cms.site.tree.SiteTree#setLabel(java.lang.String,
+ * org.apache.lenya.cms.site.tree.Label)
*/
public void setLabel(String documentId, Label label) {
SiteTreeNode node = getNode(documentId);
@@ -575,4 +537,4 @@
}
}
-}
+}
\ No newline at end of file
Copied: incubator/lenya/trunk/src/java/org/apache/lenya/cms/site/tree/Label.java (from rev 45951, incubator/lenya/trunk/src/java/org/apache/lenya/cms/publication/Label.java)
==============================================================================
--- incubator/lenya/trunk/src/java/org/apache/lenya/cms/publication/Label.java (original)
+++ incubator/lenya/trunk/src/java/org/apache/lenya/cms/site/tree/Label.java Mon Sep 13 03:04:48 2004
@@ -15,9 +15,9 @@
*
*/
-/* @version $Id: Label.java,v 1.10 2004/03/02 15:37:43 michi Exp $ */
+/* @version $Id$ */
-package org.apache.lenya.cms.publication;
+package org.apache.lenya.cms.site.tree;
/**
* The Label class encapsulates a string label and a associated language.
Copied: incubator/lenya/trunk/src/java/org/apache/lenya/cms/site/tree/SiteTree.java (from rev 45951, incubator/lenya/trunk/src/java/org/apache/lenya/cms/publication/SiteTree.java)
==============================================================================
--- incubator/lenya/trunk/src/java/org/apache/lenya/cms/publication/SiteTree.java (original)
+++ incubator/lenya/trunk/src/java/org/apache/lenya/cms/site/tree/SiteTree.java Mon Sep 13 03:04:48 2004
@@ -15,10 +15,16 @@
*
*/
-/* $Id: SiteTree.java,v 1.21 2004/03/01 16:18:16 gregor Exp $ */
+package org.apache.lenya.cms.site.tree;
-package org.apache.lenya.cms.publication;
+import org.apache.lenya.cms.site.SiteException;
+
+/**
+ * A sitetree.
+ *
+ * @version $Id:$
+ */
public interface SiteTree {
/**
@@ -28,10 +34,10 @@
* @param id e.g. "concepts"
* @param labels the labels of the node that is to be added
*
- * @throws SiteTreeException if the addition failed
+ * @throws SiteException if the addition failed
*/
void addNode(String parentid, String id, Label[] labels)
- throws SiteTreeException;
+ throws SiteException;
/**
* Add a node.
@@ -43,7 +49,7 @@
* @param suffix the suffix of the new node
* @param link the link
*
- * @throws SiteTreeException if the addition failed
+ * @throws SiteException if the addition failed
*/
void addNode(
String parentid,
@@ -52,7 +58,7 @@
String href,
String suffix,
boolean link)
- throws SiteTreeException;
+ throws SiteException;
/**
* Insert a node before a given node
@@ -65,7 +71,7 @@
* @param link the link
* @param refDocumentId document-id of the node, before which the new node will be inserted.
*
- * @throws SiteTreeException if the addition failed
+ * @throws SiteException if the addition failed
*/
void addNode(
String parentid,
@@ -75,7 +81,7 @@
String suffix,
boolean link,
String refDocumentId)
- throws SiteTreeException;
+ throws SiteException;
/**
* Add a node.
@@ -88,7 +94,7 @@
* @param suffix the suffix
* @param link the link
*
- * @throws SiteTreeException if the addition failed
+ * @throws SiteException if the addition failed
*/
void addNode(
String documentid,
@@ -96,7 +102,7 @@
String href,
String suffix,
boolean link)
- throws SiteTreeException;
+ throws SiteException;
/**
* Insert a node before a given node
@@ -110,7 +116,7 @@
* @param link the link
* @param refDocumentId document-id of the node, before which the new node will be inserted.
*
- * @throws SiteTreeException if the addition failed
+ * @throws SiteException if the addition failed
*/
void addNode(
String documentid,
@@ -119,7 +125,7 @@
String suffix,
boolean link,
String refDocumentId)
- throws SiteTreeException;
+ throws SiteException;
/**
* Add a node. This method is typically used when publishing,
@@ -131,9 +137,9 @@
*
* @param node the <code>SiteTreeNode</code> that is to be added
*
- * @throws SiteTreeException if the addition failed
+ * @throws SiteException if the addition failed
*/
- void addNode(SiteTreeNode node) throws SiteTreeException;
+ void addNode(SiteTreeNode node) throws SiteException;
/**
* Add a node. This method is typically used when publishing,
@@ -146,10 +152,10 @@
* @param node the <code>SiteTreeNode</code> that is to be added
* @param refDocumentId document-id of the node, before which the new node will be inserted.
*
- * @throws SiteTreeException if the addition failed
+ * @throws SiteException if the addition failed
*/
void addNode(SiteTreeNode node, String refDocumentId)
- throws SiteTreeException;
+ throws SiteException;
/**
* Add a label to an existing node
@@ -200,16 +206,16 @@
* Move up the node amongst its siblings.
*
* @param documentid The document id of the node.
- * @throws SiteTreeException if the moving failed.
+ * @throws SiteException if the moving failed.
*/
- void moveUp(String documentid) throws SiteTreeException;
+ void moveUp(String documentid) throws SiteException;
/**
* Move down the node amongst its siblings.
* @param documentid The document id of the node.
- * @throws SiteTreeException if the moving failed.
+ * @throws SiteException if the moving failed.
*/
- void moveDown(String documentid) throws SiteTreeException;
+ void moveDown(String documentid) throws SiteException;
/**
* Imports a subtree (from this or from another tree) at a certain position.
@@ -219,19 +225,19 @@
* @param refDocumentId The document-id corresponding to the reference node, before which
* the subtree should be inserted. If null, the subtree is inserted at the end.
* in case there is already a node with the same id in the tree).
- * @throws SiteTreeException when an error occurs.
+ * @throws SiteException when an error occurs.
*/
void importSubtree(
SiteTreeNode subtreeRoot,
SiteTreeNode newParent,
String newid,
String refDocumentId)
- throws SiteTreeException;
+ throws SiteException;
/**
* Save the SiteTree.
*
- * @throws SiteTreeException if the saving failed
+ * @throws SiteException if the saving failed
*/
- void save() throws SiteTreeException;
+ void save() throws SiteException;
}
Copied: incubator/lenya/trunk/src/java/org/apache/lenya/cms/site/tree/SiteTreeNode.java (from rev 45951, incubator/lenya/trunk/src/java/org/apache/lenya/cms/publication/SiteTreeNode.java)
==============================================================================
--- incubator/lenya/trunk/src/java/org/apache/lenya/cms/publication/SiteTreeNode.java (original)
+++ incubator/lenya/trunk/src/java/org/apache/lenya/cms/site/tree/SiteTreeNode.java Mon Sep 13 03:04:48 2004
@@ -15,11 +15,13 @@
*
*/
-/* $Id: SiteTreeNode.java,v 1.19 2004/03/01 16:18:17 gregor Exp $ */
+/* $Id$ */
-package org.apache.lenya.cms.publication;
+package org.apache.lenya.cms.site.tree;
import java.util.List;
+
+import org.apache.lenya.cms.publication.DocumentException;
/**
* This interface is a wrapper around the more general w3c.Node which
Copied: incubator/lenya/trunk/src/java/org/apache/lenya/cms/site/tree/SiteTreeNodeImpl.java (from rev 45951, incubator/lenya/trunk/src/java/org/apache/lenya/cms/publication/SiteTreeNodeImpl.java)
==============================================================================
--- incubator/lenya/trunk/src/java/org/apache/lenya/cms/publication/SiteTreeNodeImpl.java (original)
+++ incubator/lenya/trunk/src/java/org/apache/lenya/cms/site/tree/SiteTreeNodeImpl.java Mon Sep 13 03:04:48 2004
@@ -15,13 +15,12 @@
*
*/
-/* $Id: SiteTreeNodeImpl.java,v 1.27 2004/03/01 16:18:17 gregor Exp $ */
-
-package org.apache.lenya.cms.publication;
+package org.apache.lenya.cms.site.tree;
import java.util.ArrayList;
import java.util.List;
+import org.apache.lenya.cms.publication.DocumentException;
import org.apache.lenya.xml.DocumentHelper;
import org.apache.lenya.xml.NamespaceHelper;
import org.apache.log4j.Category;
@@ -33,10 +32,12 @@
/**
* Concrete implementation of the <code>SiteTreeNode</code> interface.
*
- * @see org.apache.lenya.cms.publication.SiteTreeNode
+ * @see org.apache.lenya.cms.site.tree.SiteTreeNode
+ * @version $Id:$
*/
public class SiteTreeNodeImpl implements SiteTreeNode {
private static Category log = Category.getInstance(SiteTreeNodeImpl.class);
+
public static final String ID_ATTRIBUTE_NAME = "id";
public static final String HREF_ATTRIBUTE_NAME = "href";
public static final String SUFFIX_ATTRIBUTE_NAME = "suffix";
@@ -49,15 +50,15 @@
/**
* Creates a new SiteTreeNodeImpl object.
- *
- * @param node the node which is to be wrapped by this SiteTreeNode
+ *
+ * @param node the node which is to be wrapped by this SiteTreeNode
*/
public SiteTreeNodeImpl(Node node) {
this.node = node;
}
/**
- * @see org.apache.lenya.cms.publication.SiteTreeNode#getParentId()
+ * @see org.apache.lenya.cms.site.tree.SiteTreeNode#getParentId()
* @deprecated use getParent().getId() instead
*/
public String getParentId() {
@@ -83,7 +84,7 @@
}
/**
- * @see org.apache.lenya.cms.publication.SiteTreeNode#getId()
+ * @see org.apache.lenya.cms.site.tree.SiteTreeNode#getId()
*/
public String getId() {
if (node == node.getOwnerDocument().getDocumentElement()) {
@@ -93,7 +94,7 @@
}
/**
- * @see org.apache.lenya.cms.publication.SiteTreeNode#getAbsoluteParentId()
+ * @see org.apache.lenya.cms.site.tree.SiteTreeNode#getAbsoluteParentId()
* @deprecated use getParent().getAbsoluteId() instead
*/
public String getAbsoluteParentId() {
@@ -102,7 +103,7 @@
}
/**
- * @see org.apache.lenya.cms.publication.SiteTreeNode#getAbsoluteId()
+ * @see org.apache.lenya.cms.site.tree.SiteTreeNode#getAbsoluteId()
*/
public String getAbsoluteId() {
String absoluteId = "";
@@ -131,7 +132,7 @@
}
/**
- * @see org.apache.lenya.cms.publication.SiteTreeNode#getLabels()
+ * @see org.apache.lenya.cms.site.tree.SiteTreeNode#getLabels()
*/
public Label[] getLabels() {
ArrayList labels = new ArrayList();
@@ -142,11 +143,11 @@
Node child = children.item(i);
if ((child.getNodeType() == Node.ELEMENT_NODE)
- && child.getNodeName().equals(LABEL_NAME)) {
+ && child.getNodeName().equals(LABEL_NAME)) {
String labelName = DocumentHelper.getSimpleElementText((Element) child);
String labelLanguage = null;
- Node languageAttribute =
- child.getAttributes().getNamedItem(LANGUAGE_ATTRIBUTE_NAME);
+ Node languageAttribute = child.getAttributes()
+ .getNamedItem(LANGUAGE_ATTRIBUTE_NAME);
if (languageAttribute != null) {
labelLanguage = languageAttribute.getNodeValue();
@@ -160,7 +161,7 @@
}
/**
- * @see org.apache.lenya.cms.publication.SiteTreeNode#getLabel(java.lang.String)
+ * @see org.apache.lenya.cms.site.tree.SiteTreeNode#getLabel(java.lang.String)
*/
public Label getLabel(String xmlLanguage) {
Label label = null;
@@ -170,11 +171,11 @@
for (int i = 0; i < labels.length; i++) {
language = labels[i].getLanguage();
- // FIXME: This expression is too complicated
+ // FIXME: This expression is too complicated
// considering there can no longer be any labels with
// a null language, i.e. each label must have a language.
if ((((xmlLanguage == null) || (xmlLanguage.equals(""))) && (language == null))
- || ((language != null) && (language.equals(xmlLanguage)))) {
+ || ((language != null) && (language.equals(xmlLanguage)))) {
label = labels[i];
break;
@@ -185,7 +186,7 @@
}
/**
- * @see org.apache.lenya.cms.publication.SiteTreeNode#addLabel(org.apache.lenya.cms.publication.Label)
+ * @see org.apache.lenya.cms.site.tree.SiteTreeNode#addLabel(org.apache.lenya.cms.site.tree.Label)
*/
public void addLabel(Label label) {
if (getLabel(label.getLanguage()) == null) {
@@ -201,7 +202,7 @@
}
/**
- * @see org.apache.lenya.cms.publication.SiteTreeNode#removeLabel(org.apache.lenya.cms.publication.Label)
+ * @see org.apache.lenya.cms.site.tree.SiteTreeNode#removeLabel(org.apache.lenya.cms.site.tree.Label)
*/
public void removeLabel(Label label) {
if (getLabel(label.getLanguage()) != null) {
@@ -213,14 +214,14 @@
Node child = children.item(i);
if ((child.getNodeType() == Node.ELEMENT_NODE)
- && child.getNodeName().equals(LABEL_NAME)
- && child.getFirstChild().getNodeValue().equals(label.getLabel())) {
+ && child.getNodeName().equals(LABEL_NAME)
+ && child.getFirstChild().getNodeValue().equals(label.getLabel())) {
- Node languageAttribute =
- child.getAttributes().getNamedItem(LANGUAGE_ATTRIBUTE_NAME);
+ Node languageAttribute = child.getAttributes().getNamedItem(
+ LANGUAGE_ATTRIBUTE_NAME);
if (languageAttribute != null
- && languageAttribute.getNodeValue().equals(label.getLanguage())) {
+ && languageAttribute.getNodeValue().equals(label.getLanguage())) {
node.removeChild(child);
break;
}
@@ -230,7 +231,7 @@
}
/**
- * @see org.apache.lenya.cms.publication.SiteTreeNode#getHref()
+ * @see org.apache.lenya.cms.site.tree.SiteTreeNode#getHref()
*/
public String getHref() {
Node attribute = node.getAttributes().getNamedItem(HREF_ATTRIBUTE_NAME);
@@ -243,7 +244,7 @@
}
/**
- * @see org.apache.lenya.cms.publication.SiteTreeNode#getSuffix()
+ * @see org.apache.lenya.cms.site.tree.SiteTreeNode#getSuffix()
*/
public String getSuffix() {
Node attribute = node.getAttributes().getNamedItem(SUFFIX_ATTRIBUTE_NAME);
@@ -256,7 +257,7 @@
}
/**
- * @see org.apache.lenya.cms.publication.SiteTreeNode#hasLink()
+ * @see org.apache.lenya.cms.site.tree.SiteTreeNode#hasLink()
*/
public boolean hasLink() {
Node attribute = node.getAttributes().getNamedItem(LINK_ATTRIBUTE_NAME);
@@ -267,8 +268,9 @@
return false;
}
}
+
/**
- * @see org.apache.lenya.cms.publication.SiteTreeNode#getChildren()
+ * @see org.apache.lenya.cms.site.tree.SiteTreeNode#getChildren()
*/
public SiteTreeNode[] getChildren() {
List childElements = new ArrayList();
@@ -285,7 +287,7 @@
}
/**
- * @see org.apache.lenya.cms.publication.SiteTreeNode#removeChildren()
+ * @see org.apache.lenya.cms.site.tree.SiteTreeNode#removeChildren()
*/
public SiteTreeNode[] removeChildren() {
List childElements = new ArrayList();
@@ -300,7 +302,7 @@
}
/**
- * @see org.apache.lenya.cms.publication.SiteTreeNode#getChildren()
+ * @see org.apache.lenya.cms.site.tree.SiteTreeNode#getNextSiblings()
*/
public SiteTreeNode[] getNextSiblings() {
List siblingElements = new ArrayList();
@@ -317,7 +319,7 @@
}
/**
- * @see org.apache.lenya.cms.publication.SiteTreeNode#getNextSiblingDocumentId()
+ * @see org.apache.lenya.cms.site.tree.SiteTreeNode#getNextSiblingDocumentId()
*/
public String getNextSiblingDocumentId() {
SiteTreeNode[] siblings = getNextSiblings();
@@ -329,15 +331,14 @@
}
/**
- * @see org.apache.lenya.cms.publication.SiteTreeNode#accept(org.apache.lenya.cms.publication.SiteTreeNodeVisitor)
+ * @see org.apache.lenya.cms.site.tree.SiteTreeNode#accept(org.apache.lenya.cms.site.tree.SiteTreeNodeVisitor)
*/
public void accept(SiteTreeNodeVisitor visitor) throws DocumentException {
visitor.visitSiteTreeNode(this);
}
/**
- * (non-Javadoc)
- * @see org.apache.lenya.cms.publication.SiteTreeNode#acceptSubtree(org.apache.lenya.cms.publication.SiteTreeNodeVisitor)
+ * @see org.apache.lenya.cms.site.tree.SiteTreeNode#acceptSubtree(org.apache.lenya.cms.site.tree.SiteTreeNodeVisitor)
*/
public void acceptSubtree(SiteTreeNodeVisitor visitor) throws DocumentException {
this.accept(visitor);
@@ -353,7 +354,7 @@
}
/**
- * @see org.apache.lenya.cms.publication.SiteTreeNode#acceptSubtree(org.apache.lenya.cms.publication.SiteTreeNodeVisitor)
+ * @see org.apache.lenya.cms.site.tree.SiteTreeNode#acceptReverseSubtree(org.apache.lenya.cms.site.tree.SiteTreeNodeVisitor)
*/
public void acceptReverseSubtree(SiteTreeNodeVisitor visitor) throws DocumentException {
List orderedNodes = this.postOrder();
@@ -364,7 +365,7 @@
}
/**
- * @see org.apache.lenya.cms.publication.SiteTreeNode#postOrder()
+ * @see org.apache.lenya.cms.site.tree.SiteTreeNode#postOrder()
*/
public List postOrder() {
List list = new ArrayList();
@@ -376,8 +377,9 @@
list.add(this);
return list;
}
+
/**
- * @see org.apache.lenya.cms.publication.SiteTreeNode#setLabel(org.apache.lenya.cms.publication.Label)
+ * @see org.apache.lenya.cms.site.tree.SiteTreeNode#setLabel(org.apache.lenya.cms.site.tree.Label)
*/
public void setLabel(Label label) {
Label existingLabel = getLabel(label.getLanguage());
@@ -388,7 +390,7 @@
}
/**
- * @see org.apache.lenya.cms.publication.SiteTreeNode#getChildren(java.lang.String)
+ * @see org.apache.lenya.cms.site.tree.SiteTreeNode#getChildren(java.lang.String)
*/
public SiteTreeNode[] getChildren(String language) {
SiteTreeNode[] children = getChildren();
@@ -404,14 +406,14 @@
}
/**
- * @see org.apache.lenya.cms.publication.SiteTreeNode#getParent()
+ * @see org.apache.lenya.cms.site.tree.SiteTreeNode#getParent()
*/
public SiteTreeNode getParent() {
SiteTreeNode parent = null;
Node parentNode = node.getParentNode();
if (parentNode.getNodeType() == Node.ELEMENT_NODE
- && parentNode.getLocalName().equals(NODE_NAME)) {
+ && parentNode.getLocalName().equals(NODE_NAME)) {
parent = new SiteTreeNodeImpl(parentNode);
}
@@ -423,13 +425,13 @@
* @return A namespace helper.
*/
protected NamespaceHelper getNamespaceHelper() {
- NamespaceHelper helper =
- new NamespaceHelper(DefaultSiteTree.NAMESPACE_URI, "", node.getOwnerDocument());
+ NamespaceHelper helper = new NamespaceHelper(DefaultSiteTree.NAMESPACE_URI, "", node
+ .getOwnerDocument());
return helper;
}
/**
- * @see org.apache.lenya.cms.publication.SiteTreeNode#getParent(java.lang.String)
+ * @see org.apache.lenya.cms.site.tree.SiteTreeNode#getParent(java.lang.String)
*/
public SiteTreeNode getParent(String language) {
SiteTreeNode parent = getParent();
@@ -443,7 +445,7 @@
}
/**
- * @see org.apache.lenya.cms.publication.SiteTreeNode#preOrder()
+ * @see org.apache.lenya.cms.site.tree.SiteTreeNode#preOrder()
*/
public List preOrder() {
List list = new ArrayList();
@@ -455,4 +457,4 @@
}
return list;
}
-}
+}
\ No newline at end of file
Copied: incubator/lenya/trunk/src/java/org/apache/lenya/cms/site/tree/SiteTreeNodeVisitor.java (from rev 45951, incubator/lenya/trunk/src/java/org/apache/lenya/cms/publication/SiteTreeNodeVisitor.java)
==============================================================================
--- incubator/lenya/trunk/src/java/org/apache/lenya/cms/publication/SiteTreeNodeVisitor.java (original)
+++ incubator/lenya/trunk/src/java/org/apache/lenya/cms/site/tree/SiteTreeNodeVisitor.java Mon Sep 13 03:04:48 2004
@@ -15,9 +15,11 @@
*
*/
-/* $Id: SiteTreeNodeVisitor.java,v 1.3 2004/03/01 16:18:17 gregor Exp $ */
+/* $Id$ */
-package org.apache.lenya.cms.publication;
+package org.apache.lenya.cms.site.tree;
+
+import org.apache.lenya.cms.publication.DocumentException;
/**
* Visitor interface to define operations performed on SiteTreeNode
Added: incubator/lenya/trunk/src/java/org/apache/lenya/cms/site/tree/TreeSiteManager.java
==============================================================================
--- (empty file)
+++ incubator/lenya/trunk/src/java/org/apache/lenya/cms/site/tree/TreeSiteManager.java Mon Sep 13 03:04:48 2004
@@ -0,0 +1,157 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.lenya.cms.site.tree;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.lenya.cms.publication.Document;
+import org.apache.lenya.cms.publication.PublicationException;
+import org.apache.lenya.cms.publication.DocumentIdentityMap;
+import org.apache.lenya.cms.site.AbstractSiteManager;
+import org.apache.lenya.cms.site.SiteException;
+import org.apache.log4j.Category;
+
+/**
+ * A tree-based site manager.
+ *
+ * @version $Id: TreeSiteManager.java,v 1.4 2004/02/25 08:59:54 andreas Exp $
+ */
+public class TreeSiteManager extends AbstractSiteManager {
+
+ private static final Category log = Category.getInstance(TreeSiteManager.class);
+
+ /**
+ * Ctor.
+ * @param map The resource identity map.
+ */
+ public TreeSiteManager(DocumentIdentityMap map) {
+ super(map);
+ }
+
+ /**
+ * Returns the site tree for a certain area.
+ * @param area The area.
+ * @return A site tree.
+ * @throws SiteException if an error occurs.
+ */
+ protected SiteTree getTree(String area) throws SiteException {
+ SiteTree tree = getIdentityMap().getPublication().getSiteTree(area);
+ return tree;
+ }
+
+ /**
+ * Returns the parent of a document.
+ * @param resource The resource.
+ * @return A resource.
+ * @throws SiteException if an error occurs.
+ */
+ protected Document getParent(Document resource) throws SiteException {
+ Document parent = null;
+ int lastSlashIndex = resource.getId().lastIndexOf("/");
+ if (lastSlashIndex > 0) {
+ String parentId = resource.getId().substring(0, lastSlashIndex);
+ try {
+ parent = getIdentityMap().get(parentId, resource.getArea());
+ } catch (PublicationException e) {
+ throw new SiteException(e);
+ }
+ }
+ return parent;
+ }
+
+ /**
+ * Returns the ancestors of a resource, beginning with the parent.
+ * @param resource The resource.
+ * @return A list of resources.
+ * @throws SiteException if an error occurs.
+ */
+ protected List getAncestors(Document resource) throws SiteException {
+ List ancestors = new ArrayList();
+ Document parent = getParent(resource);
+ if (parent != null) {
+ ancestors.add(parent);
+ ancestors.addAll(getAncestors(parent));
+ }
+ return ancestors;
+ }
+
+ /**
+ * @see org.apache.lenya.cms.site.SiteManager#requires(org.apache.lenya.cms.publication.Document,
+ * org.apache.lenya.cms.publication.Document)
+ */
+ public boolean requires(Document dependingResource, Document requiredResource)
+ throws SiteException {
+ return getAncestors(dependingResource).contains(requiredResource);
+ }
+
+ /**
+ * @see org.apache.lenya.cms.site.SiteManager#getRequiredResources(org.apache.lenya.cms.publication.Document)
+ */
+ public Document[] getRequiredResources(Document resource) throws SiteException {
+ List ancestors = getAncestors(resource);
+ return (Document[]) ancestors.toArray(new Document[ancestors.size()]);
+ }
+
+ /**
+ * @see org.apache.lenya.cms.site.SiteManager#getRequiringResources(org.apache.lenya.cms.publication.Document)
+ */
+ public Document[] getRequiringResources(Document resource) throws SiteException {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Obtaining requiring resources of [" + resource + "]");
+ }
+
+ SiteTree tree = getTree(resource.getArea());
+
+ SiteTreeNode node = tree.getNode(resource.getId());
+ List preOrder = node.preOrder();
+
+ // remove original resource (does not require itself)
+ preOrder.remove(0);
+
+ Document[] resources = new Document[preOrder.size()];
+
+ try {
+ for (int i = 0; i < resources.length; i++) {
+ SiteTreeNode descendant = (SiteTreeNode) preOrder.get(i);
+ resources[i] = getIdentityMap().get(descendant.getAbsoluteId(), resource.getArea());
+ if (log.isDebugEnabled()) {
+ log.debug(" Descendant: [" + resources[i] + "]");
+ }
+ }
+ } catch (PublicationException e) {
+ throw new SiteException(e);
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug("Obtaining requiring resources completed.");
+ }
+
+ return resources;
+ }
+
+ /**
+ * @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());
+ return node != null;
+ }
+
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: lenya-cvs-unsubscribe@cocoon.apache.org
For additional commands, e-mail: lenya-cvs-help@cocoon.apache.org