abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r614798 [1/2] - in /incubator/abdera/java/branches/server_refactor_all: ./ .settings/ examples/src/main/java/org/apache/abdera/examples/appserver/ server/src/main/java/org/apache/abdera/protocol/server/ server/src/main/java/org/apache/abder...
Date Thu, 24 Jan 2008 05:38:30 GMT
Author: jmsnell
Date: Wed Jan 23 21:38:20 2008
New Revision: 614798

URL: http://svn.apache.org/viewvc?rev=614798&view=rev
Log:
Fix test cases and examples. Add AbstractWorkspaceProvider back in.  While it may not make
sense for a Provider to always be a WorkspaceManager, it makes things significantly easier 
when implementing a custom Provider implementation that uses a single Adapter.

This also adds the new Filter mechanism. Filters use the same model as Servlet Filters but use the
RequestContext/ResponseContext interfaces.  They are invoked by the AbderaServlet just prior to invoking the Provider.

Added:
    incubator/abdera/java/branches/server_refactor_all/.classpath
    incubator/abdera/java/branches/server_refactor_all/.settings/
    incubator/abdera/java/branches/server_refactor_all/.settings/org.eclipse.jdt.core.prefs
    incubator/abdera/java/branches/server_refactor_all/examples/src/main/java/org/apache/abdera/examples/appserver/AppServer.java
    incubator/abdera/java/branches/server_refactor_all/examples/src/main/java/org/apache/abdera/examples/appserver/CustomProvider.java
    incubator/abdera/java/branches/server_refactor_all/examples/src/main/java/org/apache/abdera/examples/appserver/SimpleAdapter.java
    incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/Filter.java
    incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/FilterChain.java
    incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/context/RequestContextWrapper.java
    incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/context/ResponseContextWrapper.java
    incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractWorkspaceProvider.java
    incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/SimpleCollectionInfo.java
      - copied, changed from r614767, incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/SimpleCollection.java
    incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/SimpleWorkspaceInfo.java
    incubator/abdera/java/branches/server_refactor_all/server/src/test/java/org/apache/abdera/protocol/server/test/custom/
      - copied from r614767, incubator/abdera/java/branches/server_refactor_all/server/src/test/java/org/apache/abdera/protocol/server/test/simple/
    incubator/abdera/java/branches/server_refactor_all/server/src/test/java/org/apache/abdera/protocol/server/test/custom/CustomProvider.java
      - copied, changed from r614767, incubator/abdera/java/branches/server_refactor_all/server/src/test/java/org/apache/abdera/protocol/server/test/simple/SimpleProvider.java
    incubator/abdera/java/branches/server_refactor_all/server/src/test/java/org/apache/abdera/protocol/server/test/custom/CustomProviderTest.java
      - copied, changed from r614767, incubator/abdera/java/branches/server_refactor_all/server/src/test/java/org/apache/abdera/protocol/server/test/simple/SimpleTest.java
    incubator/abdera/java/branches/server_refactor_all/server/src/test/java/org/apache/abdera/protocol/server/test/custom/OpenSearchFilter.java
    incubator/abdera/java/branches/server_refactor_all/server/src/test/java/org/apache/abdera/protocol/server/test/customer/
      - copied from r614767, incubator/abdera/java/branches/server_refactor_all/server/src/test/java/org/apache/abdera/protocol/server/customer/
    incubator/abdera/java/branches/server_refactor_all/src/
Removed:
    incubator/abdera/java/branches/server_refactor_all/examples/src/main/java/org/apache/abdera/examples/appserver/SimpleProvider.java
    incubator/abdera/java/branches/server_refactor_all/examples/src/main/java/org/apache/abdera/examples/appserver/SimpleProviderManager.java
    incubator/abdera/java/branches/server_refactor_all/examples/src/main/java/org/apache/abdera/examples/appserver/SimpleServiceContext.java
    incubator/abdera/java/branches/server_refactor_all/examples/src/main/java/org/apache/abdera/examples/appserver/SimpleTargetResolver.java
    incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/SimpleCollection.java
    incubator/abdera/java/branches/server_refactor_all/server/src/test/java/org/apache/abdera/protocol/server/customer/
    incubator/abdera/java/branches/server_refactor_all/server/src/test/java/org/apache/abdera/protocol/server/test/custom/SimpleProvider.java
    incubator/abdera/java/branches/server_refactor_all/server/src/test/java/org/apache/abdera/protocol/server/test/custom/SimpleTest.java
    incubator/abdera/java/branches/server_refactor_all/server/src/test/java/org/apache/abdera/protocol/server/test/impl/
    incubator/abdera/java/branches/server_refactor_all/server/src/test/java/org/apache/abdera/protocol/server/test/simple/
Modified:
    incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/CategoriesInfo.java
    incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/CategoryInfo.java
    incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/CollectionInfo.java
    incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/Provider.java
    incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/RequestContext.java
    incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/WorkspaceInfo.java
    incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/context/AbstractRequestContext.java
    incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/context/ResponseContextException.java
    incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractCollectionAdapter.java
    incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractEntityCollectionAdapter.java
    incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractProvider.java
    incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractWorkspaceManager.java
    incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/DefaultWorkspaceManager.java
    incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/SimpleCategoriesInfo.java
    incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/SimpleCategoryInfo.java
    incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/provider/basic/BasicProvider.java
    incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/provider/basic/BasicWorkspace.java
    incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/servlet/AbderaServlet.java
    incubator/abdera/java/branches/server_refactor_all/server/src/test/java/org/apache/abdera/protocol/server/test/basic/BasicTest.java
    incubator/abdera/java/branches/server_refactor_all/server/src/test/java/org/apache/abdera/protocol/server/test/custom/SimpleAdapter.java
    incubator/abdera/java/branches/server_refactor_all/server/src/test/java/org/apache/abdera/protocol/server/test/customer/Customer.java
    incubator/abdera/java/branches/server_refactor_all/server/src/test/java/org/apache/abdera/protocol/server/test/customer/CustomerAdapter.java
    incubator/abdera/java/branches/server_refactor_all/server/src/test/java/org/apache/abdera/protocol/server/test/customer/CustomerAdapterTest.java
    incubator/abdera/java/branches/server_refactor_all/server/src/test/resources/abdera/adapter/sample.properties

