dims        01/02/21 04:17:26

  Modified:    src/org/apache/cocoon/components/language/markup/sitemap/java
                        Tag: xml-cocoon2 sitemap.xsl
               src/org/apache/cocoon/components/language/markup/xsp/java
                        Tag: xml-cocoon2 session.xsl
               src/org/apache/cocoon/environment Tag: xml-cocoon2
                        AbstractEnvironment.java Environment.java
               src/org/apache/cocoon/environment/commandline Tag:
                        xml-cocoon2 AbstractCommandLineEnvironment.java
               src/org/apache/cocoon/environment/http Tag: xml-cocoon2
                        HttpEnvironment.java
               webapp   Tag: xml-cocoon2 sitemap.xmap
               webapp/docs/samples Tag: xml-cocoon2 samples.xml
  Added:       webapp/docs/samples/session Tag: xml-cocoon2 sessionpage.xsp
  Log:
  Patches and Sample from J�rg Prante <[EMAIL PROTECTED]> for Session Handling.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.80  +13 -4     
xml-cocoon/src/org/apache/cocoon/components/language/markup/sitemap/java/Attic/sitemap.xsl
  
  Index: sitemap.xsl
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/markup/sitemap/java/Attic/sitemap.xsl,v
  retrieving revision 1.1.2.79
  retrieving revision 1.1.2.80
  diff -u -r1.1.2.79 -r1.1.2.80
  --- sitemap.xsl       2001/02/19 21:57:47     1.1.2.79
  +++ sitemap.xsl       2001/02/21 12:16:57     1.1.2.80
  @@ -94,7 +94,7 @@
        *
        * @author &lt;a href="mailto:[EMAIL PROTECTED]"&gt;Giacomo 
Pati&lt;/a&gt;
        * @author &lt;a href="mailto:[EMAIL PROTECTED]"&gt;Berin 
Loritsch&lt;/a&gt;
  -     * @version CVS $Id: sitemap.xsl,v 1.1.2.79 2001/02/19 21:57:47 
bloritsch Exp $
  +     * @version CVS $Id: sitemap.xsl,v 1.1.2.80 2001/02/21 12:16:57 dims Exp 
$
        */
       public class <xsl:value-of select="@file-name"/> extends AbstractSitemap 
{
         static final String LOCATION = "<xsl:value-of 
select="translate(@file-path, '/', '.')"/>.<xsl:value-of select="@file-name"/>";
  @@ -850,10 +850,19 @@
           if(true)return resource_<xsl:value-of select="translate(@resource, 
'- ', '__')"/>(pipeline, listOfMaps, environment, cocoon_view);
         </xsl:when>
   
  -      <!-- redirect to a external resource definition. Let the environment 
do the redirect -->
  +      <!-- redirect to a external resource definition with optional session 
