You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by ug...@apache.org on 2007/10/05 09:44:37 UTC

svn commit: r582103 [1/2] - in /cocoon/whiteboard/gt07: ./ src/ src/main/ src/main/java/ src/main/java/com/ src/main/java/com/sourcesense/ src/main/java/com/sourcesense/gt07/ src/main/java/com/sourcesense/gt07/generators/ src/main/java/com/sourcesense/...

Author: ugo
Date: Fri Oct  5 00:44:35 2007
New Revision: 582103

URL: http://svn.apache.org/viewvc?rev=582103&view=rev
Log:
A simple Atom Publishing Protocol server.

Added:
    cocoon/whiteboard/gt07/README.txt   (with props)
    cocoon/whiteboard/gt07/pom.xml   (with props)
    cocoon/whiteboard/gt07/rcl.properties   (with props)
    cocoon/whiteboard/gt07/src/
    cocoon/whiteboard/gt07/src/main/
    cocoon/whiteboard/gt07/src/main/java/
    cocoon/whiteboard/gt07/src/main/java/com/
    cocoon/whiteboard/gt07/src/main/java/com/sourcesense/
    cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/
    cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/generators/
    cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/generators/AtomEntryGenerator.java   (with props)
    cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/generators/AtomFeedGenerator.java   (with props)
    cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/generators/AtomGenerator.java   (with props)
    cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/generators/AtomServiceGenerator.java   (with props)
    cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/stax/
    cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/stax/SAXStreamReaderAdaptor.java   (with props)
    cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/stax/SAXStreamWriterAdaptor.java   (with props)
    cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/stax/SAXWriter.java   (with props)
    cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/transformers/
    cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/transformers/CreateAtomEntryTransformer.java   (with props)
    cocoon/whiteboard/gt07/src/main/resources/
    cocoon/whiteboard/gt07/src/main/resources/COB-INF/
    cocoon/whiteboard/gt07/src/main/resources/COB-INF/demo/
    cocoon/whiteboard/gt07/src/main/resources/COB-INF/demo/blog1/
    cocoon/whiteboard/gt07/src/main/resources/COB-INF/demo/blog1/entries/
    cocoon/whiteboard/gt07/src/main/resources/COB-INF/demo/blog2/
    cocoon/whiteboard/gt07/src/main/resources/COB-INF/demo/blog2/entries/
    cocoon/whiteboard/gt07/src/main/resources/COB-INF/sitemap.xmap   (with props)
    cocoon/whiteboard/gt07/src/main/resources/META-INF/
    cocoon/whiteboard/gt07/src/main/resources/META-INF/cocoon/
    cocoon/whiteboard/gt07/src/main/resources/META-INF/cocoon/spring/
    cocoon/whiteboard/gt07/src/main/resources/META-INF/cocoon/spring/servlet-service.xml   (with props)
    cocoon/whiteboard/gt07/src/test/
    cocoon/whiteboard/gt07/src/test/java/
    cocoon/whiteboard/gt07/src/test/java/com/
    cocoon/whiteboard/gt07/src/test/java/com/sourcesense/
    cocoon/whiteboard/gt07/src/test/java/com/sourcesense/gt07/
    cocoon/whiteboard/gt07/src/test/java/com/sourcesense/gt07/stax/
    cocoon/whiteboard/gt07/src/test/java/com/sourcesense/gt07/stax/SAXWriterTest.java   (with props)
    cocoon/whiteboard/gt07/src/test/resources/
    cocoon/whiteboard/gt07/src/test/resources/log4j.properties   (with props)
    cocoon/whiteboard/gt07/test-data/
    cocoon/whiteboard/gt07/test-data/entry-2.xml   (with props)
    cocoon/whiteboard/gt07/test-data/entry.xml   (with props)

Added: cocoon/whiteboard/gt07/README.txt
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/gt07/README.txt?rev=582103&view=auto
==============================================================================
--- cocoon/whiteboard/gt07/README.txt (added)
+++ cocoon/whiteboard/gt07/README.txt Fri Oct  5 00:44:35 2007
@@ -0,0 +1,8 @@
+Partial implementation of an Atom Publishing Protocol server done for the
+2007 Cocoon GetTogether in Rome.
+
+This is a Cocoon 2.2 block, so you can start it with
+
+mvn jetty:run
+
+and access the server at http://localhost:8888/GT07/
\ No newline at end of file

Propchange: cocoon/whiteboard/gt07/README.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/whiteboard/gt07/README.txt
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: cocoon/whiteboard/gt07/README.txt
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: cocoon/whiteboard/gt07/pom.xml
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/gt07/pom.xml?rev=582103&view=auto
==============================================================================
--- cocoon/whiteboard/gt07/pom.xml (added)
+++ cocoon/whiteboard/gt07/pom.xml Fri Oct  5 00:44:35 2007
@@ -0,0 +1,126 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you 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.
+-->
+<!--+
+    | @version $Id$
+    +-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+  <modelVersion>4.0.0</modelVersion>
+  <packaging>jar</packaging>
+
+  <name>GT07</name>
+  <groupId>com.sourcesense</groupId>
+  <artifactId>GT07</artifactId>
+  <version>1.0-SNAPSHOT</version>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.cocoon</groupId>
+      <artifactId>cocoon-core</artifactId>
+      <version>2.2.0-RC1</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.cocoon</groupId>
+      <artifactId>cocoon-servlet-service-components</artifactId>
+      <version>1.0.0-M2</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.cocoon</groupId>
+      <artifactId>cocoon-template-impl</artifactId>
+      <version>1.0.0-RC1</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.abdera</groupId>
+      <artifactId>abdera-core</artifactId>
+      <version>0.3.0-incubating</version>
+      <scope>compile</scope>
+    </dependency>   
+    <dependency>
+      <groupId>org.apache.abdera</groupId>
+      <artifactId>abdera-parser</artifactId>
+      <version>0.3.0-incubating</version>
+      <scope>compile</scope>
+    </dependency>   
+  </dependencies>
+
+  <build>
+    <plugins>
+	<plugin>
+		<artifactId>maven-compiler-plugin</artifactId>
+		<configuration>
+			<source>1.5</source>
+			<target>1.5</target>
+		</configuration>
+	</plugin>
+      <plugin>
+        <groupId>org.apache.cocoon</groupId>
+        <artifactId>cocoon-maven-plugin</artifactId>
+        <version>1.0.0-M1</version>
+        <executions>
+          <execution>
+            <id>rcl</id>
+            <phase>compile</phase>
+            <goals>
+              <goal>rcl</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>org.mortbay.jetty</groupId>
+        <artifactId>maven-jetty-plugin</artifactId>
+        <version>6.1.3</version>
+        <configuration>
+          <connectors>
+            <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
+              <port>8888</port>
+              <maxIdleTime>30000</maxIdleTime>
+            </connector>
+          </connectors>
+          <webAppSourceDirectory>${project.build.directory}/rcl/webapp</webAppSourceDirectory>
+          <contextPath>/</contextPath>
+          <systemProperties>
+            <systemProperty>
+              <name>org.apache.cocoon.mode</name>
+              <value>dev</value>
+            </systemProperty>
+          </systemProperties>
+        </configuration>
+      </plugin>
+      <plugin>
+        <artifactId>maven-jar-plugin</artifactId>
+        <version>2.1</version>
+        <configuration>
+          <archive>
+            <manifestEntries>
+              <Cocoon-Block-Name>${pom.artifactId}</Cocoon-Block-Name>
+            </manifestEntries>
+          </archive>
+        </configuration>
+      </plugin>
+      <plugin>
+        <artifactId>maven-eclipse-plugin</artifactId>
+        <version>2.3</version>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>
\ No newline at end of file

Propchange: cocoon/whiteboard/gt07/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/whiteboard/gt07/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: cocoon/whiteboard/gt07/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: cocoon/whiteboard/gt07/rcl.properties
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/gt07/rcl.properties?rev=582103&view=auto
==============================================================================
--- cocoon/whiteboard/gt07/rcl.properties (added)
+++ cocoon/whiteboard/gt07/rcl.properties Fri Oct  5 00:44:35 2007
@@ -0,0 +1,17 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+#
+com.sourcesense.GT07.block%classes-dir=./target/classes
\ No newline at end of file

