giacomo     01/05/10 15:19:37

  Modified:    src/org/apache/cocoon/environment/commandline
                        CommandLineRequest.java FileSavingEnvironment.java
                        LinkSamplingEnvironment.java
  Added:       src/org/apache/cocoon/environment/commandline
                        CommandlineContext.java
  Log:
  Made Commandline mode functional again (more or less).
  
  Revision  Changes    Path
  1.2       +12 -9     
xml-cocoon2/src/org/apache/cocoon/environment/commandline/CommandLineRequest.java
  
  Index: CommandLineRequest.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/org/apache/cocoon/environment/commandline/CommandLineRequest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CommandLineRequest.java   2001/05/09 20:49:44     1.1
  +++ CommandLineRequest.java   2001/05/10 22:19:33     1.2
  @@ -17,6 +17,7 @@
   import java.util.Map;
   import org.apache.cocoon.Constants;
   import org.apache.cocoon.environment.Cookie;
  +import org.apache.cocoon.environment.Environment;
   import org.apache.cocoon.environment.Request;
   import org.apache.cocoon.environment.Session;
   
  @@ -24,7 +25,7 @@
    * Creates a specific servlet request simulation from command line usage.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a>
  - * @version CVS $Revision: 1.1 $ $Date: 2001/05/09 20:49:44 $
  + * @version CVS $Revision: 1.2 $ $Date: 2001/05/10 22:19:33 $
    */
   
   /*
  @@ -55,6 +56,7 @@
           }
       }
   
  +    private Environment env;
       private String contextPath;
       private String servletPath;
       private String pathInfo;
  @@ -63,19 +65,20 @@
       private Map headers;
       private String characterEncoding = null;
   
  -    public CommandLineRequest(String contextPath, String servletPath, String 
pathInfo) {
  -        this(contextPath, servletPath, pathInfo, null, null, null);
  +    public CommandLineRequest(Environment env, String contextPath, String 
servletPath, String pathInfo) {
  +        this(env, contextPath, servletPath, pathInfo, null, null, null);
       }
   
  -    public CommandLineRequest(String contextPath, String servletPath, String 
pathInfo, Map attributes) {
  -        this(contextPath, servletPath, pathInfo, attributes, null, null);
  +    public CommandLineRequest(Environment env, String contextPath, String 
servletPath, String pathInfo, Map attributes) {
  +        this(env, contextPath, servletPath, pathInfo, attributes, null, 
null);
       }
   
  -    public CommandLineRequest(String contextPath, String servletPath, String 
pathInfo, Map attributes, Map parameters) {
  -        this(contextPath, servletPath, pathInfo, attributes, parameters, 
null);
  +    public CommandLineRequest(Environment env, String contextPath, String 
servletPath, String pathInfo, Map attributes, Map parameters) {
  +        this(env, contextPath, servletPath, pathInfo, attributes, 
parameters, null);
       }
   
  -    public CommandLineRequest(String contextPath, String servletPath, String 
pathInfo, Map attributes, Map parameters, Map headers) {
  +    public CommandLineRequest(Environment env, String contextPath, String 
servletPath, String pathInfo, Map attributes, Map parameters, Map headers) {
  +        this.env = env;
           this.contextPath = contextPath;
           this.servletPath = servletPath;
           this.pathInfo = pathInfo;
  @@ -98,7 +101,7 @@
       }
       // FIXME
       public String getSitemapURI() {
  -        return "";
  +        return this.env.getURI();
       }
       public String getQueryString() { return null; } // use parameters instead
       public String getPathTranslated() { return null; } // FIXME (SM) this is 
legal but should we do something more?
  
  
  
  1.2       +2 -2      
xml-cocoon2/src/org/apache/cocoon/environment/commandline/FileSavingEnvironment.java
  
  Index: FileSavingEnvironment.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/org/apache/cocoon/environment/commandline/FileSavingEnvironment.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- FileSavingEnvironment.java        2001/05/09 20:49:44     1.1
  +++ FileSavingEnvironment.java        2001/05/10 22:19:34     1.2
  @@ -22,7 +22,7 @@
    * This environment is used to save the requested file to disk.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a>
  - * @version CVS $Revision: 1.1 $ $Date: 2001/05/09 20:49:44 $
  + * @version CVS $Revision: 1.2 $ $Date: 2001/05/10 22:19:34 $
    */
   
   public class FileSavingEnvironment extends AbstractCommandLineEnvironment {
  @@ -32,7 +32,7 @@
           super(uri, null, context, stream);
           LogKit.getLoggerFor("cocoon").debug("FileSavingEnvironment: uri=" + 
uri);
           this.objectModel.put(Constants.LINK_OBJECT, links);
  -        this.objectModel.put(Constants.REQUEST_OBJECT, new 
CommandLineRequest(null, uri, null, attributes, parameters));
  +        this.objectModel.put(Constants.REQUEST_OBJECT, new 
CommandLineRequest(this, null, uri, null, attributes, parameters));
           this.objectModel.put(Constants.RESPONSE_OBJECT, new 
CommandLineResponse());
       }
   }
  
  
  
  1.2       +2 -2      
