X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fws%2Frest%2FRestJobThread.java;h=2aa071dd95e6c84bc95fc06756df546cb263093a;hb=b2f9a8d7bce642ff4011bc6d49e02bb0569fbb11;hp=581af9ab2cb5f51b6c9a200fc806e5fe9fba496a;hpb=d57c42c2998cafdf8f6874a3b85aa61823819f7d;p=jalview.git
diff --git a/src/jalview/ws/rest/RestJobThread.java b/src/jalview/ws/rest/RestJobThread.java
index 581af9a..2aa071d 100644
--- a/src/jalview/ws/rest/RestJobThread.java
+++ b/src/jalview/ws/rest/RestJobThread.java
@@ -1,3 +1,21 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.1)
+ * Copyright (C) 2014 The Jalview Authors
+ *
+ * This file is part of Jalview.
+ *
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * Jalview is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with Jalview. If not, see .
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
package jalview.ws.rest;
import jalview.bin.Cache;
@@ -11,6 +29,7 @@ import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
import jalview.gui.AlignFrame;
import jalview.gui.Desktop;
+import jalview.gui.PaintRefresher;
import jalview.gui.WebserviceInfo;
import jalview.io.NewickFile;
import jalview.io.packed.JalviewDataset;
@@ -22,11 +41,9 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.Enumeration;
import java.util.Hashtable;
import java.util.List;
import java.util.Map.Entry;
-import java.util.Vector;
import org.apache.axis.transport.http.HTTPConstants;
import org.apache.http.Header;
@@ -50,7 +67,7 @@ public class RestJobThread extends AWSThread
SUBMIT, POLL
}
- protected RestClient restClient;;
+ protected RestClient restClient;
public RestJobThread(RestClient restClient)
{
@@ -176,6 +193,7 @@ public class RestJobThread extends AWSThread
{
String postUrl = rj.getPostUrl();
doHttpReq(Stage.SUBMIT, rj, postUrl);
+ wsInfo.invalidate();
}
/**
@@ -236,8 +254,10 @@ public class RestJobThread extends AWSThread
response = httpclient.execute(request);
} catch (ClientProtocolException he)
{
- rj.statMessage = "Web Protocol Exception when attempting to "
- + getStage(stg) + "Job. See Console output for details.";
+ rj.statMessage = "Web Protocol Exception when " + getStage(stg)
+ + "Job.
Problematic url was " + request.getURI()
+ + "
See Console output for details.";
rj.setAllowedServerExceptions(0);// unrecoverable;
rj.error = true;
Cache.log.fatal("Unexpected REST Job " + getStage(stg)
@@ -245,8 +265,10 @@ public class RestJobThread extends AWSThread
throw (he);
} catch (IOException e)
{
- rj.statMessage = "IO Exception when attempting to "
- + getStage(stg) + "Job. See Console output for details.";
+ rj.statMessage = "IO Exception when " + getStage(stg)
+ + "Job.
Problematic url was " + request.getURI()
+ + "
See Console output for details.";
Cache.log.warn("IO Exception for REST Job " + getStage(stg)
+ "exception for URL " + rj.rsd.postUrl);
@@ -303,9 +325,22 @@ public class RestJobThread extends AWSThread
// TODO: deal with all other HTTP response codes from server.
Cache.log.warn("Unhandled response status when " + getStage(stg)
+ "for " + postUrl + ": " + response.getStatusLine());
+ rj.error = true;
+ rj.setAllowedServerExceptions(0);
+ rj.setSubjobComplete(true);
+ rj.setSubmitted(true);
try
{
- response.getEntity().consumeContent();
+ completeStatus(
+ rj,
+ response,
+ ""
+ + getStage(stg)
+ + " resulted in an unexpected server response.
Url concerned was "
+ + request.getURI()
+ + "
Filtered response content below:
");
} catch (IOException e)
{
Cache.log.debug("IOException when consuming unhandled response",
@@ -375,7 +410,7 @@ public class RestJobThread extends AWSThread
int body = f.indexOf("
-1)
{
- content.delete(0, f.indexOf(">", body));
+ content.delete(0, f.indexOf(">", body) + 1);
}
if (body > -1 && sb.length() > 0)
{
@@ -403,6 +438,14 @@ public class RestJobThread extends AWSThread
{
System.err.println("Debug RestJob: Posting Job");
doPost((RestJob) job);
+ } catch (NoValidInputDataException erex)
+ {
+ job.setSubjobComplete(true);
+ job.setSubmitted(true);
+ ((RestJob) job).statMessage = "
It looks like there was a problem with the data sent to the service :
"
+ + erex.getMessage() + "\n";
+ ((RestJob) job).error = true;
+
} catch (Exception ex)
{
job.setSubjobComplete(true);
@@ -443,6 +486,14 @@ public class RestJobThread extends AWSThread
Cache.log.warn("Failed to finish parsing data for job "
+ rj.getJobId());
ex.printStackTrace();
+ } finally
+ {
+ rj.error = true;
+ rj.statMessage = "Error whilst parsing data for this job.
URL for job response is :"
+ + rj.resSet.getUrl()
+ + "
";
}
}
}
@@ -458,7 +509,8 @@ public class RestJobThread extends AWSThread
*/
if (true)
{
- wsInfo.setViewResultsImmediatly(false);
+ // preserver current jalview behaviour
+ wsInfo.setViewResultsImmediatly(true);
}
else
{
@@ -494,6 +546,8 @@ public class RestJobThread extends AWSThread
else
{
// tell the user nothing was returned.
+ wsInfo.setStatus(wsInfo.STATE_STOPPED_ERROR);
+ wsInfo.setFinishedNoResults();
}
}
@@ -786,7 +840,6 @@ public class RestJobThread extends AWSThread
if (sg.getName() != null)
{
exsg = groupNames.get(sg.getName());
- recovered = true;
}
if (exsg == null)
{
@@ -796,16 +849,18 @@ public class RestJobThread extends AWSThread
exsg.setStartRes(sg.getStartRes() + contigs[ncnt]);
exsg.setEndRes(sg.getEndRes() + contigs[ncnt]);
}
+ else
+ {
+ recovered = true;
+ }
// now replace any references from the result set with
// corresponding refs from alignment input set.
// TODO: cope with recovering hidden sequences from
// resultContext
{
- Vector sqs = sg.getSequences(null);
- for (int sqsi = 0, iSize = sqs.size(); sqsi < iSize; sqsi++)
+ for (SequenceI oseq : sg.getSequences(null))
{
- SequenceI oseq = (SequenceI) sqs.get(sqsi);
SequenceI nseq = getNewSeq(oseq, rseqs[nrj],
ordermap[nrj], destAl);
if (nseq != null)
@@ -923,6 +978,15 @@ public class RestJobThread extends AWSThread
visan.sequenceRef = sqass;
visAlAn.add(visan);
}
+ if (contigs[ncnt] + alan[nrj][an].annotations.length > visan.annotations.length)
+ {
+ // increase width of annotation row
+ Annotation[] newannv = new Annotation[contigs[ncnt]
+ + alan[nrj][an].annotations.length];
+ System.arraycopy(visan.annotations, 0, newannv, 0,
+ visan.annotations.length);
+ visan.annotations = newannv;
+ }
// now copy local annotation data into correct position
System.arraycopy(alan[nrj][an].annotations, 0,
visan.annotations, contigs[ncnt],
@@ -977,7 +1041,7 @@ public class RestJobThread extends AWSThread
ColumnSelection destcs;
String alTitle = restClient.service.details.Action + " using "
+ restClient.service.details.Name + " on "
- + " whatever you clicked on." + "(set " + als + ")";
+ + restClient.viewTitle;
switch (action)
{
case newAlignment:
@@ -985,6 +1049,8 @@ public class RestJobThread extends AWSThread
destcs = destColsel.get(als);
destaf = new AlignFrame(destal, destcs, AlignFrame.DEFAULT_WIDTH,
AlignFrame.DEFAULT_HEIGHT);
+ PaintRefresher.Refresh(destaf, destaf.getViewport()
+ .getSequenceSetId());
// todo transfer any feature settings and colouring
/*
* destaf.getFeatureRenderer().transferSettings(this.featureSettings);
@@ -1004,12 +1070,14 @@ public class RestJobThread extends AWSThread
* i++) { af.addSortByOrderMenuItem( WebServiceName + ((String)
* names.get(i)) + " Ordering", (AlignmentOrder) alorders.get(i)); } } }
*/
+ // TODO: modify this and previous alignment's title if many alignments
+ // have been returned.
Desktop.addInternalFrame(destaf, alTitle, AlignFrame.DEFAULT_WIDTH,
AlignFrame.DEFAULT_HEIGHT);
break;
case newView:
-
+ // TODO: determine title for view
break;
case currentView:
break;
@@ -1183,6 +1251,8 @@ public class RestJobThread extends AWSThread
*/
public boolean isValid()
{
+ ArrayList _warnings = new ArrayList();
+ boolean validt = true;
if (jobs != null)
{
for (RestJob rj : (RestJob[]) jobs)
@@ -1191,14 +1261,48 @@ public class RestJobThread extends AWSThread
{
// invalid input for this job
System.err.println("Job " + rj.getJobnum()
- + " has invalid input.");
- return false;
+ + " has invalid input. ( " + rj.getStatus() + ")");
+ if (rj.hasStatus() && !_warnings.contains(rj.getStatus()))
+ {
+ _warnings.add(rj.getStatus());
+ }
+ validt = false;
}
}
- return true;
}
+ if (!validt)
+ {
+ warnings = "";
+ for (String st : _warnings)
+ {
+ if (warnings.length() > 0)
+ {
+ warnings += "\n";
+ }
+ warnings += st;
+
+ }
+ }
+ return validt;
+ }
+
+ protected String warnings;
+
+ public boolean hasWarnings()
+ {
// TODO Auto-generated method stub
- return false;
+ return warnings != null && warnings.length() > 0;
+ }
+
+ /**
+ * get any informative messages about why the job thread couldn't start.
+ *
+ * @return
+ */
+ public String getWarnings()
+ {
+ return isValid() ? "Job can be started. No warnings."
+ : hasWarnings() ? warnings : "";
}
}