abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r614086 - in /incubator/abdera/java/branches/server_refactor/src: main/java/org/apache/abdera/protocol/server/impl/ main/java/org/apache/abdera/protocol/server/provider/basic/ main/java/org/apache/abdera/protocol/server/provider/ext/ test/j...
Date Tue, 22 Jan 2008 01:41:39 GMT
Author: jmsnell
Date: Mon Jan 21 17:41:37 2008
New Revision: 614086

URL: http://svn.apache.org/viewvc?rev=614086&view=rev
Log:
Ok, the next iteration.  This moves the feed-server derived stuff on top of the ext stuff.
 This collapses things down even further.

Oh, and the feed-server derived stuff will now generate a service document.

Added:
    incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/AbstractWorkspaceInfo.java
      - copied, changed from r614076, 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/impl/CollectionInfo.java
      - copied, changed from r614076, 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/impl/ExtendedProvider.java
      - copied, changed from r614076, 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/impl/SimpleCollection.java
      - copied, changed from r614076, 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/impl/SimpleWorkspace.java
      - copied, changed from r614076, 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/impl/WorkspaceInfo.java
      - copied, changed from r614076, 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/main/java/org/apache/abdera/protocol/server/provider/basic/BasicWorkspace.java
Removed:
    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/BasicTargetResolver.java
    incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/ext/
