import java.io.File;
import java.net.MalformedURLException;
+import uk.ac.vamsas.client.InvalidSessionUrnException;
+
/**
* SessionUrn for simpleclient sessions:
* simpleclient://{Absolute path to session directory}
TYPES.put(SessionUrn.VAMSASDOCUMENT, SessionUrn.class);
}
+ /**
+ * Creates a SessionUrn object from a String.
+ * The string must be a string representation of a URI
+ * @param urnString
+ * @throws InvalidSessionUrnException
+ */
+ public SessionUrn(String urnString) throws InvalidSessionUrnException
+ {
+ super();
+ 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());
public SessionUrn(VamsasSession session) throws MalformedURLException {
super(SIMPLECLIENT, session.sessionDir.getAbsoluteFile().toURL());
}
+
+
+
+ /**
+ * @see uk.ac.vamsas.client.SessionUrn#setURN(java.lang.String)
+ */
+ protected void setURN(String urnString) throws NullPointerException, IllegalArgumentException {
+ super.setURN(urnString);
+ }
+
/**
* TODO: LATER: think about this again.
* @return File(urn.getPath())
*/
public File asFile() {
+ String path = urn.getPath();
+
+ if ("\\".equals(File.separator))
+ {
+ //remove last separator at last position if found
+ if (path.charAt(path.length() - 1) == '/')path = path.substring(0, path.length() - 1);
+ path = path.replaceAll("/", "\\\\");
+ }
+ 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());
}
// TODO: add abstract 'handler' methods for resolving the URN to a particular class