mode attribute. Let the environment do the redirect -->
         <xsl:when test="@uri">
  -        getLogger().debug("Redirecting to '<xsl:value-of select="@uri"/>'");
  -        environment.redirect (substitute(listOfMaps, "<xsl:value-of 
select="@uri"/>"));
  +        <xsl:variable name="sess">
  +          <xsl:choose>
  +            <xsl:when test="@session='yes'">true</xsl:when>
  +            <xsl:when test="@session='true'">true</xsl:when>
  +            <xsl:when test="@session='no'">false</xsl:when>
  +            <xsl:when test="@session='false'">false</xsl:when>
  +            <xsl:when test="not(@session)">false</xsl:when>
  +          </xsl:choose>
  +        </xsl:variable>
  +        getLogger().debug("Sitemap: session='<xsl:value-of 
select="$sess"/>', redirecting to '<xsl:value-of select="@uri"/>'");
  +        environment.redirect (<xsl:value-of select="$sess"/>, 
substitute(listOfMaps, "<xsl:value-of select="@uri"/>"));
           if(true)return true;
         </xsl:when>
   
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.3   +42 -0     
xml-cocoon/src/org/apache/cocoon/components/language/markup/xsp/java/Attic/session.xsl
  
  Index: session.xsl
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/markup/xsp/java/Attic/session.xsl,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- session.xsl       2001/02/12 13:36:13     1.1.2.2
  +++ session.xsl       2001/02/21 12:17:03     1.1.2.3
  @@ -292,6 +292,48 @@
       </xsp:logic>
     </xsl:template>
   
  +  <!-- encode an URL with the session ID -->
  +  <xsl:template match="session:encode-url">
  +    <xsl:variable name="href">
  +        "<xsl:value-of select="@href"/>"
  +    </xsl:variable>
  +
  +    <xsp:element name="a">
  +       <xsp:attribute name="href">
  +          <xsp:expr>response.encodeURL(String.valueOf(<xsl:copy-of 
select="$href"/>))</xsp:expr>
  +       </xsp:attribute>
  +       <xsl:value-of select="."/>
  +    </xsp:element>
  +
  +  </xsl:template>
  +
  +  <!-- encode an URL with the session ID as a form-->
  +  <xsl:template match="session:form-encode-url">
  +    <xsl:variable name="action">
  +        "<xsl:value-of select="@action"/>"
  +    </xsl:variable>
  +    <xsl:variable name="method">
  +        "<xsl:value-of select="@method"/>"
  +    </xsl:variable>
  +    <xsl:variable name="onsubmit">
  +        "<xsl:value-of select="@onsubmit"/>"
  +    </xsl:variable>
  +
  +    <xsp:element name="form">
  +       <xsp:attribute name="action">
  +          <xsp:expr>response.encodeURL(String.valueOf(<xsl:copy-of 
select="$action"/>))</xsp:expr>
  +       </xsp:attribute>
  +       <xsp:attribute name="method">
  +         <xsp:expr><xsl:copy-of select="$method"/></xsp:expr>
  +       </xsp:attribute>
  +       <xsp:attribute name="onsubmit">
  +         <xsp:expr><xsl:copy-of select="$onsubmit"/></xsp:expr>
  +       </xsp:attribute>
  +       <xsl:apply-templates/>
  +    </xsp:element>
  +
  +  </xsl:template>
  +
     <xsl:template name="value-for-name">
       <xsl:choose>
         <xsl:when test="@name">"<xsl:value-of select="@name"/>"</xsl:when>
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.10  +1 -1      
xml-cocoon/src/org/apache/cocoon/environment/Attic/AbstractEnvironment.java
  
  Index: AbstractEnvironment.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/environment/Attic/AbstractEnvironment.java,v
  retrieving revision 1.1.2.9
  retrieving revision 1.1.2.10
  diff -u -r1.1.2.9 -r1.1.2.10
  --- AbstractEnvironment.java  2001/02/15 00:59:00     1.1.2.9
  +++ AbstractEnvironment.java  2001/02/21 12:17:05     1.1.2.10
  @@ -134,7 +134,7 @@
       /**
        * Redirect the client to a new URL
        */
  -    public abstract void redirect(String newURL) throws IOException;
  +    public abstract void redirect(boolean sessionmode, String newURL) throws 
IOException;
   
       // Request methods
   
  
  
  
  1.1.2.15  +2 -2      
xml-cocoon/src/org/apache/cocoon/environment/Attic/Environment.java
  
  Index: Environment.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/environment/Attic/Environment.java,v
  retrieving revision 1.1.2.14
  retrieving revision 1.1.2.15
  diff -u -r1.1.2.14 -r1.1.2.15
  --- Environment.java  2001/02/15 00:59:01     1.1.2.14
  +++ Environment.java  2001/02/21 12:17:06     1.1.2.15
  @@ -20,7 +20,7 @@
    * Base interface for an environment abstraction
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
  - * @version CVS $Revision: 1.1.2.14 $ $Date: 2001/02/15 00:59:01 $
  + * @version CVS $Revision: 1.1.2.15 $ $Date: 2001/02/21 12:17:06 $
    */
   
   public interface Environment extends EntityResolver {
  @@ -48,7 +48,7 @@
       /**
        * Redirect to the given URL
        */
  -    void redirect(String url) throws IOException;
  +    void redirect(boolean sessionmode, String url) throws IOException;
   
       /**
        * Set the content type of the generated resource
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.2   +2 -2      
xml-cocoon/src/org/apache/cocoon/environment/commandline/Attic/AbstractCommandLineEnvironment.java
  
  Index: AbstractCommandLineEnvironment.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/environment/commandline/Attic/AbstractCommandLineEnvironment.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- AbstractCommandLineEnvironment.java       2000/10/06 21:25:27     1.1.2.1
  +++ AbstractCommandLineEnvironment.java       2001/02/21 12:17:10     1.1.2.2
  @@ -20,7 +20,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.2.1 $ $Date: 2000/10/06 21:25:27 $
  + * @version CVS $Revision: 1.1.2.2 $ $Date: 2001/02/21 12:17:10 $
    */
   
   public abstract class AbstractCommandLineEnvironment extends 
AbstractEnvironment {
  @@ -37,7 +37,7 @@
       /**
        * Redirect the client to a new URL
        */
  -    public void redirect(String newURL) throws IOException {
  +    public void redirect(boolean sessionmode, String newURL) throws 
IOException {
           throw new RuntimeException (this.getClass().getName() + 
".redirect(String url) method not yet implemented!");
       }
       
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.21  +29 -4     
xml-cocoon/src/org/apache/cocoon/environment/http/Attic/HttpEnvironment.java
  
  Index: HttpEnvironment.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/environment/http/Attic/HttpEnvironment.java,v
  retrieving revision 1.1.2.20
  retrieving revision 1.1.2.21
  diff -u -r1.1.2.20 -r1.1.2.21
  --- HttpEnvironment.java      2001/02/15 20:29:33     1.1.2.20
  +++ HttpEnvironment.java      2001/02/21 12:17:13     1.1.2.21
  @@ -18,6 +18,7 @@
   import javax.servlet.ServletContext;
   import javax.servlet.http.HttpServletRequest;
   import javax.servlet.http.HttpServletResponse;
  +import javax.servlet.http.HttpSession;
   
   import org.apache.cocoon.Constants;
   import org.apache.cocoon.environment.AbstractEnvironment;
  @@ -61,10 +62,34 @@
           this.objectModel.put(Constants.CONTEXT_OBJECT, this.servletContext);
       }
   
  -    /**
  -     * Redirect the client to a new URL
  -     */
  -    public void redirect(String newURL) throws IOException {
  +   /**
  +    *  Redirect the client to new URL with session mode
  +    */
  +    public void redirect(boolean sessionmode, String newURL) throws 
IOException {
  +        if (request == null) {
  +            getLogger().debug("redirect: something's broken, request = 
null");
  +            return;
  +        }
  +        // check if session mode shall be activated
  +        if (sessionmode) {
  +            // The session 
  +            HttpSession session = null;
  +            getLogger().debug("redirect: entering session mode");
  +            String s = request.getRequestedSessionId();
  +            if (s != null) {
  +                getLogger().debug("Old session ID found in request, id = " + 
s);
  +                if ( request.isRequestedSessionIdValid() ) {
  +                    getLogger().debug("And this old session ID is valid");
  +                }
  +            }
  +            // get session from request, or create new session
  +            session = request.getSession(true);
  +            if (session == null) {
  +                getLogger().debug("redirect session mode: unable to get 
session object!");
  +            }
  +            getLogger().debug ("redirect: session mode completed, id = " + 
session.getId() );
  +        }
  +        // redirect
           String qs = request.getQueryString();
           String redirect = this.response.encodeRedirectURL(newURL);
   
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.41  +11 -0     xml-cocoon/webapp/Attic/sitemap.xmap
  
  Index: sitemap.xmap
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/webapp/Attic/sitemap.xmap,v
  retrieving revision 1.1.2.40
  retrieving revision 1.1.2.41
  diff -u -r1.1.2.40 -r1.1.2.41
  --- sitemap.xmap      2001/02/14 18:20:07     1.1.2.40
  +++ sitemap.xmap      2001/02/21 12:17:17     1.1.2.41
  @@ -298,6 +298,17 @@
        <map:serialize/>
      </map:match>
   
  +   <!-- ========================== Session ================================= 
-->
  +   <map:match pattern="session">
  +    <map:redirect-to uri="session/sessionpage.xsp"/>
  +   </map:match>
  +
  +   <map:match pattern="session/*.xsp*">
  +     <map:generate type="serverpages" src="docs/samples/session/{1}.xsp"/>
  +     <map:transform src="stylesheets/dynamic-page2html.xsl"/>
  +     <map:serialize/>
  +   </map:match>
  +
      <!-- ========================= Server ================================ -->
      <map:match pattern="generror">
       <map:generate src="docs/samples/error-giving-page.xml"/>
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.13  +3 -0      xml-cocoon/webapp/docs/samples/Attic/samples.xml
  
  Index: samples.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/webapp/docs/samples/Attic/samples.xml,v
  retrieving revision 1.1.2.12
  retrieving revision 1.1.2.13
  diff -u -r1.1.2.12 -r1.1.2.13
  --- samples.xml       2001/02/11 22:39:07     1.1.2.12
  +++ samples.xml       2001/02/21 12:17:21     1.1.2.13
  @@ -68,6 +68,9 @@
       and table according to the docs/samples/xsp/esql.xsp and the
       docs/samples/sql/sql-page.sql definitions.
      </sample>
  +    <sample name="Session XSP" href="session" xlink:role="dynamic">
  +      Sample Session XSP to illustrate session handling.
  +    </sample>
     </group>
   
     <group name="Sample Forms">
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.1   +24 -0     
xml-cocoon/webapp/docs/samples/session/Attic/sessionpage.xsp
  
  
  
  

Reply via email to