abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r613783 - in /incubator/abdera/java/branches/server_refactor/src: main/java/org/apache/abdera/protocol/server/ main/java/org/apache/abdera/protocol/server/impl/ main/java/org/apache/abdera/protocol/server/servlet/ test/java/org/apache/abder...
Date Mon, 21 Jan 2008 07:47:45 GMT
Author: jmsnell
Date: Sun Jan 20 23:47:42 2008
New Revision: 613783

URL: http://svn.apache.org/viewvc?rev=613783&view=rev
Log:
Additional simplifications designed to make it easier to implement providers. Look at the
Simple test case for an example

Added:
    incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/AbstractCombinedProvider.java
Removed:
    incubator/abdera/java/branches/server_refactor/src/test/java/org/apache/abdera/protocol/server/test/simple/SimpleProvider.java
    incubator/abdera/java/branches/server_refactor/src/test/java/org/apache/abdera/protocol/server/test/simple/SimpleTargetResolver.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/ServiceContext.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/servlet/ServletRequestContext.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/java/org/apache/abdera/protocol/server/test/simple/SimpleTest.java

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=613783&r1=613782&r2=613783&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
Sun Jan 20 23:47:42 2008
@@ -13,17 +13,20 @@
 import org.apache.abdera.i18n.iri.IRI;
 import org.apache.abdera.i18n.text.Localizer;
 import org.apache.abdera.i18n.text.Sanitizer;
+import org.apache.abdera.model.AtomDate;
 import org.apache.abdera.model.Base;
 import org.apache.abdera.model.Content;
 import org.apache.abdera.model.Document;
 import org.apache.abdera.model.Element;
 import org.apache.abdera.model.Entry;
 import org.apache.abdera.model.ExtensibleElement;
+import org.apache.abdera.model.Feed;
 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.util.EntityTag;
 import org.apache.abdera.util.MimeTypeHelper;
 import org.apache.abdera.writer.NamedWriter;
 import org.apache.abdera.writer.StreamWriter;
@@ -115,6 +118,15 @@
   }
 
   /**
+   * Return a server error
+   */
+  public static ResponseContext servererror(
+    RequestContext request,
+    Throwable t) {
+      return servererror(request,"Server Error",t);
+  }
+  
+  /**
    * Return an unauthorized error
    */
   public static ResponseContext unauthorized(
@@ -124,6 +136,11 @@
       return createErrorResponse(request.getAbdera(),401,reason);
   }
 
+  public static ResponseContext unauthorized(
+    RequestContext request) {
+      return unauthorized(request, "Unauthorized");
+  }
+  
   /**
    * Return an unauthorized error
    */
@@ -134,12 +151,21 @@
       return createErrorResponse(request.getAbdera(),403,reason);
   }
 
+  public static ResponseContext forbidden(
+    RequestContext request) {
+      return forbidden(request, "Forbidden");
+  }
+  
   /**
    * Return a 204 No Content response
    */
   public static ResponseContext nocontent(String reason) {
     return new EmptyResponseContext(204,reason);
   }
+
+  public static ResponseContext nocontent() {
+    return nocontent("Not Content");
+  }
   
   /**
    * Return a 404 not found error
@@ -151,6 +177,11 @@
     return createErrorResponse(request.getAbdera(),404,reason);
   }
 
+  public static ResponseContext notfound(
+    RequestContext request) {
+      return notfound(request, "Not Found");
+  }
+  
   /**
    * Return a 405 method not allowed error
    */
@@ -164,6 +195,17 @@
       resp.setAllow(methods);
       return resp;
   }
+  
+  public static ResponseContext notallowed( 
+      RequestContext request,
+      String... methods) {
+   return notallowed(request, "Method Not Allowed", methods); 
+  }
+  
+  public static ResponseContext notallowed(
+    RequestContext request) {
+      return notallowed(request, getDefaultMethods(request));
+  }
 
   /**
    * Return a 400 bad request error
@@ -175,6 +217,11 @@
       return createErrorResponse(request.getAbdera(),400,reason);
   }
 
+  public static ResponseContext badrequest(
+    RequestContext request) {
+      return badrequest(request, "Bad Request");
+  }
+  
   /**
    * Return a 409 conflict error
    */
