}
+ /**
+ * try to locate the sessionUrn within the simpleclient session arena
+ * @param sessionUrn
+ * @return
+ * @throws InvalidSessionUrnException
+ */
private File convertSessionUrnToFile(String sessionUrn)
throws InvalidSessionUrnException {
if (sessionUrn == null) {
log.debug("Incorrect URN: can not open session.");
- throw new InvalidSessionUrnException();
+ throw new InvalidSessionUrnException("SessionUrn was null");
}
SessionUrn urn = new SessionUrn(sessionUrn);
- return urn.asFile();
+ SimpleSessionHandle[] sh = null;
+ try {
+ sh = getSessionManager().getSessionFor(urn);
+ } catch (IOException e)
+ {
+ log.warn("Ignored IO Exception when trying to access sessionlist.",e);
+ }
+ File sesfile = null;
+ if (sh!=null)
+ {
+ if (sh.length==1)
+ {
+ sesfile = new File(sh[0].getPhysLoc());
+ sh[0] = null;
+ } else {
+ log.error("Raising exception for multiple session files corresponding to single URN (was : "+sessionUrn+")");
+ throw new InvalidSessionUrnException("IMPLEMENTATION ERROR: Multiple session files available for URN ("+sessionUrn+")");
+ }
+ }
+ return sesfile;
}
// 3. if it is - locate the file and pass to new VamsasSession
try {
- File sessionDirectory = this.convertSessionUrnToFile(sessionUrn);
+ File sessionDirectory = convertSessionUrnToFile(sessionUrn);
// create session
log
.debug("found session directory "
} else {
vamsasSession = new VamsasSession(sessdir, vamsasDocument);
}
-
- this.getSessionManager().addSession(
- new SessionHandle(new SessionUrn(vamsasSession).getSessionUrn()));
+ getSessionManager().addSession(vamsasSession.getSessionUrn());
if (userId == null) {
// create a default userHandle
// userId = new UserHandle(System.getProperty("user.name",