- if (!v_doc.exists() && v_doc.createNewFile())
- log.debug("Created new Vamsas Session Document File " + v_doc);
+ if (!v_doc.exists())
+ {
+ if (extVamDoc==null)
+ {
+ if (v_doc.createNewFile())
+ {
+ log.debug("Created new Vamsas Session Document File " + v_doc);
+ } else {
+ log.warn("Didn't create Vamsas Session Document file in "+v_doc);
+ }
+ } else {
+ log.debug("Creating new session document from "+extVamDoc);
+ try {
+ SessionFile sesdoc = new SessionFile(new File(sessionDir, VAMSAS_OBJ));
+ SessionFile extdoc = new SessionFile(extVamDoc);
+ sesdoc.updateFrom(null, extdoc);
+ } catch (Exception e)
+ {
+ v_doc.delete();
+ v_doc.createNewFile();
+ log.warn("Problem initialising new session ("+v_doc+") from existing vamsas document ("+extVamDoc+")",e);
+ throw new IOException("Couldn't initialise session from existing vamsas document");
+ }
+ log.debug("Session document initialised from "+extVamDoc);
+ }
+ }