-/**
- *
- */
-package uk.ac.vamsas.test.simpleclient;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Date;
-import java.util.Hashtable;
-import java.util.Vector;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.exolab.castor.xml.MarshalException;
-import org.exolab.castor.xml.ValidationException;
-
-import uk.ac.vamsas.client.AppDataOutputStream;
-import uk.ac.vamsas.client.ClientHandle;
-import uk.ac.vamsas.client.IVorbaIdFactory;
-import uk.ac.vamsas.client.SessionHandle;
-import uk.ac.vamsas.client.UserHandle;
-import uk.ac.vamsas.client.Vobject;
-import uk.ac.vamsas.client.VorbaId;
-import uk.ac.vamsas.client.simpleclient.FileWatcher;
-import uk.ac.vamsas.client.simpleclient.IdFactory;
-import uk.ac.vamsas.client.simpleclient.SessionFile;
-import uk.ac.vamsas.client.simpleclient.SimpleDocBinding;
-import uk.ac.vamsas.client.simpleclient.SimpleDocument;
-import uk.ac.vamsas.client.simpleclient.VamsasArchive;
-import uk.ac.vamsas.client.simpleclient.VamsasArchiveReader;
-import uk.ac.vamsas.client.simpleclient.VamsasFile;
-import uk.ac.vamsas.objects.core.AppData;
-import uk.ac.vamsas.objects.core.ApplicationData;
-import uk.ac.vamsas.objects.core.User;
-import uk.ac.vamsas.objects.core.VamsasDocument;
-import uk.ac.vamsas.objects.utils.AppDataReference;
-import uk.ac.vamsas.objects.utils.DocumentStuff;
-import uk.ac.vamsas.objects.utils.ProvenanceStuff;
-import uk.ac.vamsas.objects.utils.SeqSet;
-import uk.ac.vamsas.objects.utils.document.VersionEntries;
-import uk.ac.vamsas.test.objects.Core;
-
-/**
- * @author jimp
- * test the VamsasFile routines for watching, reading and updating a vamsas document jar file.
- * simple document access base class.
- */
-public class ArchiveClient extends IdFactory {
-
- private Log log = LogFactory.getLog(ArchiveClient.class);
- // protected UserHandle user=null;
- // protected ClientHandle me = new ClientHandle("ArchiveClient","0.01");
- VamsasFile vsess;
-
- /**
- * @param user
- * @param vsess
- */
- public ArchiveClient(UserHandle user, VamsasFile vsess) {
- super(new SessionHandle("vamsasfile://"+vsess.getVamsasFile()), new ClientHandle("ArchiveClient","0.01"), user);
- this.vsess = vsess;
- valid();
- }
- private void _openVsess(File vsess) {
- try {
- this.vsess = new VamsasFile(vsess);
- }
- catch (Exception e) {
- log.error("Couldn't open session for file "+vsess,e);
- this.vsess = null;
- }
- }
- public ArchiveClient(String username, String organization, File vsess) {
- super(new SessionHandle("vamsasfile://"+vsess), new ClientHandle("ArchiveClient","0.01"), new UserHandle(username, organization));
- _openVsess(vsess);
- valid();
- }
- public ArchiveClient(String username, String organization, String clientName, String clientVersion, File vsess) {
- super(new SessionHandle("vamsasfile://"+vsess), new ClientHandle(clientName, clientVersion), new UserHandle(username, organization));
- _openVsess(vsess);
- valid();
- }
- public void valid() {
- if (vsess==null)
- throw new Error("ArchiveClient instance is invalid!.");
- }
- /**
- * set this to false if watch loop should end immediately
- */
- protected boolean watchForChange=true;
- public static int WATCH_SLEEP=300;
- /**
- * watch the document file for updates.
- * @param time - length of time to watch for.
- * @return read only IO interface for session document.
- */
- public ClientDoc watch(long time) {
- valid();
- vsess.unLock(); // doh.
- FileWatcher watcher = new FileWatcher(vsess.getVamsasFile());
- // watcher.setState();
- watchForChange=true;
- long endtime=System.currentTimeMillis()+time;
- try {
- uk.ac.vamsas.client.simpleclient.Lock doclock;
- do {
- doclock=watcher.getChangedState();
- if (doclock==null)
- Thread.sleep(WATCH_SLEEP);
- } while (watchForChange && doclock==null && (time==0 || endtime>System.currentTimeMillis())); // tuning.
- if (doclock==null)
- return null;
- else {
- 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);
- }
- return null;
- }
-
- // from ClientDocument.getClientAppdata
- private AppData[] getAppData(VamsasDocument doc) {
- // TODO: codefest - not yet tested or merged in to SimpleClient
- if (doc==null) {
- log.debug("extractAppData called for null document object");
- return null;
- }
- AppData appsGlobal=null, usersData=null;
- Vector apldataset = AppDataReference.getUserandApplicationsData(
- doc, this.getUserHandle(), this.getClientHandle());
- if (apldataset!=null) {
- if (apldataset.size()>0) {
- AppData clientdat = (AppData) apldataset.get(0);
- if (clientdat instanceof ApplicationData) {
- appsGlobal = (ApplicationData) clientdat;
- if (apldataset.size()>1) {
- clientdat = (AppData) apldataset.get(1);
- if (clientdat instanceof User) {
- usersData = (User) clientdat;
- }
- if (apldataset.size()>2)
- log.info("Ignoring additional ("+(apldataset.size()-2)+") AppDatas returned by document appdata query.");
- }
- } else {
- log.warn("Unexpected entry in AppDataReference query: id="+clientdat.getVorbaId()+" type="+clientdat.getClass().getName());
- }
- apldataset.removeAllElements(); // destroy references.
- }
- }
- return new AppData[] { appsGlobal, usersData};
- }
-
- protected ClientDoc _getReadonly(VamsasArchiveReader vreader) throws IOException, ValidationException, MarshalException {
- valid();
- if (vreader!=null) {
- SimpleDocBinding docb = new SimpleDocBinding();
- docb.setVorba(this);
- VamsasDocument d;
- d = docb.getVamsasDocument(vreader);
-
- if (d!=null) {
- ClientDoc creader = new ClientDoc(d, null, vreader, getClientHandle().getClientUrn(), getProvenanceUser(), getVorbaIdHash());
- return creader;
- }
- }
- return null;
- }
- /**
- * from SimpleClient
- * @return user field for a provenance entry
- */
- protected String getProvenanceUser() {
- return new String(getUserHandle().getFullName()+" ["+getClientHandle().getClientUrn()+"]");
- }
-
- public ClientDoc getUpdateable() {
- return getUpdateable(null);
- }
- public ClientDoc getUpdateable(uk.ac.vamsas.client.simpleclient.Lock lock) {
- getVorbaIdHash().clear();
- valid();
- try {
- // patiently wait for a lock on the document.
- long tries=5000;
- 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.");
- }
- VamsasArchive varc = new VamsasArchive(vsess, true, false); // read archive, write as vamsasDocument, don't erase original contents.
- varc.setVorba(this);
- VamsasDocument d = varc.getVamsasDocument(getProvenanceUser(), "Created new document.", VersionEntries.latestVersion()); // VAMSAS: provenance user and client combined
-
- if (d==null) {
- log.warn("Backing out from opening a VamsasArchive writable IO session");
- varc.cancelArchive();
- return null;
- }
- ClientDoc cdoc = new ClientDoc(d, varc, varc.getOriginalArchiveReader(), getClientHandle().getClientUrn(), getProvenanceUser(), getVorbaIdHash());
- return cdoc;
- // do appHandle?
- } catch (Exception e) {
- log.error("Failed to get Updateable version of "+vsess.getVamsasFile(), e);
- }
- return null;
- }
- /**
- * trust client to not do anything stupid to the document roots which will now be written to the archive.
- * @param cdoc
- * @return true if write was a success.
- */
- public boolean doUpdate(ClientDoc cdoc) {
- valid();
- if (cdoc==null) {
- log.warn("Invalid ClientDoc passed to uk.ac.vamsas.test.simpleclient.doUpdate()");
- return false;
- }
- if (cdoc.iohandler==null) {
- log.warn("Read only ClientDoc object passed to uk.ac.vamsas.test.simpleclient.doUpdate()");
- return false;
- }
- if (cdoc.iohandler.getVorba()!=this) {
- log.error("Mismatch between ClientDoc instances and ArchiveClient instances!");
- return false;
- }
- try {
- // do any appDatas first.
- if (cdoc.iohandler.transferRemainingAppDatas())
- log.debug("Remaining appdatas were transfered.");
- 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();
- } catch (Exception e) {
- log.warn("While updating archive in "+vsess.getVamsasFile(),e);
- return false;
- }
- return true;
- }
- /**
- * @param args
- */
- public static void usage() {
- throw new Error("Usage: Username Organization VamsasFile [command,args]*");
- }
- public static void main(String[] args) {
- // really simple.
- if (args.length<3)
- usage();
-
- ArchiveClient client = new ArchiveClient(args[0],args[1], new File(args[2]));
- ClientDoc cdoc=null;
- // sanity test.
- try {
- cdoc = client.getUpdateable();
- // ArchiveReports.reportDocument(cdoc.doc, cdoc.getReader(), true, System.out);
- System.out.println("Report Roots :");
- ArchiveReports.rootReport(cdoc.getVamsasRoots(), true, System.out);
- cdoc.addVamsasRoot(Core.getDemoVamsas());
- System.out.println("Doing update.");
- client.doUpdate(cdoc);
- cdoc.closeDoc();
- cdoc = null;
- int u=5;
- while (--u>0) {
- System.out.println("Watch for more... ("+u+" left)");
- 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);
- ucdoc.closeDoc();
- ucdoc=null;
- } else {
- System.out.println("!!!! Null document update detected at "+new Date());
- }
- }
- }
- catch (Exception e) {
- client.log.error("Broken!", e);
- }
- System.out.println("Finished at "+new Date());
- }
- public uk.ac.vamsas.client.Vobject getObject(VorbaId id) {
- Hashtable idhash = this.getVorbaIdHash();
- if (idhash!=null && idhash.containsKey(id))
- return (Vobject) idhash.get(id);
- return null;
- }
-}
+/*\r
+ * This file is part of the Vamsas Client version 0.1. \r
+ * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, \r
+ * Andrew Waterhouse and Dominik Lindner.\r
+ * \r
+ * Earlier versions have also been incorporated into Jalview version 2.4 \r
+ * since 2008, and TOPALi version 2 since 2007.\r
+ * \r
+ * The Vamsas Client is free software: you can redistribute it and/or modify\r
+ * it under the terms of the GNU Lesser General Public License as published by\r
+ * the Free Software Foundation, either version 3 of the License, or\r
+ * (at your option) any later version.\r
+ * \r
+ * The Vamsas Client is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU Lesser General Public License for more details.\r
+ * \r
+ * You should have received a copy of the GNU Lesser General Public License\r
+ * along with the Vamsas Client. If not, see <http://www.gnu.org/licenses/>.\r
+ */\r
+package uk.ac.vamsas.test.simpleclient;\r
+\r
+import java.io.File;\r
+import java.io.IOException;\r
+import java.util.Date;\r
+import java.util.Hashtable;\r
+import java.util.Vector;\r
+\r
+import org.apache.commons.logging.Log;\r
+import org.apache.commons.logging.LogFactory;\r
+import org.exolab.castor.xml.MarshalException;\r
+import org.exolab.castor.xml.ValidationException;\r
+\r
+import uk.ac.vamsas.client.AppDataOutputStream;\r
+import uk.ac.vamsas.client.ClientHandle;\r
+import uk.ac.vamsas.client.IVorbaIdFactory;\r
+import uk.ac.vamsas.client.SessionHandle;\r
+import uk.ac.vamsas.client.UserHandle;\r
+import uk.ac.vamsas.client.Vobject;\r
+import uk.ac.vamsas.client.VorbaId;\r
+import uk.ac.vamsas.client.simpleclient.FileWatcher;\r
+import uk.ac.vamsas.client.simpleclient.IdFactory;\r
+import uk.ac.vamsas.client.simpleclient.SessionFile;\r
+import uk.ac.vamsas.client.simpleclient.SimpleDocBinding;\r
+import uk.ac.vamsas.client.simpleclient.SimpleDocument;\r
+import uk.ac.vamsas.client.simpleclient.VamsasArchive;\r
+import uk.ac.vamsas.client.simpleclient.VamsasArchiveReader;\r
+import uk.ac.vamsas.client.simpleclient.VamsasFile;\r
+import uk.ac.vamsas.objects.core.AppData;\r
+import uk.ac.vamsas.objects.core.ApplicationData;\r
+import uk.ac.vamsas.objects.core.User;\r
+import uk.ac.vamsas.objects.core.VamsasDocument;\r
+import uk.ac.vamsas.objects.utils.AppDataReference;\r
+import uk.ac.vamsas.objects.utils.DocumentStuff;\r
+import uk.ac.vamsas.objects.utils.ProvenanceStuff;\r
+import uk.ac.vamsas.objects.utils.SeqSet;\r
+import uk.ac.vamsas.objects.utils.document.VersionEntries;\r
+import uk.ac.vamsas.test.objects.Core;\r
+\r
+/**\r
+ * @author jimp test the VamsasFile routines for watching, reading and updating\r
+ * a vamsas document jar file. simple document access base class.\r
+ */\r
+public class ArchiveClient extends IdFactory {\r
+\r
+ private Log log = LogFactory.getLog(ArchiveClient.class);\r
+\r
+ // protected UserHandle user=null;\r
+ // protected ClientHandle me = new ClientHandle("ArchiveClient","0.01");\r
+ VamsasFile vsess;\r
+\r
+ /**\r
+ * @param user\r
+ * @param vsess\r
+ */\r
+ public ArchiveClient(UserHandle user, VamsasFile vsess) {\r
+ super(new SessionHandle("vamsasfile://" + vsess.getVamsasFile()),\r
+ new ClientHandle("ArchiveClient", "0.01"), user);\r
+ this.vsess = vsess;\r
+ valid();\r
+ }\r
+\r
+ private void _openVsess(File vsess) {\r
+ try {\r
+ this.vsess = new VamsasFile(vsess);\r
+ } catch (Exception e) {\r
+ log.error("Couldn't open session for file " + vsess, e);\r
+ this.vsess = null;\r
+ }\r
+ }\r
+\r
+ public ArchiveClient(String username, String organization, File vsess) {\r
+ super(new SessionHandle("vamsasfile://" + vsess), new ClientHandle(\r
+ "ArchiveClient", "0.01"), new UserHandle(username, organization));\r
+ _openVsess(vsess);\r
+ valid();\r
+ }\r
+\r
+ public ArchiveClient(String username, String organization, String clientName,\r
+ String clientVersion, File vsess) {\r
+ super(new SessionHandle("vamsasfile://" + vsess), new ClientHandle(\r
+ clientName, clientVersion), new UserHandle(username, organization));\r
+ _openVsess(vsess);\r
+ valid();\r
+ }\r
+\r
+ public void valid() {\r
+ if (vsess == null)\r
+ throw new Error("ArchiveClient instance is invalid!.");\r
+ }\r
+\r
+ /**\r
+ * set this to false if watch loop should end immediately\r
+ */\r
+ protected boolean watchForChange = true;\r
+\r
+ public static int WATCH_SLEEP = 300;\r
+\r
+ /**\r
+ * watch the document file for updates.\r
+ * \r
+ * @param time\r
+ * - length of time to watch for.\r
+ * @return read only IO interface for session document.\r
+ */\r
+ public ClientDoc watch(long time) {\r
+ valid();\r
+ vsess.unLock(); // doh.\r
+ FileWatcher watcher = new FileWatcher(vsess.getVamsasFile());\r
+ // watcher.setState();\r
+ watchForChange = true;\r
+ long endtime = System.currentTimeMillis() + time;\r
+ try {\r
+ uk.ac.vamsas.client.simpleclient.Lock doclock;\r
+ do {\r
+ doclock = watcher.getChangedState();\r
+ if (doclock == null)\r
+ Thread.sleep(WATCH_SLEEP);\r
+ } while (watchForChange && doclock == null\r
+ && (time == 0 || endtime > System.currentTimeMillis())); // tuning.\r
+ if (doclock == null)\r
+ return null;\r
+ else {\r
+ return getUpdateable(vsess.getLock(doclock));\r
+ /*\r
+ * VamsasArchiveReader varc = new\r
+ * VamsasArchiveReader(vsess.getVamsasFile()); return\r
+ * _getReadonly(varc);\r
+ */\r
+ }\r
+ } catch (Exception e) {\r
+ log.error("Whilst watching file " + vsess.getVamsasFile(), e);\r
+ }\r
+ return null;\r
+ }\r
+\r
+ // from ClientDocument.getClientAppdata\r
+ private AppData[] getAppData(VamsasDocument doc) {\r
+ // TODO: codefest - not yet tested or merged in to SimpleClient\r
+ if (doc == null) {\r
+ log.debug("extractAppData called for null document object");\r
+ return null;\r
+ }\r
+ AppData appsGlobal = null, usersData = null;\r
+ Vector apldataset = AppDataReference.getUserandApplicationsData(doc, this\r
+ .getUserHandle(), this.getClientHandle());\r
+ if (apldataset != null) {\r
+ if (apldataset.size() > 0) {\r
+ AppData clientdat = (AppData) apldataset.get(0);\r
+ if (clientdat instanceof ApplicationData) {\r
+ appsGlobal = (ApplicationData) clientdat;\r
+ if (apldataset.size() > 1) {\r
+ clientdat = (AppData) apldataset.get(1);\r
+ if (clientdat instanceof User) {\r
+ usersData = (User) clientdat;\r
+ }\r
+ if (apldataset.size() > 2)\r
+ log.info("Ignoring additional (" + (apldataset.size() - 2)\r
+ + ") AppDatas returned by document appdata query.");\r
+ }\r
+ } else {\r
+ log.warn("Unexpected entry in AppDataReference query: id="\r
+ + clientdat.getVorbaId() + " type="\r
+ + clientdat.getClass().getName());\r
+ }\r
+ apldataset.removeAllElements(); // destroy references.\r
+ }\r
+ }\r
+ return new AppData[] { appsGlobal, usersData };\r
+ }\r
+\r
+ protected ClientDoc _getReadonly(VamsasArchiveReader vreader)\r
+ throws IOException, ValidationException, MarshalException {\r
+ valid();\r
+ if (vreader != null) {\r
+ SimpleDocBinding docb = new SimpleDocBinding();\r
+ docb.setVorba(this);\r
+ VamsasDocument d;\r
+ d = docb.getVamsasDocument(vreader);\r
+\r
+ if (d != null) {\r
+ ClientDoc creader = new ClientDoc(d, null, vreader, getClientHandle()\r
+ .getClientUrn(), getProvenanceUser(), getVorbaIdHash());\r
+ return creader;\r
+ }\r
+ }\r
+ return null;\r
+ }\r
+\r
+ /**\r
+ * from SimpleClient\r
+ * \r
+ * @return user field for a provenance entry\r
+ */\r
+ protected String getProvenanceUser() {\r
+ return new String(getUserHandle().getFullName() + " ["\r
+ + getClientHandle().getClientUrn() + "]");\r
+ }\r
+\r
+ public ClientDoc getUpdateable() {\r
+ return getUpdateable(null);\r
+ }\r
+\r
+ public ClientDoc getUpdateable(uk.ac.vamsas.client.simpleclient.Lock lock) {\r
+ getVorbaIdHash().clear();\r
+ valid();\r
+ try {\r
+ // patiently wait for a lock on the document.\r
+ long tries = 5000;\r
+ while (lock == null\r
+ && ((lock = vsess.getLock()) == null || !lock.isLocked())\r
+ && --tries > 0) {\r
+ // Thread.sleep(1);\r
+ log.debug("Trying to get a document lock for the " + tries\r
+ + "'th time.");\r
+ }\r
+ VamsasArchive varc = new VamsasArchive(vsess, true, false); // read\r
+ // archive,\r
+ // write as\r
+ // vamsasDocument,\r
+ // don't erase\r
+ // original\r
+ // contents.\r
+ varc.setVorba(this);\r
+ VamsasDocument d = varc.getVamsasDocument(getProvenanceUser(),\r
+ "Created new document.", VersionEntries.latestVersion()); // VAMSAS:\r
+ // provenance\r
+ // user and\r
+ // client\r
+ // combined\r
+\r
+ if (d == null) {\r
+ log\r
+ .warn("Backing out from opening a VamsasArchive writable IO session");\r
+ varc.cancelArchive();\r
+ return null;\r
+ }\r
+ ClientDoc cdoc = new ClientDoc(d, varc, varc.getOriginalArchiveReader(),\r
+ getClientHandle().getClientUrn(), getProvenanceUser(),\r
+ getVorbaIdHash());\r
+ return cdoc;\r
+ // do appHandle?\r
+ } catch (Exception e) {\r
+ log.error("Failed to get Updateable version of " + vsess.getVamsasFile(),\r
+ e);\r
+ }\r
+ return null;\r
+ }\r
+\r
+ /**\r
+ * trust client to not do anything stupid to the document roots which will now\r
+ * be written to the archive.\r
+ * \r
+ * @param cdoc\r
+ * @return true if write was a success.\r
+ */\r
+ public boolean doUpdate(ClientDoc cdoc) {\r
+ valid();\r
+ if (cdoc == null) {\r
+ log\r
+ .warn("Invalid ClientDoc passed to uk.ac.vamsas.test.simpleclient.doUpdate()");\r
+ return false;\r
+ }\r
+ if (cdoc.iohandler == null) {\r
+ log\r
+ .warn("Read only ClientDoc object passed to uk.ac.vamsas.test.simpleclient.doUpdate()");\r
+ return false;\r
+ }\r
+ if (cdoc.iohandler.getVorba() != this) {\r
+ log\r
+ .error("Mismatch between ClientDoc instances and ArchiveClient instances!");\r
+ return false;\r
+ }\r
+ try {\r
+ // do any appDatas first.\r
+ if (cdoc.iohandler.transferRemainingAppDatas())\r
+ log.debug("Remaining appdatas were transfered.");\r
+ cdoc.updateDocumentRoots();\r
+ cdoc.iohandler.putVamsasDocument(cdoc.doc);\r
+ cdoc.iohandler.closeArchive();\r
+ this.extantids.clear();// we forget our ids after we close the document.\r
+ cdoc.iohandler = null;\r
+ cdoc = null;\r
+ vsess.unLock();\r
+ } catch (Exception e) {\r
+ log.warn("While updating archive in " + vsess.getVamsasFile(), e);\r
+ return false;\r
+ }\r
+ return true;\r
+ }\r
+\r
+ /**\r
+ * @param args\r
+ */\r
+ public static void usage() {\r
+ throw new Error("Usage: Username Organization VamsasFile [command,args]*");\r
+ }\r
+\r
+ public static void main(String[] args) {\r
+ // really simple.\r
+ if (args.length < 3)\r
+ usage();\r
+\r
+ ArchiveClient client = new ArchiveClient(args[0], args[1],\r
+ new File(args[2]));\r
+ ClientDoc cdoc = null;\r
+ // sanity test.\r
+ try {\r
+ cdoc = client.getUpdateable();\r
+ // ArchiveReports.reportDocument(cdoc.doc, cdoc.getReader(), true,\r
+ // System.out);\r
+ System.out.println("Report Roots :");\r
+ ArchiveReports.rootReport(cdoc.getVamsasRoots(), true, System.out);\r
+ cdoc.addVamsasRoot(Core.getDemoVamsas());\r
+ System.out.println("Doing update.");\r
+ client.doUpdate(cdoc);\r
+ cdoc.closeDoc();\r
+ cdoc = null;\r
+ int u = 5;\r
+ while (--u > 0) {\r
+ System.out.println("Watch for more... (" + u + " left)");\r
+ ClientDoc ucdoc = client.watch(0000);\r
+ if (ucdoc != null) {\r
+ System.out.println("****\nUpdate detected at " + new Date());\r
+ ArchiveReports.reportDocument(ucdoc.doc, ucdoc.getReader(), true,\r
+ System.out);\r
+ ucdoc.closeDoc();\r
+ ucdoc = null;\r
+ } else {\r
+ System.out.println("!!!! Null document update detected at "\r
+ + new Date());\r
+ }\r
+ }\r
+ } catch (Exception e) {\r
+ client.log.error("Broken!", e);\r
+ }\r
+ System.out.println("Finished at " + new Date());\r
+ }\r
+\r
+ public uk.ac.vamsas.client.Vobject getObject(VorbaId id) {\r
+ Hashtable idhash = this.getVorbaIdHash();\r
+ if (idhash != null && idhash.containsKey(id))\r
+ return (Vobject) idhash.get(id);\r
+ return null;\r
+ }\r
+}\r