Propchange: cocoon/whiteboard/gt07/rcl.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/whiteboard/gt07/rcl.properties
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Added: cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/generators/AtomEntryGenerator.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/generators/AtomEntryGenerator.java?rev=582103&view=auto
==============================================================================
--- cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/generators/AtomEntryGenerator.java (added)
+++ cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/generators/AtomEntryGenerator.java Fri Oct  5 00:44:35 2007
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * 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.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ * 
+ * $Id$
+ */
+package com.sourcesense.gt07.generators;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+
+import org.apache.abdera.model.Document;
+import org.apache.abdera.model.Element;
+import org.apache.abdera.model.Entry;
+import org.apache.abdera.parser.ParseException;
+import org.apache.abdera.parser.Parser;
+import org.apache.cocoon.ProcessingException;
+
+
+public class AtomEntryGenerator extends AtomGenerator {
+
+    @Override
+    public Element generateDocument(File file) throws ProcessingException {
+        try {
+            Parser parser = this.abdera.getParser();
+            Document<Entry> doc = parser.parse(new FileReader(file));
+            return doc.getRoot();
+        } catch (ParseException e) {
+            throw new ProcessingException(e);
+        } catch (FileNotFoundException e) {
+            throw new ProcessingException(e);
+        }
+    }
+
+}

Propchange: cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/generators/AtomEntryGenerator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/generators/AtomEntryGenerator.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/generators/AtomEntryGenerator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/generators/AtomFeedGenerator.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/generators/AtomFeedGenerator.java?rev=582103&view=auto
==============================================================================
--- cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/generators/AtomFeedGenerator.java (added)
+++ cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/generators/AtomFeedGenerator.java Fri Oct  5 00:44:35 2007
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * 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.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ * 
+ * $Id$
+ */
+package com.sourcesense.gt07.generators;
+
+import java.io.File;
+import java.io.FileReader;
+import java.util.Date;
+
+import org.apache.abdera.model.Document;
+import org.apache.abdera.model.Element;
+import org.apache.abdera.model.Entry;
+import org.apache.abdera.model.Feed;
+import org.apache.abdera.model.Link;
+import org.apache.abdera.parser.Parser;
+import org.apache.cocoon.ProcessingException;
+
+
+public class AtomFeedGenerator extends AtomGenerator {
+
+    @Override
+    public Element generateDocument(File dir) throws ProcessingException {
+        if (!dir.isDirectory()) {
+            throw new ProcessingException(dir.getAbsolutePath() + " is not a directory.");
+        }
+        try {
+            Feed feed = factory.newFeed();
+            if (this.title != null) {
+                feed.setTitle(title);
+            }
+            for (File file : dir.listFiles()) {
+                if (file.isFile() && !file.isHidden()) {
+                    Parser parser = this.abdera.getParser();
+                    Document<Entry> doc = parser.parse(new FileReader(file));
+
+                    // Clonin the entry as suggested by James Snell as a workaround for ABDERA-70
+                    Entry entry = (Entry) doc.getRoot().clone();
+                    entry.setUpdated(new Date(file.lastModified()));
+                    
+                    // Add a rel='edit' link
+                    // A bug in Abdera prevents the link to be serialized in the XML representation,
+                    // unless we clone the entry as done above.
+                    // See: https://issues.apache.org/jira/browse/ABDERA-70
+                    Link link = factory.newLink();
+                    link.setHref(entry.getId().toString().substring("urn:uuid:".length()));
+                    link.setRel(Link.REL_EDIT);
+                    entry.addLink(link);
+                    
+                    feed.addEntry(entry);
+                    if (feed.getUpdated() == null || entry.getUpdated().after(feed.getUpdated())) {
+                        feed.setUpdated(entry.getUpdated());
+                    }
+                }
+            }
+            return feed;
+        } catch (Exception e) {
+            throw new ProcessingException(e);
+        }
+    }
+
+}

Propchange: cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/generators/AtomFeedGenerator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/generators/AtomFeedGenerator.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/generators/AtomFeedGenerator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/generators/AtomGenerator.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/generators/AtomGenerator.java?rev=582103&view=auto
==============================================================================
--- cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/generators/AtomGenerator.java (added)
+++ cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/generators/AtomGenerator.java Fri Oct  5 00:44:35 2007
@@ -0,0 +1,154 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * 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.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ * 
+ * $Id$
+ */
+package com.sourcesense.gt07.generators;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.util.Map;
+
+import org.apache.abdera.Abdera;
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.i18n.iri.IRI;
+import org.apache.abdera.model.Element;
+import org.apache.abdera.model.Entry;
+import org.apache.abdera.model.Feed;
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.cocoon.ProcessingException;
+import org.apache.cocoon.ResourceNotFoundException;
+import org.apache.cocoon.components.source.util.SourceUtil;
+import org.apache.cocoon.environment.ObjectModelHelper;
+import org.apache.cocoon.environment.Request;
+import org.apache.cocoon.environment.SourceResolver;
+import org.apache.cocoon.generation.ServiceableGenerator;
+import org.apache.excalibur.source.Source;
+import org.apache.excalibur.source.SourceException;
+import org.xml.sax.SAXException;
+
+import com.sourcesense.gt07.stax.SAXStreamWriterAdaptor;
+import com.sourcesense.gt07.stax.SAXWriter;
+
+
+public abstract class AtomGenerator extends ServiceableGenerator {
+    
+    /** Constant for the file protocol. */
+    private static final String FILE = "file:";
+
+    /** The source object for the directory. */
+    protected Source source;
+
+    protected Abdera abdera;
+
+    protected Factory factory;
+    
+    /** Title of the feed/entry, if set in parameters */
+    protected String title;
+    
+    @SuppressWarnings("unchecked")
+    @Override
+    /**
+     * Set the request parameters. Must be called before the generate method.
+     *
+     * @param resolver     the SourceResolver object
+     * @param objectModel  a <code>Map</code> containing model object
+     * @param src          the directory to be XMLized specified as src attribute on &lt;map:generate/>
+     * @param par          configuration parameters
+     */
+    public void setup(SourceResolver resolver, Map objectModel, String src, Parameters par)
+            throws ProcessingException, SAXException, IOException {
+        if (src == null) {
+            throw new ProcessingException("No src attribute specified.");
+        }
+        super.setup(resolver, objectModel, src, par);
+
+        try {
+            this.source = this.resolver.resolveURI(src);
+        } catch (SourceException se) {
+            throw SourceUtil.handle(se);
+        }
+        
+        this.title = par.getParameter("title", null);
+        this.abdera = new Abdera();
+        this.factory = abdera.getFactory();
+    }
+
+    /**
+     * Recycle resources
+     */
+    public void recycle() {
+        if (this.resolver != null) {
+            this.resolver.release(this.source);
+            this.source = null;
+        }
+        this.abdera = null;
+        this.factory = null;
+        super.recycle();
+    }
+
+    public void generate() throws IOException, SAXException, ProcessingException {
+        try {
+            String systemId = this.source.getURI();
+            if (!systemId.startsWith(FILE)) {
+                throw new ResourceNotFoundException(systemId + " does not denote a file");
+            }
+            // This relies on systemId being of the form "file://..."
+            File file = new File(new URL(systemId).getFile());
+            SAXStreamWriterAdaptor ssw = new SAXStreamWriterAdaptor(this.contentHandler);
+            ssw.enableLogging(this.getLogger());
+            SAXWriter writer = new SAXWriter(ssw);
+            Element root = this.generateDocument(file);
+            Request req = ObjectModelHelper.getRequest(objectModel);
+            URL location = new URL(req.getScheme(), req.getServerName(), req.getServerPort(), 
+                    req.getContextPath() + req.getRequestURI());
+            root.setBaseUri(new IRI(location));
+            // Use the request URL as id if the document requires it but does not have it.
+            // Use the configured title if the document does not have it.
+            if (root instanceof Entry) {
+                Entry entry = (Entry) root;
+                if (entry.getId() == null) {
+                    entry.setId(location.toExternalForm());
+                }
+                if (entry.getTitle() == null) {
+                    entry.setTitle(this.title);
+                }
+            } else if (root instanceof Feed) {
+                Feed feed = (Feed) root;
+                if (feed.getId() == null) {
+                    feed.setId(location.toExternalForm());
+                }
+                if (feed.getTitle() == null) {
+                    feed.setTitle(this.title);
+                }
+            }
+            writer.writeTo(root);
+        } catch (IOException ioe) {
+            throw new ResourceNotFoundException("Could not read directory " + super.source, ioe);
+        }
+    }
+
+    /**
+     * Generate an Atom Service, Feed or Entry.
+     * 
+     * @param file
+     * @return
+     * @throws ProcessingException
+     */
+    public abstract Element generateDocument(File file) throws ProcessingException;
+}

