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 {
41 * @return the VamsasFile
43 public File getVamsasFile() {
47 * Expand a previously stored session into the sessionDir
49 * @param storedSession
51 public VamsasFile(File sessionDir, JarFile storedSession) throws IOException {
52 // check if sessionDir is live or not
53 if (!sessionDir.exists()) {
58 // check its actually a writable directory
61 File sfile = new File(sessionDir, "vamsas.jar");
63 // if live - try to merge storedSession with sessionDir
64 // - will probably fail through duplicate Vobject references needing to be dereferenced.
65 // TODO: think of a way of specifying vorba_id scope for an application's references to allow merging of one vamsasDocument with another.
70 * public interface for getting a lock.
71 * The lock object is internally referenced
72 * so the lock will persist even after the
73 * return value of the method goes out of scope.
74 * @return null if lock couldn't be got or a valid Lock object.
76 public Lock getLock() {
84 * @return null, extantLock or new Lock.
86 public Lock getLock(Lock extantLock) {
87 if (lockFile(extantLock))
92 * explicitly unlocks vamsas file.
93 * if you have called getLock() you *must*
94 * call this to release the lock.
96 public void unLock() {