@@ -185,6 +232,11 @@
     return createErrorResponse(request.getAbdera(),409,reason);
   }
 
+  public static ResponseContext conflict(
+    RequestContext request) {
+      return conflict(request, "Conflict");
+  }
+  
   /**
    * Return a service unavailable error
    */
@@ -195,6 +247,11 @@
       return createErrorResponse(request.getAbdera(),503,reason);
   }
 
+  public static ResponseContext unavailable(
+    RequestContext request) {
+      return unavailable(request, "Service Unavailable");
+  }
+  
   public static ResponseContext notmodified( 
     RequestContext request,
     String reason) {
@@ -202,6 +259,11 @@
       return new EmptyResponseContext(304,reason);
   }
 
+  public static ResponseContext notmodified(
+    RequestContext request) {
+      return notmodified(request, "Not Modified");
+  }
+  
   public static ResponseContext preconditionfailed(
     RequestContext request,
     String reason) {
@@ -209,6 +271,11 @@
       return createErrorResponse(request.getAbdera(),412,reason);
   }
 
+  public static ResponseContext preconditionfailed(
+    RequestContext request) {
+      return preconditionfailed(request, "Precondition Failed");
+  }
+  
   /**
    * Return a 415 media type not-supported error
    */
@@ -219,6 +286,11 @@
       return createErrorResponse(request.getAbdera(),415,reason);
   }
 
+  public static ResponseContext notsupported(
+    RequestContext request) {
+      return notsupported(request, "Media Type Not Supported");
+  }
+  
   /**
    * Return a 423 locked error
    */
@@ -229,6 +301,11 @@
       return createErrorResponse(request.getAbdera(),423,reason);
     }
 
+  public static ResponseContext locked(
+    RequestContext request) {
+      return locked(request, "Locked");
+  }
+  
   /**
    * Return a document
    */
@@ -456,4 +533,25 @@
     return writer;
   }
 
+  public static EntityTag calculateEntityTag(Base base) {
+    String id = null;
+    String modified = null;
+    if (base instanceof Entry) {
+      Entry entry = (Entry) base;
+      id = entry.getId().toString();
+      modified = 
+        AtomDate.format(
+          entry.getEdited() != null ?
+            entry.getEdited() :
+            entry.getUpdated()
+        );
+    } else if (base instanceof Feed) {
+      Feed feed = (Feed) base;
+      id = feed.getId().toString();
+      modified = AtomDate.format(feed.getUpdated());
+    } else if (base instanceof Document) {
+      return calculateEntityTag(((Document<?>)base).getRoot());
+    }
+    return EntityTag.generate(id, modified);      
+  }
 }

Modified: incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/ServiceContext.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/ServiceContext.java?rev=613783&r1=613782&r2=613783&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/ServiceContext.java
(original)
+++ incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/ServiceContext.java
Sun Jan 20 23:47:42 2008
@@ -34,7 +34,7 @@
   
   Resolver<Subject> getSubjectResolver();
   
-  Resolver<Target> getTargetResolver(String contextPath);
+  Resolver<Target> getTargetResolver();
   
   String getProperty(String name);
   

