String newLocalRevisionId = String.valueOf(newLocalRevision);
String lastLocalRevisionId = lastLocalRevision != -1 ? String.valueOf(lastLocalRevision) : "FIRST";
FeatureDiffReader localChanges = fs.getDifferences(lastLocalRevisionId,
newLocalRevisionId, ff.id(changedFids), null);
while (localChanges.hasNext()) {
FeatureDiff fd = localChanges.next();
FeatureId diffFeatureId = ff.featureId(fd.getID());
if (fd.getState() == FeatureDiff.INSERTED) {
throw new GSSException(
"A new locally inserted feature has the same "
+ "id as a modified feature coming from Central, this is impossible, "
+ "there is either a bug in ID generation or someone manually tampered with it!");
} else if (fd.getState() == FeatureDiff.DELETED) {
if (deletedFids.contains(diffFeatureId)) {
saveCleanMergeMarker(fs, conflicts, lastLocalRevisionId,
newLocalRevision, fd.getID());
} else {
handleDeletionConflict(fs, conflicts, lastLocalRevisionId,
newLocalRevision, fd.getID());
}
} else {
if (updatedFids.contains(diffFeatureId)) {
if (isSameUpdate(fd, findUpdate(fd.getID(), updates))) {
saveCleanMergeMarker(fs, conflicts, lastLocalRevisionId,
newLocalRevision, fd.getID());
} else {
handleUpdateConflict(fs, conflicts, lastLocalRevisionId,
newLocalRevision, fd.getID());
}
} else {
handleUpdateConflict(fs, conflicts, lastLocalRevisionId,
newLocalRevision, fd.getID());
}
}
}
localChanges.close();
}