cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jheym...@apache.org
Subject svn commit: r330548 [54/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/servlet/multipart/RequestFactory.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/servlet/multipart/RequestFactory.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/servlet/multipart/RequestFactory.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/servlet/multipart/RequestFactory.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,99 @@
+/*
+ * 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.servlet.multipart;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Hashtable;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * This is the interface of Request Wrapper in Cocoon.
+ *
+ * @author <a href="mailto:dims@yahoo.com">Davanum Srinivas</a>
+ * @version CVS $Id: RequestFactory.java 280948 2005-09-14 21:48:24Z sylvain $
+ */
+public class RequestFactory {
+
+    private boolean saveUploadedFilesToDisk;
+
+    private File uploadDirectory;
+
+    private boolean allowOverwrite;
+
+    private boolean silentlyRename;
+
+    private String defaultCharEncoding;
+    
+    private int maxUploadSize;
+    
+    public RequestFactory (boolean saveUploadedFilesToDisk, 
+                           File uploadDirectory, 
+                           boolean allowOverwrite, 
+                           boolean silentlyRename, 
+                           int maxUploadSize,
+                           String defaultCharEncoding) {
+       this.saveUploadedFilesToDisk = saveUploadedFilesToDisk;
+       this.uploadDirectory = uploadDirectory;
+       this.allowOverwrite = allowOverwrite;
+       this.silentlyRename = silentlyRename;
+       this.maxUploadSize = maxUploadSize;
+       this.defaultCharEncoding = defaultCharEncoding;
+       
+       if (saveUploadedFilesToDisk) {
+           // Empty the contents of the upload directory
+           File[] files = uploadDirectory.listFiles();
+           for (int i = 0; i < files.length; i++) {
+               files[i].delete();
+           }
+       }
+    }
+
+    /**
+     * If the request includes a "multipart/form-data", then wrap it with
+     * methods that allow easier connection to those objects since the servlet
+     * API doesn't provide those methods directly.
+     */
+    public HttpServletRequest getServletRequest(HttpServletRequest request) throws IOException, MultipartException {
+        HttpServletRequest req = request;
+        String contentType = request.getContentType();
+        
+        if ((contentType != null) && (contentType.toLowerCase().indexOf("multipart/form-data") > -1)) {
+ 
+            String charEncoding = request.getCharacterEncoding();
+            if (charEncoding == null || charEncoding.equals("")) {
+                charEncoding = this.defaultCharEncoding;
+            }
+            
+            MultipartParser parser = new MultipartParser(
+                    this.saveUploadedFilesToDisk, 
+                    this.uploadDirectory, 
+                    this.allowOverwrite, 
+                    this.silentlyRename, 
+                    this.maxUploadSize,
+                    charEncoding);
+                    
+            Hashtable parts = parser.getParts(request);
+            
+            req = new MultipartHttpServletRequest(request,parts);
+        }
+
+        return req;
+    }
+    
+}
\ No newline at end of file

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

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/servlet/multipart/TokenStream.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/servlet/multipart/TokenStream.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/servlet/multipart/TokenStream.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/servlet/multipart/TokenStream.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,258 @@
+/*
+ * 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.servlet.multipart;
+
+import java.io.IOException;
+import java.io.PushbackInputStream;
+
+/**
+ * Utility class for MultipartParser. Divides the inputstream into parts
+ * separated by a given boundary.
+ *
+ * A newline is espected after each boundary and is parsed away.
+ * @author <a href="mailto:j.tervoorde@home.nl">Jeroen ter Voorde</a>
+ * @version CVS $Id: TokenStream.java 164225 2005-04-22 12:11:58Z cziegeler $
+ */
+class TokenStream extends PushbackInputStream {
+
+    /**
+     * Initial state, no boundary has been set.
+     */
+    public static final int STATE_NOBOUNDARY = -1;
+
+    /**
+     * Fully read a part, now at the beginning of a new part
+     */
+    public static final int STATE_NEXTPART = -2;
+
+    /**
+     * Read last boundary, end of multipart block
+     */
+    public static final int STATE_ENDMULTIPART = -3;
+
+    /**
+     * End of stream, this should not happen
+     */
+    public static final int STATE_ENDOFSTREAM = -4;
+
+    /**
+     * Currently reading a part
+     */
+    public static final int STATE_READING = -5;
+
+    /** Field in           */
+    private PushbackInputStream in = null;
+
+    /** Field boundary           */
+    private byte[] boundary = null;
+
+    /** Field state           */
+    private int state = STATE_NOBOUNDARY;
+
+    /**
+     * Creates a new pushback token stream from in.
+     *
+     * @param in The input stream
+     */
+    public TokenStream(PushbackInputStream in) {
+        this(in,1);
+    }
+    
+    /**
+     * Creates a new pushback token stream from in.
+     *
+     * @param in The input stream
+     * @param size Size (in bytes) of the pushback buffer
+     */
+    public TokenStream(PushbackInputStream in, int size) {
+        super(in,size);
+        this.in = in;
+    }
+
+    /**
+     * Sets the boundary to scan for
+     *
+     * @param boundary A byte array containg the boundary
+     *
+     * @throws MultipartException
+     */
+    public void setBoundary(byte[] boundary) throws MultipartException {
+        this.boundary = boundary;
+        if (state == STATE_NOBOUNDARY) {
+            state = STATE_READING;
+        }
+    }
+
+    /**
+     * Start reading the next part in the stream. This method may only be called
+     * if state is STATE_NEXTPART. It will throw a MultipartException if not.
+     *
+     * @throws MultipartException
+     */
+    public void nextPart() throws MultipartException {
+        if (state != STATE_NEXTPART) {
+            throw new MultipartException("Illegal state");
+        }
+        state = STATE_READING;
+    }
+
+    /**
+     * Return the stream state
+     *
+     * @return
+     */
+    public int getState() {
+        return state;
+    }
+
+    /**
+     * Fill the ouput buffer until either it's full, the boundary has been reached or
+     * the end of the inputstream has been reached.
+     * When a boundary is reached it is entirely read away including trailing \r's and \n's.
+     * It will not be written to the output buffer.
+     * The stream state is updated after each call.
+     *
+     * @param out The output buffer
+     *
+     * @return
+     *
+     * @throws IOException
+     */
+    private int readToBoundary(byte[] out) throws IOException {
+        if (state != STATE_READING) {
+            return 0;
+        }
+        int boundaryIndex = 0;
+        int written = 0;
+        int b = in.read();
+
+        while (true) {
+            while ((byte) b != boundary[0]) {
+                if (b == -1) {
+                    state = STATE_ENDOFSTREAM;
+                    return written;
+                }
+                out[written++] = (byte) b;
+
+                if (written == out.length) {
+                    return written;
+                }
+                b = in.read();
+            }
+            boundaryIndex = 0;                         // we know the first byte matched
+            // check for boundary
+            while ((boundaryIndex < boundary.length)
+                    && ((byte) b == boundary[boundaryIndex])) {
+                b = in.read();
+                boundaryIndex++;
+            }
+
+            if (boundaryIndex == boundary.length) {    // matched boundary
+                if (b != -1) {
+                    if (b == '\r') {                   // newline, another part follows
+                        state = STATE_NEXTPART;
+                        in.read();
+                    } else if (b == '-') {             // hyphen, end of multipart
+                        state = STATE_ENDMULTIPART;
+                        in.read();                     // read next hyphen
+                        in.read();                     // read \r
+                        in.read();                     // read \n
+                    } else {                           // something else, error
+                        throw new IOException(
+                                "Unexpected character after boundary");
+                    }
+                } else {    // nothing after boundary, this shouldn't happen either
+                    state = STATE_ENDOFSTREAM;
+                }
+                return written;
+            }
+            // did not match boundary
+            // bytes skipped, write first skipped byte, push back the rest
+            if (b != -1) {                         // b may be -1
+                in.unread(b);                      // the non-matching byte
+            }
+            in.unread(boundary, 1,
+                    boundaryIndex - 1);          // unread skipped boundary data
+            out[written++] = boundary[0];
+            if (written == out.length) {
+                return written;
+            }
+            b = in.read();
+        }
+    }
+
+    /**
+     * @see java.io.InputStream#read(byte[])
+     *
+     * @param out
+     *
+     * @return
+     *
+     * @throws IOException
+     */
+    public int read(byte[] out) throws IOException {
+        if (state != STATE_READING) {
+            return 0;
+        }
+        return readToBoundary(out);
+    }
+
+    /**
+     * @see java.io.InputStream#read(byte[],int,int)
+     *
+     * @param out
+     * @param off
+     * @param len
+     *
+     * @return
+     *
+     * @throws IOException
+     */
+    public int read(byte[] out, int off, int len) throws IOException {
+        if ((off < 0) || (off >= out.length)) {
+            throw new IOException("Buffer offset outside buffer");
+        }
+        if (off + len >= out.length) {
+            throw new IOException("Buffer end outside buffer");
+        }
+        if (len < 0) {
+            throw new IOException("Length must be a positive integer");
+        }
+        byte[] buf = new byte[len];
+        int read = read(buf);
+        if (read > 0) {
+            System.arraycopy(buf, 0, out, off, read);
+        }
+        return read;
+    }
+
+    /**
+     * @see java.io.InputStream#read()
+     *
+     * @return
+     *
+     * @throws IOException
+     */
+    public int read() throws IOException {
+        byte[] buf = new byte[1];
+        int read = read(buf);
+
+        if (read == 0) {
+            return -1;
+        }
+        return buf[0];
+    }
+}

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

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/ComponentLocator.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/ComponentLocator.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/ComponentLocator.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/ComponentLocator.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,37 @@
+/*
+ * Copyright 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.sitemap;
+
+import org.apache.cocoon.ProcessingException;
+
+
+/**
+ * TODO WORK IN PROGRESS!!
+ *
+ * This interface is the connection between the Cocoon core components
+ * and an optional application/sitemap container.
+ *
+ * @since 2.2
+ * @version $Id: ComponentLocator.java 168073 2005-05-04 05:30:01Z cziegeler $
+ */
+public interface ComponentLocator {
+
+    Object getComponent(String key) throws ProcessingException;
+
+    void release(Object component);
+
+    boolean hasComponent(String key);
+}

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

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/ContentAggregator.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/ContentAggregator.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/ContentAggregator.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/ContentAggregator.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,42 @@
+/*
+ * 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.sitemap;
+
+import org.apache.cocoon.generation.Generator;
+
+/**
+ * A content aggregator is a special generator used to implement &lt;map:aggregate&gt;.
+ * It combines several parts into one big XML document which is streamed
+ * into the pipeline.
+ *
+ * @version $Id: ContentAggregator.java 292483 2005-09-29 17:20:10Z bloritsch $
+ */
+public interface ContentAggregator extends Generator {
+
+    /**
+     * Set the root element. Please make sure that the parameters are not null!
+     */
+    public void setRootElement(String element, String namespace, String prefix);
+
+    /**
+     * Add a part. Please make sure that the parameters are not null!
+     */
+    public void addPart(String uri,
+                        String element,
+                        String namespace,
+                        String stripRootElement,
+                        String prefix);
+}

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

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/DefaultContentAggregator.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/DefaultContentAggregator.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/DefaultContentAggregator.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/DefaultContentAggregator.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,378 @@
+/*
+ * 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.sitemap;
+
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.service.Serviceable;
+
+import org.apache.cocoon.ProcessingException;
+import org.apache.cocoon.caching.CacheableProcessingComponent;
+import org.apache.cocoon.components.source.SourceUtil;
+import org.apache.cocoon.environment.SourceResolver;
+import org.apache.cocoon.generation.Generator;
+import org.apache.cocoon.xml.ContentHandlerWrapper;
+import org.apache.cocoon.xml.XMLConsumer;
+import org.apache.cocoon.xml.XMLUtils;
+
+import org.apache.commons.lang.BooleanUtils;
+import org.apache.excalibur.source.Source;
+import org.apache.excalibur.source.SourceException;
+import org.apache.excalibur.source.SourceValidity;
+import org.apache.excalibur.source.impl.validity.AggregatedValidity;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Map;
+
+/**
+ * This generator implements the sitemap content aggregation.
+ * It combines several parts into one big XML document which is streamed
+ * into the pipeline.
+ *
+ * @author <a href="mailto:giacomo@apache.org">Giacomo Pati</a>
+ * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
+ * @version $Id: DefaultContentAggregator.java 164815 2005-04-26 16:43:13Z vgritsenko $
+ */
+public class DefaultContentAggregator extends ContentHandlerWrapper
+                                      implements Generator, CacheableProcessingComponent,
+                                                 Serviceable, ContentAggregator {
+
+    /** The root element of the aggregated content */
+    protected Element rootElement;
+
+    /** The aggregated parts */
+    protected ArrayList parts = new ArrayList();
+
+    /** Indicates the position in the stack of the root element of the aggregated content */
+    private int rootElementIndex;
+
+    /** The element used for the current part */
+    protected Element currentElement;
+
+    /** The SourceResolver */
+    protected SourceResolver resolver;
+
+    /** The service manager */
+    protected ServiceManager manager;
+
+    /** This object holds the part parts :) */
+    protected final class Part {
+        public String uri;
+        public Element element;
+        public Source source;
+        boolean stripRootElement;
+
+        public Part(String uri, Element element, String stripRoot) {
+            this.uri = uri;
+            this.element = element;
+            this.stripRootElement = BooleanUtils.toBoolean(stripRoot);
+        }
+    }
+
+    /** This object holds an element definition */
+    protected final class Element {
+        public String namespace;
+        public String prefix;
+        public String name;
+
+        public Element(String name, String namespace, String prefix) {
+            this.namespace = namespace;
+            this.prefix = prefix;
+            this.name = name;
+        }
+    }
+
+    /**
+     * Generates the content
+     */
+    public void generate()
+    throws IOException, SAXException, ProcessingException {
+        if (getLogger().isDebugEnabled()) {
+            getLogger().debug("Generating aggregated content");
+        }
+        this.contentHandler.startDocument();
+        startElem(this.rootElement);
+
+        try {
+            for (int i = 0; i < this.parts.size(); i++) {
+                final Part part = (Part) this.parts.get(i);
+                this.rootElementIndex = part.stripRootElement ? -1 : 0;
+                if (part.element != null) {
+                    this.currentElement = part.element;
+                    startElem(part.element);
+                } else {
+                    this.currentElement = this.rootElement;
+                }
+
+                try {
+                    SourceUtil.parse(this.manager, part.source, this);
+                } finally {
+                    if (part.element != null) {
+                        endElem(part.element);
+                    }
+                }
+            }
+        } finally {
+            endElem(this.rootElement);
+            this.contentHandler.endDocument();
+        }
+        getLogger().debug("Finished aggregating content");
+    }
+
+    /**
+     * Generate the unique key.
+     * This key must be unique inside the space of this component.
+     *
+     * @return The generated key hashes the src
+     */
+    public Serializable getKey() {
+        try {
+            StringBuffer buffer = new StringBuffer(64);
+            buffer.append("CA(")
+                    .append(this.rootElement.prefix).append(':')
+                    .append(this.rootElement.name).append('<')
+                    .append(this.rootElement.namespace).append(">)");
+
+            for (int i = 0; i < this.parts.size(); i++) {
+                final Part part = (Part) this.parts.get(i);
+                final Source source = part.source;
+
+                if (part.element == null) {
+                    buffer.append("P=")
+                            .append(part.stripRootElement).append(':')
+                            .append(source.getURI()).append(';');
+                } else {
+                    buffer.append("P=")
+                            .append(part.element.prefix).append(':')
+                            .append(part.element.name)
+                            .append('<').append(part.element.namespace).append(">:")
+                            .append(part.stripRootElement).append(':')
+                            .append(source.getURI()).append(';');
+                }
+            }
+
+            return buffer.toString();
+        } catch (Exception e) {
+            getLogger().error("Could not generateKey", e);
+            return null;
+        }
+    }
+
+    /**
+     * Generate the validity object.
+     *
+     * @return The generated validity object or <code>null</code> if the
+     *         component is currently not cacheable.
+     */
+    public SourceValidity getValidity() {
+        try {
+            AggregatedValidity v = new AggregatedValidity();
+            for (int i = 0; i < this.parts.size(); i++) {
+                final Source current = ((Part) this.parts.get(i)).source;
+                final SourceValidity sv = current.getValidity();
+
+                if (sv == null) {
+                    return null;
+                } else {
+                    v.add(sv);
+                }
+            }
+
+            return v;
+        } catch (Exception e) {
+            getLogger().error("Could not getValidity", e);
+            return null;
+        }
+    }
+
+    /**
+     * Set the root element. Please make sure that the parameters are not null!
+     */
+    public void setRootElement(String element, String namespace, String prefix) {
+        this.rootElement = new Element(element,
+                                       namespace,
+                                       prefix);
+        if (getLogger().isDebugEnabled()) {
+            getLogger().debug("Root element='" + element +
+                              "' ns='" + namespace + "' prefix='" + prefix + "'");
+        }
+    }
+
+    /**
+     * Add a part. Please make sure that the parameters are not null!
+     */
+    public void addPart(String uri,
+                        String element,
+                        String namespace,
+                        String stripRootElement,
+                        String prefix) {
+        Element elem = null;
+        if (!element.equals("")) {
+            if (namespace.equals("")) {
+                elem = new Element(element,
+                                   this.rootElement.namespace,
+                                   this.rootElement.prefix);
+            } else {
+                elem = new Element(element,
+                                   namespace,
+                                   prefix);
+            }
+        }
+        this.parts.add(new Part(uri,
+                                elem,
+                                stripRootElement));
+        if (getLogger().isDebugEnabled()) {
+            getLogger().debug("Part uri='" + uri +
+                              "' element='" + element + "' ns='" + namespace +
+                              "' stripRootElement='" + stripRootElement + "' prefix='" + prefix + "'");
+        }
+    }
+
+    /**
+     * Set the <code>XMLConsumer</code> that will receive XML data.
+     *
+     * <br>
+     * This method will simply call <code>setContentHandler(consumer)</code>
+     * and <code>setLexicalHandler(consumer)</code>.
+     */
+    public void setConsumer(XMLConsumer consumer) {
+        setContentHandler(consumer);
+        setLexicalHandler(consumer);
+    }
+
+    /**
+     * Recycle the producer by removing references
+     */
+    public void recycle() {
+        super.recycle();
+
+        this.rootElement = null;
+        for (int i = 0; i < this.parts.size(); i++) {
+            final Part current = (Part) this.parts.get(i);
+            if (current.source != null) {
+                if (getLogger().isDebugEnabled()) {
+                    getLogger().debug("Releasing " + current.source);
+                }
+                this.resolver.release(current.source);
+            }
+        }
+        this.parts.clear();
+        this.currentElement = null;
+        this.resolver = null;
+    }
+
+    /**
+     * Set the <code>SourceResolver</code>, object model <code>Map</code>,
+     * the source and sitemap <code>Parameters</code> used to process the request.
+     */
+    public void setup(SourceResolver resolver, Map objectModel, String src, Parameters par)
+    throws ProcessingException, SAXException, IOException {
+        this.resolver = resolver;
+        // get the Source for each part
+        try {
+            for (int i = 0; i < this.parts.size(); i++) {
+                final Part current = (Part) this.parts.get(i);
+                current.source = resolver.resolveURI(current.uri);
+            }
+        } catch (SourceException se) {
+            throw SourceUtil.handle("Unable to resolve source.", se);
+        }
+    }
+
+    /**
+     * Private method generating startElement event for the aggregated parts
+     * and the root element
+     */
+    private void startElem(Element element)
+    throws SAXException {
+        final String qname = (element.prefix.equals("")) ? element.name : element.prefix + ':' + element.name;
+        if (!element.namespace.equals("")) {
+            this.contentHandler.startPrefixMapping(element.prefix, element.namespace);
+        }
+        this.contentHandler.startElement(element.namespace, element.name, qname, XMLUtils.EMPTY_ATTRIBUTES);
+    }
+
+    /**
+     * Private method generating endElement event for the aggregated parts
+     * and the root element
+     */
+    private void endElem(Element element) throws SAXException {
+        final String qname = (element.prefix.equals("")) ? element.name : element.prefix + ':' + element.name;
+        this.contentHandler.endElement(element.namespace, element.name, qname);
+        if (!element.namespace.equals("")) {
+            this.contentHandler.endPrefixMapping(element.prefix);
+        }
+    }
+
+    /**
+     * Ignore start and end document events
+     */
+    public void startDocument() throws SAXException {
+    }
+
+    /**
+     * Ignore start and end document events
+     */
+    public void endDocument() throws SAXException {
+    }
+
+    /**
+     * Override startElement() event to add namespace and prefix
+     */
+    public void startElement(String namespaceURI, String localName, String raw, Attributes atts)
+    throws SAXException {
+        this.rootElementIndex++;
+        if (this.rootElementIndex == 0) {
+            getLogger().debug("Skipping root element start event.");
+            return;
+        }
+        if (namespaceURI == null || namespaceURI.equals("")) {
+            final String qname = this.currentElement.prefix.equals("") ? localName : this.currentElement.prefix + ':' + localName;
+            this.contentHandler.startElement(this.currentElement.namespace, localName, qname, atts);
+        } else {
+            this.contentHandler.startElement(namespaceURI, localName, raw, atts);
+        }
+    }
+
+    /**
+     * Override startElement() event to add namespace and prefix
+     */
+    public void endElement(String namespaceURI, String localName, String raw) throws SAXException {
+        this.rootElementIndex--;
+        if (this.rootElementIndex == -1) {
+            getLogger().debug("Skipping root element end event.");
+            return;
+        }
+        if (namespaceURI == null || namespaceURI.equals("")) {
+            final String qname = this.currentElement.prefix.equals("") ? localName : this.currentElement.prefix + ':' + localName;
+            this.contentHandler.endElement(this.currentElement.namespace, localName, qname);
+        } else {
+            this.contentHandler.endElement(namespaceURI, localName, raw);
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
+     */
+    public void service(ServiceManager manager) throws ServiceException {
+        this.manager = manager;
+    }
+}

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

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/EnterSitemapEvent.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/EnterSitemapEvent.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/EnterSitemapEvent.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/EnterSitemapEvent.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,30 @@
+/*
+ * Copyright 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.sitemap;
+
+import org.apache.cocoon.Processor;
+import org.apache.cocoon.environment.Environment;
+
+/**
+ * @version $Id: EnterSitemapEvent.java 158469 2005-03-21 15:42:04Z cziegeler $
+ * @since 2.2
+ */
+public class EnterSitemapEvent extends SitemapEvent {
+
+    public EnterSitemapEvent(Processor source, Environment env) {
+        super(source, env);
+    }
+}

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

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/EnterSitemapEventListener.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/EnterSitemapEventListener.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/EnterSitemapEventListener.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/EnterSitemapEventListener.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,25 @@
+/*
+ * Copyright 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.sitemap;
+
+/**
+ * @version $Id: EnterSitemapEventListener.java 158469 2005-03-21 15:42:04Z cziegeler $
+ * @since 2.2
+ */
+public interface EnterSitemapEventListener extends SitemapListener {
+
+    void enteredSitemap(EnterSitemapEvent event);
+}

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

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/ExecutionContext.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/ExecutionContext.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/ExecutionContext.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/ExecutionContext.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,42 @@
+/*
+ * 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.sitemap;
+
+import org.apache.cocoon.util.location.Locatable;
+import org.apache.cocoon.util.location.Location;
+
+
+/**
+ * This context contains information about the current statement that should
+ * be executed like the location in the sitemap etc.
+ *
+ * TODO - This is not finished yet!
+ * 
+ * @since 2.2
+ * @version CVS $Id: ExecutionContext.java 233343 2005-08-18 18:06:44Z sylvain $
+ */
+public interface ExecutionContext extends Locatable {
+    
+    /**
+     * Return the location of the statement in the sitemap.
+     */
+    Location getLocation();
+    
+    /**
+     * Return the component type
+     */
+    String getType();
+}

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

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/LeaveSitemapEvent.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/LeaveSitemapEvent.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/LeaveSitemapEvent.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/LeaveSitemapEvent.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,31 @@
+/*
+ * Copyright 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.sitemap;
+
+import org.apache.cocoon.Processor;
+import org.apache.cocoon.environment.Environment;
+
+/**
+ *
+ * @version $Id: LeaveSitemapEvent.java 158469 2005-03-21 15:42:04Z cziegeler $
+ * @since 2.2
+ */
+public class LeaveSitemapEvent extends SitemapEvent {
+
+    public LeaveSitemapEvent(Processor source, Environment env) {
+        super(source, env);
+    }
+}

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

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/LeaveSitemapEventListener.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/LeaveSitemapEventListener.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/LeaveSitemapEventListener.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/LeaveSitemapEventListener.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,26 @@
+/*
+ * Copyright 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.sitemap;
+
+/**
+ *
+ * @version $Id: LeaveSitemapEventListener.java 158469 2005-03-21 15:42:04Z cziegeler $
+ * @since 2.2
+ */
+public interface LeaveSitemapEventListener extends SitemapListener {
+
+    void leftSitemap(LeaveSitemapEvent event);
+}

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

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/LinkGatherer.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/LinkGatherer.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/LinkGatherer.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/LinkGatherer.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,104 @@
+/*
+ * 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.sitemap;
+
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.cocoon.ProcessingException;
+import org.apache.cocoon.Constants;
+import org.apache.cocoon.caching.CacheableProcessingComponent;
+import org.apache.cocoon.environment.SourceResolver;
+import org.apache.cocoon.transformation.Transformer;
+import org.apache.cocoon.xml.xlink.ExtendedXLinkPipe;
+
+import org.apache.excalibur.source.SourceValidity;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:uv@upaya.co.uk">Upayavira</a>
+ * @version CVS $Id: LinkGatherer.java 30941 2004-07-29 19:56:58Z vgritsenko $
+ */
+public class LinkGatherer extends ExtendedXLinkPipe implements Transformer, CacheableProcessingComponent {
+    private List links;
+
+
+    /**
+     * Set the <code>SourceResolver</code>, objectModel <code>Map</code>,
+     * the source and sitemap <code>Parameters</code> used to process the request.
+     */
+    public void setup(SourceResolver resolver, Map objectModel, String src, Parameters par) throws ProcessingException,
+        SAXException, IOException {
+            this.links = (List)objectModel.get(Constants.LINK_COLLECTION_OBJECT);
+    }
+
+    /**
+     * Generate the unique key.
+     * This key must be unique inside the space of this component.
+     *
+     * @return The generated key hashes the src
+     */
+    public java.io.Serializable getKey() {
+        return "1";
+    }
+
+    /**
+     * Generate the validity object.
+     *
+     * @return The generated validity object or <code>null</code> if the
+     *         component is currently not cacheable.
+     */
+    public SourceValidity getValidity() {
+//      Whilst the cache does not store gathered links, this component must be non-cacheable
+//      return NOPValidity.SHARED_INSTANCE;
+        return null;
+    }
+
+    public void simpleLink(String href, String role, String arcrole, String title, String show, String actuate, String uri,
+        String name, String raw, Attributes attr) throws SAXException {
+            if (!this.links.contains(href)){
+                this.addLink(href);
+            }
+            super.simpleLink(href, role, arcrole, title, show, actuate, uri, name, raw, attr);
+    }
+
+    public void startLocator(String href, String role, String title, String label, String uri, String name, String raw,
+        Attributes attr) throws SAXException {
+            if (!this.links.contains(href)){
+                this.addLink(href);
+            }
+            super.startLocator(href, role, title, label, uri, name, raw, attr);
+    }
+    private void addLink(String href) {
+        if (href.length() == 0) return;
+        if (href.charAt(0) == '#') return;
+        if (href.indexOf("://") != -1) return;
+        if (href.startsWith("mailto:")) return;
+        if (href.startsWith("news:")) return;
+        if (href.startsWith("javascript:")) return;
+
+        int anchorPos = href.indexOf('#');
+        if (anchorPos == -1) {
+            this.links.add(href);
+        } else {
+            this.links.add(href.substring(0, anchorPos));
+        }
+    }
+}

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

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/LinkTranslator.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/LinkTranslator.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/LinkTranslator.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/LinkTranslator.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,86 @@
+/*
+ * 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.sitemap;
+
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.cocoon.Constants;
+import org.apache.cocoon.ProcessingException;
+import org.apache.cocoon.caching.CacheableProcessingComponent;
+import org.apache.cocoon.environment.SourceResolver;
+import org.apache.cocoon.transformation.Transformer;
+import org.apache.cocoon.xml.xlink.ExtendedXLinkPipe;
+import org.apache.excalibur.source.SourceValidity;
+import org.apache.excalibur.source.impl.validity.NOPValidity;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+import java.io.IOException;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
+ * @version CVS $Id: LinkTranslator.java 30941 2004-07-29 19:56:58Z vgritsenko $
+ */
+public class LinkTranslator extends ExtendedXLinkPipe implements Transformer, CacheableProcessingComponent {
+    
+    private Map links;
+
+    /**
+     * Set the <code>SourceResolver</code>, objectModel <code>Map</code>,
+     * the source and sitemap <code>Parameters</code> used to process the request.
+     */
+    public void setup(SourceResolver resolver, Map objectModel, String src, Parameters par) 
+    throws ProcessingException, SAXException, IOException {
+        this.links = (Map)objectModel.get(Constants.LINK_OBJECT);
+    }
+
+    /**
+     * Generate the unique key.
+     * This key must be unique inside the space of this component.
+     *
+     * @return The generated key hashes the src
+     */
+    public java.io.Serializable getKey() {
+        return "1";
+    }
+
+    /**
+     * Generate the validity object.
+     *
+     * @return The generated validity object or <code>null</code> if the
+     *         component is currently not cacheable.
+     */
+    public SourceValidity getValidity() {
+        return NOPValidity.SHARED_INSTANCE;
+    }
+
+    public void simpleLink(String href, String role, String arcrole, 
+                           String title, String show, String actuate, String uri,
+                           String name, String raw, Attributes attr) 
+    throws SAXException {
+        final String newHref = (String)this.links.get(href);
+        super.simpleLink((newHref != null) ? newHref : href, role, arcrole, title, show, actuate, uri, name, raw, attr);
+    }
+
+    public void startLocator(String href, String role, String title, 
+                             String label, String uri, String name, String raw,
+                             Attributes attr) 
+    throws SAXException {
+        final String newHref = (String)this.links.get(href);
+        super.startLocator((newHref != null) ? newHref : href, role, title, label, uri, name, raw, attr);
+    }
+}

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

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/NotifyingGenerator.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/NotifyingGenerator.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/NotifyingGenerator.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/NotifyingGenerator.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,75 @@
+/*
+ * 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.sitemap;
+
+import java.util.Map;
+import java.io.IOException;
+
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.cocoon.components.notification.Notifying;
+import org.apache.cocoon.components.notification.Notifier;
+import org.apache.cocoon.generation.AbstractGenerator;
+import org.apache.cocoon.environment.SourceResolver;
+import org.apache.cocoon.ProcessingException;
+import org.apache.cocoon.Constants;
+
+import org.xml.sax.SAXException;
+
+/**
+ * Generates an XML representation of the current notification.
+ *
+ * @author <a href="mailto:barozzi@nicolaken.com">Nicola Ken Barozzi</a>
+ * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
+ * @author <a href="mailto:proyal@managingpartners.com">Peter Royal</a>
+ * @version CVS $Id: NotifyingGenerator.java 30941 2004-07-29 19:56:58Z vgritsenko $
+ */
+public class NotifyingGenerator extends AbstractGenerator {
+    
+    /**
+     * The <code>Notification</code> to report.
+     */
+    private Notifying notification;
+
+    public void setup(SourceResolver resolver, Map objectModel, String src,
+                      Parameters par) throws ProcessingException, SAXException, IOException {
+        super.setup(resolver, objectModel, src, par);
+
+        this.notification  = (Notifying)objectModel.get(Constants.NOTIFYING_OBJECT);
+
+        if ( this.notification  == null) {
+            throw new ProcessingException("Expected Constants.NOTIFYING_OBJECT not found in object model");
+        }
+    }
+
+    /**
+     * Generate the notification information in XML format.
+     *
+     * @throws SAXException when there is a problem creating the
+     *      output SAX events.
+     */
+    public void generate() throws SAXException {
+        Notifier.notify(notification, this.contentHandler, "text/xml");
+    }
+
+    /**
+     * Recycle
+     */
+    public void recycle() {
+        super.recycle();
+        this.notification = null;
+    }
+}
+

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

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/PatternException.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/PatternException.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/PatternException.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/PatternException.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,55 @@
+/*
+ * 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.sitemap;
+
+import org.apache.avalon.framework.CascadingException;
+
+/**
+ * This exception is thrown by a <code>URIMatcher</code> or by a
+ * <code>URITranslator</code> when there's something wrong with the matching or
+ * translation patterns.
+ *
+ * @author <a href="mailto:pier@apache.org">Pierpaolo Fumagalli</a>
+ *         (Apache Software Foundation)
+ * @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
+ * @version CVS $Id: PatternException.java 30941 2004-07-29 19:56:58Z vgritsenko $
+ */
+public class PatternException extends CascadingException {
+
+    /**
+     * Construct a new <code>PatternException</code> instance.
+     */
+    public PatternException(String message) {
+        super(message, null);
+    }
+
+    /**
+     * Creates a new <code>PatternException</code> instance.
+     *
+     * @param ex an <code>Exception</code> value
+     */
+    public PatternException(Exception ex) {
+        super(ex.getMessage(), ex);
+    }
+
+    /**
+     * Construct a new <code>PatternException</code> that references
+     * a parent Exception.
+     */
+    public PatternException(String message, Throwable t) {
+        super(message, t);
+    }
+}

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

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/Sitemap.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/Sitemap.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/Sitemap.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/Sitemap.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,50 @@
+/*
+ * Copyright 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.sitemap;
+
+import org.apache.cocoon.Processor;
+import org.apache.cocoon.components.flow.Interpreter;
+
+/**
+ * TODO WORK IN PROGRESS!!
+ *
+ * This interface describes the current sitemap. The current sitemap is available using
+ * {@link org.apache.cocoon.core.Core#getCurrentSitemap()}.
+ *
+ * @since 2.2
+ * @version $Id: Sitemap.java 209567 2005-07-07 06:18:44Z cziegeler $
+ */
+public interface Sitemap {
+
+    /**
+     * Return the locator of the current sitemap.
+     * @return The current locator.
+     */
+    ComponentLocator getComponentLocator();
+
+    /**
+     * Return the current processor
+     */
+    Processor getProcessor();
+
+    /**
+     * Return the Interpreter for the given language. If no
+     * interpreter is found <code>null</code> is returned.
+     * @param language The language or <code>null</code> for the default interpreter.
+     * @return The interpreter or <code>null</code>.
+     */
+    Interpreter getInterpreter(String language);
+}

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

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/SitemapErrorHandler.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/SitemapErrorHandler.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/SitemapErrorHandler.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/SitemapErrorHandler.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,85 @@
+/*
+ * Copyright 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.sitemap;
+
+import org.apache.cocoon.Processor;
+import org.apache.cocoon.components.treeprocessor.InvokeContext;
+import org.apache.cocoon.components.treeprocessor.sitemap.ErrorHandlerHelper;
+import org.apache.cocoon.environment.Environment;
+
+/**
+ * Class providing error handling capabilities to the pipeline
+ * as configured in the sitemap.
+ *
+ * @since 2.1.7
+ * @version $Id: SitemapErrorHandler.java 157555 2005-03-15 15:49:32Z vgritsenko $
+ */
+public class SitemapErrorHandler {
+    /**
+     * Error handler helper of the pipeline node
+     */
+    private ErrorHandlerHelper handler;
+
+    /**
+     * Environment of the pipeline node
+     */
+    private Environment environment;
+
+    /**
+     * Sitemap invocation context
+     */
+    private InvokeContext context;
+
+    // Environment state
+    private String envPrefix;
+    private String envURI;
+
+    /**
+     * Construct error handler with everything needed to handle an error.
+     */
+    public SitemapErrorHandler(ErrorHandlerHelper handler,
+                               Environment environment,
+                               InvokeContext context) {
+        this.handler = handler;
+        this.environment = environment;
+        this.context = context;
+
+        this.envPrefix = environment.getURIPrefix();
+        this.envURI = environment.getURI();
+    }
+
+    /**
+     * Handle an error.
+     * @return true if error was handled.
+     */
+    public boolean handleError(Exception e) throws Exception {
+        // Restore environment state
+        this.environment.setURI(this.envPrefix, this.envURI);
+
+        return this.handler.invokeErrorHandler(e, this.environment, this.context);
+    }
+
+    /**
+     * Build error handling pipeline.
+     * @return error handling pipeline, or null if error was not handled.
+     */
+    public Processor.InternalPipelineDescription prepareErrorPipeline(Exception e) throws Exception {
+        // Restore environment state
+        this.environment.setURI(this.envPrefix, this.envURI);
+
+        return this.handler.prepareErrorHandler(e, this.environment, this.context);
+    }
+}

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

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/SitemapEvent.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/SitemapEvent.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/SitemapEvent.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/SitemapEvent.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,49 @@
+/*
+ * Copyright 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.sitemap;
+
+import java.util.EventObject;
+
+import org.apache.cocoon.Processor;
+import org.apache.cocoon.environment.Environment;
+
+/**
+ * Base interface for all sitemap events.
+ *
+ * @version $Id: SitemapEvent.java 158469 2005-03-21 15:42:04Z cziegeler $
+ * @since 2.2
+ */
+public abstract class SitemapEvent extends EventObject {
+
+    private final Environment environment;
+
+    /**
+     * @param source The current processor (sitemap)
+     * @param env    The environment describing the current request
+     */
+    public SitemapEvent(Processor source, Environment env) {
+        super(source);
+        this.environment = env;
+    }
+    
+    public Processor getSourceProcessor() {
+        return (Processor)this.getSource();
+    }
+    
+    public Environment getEnvironment() {
+        return this.environment;
+    }
+}

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

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/SitemapExecutor.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/SitemapExecutor.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/SitemapExecutor.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/SitemapExecutor.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,225 @@
+/*
+ * 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.sitemap;
+
+import java.util.Map;
+
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.cocoon.acting.Action;
+import org.apache.cocoon.environment.Redirector;
+import org.apache.cocoon.environment.SourceResolver;
+import org.apache.cocoon.matching.Matcher;
+import org.apache.cocoon.matching.PreparableMatcher;
+import org.apache.cocoon.selection.Selector;
+import org.apache.cocoon.selection.SwitchSelector;
+
+/**
+ * The sitemap executor executes all sitemap statements, so it actually
+ * calls an action, adds a generator to the pipeline etc.
+ * By separating this functionality into a single object it is easier to
+ * plugin custom profiling or debugging tools.
+ *
+ * TODO - This is not finished yet!
+ * TODO - we should add invocation of a Redirector as well
+ * 
+ * @since 2.2
+ * @version CVS $Id: SitemapExecutor.java 240034 2005-08-25 10:04:05Z cziegeler $
+ */
+public interface SitemapExecutor {
+    
+    /** The component role */
+    String ROLE = SitemapExecutor.class.getName();
+    
+    public static class PipelineComponentDescription {
+        public String type;
+        public String source;
+        public Parameters parameters;
+        public Parameters hintParameters;
+        /** Mime-type for serializers and readers */
+        public String mimeType;
+    }
+    
+    /**
+     * Invoke an action and return the result.
+     */
+    Map invokeAction(ExecutionContext context,
+                     Map              objectModel, 
+                     Action           action, 
+                     Redirector       redirector, 
+                     SourceResolver   resolver, 
+                     String           source, 
+                     Parameters       parameters )
+    throws Exception;
+    
+    /**
+     * Invoke a match and return the result
+     */
+    Map invokeMatcher(ExecutionContext context,
+                      Map              objectModel,
+                      Matcher          matcher,
+                      String           pattern,
+                      Parameters       parameters )
+    throws PatternException;
+    
+    /**
+     * Invoke a match and return the result
+     */
+    Map invokePreparableMatcher(ExecutionContext context,
+                      Map               objectModel,
+                      PreparableMatcher matcher,
+                      String            pattern,
+                      Object            preparedPattern,
+                      Parameters        parameters )
+    throws PatternException;
+
+    /**
+     * Invoke a selector
+     * @param context
+     * @param objectModel
+     * @param selector
+     * @param expression
+     * @param parameters
+     * @return
+     */
+    boolean invokeSelector(ExecutionContext context,
+            Map               objectModel,
+            Selector selector, 
+            String expression, 
+            Parameters parameters);
+    
+    /**
+     * Invoke a switch selector
+     * @param context
+     * @param objectModel
+     * @param selector
+     * @param expression
+     * @param parameters
+     * @param selectorContext The context object for the switch selector
+     * @return
+     */
+    boolean invokeSwitchSelector(ExecutionContext context,
+                                 Map             objectModel,
+                                 SwitchSelector  selector, 
+                                 String expression, 
+                                 Parameters parameters,
+                                 Object selectorContext);
+
+    /**
+     * Push map of information on the context stack.
+     * @param context The execution context
+     * @param objectModel The object model
+     * @param key A key that can be used to identify this map (can be null)
+     * @param variables The variables as key/value pairs
+     * @return The variables that are used in the sitemap. The executor can
+     *         modify the set of available variables by returning a different
+     *         map.
+     */
+    Map pushVariables(ExecutionContext context, 
+                      Map              objectModel,
+                      String           key, 
+                      Map              variables);
+    
+    /**
+     * Pop a map of information from the context stack.
+     * @param context     The execution context
+     * @param objectModel The object model
+     */
+    void popVariables(ExecutionContext context,
+                      Map              objectModel);
+    
+    /**
+     * Enter a new sitemap
+     * @param context     The execution context
+     * @param objectModel The object model
+     * @param source The uri of the sitemap
+     */
+    void enterSitemap(ExecutionContext context, 
+                      Map              objectModel,
+                      String           source);
+
+    /**
+     * Leaves a sitemap.
+     */
+    void leaveSitemap(ExecutionContext context,
+                      Map              objectModel);
+
+    /**
+     * Add a generator
+     * @param context
+     * @param objectModel
+     * @param desc The descrption of the component
+     * @return The desc of the component to use
+     */
+    PipelineComponentDescription addGenerator(ExecutionContext context, 
+                                              Map              objectModel,
+                                              PipelineComponentDescription desc);
+
+    /**
+     * Add a transformer
+     * @param context
+     * @param objectModel
+     * @param desc The descrption of the component
+     * @return The desc of the component to use
+     */
+    PipelineComponentDescription addTransformer(ExecutionContext context, 
+                                                Map              objectModel,
+                                                PipelineComponentDescription desc);
+
+    /**
+     * Add a serializer
+     * @param context
+     * @param objectModel
+     * @param desc The descrption of the component
+     * @return The desc of the component to use
+     */
+    PipelineComponentDescription addSerializer(ExecutionContext context, 
+                                               Map              objectModel,
+                                               PipelineComponentDescription desc);
+
+    /**
+     * Add a reader
+     * @param context
+     * @param objectModel
+     * @param desc The descrption of the component
+     * @return The desc of the component to use
+     */
+    PipelineComponentDescription addReader(ExecutionContext context, 
+                                           Map              objectModel,
+                                           PipelineComponentDescription desc);
+
+    /**
+     * This informs the executor about a new pipeline section.
+     * @param context
+     * @param objectModel
+     * @param desc
+     * @return
+     */
+    PipelineComponentDescription enteringPipeline(ExecutionContext context,
+                                                  Map              objectModel,
+                                                  PipelineComponentDescription desc);
+
+    /**
+     * Informs about a redirect.
+     * @return The uri to redirect to.
+     */
+    String redirectTo(ExecutionContext context,
+                      Map              objectModel,
+                      String           uri,
+                      boolean          createSession,
+                      boolean          global,
+                      boolean          permanent);
+    
+}

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

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/SitemapListener.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/SitemapListener.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/SitemapListener.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/SitemapListener.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,29 @@
+/*
+ * Copyright 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.sitemap;
+
+import java.util.EventListener;
+
+/**
+ * Base interface for all sitemap event listeners.
+ *
+ * @version $Id: SitemapListener.java 158469 2005-03-21 15:42:04Z cziegeler $
+ * @since 2.2
+ */
+public interface SitemapListener extends EventListener {
+
+    // just a marker interface
+}

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

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/SitemapModelComponent.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/SitemapModelComponent.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/SitemapModelComponent.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/SitemapModelComponent.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,64 @@
+/*
+ * 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.sitemap;
+
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.cocoon.ProcessingException;
+import org.apache.cocoon.environment.SourceResolver;
+import org.xml.sax.SAXException;
+
+import java.io.IOException;
+import java.util.Map;
+
+/**
+ * The SitemapModelComponent identifies the contract between the Sitemap and
+ * your pipeline components that create or transform information.  The types
+ * of components that fit within this umbrella are your Generators,
+ * Transformers, and your Readers.  It is very important to note that all
+ * components impementing this interface must be pooled or created on demand.
+ * This is due to the separation between the setup and the execution.  If you
+ * don't ensure every instance of the component is unique within a pipeline,
+ * or accross pipelines, then the setup process will start killing all the
+ * other setups and you will end up with serious race conditions.  It's not
+ * that they need synchronized keywords applied to the methods, its that the
+ * methods have to be called in a certain order.  This is by design.  If you
+ * really think about it, due to the SAX infrastructure we would still need to
+ * keep them synchronized because the order of SAX events affects the validity
+ * of your XML document.
+ * 
+ * @author <a href="mailto:pier@apache.org">Pierpaolo Fumagalli</a>
+ *         (Apache Software Foundation)
+ * @version CVS $Id: SitemapModelComponent.java 279591 2005-09-08 17:37:58Z bloritsch $
+ */
+public interface SitemapModelComponent {
+    /**
+     * The Sitemap will call the setup() method to prepare the component for
+     * use.  This is where you start the process of getting your information
+     * ready to generate your results.  See {@link org.apache.cocoon.environment.ObjectModelHelper} for help with the <code>objectModel</code>.
+     *
+     * @param resolver     The <code>SourceResolver</code> to find resources within your context.
+     * @param objectModel  A <code>java.util.Map</code> that contains the request and session information.
+     * @param src          The value of the "src" attribute in the sitemap.
+     * @param par          The sitemap parameters passed into your component.
+     *
+     * @throws SAXException if there is a problem reading a SAX stream.
+     * @throws IOException  if there is a problem reading files.
+     * @throws ResourceNotFoundException if the resource to be rendered cannot be found.
+     * @throws ProcessingException if there is any other unexpected problem.
+     */
+    void setup(SourceResolver resolver, Map objectModel, String src, Parameters par) 
+    throws ProcessingException, SAXException, IOException;
+}

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

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/SitemapOutputComponent.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/SitemapOutputComponent.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/SitemapOutputComponent.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/sitemap/SitemapOutputComponent.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,109 @@
+/*
+ * 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.sitemap;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * The SitemapOutputComponents are responsible for taking the results of a
+ * pipeline to the end user.  Current examples are the Serializer and the
+ * Reader.  The Sitemap will terminate the pipeline when it encounters the
+ * first instance of a <code>SitemapOutputComponent</code>.  Just like the
+ * <code>SitemapModelComponent</code>, all implementations of this contract
+ * must be pooled for the same reasons.  The sitemap will query the output
+ * component for the mime type and whether the sitemap should set the content
+ * length in the response.  It will then provide the output component the
+ * <code>java.io.OutputStream</code> so you can send the bytes directly to the
+ * user.
+ * <p>
+ * It should be noted that there is no way to access any of the request,
+ * response, or context objects within a component that just implements this
+ * interface like the Serializer.  The idea is to keep things simple.  All your
+ * response attributes should have been already set, and the only
+ * responsibility at this point in time is to give the user what he wants--the
+ * rendered object (page/image/etc.).
+ * </p>
+ * 
+ * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
+ * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
+ * @version CVS $Id: SitemapOutputComponent.java 279591 2005-09-08 17:37:58Z bloritsch $
+ */
+public interface SitemapOutputComponent {
+
+    /**
+     * Set the {@link OutputStream} where the requested resource should
+     * be serialized.
+     *
+     * @param out  The <code>OutputStream</code> target for the rendered results.
+     *
+     * @throws IOException if the stream can't be used.
+     */
+    void setOutputStream(OutputStream out) throws IOException;
+
+    /**
+     * Obtain the mime type for the results being serialized.  It helps
+     * responsible browsers to identify how to show the information to the
+     * user.
+     * <p>
+     * <strong>Warning:</strong>Microsoft Internet Explorer is a poor
+     * netizen and does not always respect this information.  I am talking
+     * about Microsoft's InternetExplorer.  It will first try to use the file
+     * extension of the resource to determine the mime type, and then if that
+     * fails it will fall back to respecting the mime type.  For that reason it
+     * is essential that you also practice good netizen habits and make the
+     * file extension and the mime type agree.  One example is the PDF
+     * document.  In order for Microsoft to treat a result set as a PDF
+     * document you must have the url end with ".pdf" as well as set the mime
+     * type to "application/pdf".  Internet Explorer will fail if you try to
+     * send the document "badhabit.xml?view=pdf" rendered as a PDF document.
+     * It is because the file extension ".xml" will be remapped to "text/xml"
+     * even if you set the mime type correctly.
+     * </p>
+     * <p>
+     * You may have some incorrectly configured servers that will work for one
+     * browser and not the other because the mime-type and file extension do
+     * not agree.  The world would be much simpler if all browsers blindly
+     * accepted the mime type.  Just be aware of this issue when you are
+     * creating your sitemap and serializing your results.
+     *
+     * @return the mime-type for the results.
+     */
+    String getMimeType();
+
+    /**
+     * Test if the component needs the content length set.
+     * <p>
+     * Most types of documents don't really care what the content length is,
+     * so it is usually safe to leave the results of this method to false.  It
+     * should be noted that the Adobe Acrobat Reader plugin for Microsoft
+     * Internet Explorer has a bug that wasn't fixed until version 7.  The bug
+     * prevents the PDF document from displaying correctly.  It will look like
+     * an empty document or something similar.  So the general rule of thumb
+     * for explicitly seting the content length is:
+     * </p>
+     * <ul>
+     * <li>If it is a PDF document, always set content length (might require
+     *     the document to be cached to get the number of bytes)</li>
+     * <li>If you are writing a Reader and you have the content lenght, set
+     *     it.</li>
+     * <li>Otherwise it is safe to return false here.</li>
+     * </ul>
+     *
+     * @return <code>true</code> if the content length needs to be set.
+     */
+    boolean shouldSetContentLength();
+}

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



Mime
View raw message