package org.vamsas.client.simpleclient; import java.io.File; import java.io.FileOutputStream; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Timer; import java.util.jar.JarEntry; import java.util.jar.JarFile; import java.util.jar.JarInputStream; import java.util.jar.JarOutputStream; import org.vamsas.objects.core.LockFileDescriptor; /** * low level vamsas document management routines * analogous to ClientsFile * This class is not thread safe. * @author jimp * */ public class VamsasFile extends SessionFile { /** * * Connect to an existing Vamsas document in a given sessionDir * or create a new one. * * @param sessionDir * @throws java.io.IOException */ public VamsasFile(File sessionFile) throws java.io.IOException { super(sessionFile); } /** * Expand a previously stored session into the sessionDir * @param sessionDir * @param storedSession public VamsasFile(File sessionDir, JarFile storedSession) throws IOException { // check if sessionDir is live or not if (!sessionDir.exists()) { sessionDir.mkdir(); } { // check its actually a writable directory } File sfile = new File(sessionDir, "vamsas.jar"); VamsasFile(sfile); // if live - try to merge storedSession with sessionDir // - will probably fail through duplicate object references needing to be dereferenced. // TODO: think of a way of specifying vorba_id scope for an application's references to allow merging of one vamsasDocument with another. } */ /** * gets a locked Reader for the vamsas document. * @return reader for vamsasdocument.xml enrty */ public Lock getLock() { while (!lockFile()) ; return fileLock; } public java.io.Reader getDocumentReader() { try { JarFile session = new JarFile("vamsasJar"); //JarEntry vamsasDocument = session.getJarEntry("vamsasDocument.xml"); //return new InputStreamReader(session.getInputStream(vamsasDocument)); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } }