+
+
+ protected void releaseActiveClientFile() throws IOException
+ {
+
+ log.debug("Releasing active client locks");
+ if( activeClientFilelock != null)
+ {// Release the lock
+ log.debug("Releasing lock on active client lock file");
+ activeClientFilelock.release();
+ log.debug("ReleaseActiveClientFile called when client has no lock on its clientLockFile");
+ activeClientFilelock = null;
+ } else {
+ log.debug("ReleaseActiveClientFile called when client has no lock on its clientLockFile");
+ }
+ if (this.clientlockFile != null)
+ {
+ log.debug("trying to delete active client lock file");
+ if (this.clientlockFile.exists())
+ {
+ this.clientlockFile.delete();
+ log.debug("deleted active client lock file");
+ }
+ } else {
+ log.debug("ReleaseActiveClientFile called when client has no clientLockFile");
+ }
+ }
+
+ protected void createActiveClientFile() throws IOException
+ {
+ if(this.clientlockFile != null )return;
+ log.debug("createActiveClientFile");
+ //create, if need, subdirectory to contain client files
+ File clientlockFileDir = new File ( this.get_session().sessionDir, this.get_session().clientFileDirectory);
+ if( !clientlockFileDir.exists())
+ {//the directory does not exist, create it
+ if (! clientlockFileDir.mkdirs())
+ {
+ throw new IOException("Failed to create sub directory to session directory for client lock files'"+clientlockFileDir.getAbsolutePath()+"'");
+ }
+ }
+ else
+ {
+ if (!(clientlockFileDir.isDirectory() && clientlockFileDir.canWrite()))
+ {
+ throw new IOException("Directory for client lock files is not a directory or is not accessibl: '"+clientlockFileDir.getAbsolutePath()+"'");
+ }
+ }
+ this.clientlockFile = new File (clientlockFileDir, this.getClientHandle().getClientUrn().replaceAll("[:;/\\\\]+",""));
+
+ log.debug("Creating active client lock file "+ this.clientlockFile.getAbsolutePath());
+ Lock clientLock = uk.ac.vamsas.client.simpleclient.LockFactory.getLock(clientlockFile, false);
+ if (clientLock==null || !clientLock.isLocked())
+ {
+ log.fatal("IMPLEMENTATION ERROR: Couldn't get a lock for the client lock file "+clientlockFile);
+ }
+ activeClientFilelock = clientLock;
+ }
+ /**
+ * @return the clientlockFile
+ */
+ protected File getClientlockFile() {
+ return clientlockFile;
+ }
+ /**
+ *
+ * @return the lock for the client in the session
+ */
+ protected Lock getClientLock() {
+ return activeClientFilelock;
+ }
+