made SimpleClientConfig externally configurable and added mechanism to prevent invali...
[vamsas.git] / src / uk / ac / vamsas / client / simpleclient / SimpleClient.java
index 43ec15d..d13fe24 100644 (file)
@@ -308,14 +308,21 @@ public class SimpleClient implements IClient {
     
     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(); 
   }
   /**
@@ -581,5 +588,13 @@ public class SimpleClient implements IClient {
   protected Lock getClientLock() {
     return activeClientFilelock;
   }
+  SimpleClientConfig _config = null;
+  public SimpleClientConfig getSimpleClientConfig() {
+    if (_config==null)
+    {
+      _config = new SimpleClientConfig();
+    }
+    return _config;
+  }
 
 }