2 package uk.ac.vamsas.client.simpleclient;
5 import java.io.FileOutputStream;
6 import java.io.FileReader;
7 import java.io.IOException;
8 import java.io.InputStream;
9 import java.io.InputStreamReader;
10 import java.io.PrintWriter;
11 import java.util.Timer;
12 import java.util.jar.JarEntry;
13 import java.util.jar.JarFile;
14 import java.util.jar.JarInputStream;
15 import java.util.jar.JarOutputStream;
18 * low level vamsas document management routines
19 * analogous to ClientsFile
20 * Grew out of io tests on VamsasArchive class in uk.ac.vamsas.test.simpleclient.VamsasArchive
21 * This class is not thread safe.
25 public class VamsasFile extends SessionFile {
28 * Connect to an existing Vamsas document in a given sessionDir
29 * or create a new one.
32 * @throws java.io.IOException
34 public VamsasFile(File sessionFile) throws java.io.IOException {
39 * @return the VamsasFile
41 public File getVamsasFile() {
45 * Expand a previously stored session into the sessionDir
47 * @param storedSession
49 public VamsasFile(File sessionDir, JarFile storedSession) throws IOException {
50 // check if sessionDir is live or not
51 if (!sessionDir.exists()) {
56 // check its actually a writable directory
59 File sfile = new File(sessionDir, "vamsas.jar");
61 // if live - try to merge storedSession with sessionDir
62 // - will probably fail through duplicate Vobject references needing to be dereferenced.
63 // TODO: think of a way of specifying vorba_id scope for an application's references to allow merging of one vamsasDocument with another.
68 * public interface for getting a lock.
69 * The lock object is internally referenced
70 * so the lock will persist even after the
71 * return value of the method goes out of scope.
72 * @return null if lock couldn't be got or a valid Lock object.
74 public Lock getLock() {
82 * @return null, extantLock or new Lock.
84 public Lock getLock(Lock extantLock) {
85 if (lockFile(extantLock))
90 * explicitly unlocks vamsas file.
91 * if you have called getLock() you *must*
92 * call this to release the lock.
94 public void unLock() {