1 package uk.ac.vamsas.client.simpleclient;
6 import uk.ac.vamsas.client.InvalidSessionUrnException;
9 * SessionUrn for simpleclient sessions:
10 * simpleclient://{Absolute path to session directory}
12 * For simpleclient urn, it consideres as on the same machine, using the path to the session
13 * directory to generate the session URN
18 public class SessionUrn extends uk.ac.vamsas.client.SessionUrn {
20 * a simple client session urn prefix
22 public static final String SIMPLECLIENT="simpleclient";
23 public static String VAMSASDOCUMENT="vdoc";
25 TYPES.put(SIMPLECLIENT, SessionUrn.class);
26 TYPES.put(SessionUrn.VAMSASDOCUMENT, SessionUrn.class);
30 * Creates a SessionUrn object from a String.
31 * The string must be a string representation of a URI
33 * @throws InvalidSessionUrnException
35 public SessionUrn(String urnString) throws InvalidSessionUrnException
38 this.setURN(urnString);
43 * Generates a sessionURN bases on a session directory location
45 * @param sessionLocation the file object to the session directory
47 public SessionUrn(File sessionLocation)
48 {//throws MalformedURLException {
49 // TODO: LATER: implement switch to have vamsas document or simpleclient sessions for same constructor
50 //use URI instead of URL
51 super(SIMPLECLIENT, sessionLocation.getAbsoluteFile().toURI());
55 * Generates a sessionURN bases on a vamsas session
56 * @param session a VamsasSession
58 * Should return the same URN string than the creation with the session directory
60 public SessionUrn(VamsasSession session)
62 //throws MalformedURLException {
63 // use URI instead of URL
64 super(SIMPLECLIENT, session.sessionDir.getAbsoluteFile().toURI());
72 * TODO: LATER: think about this again.
74 * Retrieves the file associated to the current sessionURN.
75 * The sessionURN (URI) is based on the session directory absolute path.
76 * Use the raw path of the URN and change the scheme to file to generate a new file
77 * URI. Then, from the URI create the File object (a File object can be created from an uri)
79 * @return File object representing the session URN //
82 public File asFile() {
83 String path = this.urn.getRawPath();
85 return new File ( URI.create("file://"+path));
87 // TODO: add abstract 'handler' methods for resolving the URN to a particular class