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/02 17:29:00 UTC
cvs commit: cocoon-lenya/src/java/org/apache/lenya/cms/publication DocumentSet.java LanguageVersions.java DocumentBuilder.java DefaultDocumentBuilder.java
andreas 2003/10/02 08:29:00
Modified: src/java/org/apache/lenya/cms/publication
DocumentBuilder.java DefaultDocumentBuilder.java
Added: src/java/org/apache/lenya/cms/publication DocumentSet.java
LanguageVersions.java
Log:
added DocumentSet and LanguageVersions
Revision Changes Path
1.8 +8 -1 cocoon-lenya/src/java/org/apache/lenya/cms/publication/DocumentBuilder.java
Index: DocumentBuilder.java
===================================================================
RCS file: /home/cvs/cocoon-lenya/src/java/org/apache/lenya/cms/publication/DocumentBuilder.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- DocumentBuilder.java 30 Sep 2003 09:06:46 -0000 1.7
+++ DocumentBuilder.java 2 Oct 2003 15:29:00 -0000 1.8
@@ -116,4 +116,11 @@
String area,
String documentid);
+ /**
+ * Builds a clone of a document for another language.
+ * @param document The document to clone.
+ * @param language The language of the target document.
+ * @return A document.
+ */
+ Document buildLanguageVersion(Document document, String language);
}
1.19 +30 -29 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.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- DefaultDocumentBuilder.java 30 Sep 2003 09:15:30 -0000 1.18
+++ DefaultDocumentBuilder.java 2 Oct 2003 15:29:00 -0000 1.19
@@ -56,7 +56,6 @@
import java.util.HashMap;
-
/**
* @author andreas
* @version $Id$
@@ -88,9 +87,9 @@
*/
public Document buildDocument(Publication publication, String url)
throws DocumentBuildException {
-
+
URLInformation info = new URLInformation(url);
-
+
String documentURL = info.getDocumentUrl();
String originalURL = documentURL;
@@ -110,14 +109,15 @@
String documentId = documentURL;
if (!documentId.startsWith("/")) {
- throw new DocumentBuildException("Document ID [" + documentId +
- "] does not start with '/'!");
+ throw new DocumentBuildException(
+ "Document ID [" + documentId + "] does not start with '/'!");
}
- DefaultDocument document = new DefaultDocument(publication, documentId, info.getArea(), language);
+ 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
@@ -144,7 +144,7 @@
return document;
}
-
+
/**
* Removes all "."-separated extensions from a URL
* (e.g., <code>/foo.print.html</code> is transformed to <code>/foo</code>).
@@ -165,7 +165,7 @@
* @return A string.
*/
protected String getLanguage(String urlWithoutSuffix) {
-
+
String suffix = "";
String url = urlWithoutSuffix;
if (url.length() >= 3 && url.charAt(url.length() - 3) == '_') {
@@ -193,12 +193,10 @@
/**
* @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 {
+ public boolean isDocument(Publication publication, String url) throws DocumentBuildException {
boolean isDocument = false;
- String publicationURI =
- url.substring(("/" + publication.getId()).length());
+ String publicationURI = url.substring(("/" + publication.getId()).length());
if (publicationURI.startsWith("/")) {
publicationURI = publicationURI.substring(1);
@@ -223,15 +221,7 @@
String area,
String documentid,
String language) {
- String url =
- "/"
- + publication.getId()
- + "/"
- + area
- + documentid
- + "_"
- + language
- + ".html";
+ String url = "/" + publication.getId() + "/" + area + documentid + "_" + language + ".html";
return url;
}
@@ -239,12 +229,23 @@
* (non-Javadoc)
* @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) {
- String url =
- "/" + publication.getId() + "/" + area + documentid + ".html";
+ public String buildCanonicalUrl(Publication publication, String area, String documentid) {
+ String url = "/" + publication.getId() + "/" + area + documentid + ".html";
return url;
+ }
+
+ /**
+ * @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());
+ newDocument.setDocumentURL(document.getDocumentURL());
+ return newDocument;
}
}
1.1 cocoon-lenya/src/java/org/apache/lenya/cms/publication/DocumentSet.java
Index: DocumentSet.java
===================================================================
/*
$Id: DocumentSet.java,v 1.1 2003/10/02 15:29:00 andreas Exp $
<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;
import java.util.List;
/**
* A set of documents.
* @author <a href="mailto:andreas@apache.org">Andreas Hartmann</a>
*/
public class DocumentSet {
public DocumentSet() {
}
private List documents = new ArrayList();
public Document[] getDocuments() {
return (Document[]) documents.toArray(new Document[documents.size()]);
}
public void add(Document document) {
assert document != null;
assert !documents.contains(document);
documents.add(document);
}
public boolean isEmpty() {
return documents.isEmpty();
}
}
1.1 cocoon-lenya/src/java/org/apache/lenya/cms/publication/LanguageVersions.java
Index: LanguageVersions.java
===================================================================
/*
$Id: LanguageVersions.java,v 1.1 2003/10/02 15:29:00 andreas Exp $
<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;
/**
* @author <a href="mailto:andreas@apache.org">Andreas Hartmann</a>
*/
public class LanguageVersions extends DocumentSet {
public LanguageVersions(Document document) throws DocumentException {
String[] languages = document.getLanguages();
DefaultDocumentBuilder builder = DefaultDocumentBuilder.getInstance();
for (int i = 0; i < languages.length; i++) {
Document languageVersion = builder.buildLanguageVersion(document, languages[i]);
add(languageVersion);
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: lenya-cvs-unsubscribe@cocoon.apache.org
For additional commands, e-mail: lenya-cvs-help@cocoon.apache.org