abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r614076 [1/2] - in /incubator/abdera/java/branches/server_refactor/src: main/java/org/apache/abdera/protocol/server/ main/java/org/apache/abdera/protocol/server/context/ main/java/org/apache/abdera/protocol/server/impl/ main/java/org/apache...
Date Tue, 22 Jan 2008 00:53:10 GMT
Author: jmsnell
Date: Mon Jan 21 16:53:07 2008
New Revision: 614076

URL: http://svn.apache.org/viewvc?rev=614076&view=rev
Log:
Additional refactoring and simplification.  This changes does quite a few things:

1. It eliminates the separate Adapter interface; however, there is still a BasicAdapter abstract implementation of CollectionAdapter that allows for the approach the google feed-server uses

2. It refactors and simplifies the ext package extensively

3. The process of creating and plugging in adapters is significantly easier and consistent

Look at the tests for examples

Added:
    incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/context/
    incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/context/AbstractRequestContext.java
      - copied, changed from r613765, incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/AbstractRequestContext.java
    incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/context/AbstractResponseContext.java
      - copied, changed from r613765, incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/AbstractResponseContext.java
    incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/context/AbstractServiceContext.java
      - copied, changed from r613774, incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/AbstractServiceContext.java
    incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/context/BaseResponseContext.java
      - copied, changed from r613765, incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/BaseResponseContext.java
    incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/context/DefaultServiceContext.java
      - copied, changed from r613783, incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/DefaultServiceContext.java
    incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/context/EmptyResponseContext.java
      - copied, changed from r613783, incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/EmptyResponseContext.java
    incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/context/EntityProviderResponseContext.java
      - copied, changed from r613765, incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/EntityProviderResponseContext.java
    incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/context/MediaResponseContext.java
      - copied, changed from r613765, incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/MediaResponseContext.java
    incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/context/ResponseContextException.java
      - copied, changed from r613765, incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/ResponseContextException.java
    incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/context/SimpleResponseContext.java
      - copied, changed from r613765, incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/SimpleResponseContext.java
    incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/context/StreamWriterResponseContext.java
      - copied, changed from r613765, incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/StreamWriterResponseContext.java
    incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/AbstractWorkspaceProvider.java
      - copied, changed from r613765, incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/AbstractWorkspaceManagerProvider.java
    incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/CollectionAdapterManager.java
    incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/basic/BasicAdapter.java
      - copied, changed from r613765, incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/basic/AbstractBasicAdapter.java
    incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/ext/AbstractWorkspaceInfo.java
    incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/ext/CollectionInfo.java
    incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/ext/ExtendedProvider.java
    incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/ext/SimpleCollection.java
    incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/ext/SimpleWorkspace.java
    incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/ext/WorkspaceInfo.java
    incubator/abdera/java/branches/server_refactor/src/test/java/org/apache/abdera/protocol/server/test/basic/SampleBasicAdapter.java
    incubator/abdera/java/branches/server_refactor/src/test/java/org/apache/abdera/protocol/server/test/ext/ExtendedTest.java
    incubator/abdera/java/branches/server_refactor/src/test/java/org/apache/abdera/protocol/server/test/ext/TestServiceContext.java
    incubator/abdera/java/branches/server_refactor/src/test/java/org/apache/abdera/protocol/server/test/simple/SimpleAdapter.java
    incubator/abdera/java/branches/server_refactor/src/test/java/org/apache/abdera/protocol/server/test/simple/SimpleProvider.java
Removed:
    incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/AbstractCombinedProvider.java
    incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/AbstractRequestContext.java
    incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/AbstractResponseContext.java
    incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/AbstractServiceContext.java
    incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/AbstractWorkspaceManager.java
    incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/AbstractWorkspaceManagerProvider.java
    incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/BaseResponseContext.java
    incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/DefaultServiceContext.java
    incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/EmptyResponseContext.java
    incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/EntityProviderResponseContext.java
    incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/MediaResponseContext.java
    incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/ResponseContextException.java
    incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/SimpleResponseContext.java
    incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/StreamWriterResponseContext.java
    incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/basic/AbstractBasicAdapter.java
    incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/basic/BasicAdapterManager.java
    incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/basic/BasicResponseContext.java
    incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/basic/SampleBasicAdapter.java
Modified:
    incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/ProviderHelper.java
    incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/ServiceManager.java
    incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/WorkspaceManager.java
    incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/AbstractProvider.java
    incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/RegexTargetResolver.java
    incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/basic/BasicProvider.java
    incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/basic/BasicServiceContext.java
    incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/basic/BasicTargetResolver.java
    incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/servlet/AbderaServlet.java
    incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/servlet/ServletRequestContext.java
    incubator/abdera/java/branches/server_refactor/src/test/java/org/apache/abdera/protocol/server/test/basic/BasicTest.java
    incubator/abdera/java/branches/server_refactor/src/test/java/org/apache/abdera/protocol/server/test/simple/SimpleServiceContext.java
    incubator/abdera/java/branches/server_refactor/src/test/resources/abdera/adapter/sample.properties

Modified: incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/ProviderHelper.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/ProviderHelper.java?rev=614076&r1=614075&r2=614076&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/ProviderHelper.java (original)
+++ incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/ProviderHelper.java Mon Jan 21 16:53:07 2008
@@ -21,11 +21,13 @@
 import org.apache.abdera.model.Entry;
 import org.apache.abdera.model.ExtensibleElement;
 import org.apache.abdera.model.Feed;
+import org.apache.abdera.model.Link;
 import org.apache.abdera.protocol.error.Error;
-import org.apache.abdera.protocol.server.impl.AbstractResponseContext;
-import org.apache.abdera.protocol.server.impl.BaseResponseContext;
-import org.apache.abdera.protocol.server.impl.EmptyResponseContext;
-import org.apache.abdera.protocol.server.impl.StreamWriterResponseContext;
+import org.apache.abdera.protocol.server.context.AbstractResponseContext;
+import org.apache.abdera.protocol.server.context.BaseResponseContext;
+import org.apache.abdera.protocol.server.context.EmptyResponseContext;
+import org.apache.abdera.protocol.server.context.StreamWriterResponseContext;
+import org.apache.abdera.util.Constants;
 import org.apache.abdera.util.EntityTag;
 import org.apache.abdera.util.MimeTypeHelper;
 import org.apache.abdera.writer.NamedWriter;
@@ -553,5 +555,29 @@
       return calculateEntityTag(((Document<?>)base).getRoot());
     }
     return EntityTag.generate(id, modified);      
+  }
+  
+  public static String getEditUriFromEntry(
+    Entry entry) {
+      String editUri = null;
+      List<Link> editLinks = entry.getLinks("edit");
+      for (Link link : editLinks) {
+        // if there is more than one edit link, we should not automatically
+        // assume that it's always going to point to an Atom document
+        // representation.
+        if (link.getMimeType() != null) {
+          if (MimeTypeHelper.isMatch(
+                link.getMimeType().toString(), 
+                Constants.ATOM_MEDIA_TYPE)) {
+            editUri = link.getResolvedHref().toString();
+            break;
+          }
+        } else {
+          // edit link with no type attribute is the right one to use
+          editUri = link.getResolvedHref().toString();
+          break;
+        }
+      }
+     return editUri;
   }
 }

Modified: incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/ServiceManager.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/ServiceManager.java?rev=614076&r1=614075&r2=614076&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/ServiceManager.java (original)
+++ incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/ServiceManager.java Mon Jan 21 16:53:07 2008
@@ -21,7 +21,7 @@
 
 import org.apache.abdera.Abdera;
 import org.apache.abdera.i18n.text.Localizer;