Added: incubator/abdera/java/branches/server_refactor_all/.classpath
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor_all/.classpath?rev=614798&view=auto
==============================================================================
--- incubator/abdera/java/branches/server_refactor_all/.classpath (added)
+++ incubator/abdera/java/branches/server_refactor_all/.classpath Wed Jan 23 21:38:20 2008
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="spring/src/test/java"/>
+	<classpathentry kind="src" path="parser/src/main/resources"/>
+	<classpathentry kind="src" path="extensions/geo/src/test/java"/>
+	<classpathentry kind="src" path="extensions/gdata/src/test/java"/>
+	<classpathentry kind="src" path="core/src/main/resources"/>
+	<classpathentry kind="src" path="extensions/opensearch/src/main/java"/>
+	<classpathentry kind="src" path="extensions/opensearch/src/test/resources"/>
+	<classpathentry kind="src" path="jcr/src/test/resources"/>
+	<classpathentry kind="src" path="jcr/src/main/java"/>
+	<classpathentry kind="src" path="extensions/wsse/src/main/resources"/>
+	<classpathentry kind="src" path="extensions/sharing/src/test/java"/>
+	<classpathentry kind="src" path="examples/src/main/java"/>
+	<classpathentry kind="src" path="server/src/test/java"/>
+	<classpathentry kind="src" path="dependencies/i18n/src/test/java"/>
+	<classpathentry kind="src" path="extensions/json/src/main/java"/>
+	<classpathentry kind="src" path="extensions/json/src/test/resources"/>
+	<classpathentry kind="src" path="extensions/main/src/main/resources"/>
+	<classpathentry kind="src" path="extensions/oauth/src/test/java"/>
+	<classpathentry kind="src" path="parser/src/test/resources"/>
+	<classpathentry kind="src" path="parser/src/main/java"/>
+	<classpathentry kind="src" path="extensions/converters/src/main/java"/>
+	<classpathentry kind="src" path="core/src/main/java"/>
+	<classpathentry kind="src" path="core/src/test/resources"/>
+	<classpathentry kind="src" path="extensions/media/src/main/resources"/>
+	<classpathentry kind="src" path="extensions/opensearch/src/test/java"/>
+	<classpathentry kind="src" path="jcr/src/test/java"/>
+	<classpathentry kind="src" path="extensions/wsse/src/main/java"/>
+	<classpathentry kind="src" path="extensions/json/src/test/java"/>
+	<classpathentry kind="src" path="extensions/main/src/main/java"/>
+	<classpathentry kind="src" path="extensions/main/src/test/resources"/>
+	<classpathentry kind="src" path="security/src/test/resources"/>
+	<classpathentry kind="src" path="security/src/main/java"/>
+	<classpathentry kind="src" path="parser/src/test/java"/>
+	<classpathentry kind="src" path="extensions/converters/src/test/java"/>
+	<classpathentry kind="src" path="core/src/test/java"/>
+	<classpathentry kind="src" path="extensions/media/src/main/java"/>
+	<classpathentry kind="src" path="extensions/media/src/test/resources"/>
+	<classpathentry kind="src" path="client/src/main/java"/>
+	<classpathentry kind="src" path="contrib/rss/src/main/resources"/>
+	<classpathentry kind="src" path="extensions/html/src/main/resources"/>
+	<classpathentry kind="src" path="extensions/main/src/test/java"/>
+	<classpathentry kind="src" path="security/src/test/java"/>
+	<classpathentry kind="src" path="extensions/media/src/test/java"/>
+	<classpathentry kind="src" path="spring/src/main/resources"/>
+	<classpathentry kind="src" path="extensions/geo/src/main/resources"/>
+	<classpathentry kind="src" path="extensions/gdata/src/main/resources"/>
+	<classpathentry kind="src" path="client/src/test/java"/>
+	<classpathentry kind="src" path="protocol/src/main/resources"/>
+	<classpathentry kind="src" path="extensions/sharing/src/main/resources"/>
+	<classpathentry kind="src" path="contrib/rss/src/main/java"/>
+	<classpathentry kind="src" path="contrib/rss/src/test/resources"/>
+	<classpathentry kind="src" path="extensions/html/src/main/java"/>
+	<classpathentry kind="src" path="extensions/html/src/test/resources"/>
+	<classpathentry kind="src" path="dependencies/i18n/src/main/resources"/>
+	<classpathentry kind="src" path="extensions/oauth/src/main/resources"/>
+	<classpathentry kind="src" path="spring/src/test/resources"/>
+	<classpathentry kind="src" path="spring/src/main/java"/>
+	<classpathentry kind="src" path="extensions/geo/src/test/resources"/>
+	<classpathentry kind="src" path="extensions/geo/src/main/java"/>
+	<classpathentry kind="src" path="extensions/gdata/src/test/resources"/>
+	<classpathentry kind="src" path="extensions/gdata/src/main/java"/>
+	<classpathentry kind="src" path="extensions/opensearch/src/main/resources"/>
+	<classpathentry kind="src" path="protocol/src/main/java"/>
+	<classpathentry kind="src" path="jcr/src/main/resources"/>
+	<classpathentry kind="src" path="extensions/sharing/src/test/resources"/>
+	<classpathentry kind="src" path="extensions/sharing/src/main/java"/>
+	<classpathentry kind="src" path="examples/src/main/resources"/>
+	<classpathentry kind="src" path="contrib/rss/src/test/java"/>
+	<classpathentry kind="src" path="extensions/html/src/test/java"/>
+	<classpathentry kind="src" path="server/src/test/resources"/>
+	<classpathentry kind="src" path="server/src/main/java"/>
+	<classpathentry kind="src" path="dependencies/i18n/src/main/java"/>
+	<classpathentry kind="src" path="extensions/json/src/main/resources"/>
+	<classpathentry kind="src" path="extensions/oauth/src/main/java"/>
+	<classpathentry kind="src" path="extensions/oauth/src/test/resources"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="lib" path="dependencies/axiom-api-1.2.5.jar"/>
+	<classpathentry kind="lib" path="dependencies/axiom-impl-1.2.5.jar"/>
+	<classpathentry kind="lib" path="dependencies/bcprov-jdk15-137.jar"/>
+	<classpathentry kind="lib" path="dependencies/commons-codec-1.3.jar"/>
+	<classpathentry kind="lib" path="dependencies/commons-httpclient-3.1.jar"/>
+	<classpathentry kind="lib" path="dependencies/commons-logging-1.0.4.jar"/>
+	<classpathentry kind="lib" path="dependencies/geronimo-activation_1.0.2_spec-1.1.jar"/>
+	<classpathentry kind="lib" path="dependencies/geronimo-servlet_2.4_spec-1.0.jar"/>
+	<classpathentry kind="lib" path="dependencies/htmlparser-1.0.5.jar"/>
+	<classpathentry kind="lib" path="dependencies/jaxen-1.1.1.jar"/>
+	<classpathentry kind="lib" path="dependencies/jetty-6.1.3.jar"/>
+	<classpathentry kind="lib" path="dependencies/jetty-util-6.1.3.jar"/>
+	<classpathentry kind="lib" path="dependencies/junit-4.3.jar"/>
+	<classpathentry kind="lib" path="dependencies/log4j-1.2.14.jar"/>
+	<classpathentry kind="lib" path="dependencies/serializer.jar"/>
+	<classpathentry kind="lib" path="dependencies/stax-api-1.0.1.jar"/>
+	<classpathentry kind="lib" path="dependencies/wstx-asl-3.2.1.jar"/>
+	<classpathentry kind="lib" path="dependencies/xmlsec-1.4.1.jar"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>

Added: incubator/abdera/java/branches/server_refactor_all/.settings/org.eclipse.jdt.core.prefs
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor_all/.settings/org.eclipse.jdt.core.prefs?rev=614798&view=auto
==============================================================================
--- incubator/abdera/java/branches/server_refactor_all/.settings/org.eclipse.jdt.core.prefs (added)
+++ incubator/abdera/java/branches/server_refactor_all/.settings/org.eclipse.jdt.core.prefs Wed Jan 23 21:38:20 2008
@@ -0,0 +1,12 @@
+#Wed Jan 23 18:37:28 GMT-08:00 2008
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5

Added: incubator/abdera/java/branches/server_refactor_all/examples/src/main/java/org/apache/abdera/examples/appserver/AppServer.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor_all/examples/src/main/java/org/apache/abdera/examples/appserver/AppServer.java?rev=614798&view=auto
==============================================================================
--- incubator/abdera/java/branches/server_refactor_all/examples/src/main/java/org/apache/abdera/examples/appserver/AppServer.java (added)
+++ incubator/abdera/java/branches/server_refactor_all/examples/src/main/java/org/apache/abdera/examples/appserver/AppServer.java Wed Jan 23 21:38:20 2008
@@ -0,0 +1,25 @@
+package org.apache.abdera.examples.appserver;
+
+import org.apache.abdera.protocol.server.ServiceManager;
+import org.apache.abdera.protocol.server.servlet.AbderaServlet;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.servlet.Context;
+import org.mortbay.jetty.servlet.ServletHolder;
+
+public class AppServer {
+
+  public static void main(String... args) throws Exception {
+    int port = 9002;
+    try {
+      port = args.length > 0 ? Integer.parseInt(args[0]) : 9002;
+    } catch (Exception e) {}
+    Server server = new Server(port);
+    Context context = new Context(server, "/", Context.SESSIONS);
+    ServletHolder servletHolder = new ServletHolder(new AbderaServlet());
+    servletHolder.setInitParameter(ServiceManager.PROVIDER, CustomProvider.class.getName());
+    context.addServlet(servletHolder, "/*");
+    server.start();
+    server.join();
+  }
+  
+}

Added: incubator/abdera/java/branches/server_refactor_all/examples/src/main/java/org/apache/abdera/examples/appserver/CustomProvider.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor_all/examples/src/main/java/org/apache/abdera/examples/appserver/CustomProvider.java?rev=614798&view=auto
==============================================================================
--- incubator/abdera/java/branches/server_refactor_all/examples/src/main/java/org/apache/abdera/examples/appserver/CustomProvider.java (added)
+++ incubator/abdera/java/branches/server_refactor_all/examples/src/main/java/org/apache/abdera/examples/appserver/CustomProvider.java Wed Jan 23 21:38:20 2008
@@ -0,0 +1,83 @@
+/*
+ * 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.
+ */
+package org.apache.abdera.examples.appserver;
+
+import org.apache.abdera.protocol.server.CollectionAdapter;
+import org.apache.abdera.protocol.server.Filter;
+import org.apache.abdera.protocol.server.FilterChain;
+import org.apache.abdera.protocol.server.RequestContext;
+import org.apache.abdera.protocol.server.ResponseContext;
+import org.apache.abdera.protocol.server.TargetType;
+import org.apache.abdera.protocol.server.context.RequestContextWrapper;
+import org.apache.abdera.protocol.server.impl.AbstractWorkspaceProvider;
+import org.apache.abdera.protocol.server.impl.RegexTargetResolver;
+import org.apache.abdera.protocol.server.impl.SimpleCollectionInfo;
+import org.apache.abdera.protocol.server.impl.SimpleWorkspaceInfo;
+
+public class CustomProvider 
+  extends AbstractWorkspaceProvider {
+
+  private final CollectionAdapter adapter;
+  
+  public CustomProvider() {
+    // Create the adapter that will handle all of the requests processed by this provider
+    this.adapter = new SimpleAdapter();
+    
+    // The target resolver provides the URL path mappings
+    super.setTargetResolver(      
+      new RegexTargetResolver()
+        .setPattern("/atom(\\?[^#]*)?", TargetType.TYPE_SERVICE)
+        .setPattern("/atom/([^/#?]+);categories", TargetType.TYPE_CATEGORIES, "collection")
+        .setPattern("/atom/([^/#?;]+)(\\?[^#]*)?", TargetType.TYPE_COLLECTION, "collection")
+        .setPattern("/atom/([^/#?]+)/([^/#?]+)(\\?[^#]*)?", TargetType.TYPE_ENTRY, "collection","entry")
+    );
+    
+    // Add a Workspace descriptor so the provider can generate an atompub service document
+    SimpleWorkspaceInfo workspace = new SimpleWorkspaceInfo();
+    workspace.setTitle("A Simple Workspace");
+    workspace.addCollection(
+      new SimpleCollectionInfo(
+        "feed",
+        "A simple feed",
+        "/atom/feed",
+        "application/atom+xml;type=entry"
+      ));
+    addWorkspace(workspace);
+    
+    // Add one of more Filters to be invoked prior to invoking the Provider
+    addFilter(new SimpleFilter());
+  }
+
+  public CollectionAdapter getCollectionAdapter(
+    RequestContext request) {
+      return adapter;
+  }
+
+  public class SimpleFilter 
+    implements Filter {
+      public ResponseContext filter(
+        RequestContext request, 
+        FilterChain chain) {
+          RequestContextWrapper rcw = new RequestContextWrapper(request);
+          rcw.setAttribute("offset", 10);
+          rcw.setAttribute("count", 10);
+          return chain.next(rcw);
+      }    
+  }
+
+}

