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 2003/10/29 16:31:13 UTC
cvs commit: cocoon-lenya/src/java/org/apache/lenya/cms/publication DublinCoreProxy.java DefaultDocumentBuilder.java LanguageVersions.java Label.java DefaultDocumentIdToPathMapper.java DocumentSet.java
andreas 2003/10/29 07:31:13
Modified: src/java/org/apache/lenya/cms/publication
DublinCoreProxy.java DefaultDocumentBuilder.java
LanguageVersions.java Label.java
DefaultDocumentIdToPathMapper.java DocumentSet.java
Removed: src/java/org/apache/lenya/cms/publication/xsp
DocumentHelper.java
Log:
- fixed some javadocs
- obtaining correct parent in DocumentHelper
- moving DocumentHelper to publication package
Revision Changes Path
1.3 +2 -1 cocoon-lenya/src/java/org/apache/lenya/cms/publication/DublinCoreProxy.java
Index: DublinCoreProxy.java
===================================================================
RCS file: /home/cvs/cocoon-lenya/src/java/org/apache/lenya/cms/publication/DublinCoreProxy.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DublinCoreProxy.java 28 Aug 2003 11:39:58 -0000 1.2
+++ DublinCoreProxy.java 29 Oct 2003 15:31:12 -0000 1.3
@@ -79,6 +79,7 @@
* Instanciate a dublin core implementation object
*
* @return a real dublin core object
+ * @throws DocumentException when an error occurs.
*/
protected DublinCore instance() throws DocumentException {
if (dcCore == null) {
1.23 +166 -161 cocoon-lenya/src/java/org/apache/lenya/cms/publication/DefaultDocumentBuilder.java
Index: DefaultDocumentBuilder.java
===================================================================
RCS file: /home/cvs/cocoon-lenya/src/java/org/apache/lenya/cms/publication/DefaultDocumentBuilder.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- DefaultDocumentBuilder.java 21 Oct 2003 16:34:36 -0000 1.22
+++ DefaultDocumentBuilder.java 29 Oct 2003 15:31:12 -0000 1.23
@@ -48,219 +48,224 @@
*
*/
public class DefaultDocumentBuilder implements DocumentBuilder {
- /**
+ /**
* Non-public constructor.
*/
- protected DefaultDocumentBuilder() {
- }
+ protected DefaultDocumentBuilder() {
+ }
- private static DefaultDocumentBuilder instance;
+ private static DefaultDocumentBuilder instance;
- /**
+ /**
* Returns the singleton instance.
*
* @return A document builder.
*/
- public static DefaultDocumentBuilder getInstance() {
- if (instance == null) {
- instance = new DefaultDocumentBuilder();
- }
+ public static DefaultDocumentBuilder getInstance() {
+ if (instance == null) {
+ instance = new DefaultDocumentBuilder();
+ }
- return instance;
- }
+ return instance;
+ }
- /**
+ /**
* @see org.apache.lenya.cms.publication.DocumentBuilder#buildDocument(org.apache.lenya.cms.publication.Publication,
* java.lang.String)
*/
- public Document buildDocument(Publication publication, String url)
- throws DocumentBuildException {
+ public Document buildDocument(Publication publication, String url)
+ throws DocumentBuildException {
- URLInformation info = new URLInformation(url);
+ URLInformation info = new URLInformation(url);
- String documentURL = info.getDocumentUrl();
- String originalURL = documentURL;
+ String documentURL = info.getDocumentUrl();
+ String originalURL = documentURL;
- String extension = getExtension(documentURL);
- documentURL = removeExtensions(documentURL);
-
- String language = getLanguage(documentURL);
- String fullLanguage = "".equals(language) ? "" : ("_" + language);
- documentURL = documentURL.substring(0, documentURL.length() - fullLanguage.length());
-
- boolean defaultLanguageForced = false;
- if ("".equals(language)) {
- defaultLanguageForced = true;
- language = publication.getDefaultLanguage();
- }
-
- String documentId = documentURL;
-
- if (!documentId.startsWith("/")) {
- throw new DocumentBuildException(
- "Document ID [" + documentId + "] does not start with '/'!");
- }
-
- DefaultDocument document =
- new DefaultDocument(publication, documentId, info.getArea(), language);
- document.setExtension(extension);
- document.setDocumentURL(originalURL);
-
- if (defaultLanguageForced) {
- // unfortunatelly we cannot count on the document to always be available
- // in the default language. So if the default language is not in the list
- // of available languages for this document, simply use the first available
- // language.
- HashMap languagesMap = new HashMap();
- String[] languages = null;
- try {
- languages = document.getLanguages();
- } catch (DocumentException e) {
- throw new DocumentBuildException(e);
- }
- // If the document has no languages, we'll just leave it
- // as it is (i.e. we leave it at the default language)
- if (languages.length > 0) {
- for (int i = 0; i < languages.length; i++) {
- languagesMap.put(languages[i], languages[i]);
- }
- if (!languagesMap.containsKey(document.getLanguage())) {
- document.setLanguage(languages[0]);
- }
- }
- }
+ String extension = getExtension(documentURL);
+ documentURL = removeExtensions(documentURL);
+
+ String language = getLanguage(documentURL);
+ String fullLanguage = "".equals(language) ? "" : ("_" + language);
+ documentURL = documentURL.substring(0, documentURL.length() - fullLanguage.length());
+
+ boolean defaultLanguageForced = false;
+ if ("".equals(language)) {
+ defaultLanguageForced = true;
+ language = publication.getDefaultLanguage();
+ }
+
+ String documentId = documentURL;
+
+ if (!documentId.startsWith("/")) {
+ throw new DocumentBuildException(
+ "Document ID [" + documentId + "] does not start with '/'!");
+ }
+
+ DefaultDocument document =
+ new DefaultDocument(publication, documentId, info.getArea(), language);
+ document.setExtension(extension);
+ document.setDocumentURL(originalURL);
+
+ if (defaultLanguageForced) {
+ // unfortunatelly we cannot count on the document to always be available
+ // in the default language. So if the default language is not in the list
+ // of available languages for this document, simply use the first available
+ // language.
+ HashMap languagesMap = new HashMap();
+ String[] languages = null;
+ try {
+ languages = document.getLanguages();
+ } catch (DocumentException e) {
+ throw new DocumentBuildException(e);
+ }
+ // If the document has no languages, we'll just leave it
+ // as it is (i.e. we leave it at the default language)
+ if (languages.length > 0) {
+ for (int i = 0; i < languages.length; i++) {
+ languagesMap.put(languages[i], languages[i]);
+ }
+ if (!languagesMap.containsKey(document.getLanguage())) {
+ document.setLanguage(languages[0]);
+ }
+ }
+ }
- return document;
- }
+ return document;
+ }
- /**
+ /**
* Removes all "."-separated extensions from a URL (e.g., <code>/foo.print.html</code> is
* transformed to <code>/foo</code>).
*
- * @param url
- * The URL to trim.
+ * @param url The URL to trim.
* @return A URL string.
*/
- protected String removeExtensions(String url) {
- int dotIndex = url.indexOf(".");
- if (dotIndex > -1) {
- url = url.substring(0, dotIndex);
- }
- return url;
- }
+ protected String removeExtensions(String url) {
+ int dotIndex = url.indexOf(".");
+ if (dotIndex > -1) {
+ url = url.substring(0, dotIndex);
+ }
+ return url;
+ }
- /**
+ /**
* Returns the language of a URL.
*
- * @param urlWithoutSuffix
- * The URL without the suffix.
+ * @param urlWithoutSuffix The URL without the suffix.
* @return A string.
*/
- protected String getLanguage(String urlWithoutSuffix) {
+ protected String getLanguage(String urlWithoutSuffix) {
- String suffix = "";
- String url = urlWithoutSuffix;
- if (url.length() >= 3 && url.charAt(url.length() - 3) == '_') {
- suffix = url.substring(url.length() - 2);
- }
- return suffix;
- }
+ String suffix = "";
+ String url = urlWithoutSuffix;
+ if (url.length() >= 3 && url.charAt(url.length() - 3) == '_') {
+ suffix = url.substring(url.length() - 2);
+ }
+ return suffix;
+ }
- /**
+ /**
* Returns the extension of a URL.
*
- * @param url
- * The URL.
+ * @param url The URL.
* @return The extension.
*/
- protected String getExtension(String url) {
- int startOfSuffix = url.lastIndexOf('.');
- String suffix = "";
-
- if ((startOfSuffix > -1) && !url.endsWith(".")) {
- suffix = url.substring(startOfSuffix + 1);
- }
+ protected String getExtension(String url) {
+ int startOfSuffix = url.lastIndexOf('.');
+ String suffix = "";
+
+ if ((startOfSuffix > -1) && !url.endsWith(".")) {
+ suffix = url.substring(startOfSuffix + 1);
+ }
- return suffix;
- }
+ return suffix;
+ }
- /**
+ /**
* @see org.apache.lenya.cms.publication.DocumentBuilder#isDocument(org.apache.lenya.cms.publication.Publication,
* java.lang.String)
*/
- public boolean isDocument(Publication publication, String url) throws DocumentBuildException {
- boolean isDocument = false;
+ public boolean isDocument(Publication publication, String url) throws DocumentBuildException {
+ boolean isDocument = false;
- String publicationURI = url.substring(("/" + publication.getId()).length());
- if (publicationURI.startsWith("/")) {
- publicationURI = publicationURI.substring(1);
-
- int slashIndex = publicationURI.indexOf("/");
- if (slashIndex > -1) {
- String documentUri = publicationURI.substring(slashIndex);
- if (documentUri.startsWith("/")) {
- isDocument = true;
- }
- }
- }
-
- return isDocument;
- }
-
- protected String buildCanonicalDocumentUrl(
- Publication publication,
- String documentid,
- String language) {
-
- String languageSuffix = "";
- if (!language.equals(publication.getDefaultLanguage())) {
- languageSuffix = "_" + language;
- }
-
- String url = documentid + languageSuffix + ".html";
- return url;
- }
+ String publicationURI = url.substring(("/" + publication.getId()).length());
+ if (publicationURI.startsWith("/")) {
+ publicationURI = publicationURI.substring(1);
+
+ int slashIndex = publicationURI.indexOf("/");
+ if (slashIndex > -1) {
+ String documentUri = publicationURI.substring(slashIndex);
+ if (documentUri.startsWith("/")) {
+ isDocument = true;
+ }
+ }
+ }
- /**
+ return isDocument;
+ }
+
+ /**
+ * Builds the canonical document URL.
+ *
+ * @param publication The publication.
+ * @param documentid The document ID.
+ * @param language The language of the document.
+ * @return A string.
+ */
+ protected String buildCanonicalDocumentUrl(
+ Publication publication,
+ String documentid,
+ String language) {
+
+ String languageSuffix = "";
+ if (!language.equals(publication.getDefaultLanguage())) {
+ languageSuffix = "_" + language;
+ }
+
+ String url = documentid + languageSuffix + ".html";
+ return url;
+ }
+
+ /**
* @see org.apache.lenya.cms.publication.DocumentBuilder#buildCanonicalUrl(org.apache.lenya.cms.publication.Publication,
* java.lang.String, java.lang.String, java.lang.String)
*/
- public String buildCanonicalUrl(
- Publication publication,
- String area,
- String documentid,
- String language) {
+ public String buildCanonicalUrl(
+ Publication publication,
+ String area,
+ String documentid,
+ String language) {
- String documentUrl = buildCanonicalDocumentUrl(publication, documentid, language);
- String url = "/" + publication.getId() + "/" + area + documentUrl;
+ String documentUrl = buildCanonicalDocumentUrl(publication, documentid, language);
+ String url = "/" + publication.getId() + "/" + area + documentUrl;
- return url;
- }
+ return url;
+ }
- /**
+ /**
* @see org.apache.lenya.cms.publication.DocumentBuilder#buildCanonicalUrl(org.apache.lenya.cms.publication.Publication,
* java.lang.String, java.lang.String)
*/
- public String buildCanonicalUrl(Publication publication, String area, String documentId) {
- return buildCanonicalUrl(publication, area, documentId, publication.getDefaultLanguage());
- }
+ public String buildCanonicalUrl(Publication publication, String area, String documentId) {
+ return buildCanonicalUrl(publication, area, documentId, publication.getDefaultLanguage());
+ }
- /**
+ /**
* @see org.apache.lenya.cms.publication.DocumentBuilder#buildLanguageVersion(org.apache.lenya.cms.publication.Document,
* java.lang.String)
*/
- public Document buildLanguageVersion(Document document, String language) {
- DefaultDocument newDocument =
- new DefaultDocument(
- document.getPublication(),
- document.getId(),
- document.getArea(),
- language);
- newDocument.setExtension(document.getExtension());
- String url =
- buildCanonicalDocumentUrl(document.getPublication(), document.getId(), language);
- newDocument.setDocumentURL(url);
+ public Document buildLanguageVersion(Document document, String language) {
+ DefaultDocument newDocument =
+ new DefaultDocument(
+ document.getPublication(),
+ document.getId(),
+ document.getArea(),
+ language);
+ newDocument.setExtension(document.getExtension());
+ String url =
+ buildCanonicalDocumentUrl(document.getPublication(), document.getId(), language);
+ newDocument.setDocumentURL(url);
- return newDocument;
- }
+ return newDocument;
+ }
}
1.4 +8 -1 cocoon-lenya/src/java/org/apache/lenya/cms/publication/LanguageVersions.java
Index: LanguageVersions.java
===================================================================
RCS file: /home/cvs/cocoon-lenya/src/java/org/apache/lenya/cms/publication/LanguageVersions.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- LanguageVersions.java 21 Oct 2003 09:51:55 -0000 1.3
+++ LanguageVersions.java 29 Oct 2003 15:31:12 -0000 1.4
@@ -56,10 +56,17 @@
package org.apache.lenya.cms.publication;
/**
+ * Document set containing all language versions of a document.
+ *
* @author <a href="mailto:andreas@apache.org">Andreas Hartmann</a>
*/
public class LanguageVersions extends DocumentSet {
+ /**
+ * Ctor.
+ * @param document The document.
+ * @throws DocumentException when something went wrong.
+ */
public LanguageVersions(Document document) throws DocumentException {
String[] languages = document.getLanguages();
DocumentBuilder builder = document.getPublication().getDocumentBuilder();
1.7 +3 -3 cocoon-lenya/src/java/org/apache/lenya/cms/publication/Label.java
Index: Label.java
===================================================================
RCS file: /home/cvs/cocoon-lenya/src/java/org/apache/lenya/cms/publication/Label.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- Label.java 12 Sep 2003 17:34:01 -0000 1.6
+++ Label.java 29 Oct 2003 15:31:12 -0000 1.7
@@ -97,7 +97,7 @@
/**
* Set the actual label of the label object.
*
- * @param label
+ * @param label The label.
*/
public void setLabel(String label) {
this.label = label;
1.15 +75 -98 cocoon-lenya/src/java/org/apache/lenya/cms/publication/DefaultDocumentIdToPathMapper.java
Index: DefaultDocumentIdToPathMapper.java
===================================================================
RCS file: /home/cvs/cocoon-lenya/src/java/org/apache/lenya/cms/publication/DefaultDocumentIdToPathMapper.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- DefaultDocumentIdToPathMapper.java 30 Sep 2003 09:08:05 -0000 1.14
+++ DefaultDocumentIdToPathMapper.java 29 Oct 2003 15:31:12 -0000 1.15
@@ -1,93 +1,71 @@
/*
-$Id$
-<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>
-*/
+ * $Id$ <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.publication;
import java.io.File;
/**
* @author egli
- *
- *
+ *
+ *
*/
public class DefaultDocumentIdToPathMapper
implements DocumentIdToPathMapper, PathToDocumentIdMapper {
/**
- * @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));
+ * @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)
- * @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) {
+ * (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("/");
// remove leading slash
documentId = documentId.substring(1);
@@ -96,18 +74,15 @@
File file =
new File(
publication.getDirectory(),
- Publication.CONTENT_PATH
- + File.separator
- + area
- + File.separator
- + documentId);
+ 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("/");
// remove leading slash
@@ -116,10 +91,11 @@
}
/**
- * 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)) {
@@ -128,26 +104,27 @@
return "index" + languageSuffix + ".xml";
}
- public String getDocumentId(
- Publication publication,
- String area,
- File file)
+ /**
+ * 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 {
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
- return relativeFileName.substring(
- 0,
- relativeFileName.lastIndexOf("/"));
+ return relativeFileName.substring(0, relativeFileName.lastIndexOf("/"));
} else {
- throw new DocumentDoesNotExistException(
- "No document associated with file" + fileName);
+ throw new DocumentDoesNotExistException("No document associated with file" + fileName);
}
}
}
1.2 +64 -58 cocoon-lenya/src/java/org/apache/lenya/cms/publication/DocumentSet.java
Index: DocumentSet.java
===================================================================
RCS file: /home/cvs/cocoon-lenya/src/java/org/apache/lenya/cms/publication/DocumentSet.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DocumentSet.java 2 Oct 2003 15:29:00 -0000 1.1
+++ DocumentSet.java 29 Oct 2003 15:31:12 -0000 1.2
@@ -1,58 +1,45 @@
/*
-$Id$
-<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>
-*/
+ * $Id$ <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.publication;
import java.util.ArrayList;
@@ -60,25 +47,44 @@
/**
* A set of documents.
+ *
* @author <a href="mailto:andreas@apache.org">Andreas Hartmann</a>
*/
public class DocumentSet {
+ /**
+ * Ctor.
+ */
public DocumentSet() {
}
-
+
private List documents = new ArrayList();
-
+
+ /**
+ * 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.
+ */
public void add(Document document) {
assert document != null;
assert !documents.contains(document);
documents.add(document);
}
-
+
+ /**
+ * Checks if this set is empty.
+ *
+ * @return A boolean value.
+ */
public boolean isEmpty() {
return documents.isEmpty();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: lenya-cvs-unsubscribe@cocoon.apache.org
For additional commands, e-mail: lenya-cvs-help@cocoon.apache.org