+/*******************************************************************************
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
+ * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ *******************************************************************************/
package jalview.ws.rest;
import jalview.bin.Cache;
{
String postUrl = rj.getPostUrl();
doHttpReq(Stage.SUBMIT, rj, postUrl);
+ wsInfo.invalidate();
}
/**
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. <br>Problematic url was <a href=\""
+ + request.getURI() + "\">" + request.getURI()
+ + "</a><br>See Console output for details.";
rj.setAllowedServerExceptions(0);// unrecoverable;
rj.error = true;
Cache.log.fatal("Unexpected REST Job " + getStage(stg)
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. <br>Problematic url was <a href=\""
+ + request.getURI() + "\">" + request.getURI()
+ + "</a><br>See Console output for details.";
Cache.log.warn("IO Exception for REST Job " + getStage(stg)
+ "exception for URL " + rj.rsd.postUrl);
// 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.<br/>Url concerned was <a href=\""
+ + request.getURI()
+ + "\">"
+ + request.getURI()
+ + "</a><br/>Filtered response content below:<br/>");
} catch (IOException e)
{
Cache.log.debug("IOException when consuming unhandled response",
int body = f.indexOf("<body");
if (body > -1)
{
- content.delete(0, f.indexOf(">", body));
+ content.delete(0, f.indexOf(">", body) + 1);
}
if (body > -1 && sb.length() > 0)
{
{
System.err.println("Debug RestJob: Posting Job");
doPost((RestJob) job);
+ } catch (NoValidInputDataException erex)
+ {
+ job.setSubjobComplete(true);
+ job.setSubmitted(true);
+ ((RestJob) job).statMessage = "<br>It looks like there was a problem with the data sent to the service :<br>"
+ + erex.getMessage() + "\n";
+ ((RestJob) job).error = true;
+
} catch (Exception ex)
{
job.setSubjobComplete(true);
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.<br>URL for job response is :<a href=\""
+ + rj.resSet.getUrl()
+ + "\">"
+ + rj.resSet.getUrl()
+ + "</a><br>";
}
}
}
*/
if (true)
{
- wsInfo.setViewResultsImmediatly(false);
+ // preserver current jalview behaviour
+ wsInfo.setViewResultsImmediatly(true);
}
else
{
else
{
// tell the user nothing was returned.
+ wsInfo.setStatus(wsInfo.STATE_STOPPED_ERROR);
+ wsInfo.setFinishedNoResults();
}
}
visgrps.add(exsg);
exsg.setStartRes(sg.getStartRes() + contigs[ncnt]);
exsg.setEndRes(sg.getEndRes() + contigs[ncnt]);
- } else {
+ }
+ else
+ {
recovered = true;
}
// now replace any references from the result set with
visan.sequenceRef = sqass;
visAlAn.add(visan);
}
- if (contigs[ncnt]+alan[nrj][an].annotations.length>visan.annotations.length)
+ 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;
+ 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,
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:
destcs = destColsel.get(als);
destaf = new AlignFrame(destal, destcs, AlignFrame.DEFAULT_WIDTH,
AlignFrame.DEFAULT_HEIGHT);
- PaintRefresher.Refresh(destaf, destaf.getViewport().getSequenceSetId());
+ PaintRefresher.Refresh(destaf, destaf.getViewport()
+ .getSequenceSetId());
// todo transfer any feature settings and colouring
/*
* destaf.getFeatureRenderer().transferSettings(this.featureSettings);
* 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;
*/
public boolean isValid()
{
+ ArrayList<String> _warnings = new ArrayList<String>();
+ boolean validt = true;
if (jobs != null)
{
for (RestJob rj : (RestJob[]) jobs)
{
// 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 : "";
}
}