svn commit: r575296 - /lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/transformation/UuidToUrlTransformer.java

[email protected]
Newsgroups gmane.comp.cms.lenya.cvs
Message-ID <[email protected]>
Author: andreas
Date: Thu Sep 13 05:48:48 2007
New Revision: 575296

URL: http://svn.apache.org/viewvc?rev=575296&view=rev
Log:
UuidToUrlTransformer: Don't override area and pubId of absolute links. This fixes bug 43378.

Modified:
    lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/transformation/UuidToUrlTransformer.java

Modified: lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/transformation/UuidToUrlTransformer.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/transformation/UuidToUrlTransformer.java?rev=575296&r1=575295&r2=575296&view=diff
==============================================================================
--- lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/transformation/UuidToUrlTransformer.java (original)
+++ lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/transformation/UuidToUrlTransformer.java Thu Sep 13 05:48:48 2007
@@ -18,6 +18,7 @@
 package org.apache.lenya.cms.cocoon.transformation;
 
 import java.io.IOException;
+import java.net.MalformedURLException;
 import java.util.Map;
 import java.util.StringTokenizer;
 
@@ -144,9 +145,7 @@
             if (this.currentDoc != null) {
                 target = this.linkResolver.resolve(this.currentDoc, linkUri);
             } else {
-                Link link = new Link(linkUri);
-                link.setPubId(info.getPublicationId());
-                link.setArea(info.getArea());
+                Link link = getAbsoluteLink(info, linkUri);
                 target = this.linkResolver.resolve(this.factory, link.getUri());
             }
 
@@ -180,6 +179,26 @@
                 }
             }
         }
+    }
+
+    /**
+     * The link is constructed from the linkUri string. If it lacks the area or publication ID
+     * information, these are obtained from the current URL information.
+     * @param info The current URL information.
+     * @param linkUri The link URI to use.
+     * @return A link.
+     * @throws MalformedURLException if the linkUri parameter is malformed.
+     */
+    protected Link getAbsoluteLink(URLInformation info, String linkUri)
+            throws MalformedURLException {
+        Link link = new Link(linkUri);
+        if (link.getPubId() == null) {
+            link.setPubId(info.getPublicationId());
+        }
+        if (link.getArea() == null) {
+            link.setArea(info.getArea());
+        }
+        return link;
     }
 
     /**
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.