intermediate cjeckin - nfs woes!
[vamsas.git] / src / org / vamsas / client / simpleclient / SimpleClientAppdata.java
index 52d5890..5bda46e 100644 (file)
@@ -10,6 +10,7 @@ import java.io.DataInput;
 import java.io.DataInputStream;
 import java.io.DataOutput;
 import java.io.DataOutputStream;
+import java.io.IOException;
 import java.io.InputStream;
 import java.util.Vector;
 import java.util.jar.JarEntry;
@@ -48,6 +49,15 @@ public class SimpleClientAppdata implements IClientAppdata {
    */
   SessionFile newAppData=null;
   JarOutputStream newAppDataStream=null;
+  /**
+   * set by extractAppData
+   */
+  protected ApplicationData appsGlobal = null;
+  /**
+   * set by extractAppData
+   */
+  protected User usersData = null;
+  
   ClientDocument clientdoc;
   /**
    * state flags
@@ -71,14 +81,6 @@ public class SimpleClientAppdata implements IClientAppdata {
     this.clientdoc = clientdoc;
   }
   /**
-   * set by extractAppData
-   */
-  protected ApplicationData appsGlobal = null;
-  /**
-   * set by extractAppData
-   */
-  protected User usersData = null;
-  /**
    * gets appropriate app data for the application, if it exists in this dataset
    * Called by every accessor to ensure data has been retrieved from document.
    */
@@ -447,6 +449,44 @@ public class SimpleClientAppdata implements IClientAppdata {
       // LATER: deal with error case - do we make session read only, or what ?
     }
   }
+  /**
+   * flush and close outstanding output streams. 
+   *  - do this before checking data length.
+   * @throws IOException
+   */
+  protected void closeForWriting() throws IOException {
+    if (newAppDataStream!=null) {
+      newAppDataStream.flush();
+      newAppDataStream.closeEntry();
+      newAppDataStream.close();
+    }
+    if (newUserDataStream!=null) {
+      newUserDataStream.flush();
+      newUserDataStream.closeEntry();
+      newUserDataStream.close();
+    }
+  }
+  /**
+   * copy data from the appData jar file to an appropriately 
+   * referenced jar or Data entry for the given ApplicationData 
+   * @param vdoc session Document handler
+   * @param appd the AppData whose block is being updated
+   * @param apdjar the new data in a Jar written by this class
+   */
+  protected void updateAnAppdataEntry(VamsasArchive vdoc, AppData appd, SessionFile apdjar) {
+    
+  }
+
+  /**
+   * 
+   * @return true if any AppData blocks have to be updated in session Jar
+   */
+  protected boolean isModified() {
+    // LATER differentiate between core xml modification and Jar Entry modification.
+    if (newAppData.sessionFile.exists() || newUserData.sessionFile.exists())
+      return true;
+    return false;
+  }
   /* (non-Javadoc)
    * @see java.lang.Object#finalize()
    */