Propchange: cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/generators/AtomGenerator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/generators/AtomGenerator.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/generators/AtomGenerator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/generators/AtomServiceGenerator.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/generators/AtomServiceGenerator.java?rev=582103&view=auto
==============================================================================
--- cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/generators/AtomServiceGenerator.java (added)
+++ cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/generators/AtomServiceGenerator.java Fri Oct  5 00:44:35 2007
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * 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.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ * 
+ * $Id$
+ */
+package com.sourcesense.gt07.generators;
+
+import java.io.File;
+
+import org.apache.abdera.model.Collection;
+import org.apache.abdera.model.Element;
+import org.apache.abdera.model.Service;
+import org.apache.abdera.model.Workspace;
+import org.apache.cocoon.ProcessingException;
+
+
+public class AtomServiceGenerator extends AtomGenerator {
+
+    @Override
+    public Element generateDocument(File dir) throws ProcessingException {
+        if (!dir.isDirectory()) {
+            throw new ProcessingException(dir.getAbsolutePath() + " is not a directory.");
+        }
+        Service svc = factory.newService();
+        for (File subdir : dir.listFiles()) {
+            if (subdir.isDirectory()) {
+                Workspace ws = svc.addWorkspace(subdir.getName());
+                ws.addCollection("entries", subdir.getName() + "/entries/");
+                Collection media = ws.addCollection("media", subdir.getName() + "/media/");
+                media.addAccepts("image/*");
+            }
+        }
+        return svc;
+    }
+
+}

