cziegeler    01/10/08 00:16:29

  Modified:    src/org/apache/cocoon/generation StreamGenerator.java
  Log:
  Fixed (hopefully) dependency to the http environment
  
  Revision  Changes    Path
  1.5       +13 -5     
xml-cocoon2/src/org/apache/cocoon/generation/StreamGenerator.java
  
  Index: StreamGenerator.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/org/apache/cocoon/generation/StreamGenerator.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- StreamGenerator.java      2001/08/20 13:55:15     1.4
  +++ StreamGenerator.java      2001/10/08 07:16:29     1.5
  @@ -13,7 +13,8 @@
   import org.apache.cocoon.ProcessingException;
   import org.apache.cocoon.ResourceNotFoundException;
   import org.apache.cocoon.components.parser.Parser;
  -import org.apache.cocoon.environment.http.HttpRequest;
  +import org.apache.cocoon.environment.Request;
  +import org.apache.cocoon.environment.http.HttpEnvironment;
   import org.apache.cocoon.util.PostInputStream;
   import org.xml.sax.InputSource;
   import org.xml.sax.SAXException;
  @@ -42,7 +43,7 @@
    * number of bytes read is equal to the getContentLength() value.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Kinga Dziembowski</a>
  - * @version $Revision: 1.4 $ $Date: 2001/08/20 13:55:15 $
  + * @version $Revision: 1.5 $ $Date: 2001/10/08 07:16:29 $
    */
   public class StreamGenerator extends ComposerGenerator {
       public static final String CLASS = StreamGenerator.class.getName();
  @@ -75,7 +76,7 @@
           int len = 0;
   
           try {
  -            HttpRequest request = 
(HttpRequest)objectModel.get(Constants.REQUEST_OBJECT);
  +            Request request = 
(Request)objectModel.get(Constants.REQUEST_OBJECT);
               if 
(request.getContentType().equals("application/x-www-form-urlencoded")) {
                   String sXml = request.getParameter(parameter);
                   inputSource = new InputSource(new StringReader(sXml));
  @@ -85,8 +86,15 @@
                   len = request.getContentLength();
   
                   if (len > 0) {
  -                    PostInputStream anStream = new 
PostInputStream(request.getInputStream(), len);
  -                    inputSource = new InputSource(anStream);
  +                    // we have hopefully an http request here
  +                    javax.servlet.http.HttpServletRequest httpRequest =
  +                         
(javax.servlet.http.HttpServletRequest)objectModel.get(HttpEnvironment.HTTP_REQUEST_OBJECT);
  +                    if (httpRequest != null) {
  +                        PostInputStream anStream = new 
PostInputStream(httpRequest.getInputStream(), len);
  +                        inputSource = new InputSource(anStream);
  +                    } else {
  +                        throw new IOException("No http request object 
found");
  +                    }
                   } else {
                       throw new IOException("getContentLen() == 0");
                   }
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     [EMAIL PROTECTED]
To unsubscribe, e-mail:          [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to