You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by st...@locus.apache.org on 2000/05/06 13:13:00 UTC

cvs commit: xml-cocoon/src/org/apache/cocoon Engine.java Utils.java

stefano     00/05/06 04:13:00

  Modified:    src/org/apache/cocoon Engine.java Utils.java
  Log:
  now stylesheet URI are relative to the URI space, even when absolute
  NOTE: I don't know how portable this is. It works on JServ, make sure it works on your system and report back ASAP. Thanks
  
  Revision  Changes    Path
  1.26      +3 -2      xml-cocoon/src/org/apache/cocoon/Engine.java
  
  Index: Engine.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/Engine.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- Engine.java	2000/04/26 23:32:09	1.25
  +++ Engine.java	2000/05/06 11:13:00	1.26
  @@ -1,4 +1,4 @@
  -/*-- $Id: Engine.java,v 1.25 2000/04/26 23:32:09 stefano Exp $ --
  +/*-- $Id: Engine.java,v 1.26 2000/05/06 11:13:00 stefano Exp $ --
   
    ============================================================================
                      The Apache Software License, Version 1.1
  @@ -73,7 +73,7 @@
    * This class implements the engine that does all the document processing.
    *
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version $Revision: 1.25 $ $Date: 2000/04/26 23:32:09 $
  + * @version $Revision: 1.26 $ $Date: 2000/05/06 11:13:00 $
    */
   
   public class Engine implements Defaults {
  @@ -295,6 +295,7 @@
                       environment.put("browser", browsers.map(agent));
                       environment.put("request", request);
                       environment.put("response", response);
  +                    environment.put("context", servletContext);
   
                       // process the document through the document processors
                       while (true) {
  
  
  
  1.14      +28 -9     xml-cocoon/src/org/apache/cocoon/Utils.java
  
  Index: Utils.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/Utils.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- Utils.java	2000/05/03 12:57:36	1.13
  +++ Utils.java	2000/05/06 11:13:00	1.14
  @@ -1,4 +1,4 @@
  -/*-- $Id: Utils.java,v 1.13 2000/05/03 12:57:36 stefano Exp $ --
  +/*-- $Id: Utils.java,v 1.14 2000/05/06 11:13:00 stefano Exp $ --
   
    ============================================================================
                      The Apache Software License, Version 1.1
  @@ -61,7 +61,7 @@
    * Utility methods for Cocoon and its classes.
    *
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version $Revision: 1.13 $ $Date: 2000/05/03 12:57:36 $
  + * @version $Revision: 1.14 $ $Date: 2000/05/06 11:13:00 $
    */
   
   public final class Utils {
  @@ -173,7 +173,7 @@
                 key = key.replace('=',' ').trim(); // remove whitespace and '='
                 attributes.put(key, token);    
             }
  -        } catch(NoSuchElementException nsee) {
  +        } catch (NoSuchElementException nsee) {
             // ignore white-space at the end of pseudo-list
           }
       }
  @@ -230,12 +230,14 @@
        * So, for now, leave the dirty code even if totally deprecated and work
        * out a better solution in the future.
        */
  -    public static String getBasename(HttpServletRequest request, Object context) {
  +    public static final String getBasename(HttpServletRequest request, Object context) {
  +        String path;
  +        
           try {
               // detect if the engine supports at least Servlet API 2.2
               request.getContextPath();
               // we need to check this in case we've been included in a servlet or jsp
  -            String path = (String) request.getAttribute("javax.servlet.include.servlet_path");
  +            path = (String) request.getAttribute("javax.servlet.include.servlet_path");
               // otherwise, we find it out ourselves
               if (path == null) path = request.getServletPath();
   
  @@ -249,8 +251,6 @@
                   throw new RuntimeException("Cannot access non-file/war resources");
               }
           } catch (NoSuchMethodError e) {
  -            String path;
  -            
               // if there is no such method we must be in Servlet API 2.1
               if (request.getPathInfo() != null) {
                   // this must be Apache JServ
  @@ -268,6 +268,25 @@
       }
   
       /*
  +     * Returns the base path for the request.
  +     */
  +    public static final String getBasepath(HttpServletRequest request, Object context) {
  +        String basename = getBasename(request, context);
  +        return basename.substring(0, basename.lastIndexOf('/') + 1);
  +    }
  +
  +    /*
  +     * Returns the base path for the request.
  +     */
  +    public static final String getRootpath(HttpServletRequest request, Object context) {
  +        // FIXME (SM): I have _no_absolute_idea_ how much this is portable. The whole
  +        // architecture should be based on URL rather than Files to allow the 
  +        // use of Servlet 2.2 getResource() to void calling such nasty methods
  +        // but for now, well, it's the best I can do :(
  +        return request.getRealPath("/");
  +    }    
  +
  +    /*
        * Returns the stack trace as a string
        */
       public static final String getStackTraceAsString(Throwable e) {
  @@ -276,7 +295,7 @@
           e.printStackTrace(writer);
           return bytes.toString();
       }
  -    
  +
       /*
        * Returns the resource pointed by the given location.
        */
  @@ -319,5 +338,5 @@
           }
           
           return resource;
  -    }    
  +    }
   }