Added: incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/AbstractCombinedProvider.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/AbstractCombinedProvider.java?rev=613783&view=auto
==============================================================================
--- incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/AbstractCombinedProvider.java
(added)
+++ incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/AbstractCombinedProvider.java
Sun Jan 20 23:47:42 2008
@@ -0,0 +1,40 @@
+/*
+* 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 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;
+
+public abstract class AbstractCombinedProvider 
+  extends AbstractWorkspaceManagerProvider 
+  implements CollectionAdapter {
+  
+  public CollectionAdapter getCollectionAdapter(
+    RequestContext request) {
+      return this;
+  }
+  
+  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/impl/DefaultServiceContext.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/impl/DefaultServiceContext.java?rev=613783&r1=613782&r2=613783&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/impl/DefaultServiceContext.java
Sun Jan 20 23:47:42 2008
@@ -74,7 +74,7 @@
   }
 
   @SuppressWarnings("unchecked")
-  public Resolver<Target> getTargetResolver(String contextPath) {
+  public Resolver<Target> getTargetResolver() {
     if (targetResolver == null) {
       targetResolver = (Resolver<Target>) instance(
         ServiceManager.TARGET_RESOLVER, getDefaultTargetResolver());

Modified: 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/impl/EmptyResponseContext.java?rev=613783&r1=613782&r2=613783&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/impl/EmptyResponseContext.java
Sun Jan 20 23:47:42 2008
@@ -30,6 +30,7 @@
   }
   
   public EmptyResponseContext(int status, String text) {
+    setStatus(status);
     setStatusText(text);
   }
   

Modified: incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/servlet/ServletRequestContext.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/servlet/ServletRequestContext.java?rev=613783&r1=613782&r2=613783&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/servlet/ServletRequestContext.java
(original)
+++ incubator/abdera/java/branches/server_refactor/src/main/java/org/apache/abdera/protocol/server/servlet/ServletRequestContext.java
Sun Jan 20 23:47:42 2008
@@ -63,8 +63,7 @@
         subjectResolver.resolve(this) : null;
       
       Resolver<Target> targetResolver = 
-        context.getTargetResolver(
-          request.getContextPath());
+        context.getTargetResolver();
       target = (targetResolver != null) ? 
         targetResolver.resolve(this) : null;
   }

Modified: incubator/abdera/java/branches/server_refactor/src/test/java/org/apache/abdera/protocol/server/test/simple/SimpleServiceContext.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor/src/test/java/org/apache/abdera/protocol/server/test/simple/SimpleServiceContext.java?rev=613783&r1=613782&r2=613783&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor/src/test/java/org/apache/abdera/protocol/server/test/simple/SimpleServiceContext.java
(original)
+++ incubator/abdera/java/branches/server_refactor/src/test/java/org/apache/abdera/protocol/server/test/simple/SimpleServiceContext.java
Sun Jan 20 23:47:42 2008
@@ -17,14 +17,282 @@
 */
 package org.apache.abdera.protocol.server.test.simple;
 
+import java.io.IOException;
+import java.util.Date;
+
+import javax.activation.MimeType;
+
+import org.apache.abdera.Abdera;
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.i18n.text.UrlEncoding;
+import org.apache.abdera.model.Document;
+import org.apache.abdera.model.Entry;
+import org.apache.abdera.model.Feed;
+import org.apache.abdera.parser.ParseException;
+import org.apache.abdera.protocol.Resolver;
+import org.apache.abdera.protocol.server.Provider;
+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.TargetType;
+import org.apache.abdera.protocol.server.RequestContext.Scope;
+import org.apache.abdera.protocol.server.impl.AbstractCombinedProvider;
+import org.apache.abdera.protocol.server.impl.BaseResponseContext;
 import org.apache.abdera.protocol.server.impl.DefaultServiceContext;
+import org.apache.abdera.protocol.server.impl.RegexTargetResolver;
+import org.apache.abdera.protocol.server.impl.StreamWriterResponseContext;
+import org.apache.abdera.util.Constants;
+import org.apache.abdera.util.EntityTag;
+import org.apache.abdera.util.MimeTypeHelper;
+import org.apache.abdera.writer.StreamWriter;
 
