2 * This file is part of the Vamsas Client version 0.1.
\r
3 * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite,
\r
4 * Andrew Waterhouse and Dominik Lindner.
\r
6 * Earlier versions have also been incorporated into Jalview version 2.4
\r
7 * since 2008, and TOPALi version 2 since 2007.
\r
9 * The Vamsas Client is free software: you can redistribute it and/or modify
\r
10 * it under the terms of the GNU Lesser General Public License as published by
\r
11 * the Free Software Foundation, either version 3 of the License, or
\r
12 * (at your option) any later version.
\r
14 * The Vamsas Client is distributed in the hope that it will be useful,
\r
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
17 * GNU Lesser General Public License for more details.
\r
19 * You should have received a copy of the GNU Lesser General Public License
\r
20 * along with the Vamsas Client. If not, see <http://www.gnu.org/licenses/>.
\r
22 package uk.ac.vamsas.client.simpleclient;
\r
24 import java.io.File;
\r
25 import java.net.URI;
\r
27 import uk.ac.vamsas.client.InvalidSessionUrnException;
\r
30 * SessionUrn for simpleclient sessions: simpleclient://{Absolute path to
\r
31 * session directory}
\r
33 * For simpleclient urn, it consideres as on the same machine, using the path to
\r
34 * the session directory to generate the session URN
\r
39 public class SessionUrn extends uk.ac.vamsas.client.SessionUrn {
\r
41 * a simple client session urn prefix
\r
43 public static final String SIMPLECLIENT = "simpleclient";
\r
45 public static String VAMSASDOCUMENT = "vdoc";
\r
47 TYPES.put(SIMPLECLIENT, SessionUrn.class);
\r
48 TYPES.put(SessionUrn.VAMSASDOCUMENT, SessionUrn.class);
\r
52 * Creates a SessionUrn object from a String. The string must be a string
\r
53 * representation of a URI
\r
56 * @throws InvalidSessionUrnException
\r
58 public SessionUrn(String urnString) throws InvalidSessionUrnException {
\r
60 this.setURN(urnString);
\r
64 * Generates a sessionURN bases on a session directory location
\r
66 * @param sessionLocation
\r
67 * the file object to the session directory
\r
69 public SessionUrn(File sessionLocation) {// throws MalformedURLException {
\r
70 // TODO: LATER: implement switch to have vamsas document or simpleclient
\r
71 // sessions for same constructor
\r
72 // use URI instead of URL
\r
73 super(SIMPLECLIENT, sessionLocation.getAbsoluteFile().toURI());
\r
77 * Generates a sessionURN bases on a vamsas session
\r
82 * Should return the same URN string than the creation with the
\r
85 public SessionUrn(VamsasSession session) {
\r
86 // throws MalformedURLException {
\r
87 // use URI instead of URL
\r
88 super(SIMPLECLIENT, session.sessionDir.getAbsoluteFile().toURI());
\r
92 * TODO: LATER: think about this again.
\r
94 * Retrieves the file associated to the current sessionURN. The sessionURN
\r
95 * (URI) is based on the session directory absolute path. Use the raw path of
\r
96 * the URN and change the scheme to file to generate a new file URI. Then,
\r
97 * from the URI create the File object (a File object can be created from an
\r
100 * @return File object representing the session URN // File(urn.getPath())
\r
102 public File asFile() {
\r
103 String path = this.urn.getRawPath();
\r
105 return new File(URI.create("file://" + path));
\r
107 // TODO: add abstract 'handler' methods for resolving the URN to a particular
\r