xml-cocoon2/src/org/apache/cocoon/environment/commandline/LinkSamplingEnvironment.java
  
  Index: LinkSamplingEnvironment.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/org/apache/cocoon/environment/commandline/LinkSamplingEnvironment.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LinkSamplingEnvironment.java      2001/05/09 20:49:44     1.1
  +++ LinkSamplingEnvironment.java      2001/05/10 22:19:35     1.2
  @@ -30,7 +30,7 @@
    * This environment is sample the links of the resource.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a>
  - * @version CVS $Revision: 1.1 $ $Date: 2001/05/09 20:49:44 $
  + * @version CVS $Revision: 1.2 $ $Date: 2001/05/10 22:19:35 $
    */
   
   public class LinkSamplingEnvironment extends AbstractCommandLineEnvironment {
  @@ -41,7 +41,7 @@
       throws MalformedURLException, IOException {
           super(uri, Constants.LINK_VIEW, contextFile, new 
ByteArrayOutputStream());
           LogKit.getLoggerFor("cocoon").debug("LinkSamplingEnvironment: uri=" 
+ uri);
  -        this.objectModel.put(Constants.REQUEST_OBJECT, new 
CommandLineRequest(null, uri, null, attributes, parameters));
  +        this.objectModel.put(Constants.REQUEST_OBJECT, new 
CommandLineRequest(this, null, uri, null, attributes, parameters));
           this.objectModel.put(Constants.RESPONSE_OBJECT, new 
CommandLineResponse());
       }
   
  
  
  
  1.1                  
xml-cocoon2/src/org/apache/cocoon/environment/commandline/CommandlineContext.java
  
  Index: CommandlineContext.java
  ===================================================================
  /*****************************************************************************
   * Copyright (C) The Apache Software Foundation. All rights reserved.        *
   * ------------------------------------------------------------------------- *
   * This software is published under the terms of the Apache Software License *
   * version 1.1, a copy of which has been included  with this distribution in *
   * the LICENSE file.                                                         *
   
*****************************************************************************/
  package org.apache.cocoon.environment.commandline;
  
  import org.apache.avalon.framework.logger.AbstractLoggable;
  
  import java.lang.String;
  import java.net.MalformedURLException;
  import java.net.URL;
  //import javax.servlet.ServletContext;
  import org.apache.cocoon.environment.Context;
  
  /**
   *
   * Implements the [EMAIL PROTECTED] org.apache.cocoon.environment.Context} 
interface
   */
  
  public class CommandlineContext extends AbstractLoggable implements Context {
  
      /** The context directory path*/
      private String contextDir;
  
      /**
       * Constructs a CommandlineContext object from a ServletContext object
       */
      public CommandlineContext (String contextDir) {
          this.contextDir = contextDir;
      }
  
      public Object getAttribute(String name) {
          getLogger().debug("CommandlineContext: getAttribute=" + name);
          //return servletContext.getAttribute(name);
          return null;
      }
  
      public URL getResource(String path) throws MalformedURLException {
          getLogger().debug("CommandlineContext: getResource=" + path);
          //return servletContext.getResource(path);
          return new URL("file:" + this.contextDir + path);
      }
  
      public String getRealPath(String path) throws MalformedURLException {
          getLogger().debug("CommandlineContext: getRealPath=" + path);
          //return servletContext.getRealPath(path);
          return this.contextDir + path;
      }
  
      public java.lang.String getMimeType(String file) {
          getLogger().debug("CommandlineContext: getMimeType=" + file);
          //return servletContext.getMimeType(file);
          return null;
      }
  }
  
  
  

----------------------------------------------------------------------
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