cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From craft...@apache.org
Subject cvs commit: xml-cocoon2/src/java/org/apache/cocoon/generation StreamGenerator.java
Date Sat, 28 Sep 2002 16:24:17 GMT
crafterm    2002/09/28 09:24:16

  Modified:    src/java/org/apache/cocoon/generation StreamGenerator.java
  Log:
  Updated class javadoc, and added an explicit check for 'form-name' when
  using a form as the data source (prevents an NPE from being generated
  within the servlet engine).
  
  Revision  Changes    Path
  1.11      +14 -7     xml-cocoon2/src/java/org/apache/cocoon/generation/StreamGenerator.java
  
  Index: StreamGenerator.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/generation/StreamGenerator.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- StreamGenerator.java	19 May 2002 23:13:40 -0000	1.10
  +++ StreamGenerator.java	28 Sep 2002 16:24:16 -0000	1.11
  @@ -69,10 +69,11 @@
    * The <code>StreamGenerator</code> is a class that reads XML from a
    * request InputStream and generates SAX Events.
    *
  - * For the POST requests with mimetype of
  - * application/x-www-form-urlencoded the xml data is expected to be
  - * associated with the name specified in the sitemap parameter.  For
  - * the POST requests with mimetypes: text/plain, text/xml,
  + * For the POST requests with a mimetype of application/x-www-form-urlencoded,
  + * or multipart/form-data the xml data is expected to be associated with the
  + * sitemap parameter 'form-name'.
  + *
  + * For the POST requests with mimetypes: text/plain, text/xml,
    * application/xml the xml data is in the body of the POST request and
    * its length is specified by the value returned by getContentLength()
    * method.  The StreamGenerator uses helper
  @@ -116,7 +117,6 @@
       public void generate() throws IOException, SAXException, ProcessingException
       {
           Parser parser = null;
  -        String parameter = parameters.getParameter(StreamGenerator.FORM_NAME, null);
           int len = 0;
           String contentType = null;
           try {
  @@ -124,8 +124,15 @@
               contentType = request.getContentType();
               if (contentType == null) {
                   throw new IOException("Required header ContentType is missing.");
  -            } else if (contentType.startsWith("application/x-www-form-urlencoded") || 
  +            } else if (contentType.startsWith("application/x-www-form-urlencoded") ||
                       contentType.startsWith("multipart/form-data")) {
  +                String parameter = parameters.getParameter(FORM_NAME, null);
  +                if (parameter == null) {
  +                    throw new ProcessingException(
  +                        "StreamGenerator expects a sitemap parameter called '" +
  +                        FORM_NAME + "' for handling form data"
  +                    );
  +                }
                   String sXml = request.getParameter(parameter);
                   inputSource = new InputSource(new StringReader(sXml));
               } else if (contentType.startsWith("text/plain") ||
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org


Mime
View raw message