+@SuppressWarnings("unchecked")
 public class SimpleServiceContext 
   extends DefaultServiceContext {
 
-  public SimpleServiceContext() {
-    this.defaultprovider = SimpleProvider.class.getName();
-    this.defaulttargetresolver = SimpleTargetResolver.class.getName();
+  public synchronized Provider getProvider(
+    RequestContext request) {
+      if (provider == null)
+        provider = new SimpleProvider();
+      return provider;
+  }
+
+  public Resolver<Target> getTargetResolver() {
+    return new RegexTargetResolver()
+      .setPattern("/atom(\\?[^#]*)?", TargetType.TYPE_SERVICE)
+      .setPattern("/atom/feed(\\?[^#]*)?", TargetType.TYPE_COLLECTION)
+      .setPattern("/atom/feed/([^/#?]+)(\\?[^#]*)?", TargetType.TYPE_ENTRY);
   }
+
+  public static class SimpleProvider 
+    extends AbstractCombinedProvider {
+      
+    private EntityTag service_etag = new EntityTag("simple");
+    private Document<Feed> feed_doc;
+    
+    private Document<Feed> init_feed_doc(
+      Abdera abdera, 
+      RequestContext context) {
+        Feed feed = 
+          (Feed) context.getAttribute(
+            Scope.SESSION, 
+            "feed");
+        if (feed == null) {
+          Factory factory = abdera.getFactory();
+          feed = factory.newFeed();
+          try {
+            feed.setId("tag:example.org,2006:feed");
+            feed.setTitle("Simple");
+            feed.setUpdated(new Date());
+            feed.addLink("");
+            feed.addLink("","self");
+            feed.addAuthor("Simple");
+          } catch (Exception e) {}
+          context.setAttribute(
+            Scope.SESSION, 
+            "feed", 
+            feed);
+        } 
+        return feed.getDocument();
+    }
+    
+    private synchronized Document<Feed> get_feed_doc(
+      RequestContext context) {
+        if (feed_doc == null)
+          feed_doc = 
+            init_feed_doc(
+              context.getAbdera(), 
+              context);
+      return feed_doc;
+    }
+  
+    
+    protected ResponseContext getServiceDocument(
+      RequestContext request) {
+        return 
+          new StreamWriterResponseContext(request.getAbdera()) {
+            protected void writeTo(
+              StreamWriter sw) 
+                throws IOException {
+              sw.startDocument()
+                .startService()
+                .startWorkspace()
+                .writeTitle("Simple")
+                .startCollection("atom/feed")
+                .writeTitle("Simple")
+                .writeAcceptsEntry()
+                .startCategories(false)
+                .endCategories()
+                .endCollection()
+                .endWorkspace()
+                .endService()
+                .endDocument();
+            }
+          }
+          .setStatus(200)
+          .setEntityTag(service_etag)
+          .setContentType(Constants.APP_MEDIA_TYPE);
+    }
   
+    public ResponseContext getFeed(
+      RequestContext request) {
+        Document<Feed> feed = get_feed_doc(request); 
+        return ProviderHelper.returnBase(
+          feed, 
+          200, 
+          feed.getRoot().getUpdated())
+            .setEntityTag(
+              ProviderHelper.calculateEntityTag(
+                feed.getRoot()));
+    }
+  
+    
+    public ResponseContext deleteEntry(
+      RequestContext request) {
+        Entry entry = getAbderaEntry(request);
+        if (entry != null)
+          entry.discard();
+        return ProviderHelper.nocontent();
+    }
+  
+    public ResponseContext getEntry(
+      RequestContext request) {
+        Entry entry = (Entry) getAbderaEntry(request);
+        if (entry != null) {
+          Feed feed = entry.getParentElement();
+          entry = (Entry) entry.clone();
+          entry.setSource(feed.getAsSource());
+          Document<Entry> entry_doc = entry.getDocument();
+          return 
+            ProviderHelper.returnBase(
+              entry_doc, 
+              200, 
+              entry.getEdited())
+                .setEntityTag(
+                  ProviderHelper.calculateEntityTag(
+                    entry));
+        } else {
+          return ProviderHelper.notfound(request);
+        }
+    }
+  
+    public ResponseContext postEntry(
+      RequestContext request) {
+        Abdera abdera = request.getAbdera();
+        try {
+          if (!checkMediaType(request))
+            return ProviderHelper.notsupported(request);
+          Document<Entry> entry_doc = 
+            (Document<Entry>) request.getDocument(
+              abdera.getParser()).clone();
+          if (entry_doc != null) {
+            Entry entry = entry_doc.getRoot();
+            if (!ProviderHelper.isValidEntry(entry))
+              return ProviderHelper.badrequest(request);
+            setEntryDetails(entry, abdera.getFactory().newUuidUri());
+            Feed feed = get_feed_doc(request).getRoot();
+            feed.insertEntry(entry);
+            feed.setUpdated(new Date());
+            BaseResponseContext rc = 
+              (BaseResponseContext) ProviderHelper.returnBase(
+                entry_doc, 201, entry.getEdited());
+            return 
+              rc.setLocation(
+                  ProviderHelper.resolveBase(request).resolve(
+                    entry.getEditLinkResolvedHref()).toString())
+                .setContentLocation(rc.getLocation().toString())
+                .setEntityTag(ProviderHelper.calculateEntityTag(entry));
+          } else {
+            return ProviderHelper.badrequest(request);
+          }
+        } catch (ParseException pe) {
+          return ProviderHelper.notsupported(request);
+        } catch (ClassCastException cce) {
+          return ProviderHelper.notsupported(request);
+        } catch (Exception e) {
+          return ProviderHelper.badrequest(request);
+      }
+    }
+  
+    private boolean checkMediaType(RequestContext request) {
+      MimeType contentType = request.getContentType();
+      String ctype = 
+        contentType != null ? 
+          contentType.toString() : 
+            null;
+      return ctype != null && MimeTypeHelper.isAtom(ctype);
+    }
+    
+    private void setEntryDetails(
+      Entry entry, 
+      String id) {
+        entry.setUpdated(new Date());
+        entry.setEdited(entry.getUpdated());
+        entry.getIdElement().setValue(id);
+        entry.addLink(
+          "atom/feed/" + entry.getId().toString(), 
+          "edit");
+    }
+    
+    public ResponseContext putEntry(
+      RequestContext request) {
+        Abdera abdera = request.getAbdera();
+        Entry orig_entry = getAbderaEntry(request);
+        if (orig_entry != null) {
+          try {
+            if (!checkMediaType(request))
+              return ProviderHelper.notsupported(
+                request);
+            Document<Entry> entry_doc = 
+              (Document<Entry>) request.getDocument(
+                abdera.getParser()).clone();
+            if (entry_doc != null) {
+              Entry entry = entry_doc.getRoot();
+              if (!entry.getId().equals(orig_entry.getId()))
+                return ProviderHelper.conflict(request);
+              if (!ProviderHelper.isValidEntry(entry))
+                return ProviderHelper.badrequest(request);
+              setEntryDetails(entry, orig_entry.getId().toString());
+              orig_entry.discard();
+              Feed feed = get_feed_doc(request).getRoot();
+              feed.insertEntry(entry);
+              feed.setUpdated(new Date());
+              return ProviderHelper.nocontent();
+            } else {
+              return ProviderHelper.badrequest(request);
+            }
+          } catch (ParseException pe) {
+            return ProviderHelper.notsupported(request);
+          } catch (ClassCastException cce) {
+            return ProviderHelper.notsupported(request);
+          } catch (Exception e) {
+            return ProviderHelper.badrequest(request);
+          }
+        } else {
+          return ProviderHelper.notfound(request);
+        }
+    }
+    
+    private Entry getAbderaEntry(
+      RequestContext request) {
+        try { 
+          return get_feed_doc( 
+            request)
+              .getRoot()
+              .getEntry(
+                getEntryID(request)); 
+        } catch (Exception e) {}
+        return null;
+    }
+    
+    private String getEntryID(
+      RequestContext request) {
+        if (request.getTarget().getType() != TargetType.TYPE_ENTRY) 
+          return null;
+        String[] segments = request.getUri().toString().split("/");
+        return UrlEncoding.decode(segments[segments.length-1]);
+    }
+    
+  }
 }

Modified: incubator/abdera/java/branches/server_refactor/src/test/java/org/apache/abdera/protocol/server/test/simple/SimpleTest.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/branches/server_refactor/src/test/java/org/apache/abdera/protocol/server/test/simple/SimpleTest.java?rev=613783&r1=613782&r2=613783&view=diff
==============================================================================
--- incubator/abdera/java/branches/server_refactor/src/test/java/org/apache/abdera/protocol/server/test/simple/SimpleTest.java
(original)
+++ incubator/abdera/java/branches/server_refactor/src/test/java/org/apache/abdera/protocol/server/test/simple/SimpleTest.java
Sun Jan 20 23:47:42 2008
@@ -53,10 +53,11 @@
     } catch (Exception e) {}
   }
   
-  private int count = 5;
+  private int count = 6;
   
   @Override protected void tearDown() throws Exception {
-    if (--count == 0) server.stop();
+    if (--count == 0) 
+      server.stop();
   }
   
   public void testGetService() {



Mime
View raw message