svn commit: r568269 - /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: Tue Aug 21 13:46:55 2007
New Revision: 568269

URL: http://svn.apache.org/viewvc?rev=568269&view=rev
Log:
UuidToUrlTransformer: lookup document extension only if necessary (expensive)

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=568269&r1=568268&r2=568269&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 Tue Aug 21 13:46:55 2007
@@ -113,7 +113,7 @@
 
     protected void handleLink(String linkUrl, AttributeConfiguration config, AttributesImpl newAttrs)
             throws Exception {
-        
+
         URLInformation info = new URLInformation(this.currentUrl);
         if (linkUrl.startsWith("lenya-document:")) {
 
@@ -139,12 +139,11 @@
                 query.removeValue(EXTENSION_PARAM);
                 queryString = query.toString();
             }
-            
+
             LinkTarget target;
             if (this.currentDoc != null) {
                 target = this.linkResolver.resolve(this.currentDoc, linkUri);
-            }
-            else {
+            } else {
                 Link link = new Link(linkUri);
                 link.setPubId(info.getPublicationId());
                 link.setArea(info.getArea());
@@ -183,9 +182,15 @@
         }
     }
 
+    /**
+     * Get the extension of a document. Caution: resolving the extension is expensive!
+     * @param targetDocument The document.
+     * @param requiredExtension The required extension.
+     * @return The required extension or, if it is null, the document's default extension.
+     */
     protected String getExtension(Document targetDocument, String requiredExtension) {
-        String docExtension = targetDocument.getExtension();
-        String extension = requiredExtension != null ? requiredExtension : docExtension;
+        String extension = requiredExtension != null ? requiredExtension : targetDocument
+                .getExtension();
         if (extension.length() > 0) {
             extension = "." + extension;
         }
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.