X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fuk%2Fac%2Fvamsas%2Fclient%2Fsimpleclient%2FSessionUrn.java;h=bdb429683667b17f12aac0e6a91cc6d5e204378d;hb=5ac503d283a5e030ae9ad6a0ef8bc0022e33b063;hp=18d54501b55d5421c9f4712c4864dfeb83c66f62;hpb=734bcc2a380be2c5aa9e229936cb2e026a86dfef;p=vamsas.git diff --git a/src/uk/ac/vamsas/client/simpleclient/SessionUrn.java b/src/uk/ac/vamsas/client/simpleclient/SessionUrn.java index 18d5450..bdb4296 100644 --- a/src/uk/ac/vamsas/client/simpleclient/SessionUrn.java +++ b/src/uk/ac/vamsas/client/simpleclient/SessionUrn.java @@ -2,6 +2,7 @@ package uk.ac.vamsas.client.simpleclient; import java.io.File; import java.net.MalformedURLException; +import java.net.URI; import uk.ac.vamsas.client.InvalidSessionUrnException; @@ -34,9 +35,13 @@ public class SessionUrn extends uk.ac.vamsas.client.SessionUrn { this.setURN(urnString); } + + public SessionUrn(File sessionLocation) throws MalformedURLException { // TODO: LATER: implement switch to have vamsas document or simpleclient sessions for same constructor - super(SIMPLECLIENT, sessionLocation.getAbsoluteFile().toURL()); + // super(SIMPLECLIENT, sessionLocation.getAbsoluteFile().toURL()); + // super(SIMPLECLIENT, sessionLocation.getAbsoluteFile().toURL()); + super(SIMPLECLIENT, sessionLocation.getAbsoluteFile().toURI()); //else // super(VAMSASDOCUMENT, sessionLocation); } @@ -58,23 +63,28 @@ public class SessionUrn extends uk.ac.vamsas.client.SessionUrn { * @return File(urn.getPath()) */ public File asFile() { - String path = urn.getPath(); + String path = this.urn.getRawPath(); - if ("\\".equals(File.separator)) - { + /*if ("\\".equals(File.separator)) + {//windows stuff //remove last separator at last position if found - if (path.charAt(path.length() - 1) == '/')path = path.substring(0, path.length() - 1); + /* not needed anymore if (path.charAt(path.length() - 1) == '/')path = path.substring(0, path.length() - 1); path = path.replaceAll("/", "\\\\"); + */ + + /* int index = path.indexOf(File.separator); + + if (index >-1) + {//separator found, keep last part of the urn - filename + path = path.substring(index+1, path.length()); + } + //remove encoded space character + // path = path.replaceAll("%20", " "); } - int index = path.lastIndexOf(File.separator); - /*don t remember why - if (index >-1) - {//separator found, keep last part of the urn - filename - path = path.substring(index+1, path.length()); - } - *yop - */ - return new File(urn.getPath()); + /*shall we use URI or String to create the object*/ + /* from URI : URI.create("file://path") , but first / */ + /* return new File(path);*/ + return new File ( URI.create("file://"+path)); } // TODO: add abstract 'handler' methods for resolving the URN to a particular class }