more bugfixes.
authorjprocter <Jim Procter>
Tue, 6 Feb 2007 17:27:05 +0000 (17:27 +0000)
committerjprocter <Jim Procter>
Tue, 6 Feb 2007 17:27:05 +0000 (17:27 +0000)
src/jalview/gui/UserQuestionnaireCheck.java

index 338ad6e..902b2a5 100644 (file)
@@ -34,14 +34,14 @@ public class UserQuestionnaireCheck implements Runnable {
             if (qresp.indexOf("NOTYET:")==0) {
                 prompt=true; // not yet responded under that ID
             } else {
-                if (qresp.indexOf("RESPONDED:")==-1) {
-                    // may be a qid:rid for the latest questionnaire.
-                    // check if response is of form we expect.
-                    if (qresp.indexOf(':')>-1) {
+                if (qresp.indexOf("QUESTIONNAIRE:")==0) {
+                    // QUESTIONNAIRE:qid:rid for the latest questionnaire.
+                    int p=qresp.indexOf(':',14);
+                    if (p>-1) {
                         rid=null;
-                        qid=qresp.substring(0,qresp.indexOf(':'));
-                        if (qresp.indexOf(':')<(qresp.length()-1)) {
-                            rid = qresp.substring(qresp.indexOf(':')+1);
+                        qid=qresp.substring(14,p);
+                        if (p<(qresp.length()-1)) {
+                            rid = qresp.substring(p+1);
                             prompt=true; // this is a new qid/rid pair
                         }
                     }
@@ -65,20 +65,22 @@ public class UserQuestionnaireCheck implements Runnable {
                 String qurl=url+(url.indexOf('?')>-1 ? "&" : "?") +"checkresponse=1";
                 // query the server with the old qid/id pair
                 String qqid = lastq.indexOf(':')>-1 ? lastq.substring(0,lastq.indexOf(':')) : null;
-                if (qqid!=null && qqid.length()>0) {
+                if (qqid!=null && qqid!="null" && qqid.length()>0) {
                     qurl+="&qid="+qqid;
                     qid=qqid;
-                }
-                String qrid = lastq.substring(lastq.indexOf(':')+1); // retrieve old rid
-                if (qrid!=null && !qrid.equals("null")) {
-                    rid=qrid;
-                    qurl+="&rid="+qrid;
+                    String qrid = lastq.substring(lastq.indexOf(':')+1); // retrieve old rid
+                    if (qrid!=null && !qrid.equals("null")) {
+                        rid=qrid;
+                        qurl+="&rid="+qrid;
+                    }
                 }
                 // see if we have already responsed to this questionnaire.
                 prompt = checkresponse(new URL(qurl));
             }
-            // Update our local property cache with latest qid and rid
-            jalview.bin.Cache.setProperty("QUESTIONNAIRE",qid+":"+rid);
+            if (qid!=null && rid!=null) {
+                // Update our local property cache with latest qid and rid
+                jalview.bin.Cache.setProperty("QUESTIONNAIRE",qid+":"+rid);
+            }
             if (prompt) {
                 String qurl = url+(url.indexOf('?')>-1 ? "&" : "?") + "qid="+qid+"&rid="+rid;
                 jalview.bin.Cache.log.info("Prompting user for questionnaire at "+qurl);