Added: incubator/abdera/java/branches/server_refactor_all/examples/src/main/java/org/apache/abdera/examples/appserver/SimpleAdapter.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor_all/examples/src/main/java/org/apache/abdera/examples/appserver/SimpleAdapter.java?rev=614798&view=auto
==============================================================================
--- incubator/abdera/java/branches/server_refactor_all/examples/src/main/java/org/apache/abdera/examples/appserver/SimpleAdapter.java (added)
+++ incubator/abdera/java/branches/server_refactor_all/examples/src/main/java/org/apache/abdera/examples/appserver/SimpleAdapter.java Wed Jan 23 21:38:20 2008
@@ -0,0 +1,253 @@
+/*
+* 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.
+*/
+package org.apache.abdera.examples.appserver;
+
+import java.io.IOException;
+import java.util.Date;
+
+import org.apache.abdera.Abdera;
+import org.apache.abdera.i18n.text.UrlEncoding;
+import org.apache.abdera.model.Document;
+import org.apache.abdera.model.Entry;
+import org.apache.abdera.model.Feed;
+import org.apache.abdera.parser.ParseException;
+import org.apache.abdera.protocol.server.ProviderHelper;
+import org.apache.abdera.protocol.server.RequestContext;
+import org.apache.abdera.protocol.server.ResponseContext;
+import org.apache.abdera.protocol.server.TargetType;
+import org.apache.abdera.protocol.server.RequestContext.Scope;
+import org.apache.abdera.protocol.server.context.BaseResponseContext;
+import org.apache.abdera.protocol.server.context.ResponseContextException;
+import org.apache.abdera.protocol.server.context.StreamWriterResponseContext;
+import org.apache.abdera.protocol.server.impl.AbstractCollectionAdapter;
+import org.apache.abdera.util.Constants;
+import org.apache.abdera.writer.StreamWriter;
+
+@SuppressWarnings("unchecked")
+public class SimpleAdapter 
+  extends AbstractCollectionAdapter {
+  
+  @Override
+  public String getAuthor() throws ResponseContextException {
+    return "Simple McGee";
+  }
+
+  @Override
+  public String getId(RequestContext request) {
+    return "tag:example.org,2008:feed";
+  }
+
+  public String getHref(RequestContext request) {
+    return "atom/feed";
+  }
+
+  public String getTitle(RequestContext request) {
+    return "A simple feed";
+  }
+
+  public ResponseContext extensionRequest(RequestContext request) {
+    return ProviderHelper.notallowed(
+      request, 
+      "Method Not Allowed", 
+      ProviderHelper.getDefaultMethods(request));
+  }
+  
+  private Document<Feed> getFeedDocument(RequestContext context) throws ResponseContextException {
+    Feed feed = (Feed)context.getAttribute(Scope.SESSION, "feed");
+    if (feed == null) {
+      feed = createFeedBase(context);
+      context.setAttribute(Scope.SESSION, "feed", feed);
+    }
+    return feed.getDocument();
+  }
+
+  public ResponseContext getFeed(
+    RequestContext request) {
+      Document<Feed> feed;
+      try {
+        feed = getFeedDocument(request);
+      } catch (ResponseContextException e) {
+        return e.getResponseContext();
+      } 
+      
+      return ProviderHelper.returnBase(
+        feed, 
+        200, 
+        feed.getRoot().getUpdated())
+          .setEntityTag(
+            ProviderHelper.calculateEntityTag(
+              feed.getRoot()));
+  }
+
+  
+  public ResponseContext deleteEntry(
+    RequestContext request) {
+      Entry entry = getAbderaEntry(request);
+      if (entry != null)
+        entry.discard();
+      return ProviderHelper.nocontent();
+  }
+
+  public ResponseContext getEntry(
+    RequestContext request) {
+      Entry entry = (Entry) getAbderaEntry(request);
+      if (entry != null) {
+        Feed feed = entry.getParentElement();
+        entry = (Entry) entry.clone();
+        entry.setSource(feed.getAsSource());
+        Document<Entry> entry_doc = entry.getDocument();
+        return 
+          ProviderHelper.returnBase(
+            entry_doc, 
+            200, 
+            entry.getEdited())
+              .setEntityTag(
+                ProviderHelper.calculateEntityTag(
+                  entry));
+      } else {
+        return ProviderHelper.notfound(request);
+      }
+  }
+
+  public ResponseContext postEntry(
+    RequestContext request) {
+      Abdera abdera = request.getAbdera();
+      try {
+        Document<Entry> entry_doc = 
+          (Document<Entry>) request.getDocument(
+            abdera.getParser()).clone();
+        if (entry_doc != null) {
+          Entry entry = entry_doc.getRoot();
+          if (!ProviderHelper.isValidEntry(entry))
+            return ProviderHelper.badrequest(request);
+          setEntryDetails(
+            entry, 
+            abdera.getFactory().newUuidUri());
+          Feed feed = getFeedDocument(request).getRoot();
+          feed.insertEntry(entry);
+          feed.setUpdated(new Date());
+          BaseResponseContext rc = 
+            (BaseResponseContext) ProviderHelper.returnBase(
+              entry_doc, 201, entry.getEdited());
+          return 
+            rc.setLocation(
+                ProviderHelper.resolveBase(request).resolve(
+                  entry.getEditLinkResolvedHref()).toString())
+              .setContentLocation(rc.getLocation().toString())
+              .setEntityTag(ProviderHelper.calculateEntityTag(entry));
+        } else {
+          return ProviderHelper.badrequest(request);
+        }
+      } catch (ParseException pe) {
+        return ProviderHelper.notsupported(request);
+      } catch (ClassCastException cce) {
+        return ProviderHelper.notsupported(request);
+      } catch (Exception e) {
+        return ProviderHelper.badrequest(request);
+    }
+  }
+  
+  private void setEntryDetails(
+    Entry entry, 
+    String id) {
+      entry.setUpdated(new Date());
+      entry.setEdited(entry.getUpdated());
+      entry.getIdElement().setValue(id);
+      entry.addLink(
+        "/atom/feed/" + entry.getId().toASCIIString(), 
+        "edit");
+  }
+  
+  public ResponseContext putEntry(
+    RequestContext request) {
+      Abdera abdera = request.getAbdera();
+      Entry orig_entry = getAbderaEntry(request);
+      if (orig_entry != null) {
+        try {
+          Document<Entry> entry_doc = 
+            (Document<Entry>) request.getDocument(
+              abdera.getParser()).clone();
+          if (entry_doc != null) {
+            Entry entry = entry_doc.getRoot();
+            if (!entry.getId().equals(orig_entry.getId()))
+              return ProviderHelper.conflict(request);
+            if (!ProviderHelper.isValidEntry(entry))
+              return ProviderHelper.badrequest(request);
+            setEntryDetails(
+              entry, 
+              orig_entry.getId().toString());
+            orig_entry.discard();
+            Feed feed = getFeedDocument(request).getRoot();
+            feed.insertEntry(entry);
+            feed.setUpdated(new Date());
+            return ProviderHelper.nocontent();
+          } else {
+            return ProviderHelper.badrequest(request);
+          }
+        } catch (ParseException pe) {
+          return ProviderHelper.notsupported(request);
+        } catch (ClassCastException cce) {
+          return ProviderHelper.notsupported(request);
+        } catch (Exception e) {
+          return ProviderHelper.badrequest(request);
+        }
+      } else {
+        return ProviderHelper.notfound(request);
+      }
+  }
+  
+  private Entry getAbderaEntry(
+    RequestContext request) {
+      try { 
+        return getFeedDocument( 
+          request)
+            .getRoot()
+            .getEntry(
+              getEntryID(request)); 
+      } catch (Exception e) {}
+      return null;
+  }
+  
+  public String getEntryID(
+    RequestContext request) {
+      if (request.getTarget().getType() != TargetType.TYPE_ENTRY) 
+        return null;
+      String[] segments = request.getUri().toString().split("/");
+      return UrlEncoding.decode(segments[segments.length-1]);
+  }
+  
+  public ResponseContext getCategories(
+    RequestContext request) {
+      return 
+        new StreamWriterResponseContext(request.getAbdera()) {
+          protected void writeTo(
+            StreamWriter sw) 
+              throws IOException {
+            sw.startDocument()
+              .startCategories(false)
+              .writeCategory("foo")
+              .writeCategory("bar")
+              .writeCategory("baz")
+              .endCategories()
+              .endDocument();
+          }
+        }
+        .setStatus(200)
+        .setContentType(Constants.CAT_MEDIA_TYPE);    
+  }
+}
\ No newline at end of file