Propchange: cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/generators/AtomServiceGenerator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/generators/AtomServiceGenerator.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/generators/AtomServiceGenerator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/stax/SAXStreamReaderAdaptor.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/stax/SAXStreamReaderAdaptor.java?rev=582103&view=auto
==============================================================================
--- cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/stax/SAXStreamReaderAdaptor.java (added)
+++ cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/stax/SAXStreamReaderAdaptor.java Fri Oct  5 00:44:35 2007
@@ -0,0 +1,406 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * 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.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ * 
+ * $Id$
+ */
+package com.sourcesense.gt07.stax;
+
+import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+import javax.xml.stream.Location;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.avalon.framework.logger.LogEnabled;
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.cocoon.xml.SaxBuffer;
+
+
+public class SAXStreamReaderAdaptor implements XMLStreamReader, LogEnabled {
+
+    // Wish SaxBuffer.SaxBit would be public. WTF???
+    private Iterator<Object> bits;
+    
+    // Wish SaxBuffer.SaxBit would be public. WTF???
+    private Object current;
+    
+    protected Logger logger;
+    
+    public SAXStreamReaderAdaptor(List<Object> bits) {
+        this.bits = bits.iterator();
+    }
+
+    public void close() throws XMLStreamException {
+    }
+
+    public int getAttributeCount() {
+        SaxBuffer.StartElement bit = (SaxBuffer.StartElement) current; 
+        return bit.attrs.getLength();
+    }
+
+    public String getAttributeLocalName(int index) {
+        SaxBuffer.StartElement bit = (SaxBuffer.StartElement) current; 
+        return bit.attrs.getLocalName(index);
+    }
+
+    public QName getAttributeName(int index) {
+        SaxBuffer.StartElement bit = (SaxBuffer.StartElement) current; 
+        return new QName(bit.attrs.getQName(index));
+    }
+
+    public String getAttributeNamespace(int index) {
+        SaxBuffer.StartElement bit = (SaxBuffer.StartElement) current; 
+        return bit.attrs.getURI(index);
+    }
+
+    public String getAttributePrefix(int index) {
+        return "";
+    }
+
+    public String getAttributeType(int index) {
+        SaxBuffer.StartElement bit = (SaxBuffer.StartElement) current; 
+        return bit.attrs.getType(index);
+    }
+
+    public String getAttributeValue(int index) {
+        SaxBuffer.StartElement bit = (SaxBuffer.StartElement) current; 
+        return bit.attrs.getValue(index);
+    }
+
+    public String getAttributeValue(String uri, String localName) {
+        SaxBuffer.StartElement bit = (SaxBuffer.StartElement) current; 
+        return bit.attrs.getValue(uri, localName);
+                
+    }
+
+    public String getCharacterEncodingScheme() {
+        return "UTF-8";
+    }
+
+    public String getElementText() throws XMLStreamException {
+        if (logger.isDebugEnabled()) {
+            logger.debug("SAXStreamReaderAdaptor: getElementText()");
+        }
+        if (getEventType() != XMLStreamConstants.START_ELEMENT) { throw new XMLStreamException("parser must be on START_ELEMENT to read next text",
+                getLocation()); }
+        int eventType = next();
+        StringBuffer buf = new StringBuffer();
+        while (eventType != XMLStreamConstants.END_ELEMENT) {
+            if (eventType == XMLStreamConstants.CHARACTERS || eventType == XMLStreamConstants.CDATA || eventType == XMLStreamConstants.SPACE
+                    || eventType == XMLStreamConstants.ENTITY_REFERENCE) {
+                buf.append(getText());
+            } else if (eventType == XMLStreamConstants.PROCESSING_INSTRUCTION || eventType == XMLStreamConstants.COMMENT) {
+                // skipping
+            } else if (eventType == XMLStreamConstants.END_DOCUMENT) {
+                throw new XMLStreamException("unexpected end of document when reading element text content", getLocation());
+            } else if (eventType == XMLStreamConstants.START_ELEMENT) {
+                throw new XMLStreamException("element text content may not contain START_ELEMENT", getLocation());
+            } else {
+                throw new XMLStreamException("Unexpected event type " + eventType, getLocation());
+            }
+            eventType = next();
+        }
+        return buf.toString();
+    }
+
+    public String getEncoding() {
+        return "UTF-8";
+    }
+
+    public int getEventType() {
+        if (logger.isDebugEnabled()) {
+            logger.debug("SAXStreamReaderAdaptor: getEventType(): current bit is a " + current.getClass().getSimpleName());
+        }
+        return 0;
+    }
+
+    public String getLocalName() {
+        SaxBuffer.StartElement bit = (SaxBuffer.StartElement) current; 
+        if (logger.isDebugEnabled()) {
+            logger.debug("SAXStreamReaderAdaptor: getLocalName() -> " + bit.localName);
+        }
+        return bit.localName;
+    }
+
+    public Location getLocation() {
+        return null;
+    }
+
+    public QName getName() {
+        SaxBuffer.StartElement bit = (SaxBuffer.StartElement) current; 
+        if (logger.isDebugEnabled()) {
+            logger.debug("SAXStreamReaderAdaptor: getName() -> " + new QName(bit.namespaceURI, bit.localName));
+        }
+        return new QName(bit.namespaceURI, bit.localName);
+    }
+
+    public NamespaceContext getNamespaceContext() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public int getNamespaceCount() {
+        // TODO Auto-generated method stub
+        return 0;
+    }
+
+    public String getNamespacePrefix(int arg0) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public String getNamespaceURI() {
+        SaxBuffer.StartElement bit = (SaxBuffer.StartElement) current; 
+        return bit.namespaceURI;
+    }
+
+    public String getNamespaceURI(String arg0) {
+        SaxBuffer.StartElement bit = (SaxBuffer.StartElement) current; 
+        return bit.namespaceURI;
+    }
+
+    public String getNamespaceURI(int arg0) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public String getPIData() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public String getPITarget() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public String getPrefix() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public Object getProperty(String arg0) throws IllegalArgumentException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public String getText() {
+        if (logger.isDebugEnabled()) {
+            logger.debug("SAXStreamReaderAdaptor: getText(): current bit is a " + current.getClass().getSimpleName());
+        }
+        if (current instanceof SaxBuffer.Characters) {
+            SaxBuffer.Characters bit = (SaxBuffer.Characters) current;
+            return new String(bit.ch);
+        } else if (current instanceof SaxBuffer.Comment) {
+            SaxBuffer.Comment bit = (SaxBuffer.Comment) current;
+            return new String(bit.ch);
+        } else {
+            return "";
+        }
+    }
+
+    public char[] getTextCharacters() {
+        if (logger.isDebugEnabled()) {
+            logger.debug("SAXStreamReaderAdaptor: getTextCharacters(): current bit is a " + current.getClass().getSimpleName());
+        }
+        if (current instanceof SaxBuffer.Characters) {
+            SaxBuffer.Characters bit = (SaxBuffer.Characters) current;
+            return bit.ch;
+        } else if (current instanceof SaxBuffer.Comment) {
+            SaxBuffer.Comment bit = (SaxBuffer.Comment) current;
+            return bit.ch;
+        } else {
+            return new char[0];
+        }
+    }
+
+    public int getTextCharacters(int sourceStart, char[] target, int targetStart, int length) throws XMLStreamException {
+        if (logger.isDebugEnabled()) {
+            logger.debug("SAXStreamReaderAdaptor: getTextCharacters(...): current bit is a " + current.getClass().getSimpleName());
+        }
+        if (current instanceof SaxBuffer.Characters) {
+            SaxBuffer.Characters bit = (SaxBuffer.Characters) current;
+            System.arraycopy(bit.ch, sourceStart, target, targetStart, length);
+            return length;
+        } else if (current instanceof SaxBuffer.Comment) {
+            SaxBuffer.Comment bit = (SaxBuffer.Comment) current;
+            System.arraycopy(bit.ch, sourceStart, target, targetStart, length);
+            return length;
+        } else {
+            return 0;
+        }
+    }
+
+    public int getTextLength() {
+        if (logger.isDebugEnabled()) {
+            logger.debug("SAXStreamReaderAdaptor: getTextLength(): current bit is a " + current.getClass().getSimpleName());
+        }
+        if (current instanceof SaxBuffer.Characters) {
+            SaxBuffer.Characters bit = (SaxBuffer.Characters) current;
+            return bit.ch.length;
+        } else if (current instanceof SaxBuffer.Comment) {
+            SaxBuffer.Comment bit = (SaxBuffer.Comment) current;
+            return bit.ch.length;
+        } else {
+            return 0;
+        }
+    }
+
+    public int getTextStart() {
+        if (logger.isDebugEnabled()) {
+            logger.debug("SAXStreamReaderAdaptor: getTextStart(): current bit is a " + current.getClass().getSimpleName());
+        }
+        return 0;
+    }
+
+    public String getVersion() {
+        return "1.0";
+    }
+
+    public boolean hasName() {
+        if (logger.isDebugEnabled()) {
+            logger.debug("SAXStreamReaderAdaptor: hasName(): current bit is a " + current.getClass().getSimpleName());
+        }
+        if (current instanceof SaxBuffer.StartElement) {
+            return true;
+        } else if (current instanceof SaxBuffer.EndElement) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    public boolean hasNext() throws XMLStreamException {
+        return bits.hasNext();
+    }
+
+    public boolean hasText() {
+        if (logger.isDebugEnabled()) {
+            logger.debug("SAXStreamReaderAdaptor: hasText(): current bit is a " + current.getClass().getSimpleName());
+        }
+        if (current instanceof SaxBuffer.Characters) {
+            return true;
+        } else if (current instanceof SaxBuffer.Comment) {
+            return true;
+        } else if (current instanceof SaxBuffer.IgnorableWhitespace) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    public boolean isAttributeSpecified(int arg0) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    public boolean isCharacters() {
+        if (logger.isDebugEnabled()) {
+            logger.debug("SAXStreamReaderAdaptor: isCharacters(): current bit is a " + current.getClass().getSimpleName());
+        }
+        return current instanceof SaxBuffer.Characters;
+    }
+
+    public boolean isEndElement() {
+        return current instanceof SaxBuffer.EndElement;
+    }
+
+    public boolean isStandalone() {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    public boolean isStartElement() {
+        return current instanceof SaxBuffer.StartElement;
+    }
+
+    public boolean isWhiteSpace() {
+        return current instanceof SaxBuffer.IgnorableWhitespace;
+    }
+
+    public int next() throws XMLStreamException {
+        current = bits.next();
+        if (logger.isDebugEnabled()) {
+            logger.debug("SAXStreamReaderAdaptor: Next bit is a " + current.getClass().getSimpleName());
+        }
+        if (current instanceof SaxBuffer.Characters) {
+            return XMLStreamReader.CHARACTERS;
+        } else if (current instanceof SaxBuffer.Comment) {
+            return XMLStreamReader.COMMENT;
+        } else if (current instanceof SaxBuffer.EndCDATA) {
+            return next(); // Ignored
+        } else if (current instanceof SaxBuffer.EndDocument) {
+            return XMLStreamReader.END_DOCUMENT;
+        } else if (current instanceof SaxBuffer.EndDTD) {
+            return next(); // Ignored
+        } else if (current instanceof SaxBuffer.EndElement) {
+            return XMLStreamReader.END_ELEMENT;
+        } else if (current instanceof SaxBuffer.EndEntity) {
+            return next(); // Ignored
+        } else if (current instanceof SaxBuffer.EndPrefixMapping) {
+            return next(); // Ignored
+        } else if (current instanceof SaxBuffer.IgnorableWhitespace) {
+            return XMLStreamReader.SPACE;
+        } else if (current instanceof SaxBuffer.PI) {
+            return XMLStreamReader.PROCESSING_INSTRUCTION;
+        } else if (current instanceof SaxBuffer.SkippedEntity) {
+            return next(); // Ignored
+        } else if (current instanceof SaxBuffer.StartCDATA) {
+            return next(); // Ignored
+        } else if (current instanceof SaxBuffer.StartDocument) {
+            return XMLStreamReader.START_DOCUMENT;
+        } else if (current instanceof SaxBuffer.StartDTD) {
+            return next(); // Ignored
+        } else if (current instanceof SaxBuffer.StartDocument) {
+            return XMLStreamReader.START_DOCUMENT;
+        } else if (current instanceof SaxBuffer.StartElement) {
+            return START_ELEMENT;
+        } else if (current instanceof SaxBuffer.StartEntity) {
+            return next(); // Ignored
+        } else if (current instanceof SaxBuffer.StartPrefixMapping) {
+            return next(); // Ignored
+        } else {
+            throw new XMLStreamException("Unknown SaxBits type: " + current.getClass());
+        }
+    }
+
+    public int nextTag() throws XMLStreamException {
+        if (logger.isDebugEnabled()) {
+            logger.debug("SAXStreamReaderAdaptor: nextTag()");
+        }
+        return 0;
+    }
+
+    public void require(int arg0, String arg1, String arg2) throws XMLStreamException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public boolean standaloneSet() {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    public void enableLogging(Logger logger) {
+        this.logger = logger;
+    }
+
+}

Propchange: cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/stax/SAXStreamReaderAdaptor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/stax/SAXStreamReaderAdaptor.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/stax/SAXStreamReaderAdaptor.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/stax/SAXStreamWriterAdaptor.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/stax/SAXStreamWriterAdaptor.java?rev=582103&view=auto
==============================================================================
--- cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/stax/SAXStreamWriterAdaptor.java (added)
+++ cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/stax/SAXStreamWriterAdaptor.java Fri Oct  5 00:44:35 2007
@@ -0,0 +1,383 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * 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.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ * 
+ * $Id$
+ */
+package com.sourcesense.gt07.stax;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Stack;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.abdera.util.Constants;
+import org.apache.avalon.framework.logger.LogEnabled;
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.axiom.om.impl.llom.util.NamespaceContextImpl;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.AttributesImpl;
+
+
+public class SAXStreamWriterAdaptor implements XMLStreamWriter, LogEnabled {
+
+    private final ContentHandler contentHandler;
+    
+    private NamespaceContext namespaceContext;
+    
+    private Map<String, String> namespaces = new HashMap<String, String>();
+    
+    Stack<Element> elements = new Stack<Element>();
+
+    private Logger logger;
+    
+    public SAXStreamWriterAdaptor(ContentHandler contentHandler) {
+        this.contentHandler = contentHandler;
+        namespaces.put(Constants.APP_NS, Constants.APP_PREFIX);
+        this.namespaceContext = new NamespaceContextImpl(namespaces);
+    }
+
+    public void close() throws XMLStreamException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void flush() throws XMLStreamException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public NamespaceContext getNamespaceContext() {
+        /*
+        if (logger.isDebugEnabled()) {
+            logger.debug("getNamespaceContext()");
+        }
+        */
+        return this.namespaceContext;
+    }
+
+    public String getPrefix(String uri) throws XMLStreamException {
+        /*
+        if (logger.isDebugEnabled()) {
+            logger.debug("getPrefix(" + uri + ")");
+        }
+        */
+        return this.namespaces.get(uri);
+    }
+
+    public Object getProperty(String key) throws IllegalArgumentException {
+        return null;
+    }
+
+    public void setDefaultNamespace(String uri) throws XMLStreamException {
+        /*
+        if (logger.isDebugEnabled()) {
+            logger.debug("setDefaultNamespace(" + uri + ")");
+        }
+        */
+    }
+
+    public void setNamespaceContext(NamespaceContext nc) throws XMLStreamException {
+        /*
+        if (logger.isDebugEnabled()) {
+            logger.debug("setNamespaceContext(" + nc + ")");
+        }
+        */
+        this.namespaceContext = nc;
+    }
+
+    public void setPrefix(String prefix, String uri) throws XMLStreamException {
+        /*
+        if (logger.isDebugEnabled()) {
+            logger.debug("setPrefix(" + prefix + ", " + uri + ")");
+        }
+        */
+        namespaces.put(uri, prefix);
+    }
+
+    public void writeAttribute(String localName, String value) throws XMLStreamException {
+        if (logger.isDebugEnabled()) {
+            logger.debug("writeAttribute(" + localName + ", " + value + ")");
+            logger.debug(elements.toString());
+        }
+        Element currentElement = elements.peek();
+        AttributesImpl attrs = currentElement.attrs;
+        attrs.addAttribute("", localName, localName, "CDATA", value);
+
+    }
+
+    public void writeAttribute(String namespaceUri, String localName, String value) throws XMLStreamException {
+        if (logger.isDebugEnabled()) {
+            logger.debug("writeAttribute(" + namespaceUri + ", " + localName + ", " + value + ")");
+            logger.debug(elements.toString());
+        }
+        Element currentElement = elements.peek();
+        AttributesImpl attrs = currentElement.attrs;
+        attrs.addAttribute(namespaceUri, localName, localName, "CDATA", value);
+    }
+
+    public void writeAttribute(String prefix, String namespaceUri, String localName, String value) throws XMLStreamException {
+        if (logger.isDebugEnabled()) {
+            logger.debug("writeAttribute(" + prefix + ", " + namespaceUri + ", " + localName + ", " + value + ")");
+            logger.debug(elements.toString());
+        }
+        Element currentElement = elements.peek();
+        AttributesImpl attrs = currentElement.attrs;
+        attrs.addAttribute(namespaceUri, localName, prefix + ":" + localName, "CDATA", value);
+    }
+
+    public void writeCData(String data) throws XMLStreamException {
+        if (logger.isDebugEnabled()) {
+            logger.debug("writeCData(" + data + ")");
+        }
+    }
+
+    public void writeCharacters(String text) throws XMLStreamException {
+        if (logger.isDebugEnabled()) {
+            logger.debug("writeCharacters(" + text + ")");
+        }
+        if (!elements.isEmpty()) {
+            Element currentElement = elements.peek();
+            currentElement.start(this.contentHandler);
+        }
+        try {
+            this.contentHandler.characters(text.toCharArray(), 0, text.length());
+        } catch (SAXException e) {
+            throw new XMLStreamException(e);
+        }
+    }
+
+    public void writeCharacters(char[] text, int start, int len) throws XMLStreamException {
+        if (logger.isDebugEnabled()) {
+            logger.debug("writeCharacters(" + new String(text) + ", " + start + ", " + len + ")");
+        }
+        if (!elements.isEmpty()) {
+            Element currentElement = elements.peek();
+            currentElement.start(this.contentHandler);
+        }
+        try {
+            this.contentHandler.characters(text, start, len);
+        } catch (SAXException e) {
+            throw new XMLStreamException(e);
+        }
+    }
+
+    public void writeComment(String data) throws XMLStreamException {
+        if (logger.isDebugEnabled()) {
+            logger.debug("writeComment(" + data + ")");
+        }
+    }
+
+    public void writeDTD(String dtd) throws XMLStreamException {
+        if (logger.isDebugEnabled()) {
+            logger.debug("writeDTD(" + dtd + ")");
+        }
+    }
+
+    public void writeDefaultNamespace(String namespaceURI) throws XMLStreamException {
+        if (logger.isDebugEnabled()) {
+            logger.debug("writeDefaultNamespace(" + namespaceURI + ")");
+        }
+    }
+
+    public void writeEmptyElement(String localName) throws XMLStreamException {
+        if (logger.isDebugEnabled()) {
+            logger.debug("writeEmptyElement(" + localName + ")");
+        }
+    }
+
+    public void writeEmptyElement(String namespaceUri, String localName) throws XMLStreamException {
+        if (logger.isDebugEnabled()) {
+            logger.debug("writeEmptyElement(" + namespaceUri + ", " + localName + ")");
+        }
+    }
+
+    public void writeEmptyElement(String prefix, String namespaceUri, String localName) throws XMLStreamException {
+        if (logger.isDebugEnabled()) {
+            logger.debug("writeEmptyElement(" + prefix + ", " + namespaceUri + ", " + localName + ")");
+        }
+    }
+
+    public void writeEndDocument() throws XMLStreamException {
+        if (logger.isDebugEnabled()) {
+            logger.debug("writeEndDocument()");
+        }
+        try {
+            this.contentHandler.endDocument();
+        } catch (SAXException e) {
+            throw new XMLStreamException(e);
+        }
+    }
+
+    public void writeEndElement() throws XMLStreamException {
+        if (logger.isDebugEnabled()) {
+            logger.debug("writeEndElement()");
+            logger.debug(elements.toString());
+        }
+        Element currentElement = elements.pop();
+        currentElement.start(this.contentHandler);
+        currentElement.end(this.contentHandler);
+    }
+
+    public void writeEntityRef(String arg0) throws XMLStreamException {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void writeNamespace(String prefix, String namespaceUri) throws XMLStreamException {
+        if (logger.isDebugEnabled()) {
+            logger.debug("writeNamespace(" + prefix + ", " + namespaceUri + ")");
+        }
+    }
+
+    public void writeProcessingInstruction(String target) throws XMLStreamException {
+        if (logger.isDebugEnabled()) {
+            logger.debug("writeProcessingInstruction(" + target + ")");
+        }
+        try {
+            this.contentHandler.processingInstruction("xml", target);
+        } catch (SAXException e) {
+            throw new XMLStreamException(e);
+        }
+    }
+
+    public void writeProcessingInstruction(String target, String data) throws XMLStreamException {
+        if (logger.isDebugEnabled()) {
+            logger.debug("writeProcessingInstruction(" + target + ", " + data + ")");
+        }
+    }
+
+    public void writeStartDocument() throws XMLStreamException {
+        if (logger.isDebugEnabled()) {
+            logger.debug("writeStartDocument()");
+        }
+        try {
+            this.contentHandler.startDocument();
+        } catch (SAXException e) {
+            throw new XMLStreamException(e);
+        }
+    }
+
+    public void writeStartDocument(String version) throws XMLStreamException {
+        if (logger.isDebugEnabled()) {
+            logger.debug("writeStartDocument(" + version + ")");
+        }
+        try {
+            this.contentHandler.startDocument();
+            // TODO: how do we set the version on the ContentHandler interface?
+        } catch (SAXException e) {
+            throw new XMLStreamException(e);
+        }
+    }
+
+    public void writeStartDocument(String encoding, String version) throws XMLStreamException {
+        if (logger.isDebugEnabled()) {
+            logger.debug("writeStartDocument(" + encoding + ", " + version + ")");
+        }
+        try {
+            this.contentHandler.startDocument();
+            // TODO: how do we set the version and the encoding on the ContentHandler interface?
+        } catch (SAXException e) {
+            throw new XMLStreamException(e);
+        }
+    }
+
+    public void writeStartElement(String localName) throws XMLStreamException {
+        if (logger.isDebugEnabled()) {
+            logger.debug("writeStartElement(" + localName + ")");
+            logger.debug(elements.toString());
+        }
+        if (!elements.isEmpty()) {
+            Element currentElement = elements.peek();
+            currentElement.start(this.contentHandler);
+        }
+        Element element = new Element("", localName, localName);
+        elements.push(element);
+    }
+
+    public void writeStartElement(String namespaceUri, String localName) throws XMLStreamException {
+        if (logger.isDebugEnabled()) {
+            logger.debug("writeStartElement(" + namespaceUri + ", " + localName + ")");
+            logger.debug(elements.toString());
+        }
+        if (!elements.isEmpty()) {
+            Element currentElement = elements.peek();
+            currentElement.start(this.contentHandler);
+        }
+        Element element = new Element(namespaceUri, localName, localName);
+        elements.push(element);
+    }
+
+    public void writeStartElement(String prefix, String localName, String namespaceUri) throws XMLStreamException {
+        if (logger.isDebugEnabled()) {
+            logger.debug("writeStartElement(" + prefix + ", " + localName + ", " + namespaceUri + ")");
+            logger.debug(elements.toString());
+        }
+        if (!elements.isEmpty()) {
+            Element currentElement = elements.peek();
+            currentElement.start(this.contentHandler);
+        }
+        String qName = prefix.equals("") ? localName : prefix + ":" + localName;
+        Element element = new Element(namespaceUri, qName, localName);
+        elements.push(element);
+    }
+
+    class Element {
+        public String uri;
+        public String localName;
+        public String qName;
+        public AttributesImpl attrs;
+        public boolean started = false;
+        
+        public Element(String uri, String qName, String localName) {
+            this.uri = uri;
+            this.qName = qName;
+            this.localName = localName;
+            this.attrs = new AttributesImpl();
+        }
+        
+        public void start(ContentHandler contentHandler) throws XMLStreamException {
+            if (!started) try {
+                contentHandler.startElement(this.uri, this.localName, this.qName, this.attrs);
+                this.started = true;
+            } catch (SAXException e) {
+                throw new XMLStreamException(e);
+            }
+        }
+
+        public void end(ContentHandler contentHandler) throws XMLStreamException {
+            try {
+                contentHandler.endElement(this.uri, this.localName, this.qName);
+                this.started = true;
+            } catch (SAXException e) {
+                throw new XMLStreamException(e);
+            }
+        }
+        
+        @Override
+        public String toString() {
+            return this.qName;
+        }
+    }
+
+    public void enableLogging(Logger logger) {
+        this.logger = logger;
+    }
+}

Propchange: cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/stax/SAXStreamWriterAdaptor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/stax/SAXStreamWriterAdaptor.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/stax/SAXStreamWriterAdaptor.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/stax/SAXWriter.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/stax/SAXWriter.java?rev=582103&view=auto
==============================================================================
--- cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/stax/SAXWriter.java (added)
+++ cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/stax/SAXWriter.java Fri Oct  5 00:44:35 2007
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * 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.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ * 
+ * $Id$
+ */
+package com.sourcesense.gt07.stax;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.Writer;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.abdera.model.Base;
+import org.apache.abdera.model.Document;
+import org.apache.abdera.parser.stax.FOMWriterOptions;
+import org.apache.abdera.util.AbstractNamedWriter;
+import org.apache.abdera.writer.NamedWriter;
+import org.apache.abdera.writer.WriterOptions;
+import org.apache.axiom.om.OMDocument;
+import org.apache.axiom.om.OMElement;
+
+
+public class SAXWriter extends AbstractNamedWriter implements NamedWriter {
+
+    private static final String[] FORMATS = {
+      "application/atom+xml",
+      "application/atomserv+xml",
+      "application/xml"
+    };
+    
+    private final XMLStreamWriter streamWriter;
+    
+    public SAXWriter(XMLStreamWriter streamWriter) {
+      super("PrettyXML", FORMATS);
+      this.streamWriter = streamWriter;
+    }
+
+    @Override
+    protected WriterOptions initDefaultWriterOptions() {
+        return new FOMWriterOptions();
+    }
+
+    public Object write(Base arg0, WriterOptions arg1) throws IOException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public void writeTo(Base base, OutputStream out, WriterOptions options) throws IOException {
+        writeTo(base);
+    }
+
+    public void writeTo(Base base, Writer writer, WriterOptions options) throws IOException {
+        writeTo(base);
+    }
+
+    public void writeTo(Base base) {
+        options = new FOMWriterOptions();
+        try {
+            OMElement om = (base instanceof Document) ? 
+                    (OMElement)((Document) base).getRoot() : 
+                        (OMElement) base;
+                    String charset = options.getCharset();
+                    if (om.getParent() != null && om.getParent() instanceof OMDocument) {
+                        OMDocument doc = (OMDocument) om.getParent();
+                        streamWriter.writeStartDocument(
+                                charset != null ? charset : 
+                                    doc.getCharsetEncoding(), doc.getXMLVersion());
+                    }
+                    om.serialize(streamWriter);
+                    streamWriter.writeEndDocument();
+        } catch (XMLStreamException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+}

Propchange: cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/stax/SAXWriter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/stax/SAXWriter.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/stax/SAXWriter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/transformers/CreateAtomEntryTransformer.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/transformers/CreateAtomEntryTransformer.java?rev=582103&view=auto
==============================================================================
--- cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/transformers/CreateAtomEntryTransformer.java (added)
+++ cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/transformers/CreateAtomEntryTransformer.java Fri Oct  5 00:44:35 2007
@@ -0,0 +1,264 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * 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.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ * 
+ * $Id$
+ */
+package com.sourcesense.gt07.transformers;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Date;
+import java.util.Map;
+import java.util.UUID;
+
+import org.apache.abdera.Abdera;
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.model.Document;
+import org.apache.abdera.model.Entry;
+import org.apache.abdera.parser.ParserOptions;
+import org.apache.abdera.parser.stax.FOMBuilder;
+import org.apache.abdera.parser.stax.FOMFactory;
+import org.apache.abdera.parser.stax.FOMParserOptions;
+import org.apache.avalon.framework.CascadingRuntimeException;
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.cocoon.ProcessingException;
+import org.apache.cocoon.components.source.util.SourceUtil;
+import org.apache.cocoon.environment.ObjectModelHelper;
+import org.apache.cocoon.environment.Request;
+import org.apache.cocoon.environment.Response;
+import org.apache.cocoon.environment.SourceResolver;
+import org.apache.cocoon.transformation.AbstractTransformer;
+import org.apache.cocoon.util.avalon.CLLoggerWrapper;
+import org.apache.cocoon.xml.SaxBuffer;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.excalibur.source.Source;
+import org.apache.excalibur.source.SourceException;
+import org.xml.sax.Attributes;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+
+import com.sourcesense.gt07.stax.SAXStreamReaderAdaptor;
+import com.sourcesense.gt07.stax.SAXStreamWriterAdaptor;
+import com.sourcesense.gt07.stax.SAXWriter;
+
+
+public class CreateAtomEntryTransformer extends AbstractTransformer {
+
+    /** The default logger for this class. */
+    private Log logger = LogFactory.getLog(getClass());
+
+    /** The source object for the directory. */
+    protected Source source;
+    
+    private Map<String, Object> objectModel;
+
+    private Abdera abdera;
+
+    private Factory factory;
+    
+    /**
+     * Initialize logger
+     *
+     * @throws Exception 
+     */
+    public void init() throws Exception {
+        this.enableLogging(new CLLoggerWrapper(this.logger));
+    }
+
+    protected SaxBuffer saxBuffer = new SaxBuffer();
+    
+    @SuppressWarnings("unchecked")
+    public void setup(SourceResolver resolver, Map objectModel, String src, Parameters par) throws ProcessingException, SAXException, IOException {
+        if (src == null) {
+            throw new ProcessingException("No src attribute specified.");
+        }
+
+        try {
+            this.source = resolver.resolveURI(src);
+        } catch (SourceException se) {
+            throw SourceUtil.handle(se);
+        }
+       
+        this.objectModel = objectModel;
+        this.abdera = new Abdera();
+        this.factory = abdera.getFactory();
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public void endDocument() throws SAXException {
+        saxBuffer.endDocument();
+        SAXStreamReaderAdaptor reader = new SAXStreamReaderAdaptor(saxBuffer.getBits());
+        reader.enableLogging(this.getLogger());
+        // Dependency on FOM* classes is ugly. Note this is Abdera's AXIOM-based implementation-specific.
+        // This FOM is not Cocoon's Flow Object Model.
+        ParserOptions options = new FOMParserOptions(factory);
+        FOMBuilder builder = new FOMBuilder((FOMFactory) factory, reader, options);
+        Document<Entry> doc = builder.getFomDocument();
+        Request req = ObjectModelHelper.getRequest(objectModel);
+        Entry entry = doc.getRoot();
+        if ("PUT".equals(req.getMethod())) {
+            // Should be an update
+            try {
+                updateEntry(req, entry);
+            } catch (IOException e) {
+                throw new CascadingRuntimeException(e.toString(), e);
+            }
+        } else if ("POST".equals(req.getMethod())) {
+            // Should be a new entry
+            try {
+                createEntry(req, entry);
+            } catch (IOException e) {
+                throw new CascadingRuntimeException(e.toString(), e);
+            }
+        } else {
+            throw new RuntimeException("Unsupported method: " + req.getMethod());
+        }
+        
+    }
+
+    private void updateEntry(Request req, Entry entry) throws MalformedURLException, IOException {
+        File file = new File(new URL(this.source.getURI()).getFile());
+        FileReader fr = new FileReader(file);
+        Document<Entry> doc = abdera.getParser().parse(fr); 
+        Entry oldEntry = doc.getRoot();
+        entry.setId(oldEntry.getId().toString());
+        entry.setUpdated(new Date());
+        fr.close();
+        FileWriter fw = new FileWriter(file);
+        entry.writeTo(fw);
+        fw.close();
+        if (logger.isInfoEnabled()) {
+            logger.info("New version of entry saved at " + file.getAbsolutePath());
+        }
+    }
+
+    private void createEntry(Request req, Entry entry) throws MalformedURLException, IOException {
+        // Just use a random UUID as basis for entry id and file name
+        String uuid = UUID.randomUUID().toString();
+        entry.setId("urn:uuid:" + uuid);
+        
+        // Save entry to a file
+        File file = new File(new File(new URL(this.source.getURI()).getFile()), uuid);
+        FileWriter fw = new FileWriter(file);
+        entry.writeTo(fw);
+        fw.close();
+        if (logger.isInfoEnabled()) {
+            logger.info("New entry saved at " + file.getAbsolutePath());
+        }
+        
+        // Set the Location header according to protocol
+        Response resp = ObjectModelHelper.getResponse(objectModel);
+        URL location = new URL(req.getScheme(), req.getServerName(), req.getServerPort(), 
+                req.getContextPath() + req.getRequestURI() + uuid);
+        resp.addHeader("Location", location.toString());
+        // Stream the new entry out
+        SAXStreamWriterAdaptor ssw = new SAXStreamWriterAdaptor(this.contentHandler);
+        SAXWriter writer = new SAXWriter(ssw);
+        writer.writeTo(entry);
+    }
+
+    @Override
+    public void characters(char[] ch, int start, int length) throws SAXException {
+        saxBuffer.characters(ch, start, length);
+    }
+
+    @Override
+    public void comment(char[] ch, int start, int length) throws SAXException {
+        saxBuffer.comment(ch, start, length);
+    }
+
+    @Override
+    public void endCDATA() throws SAXException {
+        saxBuffer.endCDATA();
+    }
+
+    @Override
+    public void endDTD() throws SAXException {
+        saxBuffer.endDTD();
+    }
+
+    @Override
+    public void endElement(String namespaceURI, String localName, String name) throws SAXException {
+        saxBuffer.endElement(namespaceURI, localName, name);
+    }
+
+    @Override
+    public void endEntity(String name) throws SAXException {
+        saxBuffer.endEntity(name);
+    }
+
+    @Override
+    public void endPrefixMapping(String prefix) throws SAXException {
+        saxBuffer.endPrefixMapping(prefix);
+    }
+
+    @Override
+    public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException {
+        saxBuffer.ignorableWhitespace(ch, start, length);
+    }
+
+    @Override
+    public void processingInstruction(String target, String data) throws SAXException {
+        saxBuffer.processingInstruction(target, data);
+    }
+
+    @Override
+    public void setDocumentLocator(Locator locator) {
+        saxBuffer.setDocumentLocator(locator);
+    }
+
+    @Override
+    public void skippedEntity(String name) throws SAXException {
+        saxBuffer.skippedEntity(name);
+    }
+
+    @Override
+    public void startCDATA() throws SAXException {
+        saxBuffer.startCDATA();
+    }
+
+    @Override
+    public void startDocument() throws SAXException {
+        saxBuffer.startDocument();
+    }
+
+    @Override
+    public void startDTD(String name, String publicId, String systemId) throws SAXException {
+        saxBuffer.startDTD(name, publicId, systemId);
+    }
+
+    @Override
+    public void startElement(String namespaceURI, String localName, String name, Attributes atts) throws SAXException {
+        saxBuffer.startElement(namespaceURI, localName, name, atts);
+    }
+
+    @Override
+    public void startEntity(String name) throws SAXException {
+        saxBuffer.startEntity(name);
+    }
+
+    @Override
+    public void startPrefixMapping(String prefix, String uri) throws SAXException {
+        saxBuffer.startPrefixMapping(prefix, uri);
+    }
+}

Propchange: cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/transformers/CreateAtomEntryTransformer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/transformers/CreateAtomEntryTransformer.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: cocoon/whiteboard/gt07/src/main/java/com/sourcesense/gt07/transformers/CreateAtomEntryTransformer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: cocoon/whiteboard/gt07/src/main/resources/COB-INF/sitemap.xmap
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/gt07/src/main/resources/COB-INF/sitemap.xmap?rev=582103&view=auto
==============================================================================
--- cocoon/whiteboard/gt07/src/main/resources/COB-INF/sitemap.xmap (added)
+++ cocoon/whiteboard/gt07/src/main/resources/COB-INF/sitemap.xmap Fri Oct  5 00:44:35 2007
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You 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.
+-->
+<map:sitemap xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://apache.org/cocoon/sitemap/1.0 http://cocoon.apache.org/schema/sitemap/cocoon-sitemap-1.0.xsd"
+ xmlns:map="http://apache.org/cocoon/sitemap/1.0">
+
+  <map:components>
+  
+    <map:selectors>
+      <map:selector name="method" src="org.apache.cocoon.selection.RequestMethodSelector"/>
+    </map:selectors>
+    
+  	<map:generators>
+  	  <map:generator name="atomsvc" src="com.sourcesense.gt07.generators.AtomServiceGenerator"/>
+      <map:generator name="atomfeed" src="com.sourcesense.gt07.generators.AtomFeedGenerator"/>
+      <map:generator name="atomentry" src="com.sourcesense.gt07.generators.AtomEntryGenerator"/>
+  	</map:generators>
+    
+    <map:transformers>
+      <map:transformer name="create-entry" src="com.sourcesense.gt07.transformers.CreateAtomEntryTransformer"/>
+    </map:transformers>
+    
+    <map:serializers>
+      <map:serializer name="atomsvc" src="org.apache.cocoon.serialization.XMLSerializer"
+         mime-type="application/atomsvc+xml">
+        <encoding>UTF-8</encoding>
+      </map:serializer>
+      <map:serializer name="atomfeed" src="org.apache.cocoon.serialization.XMLSerializer"
+         mime-type="application/atom+xml;type=feed">
+        <encoding>UTF-8</encoding>
+      </map:serializer>
+      <map:serializer name="atomentry" src="org.apache.cocoon.serialization.XMLSerializer"
+         mime-type="application/atom+xml;type=entry">
+        <encoding>UTF-8</encoding>
+      </map:serializer>
+    </map:serializers>
+    
+  </map:components>
+  
+  <map:pipelines>
+    <map:pipeline id="demo">
+    
+      <map:match pattern="">
+        <map:generate type="atomsvc" src="demo"/>
+        <map:serialize type="atomsvc"/>
+      </map:match>
+      
+      <map:match pattern="*/entries/">
+        <map:select type="method">
+          <map:when test="POST">
+            <map:generate type="stream"/>
+            <map:transform type="create-entry" src="demo/{0}"/>
+            <map:serialize type="atomentry" status-code="201"/>
+          </map:when>
+          <map:when test="GET">
+            <map:generate type="atomfeed" src="demo/{0}">
+            	<map:parameter name="title" value="CocoonGT 2007 Demo Feed"/>
+            </map:generate>
+            <map:serialize type="atomfeed"/>
+          </map:when>
+        </map:select>
+      </map:match>
+      
+      <map:match pattern="*/entries/*">
+        <map:select type="method">
+          <map:when test="PUT">
+            <map:generate type="stream"/>
+            <map:transform type="create-entry" src="demo/{0}"/>
+            <map:serialize type="atomentry" status-code="200"/>
+          </map:when>
+          <map:when test="GET">
+            <map:generate type="atomentry" src="demo/{0}"/>
+            <map:serialize type="atomentry"/>
+          </map:when>
+        </map:select>
+      </map:match>
+      
+	</map:pipeline>      
+
+  </map:pipelines>
+
+</map:sitemap>
\ No newline at end of file

Propchange: cocoon/whiteboard/gt07/src/main/resources/COB-INF/sitemap.xmap
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/whiteboard/gt07/src/main/resources/COB-INF/sitemap.xmap
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Added: cocoon/whiteboard/gt07/src/main/resources/META-INF/cocoon/spring/servlet-service.xml
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/gt07/src/main/resources/META-INF/cocoon/spring/servlet-service.xml?rev=582103&view=auto
==============================================================================
--- cocoon/whiteboard/gt07/src/main/resources/META-INF/cocoon/spring/servlet-service.xml (added)
+++ cocoon/whiteboard/gt07/src/main/resources/META-INF/cocoon/spring/servlet-service.xml Fri Oct  5 00:44:35 2007
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you 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
+  und
+-->
+<!--+
+    | @version $Id$
+    +-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xmlns:servlet="http://cocoon.apache.org/schema/servlet"
+  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+  http://cocoon.apache.org/schema/servlet http://cocoon.apache.org/schema/servlet/cocoon-servlet-1.0.xsd">
+  
+  <bean id="com.sourcesense.GT07.block" class="org.apache.cocoon.sitemap.SitemapServlet">
+    <servlet:context mount-path="/GT07" context-path="blockcontext:/GT07/"/>
+  </bean>
+  
+</beans>

Propchange: cocoon/whiteboard/gt07/src/main/resources/META-INF/cocoon/spring/servlet-service.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/whiteboard/gt07/src/main/resources/META-INF/cocoon/spring/servlet-service.xml
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: cocoon/whiteboard/gt07/src/main/resources/META-INF/cocoon/spring/servlet-service.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: cocoon/whiteboard/gt07/src/test/java/com/sourcesense/gt07/stax/SAXWriterTest.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/gt07/src/test/java/com/sourcesense/gt07/stax/SAXWriterTest.java?rev=582103&view=auto
==============================================================================
--- cocoon/whiteboard/gt07/src/test/java/com/sourcesense/gt07/stax/SAXWriterTest.java (added)
+++ cocoon/whiteboard/gt07/src/test/java/com/sourcesense/gt07/stax/SAXWriterTest.java Fri Oct  5 00:44:35 2007
@@ -0,0 +1,132 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * 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.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ * 
+ * $Id$
+ */
+package com.sourcesense.gt07.stax;
+
+import java.util.Date;
+
+import junit.framework.TestCase;
+
+import org.apache.abdera.Abdera;
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.model.Collection;
+import org.apache.abdera.model.Entry;
+import org.apache.abdera.model.Feed;
+import org.apache.abdera.model.Link;
+import org.apache.abdera.model.Service;
+import org.apache.abdera.model.Workspace;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+
+
+public class SAXWriterTest extends TestCase {
+
+    private Abdera abdera;
+
+    private Factory factory;
+
+    protected final Log logger = LogFactory.getLog(getClass());
+    
+    @Override
+    public void setUp() {
+        this.abdera = new Abdera();
+        this.factory = abdera.getFactory();
+    }
+    
+    public void testWriteServiceDocument() throws Exception {
+        ContentHandler contentHandler = new TestContentHandler();
+        SAXStreamWriterAdaptor ssw = new SAXStreamWriterAdaptor(contentHandler);
+        SAXWriter writer = new SAXWriter(ssw);
+        Service svc = factory.newService();
+        Workspace ws1 = svc.addWorkspace("ws1");
+        Collection c1ws1 = ws1.addCollection("c1", "http://server/ws1/c1/");
+        writer.writeTo(svc);
+        
+    }
+    
+    public void testWriteLink() throws Exception {
+        ContentHandler contentHandler = new TestContentHandler();
+        SAXStreamWriterAdaptor ssw = new SAXStreamWriterAdaptor(contentHandler);
+        SAXWriter writer = new SAXWriter(ssw);
+        Feed feed = factory.newFeed();
+        Entry entry = factory.newEntry();
+        entry.setUpdated(new Date());
+        Link link = factory.newLink();
+        link.setHref("http://example.com/entry");
+        entry.addLink(link);
+        feed.addEntry(entry);
+        writer.writeTo(feed);
+    }
+    
+    class TestContentHandler implements ContentHandler {
+
+        public void characters(char[] ch, int start, int length) throws SAXException {
+            logger.debug("chars([...], " + start + ", " + length + ")");
+        }
+
+        public void endDocument() throws SAXException {
+            logger.debug("endDocument()");
+        }
+
+        public void endElement(String uri, String localName, String qName) throws SAXException {
+            logger.debug("endElement(" + uri + ", " + localName + ", " + qName + ")");
+        }
+
+        public void endPrefixMapping(String prefix) throws SAXException {
+            logger.debug("endPrefixMapping(" + prefix + ")");
+        }
+
+        public void ignorableWhitespace(char[] arg0, int arg1, int arg2) throws SAXException {
+            // TODO Auto-generated method stub
+            
+        }
+
+        public void processingInstruction(String arg0, String arg1) throws SAXException {
+            // TODO Auto-generated method stub
+            
+        }
+
+        public void setDocumentLocator(Locator arg0) {
+            // TODO Auto-generated method stub
+            
+        }
+
+        public void skippedEntity(String arg0) throws SAXException {
+            // TODO Auto-generated method stub
+            
+        }
+
+        public void startDocument() throws SAXException {
+            logger.debug("startDocument");
+        }
+
+        public void startElement(String uri, String localName, String qName, Attributes atts)  throws SAXException {
+            logger.debug("startElement(" + uri + ", " + localName + ", " + qName + ", " + atts + ")");
+        }
+
+        public void startPrefixMapping(String prefix, String uri) throws SAXException {
+            logger.debug("startPrefixMapping(" + prefix + ", " + uri + ")");
+        }
+        
+    }
+}

Propchange: cocoon/whiteboard/gt07/src/test/java/com/sourcesense/gt07/stax/SAXWriterTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/whiteboard/gt07/src/test/java/com/sourcesense/gt07/stax/SAXWriterTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: cocoon/whiteboard/gt07/src/test/java/com/sourcesense/gt07/stax/SAXWriterTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: cocoon/whiteboard/gt07/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/gt07/src/test/resources/log4j.properties?rev=582103&view=auto
==============================================================================
--- cocoon/whiteboard/gt07/src/test/resources/log4j.properties (added)
+++ cocoon/whiteboard/gt07/src/test/resources/log4j.properties Fri Oct  5 00:44:35 2007
@@ -0,0 +1,11 @@
+log4j.debug=false
+
+log4j.rootLogger=DEBUG,Console
+
+log4j.appender.Console=org.apache.log4j.ConsoleAppender
+log4j.appender.Console.layout=org.apache.log4j.PatternLayout
+log4j.appender.Console.layout.conversionPattern=%-5p - %-26.26c{1} - %m\n
+
+log4j.logger.com.sourcesense.gt07.stax=TRACE,Console
+log4j.additivity.com.sourcesense.gt07.stax=false
+

Propchange: cocoon/whiteboard/gt07/src/test/resources/log4j.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/whiteboard/gt07/src/test/resources/log4j.properties
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id