2 package org.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;
17 import org.vamsas.objects.core.LockFileDescriptor;
20 * low level vamsas document management routines
21 * analogous to ClientsFile
22 * Grew out of io tests on VamsasArchive class in org.vamsas.test.simpleclient.VamsasArchive
23 * This class is not thread safe.
27 public class VamsasFile extends SessionFile {
30 * Connect to an existing Vamsas document in a given sessionDir
31 * or create a new one.
34 * @throws java.io.IOException
36 public VamsasFile(File sessionFile) throws java.io.IOException {
40 * Expand a previously stored session into the sessionDir
42 * @param storedSession
44 public VamsasFile(File sessionDir, JarFile storedSession) throws IOException {
45 // check if sessionDir is live or not
46 if (!sessionDir.exists()) {
51 // check its actually a writable directory
54 File sfile = new File(sessionDir, "vamsas.jar");
56 // if live - try to merge storedSession with sessionDir
57 // - will probably fail through duplicate Vobject references needing to be dereferenced.
58 // TODO: think of a way of specifying vorba_id scope for an application's references to allow merging of one vamsasDocument with another.
63 * public interface for getting a lock.
64 * The lock object is internally referenced
65 * so the lock will persist even after the
66 * return value of the method goes out of scope.
67 * @return null if lock couldn't be got or a valid Lock object.
69 public Lock getLock() {
75 * explicitly unlocks vamsas file.
76 * if you have called getLock() you *must*
77 * call this to release the lock.
79 public void unLock() {