Modified: incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/CategoriesInfo.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/CategoriesInfo.java?rev=614798&r1=614797&r2=614798&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/CategoriesInfo.java (original)
+++ incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/CategoriesInfo.java Wed Jan 23 21:38:20 2008
@@ -17,7 +17,6 @@
 */
 package org.apache.abdera.protocol.server;
 
-import org.apache.abdera.Abdera;
 import org.apache.abdera.model.Categories;
 
 public interface CategoriesInfo 
@@ -29,5 +28,5 @@
 
   String getHref(RequestContext request);
   
-  Categories asCategoriesElement(Abdera abdera);
+  Categories asCategoriesElement(RequestContext request);
 }

Modified: incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/CategoryInfo.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/CategoryInfo.java?rev=614798&r1=614797&r2=614798&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/CategoryInfo.java (original)
+++ incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/CategoryInfo.java Wed Jan 23 21:38:20 2008
@@ -17,7 +17,6 @@
 */
 package org.apache.abdera.protocol.server;
 
-import org.apache.abdera.Abdera;
 import org.apache.abdera.model.Category;
 
 public interface CategoryInfo {
@@ -28,5 +27,5 @@
   
   String getLabel(RequestContext request);
   
-  Category asCategoryElement(Abdera abdera);
+  Category asCategoryElement(RequestContext request);
 }

Modified: incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/CollectionInfo.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/CollectionInfo.java?rev=614798&r1=614797&r2=614798&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/CollectionInfo.java (original)
+++ incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/CollectionInfo.java Wed Jan 23 21:38:20 2008
@@ -17,6 +17,8 @@
 */
 package org.apache.abdera.protocol.server;
 
+import org.apache.abdera.model.Collection;
+
 
 public interface CollectionInfo {
 
@@ -27,5 +29,7 @@
   String[] getAccepts(RequestContext request);
   
   CategoriesInfo[] getCategoriesInfo(RequestContext request);
+  
+  Collection asCollectionElement(RequestContext request);
 
 }

Added: incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/Filter.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/Filter.java?rev=614798&view=auto
==============================================================================
--- incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/Filter.java (added)
+++ incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/Filter.java Wed Jan 23 21:38:20 2008
@@ -0,0 +1,24 @@
+/*
+* 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.
+*/
+package org.apache.abdera.protocol.server;
+
+public interface Filter {
+  
+  ResponseContext filter(RequestContext request, FilterChain chain);
+  
+}

Added: incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/FilterChain.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/FilterChain.java?rev=614798&view=auto
==============================================================================
--- incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/FilterChain.java (added)
+++ incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/FilterChain.java Wed Jan 23 21:38:20 2008
@@ -0,0 +1,43 @@
+/*
+* 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.
+*/
+package org.apache.abdera.protocol.server;
+
+import java.util.Arrays;
+import java.util.Iterator;
+
+public class FilterChain {
+
+  private final Iterator<Filter> filters;
+  private final Provider provider;
+  
+  public FilterChain( 
+    Provider provider,
+    RequestContext request) {
+      this.provider = provider;
+      this.filters = 
+        Arrays.asList(
+          provider.getFilters(request)).iterator();
+  }
+  
+  public ResponseContext next(RequestContext request) {
+    return filters.hasNext() ?
+      filters.next().filter(request, this) :
+      provider.process(request);
+  }
+  
+}

Modified: incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/Provider.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/Provider.java?rev=614798&r1=614797&r2=614798&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/Provider.java (original)
+++ incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/Provider.java Wed Jan 23 21:38:20 2008
@@ -40,4 +40,6 @@
   
   ResponseContext process(RequestContext request);
   
+  Filter[] getFilters(RequestContext request);
+  
 }

Modified: incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/RequestContext.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/RequestContext.java?rev=614798&r1=614797&r2=614798&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/RequestContext.java (original)
+++ incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/RequestContext.java Wed Jan 23 21:38:20 2008
@@ -80,6 +80,8 @@
   
   String[] getAttributeNames(Scope scope);
   
+  RequestContext setAttribute(String name, Object value);
+  
   RequestContext setAttribute(Scope scope, String name, Object value);
   
   InputStream getInputStream() throws IOException;

Modified: incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/WorkspaceInfo.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/WorkspaceInfo.java?rev=614798&r1=614797&r2=614798&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/WorkspaceInfo.java (original)
+++ incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/WorkspaceInfo.java Wed Jan 23 21:38:20 2008
@@ -19,10 +19,13 @@
 
 import java.util.Collection;
 
+import org.apache.abdera.model.Workspace;
+
 public interface WorkspaceInfo {
 
   String getTitle(RequestContext requsest);
   
   Collection<CollectionInfo> getCollections(RequestContext request);
   
+  Workspace asWorkspaceElement(RequestContext request);
 }

Modified: incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/context/AbstractRequestContext.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/context/AbstractRequestContext.java?rev=614798&r1=614797&r2=614798&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/context/AbstractRequestContext.java (original)
+++ incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/context/AbstractRequestContext.java Wed Jan 23 21:38:20 2008
@@ -153,4 +153,7 @@
     return cpath == null ? uri : uri.substring(cpath.length());
   }
   
+  public RequestContext setAttribute(String name, Object value) {
+    return setAttribute(Scope.REQUEST, name, value);
+  }
 }

