+ String vamsasImport=aparser.getValue("vdoc"),vamsasSession=aparser.getValue("vsess");
+ if (vamsasImport!=null || vamsasSession!=null)
+ {
+ if (desktop==null || headless)
+ {
+ System.out.println("Headless vamsas sessions not yet supported. Sorry.");
+ System.exit(1);
+ }
+ // if we have a file, start a new session and import it.
+ boolean inSession = false;
+ if (vamsasImport!=null)
+ {
+ try {
+ String viprotocol = Jalview.checkProtocol(vamsasImport);
+ if (viprotocol == jalview.io.FormatAdapter.FILE) {
+ inSession = desktop.vamsasImport(new File(vamsasImport));
+ } else if (viprotocol == jalview.io.FormatAdapter.URL) {
+ inSession = desktop.vamsasImport(new URL(vamsasImport));
+ }
+
+ } catch (Exception e)
+ {
+ System.err.println("Exeption when importing "+vamsasImport+" as a vamsas document.");
+ e.printStackTrace();
+ }
+ if (!inSession) {
+ System.err.println("Failed to import "+vamsasImport+" as a vamsas document.");
+ } else {
+ System.out.println("Imported Successfully into new session "+desktop.getVamsasApplication().getCurrentSession());
+ }
+ }
+ if (vamsasSession!=null) {
+ if (vamsasImport!=null) {
+ // close the newly imported session and import the Jalview specific remnants into the new session later on.
+ desktop.vamsasStop_actionPerformed(null);
+ }
+ // now join the new session
+ try {
+ if (desktop.joinVamsasSession(vamsasSession)) {
+ System.out.println("Successfully joined vamsas session "+vamsasSession);
+ } else {
+ System.err.println("WARNING: Failed to join vamsas session "+vamsasSession);
+ }
+ } catch (Exception e)
+ {
+ System.err.println("ERROR: Failed to join vamsas session "+vamsasSession);
+ e.printStackTrace();
+ }
+ if (vamsasImport!=null) {
+ // the Jalview specific remnants can now be imported into the new session at the user's leisure.
+ Cache.log.info("Skipping Push for import of data into existing vamsas session."); // TODO: enable this when debugged
+ // desktop.getVamsasApplication().push_update();
+ }
+ }
+ }
+ // Finally, deal with the remaining input data.