Author: suat Date: Mon Sep 17 10:14:52 2012 New Revision: 1386539 URL: http://svn.apache.org/viewvc?rev=1386539&view=rev Log: STANBOL-498: -Correction on setting to and from parameters of the ChangeSet
Modified: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/revisionmanager/src/main/java/org/apache/stanbol/contenthub/revisionmanager/DerbyRevisionManager.java Modified: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/revisionmanager/src/main/java/org/apache/stanbol/contenthub/revisionmanager/DerbyRevisionManager.java URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/revisionmanager/src/main/java/org/apache/stanbol/contenthub/revisionmanager/DerbyRevisionManager.java?rev=1386539&r1=1386538&r2=1386539&view=diff ============================================================================== --- incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/revisionmanager/src/main/java/org/apache/stanbol/contenthub/revisionmanager/DerbyRevisionManager.java (original) +++ incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/revisionmanager/src/main/java/org/apache/stanbol/contenthub/revisionmanager/DerbyRevisionManager.java Mon Sep 17 10:14:52 2012 @@ -144,6 +144,9 @@ public class DerbyRevisionManager implem */ @Override public ChangeSet getChanges(String storeID, long revision, int batchSize) throws RevisionManagerException { + if (batchSize <= 0) { + throw new IllegalArgumentException("Batch size must be larger than 0"); + } // get connection Connection con = getConnection(); @@ -167,6 +170,7 @@ public class DerbyRevisionManager implem new ArrayList<String>()); } + from = revisionBeans.get(0).getRevision(); // if the number of changes >= batchsize + 1 if (revisionBeans.size() == (batchSize + 1)) { log.debug("There are changes more than the given batch size: {}", batchSize); @@ -181,24 +185,24 @@ public class DerbyRevisionManager implem for (int i = 0; i < revisionBeans.size() - 1; i++) { changedUris.add(revisionBeans.get(i).getID()); } + to = revisionBeans.get(revisionBeans.size() - 2).getRevision(); log.info("Changes have been fetched for the initial batch size"); } else { - log.info("There are {} changes in total", revisionBeans.size()); for (RevisionBean rb : revisionBeans) { changedUris.add(rb.getID()); } + to = revisionBeans.get(revisionBeans.size() - 1).getRevision(); + log.info("There are {} changes in total", revisionBeans.size()); } - to = revisionBeans.get(batchSize).getRevision(); - from = revisionBeans.get(0).getRevision(); - if (moreChanges) { revisionBeans = dbManager.getRevisions(revisionTableName, revision, lastRowRevision, Integer.MAX_VALUE, batchSize); for (RevisionBean rb : revisionBeans) { changedUris.add(rb.getID()); } - log.info("Changes exceeding the batch size have been fetched. Total fetched changes: {}", changedUris.size()); + log.info("Changes exceeding the batch size have been fetched. Total fetched changes: {}", + changedUris.size()); } long epoch = getEpoch(storeID);