Author: andreas
Date: Wed Oct 31 09:48:56 2007
New Revision: 590743
URL: http://svn.apache.org/viewvc?rev=590743&view=rev
Log:
FallbackSourceFactory: remove query string, use fallback:pub://... syntax to pass the publication ID, otherwise problems with double-slash paths occur
Modified:
lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/FallbackSourceFactory.java
Modified: lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/FallbackSourceFactory.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/FallbackSourceFactory.java?rev=590743&r1=590742&r2=590743&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/FallbackSourceFactory.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/FallbackSourceFactory.java Wed Oct 31 09:48:56 2007
@@ -20,6 +20,7 @@
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.Map;
+import java.util.StringTokenizer;
import org.apache.avalon.framework.context.ContextException;
import org.apache.avalon.framework.context.Contextualizable;
@@ -44,7 +45,13 @@
import org.apache.lenya.cms.publication.templating.VisitingSourceResolver;
/**
+ * <p>
* Source factory following the fallback principle.
+ * </p>
+ * <p>
+ * The ID of the current publication can be passed in the URL (<code>fallback:pub://path</code),
+ * this is necessary as a workaround for bug 40564.
+ * </p>
*
* @version $Id$
*/
@@ -73,16 +80,23 @@
}
String path = location.substring(pos + 3);
+
String publicationId = null;
- //allow for template-fallback://{pubid}//{path} for the sake of the
- //cocoon use-store
- if (path.indexOf("//") > 1) {
- pos = path.indexOf("//");
- publicationId = path.substring(0, pos);
- path = path.substring(pos + 2, path.length());
+ // extract publication ID
+ String prefix = location.substring(0, pos);
+ StringTokenizer tokens = new StringTokenizer(prefix, ":");
+ if (tokens.countTokens() > 1) {
+ tokens.nextToken();
+ publicationId = tokens.nextToken();
}
-
+
+ // remove query string
+ int questionMarkIndex = path.indexOf("?");
+ if (questionMarkIndex > -1) {
+ path = path.substring(0, questionMarkIndex);
+ }
+
if (path.length() == 0) {
throw new RuntimeException("The path after the protocol must not be empty!");
}
@@ -100,7 +114,6 @@
templateManager = (PublicationTemplateManager) this.manager.lookup(PublicationTemplateManager.ROLE);
-
Request request = ContextHelper.getRequest(this.context);
if (publicationId == null) {
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.