* internal reference to single copy of Document Roots array
*/
private VAMSAS[] _VamsasRoots=null;
+ /**
+ * set if the client has corrupted the Vamsas Document structure somehow.
+ * if this is set the document will never be written back to the session unless the corruption is fixed.
+ */
+ private boolean invalidModification=false;
protected void updateDocumentRoots() {
if (doc==null) {
}
// just do internal validation for moment.
try {
- if (SimpleClientConfig.validateUpdatedRoots())
+ if (getSimpleClientConfig().validateUpdatedRoots())
+ {
newVersion.validate();
+ }
return true;
}
catch (Exception e)
{
log.error("Validation Exception for new vamsas root :"+newVersion.getVorbaId(),e);
+ modflag.invalidModification=true;
}
return false;
} else {
modflag.isModified=true;
}
try {
- if (SimpleClientConfig.validateMergedRoots())
+ if (getSimpleClientConfig().validateMergedRoots())
{
newVersion.validate();
}
}
}*/
}
+ private SimpleClientConfig getSimpleClientConfig() {
+ return sclient.getSimpleClientConfig();
+}
/**
* merge old and new root vectors
* @param newr This array may be written to
*/
private VAMSAS[] _combineRoots(VAMSAS[] newr, final VAMSAS[] original, ClientDocument modflag) {
Vector rts = new Vector();
- boolean modified=false;
for (int i=0,j=original.length; i<j; i++) {
int k = _contains(original[i], newr);
if (k>-1) {
// TODO: WALK through the document objects calling the update mechanism for each one, or just pass this vector back to client ?return updatedObjects;
return null;
}
+ /**
+ * if this is set the document will never be written back to the session unless the corruption is fixed.
+ * @return the invalidModification
+ */
+ public boolean isInvalidModification() {
+ return invalidModification;
+ }
+ /**
+ * set if the client has corrupted the Vamsas Document structure somehow.
+ * if this is set the document will never be written back to the session unless the corruption is fixed.
+ * @param invalidModification the invalidModification to set
+ */
+ public void setInvalidModification(boolean invalidModification) {
+ this.invalidModification = invalidModification;
+ }
}
if (evgen.isDocumentWatchEnabled())
throw new Error("Probable Client Error (did you remember to call SimpleClient.updateDocument(clientdoc) at the end of the document update handler?) - or Library Bug : Document watcher still enabled whilst ClientDocument instance exists.");
-
- if (!cdocument.isModified()) {
- // client document is silently got rid of, with no session update events.
- if (log.isDebugEnabled())
- log.debug("updateDocument for "+session.getSessionUrn()+" with unmodified IClientDocument (skipping the write)");
+ if (cdocument.isInvalidModification())
+ {
+ log.info("Client has corrupted the vamsas document. It will not be written back to the session - sorry.");
+ // TODO: modify updateDocument signature: We should really raise an exception here to tell the client that it broke the datamodel.
} else {
- writeSessionDocument();
+ // actually try to write - if necessary.
+ if (!cdocument.isModified()) {
+ // client document is silently got rid of, with no session update events.
+ if (log.isDebugEnabled())
+ log.debug("updateDocument for "+session.getSessionUrn()+" with unmodified IClientDocument (skipping the write)");
+ } else {
+ writeSessionDocument();
+ }
}
+ // release locks, reset and start to receive events again
tidyAwaySessionDocumentState();
}
/**
protected Lock getClientLock() {
return activeClientFilelock;
}
+ SimpleClientConfig _config = null;
+ public SimpleClientConfig getSimpleClientConfig() {
+ if (_config==null)
+ {
+ _config = new SimpleClientConfig();
+ }
+ return _config;
+ }
}
*\r
*/\r
public class SimpleClientConfig {\r
-\r
+ public boolean _validatemergedroots=false;\r
+ public boolean _validateupdatedroots=false;\r
/**\r
* New VAMSAS roots added (merged) into the document\r
* will be validated before actually being added. \r
* @return\r
*/\r
- public static boolean validateMergedRoots() {\r
- return false;\r
+ public boolean validateMergedRoots() {\r
+ return _validatemergedroots;\r
}\r
\r
/**\r
* be written. \r
* @return\r
*/\r
- public static boolean validateUpdatedRoots() {\r
- return false;\r
+ public boolean validateUpdatedRoots() {\r
+ return _validateupdatedroots;\r
}\r
-\r
+ \r
}\r