Added: incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/context/RequestContextWrapper.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/context/RequestContextWrapper.java?rev=614798&view=auto
==============================================================================
--- incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/context/RequestContextWrapper.java (added)
+++ incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/context/RequestContextWrapper.java Wed Jan 23 21:38:20 2008
@@ -0,0 +1,278 @@
+/*
+* 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.
+*/
+package org.apache.abdera.protocol.server.context;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.security.Principal;
+import java.util.Date;
+import java.util.List;
+import java.util.Locale;
+
+import javax.activation.MimeType;
+import javax.security.auth.Subject;
+
+import org.apache.abdera.Abdera;
+import org.apache.abdera.i18n.iri.IRI;
+import org.apache.abdera.model.Document;
+import org.apache.abdera.model.Element;
+import org.apache.abdera.parser.ParseException;
+import org.apache.abdera.parser.Parser;
+import org.apache.abdera.parser.ParserOptions;
+import org.apache.abdera.protocol.server.Provider;
+import org.apache.abdera.protocol.server.RequestContext;
+import org.apache.abdera.protocol.server.Target;
+import org.apache.abdera.util.EntityTag;
+
+public class RequestContextWrapper 
+  implements RequestContext {
+  
+  protected final RequestContext request;
+  
+  public RequestContextWrapper(RequestContext request) {
+    this.request = request;
+  }
+  
+  public Abdera getAbdera() {
+    return request.getAbdera();
+  }
+  
+  public Object getAttribute(Scope scope, String name) {
+    return request.getAttribute(scope,name);
+  }
+  
+  public String[] getAttributeNames(Scope scope) {
+    return request.getAttributeNames(scope);
+  }
+  
+  public IRI getBaseUri() {
+    return request.getBaseUri();
+  }
+  
+  public String getContextPath() {
+    return request.getContextPath();
+  }
+  
+  public <T extends Element> Document<T> getDocument() 
+    throws ParseException, IOException {
+      return request.getDocument();
+  }
+  
+  public <T extends Element> Document<T> getDocument(Parser parser)
+      throws ParseException, IOException {
+    return request.getDocument(parser);
+  }
+  
+  public <T extends Element> Document<T> getDocument(Parser parser,
+      ParserOptions options) throws ParseException, IOException {
+    return request.getDocument(parser,options);
+  }
+  
+  public <T extends Element> Document<T> getDocument(ParserOptions options)
+      throws ParseException, IOException {
+    return request.getDocument(options);
+  }
+  
+  public InputStream getInputStream() throws IOException {
+    return request.getInputStream();
+  }
+  
+  public String getMethod() {
+    return request.getMethod();
+  }
+  
+  public String getParameter(String name) {
+    return request.getParameter(name);
+  }
+  
+  public String[] getParameterNames() {
+    return request.getParameterNames();
+  }
+  
+  public List<String> getParameters(String name) {
+    return request.getParameters(name);
+  }
+  
+  public Locale getPreferredLocale() {
+    return request.getPreferredLocale();
+  }
+  
+  public Locale[] getPreferredLocales() {
+    return request.getPreferredLocales();
+  }
+  
+  public Principal getPrincipal() {
+    return request.getPrincipal();
+  }
+  
+  public Object getProperty(Property property) {
+    return request.getProperty(property);
+  }
+  
+  public Provider getProvider() {
+    return request.getProvider();
+  }
+  
+  public Reader getReader() throws IOException {
+    return request.getReader();
+  }
+  
+  public IRI getResolvedUri() {
+    return request.getResolvedUri();
+  }
+  
+  public Subject getSubject() {
+    return request.getSubject();
+  }
+  
+  public Target getTarget() {
+    return request.getTarget();
+  }
+  
+  public String getTargetPath() {
+    return request.getTargetPath();
+  }
+  
+  public IRI getUri() {
+    return request.getUri();
+  }
+  
+  public boolean isUserInRole(String role) {
+    return request.isUserInRole(role);
+  }
+  
+  public RequestContext setAttribute(Scope scope, String name, Object value) {
+    request.setAttribute(scope, name, value);
+    return this;
+  }
+  
+  public RequestContext setAttribute(String name, Object value) {
+    request.setAttribute(name, value);
+    return this;
+  }
+  
+  public String getAccept() {
+    return request.getAccept();
+  }
+  
+  public String getAcceptCharset() {
+    return request.getAcceptCharset();
+  }
+  
+  public String getAcceptEncoding() {
+    return request.getAcceptEncoding();
+  }
+  
+  public String getAcceptLanguage() {
+    return request.getAcceptLanguage();
+  }
+  
+  public String getAuthorization() {
+    return request.getAuthorization();
+  }
+  
+  public EntityTag[] getIfMatch() {
+    return request.getIfMatch();
+  }
+  
+  public Date getIfModifiedSince() {
+    return request.getIfModifiedSince();
+  }
+  
+  public EntityTag[] getIfNoneMatch() {
+    return request.getIfNoneMatch();
+  }
+  
+  public Date getIfUnmodifiedSince() {
+    return request.getIfUnmodifiedSince();
+  }
+  
+  public long getMaxStale() {
+    return request.getMaxStale();
+  }
+  
+  public long getMinFresh() {
+    return request.getMinFresh();
+  }
+  
+  public boolean isOnlyIfCached() {
+    return request.isOnlyIfCached();
+  }
+  
+  public String getCacheControl() {
+    return request.getCacheControl();
+  }
+  
+  public String getContentLanguage() {
+    return request.getContentLanguage();
+  }
+  
+  public IRI getContentLocation() {
+    return request.getContentLocation();
+  }
+  
+  public MimeType getContentType() {
+    return request.getContentType();
+  }
+  
+  public Date getDateHeader(String name) {
+    return request.getDateHeader(name);
+  }
+  
+  public String getDecodedHeader(String name) {
+    return request.getDecodedHeader(name);
+  }
+  
+  public String[] getDecodedHeaders(String name) {
+    return request.getDecodedHeaders(name);
+  }
+  
+  public String getHeader(String name) {
+    return request.getHeader(name);
+  }
+  
+  public String[] getHeaderNames() {
+    return request.getHeaderNames();
+  }
+  
+  public Object[] getHeaders(String name) {
+    return request.getHeaders(name);
+  }
+  
+  public long getMaxAge() {
+    return request.getMaxAge();
+  }
+  
+  public String getSlug() {
+    return request.getSlug();
+  }
+  
+  public boolean isNoCache() {
+    return request.isNoCache();
+  }
+  
+  public boolean isNoStore() {
+    return request.isNoStore();
+  }
+  
+  public boolean isNoTransform() {
+    return request.isNoTransform();
+  }
+  
+}

