X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fuk%2Fac%2Fvamsas%2Fclient%2Fsimpleclient%2FSessionsFile.java;h=9871bbfc420413673e5c6232ed51beed2f7f9ed7;hb=HEAD;hp=57303179f6406ef20f0aec7cef7db2175b722035;hpb=844ccad5a3fcbedec17b2af66d460f31abc7cff1;p=vamsas.git
diff --git a/src/uk/ac/vamsas/client/simpleclient/SessionsFile.java b/src/uk/ac/vamsas/client/simpleclient/SessionsFile.java
index 5730317..9871bbf 100644
--- a/src/uk/ac/vamsas/client/simpleclient/SessionsFile.java
+++ b/src/uk/ac/vamsas/client/simpleclient/SessionsFile.java
@@ -1,6 +1,6 @@
/*
- * This file is part of the Vamsas Client version 0.1.
- * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite,
+ * This file is part of the Vamsas Client version 0.2.
+ * Copyright 2010 by Jim Procter, Iain Milne, Pierre Marguerite,
* Andrew Waterhouse and Dominik Lindner.
*
* Earlier versions have also been incorporated into Jalview version 2.4
@@ -26,11 +26,13 @@ import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
+import java.net.URL;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import uk.ac.vamsas.client.SessionHandle;
+import uk.ac.vamsas.client.simpleclient.SimpleSessionHandle;
/**
* @author Pierre MARGUERITE
@@ -67,10 +69,10 @@ public class SessionsFile extends ListFile {
*
* @return list of clients
*/
- private SessionHandle[] retrieveSessionHandles() {
+ private SimpleSessionHandle[] retrieveSessionHandles() {
if (lockFile()) {
try {
- SessionHandle[] sessions = null;
+ SimpleSessionHandle[] sessions = null;
if (this.fileLock.length() > 0) {
ObjectInputStream is = new ObjectInputStream(this.fileLock
@@ -79,7 +81,30 @@ public class SessionsFile extends ListFile {
o = is.readObject();
if (o != null) {
try {
- sessions = (SessionHandle[]) o;
+ if (o instanceof SimpleSessionHandle[]) {
+ sessions = (SimpleSessionHandle[]) o;
+ } else {
+ // legacy support or incorrect path.
+ if (o instanceof SessionHandle[]) {
+ log.info("Importing VAMSAS 0.1 clientHandle list.");
+ SessionHandle[] oldsess = (SessionHandle[]) o;
+ File sessdir;
+ sessions = new SimpleSessionHandle[oldsess.length];
+ for (int s=0;s sessions.length)
- || !sessions[this.syncnum - 1].equals(session)) {
+ || !session.equals(sessions[this.syncnum - 1])) {
for (int i = 0, j = sessions.length; i < j; i++) {
if (sessions[i].equals(session)) {
mynum = i;
@@ -191,7 +216,7 @@ public class SessionsFile extends ListFile {
}
if (mynum > -1) {
- SessionHandle[] newlist = new SessionHandle[sessions.length - 1];
+ SimpleSessionHandle[] newlist = new SimpleSessionHandle[sessions.length - 1];
for (int k = 0, i = 0, j = sessions.length; i < j; i++)
if (i != mynum)
newlist[k++] = sessions[i];
@@ -223,7 +248,7 @@ public class SessionsFile extends ListFile {
* @return index of sessionHandle in new list, or -1-position of existing
* sessionHandle (if disambiguate is true)
*/
- protected int addSession(SessionHandle session, boolean disambiguate) {
+ protected int addSession(SimpleSessionHandle session, boolean disambiguate) {
int newsession = 0;
int tries = 5;
while (tries-- > 0 && !lockFile())
@@ -233,10 +258,10 @@ public class SessionsFile extends ListFile {
}
;
if (lockFile()) {
- SessionHandle[] sessions = retrieveSessionHandles();
+ SimpleSessionHandle[] sessions = retrieveSessionHandles();
if (sessions == null) {
- sessions = new SessionHandle[1];
+ sessions = new SimpleSessionHandle[1];
sessions[0] = session;
newsession = 1;
} else {
@@ -258,7 +283,7 @@ public class SessionsFile extends ListFile {
}
}
int i, j;
- SessionHandle[] newlist = new SessionHandle[sessions.length + 1];
+ SimpleSessionHandle[] newlist = new SimpleSessionHandle[sessions.length + 1];
for (i = 0, j = sessions.length; i < j; i++)
newlist[i] = sessions[i];
newlist[j] = session;
@@ -277,7 +302,7 @@ public class SessionsFile extends ListFile {
* @param clients
* @return true if successful write. Throws Errors otherwise.
*/
- protected boolean putSessionsList(SessionHandle[] clients) {
+ protected boolean putSessionsList(SimpleSessionHandle[] clients) {
if (lockFile()) {
File templist = null;
if (!this.backup || (templist = backupSessionFile()) != null) {