Modified:
    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/AbstractWorkspaceProvider.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/BasicAdapter.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/test/java/org/apache/abdera/protocol/server/test/ext/TestServiceContext.java

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=614086&r1=614085&r2=614086&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 17:41:37 2008
@@ -31,16 +31,6 @@
 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) {    
       Target target = request.getTarget();

Copied: incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/AbstractWorkspaceInfo.java
(from r614076, 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/impl/AbstractWorkspaceInfo.java?p2=incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/AbstractWorkspaceInfo.java&p1=incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/ext/AbstractWorkspaceInfo.java&r1=614076&r2=614086&rev=614086&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/ext/AbstractWorkspaceInfo.java
(original)
+++ incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/AbstractWorkspaceInfo.java
Mon Jan 21 17:41:37 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.provider.ext;
+package org.apache.abdera.protocol.server.impl;
 
 import org.apache.abdera.protocol.server.ProviderHelper;
 import org.apache.abdera.protocol.server.RequestContext;

Modified: incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/AbstractWorkspaceProvider.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/AbstractWorkspaceProvider.java?rev=614086&r1=614085&r2=614086&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/AbstractWorkspaceProvider.java
(original)
+++ incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/AbstractWorkspaceProvider.java
Mon Jan 21 17:41:37 2008
@@ -17,7 +17,6 @@
 */
 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;
@@ -48,16 +47,6 @@
         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;

Copied: incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/CollectionInfo.java
(from r614076, 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/impl/CollectionInfo.java?p2=incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/CollectionInfo.java&p1=incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/ext/CollectionInfo.java&r1=614076&r2=614086&rev=614086&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/ext/CollectionInfo.java
(original)
+++ incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/CollectionInfo.java
Mon Jan 21 17:41:37 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.provider.ext;
+package org.apache.abdera.protocol.server.impl;
 
 import org.apache.abdera.protocol.server.CollectionAdapter;
 import org.apache.abdera.protocol.server.RequestContext;

Copied: incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/ExtendedProvider.java
(from r614076, 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/impl/ExtendedProvider.java?p2=incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/ExtendedProvider.java&p1=incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/ext/ExtendedProvider.java&r1=614076&r2=614086&rev=614086&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/ext/ExtendedProvider.java
(original)
+++ incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/ExtendedProvider.java
Mon Jan 21 17:41:37 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.provider.ext;
+package org.apache.abdera.protocol.server.impl;
 
 import java.io.IOException;
 import java.util.ArrayList;
@@ -25,7 +25,6 @@
 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;
 
@@ -33,6 +32,13 @@
   extends AbstractProvider {
   
   private List<WorkspaceInfo> workspaces = new ArrayList<WorkspaceInfo>();
+  
+  public ExtendedProvider() {}
+  
+  public ExtendedProvider(WorkspaceInfo... workspaces) {
+    for (WorkspaceInfo wi : workspaces)
+      addWorkspace(wi);
+  }
   
   public void addWorkspace(WorkspaceInfo wi) {
     if (!workspaces.contains(wi))

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=614086&r1=614085&r2=614086&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 17:41:37 2008
@@ -17,8 +17,10 @@
 */
 package org.apache.abdera.protocol.server.impl;
 
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
@@ -164,16 +166,20 @@
     }
     
     public String getParameter(String name) {
-      if (fields == null) return null;
+      if (fields == null) return super.getParameter(name);
       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;
+        matcher.group(idx) : super.getParameter(name);
     }
 
     public String[] getParameterNames() {
-      return fields;
+      String[] names = super.getParameterNames();
+      List<String> list = new ArrayList<String>();
+      if (names != null) list.addAll(Arrays.asList(names));
+      if (fields != null) list.addAll(Arrays.asList(fields));
+      return list.toArray(new String[list.size()]);
     }
 
     @Override

Copied: incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/SimpleCollection.java
(from r614076, 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/impl/SimpleCollection.java?p2=incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/SimpleCollection.java&p1=incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/ext/SimpleCollection.java&r1=614076&r2=614086&rev=614086&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/ext/SimpleCollection.java
(original)
+++ incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/SimpleCollection.java
Mon Jan 21 17:41:37 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.provider.ext;
+package org.apache.abdera.protocol.server.impl;
 
 import org.apache.abdera.protocol.server.CollectionAdapter;
 import org.apache.abdera.protocol.server.RequestContext;

Copied: incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/SimpleWorkspace.java
(from r614076, 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/impl/SimpleWorkspace.java?p2=incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/SimpleWorkspace.java&p1=incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/ext/SimpleWorkspace.java&r1=614076&r2=614086&rev=614086&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/ext/SimpleWorkspace.java
(original)
+++ incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/SimpleWorkspace.java
Mon Jan 21 17:41:37 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.provider.ext;
+package org.apache.abdera.protocol.server.impl;
 
 import java.util.ArrayList;
 import java.util.List;

Copied: incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/WorkspaceInfo.java
(from r614076, 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/impl/WorkspaceInfo.java?p2=incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/WorkspaceInfo.java&p1=incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/ext/WorkspaceInfo.java&r1=614076&r2=614086&rev=614086&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/ext/WorkspaceInfo.java
(original)
+++ incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/WorkspaceInfo.java
Mon Jan 21 17:41:37 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.provider.ext;
+package org.apache.abdera.protocol.server.impl;
 
 import org.apache.abdera.protocol.server.RequestContext;
 import org.apache.abdera.protocol.server.WorkspaceManager;

Modified: incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/basic/BasicAdapter.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?rev=614086&r1=614085&r2=614086&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/basic/BasicAdapter.java
(original)
+++ incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/basic/BasicAdapter.java
Mon Jan 21 17:41:37 2008
@@ -120,7 +120,7 @@
         String entryId = 
           !createFlag ? 
             target.getParameter(
-              BasicProvider.PARAM_ENTRY) : null;
+              BasicServiceContext.PARAM_ENTRY) : null;
         Entry newEntry = createFlag
             ? createEntry(inputEntry)
             : updateEntry(entryId, inputEntry);
@@ -148,7 +148,7 @@
   public ResponseContext deleteEntry(
     RequestContext request) {
       Target target = request.getTarget();
-      String entryId = target.getParameter(BasicProvider.PARAM_ENTRY);
+      String entryId = target.getParameter(BasicServiceContext.PARAM_ENTRY);
       try {
         return deleteEntry(entryId) ?
           ProviderHelper.nocontent() :
@@ -166,7 +166,7 @@
   public ResponseContext getEntry(
     RequestContext request) {
       Target target = request.getTarget();
-      String entryId = target.getParameter(BasicProvider.PARAM_ENTRY);
+      String entryId = target.getParameter(BasicServiceContext.PARAM_ENTRY);
       try {
         Entry entry = getEntry(entryId);
         return entry != null ?

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=614086&r1=614085&r2=614086&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 17:41:37 2008
@@ -17,14 +17,35 @@
 */
 package org.apache.abdera.protocol.server.provider.basic;
 
+import org.apache.abdera.protocol.Resolver;
+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.protocol.server.TargetType;
 import org.apache.abdera.protocol.server.context.DefaultServiceContext;
+import org.apache.abdera.protocol.server.impl.ExtendedProvider;
+import org.apache.abdera.protocol.server.impl.RegexTargetResolver;
 
 public class BasicServiceContext 
   extends DefaultServiceContext {
 
-  public BasicServiceContext() {
-    this.defaultprovider = BasicProvider.class.getName();
-    this.defaulttargetresolver = BasicTargetResolver.class.getName();
-  }
+  public static final String PARAM_FEED = "feed";
+  public static final String PARAM_ENTRY = "entry";
+
+  public synchronized Provider getProvider(
+      RequestContext request) {
+        if (provider == null) {
+          provider = 
+            new ExtendedProvider(
+              new BasicWorkspace());
+        }
+        return provider;
+    }
     
+  public Resolver<Target> getTargetResolver() {
+    return new RegexTargetResolver()
+      .setPattern("/", TargetType.TYPE_SERVICE)
+      .setPattern("/" + "([^/#?]+)", TargetType.TYPE_COLLECTION, BasicServiceContext.PARAM_FEED)
+      .setPattern("/" + "([^/#?]+)/([^/#?]+)", TargetType.TYPE_ENTRY, BasicServiceContext.PARAM_FEED,
BasicServiceContext.PARAM_ENTRY);
+  }
 }

Added: incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/basic/BasicWorkspace.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/basic/BasicWorkspace.java?rev=614086&view=auto
==============================================================================
--- incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/basic/BasicWorkspace.java
(added)
+++ incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/provider/basic/BasicWorkspace.java
Mon Jan 21 17:41:37 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.protocol.server.provider.basic;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import org.apache.abdera.protocol.server.CollectionAdapter;
+import org.apache.abdera.protocol.server.RequestContext;
+import org.apache.abdera.protocol.server.impl.AbstractWorkspaceInfo;
+import org.apache.abdera.protocol.server.impl.CollectionAdapterManager;
+import org.apache.abdera.protocol.server.impl.CollectionInfo;
+import org.apache.abdera.protocol.server.impl.SimpleCollection;
+
+public class BasicWorkspace
+  extends AbstractWorkspaceInfo {
+
+  protected CollectionAdapterManager cam;
+  
+  protected CollectionAdapterManager getCollectionAdapterManager(
+    RequestContext request) {
+      if (cam == null) 
+        cam = new CollectionAdapterManager(
+          request.getAbdera());
+    return cam;
+  }
+  
+  public CollectionInfo[] getCollections(RequestContext request) {
+    CollectionAdapterManager cam = getCollectionAdapterManager(request);
+    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");
+        collections.add(col);
+      }
+    } catch (Exception e) {}
+    return collections.toArray(new CollectionInfo[collections.size()]);
+  }
+
+  public CollectionAdapter getCollectionAdapter(RequestContext request) {
+    try {
+      return getCollectionAdapterManager(request)
+        .getAdapter(
+          request.getTarget()
+            .getParameter(
+              BasicServiceContext.PARAM_FEED));
+    } catch (Exception e) {
+      return null;
+    }
+  }
+
+  public String getTitle(RequestContext request) {
+    return "Abdera";
+  }
+
+  public boolean isWorkspaceFor(RequestContext request) {
+    return getCollectionAdapter(request) != null;
+  }
+
+}

Modified: incubator/abdera/java/branches/server_refactor/src/test/java/org/apache/abdera/protocol/server/test/ext/TestServiceContext.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor/src/test/java/org/apache/abdera/protocol/server/test/ext/TestServiceContext.java?rev=614086&r1=614085&r2=614086&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor/src/test/java/org/apache/abdera/protocol/server/test/ext/TestServiceContext.java
(original)
+++ incubator/abdera/java/branches/server_refactor/src/test/java/org/apache/abdera/protocol/server/test/ext/TestServiceContext.java
Mon Jan 21 17:41:37 2008
@@ -23,10 +23,10 @@
 import org.apache.abdera.protocol.server.Target;
 import org.apache.abdera.protocol.server.TargetType;
 import org.apache.abdera.protocol.server.context.DefaultServiceContext;
+import org.apache.abdera.protocol.server.impl.ExtendedProvider;
 import org.apache.abdera.protocol.server.impl.RegexTargetResolver;
-import org.apache.abdera.protocol.server.provider.ext.ExtendedProvider;
-import org.apache.abdera.protocol.server.provider.ext.SimpleCollection;
-import org.apache.abdera.protocol.server.provider.ext.SimpleWorkspace;
+import org.apache.abdera.protocol.server.impl.SimpleCollection;
+import org.apache.abdera.protocol.server.impl.SimpleWorkspace;
 import org.apache.abdera.protocol.server.test.simple.SimpleAdapter;
 
 public class TestServiceContext 



Mime
View raw message