svn commit: r676559 - /lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/SiteSource.java

[email protected]
Newsgroups gmane.comp.cms.lenya.cvs
Message-ID <[email protected]>
Author: andreas
Date: Mon Jul 14 04:54:49 2008
New Revision: 676559

URL: http://svn.apache.org/viewvc?rev=676559&view=rev
Log:
Check SiteSource existence when requested with format parameter based on repository source, not SitemapSource

Modified:
    lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/SiteSource.java

Modified: lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/SiteSource.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/SiteSource.java?rev=676559&r1=676558&r2=676559&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/SiteSource.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/SiteSource.java Mon Jul 14 04:54:49 2008
@@ -51,6 +51,7 @@
 
     private ServiceManager manager;
     private Source delegate;
+    private Source repositorySource;
     private String scheme;
     private String uri;
 
@@ -107,6 +108,10 @@
 
             if (site.contains(path, language)) {
                 Document doc = site.getNode(path).getLink(language).getDocument();
+                String lenyaURL = doc.getSourceURI();
+                Session session = RepositoryUtil.getSession(this.manager, request);
+                this.repositorySource = new RepositorySource(manager, lenyaURL, session, getLogger());
+
                 if (locationSteps.hasMoreTokens()) {
                     Query query = new Query(locationSteps.nextToken());
                     String format = query.getValue("format");
@@ -115,9 +120,7 @@
                     }
                 }
                 if (this.delegate == null) {
-                    String lenyaURL = doc.getSourceURI();
-                    Session session = RepositoryUtil.getSession(this.manager, request);
-                    this.delegate = new RepositorySource(manager, lenyaURL, session, getLogger());
+                    this.delegate = this.repositorySource;
                 }
             }
 
@@ -127,11 +130,11 @@
     }
     
     public boolean exists() {
-        return this.delegate != null;
+        return this.repositorySource != null;
     }
 
     public long getContentLength() {
-        return this.delegate == null ? 0 : this.delegate.getContentLength();
+        return !exists() ? 0 : this.delegate.getContentLength();
     }
 
     public InputStream getInputStream() throws IOException, SourceNotFoundException {
@@ -139,11 +142,11 @@
     }
 
     public long getLastModified() {
-        return this.delegate == null ? 0 : this.delegate.getLastModified();
+        return !exists() ? 0 : this.delegate.getLastModified();
     }
 
     public String getMimeType() {
-        return this.delegate == null ? "" : this.delegate.getMimeType();
+        return !exists() ? "" : this.delegate.getMimeType();
     }
 
     public String getScheme() {
@@ -159,7 +162,7 @@
     }
 
     public void refresh() {
-        if (this.delegate != null) {
+        if (exists()) {
             this.delegate.refresh();
         }
     }
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.