abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dand...@apache.org
Subject svn commit: r608881 - in /incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server: CollectionProvider.java impl/AbstractCollectionProvider.java
Date Fri, 04 Jan 2008 15:11:12 GMT
Author: dandiep
Date: Fri Jan  4 07:11:12 2008
New Revision: 608881

URL: http://svn.apache.org/viewvc?rev=608881&view=rev
Log:
Make getFeed() more easily overridable.

Modified:
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/CollectionProvider.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractCollectionProvider.java

Modified: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/CollectionProvider.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/CollectionProvider.java?rev=608881&r1=608880&r2=608881&view=diff
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/CollectionProvider.java
(original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/CollectionProvider.java
Fri Jan  4 07:11:12 2008
@@ -35,7 +35,7 @@
   
   String getTitle(RequestContext request);
 
-  ResponseContext getFeed(RequestContext request, Feed feed);
+  ResponseContext getFeed(Feed feed, RequestContext request);
 
   ResponseContext createEntry(RequestContext request);
 

Modified: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractCollectionProvider.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractCollectionProvider.java?rev=608881&r1=608880&r2=608881&view=diff
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractCollectionProvider.java
(original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractCollectionProvider.java
Fri Jan  4 07:11:12 2008
@@ -133,7 +133,7 @@
   }
 
   protected ResponseContext buildGetEntryResponse(RequestContext request, Entry entry) {
-    Feed feed = createFeed(request.getAbdera(), request);
+    Feed feed = createFeedBase(request);
     entry.setSource(feed.getAsSource());
     Document<Entry> entry_doc = entry.getDocument();
     AbstractResponseContext rc = new BaseResponseContext<Document<Entry>>(entry_doc);
@@ -144,39 +144,41 @@
   public abstract T getEntry(String resourceName, RequestContext request) throws ResponseContextException;
 
   public ResponseContext getFeed(RequestContext request) {
-    Abdera abdera = request.getAbdera();
-    Feed feed = createFeed(abdera, request);
+    Feed feed = createFeedBase(request);
     
-    return getFeed(request, feed);
+    return getFeed(feed, request);
   }
   
-  public ResponseContext getFeed(RequestContext request, Feed feed) {
+  public ResponseContext getFeed(Feed feed, RequestContext request) {
+    try {
+      addFeedDetails(feed, request);
+      
+      return buildGetFeedResponse(feed);
+    } catch (ResponseContextException e) {
+      return createErrorResponse(e);
+    }
+  }
+
+  protected void addFeedDetails(Feed feed, RequestContext request) throws ResponseContextException
{
     feed.setUpdated(new Date());
 
     IRI baseIri = resolveBase(request);
     IRI entryIri = getEntryBaseFromFeedIRI(baseIri);
     
-    try {
-      Iterable<T> entries = getEntries(request);
-      if (entries != null) {
-        for (T entryObj : entries) {
-          Entry e = feed.addEntry();
-    
-          addEntryDetails(request, e, entryIri, entryObj);
-
-          if (isMediaEntry(entryObj)) {
-            addMediaContent(entryIri, e, entryObj);
-          } else {
-            addContent(e, entryObj, request);
-          }
+    Iterable<T> entries = getEntries(request);
+    if (entries != null) {
+      for (T entryObj : entries) {
+        Entry e = feed.addEntry();
+  
+        addEntryDetails(request, e, entryIri, entryObj);
+
+        if (isMediaEntry(entryObj)) {
+          addMediaContent(entryIri, e, entryObj);
+        } else {
+          addContent(e, entryObj, request);
         }
       }
-  
-      return buildGetFeedResponse(feed);
-    } catch (ResponseContextException e) {
-      return createErrorResponse(e);
     }
-    
   }
 
   protected ResponseContext buildGetFeedResponse(Feed feed) {
@@ -372,8 +374,9 @@
     }
     return EntityTag.generate(id, modified);
   }
-  protected Feed createFeed(Abdera abdera, RequestContext request) {
-    Factory factory = abdera.getFactory();
+  
+  protected Feed createFeedBase(RequestContext request) {
+    Factory factory = request.getAbdera().getFactory();
     Feed feed = factory.newFeed();
     try {
       feed.setId(getId());



Mime
View raw message