You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by re...@apache.org on 2008/09/19 14:51:39 UTC

svn commit: r697074 - in /cocoon/trunk/subprojects/cocoon-block-deployment/src: changes/changes.xml main/java/org/apache/cocoon/blockdeployment/BlockContextURLConnection.java

Author: reinhard
Date: Fri Sep 19 05:51:38 2008
New Revision: 697074

URL: http://svn.apache.org/viewvc?rev=697074&view=rev
Log:
check if the requested block is available, otherwise throw an exception that explains what has gone wrong

Modified:
    cocoon/trunk/subprojects/cocoon-block-deployment/src/changes/changes.xml
    cocoon/trunk/subprojects/cocoon-block-deployment/src/main/java/org/apache/cocoon/blockdeployment/BlockContextURLConnection.java

Modified: cocoon/trunk/subprojects/cocoon-block-deployment/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/subprojects/cocoon-block-deployment/src/changes/changes.xml?rev=697074&r1=697073&r2=697074&view=diff
==============================================================================
--- cocoon/trunk/subprojects/cocoon-block-deployment/src/changes/changes.xml (original)
+++ cocoon/trunk/subprojects/cocoon-block-deployment/src/changes/changes.xml Fri Sep 19 05:51:38 2008
@@ -28,6 +28,10 @@
   </properties>
   <body>
     <release version="1.1.0-SNAPSHOT" date="2008-??-??">
+      <action dev="reinhard" type="add">
+        The blockcontext: URLConnection checks if a requested block is available. Otherwise
+        an an exception, that explains what has gone wrong, is thrown.
+      </action>    
       <action dev="gkossakowski" type="add">
         Added implementation of org.apache.cocoon.spring.configurator.BlockResourcesHolder interface to 
         restore back-compatiblity with Cocoon Core 2.2.

Modified: cocoon/trunk/subprojects/cocoon-block-deployment/src/main/java/org/apache/cocoon/blockdeployment/BlockContextURLConnection.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/subprojects/cocoon-block-deployment/src/main/java/org/apache/cocoon/blockdeployment/BlockContextURLConnection.java?rev=697074&r1=697073&r2=697074&view=diff
==============================================================================
--- cocoon/trunk/subprojects/cocoon-block-deployment/src/main/java/org/apache/cocoon/blockdeployment/BlockContextURLConnection.java (original)
+++ cocoon/trunk/subprojects/cocoon-block-deployment/src/main/java/org/apache/cocoon/blockdeployment/BlockContextURLConnection.java Fri Sep 19 05:51:38 2008
@@ -36,10 +36,12 @@
         this.url = url;
     }
 
+    @Override
     public void connect() throws IOException {
         this.getConnection().connect();
     }
 
+    @Override
     public InputStream getInputStream() throws IOException {
         return this.getConnection().getInputStream();
     }
@@ -60,6 +62,11 @@
                 path = path.substring(pos + 1);
                 String blockContext = (String) this.blockContexts.get(blockName);
 
+                if (blockContext == null) {
+                    throw new RuntimeException("There is no block '" + blockName
+                            + "' deployed. The available blocks are " + this.blockContexts + ".");
+                }
+
                 try {
                     resolvedPath = new URL(new URL(blockContext), path);
                     this.urlConnection = resolvedPath.openConnection();
@@ -74,6 +81,7 @@
         return this.urlConnection;
     }
 
+    @Override
     public long getLastModified() {
         return this.getConnection().getLastModified();
     }