X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fuk%2Fac%2Fvamsas%2Fclient%2Fsimpleclient%2FSessionUrn.java;h=ac64f0e0c2ef4ffa4bdb66477da4f8f944569944;hb=22a4a706dd9c2081f614577235224574bb37fe91;hp=bdb429683667b17f12aac0e6a91cc6d5e204378d;hpb=5ac503d283a5e030ae9ad6a0ef8bc0022e33b063;p=vamsas.git diff --git a/src/uk/ac/vamsas/client/simpleclient/SessionUrn.java b/src/uk/ac/vamsas/client/simpleclient/SessionUrn.java index bdb4296..ac64f0e 100644 --- a/src/uk/ac/vamsas/client/simpleclient/SessionUrn.java +++ b/src/uk/ac/vamsas/client/simpleclient/SessionUrn.java @@ -1,7 +1,6 @@ package uk.ac.vamsas.client.simpleclient; import java.io.File; -import java.net.MalformedURLException; import java.net.URI; import uk.ac.vamsas.client.InvalidSessionUrnException; @@ -9,6 +8,10 @@ import uk.ac.vamsas.client.InvalidSessionUrnException; /** * SessionUrn for simpleclient sessions: * simpleclient://{Absolute path to session directory} + * + * For simpleclient urn, it consideres as on the same machine, using the path to the session + * directory to generate the session URN + * * @author jimp * */ @@ -36,54 +39,49 @@ public class SessionUrn extends uk.ac.vamsas.client.SessionUrn { } - - public SessionUrn(File sessionLocation) throws MalformedURLException { + /** + * Generates a sessionURN bases on a session directory location + * + * @param sessionLocation the file object to the session directory + */ + 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()); + //use URI instead of URL super(SIMPLECLIENT, sessionLocation.getAbsoluteFile().toURI()); - //else - // super(VAMSASDOCUMENT, sessionLocation); } - public SessionUrn(VamsasSession session) throws MalformedURLException { - super(SIMPLECLIENT, session.sessionDir.getAbsoluteFile().toURL()); - } - - /** - * @see uk.ac.vamsas.client.SessionUrn#setURN(java.lang.String) + * Generates a sessionURN bases on a vamsas session + * @param session a VamsasSession + * + * Should return the same URN string than the creation with the session directory */ - protected void setURN(String urnString) throws NullPointerException, IllegalArgumentException { - super.setURN(urnString); + public SessionUrn(VamsasSession session) + { + //throws MalformedURLException { + // use URI instead of URL + super(SIMPLECLIENT, session.sessionDir.getAbsoluteFile().toURI()); } + + + + /** * TODO: LATER: think about this again. - * @return File(urn.getPath()) + * + * Retrieves the file associated to the current sessionURN. + * The sessionURN (URI) is based on the session directory absolute path. + * Use the raw path of the URN and change the scheme to file to generate a new file + * URI. Then, from the URI create the File object (a File object can be created from an uri) + * + * @return File object representing the session URN // + * File(urn.getPath()) */ public File asFile() { String path = this.urn.getRawPath(); - - /*if ("\\".equals(File.separator)) - {//windows stuff - //remove last separator at last position if found - /* 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", " "); - } - /*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