Modified: incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/context/ResponseContextException.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/context/ResponseContextException.java?rev=614798&r1=614797&r2=614798&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/context/ResponseContextException.java (original)
+++ incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/context/ResponseContextException.java Wed Jan 23 21:38:20 2008
@@ -19,6 +19,9 @@
 
 
 public class ResponseContextException extends Exception {
+
+  private static final long serialVersionUID = -3031651143835987024L;
+
   private AbstractResponseContext responseContext;
 
   public ResponseContextException(AbstractResponseContext responseContext, Throwable t) {

Added: incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/context/ResponseContextWrapper.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/context/ResponseContextWrapper.java?rev=614798&view=auto
==============================================================================
--- incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/context/ResponseContextWrapper.java (added)
+++ incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/context/ResponseContextWrapper.java Wed Jan 23 21:38:20 2008
@@ -0,0 +1,313 @@
+/*
+* 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.
+*/
+package org.apache.abdera.protocol.server.context;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Date;
+
+import javax.activation.MimeType;
+
+import org.apache.abdera.i18n.iri.IRI;
+import org.apache.abdera.i18n.text.CharUtils.Profile;
+import org.apache.abdera.protocol.server.ResponseContext;
+import org.apache.abdera.util.EntityTag;
+import org.apache.abdera.writer.Writer;
+
+public class ResponseContextWrapper 
+  implements ResponseContext {
+  
+  protected final ResponseContext response;
+  
+  public ResponseContextWrapper(ResponseContext response) {
+    this.response = response;
+  }
+  
+  public ResponseContext addEncodedHeader(
+    String name, 
+    String charset,
+    String value) {
+      return response.addEncodedHeader(name, charset, value);
+  }
+  
+  public ResponseContext addEncodedHeaders(
+    String name, 
+    String charset,
+    String... vals) {
+      return response.addEncodedHeaders(name, charset, vals);
+  }
+  
+  public ResponseContext addHeader(String name, Object value) {
+    return response.addHeader(name, value);
+  }
+  
+  public ResponseContext addHeaders(String name, Object... vals) {
+    return response.addHeaders(name, vals);
+  }
+  
+  public boolean hasEntity() {
+    return response.hasEntity();
+  }
+  
+  public ResponseContext removeHeader(String name) {
+    return response.removeHeader(name);
+  }
+  
+  public ResponseContext setAge(long age) {
+    return response.setAge(age);
+  }
+  
+  public ResponseContext setAllow(String method) {
+    return response.setAllow(method);
+  }
+  
+  public ResponseContext setAllow(String... methods) {
+    return response.setAllow(methods);
+  }
+  
+  public ResponseContext setContentLanguage(String language) {
+    return response.setContentLanguage(language);
+  }
+  
+  public ResponseContext setContentLength(long length) {
+    return response.setContentLength(length);
+  }
+  
+  public ResponseContext setContentLocation(String uri) {
+    return response.setContentLocation(uri);
+  }
+  
+  public ResponseContext setContentType(String type) {
+    return response.setContentType(type);
+  }
+  
+  public ResponseContext setContentType(String type, String charset) {
+    return response.setContentType(type, charset);
+  }
+  
+  public ResponseContext setEncodedHeader(
+    String name, 
+    String charset,
+    String value) {
+      return response.setEncodedHeader(name, charset, value);
+  }
+  
+  public ResponseContext setEncodedHeader(
+    String name, 
+    String charset,
+    String... vals) {
+      return response.setEncodedHeader(name, charset, vals);
+  }
+  
+  public ResponseContext setEntityTag(String etag) {
+    return response.setEntityTag(etag);
+  }
+  
+  public ResponseContext setEntityTag(EntityTag etag) {
+    return response.setEntityTag(etag);
+  }
+  
+  public ResponseContext setEscapedHeader(
+    String name, 
+    Profile profile,
+    String value) {
+      return response.setEscapedHeader(name, profile, value);
+  }
+  
+  public ResponseContext setExpires(Date date) {
+    return response.setExpires(date);
+  }
+  
+  public ResponseContext setHeader(String name, Object value) {
+    return response.setHeader(name, value);
+  }
+  
+  public ResponseContext setHeader(String name, Object... vals) {
+    return response.setHeader(name, vals);
+  }
+  
+  public ResponseContext setLastModified(Date date) {
+    return response.setLastModified(date);
+  }
+  
+  public ResponseContext setLocation(String uri) {
+    return response.setLocation(uri);
+  }
+  
+  public ResponseContext setSlug(String slug) {
+    return response.setSlug(slug);
+  }
+  
+  public ResponseContext setStatus(int status) {
+    return response.setStatus(status);
+  }
+  
+  public ResponseContext setStatusText(String text) {
+    return response.setStatusText(text);
+  }
+  
+  public ResponseContext setWriter(Writer writer) {
+    return response.setWriter(writer);
+  }
+  
+  public void writeTo(OutputStream out) throws IOException {
+    response.writeTo(out);
+  }
+  
+  public void writeTo(java.io.Writer javaWriter) throws IOException {
+    response.writeTo(javaWriter);
+  }
+  
+  public void writeTo(OutputStream out, Writer writer) throws IOException {
+    response.writeTo(out, writer);
+  }
+  
+  public void writeTo(java.io.Writer javaWriter, Writer abderaWriter)
+      throws IOException {
+    response.writeTo(javaWriter, abderaWriter);
+  }
+  
+  public long getAge() {
+    return response.getAge();
+  }
+  
+  public String getAllow() {
+    return response.getAllow();
+  }
+  
+  public long getContentLength() {
+    return response.getContentLength();
+  }
+  
+  public EntityTag getEntityTag() {
+    return response.getEntityTag();
+  }
+  
+  public Date getExpires() {
+    return response.getExpires();
+  }
+  
+  public Date getLastModified() {
+    return response.getLastModified();
+  }
+  
+  public IRI getLocation() {
+    return response.getLocation();
+  }
+  
+  public String[] getNoCacheHeaders() {
+    return response.getNoCacheHeaders();
+  }
+  
+  public String[] getPrivateHeaders() {
+    return response.getPrivateHeaders();
+  }
+  
+  public long getSMaxAge() {
+    return response.getSMaxAge();
+  }
+  
+  public int getStatus() {
+    return response.getStatus();
+  }
+  
+  public String getStatusText() {
+    return response.getStatusText();
+  }
+  
+  public ResponseType getType() {
+    return response.getType();
+  }
+  
+  public boolean isMustRevalidate() {
+    return response.isMustRevalidate();
+  }
+  
+  public boolean isPrivate() {
+    return response.isPrivate();
+  }
+  
+  public boolean isProxyRevalidate() {
+    return response.isProxyRevalidate();
+  }
+  
+  public boolean isPublic() {
+    return response.isPublic();
+  }
+  
+  public String getCacheControl() {
+    return response.getCacheControl();
+  }
+  
+  public String getContentLanguage() {
+    return response.getContentLanguage();
+  }
+  
+  public IRI getContentLocation() {
+    return response.getContentLocation();
+  }
+  
+  public MimeType getContentType() {
+    return response.getContentType();
+  }
+  
+  public Date getDateHeader(String name) {
+    return response.getDateHeader(name);
+  }
+  
+  public String getDecodedHeader(String name) {
+    return response.getDecodedHeader(name);
+  }
+  
+  public String[] getDecodedHeaders(String name) {
+    return response.getDecodedHeaders(name);
+  }
+  
+  public String getHeader(String name) {
+    return response.getHeader(name);
+  }
+  
+  public String[] getHeaderNames() {
+    return response.getHeaderNames();
+  }
+  
+  public Object[] getHeaders(String name) {
+    return response.getHeaders(name);
+  }
+  
+  public long getMaxAge() {
+    return response.getMaxAge();
+  }
+  
+  public String getSlug() {
+    return response.getSlug();
+  }
+  
+  public boolean isNoCache() {
+    return response.isNoCache();
+  }
+  
+  public boolean isNoStore() {
+    return response.isNoStore();
+  }
+  
+  public boolean isNoTransform() {
+    return response.isNoTransform();
+  }
+  
+}

Modified: incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractCollectionAdapter.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractCollectionAdapter.java?rev=614798&r1=614797&r2=614798&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractCollectionAdapter.java (original)
+++ incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractCollectionAdapter.java Wed Jan 23 21:38:20 2008
@@ -5,12 +5,11 @@
 import java.io.IOException;
 import java.util.Date;
 
-import javax.activation.MimeType;
-
 import org.apache.abdera.Abdera;
 import org.apache.abdera.factory.Factory;
 import org.apache.abdera.i18n.iri.IRI;
 import org.apache.abdera.i18n.text.UrlEncoding;
+import org.apache.abdera.model.Collection;
 import org.apache.abdera.model.Document;
 import org.apache.abdera.model.Entry;
 import org.apache.abdera.model.Feed;
@@ -28,12 +27,14 @@
 import org.apache.abdera.protocol.server.context.BaseResponseContext;
 import org.apache.abdera.protocol.server.context.EmptyResponseContext;
 import org.apache.abdera.protocol.server.context.ResponseContextException;
-import org.apache.abdera.util.MimeTypeHelper;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
-public abstract class AbstractCollectionAdapter implements CollectionAdapter, MediaCollectionAdapter,
-  Transactional, CollectionInfo {
+public abstract class AbstractCollectionAdapter 
+  implements CollectionAdapter, 
+             MediaCollectionAdapter,
+             Transactional, 
+             CollectionInfo {
 
   private final static Log log = LogFactory.getLog(AbstractEntityCollectionAdapter.class);
 
@@ -182,4 +183,14 @@
     return ProviderHelper.getDefaultMethods(request);
   }
 
+  public Collection asCollectionElement(RequestContext request) {
+    Collection collection = request.getAbdera().getFactory().newCollection();
+    collection.setHref(getHref(request));
+    collection.setTitle(getTitle(request));
+    collection.setAccept(getAccepts(request));
+    for (CategoriesInfo catsinfo : getCategoriesInfo(request)) {
+      collection.addCategories(catsinfo.asCategoriesElement(request));
+    }
+    return collection;
+  }
 }

Modified: incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractEntityCollectionAdapter.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractEntityCollectionAdapter.java?rev=614798&r1=614797&r2=614798&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractEntityCollectionAdapter.java (original)
+++ incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractEntityCollectionAdapter.java Wed Jan 23 21:38:20 2008
@@ -452,4 +452,5 @@
 
     return entry;
   }
+  
 }

Modified: incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractProvider.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractProvider.java?rev=614798&r1=614797&r2=614798&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractProvider.java (original)
+++ incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractProvider.java Wed Jan 23 21:38:20 2008
@@ -18,16 +18,20 @@
 package org.apache.abdera.protocol.server.impl;
 
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Map;
 
 import javax.security.auth.Subject;
 
 import org.apache.abdera.Abdera;
+import org.apache.abdera.model.Service;
 import org.apache.abdera.protocol.Resolver;
 import org.apache.abdera.protocol.server.CategoriesInfo;
 import org.apache.abdera.protocol.server.CategoryInfo;
 import org.apache.abdera.protocol.server.CollectionAdapter;
 import org.apache.abdera.protocol.server.CollectionInfo;
+import org.apache.abdera.protocol.server.Filter;
 import org.apache.abdera.protocol.server.MediaCollectionAdapter;
 import org.apache.abdera.protocol.server.Provider;
 import org.apache.abdera.protocol.server.ProviderHelper;
@@ -47,6 +51,7 @@
   
   protected Abdera abdera;
   protected Map<String,String> properties;
+  protected List<Filter> filters = new ArrayList<Filter>();
   
   public void init(
     Abdera abdera, 
@@ -161,6 +166,13 @@
     RequestContext request);
   
 
+  protected Service getServiceElement(RequestContext request) {
+    Service service = abdera.newService();
+    for (WorkspaceInfo wi : getWorkspaceManager(request).getWorkspaces(request))
+      service.addWorkspace(wi.asWorkspaceElement(request));
+    return service;
+  }
+  
   protected ResponseContext getServiceDocument(
     final RequestContext request) {
       return 
@@ -211,5 +223,12 @@
         .setContentType(Constants.APP_MEDIA_TYPE);
   }
 
-  
+  public Filter[] getFilters(RequestContext request) {
+    return filters.toArray(new Filter[filters.size()]);
+  }
+
+  public void addFilter(Filter... filters) {
+    for (Filter filter : filters)
+      this.filters.add(filter);
+  }  
 }

Modified: incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractWorkspaceManager.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractWorkspaceManager.java?rev=614798&r1=614797&r2=614798&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractWorkspaceManager.java (original)
+++ incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractWorkspaceManager.java Wed Jan 23 21:38:20 2008
@@ -19,14 +19,14 @@
 
 import java.util.Collection;
 import java.util.HashSet;
-import java.util.Map;
 
-import org.apache.abdera.protocol.server.CollectionAdapter;
 import org.apache.abdera.protocol.server.RequestContext;
 import org.apache.abdera.protocol.server.WorkspaceInfo;
 import org.apache.abdera.protocol.server.WorkspaceManager;
 
