/*.................................................................................................................*/ public String jobStatusFromResponse(Document cipresResponseDoc) { String status = "Status not available"; Element element = cipresResponseDoc.getRootElement().element("terminalStage"); if (element != null) { status = element.getText(); if ("true".equalsIgnoreCase(status)) return JOBCOMPLETED; } element = cipresResponseDoc.getRootElement().element("messages"); if (element == null) return status; List entries = element.elements("message"); String reportedJobID = ""; for (Iterator iter = entries.iterator(); iter.hasNext(); ) { Element nextEntry = (Element) iter.next(); if (nextEntry != null) status = nextEntry.elementText("stage"); } element = cipresResponseDoc.getRootElement().element("minPollIntervalSeconds"); if (element != null) { minPollIntervalSeconds = MesquiteInteger.fromString(element.getText()); if (!MesquiteInteger.isCombinable(minPollIntervalSeconds) || minPollIntervalSeconds <= 0) minPollIntervalSeconds = defaultMinPollIntervalSeconds; } if (JOBCOMPLETED.equalsIgnoreCase(status)) return JOBCOMPLETED; return status; }
public void reportError(Document doc, String noteToUser, boolean resetPassword) { if (doc == null) return; String displayMessage = doc.getRootElement().elementText("displayMessage"); String message = doc.getRootElement().elementText("message"); if (StringUtil.notEmpty(message)) { if ("Authentication Error".equalsIgnoreCase(displayMessage)) { if (resetPassword) password = ""; } else { ownerModule.logln("\n******************"); ownerModule.logln(noteToUser); ownerModule.logln(displayMessage); ownerModule.logln(message); List paramErrors = doc.getRootElement().elements("paramError"); if (paramErrors != null) for (Iterator iter = paramErrors.iterator(); iter.hasNext(); ) { Element nextEntry = (Element) iter.next(); String param = nextEntry.elementText("param"); String error = nextEntry.elementText("error"); ownerModule.logln(" " + param + ": " + error); } ownerModule.logln("\n******************\n"); } } }
public String[] getJobURLs(Document cipresResponseDoc) { String elementName = "jobstatus"; Element jobs = cipresResponseDoc.getRootElement().element("jobs"); if (jobs == null) return null; List tools = jobs.elements("jobstatus"); int count = 0; for (Iterator iter = tools.iterator(); iter.hasNext(); ) { Element nextTool = (Element) iter.next(); count++; } String[] url = new String[count]; count = 0; for (Iterator iter = tools.iterator(); iter.hasNext(); ) { Element nextJob = (Element) iter.next(); if (nextJob != null) { Element selfUriElement = nextJob.element("selfUri"); if (selfUriElement != null) { String jobURL = selfUriElement.elementText("url"); if (!StringUtil.blank(jobURL) && count < url.length) { url[count] = jobURL; } } count++; } } return url; }
/** This method simply lists the tools available */ public void listTools(HttpClient httpclient) { Document cipresResponseDoc = cipresQuery(httpclient, baseURL + "/tool", "tools"); if (cipresResponseDoc != null) { String elementName = "tool"; List tools = cipresResponseDoc.getRootElement().elements(elementName); int count = 0; for (Iterator iter = tools.iterator(); iter.hasNext(); ) { // let's get a count as to how many tools there are. Element nextTool = (Element) iter.next(); count++; } String[] toolName = new String[count]; count = 0; for (Iterator iter = tools.iterator(); iter.hasNext(); ) { Element nextTool = (Element) iter.next(); String name = nextTool.elementText("toolId"); if (!StringUtil.blank(name) && count < toolName.length) { ownerModule.logln(name); } name = nextTool.elementText("toolName"); if (!StringUtil.blank(name) && count < toolName.length) { ownerModule.logln(" " + name); } count++; } } }
public void processJobSubmissionResponse(Document cipresResponseDoc, MesquiteString jobURL) { Element element = cipresResponseDoc.getRootElement().element("selfUri"); Element subelement = null; if (element != null) subelement = element.element("url"); if ("false".equals(cipresResponseDoc.getRootElement().elementText("failed"))) { element = cipresResponseDoc.getRootElement().element("metadata"); List entries = element.elements("entry"); String reportedJobID = ""; for (Iterator iter = entries.iterator(); iter.hasNext(); ) { Element nextEntry = (Element) iter.next(); if ("clientJobId".equals(nextEntry.elementText("key"))) reportedJobID = nextEntry.elementText("value"); } ownerModule.logln("\nJob successfully submitted to CIPRes."); ownerModule.logln(" Job URL: " + subelement.getText()); ownerModule.logln(" Job ID: " + reportedJobID + "\n"); if (jobURL != null) jobURL.setValue(subelement.getText()); } }
/** * This processes information about the files contained in either the results or working directory * of a job. */ public CipresJobFile[] processFilesDocument(Document cipresResponseDoc) { Element jobfiles = cipresResponseDoc.getRootElement().element("jobfiles"); if (jobfiles == null) return null; List tools = jobfiles.elements("jobfile"); int count = 0; for (Iterator iter = tools.iterator(); iter.hasNext(); ) { Element nextTool = (Element) iter.next(); count++; } if (count == 0) return null; CipresJobFile[] cipresJobFile = new CipresJobFile[count]; count = 0; for (Iterator iter = tools.iterator(); iter.hasNext(); ) { Element nextJob = (Element) iter.next(); if (nextJob != null) { if (cipresJobFile[count] == null) cipresJobFile[count] = new CipresJobFile(); Element jobFileElement = nextJob.element("downloadUri"); String fileInfo = null; if (jobFileElement != null) { fileInfo = jobFileElement.elementText("url"); if (!StringUtil.blank(fileInfo) && count < cipresJobFile.length) { cipresJobFile[count].setDownloadURL(fileInfo); } fileInfo = jobFileElement.elementText("title"); if (!StringUtil.blank(fileInfo) && count < cipresJobFile.length) { cipresJobFile[count].setDownloadTitle(fileInfo); } } fileInfo = nextJob.elementText("dateModified"); if (!StringUtil.blank(fileInfo) && count < cipresJobFile.length) { cipresJobFile[count].setLastModified(fileInfo); } fileInfo = nextJob.elementText("filename"); if (!StringUtil.blank(fileInfo) && count < cipresJobFile.length) { cipresJobFile[count].setFileName(fileInfo); } fileInfo = nextJob.elementText("length"); if (!StringUtil.blank(fileInfo) && count < cipresJobFile.length) { cipresJobFile[count].setLength(MesquiteLong.fromString(fileInfo)); } count++; } } return cipresJobFile; }