* verify that newr version is really an intact version of the
* @param newVersion (may be modified)
* @param oldVersion
+ * @param modflag
* @return true if newVersion is a valid root that preserves original references
*/
- private boolean isValidUpdate(VAMSAS newVersion, final VAMSAS oldVersion) {
+ private boolean isValidUpdate(VAMSAS newVersion, final VAMSAS oldVersion, ClientDocument modflag) {
// ideal - this cascades down the two structures, ensuring that all ID'd objects in one are present in the other.
if (oldVersion==newVersion) {
// may be a virgin root element.
if (!newVersion.isRegistered())
- _registerObject(newVersion); // TODO: check - this call hasn't been tested.
- // Should retrieve original version and compare - unless local hashes can be used to determine if resultSet has been truncated.
+ {
+ _registerObject(newVersion); // TODO: check - this call hasn't been tested. (seems to work now)
+ modflag.isModified=true;
+ }
+ // TODO: Should attempt to repair document if client app has deleted/broken bits of it
+ if (oldVersion.is__stored_in_document()) {
+ // retrieve compare hashCodes to detect update.
+ if (oldVersion.get__last_hash()!=oldVersion.hashCode())
+ {
+ log.debug("Modified hashcode for vamsas root "+oldVersion.getVorbaId());
+ modflag.isModified = true;
+ } else {
+ log.debug("Unmodified vamsas root "+oldVersion.getVorbaId());
+ }
+ }
// just do internal validation for moment.
try {
if (SimpleClientConfig.validateUpdatedRoots())
} else {
// redundant ? if (oldVersion.is__stored_in_document())
if (!newVersion.isRegistered())
+ {
_registerObject(newVersion);
+ modflag.isModified=true;
+ }
try {
if (SimpleClientConfig.validateMergedRoots())
+ {
newVersion.validate();
+ }
+ modflag.isModified=true;
return true;
}
catch (Exception e)
for (int i=0,j=original.length; i<j; i++) {
int k = _contains(original[i], newr);
if (k>-1) {
- if (isValidUpdate(newr[k], original[i])) {
- modified=true;
+ if (isValidUpdate(newr[k], original[i], modflag)) {
+ // set by isValidUpdate if the hashcodes were really different from last store
rts.add(newr[k]);
newr[k]=null;
} else {
for (int i=0,j=newr.length; i<j; i++) {
if (newr[i]!=null) {
rts.add(newr[i]);
- modified=true;
+ modflag.isModified=true;
}
}
newr = new VAMSAS[rts.size()];
for (int i=0,j=rts.size(); i<j; i++)
newr[i] = (VAMSAS) rts.get(i);
- if (modflag!=null)
- modflag.isModified = modified;
return newr;
}