-import org.apache.abdera.protocol.server.impl.DefaultServiceContext;
+import org.apache.abdera.protocol.server.context.DefaultServiceContext;
 import org.apache.abdera.util.ServiceUtil;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;

Modified: incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/WorkspaceManager.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/WorkspaceManager.java?rev=614076&r1=614075&r2=614076&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/WorkspaceManager.java (original)
+++ incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/WorkspaceManager.java Mon Jan 21 16:53:07 2008
@@ -18,7 +18,7 @@
 package org.apache.abdera.protocol.server;
 
 public interface WorkspaceManager {
-  
+    
   CollectionAdapter getCollectionAdapter(RequestContext request);
   
   boolean checkTarget(RequestContext request);

Copied: incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/context/AbstractRequestContext.java (from r613765, incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/AbstractRequestContext.java)
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/context/AbstractRequestContext.java?p2=incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/context/AbstractRequestContext.java&p1=incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/AbstractRequestContext.java&r1=613765&r2=614076&rev=614076&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/AbstractRequestContext.java (original)
+++ incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/context/AbstractRequestContext.java Mon Jan 21 16:53:07 2008
@@ -15,7 +15,7 @@
 * copyright in this work, please see the NOTICE file in the top level
 * directory of this distribution.
 */
-package org.apache.abdera.protocol.server.impl;
+package org.apache.abdera.protocol.server.context;
 
 import java.io.IOException;
 import java.security.Principal;

Copied: incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/context/AbstractResponseContext.java (from r613765, incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/AbstractResponseContext.java)
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/context/AbstractResponseContext.java?p2=incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/context/AbstractResponseContext.java&p1=incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/AbstractResponseContext.java&r1=613765&r2=614076&rev=614076&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/AbstractResponseContext.java (original)
+++ incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/context/AbstractResponseContext.java Mon Jan 21 16:53:07 2008
@@ -15,7 +15,7 @@
 * copyright in this work, please see the NOTICE file in the top level
 * directory of this distribution.
 */
-package org.apache.abdera.protocol.server.impl;
+package org.apache.abdera.protocol.server.context;
 
 import java.util.ArrayList;
 import java.util.Arrays;

Copied: incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/context/AbstractServiceContext.java (from r613774, incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/AbstractServiceContext.java)
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/context/AbstractServiceContext.java?p2=incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/context/AbstractServiceContext.java&p1=incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/AbstractServiceContext.java&r1=613774&r2=614076&rev=614076&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/AbstractServiceContext.java (original)
+++ incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/context/AbstractServiceContext.java Mon Jan 21 16:53:07 2008
@@ -15,7 +15,7 @@
 * copyright in this work, please see the NOTICE file in the top level
 * directory of this distribution.
 */
-package org.apache.abdera.protocol.server.impl;
+package org.apache.abdera.protocol.server.context;
 
 import java.util.HashMap;
 import java.util.Map;

Copied: incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/context/BaseResponseContext.java (from r613765, incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/BaseResponseContext.java)
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/context/BaseResponseContext.java?p2=incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/context/BaseResponseContext.java&p1=incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/BaseResponseContext.java&r1=613765&r2=614076&rev=614076&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/BaseResponseContext.java (original)
+++ incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/context/BaseResponseContext.java Mon Jan 21 16:53:07 2008
@@ -15,7 +15,7 @@
 * copyright in this work, please see the NOTICE file in the top level
 * directory of this distribution.
 */
-package org.apache.abdera.protocol.server.impl;
+package org.apache.abdera.protocol.server.context;
 
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;

Copied: incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/context/DefaultServiceContext.java (from r613783, incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/DefaultServiceContext.java)
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/context/DefaultServiceContext.java?p2=incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/context/DefaultServiceContext.java&p1=incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/DefaultServiceContext.java&r1=613783&r2=614076&rev=614076&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/DefaultServiceContext.java (original)
+++ incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/context/DefaultServiceContext.java Mon Jan 21 16:53:07 2008
@@ -15,7 +15,7 @@
 * copyright in this work, please see the NOTICE file in the top level
 * directory of this distribution.
 */
-package org.apache.abdera.protocol.server.impl;
+package org.apache.abdera.protocol.server.context;
 
 import javax.security.auth.Subject;
 
@@ -25,6 +25,8 @@
 import org.apache.abdera.protocol.server.RequestContext;
 import org.apache.abdera.protocol.server.ServiceManager;
 import org.apache.abdera.protocol.server.Target;
+import org.apache.abdera.protocol.server.impl.RegexTargetResolver;
+import org.apache.abdera.protocol.server.impl.SimpleSubjectResolver;
 import org.apache.abdera.util.ServiceUtil;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;

Copied: incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/context/EmptyResponseContext.java (from r613783, incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/EmptyResponseContext.java)
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/context/EmptyResponseContext.java?p2=incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/context/EmptyResponseContext.java&p1=incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/EmptyResponseContext.java&r1=613783&r2=614076&rev=614076&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/EmptyResponseContext.java (original)
+++ incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/context/EmptyResponseContext.java Mon Jan 21 16:53:07 2008
@@ -15,7 +15,7 @@
 * copyright in this work, please see the NOTICE file in the top level
 * directory of this distribution.
 */
-package org.apache.abdera.protocol.server.impl;
+package org.apache.abdera.protocol.server.context;
 
 import java.io.IOException;
 import java.io.OutputStream;

Copied: incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/context/EntityProviderResponseContext.java (from r613765, incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/EntityProviderResponseContext.java)
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/context/EntityProviderResponseContext.java?p2=incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/context/EntityProviderResponseContext.java&p1=incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/EntityProviderResponseContext.java&r1=613765&r2=614076&rev=614076&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/EntityProviderResponseContext.java (original)
+++ incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/context/EntityProviderResponseContext.java Mon Jan 21 16:53:07 2008
@@ -15,7 +15,7 @@
 * copyright in this work, please see the NOTICE file in the top level
 * directory of this distribution.
 */
-package org.apache.abdera.protocol.server.impl;
+package org.apache.abdera.protocol.server.context;
 
 import java.io.IOException;
 

Copied: incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/context/MediaResponseContext.java (from r613765, incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/MediaResponseContext.java)
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/context/MediaResponseContext.java?p2=incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/context/MediaResponseContext.java&p1=incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/MediaResponseContext.java&r1=613765&r2=614076&rev=614076&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/MediaResponseContext.java (original)
+++ incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/context/MediaResponseContext.java Mon Jan 21 16:53:07 2008
@@ -15,7 +15,7 @@
 * copyright in this work, please see the NOTICE file in the top level
 * directory of this distribution.
 */
-package org.apache.abdera.protocol.server.impl;
+package org.apache.abdera.protocol.server.context;
 
 import java.io.ByteArrayInputStream;
 import java.io.IOException;

Copied: incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/context/ResponseContextException.java (from r613765, incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/ResponseContextException.java)
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/context/ResponseContextException.java?p2=incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/context/ResponseContextException.java&p1=incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/ResponseContextException.java&r1=613765&r2=614076&rev=614076&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/ResponseContextException.java (original)
+++ incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/context/ResponseContextException.java Mon Jan 21 16:53:07 2008
@@ -15,7 +15,8 @@
 * copyright in this work, please see the NOTICE file in the top level
 * directory of this distribution.
 */
-package org.apache.abdera.protocol.server.impl;
+package org.apache.abdera.protocol.server.context;
+
 
 
 public class ResponseContextException extends Exception {

Copied: incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/context/SimpleResponseContext.java (from r613765, incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/SimpleResponseContext.java)
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/context/SimpleResponseContext.java?p2=incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/context/SimpleResponseContext.java&p1=incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/SimpleResponseContext.java&r1=613765&r2=614076&rev=614076&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/SimpleResponseContext.java (original)
+++ incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/context/SimpleResponseContext.java Mon Jan 21 16:53:07 2008
@@ -15,7 +15,7 @@
 * copyright in this work, please see the NOTICE file in the top level
 * directory of this distribution.
 */
-package org.apache.abdera.protocol.server.impl;
+package org.apache.abdera.protocol.server.context;
 
 import java.io.IOException;
 import java.io.OutputStream;

Copied: incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/context/StreamWriterResponseContext.java (from r613765, incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/StreamWriterResponseContext.java)
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/context/StreamWriterResponseContext.java?p2=incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/context/StreamWriterResponseContext.java&p1=incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/StreamWriterResponseContext.java&r1=613765&r2=614076&rev=614076&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/StreamWriterResponseContext.java (original)
+++ incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/context/StreamWriterResponseContext.java Mon Jan 21 16:53:07 2008
@@ -15,7 +15,7 @@
  * copyright in this work, please see the NOTICE file in the top level
  * directory of this distribution.
  */
-package org.apache.abdera.protocol.server.impl;
+package org.apache.abdera.protocol.server.context;
 
 import java.io.IOException;
 import java.io.Writer;

Modified: incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/AbstractProvider.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/AbstractProvider.java?rev=614076&r1=614075&r2=614076&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/AbstractProvider.java (original)
+++ incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/AbstractProvider.java Mon Jan 21 16:53:07 2008
@@ -31,12 +31,29 @@
 public abstract class AbstractProvider 
   implements Provider {
   
+  protected CollectionAdapterManager cam;
+  
+  protected CollectionAdapterManager getCollectionAdapterManager(
+    RequestContext request) {
+      if (cam == null) 
+        cam = new CollectionAdapterManager(
+          request.getAbdera());
+    return cam;
+  }
+  
   public ResponseContext process(
     RequestContext request) {    
-      WorkspaceManager wm = getWorkspaceManager(request);
       Target target = request.getTarget();
       String method = request.getMethod();
       TargetType type = target.getType();
+      if (type == TargetType.TYPE_SERVICE && 
+          method.equalsIgnoreCase("GET")) {
+          return getServiceDocument(request);
+      } else if (type == TargetType.TYPE_CATEGORIES && 
+                 method.equalsIgnoreCase("GET")) {
+          return getCategoriesDocument(request);
+      }
+      WorkspaceManager wm = getWorkspaceManager(request);
       if (!wm.checkTarget(request)) {
         return ProviderHelper.notfound(
           request,
@@ -47,7 +64,7 @@
           request, 
           "Method Not Allowed", 
           wm.getMethods(request));
-      }
+      }      
       CollectionAdapter adapter = 
         wm.getCollectionAdapter(request);
       Transactional transaction = 
@@ -55,56 +72,50 @@
           (Transactional)adapter : null;
       try {
         if (transaction != null) transaction.start();
-        if (type == TargetType.TYPE_SERVICE) {
-          if (method.equalsIgnoreCase("GET")) {
-            return getServiceDocument(request);
-          }
-        } else if (type == TargetType.TYPE_CATEGORIES) {
-          if (method.equalsIgnoreCase("GET")) {
-            return getCategoriesDocument(request);
-          }
-        } else if (type == TargetType.TYPE_COLLECTION) {
-          if (method.equalsIgnoreCase("GET")) return adapter.getFeed(request);
+        if (type == TargetType.TYPE_COLLECTION) {
+          if (method.equalsIgnoreCase("GET")) 
+            return adapter.getFeed(request);
           else if (method.equalsIgnoreCase("POST")) {
-            if (ProviderHelper.isAtom(request)) {
-              return adapter.postEntry(request);
-            } else {
-              if (adapter instanceof MediaCollectionAdapter) {
-                return ((MediaCollectionAdapter)adapter).postMedia(request);
-              } else {
-                return ProviderHelper.notsupported(request, "Media Type Not Supported");
-              }
-            }
+            return ProviderHelper.isAtom(request) ?
+              adapter.postEntry(request) :
+              adapter instanceof MediaCollectionAdapter ?
+                ((MediaCollectionAdapter)adapter).postMedia(request) :
+                ProviderHelper.notsupported(request);
           }
         } else if (type == TargetType.TYPE_ENTRY) {
-          if (method.equalsIgnoreCase("GET")) return adapter.getEntry(request);
-          else if (method.equalsIgnoreCase("PUT")) return adapter.putEntry(request);
-          else if (method.equalsIgnoreCase("DELETE")) return adapter.deleteEntry(request);
+          if (method.equalsIgnoreCase("GET")) 
+            return adapter.getEntry(request);
+          else if (method.equalsIgnoreCase("PUT")) 
+            return adapter.putEntry(request);
+          else if (method.equalsIgnoreCase("DELETE")) 
+            return adapter.deleteEntry(request);
         } else if (type == TargetType.TYPE_MEDIA) {
           if (adapter instanceof MediaCollectionAdapter) {
-            MediaCollectionAdapter mcadapter = (MediaCollectionAdapter) adapter;
-            if (method.equalsIgnoreCase("GET")) return mcadapter.getMedia(request);
-            else if (method.equalsIgnoreCase("PUT")) return mcadapter.putMedia(request);
-            else if (method.equalsIgnoreCase("DELETE")) return mcadapter.deleteMedia(request);        
+            MediaCollectionAdapter mcadapter = 
+              (MediaCollectionAdapter) adapter;
+            if (method.equalsIgnoreCase("GET")) 
+              return mcadapter.getMedia(request);
+            else if (method.equalsIgnoreCase("PUT")) 
+              return mcadapter.putMedia(request);
+            else if (method.equalsIgnoreCase("DELETE")) 
+              return mcadapter.deleteMedia(request);        
           } else {
-            return ProviderHelper.notsupported(
-              request, 
-              "Media Type Not Supported");
+            return ProviderHelper.notsupported(request);
           }
         }
         return adapter.extensionRequest(request);
       } catch (Throwable e) {
         if (transaction != null) 
           transaction.compensate(e);
-        return ProviderHelper.servererror(
-          request, "Server Error", e);
+        return ProviderHelper.servererror(request, e);
       } finally {
         if (transaction != null) 
           transaction.end();
       }
   }
    
-  protected abstract WorkspaceManager getWorkspaceManager(RequestContext request);
+  protected abstract WorkspaceManager getWorkspaceManager(
+    RequestContext request);
   
   protected ResponseContext getServiceDocument(
     RequestContext request) {

Copied: incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/AbstractWorkspaceProvider.java (from r613765, incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/AbstractWorkspaceManagerProvider.java)
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/AbstractWorkspaceProvider.java?p2=incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/AbstractWorkspaceProvider.java&p1=incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/AbstractWorkspaceManagerProvider.java&r1=613765&r2=614076&rev=614076&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/AbstractWorkspaceManagerProvider.java (original)
+++ incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/AbstractWorkspaceProvider.java Mon Jan 21 16:53:07 2008
@@ -17,11 +17,12 @@
 */
 package org.apache.abdera.protocol.server.impl;
 
+import org.apache.abdera.protocol.server.CollectionAdapter;
 import org.apache.abdera.protocol.server.ProviderHelper;
 import org.apache.abdera.protocol.server.RequestContext;
 import org.apache.abdera.protocol.server.WorkspaceManager;
 
-public abstract class AbstractWorkspaceManagerProvider 
+public abstract class AbstractWorkspaceProvider 
   extends AbstractProvider
   implements WorkspaceManager {
   
@@ -47,4 +48,18 @@
         getMethods(request));
   }
 
+  public CollectionAdapter getCollectionAdapter(
+      RequestContext request) {
+        try {
+          return getCollectionAdapterManager(request)
+            .getAdapter(getAdapterIdentifier(request));
+        } catch (Exception e) {
+          throw new RuntimeException(e);
+        }
+    }
+  
+  protected String getAdapterIdentifier(
+    RequestContext request) {
+      return null;
+  }
 }

Added: incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/CollectionAdapterManager.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/CollectionAdapterManager.java?rev=614076&view=auto
==============================================================================
--- incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/CollectionAdapterManager.java (added)
+++ incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/CollectionAdapterManager.java Mon Jan 21 16:53:07 2008
@@ -0,0 +1,155 @@
+/*
+* 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.File;
+import java.io.FileFilter;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.lang.reflect.Constructor;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.logging.Logger;
+
+import org.apache.abdera.Abdera;
+import org.apache.abdera.protocol.server.CollectionAdapter;
+
+public class CollectionAdapterManager {
+  
+  public static Logger logger =
+    Logger.getLogger(CollectionAdapterManager.class.getName());
+
+  protected static final String PROP_NAME_ADAPTER_CLASS = "adapterClassName";
+  protected static final String PROPERTIES_PATH = "abdera/adapter/";
+  protected static final String PROPERTIES_FILE_SUFFIX = ".properties";
+
+  // maps a feed id to an adapter instance
+  protected Map<String, CollectionAdapter> adapterInstanceMap =
+      new HashMap<String, CollectionAdapter>();
+
+  protected final Abdera abdera;
+
+  public CollectionAdapterManager(Abdera abdera) {
+    this.abdera = abdera;
+  }
+  
+  public CollectionAdapter getAdapter(
+    String feedId) 
+      throws Exception {
+    CollectionAdapter adapter = 
+      adapterInstanceMap.get(feedId);
+    if (adapter != null)
+      return adapter;
+
+    // load the feed properties file
+    Properties properties = loadFeedInfo(feedId);
+    String className = properties.getProperty(PROP_NAME_ADAPTER_CLASS);
+    if (className == null) {
+      logger.warning("property '" + PROP_NAME_ADAPTER_CLASS +
+          "' not found for feed '" + feedId + "'");
+      throw new RuntimeException();
+    }
+
+    return createAdapterInstance(feedId, className, properties);
+   }
+
+  public Map<String,Properties> listAdapters() throws Exception {
+    Map<String,Properties> results = new HashMap<String,Properties>();
+    Enumeration<URL> e = 
+      Thread.currentThread()
+        .getContextClassLoader()
+        .getResources(PROPERTIES_PATH);
+    while (e.hasMoreElements()) {
+      URL url = e.nextElement();
+      File file = new File(url.getFile());
+      File[] files = 
+        file.listFiles(
+          new FileFilter() {
+            public boolean accept(File file) {
+              return !file.isDirectory();
+            }
+          }
+        );
+      for (File _file : files) {
+        String name = _file.getName();
+        int i = name.indexOf(PROPERTIES_FILE_SUFFIX);
+        String id = i > -1 ? name.substring(0,i) : null;
+        if (id != null) {
+          Properties properties = loadFeedInfo(id);
+          if (properties != null)
+            results.put(id,properties);
+        }
+      }
+    }
+    return results;
+  }
+  
+  protected Properties loadFeedInfo(String feedId)
+    throws Exception {
+    String fileName = PROPERTIES_PATH + feedId + PROPERTIES_FILE_SUFFIX;
+    InputStream in =       
+      Thread.currentThread()
+        .getContextClassLoader()
+        .getResourceAsStream(fileName);
+    if (in == null) {
+      throw new FileNotFoundException();
+    }
+    Properties props = new Properties();
+    props.load(in);
+    in.close();
+    return props;
+  }
+
+  protected synchronized CollectionAdapter createAdapterInstance(
+    String feedId,
+    String className, 
+    Properties properties) 
+      throws Exception {
+    CollectionAdapter basicAdapter = adapterInstanceMap.get(feedId);
+    if (basicAdapter != null) {
+      return basicAdapter;
+    }
+    ClassLoader cl = Thread.currentThread().getContextClassLoader();
+    Class<?> adapterClass = cl.loadClass(className);
+    Constructor<?>[] ctors = adapterClass.getConstructors();
+    for (Constructor<?> element : ctors) {
+      logger.finest("Public constructor found: " +
+        element.toString());
+    }
+    Constructor<?> c = 
+      adapterClass.getConstructor(
+        new Class[] {
+          Abdera.class,
+          Properties.class, 
+          String.class});
+    c.setAccessible(true);
+    CollectionAdapter adapterInstance = 
+      (CollectionAdapter) c.newInstance(
+        abdera, 
+        properties,
+        feedId);
+
+    // put this adapter instance in adapterInstanceMap
+    adapterInstanceMap.put(feedId, adapterInstance);
+    return adapterInstance;
+  }
+
+}
\ No newline at end of file

Modified: incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/RegexTargetResolver.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/RegexTargetResolver.java?rev=614076&r1=614075&r2=614076&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/RegexTargetResolver.java (original)
+++ incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/RegexTargetResolver.java Mon Jan 21 16:53:07 2008
@@ -17,6 +17,7 @@
 */
 package org.apache.abdera.protocol.server.impl;
 
+import java.util.Arrays;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.regex.Matcher;
@@ -56,24 +57,44 @@
 public class RegexTargetResolver 
   implements Resolver<Target> {
 
-  private final Map<Pattern, TargetType> patterns;
+  protected final Map<Pattern, TargetType> patterns;
+  protected final Map<Pattern, String[]> fields;
   
   public RegexTargetResolver() {
     this.patterns = new HashMap<Pattern, TargetType>();
+    this.fields = new HashMap<Pattern, String[]>();
   }
   
   public RegexTargetResolver(Map<String, TargetType> patterns) {
     this.patterns = new HashMap<Pattern, TargetType>();
+    this.fields = new HashMap<Pattern, String[]>();
     for (String p : patterns.keySet()) {
       TargetType type = patterns.get(p);
       setPattern(p,type);
     }
   }
   
-  public synchronized RegexTargetResolver setPattern(String pattern, TargetType type) {
-    Pattern p = Pattern.compile(pattern);
-    this.patterns.put(p,type);
-    return this;
+  public RegexTargetResolver setPattern(
+    String pattern, 
+    TargetType type) {
+      return setPattern(pattern,type, new String[0]);
+  }
+  
+  public RegexTargetResolver setPattern(
+    String pattern, 
+    TargetType type, 
+    String... fields) {
+      _setPattern(pattern,type,fields);
+      return this;
+  }
+  
+  protected void _setPattern(
+    String pattern, 
+    TargetType type, 
+    String[] fields) {
+      Pattern p = Pattern.compile(pattern);
+      this.patterns.put(p,type);
+      this.fields.put(p,fields);    
   }
   
   public Target resolve(Request request) {
@@ -82,8 +103,9 @@
     for (Pattern pattern : patterns.keySet()) {
       Matcher matcher = pattern.matcher(uri);
       if (matcher.matches()) {
-        TargetType type = patterns.get(pattern);
-        return getTarget(type, context, matcher);
+        TargetType type = this.patterns.get(pattern);
+        String[] fields = this.fields.get(pattern);
+        return getTarget(type, context, matcher, fields);
       }
     }
     return null;
@@ -92,25 +114,75 @@
   protected Target getTarget(
     TargetType type, 
     RequestContext request, 
-    Matcher matcher) {
-      return new RegexTarget(type, request, matcher);
+    Matcher matcher,
+    String[] fields) {
+      return new RegexTarget(type, request, matcher, fields);
   }
   
+  public String toString() {
+    StringBuilder buf = new StringBuilder();
+    buf.append("Regex Target Resolver:\n");
+    for (Pattern pattern : patterns.keySet()) {
+      TargetType type = this.patterns.get(pattern);
+      String[] fields = this.fields.get(pattern);
+      buf.append(pattern.toString() + ", Type: " + type + ", Fields: " + Arrays.toString(fields));
+    }
+    return buf.toString();
+  }
+  
+  public int hashCode() {
+    final int prime = 31;
+    int result = 1;
+    result = prime * result + ((fields == null) ? 0 : fields.hashCode());
+    result = prime * result + ((patterns == null) ? 0 : patterns.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 RegexTargetResolver other = (RegexTargetResolver) obj;
+    if (fields == null) {
+      if (other.fields != null) return false;
+    } else if (!fields.equals(other.fields)) return false;
+    if (patterns == null) {
+      if (other.patterns != null) return false;
+    } else if (!patterns.equals(other.patterns)) return false;
+    return true;
+  }  
+  
   public static class RegexTarget
     extends AbstractTarget
     implements Target {
     
     private static final long serialVersionUID = 165211244926064449L;
-    protected transient Matcher matcher;
+    protected Matcher matcher;
+    protected String[] fields;
     
-    protected RegexTarget(
+    public RegexTarget(
       TargetType type, 
       RequestContext context, 
-      Matcher matcher) {
+      Matcher matcher,
+      String[] fields) {
         super(type, context);
         this.matcher = matcher;
+        this.fields = fields;
     }
     
+    public String getParameter(String name) {
+      if (fields == null) return null;
+      int idx = 0;
+      for (int n = 0; n < fields.length; n++)
+        if (fields[n].equalsIgnoreCase(name)) idx = n + 1;
+      return idx > 0 && idx <= matcher.groupCount() ? 
+        matcher.group(idx) : null;
+    }
+
+    public String[] getParameterNames() {
+      return fields;
+    }
+
     @Override
     public int hashCode() {
       final int PRIME = 31;
@@ -180,5 +252,5 @@
     }
     
   }
-
+  
 }

Copied: incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/basic/BasicAdapter.java (from r613765, incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/basic/AbstractBasicAdapter.java)
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/basic/BasicAdapter.java?p2=incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/basic/BasicAdapter.java&p1=incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/basic/AbstractBasicAdapter.java&r1=613765&r2=614076&rev=614076&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/basic/AbstractBasicAdapter.java (original)
+++ incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/basic/BasicAdapter.java Mon Jan 21 16:53:07 2008
@@ -18,29 +18,33 @@
 package org.apache.abdera.protocol.server.provider.basic;
 
 import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
 import java.util.Properties;
 import java.util.logging.Logger;
 
+import javax.activation.MimeType;
+
 import org.apache.abdera.Abdera;
-import org.apache.abdera.model.Element;
+import org.apache.abdera.model.Document;
 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.abdera.protocol.server.CollectionAdapter;
+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.Target;
+import org.apache.abdera.util.MimeTypeHelper;
+
+public abstract class BasicAdapter 
+  implements CollectionAdapter {
 
-public abstract class AbstractBasicAdapter implements BasicAdapter {
   public static Logger logger =
-    Logger.getLogger(AbstractBasicAdapter.class.getName());
+    Logger.getLogger(BasicAdapter.class.getName());
 
   protected Properties feedProperties;
   protected final String feedId;
   protected final Abdera abdera;
 
-  public static final String GBASE_NS = "http://base.google.com/ns/1.0";
-  public static final String GBASE_NS_PREFIX = "g";
-
   protected static final String PROP_NAME_FEED_URI = "feedUri";
   protected static final String PROP_NAME_TITLE = "title";
   protected static final String PROP_NAME_AUTHOR = "author";
@@ -50,11 +54,13 @@
   public static final String ENTRY_ELEM_NAME_AUTHOR = "author";
   public static final String ENTRY_ELEM_NAME_UPDATED = "updated";
 
-  protected AbstractBasicAdapter(Abdera abdera, Properties feedProperties,
-      String feedId) {
-    this.abdera = abdera;
-    this.feedProperties = feedProperties;
-    this.feedId = feedId;
+  protected BasicAdapter(
+    Abdera abdera, 
+    Properties feedProperties,
+    String feedId) {
+      this.abdera = abdera;
+      this.feedProperties = feedProperties;
+      this.feedId = feedId;
   }
 
   public String getProperty(String key) throws Exception {
@@ -77,33 +83,11 @@
   }
 
   protected void addEditLinkToEntry(Entry entry) throws Exception {
-    if (getEditUriFromEntry(entry) == null) {
+    if (ProviderHelper.getEditUriFromEntry(entry) == null) {
       entry.addLink(entry.getId().toString(), "edit");
     }
   }
 
-  //TODO: this should be moved to a Util class
-  public static String getEditUriFromEntry(Entry entry) throws Exception {
-    String editUri = null;
-    List<Link> editLinks = entry.getLinks("edit");
-    for (Link link : editLinks) {
-      // if there is more than one edit link, we should not automatically
-      // assume that it's always going to point to an Atom document
-      // representation.
-      if (link.getMimeType() != null) {
-        if (link.getMimeType().match("application/atom+xml")) {
-          editUri = link.getResolvedHref().toString();
-          break;
-        }
-      } else {
-        // edit link with no type attribute is the right one to use
-        editUri = link.getResolvedHref().toString();
-        break;
-      }
-    }
-   return editUri;
-  }
-
   protected void setEntryIdIfNull(Entry entry) throws Exception{
     // if there is no id in Entry, assign one.
     if (entry.getId() != null) {
@@ -118,32 +102,119 @@
   protected String createEntryIdUri(String entryId) throws Exception{
     return getProperty(PROP_NAME_FEED_URI) + "/" + entryId;
   }
+  
+  private ResponseContext createOrUpdateEntry(
+    RequestContext request,
+    boolean createFlag) {
+      try {
+        MimeType mimeType = request.getContentType();
+        String contentType = mimeType == null ? null : mimeType.toString();
+        if (contentType != null && 
+            !MimeTypeHelper.isAtom(contentType) &&
+            !MimeTypeHelper.isXml(contentType))
+          return ProviderHelper.notsupported(request);
+        Abdera abdera = request.getAbdera();
+        Parser parser = abdera.getParser();
+        Entry inputEntry = (Entry) request.getDocument(parser).getRoot();
+        Target target = request.getTarget();
+        String entryId = 
+          !createFlag ? 
+            target.getParameter(
+              BasicProvider.PARAM_ENTRY) : null;
+        Entry newEntry = createFlag
+            ? createEntry(inputEntry)
+            : updateEntry(entryId, inputEntry);
+        if (newEntry != null) {
+          Document<Entry> newEntryDoc = newEntry.getDocument();
+          String loc = newEntry.getEditLinkResolvedHref().toString();
+          return
+            ProviderHelper.returnBase(
+              newEntryDoc, 
+              createFlag ? 201 : 200, 
+                  null).setLocation(loc);
+        } else {
+          return ProviderHelper.notfound(request);
+        }
+      } catch (Exception e) {
+        return ProviderHelper.servererror(request, e.getMessage(), e);
+      }
+  }
 
-  protected Map<String, Object> collectColumns(Entry entry) {
-    Map<String, Object> columns = new HashMap<String, Object>();
-
-    if (entry.getId() != null) {
-      columns.put(ENTRY_ELEM_NAME_ID, entry.getId().toString());
-    }
-    if (entry.getAuthor() != null) {
-      columns.put(ENTRY_ELEM_NAME_AUTHOR, entry.getAuthor().getText());
-    }
-    if (entry.getTitle() != null) {
-      columns.put(ENTRY_ELEM_NAME_TITLE, entry.getTitle());
-    }
-    if (entry.getUpdated() != null) {
-      columns.put(ENTRY_ELEM_NAME_UPDATED, entry.getUpdated());
-    }
+  public ResponseContext postEntry(
+    RequestContext request) {
+      return createOrUpdateEntry(request, true);
+  }
+  
+  public ResponseContext deleteEntry(
+    RequestContext request) {
+      Target target = request.getTarget();
+      String entryId = target.getParameter(BasicProvider.PARAM_ENTRY);
+      try {
+        return deleteEntry(entryId) ?
+          ProviderHelper.nocontent() :
+          ProviderHelper.notfound(request);
+      } catch (Exception e) {
+        return ProviderHelper.servererror(request, e.getMessage(), e);
+      }
+  }
 
-    // get all our namespace extension elements
-    List<Element> extElements = entry.getExtensions(GBASE_NS);
-    if (extElements != null) {
-      for (Element element : extElements) {
-        String name = element.getQName().getLocalPart();
-        String value = element.getText();
-        columns.put(name, value);
+  public ResponseContext putEntry(
+    RequestContext request) {
+      return createOrUpdateEntry(request, false);
+  }
+
+  public ResponseContext getEntry(
+    RequestContext request) {
+      Target target = request.getTarget();
+      String entryId = target.getParameter(BasicProvider.PARAM_ENTRY);
+      try {
+        Entry entry = getEntry(entryId);
+        return entry != null ?
+          ProviderHelper.returnBase(entry.getDocument(),200,null) :
+          ProviderHelper.notfound(request);
+      } catch (Exception e) {
+        return ProviderHelper.servererror(request, e.getMessage(), e);
       }
+  }
+
+  public ResponseContext getFeed(RequestContext request) {
+    try {
+      Feed feed = getFeed();
+      return feed != null ?
+        ProviderHelper.returnBase(feed.getDocument(),200,null) :
+        ProviderHelper.notfound(request);
+    } catch (Exception e) {
+      return ProviderHelper.servererror(request, e.getMessage(), e);
     }
-    return columns;
   }
+
+  public ResponseContext extensionRequest(RequestContext request) {
+    return ProviderHelper.notallowed(
+      request, 
+      "Method Not Allowed", 
+      ProviderHelper.getDefaultMethods(request));
+  }
+  
+  
+  
+  public abstract Feed getFeed() 
+    throws Exception;
+
+  public abstract Entry getEntry(
+    Object entryId) 
+      throws Exception;
+
+  public abstract Entry createEntry(
+    Entry entry) 
+      throws Exception;
+
+  public abstract Entry updateEntry(
+    Object entryId, 
+    Entry entry) 
+      throws Exception;
+
+  public abstract boolean deleteEntry(
+    Object entryId) 
+      throws Exception;
+  
 }

Modified: incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/basic/BasicProvider.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/basic/BasicProvider.java?rev=614076&r1=614075&r2=614076&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/basic/BasicProvider.java (original)
+++ incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/basic/BasicProvider.java Mon Jan 21 16:53:07 2008
@@ -17,166 +17,64 @@
 */
 package org.apache.abdera.protocol.server.provider.basic;
 
-import java.util.logging.Logger;
+import java.io.IOException;
+import java.util.Map;
+import java.util.Properties;
 
-import javax.activation.MimeType;
-
-import org.apache.abdera.Abdera;
-import org.apache.abdera.model.Document;
-import org.apache.abdera.model.Entry;
-import org.apache.abdera.model.Feed;
-import org.apache.abdera.parser.Parser;
-import org.apache.abdera.protocol.server.CollectionAdapter;
 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.Target;
-import org.apache.abdera.protocol.server.impl.AbstractWorkspaceManagerProvider;
-import org.apache.abdera.protocol.server.impl.EmptyResponseContext;
-import org.apache.abdera.util.MimeTypeHelper;
+import org.apache.abdera.protocol.server.context.StreamWriterResponseContext;
+import org.apache.abdera.protocol.server.impl.AbstractWorkspaceProvider;
+import org.apache.abdera.protocol.server.impl.CollectionAdapterManager;
+import org.apache.abdera.util.Constants;
+import org.apache.abdera.writer.StreamWriter;
 
 @SuppressWarnings("unchecked")
 public class BasicProvider 
-  extends AbstractWorkspaceManagerProvider
-  implements CollectionAdapter {
+  extends AbstractWorkspaceProvider {
     
-  public CollectionAdapter getCollectionAdapter(
-    RequestContext request) {
-      return this;
-  }
-
-  public static final String PARAM_ENTRY = "entry";
   public static final String PARAM_FEED = "feed";
-
-  private static final boolean CREATE_FLAG = true;
-  private static final boolean UPDATE_FLAG = false;
-
-  public static Logger logger = Logger.getLogger(
-      BasicProvider.class.getName());
-
-  public static BasicAdapterManager basicAdapterManager;
-
-  private ResponseContext createOrUpdateEntry(RequestContext request,
-      boolean createFlag) {
-    try {
-      MimeType mimeType = request.getContentType();
-      String contentType = mimeType == null ? null : mimeType.toString();
-      if (contentType != null && !MimeTypeHelper.isAtom(contentType) &&
-          !MimeTypeHelper.isXml(contentType)) {
-        // unsupported media type
-        return new EmptyResponseContext(415);
-      }
-
-      Abdera abdera = request.getServiceContext().getAbdera();
-      Parser parser = abdera.getParser();
-      Entry inputEntry = (Entry) request.getDocument(parser).getRoot();
-
-      Target target = request.getTarget();
-      String feedId = target.getParameter(PARAM_FEED);
-      String entryId = createFlag == UPDATE_FLAG
-          ? target.getParameter(PARAM_ENTRY) : null;
-
-      BasicAdapter basicAdapter = getAdapterManagerInstance(request).getAdapter(feedId);
-      Entry newEntry = createFlag == CREATE_FLAG
-          ? basicAdapter.createEntry(inputEntry)
-          : basicAdapter.updateEntry(entryId, inputEntry);
-      if (newEntry != null) {
-        Document<Entry> newEntryDoc = newEntry.getDocument();
-        ResponseContext response =
-          new BasicResponseContext<Document<Entry>>(newEntryDoc, createFlag ? 201 : 200);
-        String loc = newEntry.getEditLinkResolvedHref().toString();
-        response.setLocation(loc);
-        return response;
-      } else {
-        return new EmptyResponseContext(404);
-      }
-    } catch (Exception e) {
-      EmptyResponseContext response = new EmptyResponseContext(500);
-      response.setStatusText(e.getMessage());
-      return response;
-    }
-  }
-
-  private BasicAdapterManager getAdapterManagerInstance(RequestContext request) {
-    if (basicAdapterManager == null) {
-      basicAdapterManager =
-        new BasicAdapterManager(request.getServiceContext().getAbdera());
-    }
-    return basicAdapterManager;
-  }
-
-  public ResponseContext postEntry(RequestContext request) {
-    return createOrUpdateEntry(request, CREATE_FLAG);
-  }
+  public static final String PARAM_ENTRY = "entry";
   
-  public ResponseContext deleteEntry(RequestContext request) {
-    Target target = request.getTarget();
-    String feedId = target.getParameter(PARAM_FEED);
-    String entryId = target.getParameter(PARAM_ENTRY);
-
-    try {
-      BasicAdapter basicAdapter = getAdapterManagerInstance(request).getAdapter(feedId);
-      if (basicAdapter.deleteEntry(entryId)) {
-        return new EmptyResponseContext(200);
-      } else { // entry not found
-        return new EmptyResponseContext(404);
-      }
-    } catch (Exception e) {
-      EmptyResponseContext response = new EmptyResponseContext(500);
-      response.setStatusText(e.getMessage());
-      return response;
-    }
-  }
-
-  public ResponseContext putEntry(RequestContext request) {
-    return createOrUpdateEntry(request, UPDATE_FLAG);
-  }
-
-  public ResponseContext getEntry(RequestContext request) {
-    Target target = request.getTarget();
-    String feedId = target.getParameter(PARAM_FEED);
-    String entryId = target.getParameter(PARAM_ENTRY);
-
-    try {
-      BasicAdapter basicAdapter = getAdapterManagerInstance(request).getAdapter(feedId);
-      Entry entry = basicAdapter.getEntry(entryId);
-      if (entry != null) {
-        Document<Entry> entryDoc = entry.getDocument();
-        return new BasicResponseContext<Document<Entry>>(entryDoc,200);
-      } else {
-        return new EmptyResponseContext(404);
-      }
-    } catch (Exception e) {
-      EmptyResponseContext response = new EmptyResponseContext(500);
-      response.setStatusText(e.getMessage());
-      return response;
-    }
+  public String getAdapterIdentifier(
+    RequestContext request) {
+      return request.getTarget().getParameter(PARAM_FEED);
   }
 
-  public ResponseContext getFeed(RequestContext request) {
-    Target target = request.getTarget();
-    String feedId = target.getParameter(PARAM_FEED);
-    try {
-      BasicAdapter basicAdapter = getAdapterManagerInstance(request).getAdapter(feedId);
-      Feed feed = basicAdapter.getFeed();
-      if (feed != null) {
-        Document<Feed> feedDoc = feed.getDocument();
-        return new BasicResponseContext<Document<Feed>>(feedDoc, 200);
-      } else {
-        return new EmptyResponseContext(404);
+  protected ResponseContext getServiceDocument(
+    RequestContext request) {
+      try {
+        CollectionAdapterManager bam = getCollectionAdapterManager(request);
+        final Map<String,Properties> map = bam.listAdapters();
+        return 
+        new StreamWriterResponseContext(request.getAbdera()) {
+          protected void writeTo(
+            StreamWriter sw) 
+              throws IOException {
+            sw.startDocument()
+              .startService()
+              .startWorkspace()
+              .writeTitle("Abdera");
+            for (Map.Entry<String,Properties> entry : map.entrySet()) {
+              Properties properties = entry.getValue();
+              sw.startCollection(properties.getProperty(BasicAdapter.PROP_NAME_FEED_URI))
+                .writeTitle(properties.getProperty(BasicAdapter.PROP_NAME_TITLE))
+                .writeAcceptsEntry()
+                .startCategories(false)
+                .endCategories()
+                .endCollection();
+            }
+            sw.endWorkspace()
+              .endService()
+              .endDocument();
+          }
+        }
+        .setStatus(200)
+        .setContentType(Constants.APP_MEDIA_TYPE);
+      } catch (Exception e) {
+        return ProviderHelper.servererror(request, e.getMessage(), e);
       }
-    } catch (Exception e) {
-      EmptyResponseContext response = new EmptyResponseContext(500);
-      response.setStatusText(e.getMessage());
-      return response;
-    }
-  }
-
-  public ResponseContext extensionRequest(RequestContext request) {
-    return ProviderHelper.notallowed(
-      request, 
-      "Method Not Allowed", 
-      this.getMethods(request));
   }
   
 }

Modified: incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/basic/BasicServiceContext.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/basic/BasicServiceContext.java?rev=614076&r1=614075&r2=614076&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/basic/BasicServiceContext.java (original)
+++ incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/basic/BasicServiceContext.java Mon Jan 21 16:53:07 2008
@@ -17,7 +17,7 @@
 */
 package org.apache.abdera.protocol.server.provider.basic;
 
-import org.apache.abdera.protocol.server.impl.DefaultServiceContext;
+import org.apache.abdera.protocol.server.context.DefaultServiceContext;
 
 public class BasicServiceContext 
   extends DefaultServiceContext {
@@ -26,5 +26,5 @@
     this.defaultprovider = BasicProvider.class.getName();
     this.defaulttargetresolver = BasicTargetResolver.class.getName();
   }
-  
-}
+    
+}
\ No newline at end of file

Modified: incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/basic/BasicTargetResolver.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/basic/BasicTargetResolver.java?rev=614076&r1=614075&r2=614076&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/basic/BasicTargetResolver.java (original)
+++ incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/basic/BasicTargetResolver.java Mon Jan 21 16:53:07 2008
@@ -17,13 +17,6 @@
 */
 package org.apache.abdera.protocol.server.provider.basic;
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.regex.Matcher;
-
-import org.apache.abdera.protocol.server.RequestContext;
-import org.apache.abdera.protocol.server.Target;
 import org.apache.abdera.protocol.server.TargetType;
 import org.apache.abdera.protocol.server.impl.RegexTargetResolver;
 
@@ -31,63 +24,9 @@
   extends RegexTargetResolver {
 
   public BasicTargetResolver() {
-    setPattern("/" + "([^/#?]+)", TargetType.TYPE_COLLECTION);
-    setPattern("/" + "([^/#?]+)/([^/#?]+)", TargetType.TYPE_ENTRY);
-  }
-
-  @Override
-  protected Target getTarget(
-    TargetType type,
-    RequestContext request,
-    Matcher matcher) {
-      return new FeedServerTarget(type, request, matcher);
+    setPattern("/", TargetType.TYPE_SERVICE);
+    setPattern("/" + "([^/#?]+)", TargetType.TYPE_COLLECTION, BasicProvider.PARAM_FEED);
+    setPattern("/" + "([^/#?]+)/([^/#?]+)", TargetType.TYPE_ENTRY, BasicProvider.PARAM_FEED, BasicProvider.PARAM_ENTRY);
   }
 
-  private static final class FeedServerTarget extends RegexTarget {
-
-    protected FeedServerTarget(
-      TargetType type,
-      RequestContext context,
-      Matcher matcher) {
-        super(type, context, matcher);
-    }
-
-    @Override
-    public String getParameter(String name) {
-      TargetType type = getType();
-
-      if (type.equals(TargetType.TYPE_COLLECTION) ||
-          type.equals(TargetType.TYPE_ENTRY)) {
-        if (name.equalsIgnoreCase(BasicProvider.PARAM_FEED)) {
-          return matcher.group(1);
-        }
-      }
-
-      if (type.equals(TargetType.TYPE_ENTRY)) {
-        if (name.equalsIgnoreCase(BasicProvider.PARAM_ENTRY)) {
-          return matcher.group(2);
-        }
-      }
-
-      return super.getParameter(name);
-    }
-
-    @Override
-    public String[] getParameterNames() {
-      List<String> paramNames = new ArrayList<String>();
-      paramNames.addAll(Arrays.asList(super.getParameterNames()));
-      TargetType type = getType();
-      if (type.equals(TargetType.TYPE_COLLECTION) ||
-          type.equals(TargetType.TYPE_ENTRY)) {
-        paramNames.add(BasicProvider.PARAM_FEED);
-      }
-
-      if (type.equals(TargetType.TYPE_ENTRY)) {
-        paramNames.add(BasicProvider.PARAM_ENTRY);
-      }
-
-      return paramNames.toArray(new String[0]);
-    }
-  }
-  
 }

Added: incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/ext/AbstractWorkspaceInfo.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/ext/AbstractWorkspaceInfo.java?rev=614076&view=auto
==============================================================================
--- incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/ext/AbstractWorkspaceInfo.java (added)
+++ incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/ext/AbstractWorkspaceInfo.java Mon Jan 21 16:53:07 2008
@@ -0,0 +1,42 @@
+/*
+* 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.provider.ext;
+
+import org.apache.abdera.protocol.server.ProviderHelper;
+import org.apache.abdera.protocol.server.RequestContext;
+
+public abstract class AbstractWorkspaceInfo 
+  implements WorkspaceInfo {
+  
+  public boolean checkTarget(
+    RequestContext request) {
+      return request.getTarget() != null;
+  }
+  
+  public String[] getMethods(RequestContext request) {
+    return ProviderHelper.getDefaultMethods(request);
+  }
+  
+  public boolean checkMethod(
+    RequestContext request) {
+      return ProviderHelper.defaultCheckMethod(
+        request, 
+        getMethods(request));
+  }
+  
+}

Added: incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/ext/CollectionInfo.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/ext/CollectionInfo.java?rev=614076&view=auto
==============================================================================
--- incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/ext/CollectionInfo.java (added)
+++ incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/ext/CollectionInfo.java Mon Jan 21 16:53:07 2008
@@ -0,0 +1,34 @@
+/*
+* 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.provider.ext;
+
+import org.apache.abdera.protocol.server.CollectionAdapter;
+import org.apache.abdera.protocol.server.RequestContext;
+
+public interface CollectionInfo 
+  extends CollectionAdapter {
+
+  public String getHref(RequestContext request);
+  
+  public String getTitle(RequestContext request);
+  
+  public String[] getAccepts(RequestContext request);
+  
+  public boolean isAdapterFor(RequestContext request);
+  
+}

Added: incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/ext/ExtendedProvider.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/ext/ExtendedProvider.java?rev=614076&view=auto
==============================================================================
--- incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/ext/ExtendedProvider.java (added)
+++ incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/ext/ExtendedProvider.java Mon Jan 21 16:53:07 2008
@@ -0,0 +1,90 @@
+/*
+* 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.provider.ext;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.abdera.protocol.server.RequestContext;
+import org.apache.abdera.protocol.server.ResponseContext;
+import org.apache.abdera.protocol.server.WorkspaceManager;
+import org.apache.abdera.protocol.server.context.StreamWriterResponseContext;
+import org.apache.abdera.protocol.server.impl.AbstractProvider;
+import org.apache.abdera.util.Constants;
+import org.apache.abdera.writer.StreamWriter;
+
+public class ExtendedProvider 
+  extends AbstractProvider {
+  
+  private List<WorkspaceInfo> workspaces = new ArrayList<WorkspaceInfo>();
+  
+  public void addWorkspace(WorkspaceInfo wi) {
+    if (!workspaces.contains(wi))
+      workspaces.add(wi);
+  }
+   
+  protected WorkspaceInfo getWorkspace(
+    RequestContext request) {
+      for (WorkspaceInfo wi : getWorkspaces(request)) {
+        if (wi.isWorkspaceFor(request))
+          return wi;
+      }
+      return null;
+  }
+ 
+  protected WorkspaceInfo[] getWorkspaces(
+    RequestContext request) {
+      return workspaces.toArray(new WorkspaceInfo[workspaces.size()]);
+  }
+  
+  protected WorkspaceManager getWorkspaceManager(
+    RequestContext request) {
+      return getWorkspace(request);
+  }
+  
+  protected ResponseContext getServiceDocument(
+    final RequestContext request) {
+      return 
+        new StreamWriterResponseContext(request.getAbdera()) {
+          protected void writeTo(
+            StreamWriter sw) 
+              throws IOException {
+            sw.startDocument()
+              .startService();
+            for (WorkspaceInfo wi : getWorkspaces(request)) {
+              sw.startWorkspace()
+                .writeTitle(wi.getTitle(request));
+              for (CollectionInfo ci : wi.getCollections(request)) {
+                sw.startCollection(ci.getHref(request))
+                  .writeTitle(ci.getTitle(request))
+                  .writeAccepts(ci.getAccepts(request))
+                    // TODO: handle categories
+                  .endCollection();
+              }
+              sw.endWorkspace();
+            }
+            sw.endService()
+              .endDocument();
+          }
+        }
+        .setStatus(200)
+        .setContentType(Constants.APP_MEDIA_TYPE);
+  }
+  
+}

Added: incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/ext/SimpleCollection.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/ext/SimpleCollection.java?rev=614076&view=auto
==============================================================================
--- incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/ext/SimpleCollection.java (added)
+++ incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/ext/SimpleCollection.java Mon Jan 21 16:53:07 2008
@@ -0,0 +1,86 @@
+/*
+* 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.provider.ext;
+
+import org.apache.abdera.protocol.server.CollectionAdapter;
+import org.apache.abdera.protocol.server.RequestContext;
+import org.apache.abdera.protocol.server.ResponseContext;
+
+public class SimpleCollection 
+  implements CollectionInfo {
+  
+  private final CollectionAdapter internal;
+  private final String id;
+  private final String title;
+  private final String href;
+  private final String[] accepts;
+  
+  public SimpleCollection(
+    CollectionAdapter adapter,
+    String id,
+    String title,
+    String href,
+    String... accepts) {
+      this.internal = adapter;
+      this.id = id;
+      this.title = title;
+      this.accepts = accepts;
+      this.href = href;
+  }
+  
+  public String[] getAccepts(RequestContext request) {
+    return accepts;
+  }
+  
+  public String getHref(RequestContext request) {
+    return href;
+  }
+  
+  public String getTitle(RequestContext request) {
+    return title;
+  }
+  
+  public boolean isAdapterFor(RequestContext request) {
+    return request.getTarget().getParameter("collection").equals(this.id);
+  }
+  
+  public ResponseContext deleteEntry(RequestContext request) {
+    return internal.deleteEntry(request);
+  }
+  
+  public ResponseContext extensionRequest(RequestContext request) {
+    return internal.extensionRequest(request);
+  }
+  
+  public ResponseContext getEntry(RequestContext request) {
+    return internal.getEntry(request);
+  }
+  
+  public ResponseContext getFeed(RequestContext request) {
+    return internal.getFeed(request);
+  }
+  
+  public ResponseContext postEntry(RequestContext request) {
+    return internal.postEntry(request);
+  }
+  
+  public ResponseContext putEntry(RequestContext request) {
+    return internal.putEntry(request);
+  }
+  
+}

Added: incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/ext/SimpleWorkspace.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/ext/SimpleWorkspace.java?rev=614076&view=auto
==============================================================================
--- incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/ext/SimpleWorkspace.java (added)
+++ incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/ext/SimpleWorkspace.java Mon Jan 21 16:53:07 2008
@@ -0,0 +1,69 @@
+/*
+* 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.provider.ext;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.abdera.protocol.server.CollectionAdapter;
+import org.apache.abdera.protocol.server.RequestContext;
+
+public class SimpleWorkspace
+  extends AbstractWorkspaceInfo
+  implements WorkspaceInfo {
+
+  protected String title;
+  protected List<CollectionInfo> collections = new ArrayList<CollectionInfo>();
+  
+  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) {
+    if (!this.collections.contains(ci))
+      this.collections.add(ci);
+  }
+  
+  public CollectionInfo[] getCollections(RequestContext request) {
+    return collections.toArray(new CollectionInfo[collections.size()]);
+  }
+
+  public CollectionAdapter getCollectionAdapter(
+    RequestContext request) {
+      for (CollectionInfo ci : getCollections(request)) {
+        if (ci.isAdapterFor(request)) return ci;
+      }
+      return null;
+  }
+
+  public boolean isWorkspaceFor(RequestContext request) {
+    for (CollectionInfo ci : getCollections(request)) {
+      if (ci.isAdapterFor(request)) return true;
+    }
+    return false;
+  }
+
+}

Added: incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/ext/WorkspaceInfo.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/ext/WorkspaceInfo.java?rev=614076&view=auto
==============================================================================
--- incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/ext/WorkspaceInfo.java (added)
+++ incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/ext/WorkspaceInfo.java Mon Jan 21 16:53:07 2008
@@ -0,0 +1,31 @@
+/*
+* 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.provider.ext;
+
+import org.apache.abdera.protocol.server.RequestContext;
+import org.apache.abdera.protocol.server.WorkspaceManager;
+
+public interface WorkspaceInfo 
+  extends WorkspaceManager {
+
+  String getTitle(RequestContext request);
+  
+  CollectionInfo[] getCollections(RequestContext request);
+  
+  boolean isWorkspaceFor(RequestContext request);
+}



Mime
View raw message