ensured that hash binding vorbaIds is passed to client document object for vorba...
[vamsas.git] / src / org / vamsas / test / simpleclient / ArchiveClient.java
index f0b2e16..c681fe0 100644 (file)
@@ -110,9 +110,9 @@ public class ArchiveClient extends IdFactory {
       if (doclock==null)
         return null;
       else {
-        doclock = vsess.getLock(doclock);
-        VamsasArchiveReader varc = new VamsasArchiveReader(vsess.getVamsasFile());
-        return _getReadonly(varc);
+        return getUpdateable(vsess.getLock(doclock));
+        /*VamsasArchiveReader varc = new VamsasArchiveReader(vsess.getVamsasFile());
+        return _getReadonly(varc);*/
       }
     } catch (Exception e) {
       log.error("Whilst watching file "+vsess.getVamsasFile(), e);
@@ -175,12 +175,15 @@ public class ArchiveClient extends IdFactory {
   }
   
   public ClientDoc getUpdateable() {
+    return getUpdateable(null);
+  }
+  public ClientDoc getUpdateable(org.vamsas.client.simpleclient.Lock lock) {
+    getVorbaIdHash().clear();
     valid();
     try {
       // patiently wait for a lock on the document.
       long tries=5000;
-      org.vamsas.client.simpleclient.Lock lock;
-      while (((lock=vsess.getLock())==null || !lock.isLocked()) && --tries>0) {
+      while (lock==null && ((lock=vsess.getLock())==null || !lock.isLocked()) && --tries>0) {
 //        Thread.sleep(1);
         log.debug("Trying to get a document lock for the "+tries+"'th time.");
       }
@@ -227,6 +230,7 @@ public class ArchiveClient extends IdFactory {
       cdoc.updateDocumentRoots();
       cdoc.iohandler.putVamsasDocument(cdoc.doc);
       cdoc.iohandler.closeArchive();
+      this.extantids.clear();// we forget our ids after we close the document.
       cdoc.iohandler=null;
       cdoc = null;
       vsess.unLock();
@@ -263,7 +267,7 @@ public class ArchiveClient extends IdFactory {
       int u=5;
       while (--u>0) {
         System.out.println("Watch for more... ("+u+" left)");
-        ClientDoc ucdoc = client.watch(50000);
+        ClientDoc ucdoc = client.watch(0000);
         if (ucdoc!=null) {
           System.out.println("****\nUpdate detected at "+new Date());
           ArchiveReports.reportDocument(ucdoc.doc, ucdoc.getReader(), true, System.out);