cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jheym...@apache.org
Subject svn commit: r330548 [41/132] - in /cocoon/whiteboard/maven2/cocoon-flat-layout: ./ cocoon-ajax-block/ cocoon-ajax-block/api/ cocoon-ajax-block/api/src/ cocoon-ajax-block/api/src/main/ cocoon-ajax-block/api/src/main/java/ cocoon-ajax-block/api/src/main/...
Date Thu, 03 Nov 2005 14:00:48 GMT
Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/ForwardRedirector.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/ForwardRedirector.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/ForwardRedirector.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/ForwardRedirector.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,161 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.environment;
+
+import java.io.IOException;
+
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.cocoon.ProcessingException;
+
+/**
+ * A base class for <code>Redirector</code>s that handle forward redirects, i.e. internal
+ * redirects using the "cocoon:" pseudo-protocol.
+ * <p>
+ * Concrete subclasses have to define the <code>cocoonRedirect()</code> method.
+ *
+ * @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
+ * @version CVS $Id: ForwardRedirector.java 30941 2004-07-29 19:56:58Z vgritsenko $
+ */
+public abstract class ForwardRedirector 
+extends AbstractLogEnabled 
+implements Redirector, PermanentRedirector {
+
+    /**
+     * Was there a call to <code>redirect()</code> ?
+     */
+    private boolean hasRedirected = false;
+    
+    /** The <code>Environment to use for redirection (either internal or external) */
+    protected Environment env;
+
+    /**
+     * Constructor
+     */
+    public ForwardRedirector(Environment env) {
+        this.env = env;
+    }
+
+    /**
+     * Redirects to a given URL. If this URL starts with "cocoon:", then an internal
+     * redirect is performed. Otherwise, an external redirect is send to the
+     * environment.
+     */
+    public void redirect(boolean sessionMode, String url) throws IOException, ProcessingException {
+        if (getLogger().isInfoEnabled()) {
+            getLogger().info("Redirecting to '" + url + "'");
+        }
+
+        if (url.startsWith("cocoon:")) {
+            cocoonRedirect(url);
+        } else {
+            this.doRedirect(sessionMode, url, false, false);
+        }
+
+        this.hasRedirected = true;
+    }
+
+    public void permanentRedirect(boolean sessionMode, String url) throws IOException, ProcessingException {
+        if (getLogger().isInfoEnabled()) {
+            getLogger().info("Redirecting to '" + url + "'");
+        }
+
+        if (url.startsWith("cocoon:")) {
+            cocoonRedirect(url);
+        } else {
+            this.doRedirect(sessionMode, url, true, false);
+        }
+
+        this.hasRedirected = true;
+    }
+
+    /**
+     * Unconditionally redirects to a given URL, even it this redirector is part of a
+     * subpipeline.
+     */
+    public void globalRedirect(boolean sessionMode, String url) throws IOException, ProcessingException {
+        if (getLogger().isInfoEnabled()) {
+            getLogger().info("Redirecting to '" + url + "'");
+        }
+
+        // FIXME : how to handle global redirect to cocoon: ?
+        if (url.startsWith("cocoon:")) {
+            cocoonRedirect(url);
+        } else {
+            this.doRedirect(sessionMode, url, false, true);
+        }
+        this.hasRedirected = true;
+    }
+
+    protected abstract void cocoonRedirect(String uri) throws IOException, ProcessingException;
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Redirector#hasRedirected()
+     */
+    public boolean hasRedirected() {
+        return this.hasRedirected;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Redirector#sendStatus(int)
+     */
+    public void sendStatus(int sc) {
+        env.setStatus(sc);
+        this.hasRedirected = true;
+    }
+
+
+    /**
+     * Redirect the client to new URL with session mode
+     */
+    protected void doRedirect(boolean sessionmode, 
+                                String newURL, 
+                                boolean permanent,
+                                boolean global) 
+    throws IOException {
+        final Request request = ObjectModelHelper.getRequest(this.env.getObjectModel());
+        // check if session mode shall be activated
+        if (sessionmode) {
+
+            // The session
+            Session session = null;
+            if (getLogger().isDebugEnabled()) {
+                getLogger().debug("redirect: entering session mode");
+            }
+            String s = request.getRequestedSessionId();
+            if (s != null) {
+                if (getLogger().isDebugEnabled()) {
+                    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) {
+                if (getLogger().isDebugEnabled()) {
+                    getLogger().debug("redirect session mode: unable to get session object!");
+                }
+            }
+            if (getLogger().isDebugEnabled()) {
+                getLogger().debug ("redirect: session mode completed, id = " + session.getId() );
+            }
+        }
+        // redirect
+        this.env.redirect(newURL, global, permanent);
+    }
+
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/ForwardRedirector.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/ObjectModelHelper.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/ObjectModelHelper.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/ObjectModelHelper.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/ObjectModelHelper.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,84 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.environment;
+
+import java.util.Map;
+
+/**
+ * A set of constants and methods to access the content of the object model.
+ * <p>
+ * The object model is a <code>Map</code> used to pass information about the
+ * calling environment to the sitemap and its components (matchers, actions,
+ * transformers, etc).
+ * <p>
+ * This class provides accessors only for the objects in the object model that are
+ * common to every environment and which can thus be used safely. Some environments
+ * provide additional objects, but they are not described here and accessing them
+ * should be done in due cause since this ties the application to that particular
+ * environment.
+ *
+ * @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
+ * @version CVS $Id: ObjectModelHelper.java 312663 2005-10-10 15:05:55Z sylvain $
+ */
+
+public final class ObjectModelHelper {
+
+    /** Key for the environment {@link Request} in the object model. */
+    public final static String REQUEST_OBJECT  = "request";
+
+    /** Key for the environment {@link Response} in the object model. */
+    public final static String RESPONSE_OBJECT = "response";
+
+    /** Key for the environment {@link Context} in the object model. */
+    public final static String CONTEXT_OBJECT  = "context";
+
+    /** Key for the expiration value (Long) in the object model. */
+    public final static String EXPIRES_OBJECT  = "expires";
+    
+    /** Key for the throwable object, only available within a &lt;map:handle-errors>. */
+    public final static String THROWABLE_OBJECT = "throwable";
+
+    /**
+     * Key for a {@link Map} containing information from
+     * a parent request provided to a sub-request (internal processing)
+     */
+    public final static String PARENT_CONTEXT = "parent-context";
+
+
+    private ObjectModelHelper() {
+        // Forbid instantiation
+    }
+
+    public static final Request getRequest(Map objectModel) {
+        return (Request)objectModel.get(REQUEST_OBJECT);
+    }
+
+    public static final Response getResponse(Map objectModel) {
+        return (Response)objectModel.get(RESPONSE_OBJECT);
+    }
+
+    public static final Context getContext(Map objectModel) {
+        return (Context)objectModel.get(CONTEXT_OBJECT);
+    }
+
+    public static final Long getExpires(Map objectModel) {
+        return (Long)objectModel.get(EXPIRES_OBJECT);
+    }
+    
+    public static final Throwable getThrowable(Map objectModel) {
+        return (Throwable)objectModel.get(THROWABLE_OBJECT);
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/ObjectModelHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/PermanentRedirector.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/PermanentRedirector.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/PermanentRedirector.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/PermanentRedirector.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,35 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.environment;
+
+import org.apache.cocoon.ProcessingException;
+import java.io.IOException;
+
+/**
+ * Interface for a permanent redirector abstraction
+ *
+ * @author <a href="mailto:uv@upaya.co.uk">Upayavira</a>
+ * @version CVS $Id: PermanentRedirector.java 30941 2004-07-29 19:56:58Z vgritsenko $
+ */
+
+public interface PermanentRedirector {
+
+    /**
+     * Redirect to the given URL
+     */
+    void permanentRedirect(boolean sessionmode, String url) throws IOException, ProcessingException;
+ }
+

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/PermanentRedirector.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/Redirector.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/Redirector.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/Redirector.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/Redirector.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,48 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.environment;
+
+import org.apache.cocoon.ProcessingException;
+import java.io.IOException;
+
+/**
+ * Interface for an redirector abstraction
+ *
+ * @author <a href="mailto:dims@yahoo.com">Davanum Srinivas</a>
+ * @version CVS $Id: Redirector.java 30941 2004-07-29 19:56:58Z vgritsenko $
+ */
+
+public interface Redirector {
+
+    /**
+     * Redirect to the given URL
+     */
+    void redirect(boolean sessionmode, String url) throws IOException, ProcessingException;
+    void globalRedirect(boolean sessionmode, String url) throws IOException, ProcessingException;
+    
+    /**
+     * Was one of the redirection methods called ?
+     */
+    boolean hasRedirected();
+    
+    /**
+     * Send a content-less response with the given status code.
+     * 
+     * @param sc  an http status code.
+     */
+    void sendStatus(int sc);
+}
+

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/Redirector.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/Request.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/Request.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/Request.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/Request.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,994 @@
+/*
+ * Copyright 1999-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.environment;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.security.Principal;
+import java.util.Enumeration;
+import java.util.Locale;
+import java.util.Map;
+
+/**
+ * Defines an interface to provide client request information .
+ *
+ * A client can bind an object attribute into a <code>Request</code> by name.
+ * The <code>Request</code> interface defines two scopes for storing objects:
+ * <ul>
+ * <li><code>GLOBAL_SCOPE</code>
+ * <li><code>REQUEST_SCOPE</code>
+ * </ul>
+ * All objects stored in the request using the <code>GLOBAL_SCOPE</code> 
+ * are available to all sub requests and the main request associatiated
+ * Objects stored in the request using the <code>REQUEST_SCOPE</code> are
+ * only available for the current (sub) request.
+ * 
+ * @author <a href="mailto:dims@yahoo.com">Davanum Srinivas</a>
+ * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
+ * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
+ * @version $Id: Request.java 202268 2005-06-28 19:03:15Z vgritsenko $
+ */
+public interface Request {
+
+    /**
+     * This constant defines an request wide scope for the request attribute.
+     * @since 2.2
+     */
+    public static final int GLOBAL_SCOPE = 1;
+
+    /**
+     * This constant defines the scope of the request attribute to be
+     * private to the current (sub) request. 
+     * @since 2.2
+     */
+    public static final int REQUEST_SCOPE = 2;
+
+    /**
+     *
+     * Returns the value of the named parameter as an <code>Object</code>,
+     * or <code>null</code> if no parameter of the given name exists.
+     * Basically, this method is similar to {@link #getParameter(String)},
+     * but it returns an object instead. 
+     * This is useful when special processing has been made on these parameters,
+     * for example for file uploads. In this case you get an object 
+     * representing the uploaded file.
+     * If the parameters have not been processed, you either get a String
+     * object if the parameter has one value, or a Collection of Strings
+     * if the parameter has more than one value.
+     * 
+     * @param name        a <code>String</code> specifying the name of
+     *                        the parameter
+     *
+     * @return                an <code>Object</code> containing the value
+     *                        of the parameter, or <code>null</code> if
+     *                        the parameter does not exist
+     *
+     */
+
+    Object get(String name);
+
+    /**
+     *
+     * Returns the value of the named attribute from the <code>GLOBAL_SCOPE</code>
+     * as an <code>Object</code>, or <code>null</code> if no attribute 
+     * of the given name exists.
+     *
+     * @param name        a <code>String</code> specifying the name of
+     *                        the attribute
+     *
+     * @return                an <code>Object</code> containing the value
+     *                        of the attribute, or <code>null</code> if
+     *                        the attribute does not exist
+     *
+     */
+    Object getAttribute(String name);
+
+    /**
+     * Returns an <code>Enumeration</code> containing the
+     * names of the attributes available to this request in the  <code>GLOBAL_SCOPE</code>.
+     * This method returns an empty <code>Enumeration</code>
+     * if the request has no attributes available to it.
+     *
+     *
+     * @return                an <code>Enumeration</code> of strings
+     *                        containing the names
+     *                         of the request's attributes
+     *
+     */
+    Enumeration getAttributeNames();
+
+    /**
+     *
+     * Stores an attribute in this request in the <code>GLOBAL_SCOPE</code>.
+     * Attributes are reset between requests.
+     *
+     * <p>Attribute names should follow the same conventions as
+     * package names. Names beginning with <code>java.*</code>,
+     * <code>javax.*</code>, and <code>com.sun.*</code>, are
+     * reserved for use by Sun Microsystems.
+     *
+     *
+     * @param name                        a <code>String</code> specifying
+     *                                        the name of the attribute
+     *
+     * @param o                                the <code>Object</code> to be stored
+     *
+     */
+    void setAttribute(String name, Object o);
+
+    /**
+     *
+     * Removes an attribute from this request in the <code>GLOBAL_SCOPE</code>.  
+     * This method is not
+     * generally needed as attributes only persist as long as the request
+     * is being handled.
+     *
+     * <p>Attribute names should follow the same conventions as
+     * package names. Names beginning with <code>java.*</code>,
+     * <code>javax.*</code>, and <code>com.sun.*</code>, are
+     * reserved for use by Sun Microsystems.
+     *
+     *
+     * @param name                        a <code>String</code> specifying
+     *                                        the name of the attribute to remove
+     *
+     */
+    void removeAttribute(String name);
+
+    /**
+     * Returns the value of the named attribute from the scope
+     * as an <code>Object</code>, or <code>null</code> if no attribute 
+     * of the given name exists.
+     *
+     * @param name        a <code>String</code> specifying the name of
+     *                        the attribute
+     * @param scope        scope (global or request) of the attribute
+     *
+     * @return                an <code>Object</code> containing the value
+     *                        of the attribute, or <code>null</code> if
+     *                        the attribute does not exist
+     *
+     * @since 2.2
+     */
+    Object getAttribute(String name, int scope);
+
+    /**
+     * Returns the value of the named attribute searching both scopes
+     * as an <code>Object</code>, or <code>null</code> if no attribute 
+     * of the given name exists. This method first searches in the 
+     * request scope and then, if no object is found, in the global scope.
+     *
+     * @param name        a <code>String</code> specifying the name of
+     *                        the attribute
+     *
+     * @return                an <code>Object</code> containing the value
+     *                        of the attribute, or <code>null</code> if
+     *                        the attribute does not exist
+     *
+     * @since 2.2
+     */
+    Object searchAttribute(String name);
+
+    /**
+     * Returns an <code>Enumeration</code> containing the
+     * names of the attributes available to this request in the scope.
+     * This method returns an empty <code>Enumeration</code>
+     * if the request has no attributes available to it.
+     *
+     * @param scope        scope (global or request) of the attribute
+     *
+     * @return                an <code>Enumeration</code> of strings
+     *                        containing the names
+     *                         of the request's attributes
+     *
+     * @since 2.2
+     */
+    Enumeration getAttributeNames(int scope);
+
+    /**
+     *
+     * Stores an attribute in this request in the scope.
+     * Attributes are reset between requests.
+     *
+     * <p>Attribute names should follow the same conventions as
+     * package names. Names beginning with <code>java.*</code>,
+     * <code>javax.*</code>, and <code>com.sun.*</code>, are
+     * reserved for use by Sun Microsystems.
+     *
+     *
+     * @param name                        a <code>String</code> specifying
+     *                                    the name of the attribute    
+     * @param o                            the <code>Object</code> to be stored
+     * @param scope        scope (global or request) of the attribute
+     *
+     * @since 2.2
+     */
+    void setAttribute(String name, Object o, int scope);
+
+    /**
+     * Removes an attribute from this request in the scope.  
+     * This method is not
+     * generally needed as attributes only persist as long as the request
+     * is being handled.
+     *
+     * <p>Attribute names should follow the same conventions as
+     * package names. Names beginning with <code>java.*</code>,
+     * <code>javax.*</code>, and <code>com.sun.*</code>, are
+     * reserved for use by Sun Microsystems.
+     *
+     *
+     * @param name                        a <code>String</code> specifying
+     *                                        the name of the attribute to remove
+     * @param scope        scope (global or request) of the attribute
+     *
+     * @since 2.2
+     */
+    void removeAttribute(String name, int scope);
+
+    /**
+     * Utility method for getting a <code>Map</code> view of the request attributes.
+     * Returns a <code>Map</code> with attributes from the <code>GLOBAL_SCOPE</code>.
+     *
+     * @return                a <code>Map</code> containing the request attributes.
+     *
+     * @since 2.2
+     */
+    Map getAttributes();
+
+    /**
+     *
+     * Returns the name of the authentication scheme used to protect
+     * the servlet, for example, "BASIC" or "SSL," or null if the servlet was
+     * not protected
+     *
+     * @return                The name of the authentication scheme used to
+     *                        protect the servlet, or null if the servlet was
+     *                        not protected
+     */
+
+    String getAuthType();
+
+    /**
+     * Returns the name of the character encoding used in the body of this
+     * request. This method returns <code>null</code> if the request
+     * does not specify a character encoding
+     *
+     *
+     * @return                a <code>String</code> containing the name of
+     *                        the chararacter encoding, or <code>null</code>
+     *                        if the request does not specify a character encoding
+     *
+     */
+
+    String getCharacterEncoding();
+
+    /**
+     * Overrides the charactor encoding of parameters.
+     *
+     * @throws java.io.UnsupportedEncodingException if this is not a valid encoding.
+     *
+     */
+
+    void setCharacterEncoding(String enc) throws java.io.UnsupportedEncodingException;
+
+    /**
+     * Returns the length, in bytes, of the request body
+     *
+     * @return                an integer containing the length of the
+     *                         request body or -1 if the length is not known
+     *
+     */
+
+    int getContentLength();
+
+    /**
+     * Returns the MIME type of the body of the request
+     *
+     * @return                a <code>String</code> containing the name
+     *                        of the MIME type of
+     *                         the request, or -1 if the type is not known
+     *
+     */
+
+    String getContentType();
+
+    /**
+     * Returns the value of a request parameter as a <code>String</code>,
+     *
+     * @param name         a <code>String</code> specifying the
+     *                        name of the parameter
+     *
+     * @return                a <code>String</code> representing the
+     *                        single value of the parameter
+     *
+     * @see                 #getParameterValues(String)
+     *
+     */
+
+    String getParameter(String name);
+
+    /**
+     *
+     * Returns an <code>Enumeration</code> of <code>String</code>
+     * objects containing the names of the parameters contained
+     * in this request. If the request has
+     * no parameters, the method returns an
+     * empty <code>Enumeration</code>.
+     *
+     * @return                an <code>Enumeration</code> of <code>String</code>
+     *                        objects, each <code>String</code> containing
+     *                         the name of a request parameter; or an
+     *                        empty <code>Enumeration</code> if the
+     *                        request has no parameters
+     *
+     */
+
+    Enumeration getParameterNames();
+
+    /**
+     * Returns an array of <code>String</code> objects containing
+     * all of the values the given request parameter has, or
+     * <code>null</code> if the parameter does not exist.
+     *
+     * <p>If the parameter has a single value, the array has a length
+     * of 1.
+     *
+     * @param name        a <code>String</code> containing the name of
+     *                        the parameter whose value is requested
+     *
+     * @return                an array of <code>String</code> objects
+     *                        containing the parameter's values
+     *
+     * @see                #getParameter(String)
+     *
+     */
+
+    String[] getParameterValues(String name);
+
+
+    /**
+     * Utility method for getting a <code>Map</code> view of the request parameters.
+     * Returns a <code>Map</code> with request parameters.
+     *
+     * @return                a <code>Map</code> containing the request parameters.
+     *
+     * @since 2.2
+     */
+    Map getParameters();
+
+    /**
+     * Returns the name and version of the protocol the request uses
+     * in the form <i>protocol/majorVersion.minorVersion</i>, for
+     * example, HTTP/1.1. For HTTP servlets, the value
+     * returned is the same as the value of the CGI variable
+     * <code>SERVER_PROTOCOL</code>.
+     *
+     * @return                a <code>String</code> containing the protocol
+     *                        name and version number
+     *
+     */
+
+    String getProtocol();
+
+    /**
+     * Returns the name of the scheme used to make this request,
+     * for example,
+     * <code>http</code>, <code>https</code>, or <code>ftp</code>.
+     * Different schemes have different rules for constructing URLs,
+     * as noted in RFC 1738.
+     *
+     * @return                a <code>String</code> containing the name
+     *                        of the scheme used to make this request
+     *
+     */
+
+    String getScheme();
+
+    /**
+     * Returns the host name of the server that received the request.
+     * For HTTP servlets, same as the value of the CGI variable
+     * <code>SERVER_NAME</code>.
+     *
+     * @return                a <code>String</code> containing the name
+     *                        of the server to which the request was sent
+     */
+
+    String getServerName();
+
+    /**
+     * Returns the port number on which this request was received.
+     * For HTTP servlets, same as the value of the CGI variable
+     * <code>SERVER_PORT</code>.
+     *
+     * @return                an integer specifying the port number
+     *
+     */
+
+    int getServerPort();
+
+    /**
+     * Returns the Internet Protocol (IP) address of the client
+     * that sent the request.  For HTTP servlets, same as the value of the
+     * CGI variable <code>REMOTE_ADDR</code>.
+     *
+     * @return                a <code>String</code> containing the
+     *                        IP address of the client that sent the request
+     *
+     */
+
+    String getRemoteAddr();
+
+    /**
+     * Returns the fully qualified name of the client that sent the
+     * request, or the IP address of the client if the name cannot be
+     * determined. For HTTP servlets, same as the value of the CGI variable
+     * <code>REMOTE_HOST</code>.
+     *
+     * @return                a <code>String</code> containing the fully qualified name
+     *                        of the client
+     *
+     */
+
+    String getRemoteHost();
+
+    /**
+     *
+     * Returns the preferred <code>Locale</code> that the client will
+     * accept content in, based on the Accept-Language header.
+     * If the client request doesn't provide an Accept-Language header,
+     * this method returns the default locale for the server.
+     *
+     *
+     * @return                the preferred <code>Locale</code> for the client
+     *
+     */
+
+    Locale getLocale();
+
+    /**
+     *
+     * Returns an <code>Enumeration</code> of <code>Locale</code> objects
+     * indicating, in decreasing order starting with the preferred locale, the
+     * locales that are acceptable to the client based on the Accept-Language
+     * header.
+     * If the client request doesn't provide an Accept-Language header,
+     * this method returns an <code>Enumeration</code> containing one
+     * <code>Locale</code>, the default locale for the server.
+     *
+     *
+     * @return                an <code>Enumeration</code> of preferred
+     *                  <code>Locale</code> objects for the client
+     *
+     */
+
+    Enumeration getLocales();
+
+    /**
+     *
+     * Returns a boolean indicating whether this request was made using a
+     * secure channel, such as HTTPS.
+     *
+     *
+     * @return                a boolean indicating if the request was made using a
+     *                  secure channel
+     *
+     */
+
+    boolean isSecure();
+
+    /**
+     *
+     * Returns an array containing all of the <code>Cookie</code>
+     * objects the client sent with this request.
+     * This method returns <code>null</code> if no cookies were sent.
+     *
+     * @return                an array of all the <code>Cookies</code>
+     *                        included with this request, or <code>null</code>
+     *                        if the request has no cookies
+     *
+     *
+     */
+
+    Cookie[] getCookies();
+
+    /**
+     * Returns a map of the <code>Cookie</code> objects the client sent
+     * with this request, indexed by name. This method returns an empty
+     * map if no cookies were sent.
+     *
+     * @return a Map of <code>Cookie</code> objects
+     */
+    Map getCookieMap();
+
+    /**
+     *
+     * Returns the value of the specified request header
+     * as a <code>long</code> value that represents a
+     * <code>Date</code> object. Use this method with
+     * headers that contain dates, such as
+     * <code>If-Modified-Since</code>.
+     *
+     * <p>The date is returned as
+     * the number of milliseconds since January 1, 1970 GMT.
+     * The header name is case insensitive.
+     *
+     * <p>If the request did not have a header of the
+     * specified name, this method returns -1. If the header
+     * can't be converted to a date, the method throws
+     * an <code>IllegalArgumentException</code>.
+     *
+     * @param name                a <code>String</code> specifying the
+     *                                name of the header
+     *
+     * @return                        a <code>long</code> value
+     *                                representing the date specified
+     *                                in the header expressed as
+     *                                the number of milliseconds
+     *                                since January 1, 1970 GMT,
+     *                                or -1 if the named header
+     *                                was not included with the
+     *                                reqest
+     *
+     * @exception        IllegalArgumentException        If the header value
+     *                                                        can't be converted
+     *                                                        to a date
+     *
+     */
+
+    long getDateHeader(String name);
+
+    /**
+     *
+     * Returns the value of the specified request header
+     * as a <code>String</code>. If the request did not include a header
+     * of the specified name, this method returns <code>null</code>.
+     * The header name is case insensitive. You can use
+     * this method with any request header.
+     *
+     * @param name                a <code>String</code> specifying the
+     *                                header name
+     *
+     * @return                        a <code>String</code> containing the
+     *                                value of the requested
+     *                                header, or <code>null</code>
+     *                                if the request does not
+     *                                have a header of that name
+     *
+     */
+
+    String getHeader(String name);
+
+    /**
+     *
+     * Returns all the values of the specified request header
+     * as an <code>Enumeration</code> of <code>String</code> objects.
+     *
+     * <p>Some headers, such as <code>Accept-Language</code> can be sent
+     * by clients as several headers each with a different value rather than
+     * sending the header as a comma separated list.
+     *
+     * <p>If the request did not include any headers
+     * of the specified name, this method returns an empty
+     * <code>Enumeration</code>.
+     * The header name is case insensitive. You can use
+     * this method with any request header.
+     *
+     * @param name                a <code>String</code> specifying the
+     *                                header name
+     *
+     * @return                        a <code>Enumeration</code> containing the
+     *                                values of the requested
+     *                                header, or <code>null</code>
+     *                                if the request does not
+     *                                have any headers of that name
+     *
+     */
+
+    Enumeration getHeaders(String name);
+
+    /**
+     *
+     * Returns an enumeration of all the header names
+     * this request contains. If the request has no
+     * headers, this method returns an empty enumeration.
+     *
+     * <p>Some servlet containers do not allow do not allow
+     * servlets to access headers using this method, in
+     * which case this method returns <code>null</code>
+     *
+     * @return                        an enumeration of all the
+     *                                header names sent with this
+     *                                request; if the request has
+     *                                no headers, an empty enumeration;
+     *                                if the servlet container does not
+     *                                allow servlets to use this method,
+     *                                <code>null</code>
+     *
+     */
+
+    Enumeration getHeaderNames();
+    
+    /**
+     * Utility method for getting a <code>Map</code> view of the request headers.
+     * Returns a <code>Map</code> with request headers.
+     *
+     * @return                a <code>Map</code> containing the request headers.
+     *
+     * @since 2.2
+     */
+    Map getHeaders();
+
+    /**
+     * Retrieves the body of the request as binary data using 
+     * an <code>InputStream</code>.
+     * 
+     * @return                        an <code>InputStream</code>
+     *                                containing the body of the request.
+     * 
+     * @throws IOException            if an input or output exception occurred
+     * @throws UnsupportedOperationException
+     */
+    InputStream getInputStream() throws IOException, UnsupportedOperationException;
+
+    /**
+     *
+     * Returns the name of the HTTP method with which this
+     * request was made, for example, GET, POST, or PUT.
+     * Same as the value of the CGI variable REQUEST_METHOD.
+     *
+     * @return                        a <code>String</code>
+     *                                specifying the name
+     *                                of the method with which
+     *                                this request was made
+     *
+     */
+
+    String getMethod();
+
+    /**
+     *
+     * Returns any extra path information associated with
+     * the URL the client sent when it made this request.
+     * The extra path information follows the servlet path
+     * but precedes the query string.
+     * This method returns <code>null</code> if there
+     * was no extra path information.
+     *
+     * <p>Same as the value of the CGI variable PATH_INFO.
+     *
+     *
+     * @return                a <code>String</code> specifying
+     *                        extra path information that comes
+     *                        after the servlet path but before
+     *                        the query string in the request URL;
+     *                        or <code>null</code> if the URL does not have
+     *                        any extra path information
+     *
+     */
+
+    String getPathInfo();
+
+    /**
+     *
+     * Returns any extra path information after the servlet name
+     * but before the query string, and translates it to a real
+     * path. Same as the value of the CGI variable PATH_TRANSLATED.
+     *
+     * <p>If the URL does not have any extra path information,
+     * this method returns <code>null</code>.
+     *
+     *
+     * @return                a <code>String</code> specifying the
+     *                        real path, or <code>null</code> if
+     *                        the URL does not have any extra path
+     *                        information
+     *
+     *
+     */
+
+    String getPathTranslated();
+
+    /**
+     *
+     * Returns the portion of the request URI that indicates the context
+     * of the request.  The context path always comes first in a request
+     * URI.  The path starts with a "/" character but does not end with a "/"
+     * character.  For servlets in the default (root) context, this method
+     * returns "".
+     *
+     *
+     * @return                a <code>String</code> specifying the
+     *                        portion of the request URI that indicates the context
+     *                        of the request
+     *
+     *
+     */
+
+    String getContextPath();
+
+    /**
+     *
+     * Returns the query string that is contained in the request
+     * URL after the path. This method returns <code>null</code>
+     * if the URL does not have a query string. Same as the value
+     * of the CGI variable QUERY_STRING.
+     *
+     * @return                a <code>String</code> containing the query
+     *                        string or <code>null</code> if the URL
+     *                        contains no query string
+     *
+     */
+
+    String getQueryString();
+
+    /**
+     *
+     * Returns the login of the user making this request, if the
+     * user has been authenticated, or <code>null</code> if the user
+     * has not been authenticated.
+     * Whether the user name is sent with each subsequent request
+     * depends on the browser and type of authentication. Same as the
+     * value of the CGI variable REMOTE_USER.
+     *
+     * @return                a <code>String</code> specifying the login
+     *                        of the user making this request, or <code>null</code
+     *                        if the user login is not known
+     *
+     */
+
+    String getRemoteUser();
+
+    /**
+     *
+     * Returns the login of the user making this request, if the
+     * user has been authenticated, or <code>null</code> if the user
+     * has not been authenticated.
+     * Whether the user name is sent with each subsequent request
+     * depends on the browser and type of authentication. Same as the
+     * value of the CGI variable REMOTE_USER.
+     *
+     * @return                a <code>String</code> specifying the login
+     *                        of the user making this request, or <code>null</code
+     *                        if the user login is not known
+     *
+     */
+
+    Principal getUserPrincipal();
+
+    /**
+     *
+     * Checks whether the currently logged in user is in a specified role.
+     *
+     * @return                        <code>true</code> if the user is
+     *                                authenticated and in the role;
+     *                                otherwise, <code>false</code>
+     *
+     *
+     * @see                        #getRemoteUser()
+     *
+     */
+
+    boolean isUserInRole(String role);
+
+    /**
+     *
+     * Returns the session ID specified by the client. This may
+     * not be the same as the ID of the actual session in use.
+     * For example, if the request specified an old (expired)
+     * session ID and the server has started a new session, this
+     * method gets a new session with a new ID. If the request
+     * did not specify a session ID, this method returns
+     * <code>null</code>.
+     *
+     *
+     * @return                a <code>String</code> specifying the session
+     *                        ID, or <code>null</code> if the request did
+     *                        not specify a session ID
+     *
+     * @see                #isRequestedSessionIdValid()
+     *
+     */
+
+    String getRequestedSessionId();
+
+    /**
+     *
+     * Returns the part of this request's URL from the protocol
+     * name up to the query string in the first line of the HTTP request.
+     * For example:
+     *
+     * <blockquote>
+     * <table>
+     * <tr align=left><th>First line of HTTP request<th>
+     * <th>Returned Value
+     * <tr><td>POST /some/path.html HTTP/1.1<td><td>/some/path.html
+     * <tr><td>GET http://foo.bar/a.html HTTP/1.0
+     * <td><td>http://foo.bar/a.html
+     * <tr><td>HEAD /xyz?a=b HTTP/1.1<td><td>/xyz
+     * </table>
+     * </blockquote>
+     * 
+     * For internal requests, this method returns
+     * the information for the original/external request!
+     *
+     * @return                a <code>String</code> containing
+     *                        the part of the URL from the
+     *                        protocol name up to the query string
+     */
+    String getRequestURI();
+
+    /**
+     * <p>
+     * Returns the URI of the requested resource as interpreted by the sitemap.
+     * For example, if your webapp is mounted at "/webapp" and the HTTP request
+     * is for "/webapp/foo", this method returns "foo". Consequently, if the
+     * request is for "/webapp", this method returns an empty string.
+     * </p>
+     * <p>
+     * Note that if the request is mapped to a pipeline that contains
+     * aggregated content, and if this method is called in the context of
+     * one of the aggregated parts (e.g. a server page), this method will
+     * return the URI of the aggregated part, not the original requested URI.
+     * </p>
+     *
+     * @return a <code>String</code> containing the URL as mangled by the
+     *         sitemap
+     */
+    String getSitemapURI();
+
+    /**
+     * <p>
+     * Returns the URI Prefix of the requested resource where the sitemap is mounted.
+     * For example, if your webapp is mounted at "/webapp" and the HTTP request
+     * is for "/webapp/foo", this method returns "webapp/".
+     * </p>
+     *
+     * @return a <code>String</code> containing the URI prefix as mangled by the
+     *         sitemap
+     */
+
+    String getSitemapURIPrefix();
+
+    /**
+     * <p>
+     * Returns the path to the sitemap of the requested resource as interpreted 
+     * by the sitemap.
+     * For example, if your webapp is mounted at "webapp" and the HTTP request
+     * is for "webapp/foo", this method returns "webapp/". Consequently, if the
+     * request is for "foo", this method returns the empty string.
+     * </p>
+     *
+     * @return a <code>String</code> containing the path to the sitemap
+     * @since 2.2
+     */
+
+    String getSitemapPath();
+    
+    /**
+     *
+     * Returns the part of this request's URL that calls
+     * the servlet. This includes either the servlet name or
+     * a path to the servlet, but does not include any extra
+     * path information or a query string. Same as the value
+     * of the CGI variable SCRIPT_NAME.
+     *
+     *
+     * @return                a <code>String</code> containing
+     *                        the name or path of the servlet being
+     *                        called, as specified in the request URL
+     *
+     *
+     */
+
+    String getServletPath();
+
+    /**
+     *
+     * Returns the current <code>Session</code>
+     * associated with this request or, if if there is no
+     * current session and <code>create</code> is true, returns
+     * a new session.
+     *
+     * <p>If <code>create</code> is <code>false</code>
+     * and the request has no valid <code>Session</code>,
+     * this method returns <code>null</code>.
+     *
+     * <p>To make sure the session is properly maintained,
+     * you must call this method before
+     * the response is committed.
+     *
+     *
+     *
+     *
+     * @param create          <code>true</code> to create
+     *                        a new session for this request if necessary;
+     *                        <code>false</code> to return <code>null</code>
+     *                        if there's no current session
+     *
+     *
+     * @return                 the <code>Session</code> associated
+     *                        with this request or <code>null</code> if
+     *                         <code>create</code> is <code>false</code>
+     *                        and the request has no valid session
+     *
+     * @see        #getSession()
+     *
+     *
+     */
+
+    Session getSession(boolean create);
+
+    /**
+     *
+     * Returns the current session associated with this request,
+     * or if the request does not have a session, creates one.
+     *
+     * @return                the <code>Session</code> associated
+     *                        with this request
+     *
+     * @see        #getSession(boolean)
+     *
+     */
+
+     Session getSession();
+
+    /**
+     *
+     * Checks whether the requested session ID is still valid.
+     *
+     * @return                        <code>true</code> if this
+     *                                request has an id for a valid session
+     *                                in the current session context;
+     *                                <code>false</code> otherwise
+     *
+     * @see                        #getRequestedSessionId()
+     * @see                        #getSession()
+     *
+     */
+
+    boolean isRequestedSessionIdValid();
+
+    /**
+     *
+     * Checks whether the requested session ID came in as a cookie.
+     *
+     * @return                        <code>true</code> if the session ID
+     *                                came in as a
+     *                                cookie; otherwise, <code>false</code>
+     *
+     *
+     * @see                        #getSession()
+     *
+     */
+
+    boolean isRequestedSessionIdFromCookie();
+
+    /**
+     *
+     * Checks whether the requested session ID came in as part of the
+     * request URL.
+     *
+     * @return                        <code>true</code> if the session ID
+     *                                came in as part of a URL; otherwise,
+     *                                <code>false</code>
+     *
+     *
+     * @see                        #getSession()
+     *
+     */
+
+    boolean isRequestedSessionIdFromURL();
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/Request.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/Response.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/Response.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/Response.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/Response.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,234 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.environment;
+
+import java.util.Locale;
+
+/**
+ * Defines an interface to provide client response information .
+ *
+ * @author <a href="mailto:dims@yahoo.com">Davanum Srinivas</a>
+ * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
+ * @version CVS $Id: Response.java 160568 2005-04-08 17:33:05Z sylvain $
+ *
+ */
+
+public interface Response {
+
+    /**
+     * Returns the name of the charset used for
+     * the MIME body sent in this response.
+     *
+     * <p>If no charset has been assigned, it is implicitly
+     * set to <code>ISO-8859-1</code> (<code>Latin-1</code>).
+     *
+     * <p>See RFC 2047 (http://ds.internic.net/rfc/rfc2045.txt)
+     * for more information about character encoding and MIME.
+     *
+     * @return                a <code>String</code> specifying the
+     *                        name of the charset, for
+     *                        example, <code>ISO-8859-1</code>
+     *
+     */
+
+    String getCharacterEncoding();
+
+    /**
+     * Sets the locale of the response, setting the headers (including the
+     * Content-Type's charset) as appropriate.  By default, the response locale
+     * is the default locale for the server.
+     *
+     * @param loc  the locale of the response
+     *
+     * @see                 #getLocale()
+     *
+     */
+
+    void setLocale(Locale loc);
+
+    /**
+     * Returns the locale assigned to the response.
+     *
+     *
+     * @see                 #setLocale(Locale)
+     *
+     */
+
+    Locale getLocale();
+
+    /**
+     * Constructs a cookie with a specified name and value.
+     *
+     * <p>The name must conform to RFC 2109. That means it can contain
+     * only ASCII alphanumeric characters and cannot contain commas,
+     * semicolons, or white space or begin with a $ character. The cookie's
+     * name cannot be changed after creation.
+     *
+     * <p>The value can be anything the server chooses to send. Its
+     * value is probably of interest only to the server. The cookie's
+     * value can be changed after creation with the
+     * <code>setValue</code> method.
+     *
+     * <p>By default, cookies are created according to the Netscape
+     * cookie specification. The version can be changed with the
+     * <code>setVersion</code> method.
+     *
+     *
+     * @param name                         a <code>String</code> specifying the name of the cookie
+     *
+     * @param value                        a <code>String</code> specifying the value of the cookie
+     *
+     * @throws IllegalArgumentException        if the cookie name contains illegal characters
+     *                                        (for example, a comma, space, or semicolon)
+     *                                        or it is one of the tokens reserved for use
+     *                                        by the cookie protocol
+     *
+     */
+    Cookie createCookie(String name, String value);
+
+    /**
+     * Adds the specified cookie to the response.  This method can be called
+     * multiple times to set more than one cookie.
+     *
+     * @param cookie the Cookie to return to the client
+     *
+     */
+
+    void addCookie(Cookie cookie);
+
+    /**
+     * Returns a boolean indicating whether the named response header
+     * has already been set.
+     *
+     * @param        name        the header name
+     * @return                <code>true</code> if the named response header
+     *                        has already been set;
+     *                         <code>false</code> otherwise
+     */
+
+    boolean containsHeader(String name);
+
+    /**
+     * Encodes the specified URL by including the session ID in it,
+     * or, if encoding is not needed, returns the URL unchanged.
+     * The implementation of this method includes the logic to
+     * determine whether the session ID needs to be encoded in the URL.
+     * For example, if the browser supports cookies, or session
+     * tracking is turned off, URL encoding is unnecessary.
+     *
+     * <p>For robust session tracking, all URLs emitted by a servlet
+     * should be run through this
+     * method.  Otherwise, URL rewriting cannot be used with browsers
+     * which do not support cookies.
+     *
+     * @param        url        the url to be encoded.
+     * @return                the encoded URL if encoding is needed;
+     *                         the unchanged URL otherwise.
+     */
+
+    String encodeURL(String url);
+
+    /**
+     *
+     * Sets a response header with the given name and
+     * date-value.  The date is specified in terms of
+     * milliseconds since the epoch.  If the header had already
+     * been set, the new value overwrites the previous one.  The
+     * <code>containsHeader</code> method can be used to test for the
+     * presence of a header before setting its value.
+     *
+     * @param        name        the name of the header to set
+     * @param        date        the assigned date value
+     *
+     * @see #containsHeader(String)
+     * @see #addDateHeader(String, long)
+     */
+
+    void setDateHeader(String name, long date);
+
+    /**
+     *
+     * Adds a response header with the given name and
+     * date-value.  The date is specified in terms of
+     * milliseconds since the epoch.  This method allows response headers
+     * to have multiple values.
+     *
+     * @param        name        the name of the header to set
+     * @param        date        the additional date value
+     *
+     * @see #setDateHeader(String, long)
+     */
+
+    void addDateHeader(String name, long date);
+
+    /**
+     *
+     * Sets a response header with the given name and value.
+     * If the header had already been set, the new value overwrites the
+     * previous one.  The <code>containsHeader</code> method can be
+     * used to test for the presence of a header before setting its
+     * value.
+     *
+     * @param        name        the name of the header
+     * @param        value        the header value
+     *
+     * @see #containsHeader(String)
+     * @see #addHeader(String, String)
+     */
+
+    void setHeader(String name, String value);
+
+    /**
+     * Adds a response header with the given name and value.
+     * This method allows response headers to have multiple values.
+     *
+     * @param        name        the name of the header
+     * @param        value        the additional header value
+     *
+     * @see #setHeader(String, String)
+     */
+
+    void addHeader(String name, String value);
+
+    /**
+     * Sets a response header with the given name and
+     * int value. If the header had already
+     * been set, the new value overwrites the previous one.  The
+     * <code>containsHeader</code> method can be used to test for the
+     * presence of a header before setting its value.
+     *
+     * @param        name        the name of the header to set
+     * @param        value       the assigned int value
+     *
+     * @see #containsHeader(String)
+     * @see #addIntHeader(String, int)
+     */
+
+    void setIntHeader(String name, int value);
+
+    /**
+     * Adds a response header with the given name and
+     * int value. This method allows response headers
+     * to have multiple values.
+     *
+     * @param        name        the name of the header to set
+     * @param        value       the additional int value
+     *
+     * @see #setIntHeader(String, int)
+     */
+
+    void addIntHeader(String name, int value);
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/Response.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/Session.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/Session.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/Session.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/Session.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,240 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.environment;
+
+import java.util.Enumeration;
+import java.util.Map;
+
+/**
+ *
+ * Provides a way to identify a user across more than one page
+ * request or visit to a Web site and to store information about that user.
+ *
+ * <p>Cocoon uses this interface to create a session
+ * between a client and the "cocoon server". The session persists
+ * for a specified time period, across more than one connection or
+ * page request from the user. A session usually corresponds to one
+ * user, who may visit a site many times. The server can maintain a
+ * session in many ways such as using cookies or rewriting URLs.
+ *
+ * <p>This interface allows Cocoon to
+ * <ul>
+ * <li>View and manipulate information about a session, such as
+ *     the session identifier, creation time, and last accessed time
+ * <li>Bind objects to sessions, allowing user information to persist
+ *     across multiple user connections
+ * </ul>
+ *
+ * <p>Session information is scoped only to the current context
+ * (<code>Context</code>), so information stored in one context
+ * will not be directly visible in another.
+ *
+ * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
+ * @version CVS $Id: Session.java 170542 2005-05-17 08:10:19Z danielf $
+ *
+ */
+
+public interface Session {
+
+    /**
+     *
+     * Returns the time when this session was created, measured
+     * in milliseconds since midnight January 1, 1970 GMT.
+     *
+     * @return                                a <code>long</code> specifying
+     *                                         when this session was created,
+     *                                        expressed in
+     *                                        milliseconds since 1/1/1970 GMT
+     *
+     * @exception IllegalStateException        if this method is called on an
+     *                                        invalidated session
+     *
+     */
+    long getCreationTime();
+
+    /**
+     *
+     * Returns a string containing the unique identifier assigned
+     * to this session. The identifier is assigned
+     * by the context container and is implementation dependent.
+     *
+     * @return                                a string specifying the identifier
+     *                                        assigned to this session
+     *
+     * @exception IllegalStateException        if this method is called on an
+     *                                        invalidated session
+     *
+     */
+    String getId();
+
+    /**
+     *
+     * Returns the last time the client sent a request associated with
+     * this session, as the number of milliseconds since midnight
+     * January 1, 1970 GMT.
+     *
+     * <p>Actions that your application takes, such as getting or setting
+     * a value associated with the session, do not affect the access
+     * time.
+     *
+     * @return                                a <code>long</code>
+     *                                        representing the last time
+     *                                        the client sent a request associated
+     *                                        with this session, expressed in
+     *                                        milliseconds since 1/1/1970 GMT
+     *
+     * @exception IllegalStateException        if this method is called on an
+     *                                        invalidated session
+     *
+     */
+
+    long getLastAccessedTime();
+
+    /**
+     *
+     * Specifies the time, in seconds, between client requests before the
+     * contextcontainer will invalidate this session.  A negative time
+     * indicates the session should never timeout.
+     *
+     * @param interval                An integer specifying the number
+     *                                 of seconds
+     *
+     */
+    void setMaxInactiveInterval(int interval);
+
+   /**
+    * Returns the maximum time interval, in seconds, that
+    * the context container will keep this session open between
+    * client accesses. After this interval, the context container
+    * will invalidate the session.  The maximum time interval can be set
+    * with the <code>setMaxInactiveInterval</code> method.
+    * A negative time indicates the session should never timeout.
+    *
+    *
+    * @return                an integer specifying the number of
+    *                        seconds this session remains open
+    *                        between client requests
+    *
+    * @see                #setMaxInactiveInterval(int)
+    *
+    *
+    */
+    int getMaxInactiveInterval();
+
+    /**
+     *
+     * Returns the object bound with the specified name in this session, or
+     * <code>null</code> if no object is bound under the name.
+     *
+     * @param name                a string specifying the name of the object
+     *
+     * @return                        the object with the specified name
+     *
+     * @exception IllegalStateException        if this method is called on an
+     *                                        invalidated session
+     *
+     */
+    Object getAttribute(String name);
+
+    /**
+     *
+     * Returns an <code>Enumeration</code> of <code>String</code> objects
+     * containing the names of all the objects bound to this session.
+     *
+     * @return                        an <code>Enumeration</code> of
+     *                                <code>String</code> objects specifying the
+     *                                names of all the objects bound to
+     *                                this session
+     *
+     * @exception IllegalStateException        if this method is called on an
+     *                                        invalidated session
+     *
+     */
+    Enumeration getAttributeNames();
+
+    /**
+     * Binds an object to this session, using the name specified.
+     * If an object of the same name is already bound to the session,
+     * the object is replaced.
+     *
+     *
+     * @param name                        the name to which the object is bound;
+     *                                        cannot be null
+     *
+     * @param value                        the object to be bound; cannot be null
+     *
+     * @exception IllegalStateException        if this method is called on an
+     *                                        invalidated session
+     *
+     */
+    void setAttribute(String name, Object value);
+
+    /**
+     *
+     * Removes the object bound with the specified name from
+     * this session. If the session does not have an object
+     * bound with the specified name, this method does nothing.
+     *
+     *
+     * @param name                                the name of the object to
+     *                                                remove from this session
+     *
+     * @exception IllegalStateException        if this method is called on an
+     *                                        invalidated session
+     */
+    void removeAttribute(String name);
+
+    /**
+     * Utility method for getting a <code>Map</code> view of the request attributes.
+     * Returns a <code>Map</code> with attributes.
+     *
+     * @return                a <code>Map</code> containing the request attributes.
+     *
+     * @since 2.2
+     */
+    Map getAttributes();
+
+    /**
+     *
+     * Invalidates this session
+     * to it.
+     *
+     * @exception IllegalStateException        if this method is called on an
+     *                                        already invalidated session
+     *
+     */
+    void invalidate();
+
+    /**
+     *
+     * Returns <code>true</code> if the client does not yet know about the
+     * session or if the client chooses not to join the session.  For
+     * example, if the server used only cookie-based sessions, and
+     * the client had disabled the use of cookies, then a session would
+     * be new on each request.
+     *
+     * @return                                 <code>true</code> if the
+     *                                        server has created a session,
+     *                                        but the client has not yet joined
+     *
+     * @exception IllegalStateException        if this method is called on an
+     *                                        already invalidated session
+     *
+     */
+    boolean isNew();
+
+}
+

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/Session.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/SourceResolver.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/SourceResolver.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/SourceResolver.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/SourceResolver.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,33 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.environment;
+
+/**
+ * Base interface for resolving a source by system identifiers. This 
+ * component is a special extension of the Avalon Excalibur 
+ * {@link org.apache.excalibur.source.SourceResolver} that is only
+ * used for Cocoon sitemap components.
+ *
+ * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
+ * @version CVS $Id: SourceResolver.java 165284 2005-04-29 09:24:28Z cziegeler $
+ */
+
+public interface SourceResolver
+extends org.apache.excalibur.source.SourceResolver {
+
+    // no methods to add
+}
+

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/SourceResolver.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/TemplateObjectModelHelper.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/TemplateObjectModelHelper.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/TemplateObjectModelHelper.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/TemplateObjectModelHelper.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,195 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.environment;
+
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.cocoon.components.flow.FlowHelper;
+import org.apache.cocoon.components.flow.javascript.fom.FOM_JavaScriptFlowHelper;
+import org.apache.commons.jxpath.DynamicPropertyHandler;
+import org.apache.commons.jxpath.JXPathBeanInfo;
+import org.apache.commons.jxpath.JXPathIntrospector;
+import org.mozilla.javascript.Context;
+import org.mozilla.javascript.NativeJavaPackage;
+import org.mozilla.javascript.Scriptable;
+import org.mozilla.javascript.ScriptableObject;
+
+
+/**
+ * This is an utility class to create an object model which is similar to the one
+ * used in flow, that can be used from every component.
+ * 
+ * Work-in-progress, derived from JXTemplateGenerator
+ * 
+ * @version CVS $Id: TemplateObjectModelHelper.java 307316 2005-10-08 17:20:59Z cziegeler $
+ */
+public class TemplateObjectModelHelper {
+    private static Scriptable rootScope = null;
+    
+    /** Avoid instantiation */
+    private TemplateObjectModelHelper() {}
+
+    public static Scriptable getScope() {
+        Context ctx = Context.enter();
+        try {
+            // Create it if never used up to now
+            if (rootScope == null)
+                rootScope = ctx.initStandardObjects(null);
+            
+            Scriptable scope = ctx.newObject(rootScope);
+            scope.setPrototype(rootScope);
+            scope.setParentScope(null);
+            return scope;
+        } finally {
+            Context.exit();
+        }
+    }
+    
+    public static void fillContext(Object contextObject, Map map) {
+        // Hack: I use jxpath to populate the context object's properties
+        // in the jexl context
+        final JXPathBeanInfo bi =
+            JXPathIntrospector.getBeanInfo(contextObject.getClass());
+        if (bi.isDynamic()) {
+            Class cl = bi.getDynamicPropertyHandlerClass();
+            try {
+                DynamicPropertyHandler h =
+                    (DynamicPropertyHandler) cl.newInstance();
+                String[] result = h.getPropertyNames(contextObject);
+                int len = result.length;
+                for (int i = 0; i < len; i++) {
+                    try {
+                        map.put(result[i], h.getProperty(contextObject, result[i]));
+                    } catch (Exception exc) {
+                        exc.printStackTrace();
+                    }
+                }
+            } catch (Exception ignored) {
+                ignored.printStackTrace();
+            }
+        } else {
+            PropertyDescriptor[] props =  bi.getPropertyDescriptors();
+            int len = props.length;
+            for (int i = 0; i < len; i++) {
+                try {
+                    Method read = props[i].getReadMethod();
+                    if (read != null) {
+                        map.put(props[i].getName(),
+                                read.invoke(contextObject, null));
+                    }
+                } catch (Exception ignored) {
+                    ignored.printStackTrace();
+                }
+            }
+        }
+    }
+
+    /**
+     * Create the object model.
+     * Currently the object model is a map with one single entry:
+     *  cocoon + request         The Request Object
+     *         + session         The Session (if available)
+     *         + context         The Context
+     *         + continuation    The Continuation (if available)
+     *         + parameters      The parameters (if provided)
+     */
+    public static Object getTemplateObjectModel(final Map objectModel, 
+                                                final Parameters parameters) {
+
+        // first create the "cocoon object":
+        final Map cocoon = new HashMap();
+
+        // Needed for the FOM wrappers
+        Context cx = Context.enter();
+        try {
+            // cocoon.request
+            final Request request = ObjectModelHelper.getRequest( objectModel );
+            cocoon.put("request", request);
+            
+            // cocoon.session
+            final Session session = request.getSession(false);
+            if (session != null) {
+                cocoon.put("session", session);
+            }
+        
+            // cocoon.context
+            final org.apache.cocoon.environment.Context context =
+                ObjectModelHelper.getContext( objectModel );
+            cocoon.put("context", context);
+
+        } finally {
+            Context.exit();
+        }
+            
+        // cocoon.continuation
+        final Object cont = FlowHelper.getWebContinuation(objectModel);
+        if ( cont != null ) {
+            cocoon.put("continuation", cont);
+        }
+            
+        // cocoon.parameters
+        if ( parameters != null ) {
+            cocoon.put("parameters", Parameters.toProperties(parameters));
+        }
+
+        final Map map = new HashMap();
+        map.put("cocoon", cocoon);
+
+        // Now add objects from flow context (if any)
+        final Object contextObject = FlowHelper.getContextObject(objectModel);
+        if (contextObject instanceof Map) {
+            map.putAll((Map)contextObject);
+        } else if ( contextObject != null ) {
+            fillContext(contextObject, map);
+        }
+        
+        return map;
+    }
+
+    /**
+     * Add java packages to object model. Allows to construct java objects.
+     * @param objectModel usually the result of invoking getTemplateObjectModel
+     */
+    public static Object addJavaPackages( Map objectModel ) {
+        Object javaPkg = FOM_JavaScriptFlowHelper.getJavaPackage(objectModel);
+        Object pkgs = FOM_JavaScriptFlowHelper.getPackages(objectModel);
+        
+        // packages might have already been set up if flowscript is being used
+        if ( javaPkg != null && pkgs != null ) {
+            objectModel.put( "Packages", javaPkg );
+            objectModel.put( "java", pkgs );
+        } else { 
+            Context cx = Context.enter();
+            try {
+                final String JAVA_PACKAGE = "JavaPackage";
+                ClassLoader cl = Thread.currentThread().getContextClassLoader();
+                Scriptable newPackages = new NativeJavaPackage( "", cl );
+                newPackages.setParentScope( getScope() );
+                newPackages.setPrototype( ScriptableObject.getClassPrototype(   getScope(),
+                                                                                JAVA_PACKAGE ) );
+                objectModel.put( "Packages", newPackages );
+                objectModel.put( "java", ScriptableObject.getProperty( getScope(), "java" ) );
+            } finally {
+                Context.exit();
+            }
+        }
+        return objectModel;
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/TemplateObjectModelHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/commandline/AbstractCommandLineEnvironment.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/commandline/AbstractCommandLineEnvironment.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/commandline/AbstractCommandLineEnvironment.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/commandline/AbstractCommandLineEnvironment.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,190 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.environment.commandline;
+
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.cocoon.CascadingIOException;
+import org.apache.cocoon.Constants;
+import org.apache.cocoon.ProcessingException;
+import org.apache.cocoon.components.source.SourceUtil;
+import org.apache.cocoon.environment.AbstractEnvironment;
+import org.apache.cocoon.environment.internal.EnvironmentHelper;
+import org.apache.excalibur.source.Source;
+import org.apache.excalibur.source.SourceException;
+import org.apache.excalibur.source.SourceResolver;
+import org.xml.sax.SAXException;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.MalformedURLException;
+
+/**
+ * This environment is used to save the requested file to disk.
+ *
+ * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
+ * @version CVS $Id: AbstractCommandLineEnvironment.java 165284 2005-04-29 09:24:28Z cziegeler $
+ */
+
+public abstract class AbstractCommandLineEnvironment
+extends AbstractEnvironment {
+
+    protected String contentType;
+    protected int contentLength;
+    protected int statusCode;
+
+    public AbstractCommandLineEnvironment(String uri,
+                                          String view,
+                                          File context,
+                                          OutputStream stream,
+                                          Logger log)
+    throws MalformedURLException {
+        super(uri, view);
+        this.enableLogging(log);
+        this.outputStream = stream;
+        this.statusCode = 0;
+    }
+
+    /**
+     * Redirect the client to a new URL
+     */
+    public void redirect(String newURL, boolean global, boolean permanent) 
+    throws IOException {
+
+        // fix all urls created with request.getScheme()+... etc.
+        if (newURL.startsWith("cli:/")) {
+            int pos = newURL.indexOf('/', 6);
+            newURL = newURL.substring(pos+1);
+        }
+
+        // fix all relative urls to use to cocoon: protocol
+        if (newURL.indexOf(":") == -1) {
+            newURL = "cocoon:/" + newURL;
+        }
+
+        // FIXME: this is a hack for the links view
+        ServiceManager manager = EnvironmentHelper.getSitemapServiceManager();
+        SourceResolver resolver = null;
+        try {
+            resolver = (SourceResolver)manager.lookup(SourceResolver.ROLE);
+            if (newURL.startsWith("cocoon:")
+                && this.getView() != null
+                && this.getView().equals(Constants.LINK_VIEW)) {
+            
+                // as the internal cocoon protocol is used the last
+                // serializer is removed from it! And therefore
+                // the LinkSerializer is not used.
+                // so we create one without Avalon...
+                org.apache.cocoon.serialization.LinkSerializer ls =
+                    new org.apache.cocoon.serialization.LinkSerializer();
+                ls.setOutputStream(this.outputStream);
+    
+                Source redirectSource = null;
+                try {
+                    redirectSource = resolver.resolveURI(newURL);
+                    SourceUtil.parse( manager, redirectSource, ls);
+                } catch (SourceException se) {
+                    throw new CascadingIOException("SourceException: " + se, se);
+                } catch (SAXException se) {
+                    throw new CascadingIOException("SAXException: " + se, se);
+                } catch (ProcessingException pe) {
+                    throw new CascadingIOException("ProcessingException: " + pe, pe);
+                } finally {
+                    resolver.release( redirectSource );
+                }
+                
+            } else {
+                Source redirectSource = null;
+                try {
+                    redirectSource = resolver.resolveURI(newURL);
+                    InputStream is = redirectSource.getInputStream();
+                    byte[] buffer = new byte[8192];
+                    int length = -1;
+    
+                    while ((length = is.read(buffer)) > -1) {
+                        this.outputStream.write(buffer, 0, length);
+                    }
+                } catch (SourceException se) {
+                    throw new CascadingIOException("SourceException: " + se, se);
+                } finally {
+                    resolver.release( redirectSource);
+                }
+            }
+        } catch (ServiceException se) {
+            throw new CascadingIOException("Unable to get source resolver.", se);
+        } finally {
+            manager.release(resolver);
+        }
+    }
+
+    /**
+     * Set the StatusCode
+     */
+    public void setStatus(int statusCode) {
+        this.statusCode = statusCode;
+    }
+
+    /**
+     * Get the StatusCode
+     */
+    public int getStatus() {
+        return statusCode;
+    }
+
+    /**
+     * Set the ContentType
+     */
+    public void setContentType(String contentType) {
+        this.contentType = contentType;
+    }
+
+    /**
+     * Set the ContentLength
+     */
+    public void setContentLength(int contentLength) {
+        this.contentLength = contentLength;
+    }
+
+    /**
+     * Get the ContentType
+     */
+    public String getContentType() {
+        return this.contentType;
+    }
+    
+    /**
+     * Always return <code>true</code>.
+     */
+    public boolean isExternal() {
+        return true;
+    }
+
+    /**
+     * Return an OutputStream, but allow it to be null for when
+     * the pipeline is being streamed to the provided SAX 
+     * content handler (using CocoonBean)
+     */
+    public OutputStream getOutputStream(int bufferSize) throws IOException {
+        if (this.outputStream == null) {
+            return null;
+        }
+        return super.getOutputStream(bufferSize);
+    }
+
+}
\ No newline at end of file

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/environment/commandline/AbstractCommandLineEnvironment.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message