-public abstract class AbstractWorkspaceManager implements WorkspaceManager {
+public abstract class AbstractWorkspaceManager 
+  implements WorkspaceManager {
+  
   protected Collection<WorkspaceInfo> workspaces;
 
   public Collection<WorkspaceInfo> getWorkspaces(RequestContext request) {

Added: incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractWorkspaceProvider.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractWorkspaceProvider.java?rev=614798&view=auto
==============================================================================
--- incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractWorkspaceProvider.java (added)
+++ incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractWorkspaceProvider.java Wed Jan 23 21:38:20 2008
@@ -0,0 +1,44 @@
+package org.apache.abdera.protocol.server.impl;
+
+import java.util.Collection;
+import java.util.HashSet;
+
+import org.apache.abdera.protocol.Resolver;
+import org.apache.abdera.protocol.server.RequestContext;
+import org.apache.abdera.protocol.server.Target;
+import org.apache.abdera.protocol.server.WorkspaceInfo;
+import org.apache.abdera.protocol.server.WorkspaceManager;
+
+public abstract class AbstractWorkspaceProvider 
+  extends AbstractProvider 
+  implements WorkspaceManager {
+  
+  protected Resolver<Target> targetResolver;
+  protected Collection<WorkspaceInfo> workspaces;
+
+  protected WorkspaceManager getWorkspaceManager(
+    RequestContext request) {
+      return this;
+  }
+    
+  protected Resolver<Target> getTargetResolver(
+    RequestContext request) {
+      return targetResolver;
+  }
+  
+  protected void setTargetResolver(Resolver<Target> targetResolver) {
+    this.targetResolver = targetResolver;
+  }
+  
+  public Collection<WorkspaceInfo> getWorkspaces(RequestContext request) {
+    return workspaces;
+  }
+
+  public void addWorkspace(WorkspaceInfo workspace) {
+    if (workspaces == null) {
+      workspaces = new HashSet<WorkspaceInfo>();
+    }
+    workspaces.add(workspace);
+  }
+  
+}

Modified: incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/DefaultWorkspaceManager.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/DefaultWorkspaceManager.java?rev=614798&r1=614797&r2=614798&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/DefaultWorkspaceManager.java (original)
+++ incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/DefaultWorkspaceManager.java Wed Jan 23 21:38:20 2008
@@ -1,9 +1,7 @@
 package org.apache.abdera.protocol.server.impl;
 
 import org.apache.abdera.protocol.server.CollectionAdapter;
-import org.apache.abdera.protocol.server.CollectionInfo;
 import org.apache.abdera.protocol.server.RequestContext;
-import org.apache.abdera.protocol.server.WorkspaceInfo;
 import org.apache.abdera.protocol.server.RequestContext.Scope;
 
 

Modified: incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/SimpleCategoriesInfo.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/SimpleCategoriesInfo.java?rev=614798&r1=614797&r2=614798&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/SimpleCategoriesInfo.java (original)
+++ incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/SimpleCategoriesInfo.java Wed Jan 23 21:38:20 2008
@@ -22,7 +22,6 @@
 import java.util.Iterator;
 import java.util.List;
 
-import org.apache.abdera.Abdera;
 import org.apache.abdera.model.Categories;
 import org.apache.abdera.protocol.server.CategoriesInfo;
 import org.apache.abdera.protocol.server.CategoryInfo;
@@ -30,10 +29,10 @@
 
 public class SimpleCategoriesInfo 
   implements CategoriesInfo, 
-             Serializable, 
-             Cloneable {
+             Serializable {
+  
+  private static final long serialVersionUID = 8732335394387909260L;
   
-  private static final long serialVersionUID = 1L;
   private final String href;
   private final String scheme;
   private final boolean fixed;
@@ -111,29 +110,15 @@
     return true;
   }
   
-  public Object clone() {
-    try {
-      return super.clone();
-    } catch (CloneNotSupportedException e) {
-      return href != null ? 
-        new SimpleCategoriesInfo(href) : 
-        new SimpleCategoriesInfo(
-          scheme, 
-          fixed, 
-          list.toArray(
-            new CategoryInfo[list.size()]));
-    }
-  }
-  
-  public Categories asCategoriesElement(Abdera abdera) {
-    Categories cats = abdera.getFactory().newCategories();
+  public Categories asCategoriesElement(RequestContext request) {
+    Categories cats = request.getAbdera().getFactory().newCategories();
     if (href != null) cats.setHref(href);
     else {
       cats.setFixed(fixed);
       cats.setScheme(scheme);
       for (CategoryInfo cat : this)
         cats.addCategory(
-          cat.asCategoryElement(abdera));
+          cat.asCategoryElement(request));
     }
     return cats;
   }

Modified: incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/SimpleCategoryInfo.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/SimpleCategoryInfo.java?rev=614798&r1=614797&r2=614798&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/SimpleCategoryInfo.java (original)
+++ incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/SimpleCategoryInfo.java Wed Jan 23 21:38:20 2008
@@ -19,15 +19,13 @@
 
 import java.io.Serializable;
 
-import org.apache.abdera.Abdera;
 import org.apache.abdera.model.Category;
 import org.apache.abdera.protocol.server.CategoryInfo;
 import org.apache.abdera.protocol.server.RequestContext;
 
 public class SimpleCategoryInfo 
   implements CategoryInfo, 
-             Serializable, 
-             Cloneable {
+             Serializable {
   
   private static final long serialVersionUID = -4013333222147077975L;
   private final String label;
@@ -92,16 +90,8 @@
     return true;
   }
   
-  public Object clone() {
-    try {
-      return super.clone();
-    } catch (CloneNotSupportedException e) {
-      return new SimpleCategoryInfo(term,scheme,label);
-    }
-  }
-  
-  public Category asCategoryElement(Abdera abdera) {
-    Category cat = abdera.getFactory().newCategory();
+  public Category asCategoryElement(RequestContext request) {
+    Category cat = request.getAbdera().getFactory().newCategory();
     cat.setTerm(term);
     if (scheme != null) cat.setScheme(scheme);
     if (label != null) cat.setLabel(label);

Copied: incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/SimpleCollectionInfo.java (from r614767, incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/SimpleCollection.java)
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/SimpleCollectionInfo.java?p2=incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/SimpleCollectionInfo.java&p1=incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/SimpleCollection.java&r1=614767&r2=614798&rev=614798&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/SimpleCollection.java (original)
+++ incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/SimpleCollectionInfo.java Wed Jan 23 21:38:20 2008
@@ -19,44 +19,34 @@
 
 import java.io.Serializable;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 
+import org.apache.abdera.model.Collection;
 import org.apache.abdera.protocol.server.CategoriesInfo;
-import org.apache.abdera.protocol.server.CollectionAdapter;
 import org.apache.abdera.protocol.server.CollectionInfo;
 import org.apache.abdera.protocol.server.RequestContext;
 
-public class SimpleCollection 
+public class SimpleCollectionInfo 
   implements CollectionInfo, 
              Serializable {
   
   private static final long serialVersionUID = 8026455829158149510L;
   
-  private final CollectionAdapter adapter;
-  private final String id;
   private final String title;
   private final String href;
   private final String[] accepts;
   private final List<CategoriesInfo> catinfos = new ArrayList<CategoriesInfo>();
   
-  public SimpleCollection(
-    CollectionAdapter adapter,
-    String id,
+  public SimpleCollectionInfo(
     String title,
     String href,
     String... accepts) {
-      this.adapter = adapter;
-      this.id = id;
       this.title = title;
       this.accepts = accepts;
       this.href = href;
   }
   
-  public boolean isCollectionFor(RequestContext request) {
-    // TODO Auto-generated method stub
-    return false;
-  }
-
   public String[] getAccepts(RequestContext request) {
     return accepts;
   }
@@ -69,14 +59,6 @@
     return title;
   }
   
-  public boolean isAdapterFor(RequestContext request) {
-    return request.getTarget().getParameter("collection").equals(this.id);
-  }
-
-  public CollectionAdapter getCollectionAdapter(RequestContext request) {
-    return adapter;
-  }
-
   public CategoriesInfo[] getCategoriesInfo(RequestContext request) {
     return catinfos.toArray(new CategoriesInfo[catinfos.size()]);
   }
@@ -89,5 +71,44 @@
   public void setCategoriesInfo(CategoriesInfo...catinfos) {
     this.catinfos.clear();
     addCategoriesInfo(catinfos);
+  }
+
+  public int hashCode() {
+    final int prime = 31;
+    int result = 1;
+    result = prime * result + Arrays.hashCode(accepts);
+    result = prime * result + ((catinfos == null) ? 0 : catinfos.hashCode());
+    result = prime * result + ((href == null) ? 0 : href.hashCode());
+    result = prime * result + ((title == null) ? 0 : title.hashCode());
+    return result;
+  }
+
+  public boolean equals(Object obj) {
+    if (this == obj) return true;
+    if (obj == null) return false;
+    if (getClass() != obj.getClass()) return false;
+    final SimpleCollectionInfo other = (SimpleCollectionInfo) obj;
+    if (!Arrays.equals(accepts, other.accepts)) return false;
+    if (catinfos == null) {
+      if (other.catinfos != null) return false;
+    } else if (!catinfos.equals(other.catinfos)) return false;
+    if (href == null) {
+      if (other.href != null) return false;
+    } else if (!href.equals(other.href)) return false;
+    if (title == null) {
+      if (other.title != null) return false;
+    } else if (!title.equals(other.title)) return false;
+    return true;
+  }
+  
+  public Collection asCollectionElement(RequestContext request) {
+    Collection collection = request.getAbdera().getFactory().newCollection();
+    collection.setHref(href);
+    collection.setTitle(title);
+    collection.setAccept(accepts);
+    for (CategoriesInfo catsinfo : this.catinfos) {
+      collection.addCategories(catsinfo.asCategoriesElement(request));
+    }
+    return collection;
   }
 }

Added: incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/SimpleWorkspaceInfo.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/SimpleWorkspaceInfo.java?rev=614798&view=auto
==============================================================================
--- incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/SimpleWorkspaceInfo.java (added)
+++ incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/impl/SimpleWorkspaceInfo.java Wed Jan 23 21:38:20 2008
@@ -0,0 +1,101 @@
+/*
+ * 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.
+ */
+package org.apache.abdera.protocol.server.impl;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.abdera.model.Workspace;
+import org.apache.abdera.protocol.server.CollectionInfo;
+import org.apache.abdera.protocol.server.RequestContext;
+import org.apache.abdera.protocol.server.WorkspaceInfo;
+
+public class SimpleWorkspaceInfo 
+  implements WorkspaceInfo,
+             Serializable {
+
+  private static final long serialVersionUID = -8459688584319762878L;
+  
+  protected String title;
+  protected Set<CollectionInfo> collections;
+
+  public String getTitle() {
+    return title;
+  }
+
+  public void setTitle(String title) {
+    this.title = title;
+  }
+
+  public String getTitle(RequestContext request) {
+    return title;
+  }
+
+  public void addCollection(CollectionInfo ci) {
+    getCollections().add(ci);
+  }
+
+  public Collection<CollectionInfo> getCollections(RequestContext request) {
+    return collections;
+  }
+
+  public Set<CollectionInfo> getCollections() {
+    if (collections == null) {
+      collections = new HashSet<CollectionInfo>();
+    }
+
+    return collections;
+  }
+
+  public void setCollections(Set<CollectionInfo> collections) {
+    this.collections = collections;
+  }
+
+  public int hashCode() {
+    final int prime = 31;
+    int result = 1;
+    result = prime * result
+        + ((collections == null) ? 0 : collections.hashCode());
+    result = prime * result + ((title == null) ? 0 : title.hashCode());
+    return result;
+  }
+
+  public boolean equals(Object obj) {
+    if (this == obj) return true;
+    if (obj == null) return false;
+    if (getClass() != obj.getClass()) return false;
+    final SimpleWorkspaceInfo other = (SimpleWorkspaceInfo) obj;
+    if (collections == null) {
+      if (other.collections != null) return false;
+    } else if (!collections.equals(other.collections)) return false;
+    if (title == null) {
+      if (other.title != null) return false;
+    } else if (!title.equals(other.title)) return false;
+    return true;
+  }
+  
+  public Workspace asWorkspaceElement(RequestContext request) {
+    Workspace workspace = request.getAbdera().getFactory().newWorkspace();
+    workspace.setTitle(title);
+    for (CollectionInfo collection : this.collections)
+      workspace.addCollection(collection.asCollectionElement(request));
+    return workspace;
+  }
+}

Modified: incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/provider/basic/BasicProvider.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/provider/basic/BasicProvider.java?rev=614798&r1=614797&r2=614798&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/provider/basic/BasicProvider.java (original)
+++ incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/provider/basic/BasicProvider.java Wed Jan 23 21:38:20 2008
@@ -17,12 +17,16 @@
 */
 package org.apache.abdera.protocol.server.provider.basic;
 
+import org.apache.abdera.Abdera;
+import org.apache.abdera.protocol.server.CollectionAdapter;
+import org.apache.abdera.protocol.server.RequestContext;
 import org.apache.abdera.protocol.server.TargetType;
-import org.apache.abdera.protocol.server.impl.DefaultProvider;
+import org.apache.abdera.protocol.server.impl.AbstractWorkspaceProvider;
+import org.apache.abdera.protocol.server.impl.CollectionAdapterManager;
 import org.apache.abdera.protocol.server.impl.RegexTargetResolver;
 
 public class BasicProvider 
-  extends DefaultProvider {
+  extends AbstractWorkspaceProvider {
 
   public static final String PARAM_FEED = "feed";
   public static final String PARAM_ENTRY = "entry";
@@ -34,7 +38,28 @@
         .setPattern("/" + "([^/#?]+)", TargetType.TYPE_COLLECTION, PARAM_FEED)
         .setPattern("/" + "([^/#?]+)/([^/#?]+)", TargetType.TYPE_ENTRY, PARAM_FEED, PARAM_ENTRY)
     );
-    addWorkspace(new BasicWorkspace());
+    addWorkspace(new BasicWorkspace(this));
+  }
+
+  protected CollectionAdapterManager cam;
+  
+  protected CollectionAdapterManager getCollectionAdapterManager(
+    Abdera abdera) {
+      if (cam == null) 
+        cam = new CollectionAdapterManager(abdera);
+    return cam;
+  }
+  
+  public CollectionAdapter getCollectionAdapter(RequestContext request) {
+    try {
+      return getCollectionAdapterManager(request.getAbdera())
+        .getAdapter(
+          request.getTarget()
+            .getParameter(
+                BasicProvider.PARAM_FEED));
+    } catch (Exception e) {
+      return null;
+    }
   }
   
 }

Modified: incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/provider/basic/BasicWorkspace.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/provider/basic/BasicWorkspace.java?rev=614798&r1=614797&r2=614798&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/provider/basic/BasicWorkspace.java (original)
+++ incubator/abdera/java/branches/server_refactor_all/server/src/main/java/org/apache/abdera/protocol/server/provider/basic/BasicWorkspace.java Wed Jan 23 21:38:20 2008
@@ -23,61 +23,47 @@
 import java.util.Map;
 import java.util.Properties;
 
-import org.apache.abdera.protocol.server.CollectionAdapter;
+import org.apache.abdera.model.Workspace;
 import org.apache.abdera.protocol.server.CollectionInfo;
 import org.apache.abdera.protocol.server.RequestContext;
 import org.apache.abdera.protocol.server.WorkspaceInfo;
 import org.apache.abdera.protocol.server.impl.CollectionAdapterManager;
-import org.apache.abdera.protocol.server.impl.SimpleCollection;
+import org.apache.abdera.protocol.server.impl.SimpleCollectionInfo;
 
-public class BasicWorkspace implements WorkspaceInfo {
-
-  protected CollectionAdapterManager cam;
+class BasicWorkspace 
+  implements WorkspaceInfo {
+  
+  private final BasicProvider provider;
   
-  protected CollectionAdapterManager getCollectionAdapterManager(
-    RequestContext request) {
-      if (cam == null) 
-        cam = new CollectionAdapterManager(
-          request.getAbdera());
-    return cam;
+  BasicWorkspace(BasicProvider provider) {
+    this.provider = provider;
   }
   
   public Collection<CollectionInfo> getCollections(RequestContext request) {
-    CollectionAdapterManager cam = getCollectionAdapterManager(request);
+    CollectionAdapterManager cam = provider.getCollectionAdapterManager(request.getAbdera());
     List<CollectionInfo> collections = new ArrayList<CollectionInfo>();
     try {
       Map<String,Properties> map = cam.listAdapters();
       for (Map.Entry<String,Properties> entry : map.entrySet()) {
-        String id = entry.getKey();
         Properties properties = entry.getValue();
-        CollectionAdapter ca = cam.getAdapter(id);
         String href = properties.getProperty(BasicAdapter.PROP_NAME_FEED_URI);
         String title = properties.getProperty(BasicAdapter.PROP_NAME_TITLE);
-        SimpleCollection col = new SimpleCollection(ca,id,title,href,"application/atom+xml;type=entry");
+        SimpleCollectionInfo col = new SimpleCollectionInfo(title,href,"application/atom+xml;type=entry");
         collections.add(col);
       }
     } catch (Exception e) {}
     return collections;
   }
 
-  public CollectionAdapter getCollectionAdapter(RequestContext request) {
-    try {
-      return getCollectionAdapterManager(request)
-        .getAdapter(
-          request.getTarget()
-            .getParameter(
-                BasicProvider.PARAM_FEED));
-    } catch (Exception e) {
-      return null;
-    }
-  }
-
   public String getTitle(RequestContext request) {
     return "Abdera";
   }
 
-  public boolean isWorkspaceFor(RequestContext request) {
-    return getCollectionAdapter(request) != null;
+  public Workspace asWorkspaceElement(RequestContext request) {
+    Workspace workspace = request.getAbdera().getFactory().newWorkspace();
+    workspace.setTitle(getTitle(null));
+    for (CollectionInfo collection : getCollections(request))
+      workspace.addCollection(collection.asCollectionElement(request));
+    return workspace;
   }
-
 }



Mime
View raw message