import uk.ac.vamsas.client.IClient;
import uk.ac.vamsas.client.IClientDocument;
import uk.ac.vamsas.client.IObjectUpdate;
+import uk.ac.vamsas.client.InvalidSessionDocumentException;
import uk.ac.vamsas.client.InvalidSessionUrnException;
import uk.ac.vamsas.client.SessionHandle;
import uk.ac.vamsas.client.UserHandle;
}
/**
- * construct new session by importing objects from an existing vamsas document
+ * construct new SimpleClientsession by importing objects from an existing vamsas document
* @param user
* @param client
* @param sess
* @param importingArchive
* @throws Exception IOExceptions for Session IO problems, and general Exception if importing document is invalid.
- */
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);
+ log.debug("Attempting to overwrite session document with file: "+importingArchive);
}
- initSessionDocFromFile(importingArchive);
- // TODO: write provenance entry for new session indicating the import.
+ // 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);
- SimpleDocument sdoc = new SimpleDocument(makeVorbaIdFactory());
- VamsasDocument doc = sdoc.getVamsasDocument(odoc);
- sessdoc.putVamsasDocument(doc, sdoc.vorba);
- sessdoc.closeArchive();
- log.debug("Imported new vamsas data from "+importingArchive);
-
- } catch (Exception e) {
- sessdoc.cancelArchive();
- // 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