aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Terry2013-07-12 11:20:31 (EDT)
committerGerrit Code Review @ Eclipse.org2013-07-22 10:26:37 (EDT)
commit2530c30aa8b5a2d0613193745362c0ad0529c11e (patch)
tree2e9fe3751e1d03cf16c878b13e952b79dbb88e16
parent9f5a25a4831330b9387ec07077fde47e3013d178 (diff)
downloadorg.eclipse.lyo.rio-2530c30aa8b5a2d0613193745362c0ad0529c11e.zip
org.eclipse.lyo.rio-2530c30aa8b5a2d0613193745362c0ad0529c11e.tar.gz
org.eclipse.lyo.rio-2530c30aa8b5a2d0613193745362c0ad0529c11e.tar.bz2
[412871] Update the TRS refrence application's base resource cutoff atrefs/changes/10/14510/4
server init time At startup the reference app calculates the latest change event in both the base and the change log and sets the cutoff to this change event about URI. Change-Id: I311853930f3843ea0f684c02fa76897700a66eab Signed-off-by: David Terry <dgterry@us.ibm.com>
-rw-r--r--org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/util/TRSObject.java34
1 files changed, 26 insertions, 8 deletions
diff --git a/org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/util/TRSObject.java b/org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/util/TRSObject.java
index 30f063f..c0fc02c 100644
--- a/org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/util/TRSObject.java
+++ b/org.eclipse.lyo.rio.trs/src/main/java/org/eclipse/lyo/rio/trs/util/TRSObject.java
@@ -177,16 +177,10 @@ public class TRSObject {
boolean pruned = false;
// Loop over all change events we found on disk and put them in
- // the treemap sorted by order. Prune events greater than
- // PruneTimeInDays (found in config.properties).
+ // the treemap sorted by order.
for (int i = 0; i < changeEvents.length; i++) {
ChangeEvent changeEvent = (ChangeEvent) changeEvents[i];
- if (isPrunningNecessary(changeEvent.getAbout())) {
- pruned = true;
- continue;
- }
-
sortedTree.put(changeEvent.getOrder(), changeEvent);
}
@@ -195,10 +189,34 @@ public class TRSObject {
// Insert the sorted in-memory change events into the log
for (int key : keys) {
ChangeEvent changeEvent = sortedTree.get(key);
+
+ // Prune events greater than
+ // PruneTimeInDays (found in config.properties). Never
+ // prune the final event since that means the change log
+ // will be empty and the cutoff event will be nil. which by
+ // the spec means the change log must have ALL events since
+ // the beginning of time.
+ if ((key != sortedTree.lastKey())
+ && isPrunningNecessary(changeEvent.getAbout())) {
+ pruned = true;
+ continue;
+ }
+
+ change_events.add(changeEvent);
insertEventToPagedChangeLog(changeEvent, changeEvent.getChanged());
}
- change_events.addAll(sortedTree.values());
+ // At init time, when this method is called, the base resource
+ // contains a record of all resources. According to the spec:
+ // The first page of a Base MUST include a trs:cutoffEvent
+ // property, whose value is the URI of the most recent Change
+ // Event in the corresponding Change Log that is already
+ // reflected in the Base. So set the cutoff to the URI of the
+ // last event in the sorted tree
+ synchronized (trs_base_map) {
+ for (Base base : trs_base_map.values())
+ base.setCutoffEvent(sortedTree.lastEntry().getValue().getAbout());
+ }
// If pruning took place persist the new list of change events
// to disk so we don't have to prune them again.