svn commit: r627201 - /lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/source/DocumentSourceFactory.java

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

URL: http://svn.apache.org/viewvc?rev=627201&view=rev
Log:
DocumentSourceFactory: throw SourceNotFoundException instead of NPE if the link target doesn't exist.

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

Modified: lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/source/DocumentSourceFactory.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/source/DocumentSourceFactory.java?rev=627201&r1=627200&r2=627201&view=diff
==============================================================================
--- lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/source/DocumentSourceFactory.java (original)
+++ lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/source/DocumentSourceFactory.java Tue Feb 12 16:29:56 2008
@@ -38,6 +38,7 @@
 import org.apache.excalibur.source.Source;
 import org.apache.excalibur.source.SourceException;
 import org.apache.excalibur.source.SourceFactory;
+import org.apache.excalibur.source.SourceNotFoundException;
 import org.apache.excalibur.source.SourceResolver;
 import org.apache.lenya.cms.linking.Link;
 import org.apache.lenya.cms.linking.LinkResolver;
@@ -136,6 +137,10 @@
                 contextualize(link, webappUrl);
                 target = resolver.resolve(factory, link.getUri());
             }
+            
+            if (!target.exists()) {
+                throw new SourceNotFoundException("Source not found: [" + location + "]");
+            }
 
             Document doc = target.getDocument();
 
@@ -160,7 +165,8 @@
                 }
                 return this.sourceResolver.resolveURI(lenyaURL);
             }
-
+        } catch (SourceException e) {
+            throw e;
         } catch (Exception e) {
             throw new RuntimeException(e);
         }
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.