package uk.ac.vamsas.client.simpleclient;\r
\r
import java.io.File;\r
-import java.io.FileNotFoundException;\r
import java.io.IOException;\r
import java.io.RandomAccessFile;\r
import java.nio.channels.FileChannel;\r
\r
import uk.ac.vamsas.client.ClientHandle;\r
import uk.ac.vamsas.client.Events;\r
-import uk.ac.vamsas.client.IClient;\r
-import uk.ac.vamsas.client.SessionHandle;\r
import uk.ac.vamsas.client.UserHandle;\r
\r
/**\r
protected VamsasSession(File sessionDir1) throws IOException {\r
this(sessionDir1, null);\r
}\r
-\r
+ private SimpleSessionHandle sessionHandle = null;\r
/**\r
* sets up the vamsas session files and watchers in sessionDir1\r
* \r
* new data into session in this way)\r
*/\r
protected VamsasSession(File sessionDir1, File extVamDoc) throws IOException {\r
+ // TODO: refactor to separate extVamDoc path from session URN - enables non-local URLs to be locally bound to sessions.\r
if (sessionDir1 == null)\r
throw new Error("Null directory for VamsasSession.");\r
if (!sessionDir1.exists() && !sessionDir1.mkdir()) {\r
}\r
}\r
this.sessionDir = sessionDir1;\r
+ if (extVamDoc==null) {\r
+ sessionHandle = new SimpleSessionHandle(new SessionUrn(sessionDir).getSessionUrn(),sessionDir);\r
+ } else {\r
+ // Construct Session URN from the original vamsas document.\r
+ sessionHandle = new SimpleSessionHandle(new SessionUrn(extVamDoc).getSessionUrn(),sessionDir);\r
+ }\r
initSessionObjects();\r
if (existingSession) {\r
slog.debug("Initialising additional VamsasSession instance");\r
if (closeSession) {\r
log.debug("Last active client: closing session");\r
log.info("Closing session");\r
- getSessionManager().removeSession(client.getSessionHandle());\r
+ closeSession(client.getSessionHandle());\r
}\r
}\r
\r
* @param sessionHandle\r
* sessionHandle of the session to remove\r
*/\r
- private void closeSession(SessionHandle sessionHandle) {\r
- getSessionManager().removeSession(sessionHandle);\r
- log.debug("Session removed");\r
+ private void closeSession(uk.ac.vamsas.client.SessionHandle sessionHandle) {\r
+ //if (sessionHandle instanceof SimpleSessionHandle)\r
+ //{\r
+ getSessionManager().removeSession(sessionHandle);\r
+ log.debug("Session removed");\r
+ //} else {\r
+ // log.error("Cannot close a sessionHandle (URN="+sessionHandle.getSessionUrn()+") which is of type "+sessionHandle.getClass());\r
+ // throw new Error("Tried to close a non-SimpleClient vamsas sessionHandle");\r
+ //}\r
}\r
\r
/**\r
}\r
return clistWatchElement;\r
}\r
+\r
+ public uk.ac.vamsas.client.simpleclient.SimpleSessionHandle getSessionUrn() {\r
+ return sessionHandle;\r
+ }\r
}\r