You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by eg...@apache.org on 2004/01/07 14:28:54 UTC
cvs commit: cocoon-lenya/src/java/org/apache/lenya/cms/publication DefaultDocumentIdToPathMapper.java
egli 2004/01/07 05:28:54
Modified: src/java/org/apache/lenya/cms/publication
DefaultDocumentIdToPathMapper.java
Log:
Simplified the code and fixed a bug in getLanguage.
Fixes #562.
Revision Changes Path
1.18 +10 -6 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.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- DefaultDocumentIdToPathMapper.java 31 Oct 2003 15:21:04 -0000 1.17
+++ DefaultDocumentIdToPathMapper.java 7 Jan 2004 13:28:54 -0000 1.18
@@ -49,7 +49,7 @@
*/
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)
@@ -137,14 +137,18 @@
* the file has no language.
*/
public String getLanguage(File file) {
- String fileName = file.getAbsolutePath();
+ String fileName = file.getName();
String language = null;
+ String fileNameSuffix = ".xml";
+ String fileNamePrefix = "index";
// check if the file is of the form index.html or index_en.html
- if (fileName.startsWith("index") && fileName.endsWith(".html")) {
+
+ if (fileName.startsWith(fileNamePrefix)
+ && fileName.endsWith(fileNameSuffix)) {
String languageSuffix =
fileName.substring(
- "index".length() - 1,
- fileName.indexOf(".html"));
+ fileNamePrefix.length(),
+ fileName.indexOf(fileNameSuffix));
if (languageSuffix.length() > 0) {
// trim the leading '_'
language = languageSuffix.substring(1);
---------------------------------------------------------------------
To unsubscribe, e-mail: lenya-cvs-unsubscribe@cocoon.apache.org
For additional commands, e-mail: lenya-cvs-help@cocoon.apache.org