roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject svn commit: r378056 - /incubator/roller/trunk/sandbox/atomprotocol/src/org/roller/presentation/atomapi/RollerAtomHandler.java
Date Wed, 15 Feb 2006 18:49:25 GMT
Author: snoopdave
Date: Wed Feb 15 10:49:23 2006
New Revision: 378056

URL: http://svn.apache.org/viewcvs?rev=378056&view=rev
Log:
bug in Atom protcol next/prev links

Modified:
    incubator/roller/trunk/sandbox/atomprotocol/src/org/roller/presentation/atomapi/RollerAtomHandler.java

Modified: incubator/roller/trunk/sandbox/atomprotocol/src/org/roller/presentation/atomapi/RollerAtomHandler.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/sandbox/atomprotocol/src/org/roller/presentation/atomapi/RollerAtomHandler.java?rev=378056&r1=378055&r2=378056&view=diff
==============================================================================
--- incubator/roller/trunk/sandbox/atomprotocol/src/org/roller/presentation/atomapi/RollerAtomHandler.java
(original)
+++ incubator/roller/trunk/sandbox/atomprotocol/src/org/roller/presentation/atomapi/RollerAtomHandler.java
Wed Feb 15 10:49:23 2006
@@ -174,20 +174,18 @@
      */
     public Feed getCollection(String[] pathInfo) throws Exception {
         int start = 0;
-        int end = mMaxEntries;
         if (pathInfo.length > 2) {
             try { 
                 String s = pathInfo[2].trim();
                 start = Integer.parseInt(s);
-                if (start > 0) end = start + mMaxEntries;
             } catch (Throwable t) {
                 mLogger.warn("Unparsable range: " + pathInfo[2]);
             }
         }
         if (pathInfo.length > 0 && pathInfo[1].equals("entries")) {
-            return getCollectionOfEntries(pathInfo, start, end);
+            return getCollectionOfEntries(pathInfo, start, mMaxEntries);
         } else if (pathInfo.length > 0 && pathInfo[1].equals("resources")) {
-            return getCollectionOfResources(pathInfo, start, end);
+            return getCollectionOfResources(pathInfo, start, mMaxEntries);
         }
         throw new Exception("ERROR: bad URL in getCollection()");
     }
@@ -196,7 +194,7 @@
      * Helper method that returns collection of entries, called by getCollection().
      */
     public Feed getCollectionOfEntries(
-            String[] pathInfo, int start, int end) throws Exception {
+            String[] pathInfo, int start, int max) throws Exception {
         String handle = pathInfo[0];
         String absUrl = mRollerContext.getAbsoluteContextUrl(mRequest);
         WebsiteData website = mRoller.getUserManager().getWebsiteByHandle(handle);
@@ -210,7 +208,7 @@
                     null,              // status
                     "updateTime",      // sortby
                     start,             // offset (for range paging)
-                    end - start + 2);  // maxEntries
+                    max + 1);          // maxEntries
             Feed feed = new Feed();
             List atomEntries = new ArrayList();
             int count = 0;
@@ -218,8 +216,8 @@
                 WeblogEntryData rollerEntry = (WeblogEntryData)iter.next();
                 atomEntries.add(createAtomEntry(rollerEntry));
             }
-            if (count > start - end) { // add next link
-                int nextOffset = start + mMaxEntries; 
+            if (count > max) { // add next link
+                int nextOffset = start + max; 
                 String url = absUrl + "/app/" + website.getHandle() + "/entries/" + nextOffset;
                 Link nextLink = new Link();
                 nextLink.setRel("next");
@@ -229,7 +227,7 @@
                 feed.setOtherLinks(next);
             }
             if (start > 0) { // add previous link
-                int prevOffset = start > mMaxEntries ? start - mMaxEntries : 0;
+                int prevOffset = start > max ? start - max : 0;
                 String url = absUrl + "/app/" +website.getHandle() + "/entries/" + prevOffset;
                 Link prevLink = new Link();
                 prevLink.setRel("previous");
@@ -248,7 +246,7 @@
      * Helper method that returns collection of resources, called by getCollection().
      */
     public Feed getCollectionOfResources(
-            String[] pathInfo, int start, int end) throws Exception {
+            String[] pathInfo, int start, int max) throws Exception {
         String handle = pathInfo[0];
         String absUrl = mRollerContext.getAbsoluteContextUrl(mRequest);
         WebsiteData website = mRoller.getUserManager().getWebsiteByHandle(handle);
@@ -259,15 +257,14 @@
             List atomEntries = new ArrayList();
             int count = 0;
             if (files != null && start < files.length) {
-                end = (end > files.length) ? files.length : end;
-                for (int i=start; i<end; i++) {                   
+                for (int i=start; i<(start + max); i++) {                   
                     Entry entry = createAtomResourceEntry(website, files[i]);
                     atomEntries.add(entry);
                     count++;
                 }
             }
             if (start + count < files.length) { // add next link
-                int nextOffset = start + mMaxEntries; 
+                int nextOffset = start + max; 
                 String url = absUrl + "/app/" + website.getHandle() + "/resources/" + nextOffset;
                 Link nextLink = new Link();
                 nextLink.setRel("next");
@@ -277,7 +274,7 @@
                 feed.setOtherLinks(next);
             }
             if (start > 0) { // add previous link
-                int prevOffset = start > mMaxEntries ? start - mMaxEntries : 0;
+                int prevOffset = start > max ? start - max : 0;
                 String url = absUrl + "/app/" +website.getHandle() + "/resources/" + prevOffset;
                 Link prevLink = new Link();
                 prevLink.setRel("previous");



Mime
View raw message