You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by so...@apache.org on 2007/09/11 23:39:44 UTC
svn commit: r574702 [4/6] - in /lenya/branches/revolution/1.3.x: ./ lib/
src/java/org/apache/lenya/ac/ src/java/org/apache/lenya/ac/file/
src/java/org/apache/lenya/ac/impl/ src/java/org/apache/lenya/cms/ac/
src/java/org/apache/lenya/cms/ac/cocoon/ src/...
Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/AbstractPublication.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/AbstractPublication.java?rev=574702&r1=574701&r2=574702&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/AbstractPublication.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/AbstractPublication.java Tue Sep 11 14:39:37 2007
@@ -14,9 +14,7 @@
* limitations under the License.
*
*/
-
/* $Id$ */
-
package org.apache.lenya.cms.publication;
import java.io.File;
@@ -25,29 +23,22 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
import org.apache.lenya.cms.publishing.PublishingEnvironment;
import org.apache.log4j.Category;
-
-//Lenya1.3 - BEGIN
+// Lenya1.3 - BEGIN
import org.apache.lenya.cms.content.Content;
import org.apache.lenya.cms.content.flat.FlatContent;
import org.apache.lenya.cms.content.hierarchical.HierarchicalContent;
-//Lenya1.3 - END
+// Lenya1.3 - END
/**
* A publication.
*/
public abstract class AbstractPublication implements Publication {
private static Category log = Category.getInstance(AbstractPublication.class);
-
- private static final String[] areas = { AUTHORING_AREA, STAGING_AREA, LIVE_AREA, ADMIN_AREA,
- ARCHIVE_AREA, TRASH_AREA, INFO_AREA_PREFIX + AUTHORING_AREA,
- INFO_AREA_PREFIX + STAGING_AREA, INFO_AREA_PREFIX + LIVE_AREA,
- INFO_AREA_PREFIX + ARCHIVE_AREA, INFO_AREA_PREFIX + TRASH_AREA };
-
+ private static final String[] areas = { AUTHORING_AREA, STAGING_AREA, LIVE_AREA, ADMIN_AREA, ARCHIVE_AREA, TRASH_AREA, INFO_AREA_PREFIX + AUTHORING_AREA, INFO_AREA_PREFIX + STAGING_AREA, INFO_AREA_PREFIX + LIVE_AREA, INFO_AREA_PREFIX + ARCHIVE_AREA, INFO_AREA_PREFIX + TRASH_AREA };
private String id;
private PublishingEnvironment environment;
private File servletContext;
@@ -58,79 +49,66 @@
private String sslprefix = null;
private String livemountpoint = null;
private HashMap siteTrees = new HashMap();
- private String[] rewriteAttributeXPaths = { };
+ private String[] rewriteAttributeXPaths = {};
private boolean hasSitetree = true;
-
private static final String ELEMENT_PROXY = "proxy";
private static final String ATTRIBUTE_AREA = "area";
private static final String ATTRIBUTE_URL = "url";
private static final String ATTRIBUTE_SSL = "ssl";
private static final String ELEMENT_REWRITE_ATTRIBUTE = "link-attribute";
private static final String ATTRIBUTE_XPATH = "xpath";
- private static final String ELEMENT_CONTENT_DIR = "content-dir";
-
-//Lenya1.3 - BEGIN
- private Modules modules;
- private Content content;
- private File publicationDirectory;
- private File contentDirectory;
- private String contentType = "hierarchical";
-//Lenya1.3 - END
-
+ private static final String ELEMENT_CONTENT_DIR = "content-dir";
+ // Lenya1.3 - BEGIN
+ private Modules modules;
+ private Content content;
+ private File publicationDirectory;
+ private File contentDirectory;
+ private String contentType = "hierarchical";
+ // Lenya1.3 - END
/**
* Creates a new instance of Publication
*
- * @param id the publication id
- * @param servletContextPath the servlet context of this publication
+ * @param id
+ * the publication id
+ * @param servletContextPath
+ * the servlet context of this publication
*
- * @throws PublicationException if there was a problem reading the config file
+ * @throws PublicationException
+ * if there was a problem reading the config file
*/
protected AbstractPublication(String id, String servletContextPath) throws PublicationException {
- assert id != null;
+ // assert id != null;
this.id = id;
-
- assert servletContextPath != null;
-
+ // assert servletContextPath != null;
File servletContext = new File(servletContextPath);
- assert servletContext.exists();
+ // assert servletContext.exists();
this.servletContext = servletContext;
-
// FIXME: remove PublishingEnvironment from publication
environment = new PublishingEnvironment(servletContextPath, id);
-
File configFile = new File(getDirectory(), CONFIGURATION_FILE);
DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
-
Configuration config;
-
String pathMapperClassName = null;
String documentBuilderClassName = null;
-
try {
config = builder.buildFromFile(configFile);
-
try {
pathMapperClassName = config.getChild(ELEMENT_PATH_MAPPER).getValue();
Class pathMapperClass = Class.forName(pathMapperClassName);
this.mapper = (DocumentIdToPathMapper) pathMapperClass.newInstance();
} catch (ClassNotFoundException e) {
- throw new PublicationException("Cannot instantiate documentToPathMapper: ["
- + pathMapperClassName + "]", e);
+ throw new PublicationException("Cannot instantiate documentToPathMapper: [" + pathMapperClassName + "]", e);
}
-
try {
- Configuration documentBuilderConfiguration = config.getChild(
- ELEMENT_DOCUMENT_BUILDER, false);
+ Configuration documentBuilderConfiguration = config.getChild(ELEMENT_DOCUMENT_BUILDER, false);
if (documentBuilderConfiguration != null) {
documentBuilderClassName = documentBuilderConfiguration.getValue();
Class documentBuilderClass = Class.forName(documentBuilderClassName);
this.documentBuilder = (DocumentBuilder) documentBuilderClass.newInstance();
}
} catch (ClassNotFoundException e) {
- throw new PublicationException("Cannot instantiate document builder: ["
- + pathMapperClassName + "]", e);
+ throw new PublicationException("Cannot instantiate document builder: [" + pathMapperClassName + "]", e);
}
-
Configuration[] languages = config.getChild(LANGUAGES).getChildren();
for (int i = 0; i < languages.length; i++) {
Configuration languageConfig = languages[i];
@@ -140,33 +118,26 @@
defaultLanguage = language;
}
}
-
- Configuration siteStructureConfiguration = config.getChild(ELEMENT_SITE_STRUCTURE,
- false);
+ Configuration siteStructureConfiguration = config.getChild(ELEMENT_SITE_STRUCTURE, false);
if (siteStructureConfiguration != null) {
String siteStructureType = siteStructureConfiguration.getAttribute(ATTRIBUTE_TYPE);
if (!siteStructureType.equals("sitetree")) {
hasSitetree = false;
}
}
-
Configuration[] proxyConfigs = config.getChildren(ELEMENT_PROXY);
for (int i = 0; i < proxyConfigs.length; i++) {
String url = proxyConfigs[i].getAttribute(ATTRIBUTE_URL);
String ssl = proxyConfigs[i].getAttribute(ATTRIBUTE_SSL);
String area = proxyConfigs[i].getAttribute(ATTRIBUTE_AREA);
-
Proxy proxy = new Proxy();
proxy.setUrl(url);
-
Object key = getProxyKey(area, Boolean.valueOf(ssl).booleanValue());
this.areaSsl2proxy.put(key, proxy);
if (log.isDebugEnabled()) {
- log.debug("Adding proxy: [" + proxy + "] for area=[" + area + "] SSL=[" + ssl
- + "]");
+ log.debug("Adding proxy: [" + proxy + "] for area=[" + area + "] SSL=[" + ssl + "]");
}
}
-
Configuration[] rewriteAttributeConfigs = config.getChildren(ELEMENT_REWRITE_ATTRIBUTE);
List xPaths = new ArrayList();
for (int i = 0; i < rewriteAttributeConfigs.length; i++) {
@@ -174,48 +145,39 @@
xPaths.add(xPath);
}
this.rewriteAttributeXPaths = (String[]) xPaths.toArray(new String[xPaths.size()]);
-
-
Configuration[] contentDirConfigs = config.getChildren(ELEMENT_CONTENT_DIR);
- for (int i = 0; i < contentDirConfigs.length; i++){
- String area = contentDirConfigs[i].getAttribute(ATTRIBUTE_AREA);
- String dir = contentDirConfigs[i].getValue();
+ for (int i = 0; i < contentDirConfigs.length; i++) {
+ String area = contentDirConfigs[i].getAttribute(ATTRIBUTE_AREA);
+ String dir = contentDirConfigs[i].getValue();
Object key = getContentDirKey(area);
- this.areaContentDir.put(key, dir);
+ this.areaContentDir.put(key, dir);
}
-
-//Lenya1.3 - BEGIN
-//Content
+ // Lenya1.3 - BEGIN
+ // Content
Configuration contentConfig = config.getChild("content");
contentType = contentConfig.getAttribute("type", "hierarchical");
String contentConfigValue = contentConfig.getValue(CONTENT_PATH);
publicationDirectory = new File(getServletContext(), PUBLICATION_PREFIX + File.separator + getId());
contentDirectory = new File(publicationDirectory, contentConfigValue);
- if(contentType.equalsIgnoreCase("flat")){
- content = (Content) new FlatContent(contentDirectory, getLanguages());
- }else{
- content = (Content) new HierarchicalContent(contentDirectory, getLanguages());
+ if (contentType.equalsIgnoreCase("flat")) {
+ content = (Content) new FlatContent(contentDirectory, getLanguages());
+ } else {
+ content = (Content) new HierarchicalContent(contentDirectory, getLanguages());
}
-//Modules
+ // Modules
modules = new Modules(id, servletContextPath, config.getChild("modules"));
-//Lenya1.3 - END
-
+ // Lenya1.3 - END
} catch (PublicationException e) {
throw e;
} catch (Exception e) {
log.error(e);
- throw new PublicationException("Problem with config file: "
- + configFile.getAbsolutePath(), e);
+ throw new PublicationException("Problem with config file: " + configFile.getAbsolutePath(), e);
}
-
breadcrumbprefix = config.getChild(BREADCRUMB_PREFIX).getValue("");
-
sslprefix = config.getChild(SSL_PREFIX).getValue("");
-
livemountpoint = config.getChild(LIVE_MOUNT_POINT).getValue("");
-
}
-//Lenya1.3 - BEGIN
+ // Lenya1.3 - BEGIN
public Modules getModules() {
return modules;
}
@@ -228,74 +190,76 @@
public String getContentType() {
return contentType;
}
-//Lenya1.3 - END
-
+ // Lenya1.3 - END
/**
* Returns the publication ID.
+ *
* @return A string value.
*/
public String getId() {
return id;
}
-
/**
* Returns the publishing environment of this publication.
+ *
* @return A {@link PublishingEnvironment}object.
- * @deprecated It is planned to decouple the environments from the publication.
+ * @deprecated It is planned to decouple the environments from the
+ * publication.
*/
public PublishingEnvironment getEnvironment() {
return environment;
}
-
/**
* Returns the servlet context this publication belongs to (usually, the
* <code>webapps/lenya</code> directory).
+ *
* @return A <code>File</code> object.
*/
public File getServletContext() {
return servletContext;
}
-
-//Lenya1.3 BEGIN - changed
+ // Lenya1.3 BEGIN - changed
/**
* Returns the publication directory.
+ *
* @return A <code>File</code> object.
*/
public File getDirectory() {
- if(null == publicationDirectory)
+ if (null == publicationDirectory)
publicationDirectory = new File(getServletContext(), PUBLICATION_PREFIX + File.separator + getId());
return publicationDirectory;
}
-//Lenya1.3 - deprecated
+ // Lenya1.3 - deprecated
/**
* Return the directory of a specific area.
*
- * @param area a <code>File</code> representing the root of the area content directory.
+ * @param area
+ * a <code>File</code> representing the root of the area
+ * content directory.
*
* @return the directory of the given content area.
- * @deprecated Areas are bad. Do not use them.
+ * @deprecated Areas are bad. Do not use them.
*/
-//Lenya1.3 END
+ // Lenya1.3 END
public File getContentDirectory(String area) {
- Object key = getContentDirKey(area);
- String contentDir = (String) this.areaContentDir.get(key);
- if (contentDir!= null) {
- return new File(contentDir);
+ Object key = getContentDirKey(area);
+ String contentDir = (String) this.areaContentDir.get(key);
+ if (contentDir != null) {
+ return new File(contentDir);
} else {
- return new File(getDirectory(), CONTENT_PATH + File.separator + area);
- }
+ return new File(getDirectory(), CONTENT_PATH + File.separator + area);
+ }
}
-
/**
* DOCUMENT ME!
*
- * @param mapper DOCUMENT ME!
+ * @param mapper
+ * DOCUMENT ME!
*/
public void setPathMapper(DefaultDocumentIdToPathMapper mapper) {
- assert mapper != null;
+ // assert mapper != null;
this.mapper = mapper;
}
-
/**
* Returns the path mapper.
*
@@ -304,16 +268,16 @@
public DocumentIdToPathMapper getPathMapper() {
return mapper;
}
-
/**
* Returns if a given string is a valid area name.
- * @param area The area string to test.
+ *
+ * @param area
+ * The area string to test.
* @return A boolean value.
*/
public static boolean isValidArea(String area) {
return area != null && Arrays.asList(areas).contains(area);
}
-
/**
* Get the default language
*
@@ -322,16 +286,15 @@
public String getDefaultLanguage() {
return defaultLanguage;
}
-
/**
* Set the default language
*
- * @param language the default language
+ * @param language
+ * the default language
*/
public void setDefaultLanguage(String language) {
defaultLanguage = language;
}
-
/**
* Get all available languages for this publication
*
@@ -340,54 +303,53 @@
public String[] getLanguages() {
return (String[]) languages.toArray(new String[languages.size()]);
}
-
/**
- * Get the breadcrumb prefix. It can be used as a prefix if a publication is part of a larger
- * site
+ * Get the breadcrumb prefix. It can be used as a prefix if a publication is
+ * part of a larger site
*
* @return the breadcrumb prefix
*/
public String getBreadcrumbPrefix() {
return breadcrumbprefix;
}
-
/**
- * Get the SSL prefix. If you want to serve SSL-protected pages through a special site, use this
- * prefix. This can come in handy if you have multiple sites that need SSL protection and you
- * want to share one SSL certificate.
+ * Get the SSL prefix. If you want to serve SSL-protected pages through a
+ * special site, use this prefix. This can come in handy if you have
+ * multiple sites that need SSL protection and you want to share one SSL
+ * certificate.
*
* @return the SSL prefix
*/
public String getSSLPrefix() {
return sslprefix;
}
-
/**
- * Get the Live mount point. The live mount point is used to rewrite links that are of the form
- * /contextprefix/publication/area/documentid to /livemountpoint/documentid
- *
- * This is useful if you serve your live area through mod_proxy. to enable this functionality,
- * set the Live mount point to / or something else. An empty mount point disables the feature.
+ * Get the Live mount point. The live mount point is used to rewrite links
+ * that are of the form /contextprefix/publication/area/documentid to
+ * /livemountpoint/documentid
+ *
+ * This is useful if you serve your live area through mod_proxy. to enable
+ * this functionality, set the Live mount point to / or something else. An
+ * empty mount point disables the feature.
*
* @return the Live mount point
*/
public String getLiveMountPoint() {
return livemountpoint;
}
-
/**
- * Get the sitetree for a specific area of this publication. Sitetrees are created on demand and
- * are cached.
+ * Get the sitetree for a specific area of this publication. Sitetrees are
+ * created on demand and are cached.
*
- * @param area the area
+ * @param area
+ * the area
* @return the sitetree for the specified area
*
- * @throws SiteTreeException if an error occurs
+ * @throws SiteTreeException
+ * if an error occurs
*/
public SiteTree getTree(String area) throws SiteTreeException {
-
SiteTree sitetree = null;
-
if (hasSitetree) {
if (siteTrees.containsKey(area)) {
sitetree = (SiteTree) siteTrees.get(area);
@@ -398,23 +360,23 @@
}
return sitetree;
}
-
/**
- * Get the sitetree for a specific area of this publication. Sitetrees are created on demand and
- * are cached.
- *
- * @deprecated Please use getTree() because this method returns the interface and not a specific implementation
+ * Get the sitetree for a specific area of this publication. Sitetrees are
+ * created on demand and are cached.
+ *
+ * @deprecated Please use getTree() because this method returns the
+ * interface and not a specific implementation
* @see getTree()
*
- * @param area the area
+ * @param area
+ * the area
* @return the sitetree for the specified area
*
- * @throws SiteTreeException if an error occurs
+ * @throws SiteTreeException
+ * if an error occurs
*/
public DefaultSiteTree getSiteTree(String area) throws SiteTreeException {
-
DefaultSiteTree sitetree = null;
-
if (hasSitetree) {
if (siteTrees.containsKey(area)) {
sitetree = (DefaultSiteTree) siteTrees.get(area);
@@ -425,53 +387,46 @@
}
return sitetree;
}
-
private DocumentBuilder documentBuilder;
-
/**
* Returns the document builder of this instance.
+ *
* @return A document builder.
*/
public DocumentBuilder getDocumentBuilder() {
-
if (documentBuilder == null) {
- throw new IllegalStateException(
- "The document builder was not defined in publication.xconf!");
+ throw new IllegalStateException("The document builder was not defined in publication.xconf!");
}
-
return documentBuilder;
}
-
/**
* Creates a version of the document object in another area.
- * @param document The document to clone.
- * @param area The destination area.
+ *
+ * @param document
+ * The document to clone.
+ * @param area
+ * The destination area.
* @return A document.
- * @throws PublicationException when an error occurs.
+ * @throws PublicationException
+ * when an error occurs.
*/
public Document getAreaVersion(Document document, String area) throws PublicationException {
DocumentBuilder builder = getDocumentBuilder();
- String url = builder
- .buildCanonicalUrl(this, area, document.getId(), document.getLanguage());
+ String url = builder.buildCanonicalUrl(this, area, document.getId(), document.getLanguage());
Document destinationDocument = builder.buildDocument(this, url);
return destinationDocument;
}
-
/**
* @see java.lang.Object#equals(java.lang.Object)
*/
public boolean equals(Object object) {
boolean equals = false;
-
if (getClass().isInstance(object)) {
Publication publication = (Publication) object;
- equals = getId().equals(publication.getId())
- && getServletContext().equals(publication.getServletContext());
+ equals = getId().equals(publication.getId()) && getServletContext().equals(publication.getServletContext());
}
-
return equals;
}
-
/**
* @see java.lang.Object#hashCode()
*/
@@ -479,115 +434,100 @@
String key = getServletContext() + ":" + getId();
return key.hashCode();
}
-
/**
- * Template method to copy a document. Override {@link #copyDocumentSource(Document, Document)}
- * to implement access to a custom repository.
+ * Template method to copy a document. Override
+ * {@link #copyDocumentSource(Document, Document)} to implement access to a
+ * custom repository.
+ *
* @see org.apache.lenya.cms.publication.Publication#copyDocument(org.apache.lenya.cms.publication.Document,
* org.apache.lenya.cms.publication.Document)
*/
- public void copyDocument(Document sourceDocument, Document destinationDocument)
- throws PublicationException {
-
+ public void copyDocument(Document sourceDocument, Document destinationDocument) throws PublicationException {
copyDocumentSource(sourceDocument, destinationDocument);
-
copySiteStructure(sourceDocument, destinationDocument);
}
-
/**
* Copies a document in the site structure.
- * @param sourceDocument The source document.
- * @param destinationDocument The destination document.
- * @throws PublicationException when something went wrong.
+ *
+ * @param sourceDocument
+ * The source document.
+ * @param destinationDocument
+ * The destination document.
+ * @throws PublicationException
+ * when something went wrong.
*/
- protected void copySiteStructure(Document sourceDocument, Document destinationDocument)
- throws PublicationException {
+ protected void copySiteStructure(Document sourceDocument, Document destinationDocument) throws PublicationException {
if (hasSitetree) {
try {
SiteTree sourceTree = getSiteTree(sourceDocument.getArea());
SiteTree destinationTree = getSiteTree(destinationDocument.getArea());
-
SiteTreeNode sourceNode = sourceTree.getNode(sourceDocument.getId());
if (sourceNode == null) {
- throw new PublicationException("The node for source document ["
- + sourceDocument.getId() + "] doesn't exist!");
+ throw new PublicationException("The node for source document [" + sourceDocument.getId() + "] doesn't exist!");
+ }
+ SiteTreeNode[] siblings = sourceNode.getNextSiblings();
+ String parentId = sourceNode.getAbsoluteParentId();
+ SiteTreeNode sibling = null;
+ String siblingDocId = null;
+ // same document ID -> insert at the same position
+ if (sourceDocument.getId().equals(destinationDocument.getId())) {
+ for (int i = 0; i < siblings.length; i++) {
+ String docId = parentId + "/" + siblings[i].getId();
+ sibling = destinationTree.getNode(docId);
+ if (sibling != null) {
+ siblingDocId = docId;
+ break;
+ }
+ }
+ }
+ Label label = sourceNode.getLabel(sourceDocument.getLanguage());
+ if (label == null) {
+ // the node that we're trying to publish
+ // doesn't have this language
+ throw new PublicationException("The node " + sourceDocument.getId() + " doesn't contain a label for language " + sourceDocument.getLanguage());
+ }
+ SiteTreeNode destinationNode = destinationTree.getNode(destinationDocument.getId());
+ if (destinationNode == null) {
+ Label[] labels = { label };
+ if (siblingDocId == null) {
+ destinationTree.addNode(destinationDocument.getId(), labels, sourceNode.visibleInNav(), sourceNode.getHref(), sourceNode.getSuffix(), sourceNode.hasLink());
+ } else {
+ destinationTree.addNode(destinationDocument.getId(), labels, sourceNode.visibleInNav(), sourceNode.getHref(), sourceNode.getSuffix(), sourceNode.hasLink(), siblingDocId);
+ }
+ } else {
+ // if the node already exists in the live
+ // tree simply insert the label in the
+ // live tree
+ destinationTree.setLabel(destinationDocument.getId(), label);
+ // and synchronize visibilityinnav attribute with the one in
+ // the source area
+ String visibility = "true";
+ if (!sourceNode.visibleInNav())
+ visibility = "false";
+ destinationNode.setNodeAttribute(SiteTreeNodeImpl.VISIBLEINNAV_ATTRIBUTE_NAME, visibility);
+ // also update the link attribute if necessary
+ if (sourceNode.hasLink() != destinationNode.hasLink()) {
+ String link = (sourceNode.hasLink() ? "true" : "false");
+ destinationNode.setNodeAttribute(SiteTreeNodeImpl.LINK_ATTRIBUTE_NAME, link);
+ }
}
- SiteTreeNode[] siblings = sourceNode.getNextSiblings();
- String parentId = sourceNode.getAbsoluteParentId();
- SiteTreeNode sibling = null;
- String siblingDocId = null;
-
- // same document ID -> insert at the same position
- if (sourceDocument.getId().equals(destinationDocument.getId())) {
- for (int i = 0; i < siblings.length; i++) {
- String docId = parentId + "/" + siblings[i].getId();
- sibling = destinationTree.getNode(docId);
- if (sibling != null) {
- siblingDocId = docId;
- break;
- }
- }
- }
-
-
- Label label = sourceNode.getLabel(sourceDocument.getLanguage());
- if (label == null) {
- // the node that we're trying to publish
- // doesn't have this language
- throw new PublicationException("The node " + sourceDocument.getId()
- + " doesn't contain a label for language "
- + sourceDocument.getLanguage());
- }
- SiteTreeNode destinationNode = destinationTree.getNode(destinationDocument
- .getId());
- if (destinationNode == null) {
- Label[] labels = { label };
-
- if (siblingDocId == null) {
- destinationTree.addNode(destinationDocument.getId(), labels,
- sourceNode.visibleInNav(), sourceNode.getHref(), sourceNode.getSuffix(), sourceNode
- .hasLink());
- } else {
- destinationTree.addNode(destinationDocument.getId(), labels, sourceNode.visibleInNav(),
- sourceNode.getHref(), sourceNode.getSuffix(), sourceNode
- .hasLink(), siblingDocId);
- }
-
- } else {
- // if the node already exists in the live
- // tree simply insert the label in the
- // live tree
- destinationTree.setLabel(destinationDocument.getId(), label);
- //and synchronize visibilityinnav attribute with the one in the source area
- String visibility ="true";
- if (!sourceNode.visibleInNav()) visibility = "false";
- destinationNode.setNodeAttribute(SiteTreeNodeImpl.VISIBLEINNAV_ATTRIBUTE_NAME,
- visibility);
-
- // also update the link attribute if necessary
- if (sourceNode.hasLink() != destinationNode.hasLink()) {
- String link = (sourceNode.hasLink() ? "true" : "false");
- destinationNode.setNodeAttribute(SiteTreeNodeImpl.LINK_ATTRIBUTE_NAME, link);
- }
-
- }
-
destinationTree.save();
} catch (SiteTreeException e) {
throw new PublicationException(e);
}
}
}
-
/**
* Copies a document source.
- * @param sourceDocument The source document.
- * @param destinationDocument The destination document.
- * @throws PublicationException when something went wrong.
+ *
+ * @param sourceDocument
+ * The source document.
+ * @param destinationDocument
+ * The destination document.
+ * @throws PublicationException
+ * when something went wrong.
*/
- protected abstract void copyDocumentSource(Document sourceDocument, Document destinationDocument)
- throws PublicationException;
-
+ protected abstract void copyDocumentSource(Document sourceDocument, Document destinationDocument) throws PublicationException;
/**
* @see org.apache.lenya.cms.publication.Publication#deleteDocument(org.apache.lenya.cms.publication.Document)
*/
@@ -598,11 +538,13 @@
deleteFromSiteStructure(document);
deleteDocumentSource(document);
}
-
/**
* Deletes a document from the site structure.
- * @param document The document to remove.
- * @throws PublicationException when something went wrong.
+ *
+ * @param document
+ * The document to remove.
+ * @throws PublicationException
+ * when something went wrong.
*/
protected void deleteFromSiteStructure(Document document) throws PublicationException {
if (hasSitetree) {
@@ -612,95 +554,78 @@
} catch (SiteTreeException e) {
throw new PublicationException(e);
}
-
SiteTreeNode node = tree.getNode(document.getId());
-
if (node == null) {
- throw new PublicationException("Sitetree node for document [" + document
- + "] does not exist!");
+ throw new PublicationException("Sitetree node for document [" + document + "] does not exist!");
}
-
Label label = node.getLabel(document.getLanguage());
-
if (label == null) {
- throw new PublicationException("Sitetree label for document [" + document
- + "] in language [" + document.getLanguage() + "]does not exist!");
+ throw new PublicationException("Sitetree label for document [" + document + "] in language [" + document.getLanguage() + "]does not exist!");
}
-
if (node.getLabels().length == 1 && node.getChildren().length > 0) {
- throw new PublicationException("Cannot delete last language version of document ["
- + document + "] because this node has children.");
+ throw new PublicationException("Cannot delete last language version of document [" + document + "] because this node has children.");
}
-
node.removeLabel(label);
-
try {
if (node.getLabels().length == 0) {
tree.deleteNode(document.getId());
}
-
tree.save();
} catch (SiteTreeException e) {
throw new PublicationException(e);
}
}
}
-
/**
* Deletes the source of a document.
- * @param document The document to delete.
- * @throws PublicationException when something went wrong.
+ *
+ * @param document
+ * The document to delete.
+ * @throws PublicationException
+ * when something went wrong.
*/
protected abstract void deleteDocumentSource(Document document) throws PublicationException;
-
/**
* @see org.apache.lenya.cms.publication.Publication#moveDocument(org.apache.lenya.cms.publication.Document,
* org.apache.lenya.cms.publication.Document)
*/
- public void moveDocument(Document sourceDocument, Document destinationDocument)
- throws PublicationException {
+ public void moveDocument(Document sourceDocument, Document destinationDocument) throws PublicationException {
copyDocument(sourceDocument, destinationDocument);
deleteDocument(sourceDocument);
}
-
private Map areaSsl2proxy = new HashMap();
-
/**
* Generates a hash key for a area-SSL combination.
- * @param area The area.
- * @param isSslProtected If the proxy is assigned for SSL-protected pages.
+ *
+ * @param area
+ * The area.
+ * @param isSslProtected
+ * If the proxy is assigned for SSL-protected pages.
* @return An object.
*/
protected Object getProxyKey(String area, boolean isSslProtected) {
return area + ":" + isSslProtected;
}
-
/**
* @see org.apache.lenya.cms.publication.Publication#getProxy(org.apache.lenya.cms.publication.Document,
* boolean)
*/
public Proxy getProxy(Document document, boolean isSslProtected) {
-
Object key = getProxyKey(document.getArea(), isSslProtected);
Proxy proxy = (Proxy) this.areaSsl2proxy.get(key);
-
if (log.isDebugEnabled()) {
log.debug("Resolving proxy for [" + document + "] SSL=[" + isSslProtected + "]");
log.debug("Resolved proxy: [" + proxy + "]");
}
-
return proxy;
}
-
/**
* @see org.apache.lenya.cms.publication.Publication#getRewriteAttributeXPaths()
*/
public String[] getRewriteAttributeXPaths() {
return this.rewriteAttributeXPaths;
}
-
private Map areaContentDir = new HashMap();
-
protected Object getContentDirKey(String area) {
return area;
}
Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/DefaultDocument.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/DefaultDocument.java?rev=574702&r1=574701&r2=574702&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/DefaultDocument.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/DefaultDocument.java Tue Sep 11 14:39:37 2007
@@ -14,9 +14,7 @@
* limitations under the License.
*
*/
-
/* $Id$ */
-
package org.apache.lenya.cms.publication;
import java.io.File;
@@ -27,19 +25,19 @@
* A typical CMS document.
*/
public class DefaultDocument implements Document {
-
private String id;
private Publication publication;
private DublinCore dublincore;
-
/**
* Creates a new instance of DefaultDocument.
- * @param publication The publication the document belongs to.
- * @param id The document ID (starting with a slash).
+ *
+ * @param publication
+ * The publication the document belongs to.
+ * @param id
+ * The document ID (starting with a slash).
* @deprecated Use {@link DefaultDocumentBuilder} instead.
*/
public DefaultDocument(Publication publication, String id) {
-
if (id == null) {
throw new IllegalArgumentException("The document ID must not be null!");
}
@@ -47,19 +45,20 @@
throw new IllegalArgumentException("The document ID must start with a slash!");
}
this.id = id;
-
- assert(publication != null) && !"".equals(publication.getId());
+ // assert(publication != null) && !"".equals(publication.getId());
this.publication = publication;
this.dublincore = new DublinCoreProxy(this);
}
-
/**
- * Creates a new instance of DefaultDocument.
- * The language of the document is the default language of
- * the publication.
- * @param publication The publication the document belongs to.
- * @param id The document ID (starting with a slash).
- * @param area The area.
+ * Creates a new instance of DefaultDocument. The language of the document
+ * is the default language of the publication.
+ *
+ * @param publication
+ * The publication the document belongs to.
+ * @param id
+ * The document ID (starting with a slash).
+ * @param area
+ * The area.
*/
protected DefaultDocument(Publication publication, String id, String area) {
if (id == null) {
@@ -69,24 +68,23 @@
throw new IllegalArgumentException("The document ID must start with a slash!");
}
this.id = id;
-
- assert(publication != null) && !"".equals(publication.getId());
+ // assert(publication != null) && !"".equals(publication.getId());
this.publication = publication;
-
setArea(area);
setLanguage(publication.getDefaultLanguage());
-
this.dublincore = new DublinCoreProxy(this);
-
}
-
/**
* Creates a new instance of DefaultDocument.
*
- * @param publication The publication the document belongs to.
- * @param id The document ID (starting with a slash).
- * @param area The area.
- * @param language the language
+ * @param publication
+ * The publication the document belongs to.
+ * @param id
+ * The document ID (starting with a slash).
+ * @param area
+ * The area.
+ * @param language
+ * the language
*/
protected DefaultDocument(Publication publication, String id, String area, String language) {
if (id == null) {
@@ -96,33 +94,26 @@
throw new IllegalArgumentException("The document ID must start with a slash!");
}
this.id = id;
-
- assert(publication != null) && !"".equals(publication.getId());
+ // assert(publication != null) && !"".equals(publication.getId());
this.publication = publication;
this.language = language;
setArea(area);
-
this.dublincore = new DublinCoreProxy(this);
-
}
-
/**
* @see org.apache.lenya.cms.publication.Document#getId()
*/
public String getId() {
return id;
}
-
/**
* @see org.apache.lenya.cms.publication.Document#getName()
*/
public String getName() {
String[] ids = id.split("/");
String nodeId = ids[ids.length - 1];
-
return nodeId;
}
-
/**
* @see org.apache.lenya.cms.publication.Document#getNodeId()
* @deprecated replaced by getName()
@@ -130,49 +121,39 @@
public String getNodeId() {
return getName();
}
-
/**
* @see org.apache.lenya.cms.publication.Document#getPublication()
*/
public Publication getPublication() {
return publication;
}
-
/**
* @see org.apache.lenya.cms.publication.Document#getLastModified()
*/
public Date getLastModified() {
return new Date(getFile().lastModified());
}
-
/**
* @see org.apache.lenya.cms.publication.Document#getDublinCore()
*/
public DublinCore getDublinCore() {
return dublincore;
}
-
/**
* Returns the file for this document.
+ *
* @return A file object.
*/
public File getFile() {
- return getPublication().getPathMapper().getFile(
- getPublication(),
- getArea(),
- getId(),
- getLanguage());
+ return getPublication().getPathMapper().getFile(getPublication(), getArea(), getId(), getLanguage());
}
-
private String language = "";
-
/**
* @see org.apache.lenya.cms.publication.Document#getLanguage()
*/
public String getLanguage() {
return language;
}
-
/**
* @see org.apache.lenya.cms.publication.Document#getLanguage()
*/
@@ -195,19 +176,18 @@
} catch (SiteTreeException e) {
throw new DocumentException(e);
}
-
return (String[]) languages.toArray(new String[languages.size()]);
}
-
/**
* Sets the language of this document.
- * @param language The language.
+ *
+ * @param language
+ * The language.
*/
public void setLanguage(String language) {
- assert language != null;
+ // /// language != null;
this.language = language;
}
-
/**
* @see org.apache.lenya.cms.publication.Document#getLabel()
*/
@@ -223,96 +203,84 @@
}
return label;
}
-
private String area;
-
/**
* @see org.apache.lenya.cms.publication.Document#getArea()
*/
public String getArea() {
return area;
}
-
/**
* @see Document#getCompleteURL(String)
*/
public String getCompleteURL() {
return "/" + getPublication().getId() + "/" + getArea() + getDocumentURL();
}
-
/**
* @see Document#getCompleteInfoURL(String)
*/
public String getCompleteInfoURL() {
- return "/"
- + getPublication().getId()
- + "/"
- + Publication.INFO_AREA_PREFIX
- + getArea()
- + getDocumentURL();
+ return "/" + getPublication().getId() + "/" + Publication.INFO_AREA_PREFIX + getArea() + getDocumentURL();
}
-
/**
* @see Document#getCompleteURL(String)
*/
public String getCompleteURLWithoutLanguage() {
String extensionSuffix = "".equals(getExtension()) ? "" : ("." + getExtension());
-
return "/" + getPublication().getId() + "/" + getArea() + getId() + extensionSuffix;
}
-
/**
* Sets the area.
- * @param area A string.
+ *
+ * @param area
+ * A string.
*/
-// LENYA1.3 BEGIN - Area as Module cannot error, so assume "live".
+ // LENYA1.3 BEGIN - Area as Module cannot error, so assume "live".
protected void setArea(String area) {
if (!AbstractPublication.isValidArea(area)) {
- this.area = Publication.LIVE_AREA;
- }else{
- this.area = area;
+ this.area = Publication.LIVE_AREA;
+ } else {
+ this.area = area;
}
}
-// LENYA1.3 END
-
-
+ // LENYA1.3 END
private String extension = "html";
-
/**
* @see org.apache.lenya.cms.publication.Document#getExtension()
*/
public String getExtension() {
return extension;
}
-
/**
* Sets the extension of the file in the URL.
- * @param extension A string.
+ *
+ * @param extension
+ * A string.
*/
protected void setExtension(String extension) {
- assert extension != null;
+ // assert extension != null;
this.extension = extension;
}
-
private String documentURL;
-
/**
* Sets the document URL.
- * @param url The document URL (without publication ID and area).
+ *
+ * @param url
+ * The document URL (without publication ID and area).
*/
public void setDocumentURL(String url) {
- assert url != null;
+ // assert url != null;
this.documentURL = url;
}
-
/**
* @see org.apache.lenya.cms.publication.Document#getDocumentURL()
*/
public String getDocumentURL() {
return documentURL;
}
-
- /** (non-Javadoc)
+ /**
+ * (non-Javadoc)
+ *
* @see org.apache.lenya.cms.publication.Document#exists()
*/
public boolean exists() throws DocumentException {
@@ -330,8 +298,9 @@
}
return exists;
}
-
- /** (non-Javadoc)
+ /**
+ * (non-Javadoc)
+ *
* @see org.apache.lenya.cms.publication.Document#existsInAnyLanguage()
*/
public boolean existsInAnyLanguage() throws DocumentException {
@@ -349,7 +318,6 @@
}
return exists;
}
-
/**
* @see java.lang.Object#equals(java.lang.Object)
*/
@@ -357,40 +325,21 @@
boolean equals = false;
if (getClass().isInstance(object)) {
Document document = (Document) object;
- equals =
- getPublication().equals(document.getPublication())
- && getId().equals(document.getId())
- && getArea().equals(document.getArea())
- && getLanguage().equals(document.getLanguage());
+ equals = getPublication().equals(document.getPublication()) && getId().equals(document.getId()) && getArea().equals(document.getArea()) && getLanguage().equals(document.getLanguage());
}
return equals;
-
}
-
/**
* @see java.lang.Object#hashCode()
*/
public int hashCode() {
-
- String key =
- getPublication().getId()
- + ":"
- + getPublication().getServletContext()
- + ":"
- + getArea()
- + ":"
- + getId()
- + ":"
- + getLanguage();
-
+ String key = getPublication().getId() + ":" + getPublication().getServletContext() + ":" + getArea() + ":" + getId() + ":" + getLanguage();
return key.hashCode();
}
-
/**
* @see java.lang.Object#toString()
*/
public String toString() {
return getPublication().getId() + ":" + getArea() + ":" + getId() + ":" + getLanguage();
}
-
}
Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/DefaultDocumentIdToPathMapper.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/DefaultDocumentIdToPathMapper.java?rev=574702&r1=574701&r2=574702&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/DefaultDocumentIdToPathMapper.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/DefaultDocumentIdToPathMapper.java Tue Sep 11 14:39:37 2007
@@ -14,28 +14,22 @@
* limitations under the License.
*
*/
-
/* $Id$ */
-
package org.apache.lenya.cms.publication;
import java.io.File;
-public class DefaultDocumentIdToPathMapper
- implements DocumentIdToPathMapper, PathToDocumentIdMapper {
-
+public class DefaultDocumentIdToPathMapper implements DocumentIdToPathMapper, PathToDocumentIdMapper {
public static final String BASE_FILENAME_PREFIX = "index";
public static final String BASE_FILENAME_SUFFIX = ".xml";
-
/**
- * @see org.apache.lenya.cms.publication.DocumentIdToPathMapper#getFile(org.apache.lenya.cms.publication.Publication,
- * java.lang.String, java.lang.String, java.lang.String)
- */
+ * @see org.apache.lenya.cms.publication.DocumentIdToPathMapper#getFile(org.apache.lenya.cms.publication.Publication,
+ * java.lang.String, java.lang.String, java.lang.String)
+ */
public File getFile(Publication publication, String area, String documentId, String language) {
File file = new File(getDirectory(publication, area, documentId), getFilename(language));
return file;
}
-
/**
* (non-Javadoc)
*
@@ -45,45 +39,37 @@
public File getDirectory(Publication publication, String area, String documentId, String language) {
return getDirectory(publication, area, documentId);
}
-
/**
- * @deprecated because language is missing
- * (non-Javadoc)
+ * @deprecated because language is missing (non-Javadoc)
*
* @see org.apache.lenya.cms.publication.DocumentIdToPathMapper#getDirectory(org.apache.lenya.cms.publication.Publication,
* java.lang.String, java.lang.String)
*/
public File getDirectory(Publication publication, String area, String documentId) {
- assert documentId.startsWith("/");
+ // assert documentId.startsWith("/");
// remove leading slash
documentId = documentId.substring(1);
documentId = documentId.replace('/', File.separatorChar);
-
- File file =
- new File(
- publication.getDirectory(),
- Publication.CONTENT_PATH + File.separator + area + File.separator + documentId);
-
+ File file = new File(publication.getDirectory(), Publication.CONTENT_PATH + File.separator + area + File.separator + documentId);
return file;
}
-
/**
- * @see org.apache.lenya.cms.publication.DocumentIdToPathMapper#getPath(java.lang.String,
- * java.lang.String)
- */
+ * @see org.apache.lenya.cms.publication.DocumentIdToPathMapper#getPath(java.lang.String,
+ * java.lang.String)
+ */
public String getPath(String documentId, String language) {
- assert documentId.startsWith("/");
+ // assert documentId.startsWith("/");
// remove leading slash
documentId = documentId.substring(1);
return documentId + "/" + getFilename(language);
}
-
/**
- * Constructs the filename for a given language.
- *
- * @param language The language.
- * @return A string value.
- */
+ * Constructs the filename for a given language.
+ *
+ * @param language
+ * The language.
+ * @return A string value.
+ */
protected String getFilename(String language) {
String languageSuffix = "";
if (language != null && !"".equals(language)) {
@@ -91,62 +77,47 @@
}
return BASE_FILENAME_PREFIX + languageSuffix + BASE_FILENAME_SUFFIX;
}
-
/**
* Returns the document ID for a certain file.
*
- * @param publication The publication.
- * @param area The area.
- * @param file The file representing the document.
- * @throws DocumentDoesNotExistException when the document
- * referenced by the file does not exist.
- */
- public String getDocumentId(
- Publication publication,
- String area,
- File file)
- throws DocumentDoesNotExistException {
-
+ * @param publication
+ * The publication.
+ * @param area
+ * The area.
+ * @param file
+ * The file representing the document.
+ * @throws DocumentDoesNotExistException
+ * when the document referenced by the file does not exist.
+ */
+ public String getDocumentId(Publication publication, String area, File file) throws DocumentDoesNotExistException {
String fileName = file.getAbsolutePath();
- String contentDirName =
- publication.getContentDirectory(area).getAbsolutePath();
+ String contentDirName = publication.getContentDirectory(area).getAbsolutePath();
if (fileName.startsWith(contentDirName)) {
// trim everything up to the documentId
- String relativeFileName =
- fileName.substring(contentDirName.length());
+ String relativeFileName = fileName.substring(contentDirName.length());
// trim everything after the documentId
- relativeFileName =
- relativeFileName.substring(
- 0,
- relativeFileName.lastIndexOf(File.separator));
+ relativeFileName = relativeFileName.substring(0, relativeFileName.lastIndexOf(File.separator));
// and replace the os specific separator by '/'
return relativeFileName.replace(File.separatorChar, '/');
} else {
- throw new DocumentDoesNotExistException(
- "No document associated with file" + fileName);
+ throw new DocumentDoesNotExistException("No document associated with file" + fileName);
}
}
-
/**
* Returns the language for a certain file
*
- * @param file the document file
+ * @param file
+ * the document file
*
- * @return the language for the given document file or null if
- * the file has no language.
+ * @return the language for the given document file or null if the file has
+ * no language.
*/
public String getLanguage(File file) {
String fileName = file.getName();
String language = null;
-
// check if the file is of the form index.html or index_en.html
-
- if (fileName.startsWith(BASE_FILENAME_PREFIX)
- && fileName.endsWith(BASE_FILENAME_SUFFIX)) {
- String languageSuffix =
- fileName.substring(
- BASE_FILENAME_PREFIX.length(),
- fileName.indexOf(BASE_FILENAME_SUFFIX));
+ if (fileName.startsWith(BASE_FILENAME_PREFIX) && fileName.endsWith(BASE_FILENAME_SUFFIX)) {
+ String languageSuffix = fileName.substring(BASE_FILENAME_PREFIX.length(), fileName.indexOf(BASE_FILENAME_SUFFIX));
if (languageSuffix.length() > 0) {
// trim the leading '_'
language = languageSuffix.substring(1);
Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/DefaultSiteTree.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/DefaultSiteTree.java?rev=574702&r1=574701&r2=574702&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/DefaultSiteTree.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/DefaultSiteTree.java Tue Sep 11 14:39:37 2007
@@ -14,9 +14,7 @@
* limitations under the License.
*
*/
-
/* @version $Id$ */
-
package org.apache.lenya.cms.publication;
import java.io.File;
@@ -25,10 +23,8 @@
import java.util.Date;
import java.util.List;
import java.util.StringTokenizer;
-
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;
-
import org.apache.lenya.xml.DocumentHelper;
import org.apache.lenya.xml.NamespaceHelper;
import org.apache.log4j.Logger;
@@ -45,67 +41,60 @@
*/
public class DefaultSiteTree implements SiteTree, LastModified {
private static Logger log = Logger.getLogger(DefaultSiteTree.class);
-
private static Object lock = new Object();
-
public static final String SITE_TREE_FILENAME = "sitetree.xml";
-
private Document document = null;
private File treefile = null;
- // the area is only retained to provide some more info when raising an exception.
+ // the area is only retained to provide some more info when raising an
+ // exception.
private String area = "";
-
private long lastModified = 0;
-
/**
* Create a DefaultSiteTree
*
- * @param pubDir the publication directory
- * @param area the area
+ * @param pubDir
+ * the publication directory
+ * @param area
+ * the area
*
- * @throws SiteTreeException if an error occurs
+ * @throws SiteTreeException
+ * 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));
+ 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
- *
- * @deprecated use the DefaultSiteTree(File pubDir, String area) constructor instead.
+ *
+ * @param treefilename
+ * file name of the tree
+ *
+ * @throws SiteTreeException
+ * if an error occurs
+ *
+ * @deprecated use the DefaultSiteTree(File pubDir, String area) constructor
+ * instead.
*/
public DefaultSiteTree(String treefilename) throws SiteTreeException {
this(new File(treefilename));
}
-
/**
* Create a DefaultSiteTree from a file.
- *
- * @param treefile the file containing the tree
*
- * @throws SiteTreeException if an error occurs
+ * @param treefile
+ * the file containing the tree
+ *
+ * @throws SiteTreeException
+ * if an error occurs
*
* @deprecated this constructor will be private in the future
*/
public DefaultSiteTree(File treefile) throws SiteTreeException {
this.treefile = treefile;
-
try {
if (!treefile.isFile()) {
- //the treefile doesn't exist, so create it
-
+ // the treefile doesn't exist, so create it
document = createDocument();
} else {
// Read tree
@@ -118,22 +107,19 @@
} catch (IOException e) {
throw new SiteTreeException(e);
}
-
}
-
/**
- * Checks if the tree file has been modified externally and reloads the site tree.
- * @throws SiteTreeException when something went wrong.
+ * Checks if the tree file has been modified externally and reloads the site
+ * tree.
+ *
+ * @throws SiteTreeException
+ * when something went wrong.
*/
protected synchronized 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) {
@@ -142,220 +128,170 @@
lastModified = treefile.lastModified();
}
}
-
/**
* Create a new DefaultSiteTree xml document.
- *
+ *
* @return the new site document
*
- * @throws ParserConfigurationException if an error occurs
+ * @throws ParserConfigurationException
+ * if an error occurs
*/
public synchronized Document createDocument() throws ParserConfigurationException {
document = DocumentHelper.createDocument(NAMESPACE_URI, "site", null);
-
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 "/".
- *
- * @param node where to start the search
- * @param ids list of node ids
+ * Find a node in a subtree. The search is started at the given node. The
+ * list of ids contains the document-id split by "/".
+ *
+ * @param node
+ * where to start the search
+ * @param ids
+ * list of node ids
*
* @return the node that matches the path given in the list of ids
*/
protected synchronized Node findNode(Node node, List ids) {
-
checkModified();
-
if (ids.size() < 1) {
return node;
} else {
NodeList nodes = node.getChildNodes();
-
for (int i = 0; i < nodes.getLength(); i++) {
NamedNodeMap attributes = nodes.item(i).getAttributes();
-
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()));
}
}
}
}
-
// node wasn't found
return null;
}
-
- /** (non-Javadoc)
- * @see org.apache.lenya.cms.publication.SiteTree#addNode(org.apache.lenya.cms.publication.SiteTreeNode, java.lang.String)
+ /**
+ * (non-Javadoc)
+ *
+ * @see org.apache.lenya.cms.publication.SiteTree#addNode(org.apache.lenya.cms.publication.SiteTreeNode,
+ * java.lang.String)
*/
public synchronized void addNode(SiteTreeNode node, String refDocumentId) throws SiteTreeException {
- this.addNode(
- node.getAbsoluteParentId(),
- node.getId(),
- node.getLabels(),
- node.visibleInNav(),
- node.getHref(),
- node.getSuffix(),
- node.hasLink(),
- refDocumentId);
+ this.addNode(node.getAbsoluteParentId(), node.getId(), node.getLabels(), node.visibleInNav(), 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[])
+ /**
+ * (non-Javadoc)
+ *
+ * @see org.apache.lenya.cms.publication.SiteTree#addNode(java.lang.String,
+ * java.lang.String, org.apache.lenya.cms.publication.Label[])
*/
- public synchronized void addNode(String parentid, String id, Label[] labels, boolean visibleInNav ) throws SiteTreeException {
+ public synchronized void addNode(String parentid, String id, Label[] labels, boolean visibleInNav) throws SiteTreeException {
addNode(parentid, id, labels, visibleInNav, null, null, false);
}
-
- /** (non-Javadoc)
- * @see org.apache.lenya.cms.publication.SiteTree#addNode(java.lang.String, java.lang.String, org.apache.lenya.cms.publication.Label[], boolean)
+ /**
+ * (non-Javadoc)
+ *
+ * @see org.apache.lenya.cms.publication.SiteTree#addNode(java.lang.String,
+ * java.lang.String, org.apache.lenya.cms.publication.Label[], boolean)
*/
public synchronized void addNode(String parentid, String id, Label[] labels) throws SiteTreeException {
addNode(parentid, id, labels, true);
}
-
- /** (non-Javadoc)
+ /**
+ * (non-Javadoc)
+ *
* @see org.apache.lenya.cms.publication.SiteTree#addNode(org.apache.lenya.cms.publication.SiteTreeNode)
*/
public synchronized void addNode(SiteTreeNode node) throws SiteTreeException {
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)
+ /**
+ * (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)
*/
- public synchronized void addNode(
- String documentid,
- Label[] labels,
- boolean visibleInNav,
- String href,
- String suffix,
- boolean link,
- String refDocumentId)
- throws SiteTreeException {
+ public synchronized void addNode(String documentid, Label[] labels, boolean visibleInNav, String href, String suffix, boolean link, String refDocumentId) throws SiteTreeException {
String parentid = "";
StringTokenizer st = new StringTokenizer(documentid, "/");
int length = st.countTokens();
-
for (int i = 0; i < (length - 1); i++) {
parentid = parentid + "/" + st.nextToken();
}
-
String id = st.nextToken();
this.addNode(parentid, id, labels, visibleInNav, 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)
+ /**
+ * (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)
*/
- public synchronized void addNode(
- String documentid,
- Label[] labels,
- boolean visibleInNav,
- String href,
- String suffix,
- boolean link)
- throws SiteTreeException {
+ public synchronized void addNode(String documentid, Label[] labels, boolean visibleInNav, String href, String suffix, boolean link) throws SiteTreeException {
this.addNode(documentid, labels, visibleInNav, 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)
+ /**
+ * (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)
*/
- public synchronized void addNode(
- String parentid,
- String id,
- Label[] labels,
- boolean visibleInNav,
- String href,
- String suffix,
- boolean link)
- throws SiteTreeException {
+ public synchronized void addNode(String parentid, String id, Label[] labels, boolean visibleInNav, String href, String suffix, boolean link) throws SiteTreeException {
this.addNode(parentid, id, labels, visibleInNav, 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)
+ /**
+ * (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)
*/
- public synchronized void addNode(
- String parentid,
- String id,
- Label[] labels,
- boolean visibleInNav,
- String href,
- String suffix,
- boolean link,
- String refDocumentId)
- throws SiteTreeException {
-
+ public synchronized void addNode(String parentid, String id, Label[] labels, boolean visibleInNav, String href, String suffix, boolean link, String refDocumentId) throws SiteTreeException {
Node parentNode = getNodeInternal(parentid);
-
if (parentNode == null) {
- throw new SiteTreeException(
- "Parentid: " + parentid + " in " + area + " tree not found");
+ throw new SiteTreeException("Parentid: " + parentid + " in " + area + " tree not found");
}
-
log.debug("PARENT ELEMENT: " + parentNode);
-
// Check if child already exists
Node childNode = getNodeInternal(parentid + "/" + id);
-
if (childNode != null) {
log.info("This node: " + parentid + "/" + id + " has already been inserted");
-
return;
}
-
// Create node
NamespaceHelper helper = new NamespaceHelper(NAMESPACE_URI, "", document);
Element child = helper.createElement(SiteTreeNodeImpl.NODE_NAME);
child.setAttribute(SiteTreeNodeImpl.ID_ATTRIBUTE_NAME, id);
-
if (visibleInNav) {
child.setAttribute(SiteTreeNodeImpl.VISIBLEINNAV_ATTRIBUTE_NAME, "true");
} else {
child.setAttribute(SiteTreeNodeImpl.VISIBLEINNAV_ATTRIBUTE_NAME, "false");
}
-
if ((href != null) && (href.length() > 0)) {
child.setAttribute(SiteTreeNodeImpl.HREF_ATTRIBUTE_NAME, href);
}
-
if ((suffix != null) && (suffix.length() > 0)) {
child.setAttribute(SiteTreeNodeImpl.SUFFIX_ATTRIBUTE_NAME, suffix);
}
-
if (link) {
child.setAttribute(SiteTreeNodeImpl.LINK_ATTRIBUTE_NAME, "true");
}
-
for (int i = 0; i < labels.length; i++) {
String labelName = labels[i].getLabel();
Element label = helper.createElement(SiteTreeNodeImpl.LABEL_NAME, labelName);
String labelLanguage = labels[i].getLanguage();
-
if ((labelLanguage != null) && (labelLanguage.length() > 0)) {
label.setAttribute(SiteTreeNodeImpl.LANGUAGE_ATTRIBUTE_NAME, labelLanguage);
}
-
child.appendChild(label);
}
-
- // Add Node
+ // Add Node
if (refDocumentId != null && !refDocumentId.equals("")) {
Node nextSibling = getNodeInternal(refDocumentId);
if (nextSibling != null) {
@@ -369,8 +305,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)
+ * (non-Javadoc)
+ *
+ * @see org.apache.lenya.cms.publication.SiteTree#addLabel(java.lang.String,
+ * org.apache.lenya.cms.publication.Label)
*/
public synchronized void addLabel(String documentId, Label label) {
SiteTreeNode node = getNode(documentId);
@@ -378,10 +316,11 @@
node.addLabel(label);
}
}
-
/**
- * (non-Javadoc)
- * @see org.apache.lenya.cms.publication.SiteTree#removeLabel(java.lang.String, org.apache.lenya.cms.publication.Label)
+ * (non-Javadoc)
+ *
+ * @see org.apache.lenya.cms.publication.SiteTree#removeLabel(java.lang.String,
+ * org.apache.lenya.cms.publication.Label)
*/
public synchronized void removeLabel(String documentId, Label label) {
SiteTreeNode node = getNode(documentId);
@@ -389,23 +328,22 @@
node.removeLabel(label);
}
}
-
- /** (non-Javadoc)
+ /**
+ * (non-Javadoc)
+ *
* @see org.apache.lenya.cms.publication.SiteTree#removeNode(java.lang.String)
*/
public synchronized SiteTreeNode removeNode(String documentId) {
- assert documentId != null;
-
+ // assert documentId != null;
Node node = removeNodeInternal(documentId);
-
if (node == null) {
return null;
}
-
return new SiteTreeNodeImpl(node, this);
}
-
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.apache.lenya.cms.publication.SiteTree#deleteNode(java.lang.String)
*/
public void deleteNode(String documentId) throws SiteTreeException {
@@ -413,13 +351,11 @@
Node parentNode = node.getParentNode();
Node newNode = parentNode.removeChild(node);
}
-
-
/**
- * 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
+ * @param documentId
+ * the document-id of the Node to be removed
*
* @return the <code>Node</code> that was removed
*/
@@ -427,68 +363,58 @@
Node node = this.getNodeInternal(documentId);
Node parentNode = node.getParentNode();
Node newNode = parentNode.removeChild(node);
-
return newNode;
}
-
/**
* 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
+ * @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
*/
private synchronized Node getNodeInternal(String documentId) {
StringTokenizer st = new StringTokenizer(documentId, "/");
ArrayList ids = new ArrayList();
-
while (st.hasMoreTokens()) {
ids.add(st.nextToken());
}
-
Node node = findNode(document.getDocumentElement(), ids);
return node;
}
-
/**
* @see org.apache.lenya.cms.publication.SiteTree#getNode(java.lang.String)
*/
public synchronized SiteTreeNode getNode(String documentId) {
- assert documentId != null;
-
+ // assert documentId != null;
SiteTreeNode treeNode = null;
-
Node node = getNodeInternal(documentId);
if (node != null) {
treeNode = new SiteTreeNodeImpl(node, this);
}
-
return treeNode;
}
-
/**
* @see org.apache.lenya.cms.publication.SiteTree#getTopNodes()
*/
public SiteTreeNode[] getTopNodes() {
List childElements = new ArrayList();
-
NamespaceHelper helper = new NamespaceHelper(NAMESPACE_URI, "", document);
-
Element[] elements = helper.getChildren((Element) document.getDocumentElement(), SiteTreeNodeImpl.NODE_NAME);
-
for (int i = 0; i < elements.length; i++) {
SiteTreeNode newNode = new SiteTreeNodeImpl(elements[i], this);
childElements.add(newNode);
}
-
return (SiteTreeNode[]) childElements.toArray(new SiteTreeNode[childElements.size()]);
}
-
/**
* Move up the node amongst its siblings.
*
- * @param documentid The document id for the node.
- * @throws SiteTreeException if the moving failed.
+ * @param documentid
+ * The document id for the node.
+ * @throws SiteTreeException
+ * if the moving failed.
*/
public synchronized void moveUp(String documentid) throws SiteTreeException {
Node node = this.getNodeInternal(documentid);
@@ -497,20 +423,14 @@
}
Node parentNode = node.getParentNode();
if (parentNode == null) {
- throw new SiteTreeException(
- "Parentid of node with documentid: " + documentid + " not found");
+ throw new SiteTreeException("Parentid of node with documentid: " + documentid + " not found");
}
-
Node previousNode;
try {
- previousNode =
- XPathAPI.selectSingleNode(
- node,
- "(preceding-sibling::*[local-name() = 'node'])[last()]");
+ previousNode = XPathAPI.selectSingleNode(node, "(preceding-sibling::*[local-name() = 'node'])[last()]");
} catch (TransformerException e) {
throw new SiteTreeException(e);
}
-
if (previousNode == null) {
log.warn("Couldn't found a preceding sibling");
return;
@@ -518,12 +438,13 @@
Node insertNode = parentNode.removeChild(node);
parentNode.insertBefore(insertNode, previousNode);
}
-
/**
* Move down the node amongst its siblings.
*
- * @param documentid The document id for the node.
- * @throws SiteTreeException if the moving failed.
+ * @param documentid
+ * The document id for the node.
+ * @throws SiteTreeException
+ * if the moving failed.
*/
public synchronized void moveDown(String documentid) throws SiteTreeException {
Node node = this.getNodeInternal(documentid);
@@ -532,21 +453,15 @@
}
Node parentNode = node.getParentNode();
if (parentNode == null) {
- throw new SiteTreeException(
- "Parentid of node with documentid: " + documentid + " not found");
+ throw new SiteTreeException("Parentid of node with documentid: " + documentid + " not found");
}
Node nextNode;
try {
- nextNode =
- XPathAPI.selectSingleNode(
- node,
- "following-sibling::*[local-name() = 'node'][position()=2]");
+ nextNode = XPathAPI.selectSingleNode(node, "following-sibling::*[local-name() = 'node'][position()=2]");
} catch (TransformerException e) {
throw new SiteTreeException(e);
}
-
Node insertNode = parentNode.removeChild(node);
-
if (nextNode == null) {
log.warn("Couldn't found the second following sibling");
parentNode.appendChild(insertNode);
@@ -554,30 +469,18 @@
parentNode.insertBefore(insertNode, nextNode);
}
}
-
- /** (non-Javadoc)
- * @see org.apache.lenya.cms.publication.SiteTree#importSubtree(org.apache.lenya.cms.publication.SiteTreeNode, org.apache.lenya.cms.publication.SiteTreeNode, java.lang.String)
+ /**
+ * (non-Javadoc)
+ *
+ * @see org.apache.lenya.cms.publication.SiteTree#importSubtree(org.apache.lenya.cms.publication.SiteTreeNode,
+ * org.apache.lenya.cms.publication.SiteTreeNode, java.lang.String)
*/
- public synchronized void importSubtree(
- SiteTreeNode newParent,
- SiteTreeNode subtreeRoot,
- String newid,
- String refDocumentId)
- throws SiteTreeException {
- assert subtreeRoot != null;
- assert newParent != null;
+ public synchronized void importSubtree(SiteTreeNode newParent, SiteTreeNode subtreeRoot, String newid, String refDocumentId) throws SiteTreeException {
+ // assert subtreeRoot != null;
+ // assert newParent != null;
String parentId = newParent.getAbsoluteId();
String id = newid;
-
- this.addNode(
- parentId,
- id,
- subtreeRoot.getLabels(),
- subtreeRoot.visibleInNav(),
- subtreeRoot.getHref(),
- subtreeRoot.getSuffix(),
- subtreeRoot.hasLink(),
- refDocumentId);
+ this.addNode(parentId, id, subtreeRoot.getLabels(), subtreeRoot.visibleInNav(), subtreeRoot.getHref(), subtreeRoot.getSuffix(), subtreeRoot.hasLink(), refDocumentId);
newParent = this.getNode(parentId + "/" + id);
if (newParent == null) {
throw new SiteTreeException("The added node was not found.");
@@ -586,30 +489,30 @@
if (children == null) {
log.info("The node " + subtreeRoot.toString() + " has no children");
return;
- } else { for (int i = 0; i < children.length; i++) {
+ } else {
+ for (int i = 0; i < children.length; i++) {
importSubtree(newParent, children[i], children[i].getId(), null);
}
}
}
-
- /** (non-Javadoc)
+ /**
+ * (non-Javadoc)
+ *
* @see org.apache.lenya.cms.publication.SiteTree#save()
*/
public synchronized void save() throws SiteTreeException {
try {
DocumentHelper.writeDocument(document, treefile);
} catch (TransformerException e) {
- throw new SiteTreeException(
- "The document [" + document.getLocalName() + "] could not be transformed");
+ throw new SiteTreeException("The document [" + document.getLocalName() + "] could not be transformed");
} catch (IOException e) {
- throw new SiteTreeException(
- "The saving of document [" + document.getLocalName() + "] failed");
+ throw new SiteTreeException("The saving of document [" + document.getLocalName() + "] failed");
}
- lastModified = new Date().getTime();
+ lastModified = new Date().getTime();
}
-
/**
- * @see org.apache.lenya.cms.publication.SiteTree#setLabel(java.lang.String, org.apache.lenya.cms.publication.Label)
+ * @see org.apache.lenya.cms.publication.SiteTree#setLabel(java.lang.String,
+ * org.apache.lenya.cms.publication.Label)
*/
public synchronized void setLabel(String documentId, Label label) {
SiteTreeNode node = getNode(documentId);
@@ -617,33 +520,25 @@
node.setLabel(label);
}
}
-
/**
- * @see org.apache.lenya.cms.publication.SiteTree#copy(org.apache.lenya.cms.publication.SiteTreeNode, org.apache.lenya.cms.publication.SiteTreeNode, java.lang.String, java.lang.String)
+ * @see org.apache.lenya.cms.publication.SiteTree#copy(org.apache.lenya.cms.publication.SiteTreeNode,
+ * org.apache.lenya.cms.publication.SiteTreeNode, java.lang.String,
+ * java.lang.String)
*/
public void copy(SiteTreeNode src, SiteTreeNode dst, String newId, String followingSibling) throws SiteTreeException {
- assert dst instanceof SiteTreeNodeImpl;
-
- SiteTreeNodeImpl dstNode = (SiteTreeNodeImpl)dst;
+ // assert dst instanceof SiteTreeNodeImpl;
+ SiteTreeNodeImpl dstNode = (SiteTreeNodeImpl) dst;
if (this.equals(dstNode.getDefaultSiteTree())) {
// Copy if this sitetree is the destination sitetree.
- // Acquire global sitetree lock to establish lock hierarchy in case of copy operation
- synchronized(DefaultSiteTree.lock) {
- DefaultSiteTree srcSiteTree = ((SiteTreeNodeImpl)src).getDefaultSiteTree();
- synchronized(srcSiteTree) {
- synchronized(this) {
+ // Acquire global sitetree lock to establish lock hierarchy in case
+ // of copy operation
+ synchronized (DefaultSiteTree.lock) {
+ DefaultSiteTree srcSiteTree = ((SiteTreeNodeImpl) src).getDefaultSiteTree();
+ synchronized (srcSiteTree) {
+ synchronized (this) {
String parentId = dst.getAbsoluteId();
String id = newId;
-
- this.addNode(
- parentId,
- id,
- src.getLabels(),
- src.visibleInNav(),
- src.getHref(),
- src.getSuffix(),
- src.hasLink(),
- followingSibling);
+ this.addNode(parentId, id, src.getLabels(), src.visibleInNav(), src.getHref(), src.getSuffix(), src.hasLink(), followingSibling);
SiteTreeNode node = this.getNode(parentId + "/" + id);
if (node == null) {
throw new SiteTreeException("The added node was not found.");
@@ -665,27 +560,27 @@
dstNode.getDefaultSiteTree().copy(src, dst, newId, followingSibling);
}
}
-
/**
- * @see org.apache.lenya.cms.publication.SiteTree#move(org.apache.lenya.cms.publication.SiteTreeNode, org.apache.lenya.cms.publication.SiteTreeNode, java.lang.String, java.lang.String)
+ * @see org.apache.lenya.cms.publication.SiteTree#move(org.apache.lenya.cms.publication.SiteTreeNode,
+ * org.apache.lenya.cms.publication.SiteTreeNode, java.lang.String,
+ * java.lang.String)
*/
public void move(SiteTreeNode src, SiteTreeNode dst, String newId, String followingSibling) throws SiteTreeException {
- assert dst != null;
- assert src instanceof SiteTreeNodeImpl;
-
- // Acquire global sitetree lock to establish lock hierarchy in case of move operation
- synchronized(DefaultSiteTree.lock) {
+ // assert dst != null;
+ // assert src instanceof SiteTreeNodeImpl;
+ // Acquire global sitetree lock to establish lock hierarchy in case of
+ // move operation
+ synchronized (DefaultSiteTree.lock) {
// Lock both source and destination sitetree.
- synchronized(((SiteTreeNodeImpl)src).getDefaultSiteTree()) {
- synchronized(((SiteTreeNodeImpl)dst).getDefaultSiteTree()) {
+ synchronized (((SiteTreeNodeImpl) src).getDefaultSiteTree()) {
+ synchronized (((SiteTreeNodeImpl) dst).getDefaultSiteTree()) {
copy(src, dst, newId, followingSibling);
- DefaultSiteTree sitetree = ((SiteTreeNodeImpl)src).getDefaultSiteTree();
+ DefaultSiteTree sitetree = ((SiteTreeNodeImpl) src).getDefaultSiteTree();
sitetree.deleteNode(src.getAbsoluteId());
}
}
}
}
-
/**
* @see org.apache.lenya.cms.publication.LastModified#getLastModified()
*/
Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/DocumentSet.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/DocumentSet.java?rev=574702&r1=574701&r2=574702&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/DocumentSet.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/publication/DocumentSet.java Tue Sep 11 14:39:37 2007
@@ -14,9 +14,7 @@
* limitations under the License.
*
*/
-
/* $Id$ */
-
package org.apache.lenya.cms.publication;
import java.util.ArrayList;
@@ -26,52 +24,48 @@
* A set of documents.
*/
public class DocumentSet {
-
/**
- * Ctor.
- */
+ * Ctor.
+ */
public DocumentSet() {
}
-
/**
* Ctor.
- * @param documents The initial documents.
+ *
+ * @param documents
+ * The initial documents.
*/
public DocumentSet(Document[] documents) {
for (int i = 0; i < documents.length; i++) {
add(documents[i]);
}
}
-
private List documents = new ArrayList();
-
/**
- * Returns the documents contained in this set.
- *
- * @return An array of documents.
- */
+ * Returns the documents contained in this set.
+ *
+ * @return An array of documents.
+ */
public Document[] getDocuments() {
return (Document[]) documents.toArray(new Document[documents.size()]);
}
-
/**
- * Adds a document to this set.
- *
- * @param document The document to add.
- */
+ * Adds a document to this set.
+ *
+ * @param document
+ * The document to add.
+ */
public void add(Document document) {
- assert document != null;
- assert !documents.contains(document);
+ // assert document != null;
+ // assert !documents.contains(document);
documents.add(document);
}
-
/**
- * Checks if this set is empty.
- *
- * @return A boolean value.
- */
+ * Checks if this set is empty.
+ *
+ * @return A boolean value.
+ */
public boolean isEmpty() {
return documents.isEmpty();
}
-
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org