1 package uk.ac.vamsas.client.simpleclient;
4 import java.net.MalformedURLException;
6 import uk.ac.vamsas.client.InvalidSessionUrnException;
9 * SessionUrn for simpleclient sessions:
10 * simpleclient://{Absolute path to session directory}
14 public class SessionUrn extends uk.ac.vamsas.client.SessionUrn {
16 * a simple client session urn prefix
18 public static final String SIMPLECLIENT="simpleclient";
19 public static String VAMSASDOCUMENT="vdoc";
21 TYPES.put(SIMPLECLIENT, SessionUrn.class);
22 TYPES.put(SessionUrn.VAMSASDOCUMENT, SessionUrn.class);
26 * Creates a SessionUrn object from a String.
27 * The string must be a string representation of a URI
29 * @throws InvalidSessionUrnException
31 public SessionUrn(String urnString) throws InvalidSessionUrnException
34 this.setURN(urnString);
37 public SessionUrn(File sessionLocation) throws MalformedURLException {
38 // TODO: LATER: implement switch to have vamsas document or simpleclient sessions for same constructor
39 super(SIMPLECLIENT, sessionLocation.getAbsoluteFile().toURL());
41 // super(VAMSASDOCUMENT, sessionLocation);
43 public SessionUrn(VamsasSession session) throws MalformedURLException {
44 super(SIMPLECLIENT, session.sessionDir.getAbsoluteFile().toURL());
50 * @see uk.ac.vamsas.client.SessionUrn#setURN(java.lang.String)
52 protected void setURN(String urnString) throws NullPointerException, IllegalArgumentException {
53 super.setURN(urnString);
57 * TODO: LATER: think about this again.
58 * @return File(urn.getPath())
60 public File asFile() {
61 String path = urn.getPath();
63 if ("\\".equals(File.separator))
65 //remove last separator at last position if found
66 if (path.charAt(path.length() - 1) == '/')path = path.substring(0, path.length() - 1);
67 path = path.replaceAll("/", "\\\\");
69 int index = path.lastIndexOf(File.separator);
72 {//separator found, keep last part of the urn - filename
73 path = path.substring(index+1, path.length());
77 return new File(urn.getPath());
79 // TODO: add abstract 'handler' methods for resolving the URN to a particular class