From: jprocter Date: Tue, 11 Sep 2007 16:55:03 +0000 (+0000) Subject: refactored initialisation of new session with existing document code. X-Git-Tag: Release_0.2~62 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=f5d362ecabee4658cebb7ad43b42381950c74a82;p=vamsas.git refactored initialisation of new session with existing document code. git-svn-id: https://svn.lifesci.dundee.ac.uk/svn/repository/trunk@458 be28352e-c001-0410-b1a7-c7978e42abec --- diff --git a/src/uk/ac/vamsas/client/simpleclient/SimpleClient.java b/src/uk/ac/vamsas/client/simpleclient/SimpleClient.java index a2b999d..d5dc880 100644 --- a/src/uk/ac/vamsas/client/simpleclient/SimpleClient.java +++ b/src/uk/ac/vamsas/client/simpleclient/SimpleClient.java @@ -103,6 +103,15 @@ public class SimpleClient implements IClient { */ protected SimpleClient(UserHandle user, ClientHandle client, VamsasSession sess, File importingArchive) throws Exception { this(user, client, sess); + if (log.isDebugEnabled()) + { + log.debug("Attempting to create a new session from file: "+importingArchive); + } + initSessionDocFromFile(importingArchive); + // TODO: write provenance entry for new session indicating the import. + } + + private void initSessionDocFromFile(File importingArchive) throws Exception { VamsasArchive sessdoc = _session.getVamsasDocument(); try { VamsasArchiveReader odoc = new VamsasArchiveReader(importingArchive); @@ -111,15 +120,16 @@ public class SimpleClient implements IClient { sessdoc.putVamsasDocument(doc, sdoc.vorba); sessdoc.closeArchive(); log.debug("Imported new vamsas data from "+importingArchive); + } catch (Exception e) { sessdoc.cancelArchive(); - // write a dummy iohandler + // TODO: check that new session is really writeable if the imported document was invalid ? or is removed _session.slog.info("Exception when importing document data from "+importingArchive); log.warn("While importing session data from existing archive in "+importingArchive, e); throw new Exception("Failed to import data from "+importingArchive, e); } } - + /* * (non-Javadoc) * LATER: check that build substitution variables are correct