* @throws IOException if call to accessOriginal failed for updates, or openArchive failed.
*/
public VamsasArchive(File archive, boolean vamsasdocument) throws IOException {
* @throws IOException if call to accessOriginal failed for updates, or openArchive failed.
*/
public VamsasArchive(File archive, boolean vamsasdocument) throws IOException {
if (archive==null || (archive!=null && !(archive.getParentFile().canWrite() && (!archive.exists() || archive.canWrite())))) {
log.fatal("Expect Badness! -- Invalid parameters for VamsasArchive constructor:"+((archive!=null)
? "File cannot be overwritten." : "Null Object not valid constructor parameter"));
if (archive==null || (archive!=null && !(archive.getParentFile().canWrite() && (!archive.exists() || archive.canWrite())))) {
log.fatal("Expect Badness! -- Invalid parameters for VamsasArchive constructor:"+((archive!=null)
? "File cannot be overwritten." : "Null Object not valid constructor parameter"));
* opens the new archive ready for writing. If the new archive is replacing an existing one,
* then the existing archive will be locked, and the new archive written to a temporary file.
* The new archive will be put in place once close() is called.
* opens the new archive ready for writing. If the new archive is replacing an existing one,
* then the existing archive will be locked, and the new archive written to a temporary file.
* The new archive will be put in place once close() is called.
- rchive = new SessionFile(archive);
- rchive.lockFile();
+ if (rchive==null)
+ rchive = new SessionFile(archive);
+ archive.createNewFile();
+ if (!rchive.lockFile())
+ throw new IOException("Failed to get lock on file "+archive);
+
newarchive = new JarOutputStream(new BufferedOutputStream(new java.io.FileOutputStream(archive)));
entries = new Hashtable();
}
newarchive = new JarOutputStream(new BufferedOutputStream(new java.io.FileOutputStream(archive)));
entries = new Hashtable();
}