svn commit: r627200 - /lenya/trunk/src/java/org/apache/lenya/cms/publication/PageEnvelope.java

[email protected]
Newsgroups gmane.comp.cms.lenya.cvs
Message-ID <[email protected]>
Author: andreas
Date: Tue Feb 12 16:29:15 2008
New Revision: 627200

URL: http://svn.apache.org/viewvc?rev=627200&view=rev
Log:
PageEnvelope: use DocumentBuilder to extract path if necessary.

Modified:
    lenya/trunk/src/java/org/apache/lenya/cms/publication/PageEnvelope.java

Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/PageEnvelope.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/publication/PageEnvelope.java?rev=627200&r1=627199&r2=627200&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/PageEnvelope.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/PageEnvelope.java Tue Feb 12 16:29:15 2008
@@ -264,14 +264,25 @@
     public String getContext() {
         return this.context;
     }
+    
+    private String path;
 
     /**
-     * Returns the document-path.
-     * @return a <code>File<code> value
+     * Returns the document path. If the current URL doesn't point to a document, the document
+     * builder is used to extract the supposed path from the URL.
+     * @return A string.
      */
     public String getDocumentPath() {
-        return getPublication().getPathMapper().getPath(getDocument().getUUID(),
-                getDocument().getLanguage());
+        if (this.path == null) {
+            final Document doc = getDocument();
+            try {
+                this.path = doc != null ? doc.getPath() :
+                    getPublication().getDocumentBuilder().getLocator(this.factory, this.webappUrl).getPath();
+            } catch (final Exception e) {
+                throw new RuntimeException(e);
+            }
+        }
+        return this.path;
     }
 
     /**
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.