cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From reinh...@apache.org
Subject svn commit: r682356 - /cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/src/main/java/org/apache/cocoon/servletservice/components/ServletSource.java
Date Mon, 04 Aug 2008 12:16:42 GMT
Author: reinhard
Date: Mon Aug  4 05:16:42 2008
New Revision: 682356

URL: http://svn.apache.org/viewvc?rev=682356&view=rev
Log:
. throw exceptions in the case of a SSF self-reference or relative reference because this
always requires a calling SSF request. Only an absolute reference can work without a stand-alone
reference

Modified:
    cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/src/main/java/org/apache/cocoon/servletservice/components/ServletSource.java

Modified: cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/src/main/java/org/apache/cocoon/servletservice/components/ServletSource.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/src/main/java/org/apache/cocoon/servletservice/components/ServletSource.java?rev=682356&r1=682355&r2=682356&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/src/main/java/org/apache/cocoon/servletservice/components/ServletSource.java
(original)
+++ cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-components/src/main/java/org/apache/cocoon/servletservice/components/ServletSource.java
Mon Aug  4 05:16:42 2008
@@ -30,6 +30,7 @@
 import org.apache.cocoon.servletservice.AbsoluteServletConnection;
 import org.apache.cocoon.servletservice.Absolutizable;
 import org.apache.cocoon.servletservice.CallStackHelper;
+import org.apache.cocoon.servletservice.NoCallingServletServiceRequestAvailableException;
 import org.apache.cocoon.servletservice.ServletConnection;
 import org.apache.cocoon.servletservice.postable.PostableSource;
 import org.apache.commons.logging.Log;
@@ -110,11 +111,11 @@
             if (logger.isDebugEnabled()) {
                 logger.debug("Trying to create a servlet connection for location " + location);
             }
-            
+
             locationUri = new URI(location);
             if (!locationUri.isAbsolute()) {
                 throw new MalformedURLException("Only absolute URIs are allowed for the block
protocol. "
-                                + locationUri.toString());
+                        + locationUri.toString());
             }
 
             // get the referenced servlet and find out if it is an absolute or
@@ -128,19 +129,29 @@
             // find out the type of the reference and create a service name
             if (servletReference == null) {
                 // self-reference
+                if (absolutizable == null) {
+                    throw new NoCallingServletServiceRequestAvailableException(
+                            "A self-reference requires an active servlet request.");
+                }
+
                 servletName = absolutizable.getServiceName();
             } else if (servletReference.endsWith(AbsoluteServletConnection.ABSOLUTE_SERVLET_SOURCE_POSTFIX))
{
                 // absolute reference
                 servletName = servletReference.substring(0, servletReference.length() - 1);
             } else {
                 // relative reference
+                if (absolutizable == null) {
+                    throw new NoCallingServletServiceRequestAvailableException(
+                            "A relative servlet call requires an active servlet request.");
+                }
+
                 servletName = absolutizable.getServiceName(servletReference);
             }
+            
             return new AbsoluteServletConnection(servletName, locationUri.getRawPath(), locationUri.getRawQuery());
-
         } catch (URISyntaxException e) {
             MalformedURLException malformedURLException = new MalformedURLException("Invalid
URI syntax. "
-                            + e.getMessage());
+                    + e.getMessage());
             malformedURLException.initCause(e);
             throw malformedURLException;
         }



Mime
View raw message