simple test of locked IO based on ArchiveWatcher. Extend this to quickly incorporate...
authorjprocter <jprocter@compbio.dundee.ac.uk>
Fri, 24 Mar 2006 19:03:00 +0000 (19:03 +0000)
committerjprocter <jprocter@compbio.dundee.ac.uk>
Fri, 24 Mar 2006 19:03:00 +0000 (19:03 +0000)
git-svn-id: https://svn.lifesci.dundee.ac.uk/svn/repository/trunk@209 be28352e-c001-0410-b1a7-c7978e42abec

src/org/vamsas/test/simpleclient/ArchiveClient.java [new file with mode: 0644]

diff --git a/src/org/vamsas/test/simpleclient/ArchiveClient.java b/src/org/vamsas/test/simpleclient/ArchiveClient.java
new file mode 100644 (file)
index 0000000..a5deb87
--- /dev/null
@@ -0,0 +1,77 @@
+/**
+ * 
+ */
+package org.vamsas.test.simpleclient;
+
+import java.io.File;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.vamsas.client.ClientHandle;
+import org.vamsas.client.UserHandle;
+import org.vamsas.client.simpleclient.FileWatcher;
+import org.vamsas.client.simpleclient.SessionFile;
+import org.vamsas.client.simpleclient.VamsasArchive;
+import org.vamsas.client.simpleclient.VamsasFile;
+
+/**
+ * @author jimp
+ *  test the VamsasFile routines for watching, reading and updating a vamsas document jar file.
+ */
+public class ArchiveClient {
+  Log log = LogFactory.getLog(ArchiveClient.class);
+  UserHandle user=null;
+  ClientHandle me = new ClientHandle("ArchiveClient","0.01");
+  VamsasFile vsess;
+  
+  /**
+   * @param user
+   * @param vsess
+   */
+  public ArchiveClient(UserHandle user, VamsasFile vsess) {
+    super();
+    this.user = user;
+    this.vsess = vsess;
+  }
+  public ArchiveClient(String username, String organization, String vsess) {
+    super();
+    this.user = new UserHandle(username, organization);
+    try {
+      this.vsess = new VamsasFile(new File(vsess));
+    } catch (Exception e) {
+      log.error("Couldn't open session on file "+vsess,e);
+      this.vsess=null;
+    }
+  }
+  public void valid() {
+    if (vsess==null)
+      throw new Error("ArchiveClient instance is invalid!.");
+  }
+  /**
+   * 
+   * @param time - length of time to watch for.
+   * @return IO interface for session document.
+   */
+  public VamsasArchive watch(long time) {
+    valid();
+    // wait around watching for a change.
+    VamsasArchive varch=null;
+    // FileWatcher w = new FileWatcher(vsess);
+    return varch;
+  }
+  
+  /**
+   * @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], args[2]);
+    
+  }
+
+}