/*.................................................................................................................*/
 public boolean downloadWorkingResults(
     HttpClient httpclient,
     String jobURL,
     String rootDir,
     String fileName,
     boolean onlyNewOrModified) {
   if (StringUtil.blank(fileName)) return false;
   String workingUri = getWorkingDirectory(jobURL);
   if (StringUtil.notEmpty(workingUri)) {
     Document cipresResponseDoc = cipresQuery(httpclient, workingUri, "workingdir");
     if (cipresResponseDoc != null) {
       CipresJobFile[] cipresJobFiles = processFilesDocument(cipresResponseDoc);
       if (cipresJobFiles == null || cipresJobFiles.length == 0) {
         return false;
       }
       for (int job = 0; job < cipresJobFiles.length; job++) {
         if (fileName.equalsIgnoreCase(cipresJobFiles[job].getFileName())
             && (!onlyNewOrModified
                 || fileNewOrModified(previousCipresJobFiles, cipresJobFiles, job)))
           cipresDownload(
               httpclient,
               cipresJobFiles[job].getDownloadURL(),
               rootDir + cipresJobFiles[job].getFileName());
       }
       previousCipresJobFiles = cipresJobFiles.clone();
       return true;
     }
   }
   return false;
 }
 /**
  * this is the primary method that sends a query to the CIPRes REST service. It expects to receive
  * an XML file, which it returns in Document if the root tag matc hes xmlRootTag
  */
 public Document cipresQuery(HttpClient httpclient, String URL, String xmlRootTag) {
   if (StringUtil.blank(URL)) return null;
   try {
     HttpGet httpget = new HttpGet(URL);
     httpget.addHeader("cipres-appkey", CIPRESkey);
     try {
       HttpResponse response = httpclient.execute(httpget);
       HttpEntity responseEntity = response.getEntity();
       InputStream instream = responseEntity.getContent();
       BufferedReader br = new BufferedReader(new InputStreamReader(instream));
       String line = "";
       StringBuffer sb = new StringBuffer();
       while ((line = br.readLine()) != null) {
         sb.append(line + StringUtil.lineEnding());
       }
       Document cipresResponseDoc = loadXMLFile(xmlRootTag, sb.toString());
       if (cipresResponseDoc != null && verbose) {
         ownerModule.logln(sb.toString());
       }
       if (cipresResponseDoc == null) {
         Document errorDoc = loadXMLFile(sb.toString());
         if (errorDoc != null) reportError(errorDoc, "Error in communicating with CIPRes", true);
       }
       EntityUtils.consume(response.getEntity());
       return cipresResponseDoc;
     } catch (IOException e) {
       Debugg.printStackTrace(e);
     } catch (Exception e) {
       Debugg.printStackTrace(e);
     }
   } catch (Exception e) {
     Debugg.printStackTrace(e);
   }
   return null;
 }
Example #3
0
  /*.................................................................................................................*/
  public void actionPerformed(ActionEvent e) {
    if (e.getActionCommand().equalsIgnoreCase("setToDefaults")) {
      setDefaultTNTCommandsSearchOptions();
      searchField.setText(searchArguments);
      bootstrapSearchField.setText(bootstrapSearchArguments);
      harvestOnlyStrictConsensusBox.setState(harvestOnlyStrictConsensus);
      resamplingAllConsensusTreesBox.setState(!resamplingAllConsensusTrees);
      bootStrapRepsField.setValue(bootstrapreps);

    } else if (e.getActionCommand().equalsIgnoreCase("setToDefaultsOtherOptions")) {
      setDefaultTNTCommandsOtherOptions();
      otherOptionsField.setText(otherOptions);
      convertGapsBox.setState(convertGapsToMissing);
    } else if (e.getActionCommand().equalsIgnoreCase("browseSearchScript")
        && searchScriptPathField != null) {
      MesquiteString directoryName = new MesquiteString();
      MesquiteString fileName = new MesquiteString();
      String path =
          MesquiteFile.openFileDialog("Choose Search Script File", directoryName, fileName);
      if (StringUtil.notEmpty(path)) searchScriptPathField.setText(path);
    } else if (e.getActionCommand().equalsIgnoreCase("browseBootSearchScript")
        && bootSearchScriptPathField != null) {

      MesquiteString directoryName = new MesquiteString();
      MesquiteString fileName = new MesquiteString();
      String path =
          MesquiteFile.openFileDialog(
              "Choose Resampling Search Script File", directoryName, fileName);
      if (StringUtil.notEmpty(path)) bootSearchScriptPathField.setText(path);
    }
  }
 /*.................................................................................................................*/
 boolean checkUsernamePassword(boolean tellUserAboutCipres) {
   if (StringUtil.blank(username) || StringUtil.blank(password)) {
     MesquiteBoolean answer = new MesquiteBoolean(false);
     MesquiteString usernameString = new MesquiteString();
     if (username != null) usernameString.setValue(username);
     MesquiteString passwordString = new MesquiteString();
     if (password != null) passwordString.setValue(password);
     String help =
         "You will need an account on the CIPRes REST system to use this service.  To register, go to https://www.phylo.org/restusers/register.action";
     new UserNamePasswordDialog(
         ownerModule.containerOfModule(),
         "Sign in to CIPRes",
         help,
         "",
         "Username",
         "Password",
         answer,
         usernameString,
         passwordString);
     if (answer.getValue()) {
       username = usernameString.getValue();
       password = passwordString.getValue();
     }
     ownerModule.storePreferences();
   }
   boolean success = StringUtil.notEmpty(username) && StringUtil.notEmpty(password);
   if (!success && tellUserAboutCipres) {
     MesquiteMessage.discreetNotifyUser(
         "Use of the CIPRes service requires an account with CIPRes's REST service.  Go to https://www.phylo.org/restusers/register.action to register for an account");
   }
   return success;
 }
  /** Create LockssKeystore from a config subtree */
  LockssKeyStore createLockssKeyStore(Configuration config) {
    log.debug2("Creating LockssKeyStore from config: " + config);
    String name = config.get(KEYSTORE_PARAM_NAME);
    LockssKeyStore lk = new LockssKeyStore(name);

    String file = config.get(KEYSTORE_PARAM_FILE);
    String resource = config.get(KEYSTORE_PARAM_RESOURCE);
    String url = config.get(KEYSTORE_PARAM_URL);

    if (!StringUtil.isNullString(file)) {
      lk.setLocation(file, LocationType.File);
    } else if (!StringUtil.isNullString(resource)) {
      lk.setLocation(resource, LocationType.Resource);
    } else if (!StringUtil.isNullString(url)) {
      lk.setLocation(url, LocationType.Url);
    }

    lk.setType(config.get(KEYSTORE_PARAM_TYPE, defaultKeyStoreType));
    lk.setProvider(config.get(KEYSTORE_PARAM_PROVIDER, defaultKeyStoreProvider));
    lk.setPassword(config.get(KEYSTORE_PARAM_PASSWORD));
    lk.setKeyPassword(config.get(KEYSTORE_PARAM_KEY_PASSWORD));
    lk.setKeyPasswordFile(config.get(KEYSTORE_PARAM_KEY_PASSWORD_FILE));
    lk.setMayCreate(config.getBoolean(KEYSTORE_PARAM_CREATE, DEFAULT_CREATE));
    return lk;
  }
 /** 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++;
     }
   }
 }
 void setConfig(Configuration config) {
   log.debug("config: " + config);
   proxyHost = config.get(PARAM_PROXY_HOST);
   proxyPort = config.getInt(PARAM_PROXY_PORT, DEFAULT_PROXY_PORT);
   if (StringUtil.isNullString(proxyHost) || proxyPort <= 0) {
     String http_proxy = System.getenv("http_proxy");
     if (!StringUtil.isNullString(http_proxy)) {
       try {
         HostPortParser hpp = new HostPortParser(http_proxy);
         proxyHost = hpp.getHost();
         proxyPort = hpp.getPort();
       } catch (HostPortParser.InvalidSpec e) {
         log.warning("Can't parse http_proxy environment var, ignoring: " + http_proxy + ": " + e);
       }
     }
   }
   if (StringUtil.isNullString(proxyHost) || proxyPort <= 0) {
     proxyHost = null;
   } else {
     log.info("Proxying through " + proxyHost + ":" + proxyPort);
   }
   userAgent = config.get(PARAM_USER_AGENT);
   if (StringUtil.isNullString(userAgent)) {
     userAgent = null;
   } else {
     log.debug("Setting User-Agent to " + userAgent);
   }
 }
Example #8
0
 public void processCompletedOutputFiles(String[] outputFilePaths) {
   if (outputFilePaths.length > 1 && !StringUtil.blank(outputFilePaths[1])) {
     ZephyrUtil.copyLogFile(this, "TNT", outputFilePaths[1]);
   }
   if (outputFilePaths.length > 2 && !StringUtil.blank(outputFilePaths[2])) {
     ZephyrUtil.copyOutputText(this, outputFilePaths[2], commands);
   }
 }
  /**
   * Did the client provide the minimal parameters required?
   *
   * @return true If so
   */
  private boolean verifyMinimumParameters() {
    int count = 0;

    if (!StringUtil.isNullString(getParameter(AP_E_PUBLICATION))) count++;
    if (!StringUtil.isNullString(getParameter(AP_E_CLASSNAME))) count++;
    if (!StringUtil.isNullString(getParameter(AP_E_PLUGIN))) count++;

    return (count > 0);
  }
Example #10
0
 /** Concatenate params for URL string */
 static String concatParams(String p1, String p2) {
   if (StringUtil.isNullString(p1)) {
     return p2;
   }
   if (StringUtil.isNullString(p2)) {
     return p1;
   }
   return p1 + "&" + p2;
 }
 public void testFilterE() throws Exception {
   InputStream in;
   // all these should match, once filtered, the string HtmlHashEFiltered
   in = fact.createFilteredInputStream(mau, new StringInputStream(HtmlHashE), ENC);
   String filtStr = StringUtil.fromInputStream(in);
   assertEquals(HtmlHashEFiltered, filtStr);
   in = fact.createFilteredInputStream(mau, new StringInputStream(HtmlHashF), ENC);
   filtStr = StringUtil.fromInputStream(in);
   assertEquals(HtmlHashEFiltered, filtStr);
   in = fact.createFilteredInputStream(mau, new StringInputStream(HtmlHashG), ENC);
   filtStr = StringUtil.fromInputStream(in);
   assertEquals(HtmlHashEFiltered, filtStr);
   in = fact.createFilteredInputStream(mau, new StringInputStream(HtmlHashH), ENC);
   filtStr = StringUtil.fromInputStream(in);
   assertEquals(HtmlHashEFiltered, filtStr);
   in = fact.createFilteredInputStream(mau, new StringInputStream(HtmlHashI), ENC);
   filtStr = StringUtil.fromInputStream(in);
   assertEquals(HtmlHashEFiltered, filtStr);
   in = fact.createFilteredInputStream(mau, new StringInputStream(HtmlHashJ), ENC);
   filtStr = StringUtil.fromInputStream(in);
   assertEquals(HtmlHashEFiltered, filtStr);
   in = fact.createFilteredInputStream(mau, new StringInputStream(HtmlHashK), ENC);
   filtStr = StringUtil.fromInputStream(in);
   assertEquals(HtmlHashEFiltered, filtStr);
   in = fact.createFilteredInputStream(mau, new StringInputStream(HtmlHashL), ENC);
   filtStr = StringUtil.fromInputStream(in);
   assertEquals(HtmlHashEFiltered, filtStr);
   in = fact.createFilteredInputStream(mau, new StringInputStream(HtmlHashO), ENC);
   filtStr = StringUtil.fromInputStream(in);
   assertEquals(HtmlHashEFiltered, filtStr);
 }
Example #12
0
 /**
  * シートのクローンを行う
  *
  * @param workbook ワークブック
  * @param insertSheetId シートの挿入先番号
  * @param from コピー元のシート名
  * @param to 追加するシート名
  * @return 追加するシート
  */
 public static XSSFSheet cloneSheet(
     XSSFWorkbook workbook, int insertSheetId, String from, String to) {
   assert workbook != null && StringUtil.isNotEmpty(from) && StringUtil.isNotEmpty(to);
   int sheetId = workbook.getSheetIndex(from);
   XSSFSheet clone = workbook.cloneSheet(sheetId);
   String cloneName = clone.getSheetName();
   workbook.setSheetOrder(cloneName, insertSheetId);
   workbook.setSheetName(insertSheetId, to);
   int newSheetId = workbook.getSheetIndex(to);
   return workbook.getSheetAt(newSheetId);
 }
Example #13
0
 private StringSet getStringSet(String key, String deli) {
   StringSet set = new StringSet();
   String v = getValue(key);
   if (v != null) {
     String[] vv = StringUtil.split(v, deli);
     for (String x : vv) {
       x = StringUtil.trimToEmpty(x);
       if (x.length() > 0) set.put(x);
     }
   }
   return set;
 }
  public void testFiltering() throws IOException {
    Reader readerA;
    Reader readerB;

    readerA = rule.createFilteredReader(new StringReader(inst1));
    readerB = rule.createFilteredReader(new StringReader(inst2));
    assertEquals(StringUtil.fromReader(readerA), StringUtil.fromReader(readerB));

    readerA = rule.createFilteredReader(new StringReader(inst1));
    readerB = rule.createFilteredReader(new StringReader(inst3));
    assertEquals(StringUtil.fromReader(readerA), StringUtil.fromReader(readerB));
  }
Example #15
0
 private void doSleep() throws IOException {
   String timestr = getParameter(KEY_TIME);
   try {
     long time = StringUtil.parseTimeInterval(timestr);
     Deadline.in(time).sleep();
     statusMsg = "Slept for " + StringUtil.timeIntervalToString(time);
   } catch (NumberFormatException e) {
     errMsg = "Illegal duration: " + e;
   } catch (InterruptedException e) {
     errMsg = "Interrupted: " + e;
   }
 }
  public void testFilterViewedBy() throws Exception {
    InputStream in;
    String filtStr = null;

    in = fact.createFilteredInputStream(mau, new StringInputStream(HtmlHashN), ENC);
    filtStr = StringUtil.fromInputStream(in);
    assertEquals(HtmlHashNFiltered, filtStr);

    in = fact.createFilteredInputStream(mau, new StringInputStream(HtmlHashP), ENC);
    filtStr = StringUtil.fromInputStream(in);
    assertEquals(HtmlHashPFiltered, filtStr);
  }
Example #17
0
 /** Concatenate params for URL string */
 String concatParams(Properties props) {
   if (props == null) {
     return null;
   }
   java.util.List list = new ArrayList();
   for (Iterator iter = props.keySet().iterator(); iter.hasNext(); ) {
     String key = (String) iter.next();
     String val = props.getProperty(key);
     if (!StringUtil.isNullString(val)) {
       list.add(key + "=" + urlEncode(val));
     }
   }
   return StringUtil.separatedString(list, "&");
 }
  /*.................................................................................................................*/
  public boolean monitorAndCleanUpShell(String jobURL) {
    boolean stillGoing = true;

    if (!checkUsernamePassword(true)) {
      return false;
    }
    lastModified = null;
    if (outputFilePaths != null) {
      lastModified = new long[outputFilePaths.length];
      LongArray.deassignArray(lastModified);
    }
    String status = "";
    while (!jobCompleted(jobURL) && stillGoing) {
      if (StringUtil.blank(status))
        ownerModule.logln(
            "CIPRes Job Status: " + getJobStatus(jobURL) + "  (" + StringUtil.getDateTime() + ")");

      //	if (jobSubmitted(jobURL))
      //		processOutputFiles();
      try {
        Thread.sleep(minPollIntervalSeconds * 1000);
      } catch (InterruptedException e) {
        MesquiteMessage.notifyProgrammer("InterruptedException in CIPRes monitoring");
        return false;
      }

      stillGoing = watcher == null || watcher.continueShellProcess(null);
      String newStatus = getJobStatus(jobURL);
      if (newStatus != null && !newStatus.equalsIgnoreCase(status)) {
        ownerModule.logln(
            "CIPRes Job Status: " + newStatus + "  (" + StringUtil.getDateTime() + ")");
        status = newStatus;
      } else ownerModule.log(".");
      if (newStatus != null && newStatus.equalsIgnoreCase("SUBMITTED")) { // job is running
        processOutputFiles(jobURL);
      }
    }
    ownerModule.logln("CIPRes job completed.");
    if (outputFileProcessor != null) {
      if (rootDir != null) {
        ownerModule.logln("About to download results from CIPRes.");
        if (downloadResults(jobURL, rootDir, false))
          outputFileProcessor.processCompletedOutputFiles(outputFilePaths);
        else return false;
      }
    }

    return true;
  }
Example #19
0
 protected Properties filterResponseProps(Properties props) {
   Properties res = new Properties();
   for (Map.Entry ent : props.entrySet()) {
     String key = (String) ent.getKey();
     if (StringUtil.startsWithIgnoreCase(key, "x-lockss")
         || StringUtil.startsWithIgnoreCase(key, "x_lockss")
         || key.equalsIgnoreCase("org.lockss.version.number")) {
       continue;
     }
     // We've lost the original case - capitalize them the way most people
     // expect
     res.put(StringUtil.titleCase(key, '-'), (String) ent.getValue());
   }
   return res;
 }
Example #20
0
 protected void logParams() {
   Enumeration en = req.getParameterNames();
   while (en.hasMoreElements()) {
     String name = (String) en.nextElement();
     String vals[];
     String dispval;
     if (StringUtil.indexOfIgnoreCase(name, "passw") >= 0) {
       dispval = req.getParameter(name).length() == 0 ? "" : "********";
     } else if (log.isDebug2() && (vals = req.getParameterValues(name)).length > 1) {
       dispval = StringUtil.separatedString(vals, ", ");
     } else {
       dispval = req.getParameter(name);
     }
     log.debug(name + " = " + dispval);
   }
 }
Example #21
0
  protected void connectSession() throws JSchException {
    if (session != null) {
      if (session.isConnected()) {
        session.disconnect();
      }
      session = null;
    }

    AutomationLogger.getInstance().info("Connectting...");

    if (StringUtil.notEmpty(user)) {
      session = jsch.getSession(user, host, 22);
      session.setPassword(password);
    } else if (auth != null) {
      session = auth.getSession(host);
    } else {
      throw new ItemNotFoundException("Authentication is missing!");
    }

    java.util.Properties config = new java.util.Properties();
    config.put("StrictHostKeyChecking", "no");
    session.setConfig(config);
    session.connect();
    AutomationLogger.getInstance().info("Connected");
  }
 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 returns a Document from the contents of the XML file as contained in the String
  * xmlFile, with no restriction as to the root element.
  */
 public Document loadXMLFile(String xmlFile) {
   if (!StringUtil.blank(xmlFile)) {
     Document CipresDoc = XMLUtil.getDocumentFromString(xmlFile);
     return CipresDoc;
   }
   return null;
 }
  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 boolean downloadResults(
      HttpClient httpclient, String jobURL, String rootDir, boolean onlyNewOrModified) {

    String resultsUri = getResultsDirectory(jobURL);
    if (StringUtil.notEmpty(resultsUri)) {
      Document cipresResponseDoc = cipresQuery(httpclient, resultsUri, "results");
      if (cipresResponseDoc != null) {
        CipresJobFile[] cipresJobFiles = processFilesDocument(cipresResponseDoc);
        if (cipresJobFiles == null || cipresJobFiles.length == 0) {
          ownerModule.logln(cipresResponseDoc.toString());
          return false;
        }
        for (int job = 0; job < cipresJobFiles.length; job++) {
          if (!onlyNewOrModified || fileNewOrModified(previousCipresJobFiles, cipresJobFiles, job))
            cipresDownload(
                httpclient,
                cipresJobFiles[job].getDownloadURL(),
                rootDir + cipresJobFiles[job].getFileName());
        }
        previousCipresJobFiles = cipresJobFiles.clone();
        return true;
      }
    }
    return false;
  }
  /*................................................................................................*/
  public boolean startJob(String arguments, Object condition, boolean hiredByName) {
    addMenuItem("Directory for Sample Trees From Directory...", makeCommand("setDirPath", this));
    fillerTasks = new Vector();
    if (!MesquiteThread
        .isScripting()) { // enclosed in conditional to avoid hiring query when opening file; should
      // be handled by snapshot/doCommand when file is opened.
      String directoryPath =
          MesquiteFile.chooseDirectory(
              "Choose directory containing tree files:",
              previousDirectory); // MesquiteFile.saveFileAsDialog("Base name for files (files will
      // be named <name>1.nex, <name>2.nex, etc.)", baseName);

      if (StringUtil.blank(directoryPath)) { // TODO: clean this up?
        return false;
      } else {
        directory = new File(directoryPath);
        previousDirectory = directory.getParent();
        if (directory.exists() && directory.isDirectory()) {
          return hireFillers(directoryPath);
        }
      }
    }
    return true; // Add something to make sure directory paths are set up correctly, when not
    // scripting...
  }
  /*................................................................................................*/
  private boolean hireFillers(String directoryPath) {
    String[] files = directory.list();
    String treePath;
    for (int i = 0; i < files.length; i++) {
      if (files[i] != null) {
        String fileLowerCase = files[i].toLowerCase();
        if (fileLowerCase.endsWith(".nex") || fileLowerCase.endsWith(".nexus")) {
          treePath = directoryPath + MesquiteFile.fileSeparator + files[i];
          File treeFile = new File(treePath);
          String treeFileName = treeFile.getName();
          if (StringUtil.blank(treeFileName)) {
            return false;
          }
          TreeBlockFiller newFiller;
          newFiller =
              (TreeBlockFiller)
                  hireNamedEmployee(TreeBlockFiller.class, "#SampleOneTreeFromFile"); // treePath);
          if (newFiller != null) {
            if (((SampleOneTreeFromFile) newFiller).setFilePath(treePath)
                && ((SampleOneTreeFromFile) newFiller).processFile()) {
              fillerTasks.addElement(newFiller);
            } else
              Debugg.println(
                  "Filler "
                      + i
                      + " processFile = "
                      + ((SampleOneTreeFromFile) newFiller).processFile());
          }
        }
      }
    }

    return true;
  }
Example #28
0
  private String[] GetBusPosition(String Str) {
    String uploadWebsite = "http://" + controller.URL_BASE + "/php/busposition?q=";
    String[] ArrayOfData = null;
    StreamConnection c = null;
    InputStream s = null;
    StringBuffer b = new StringBuffer();

    String url = uploadWebsite + Str;
    System.out.print(url);
    try {
      /* c = (StreamConnection)Connector.open(url);
      s = c.openDataInputStream();
      int ch;
      int k =0;
      while((ch = s.read()) != -1) {
            System.out.print((char) ch);
          b.append((char) ch);   }
      */
      String result; // = b.toString();
      result = "365E~~RTONO~~09:30:23~~12.21212~~89.23324234";
      //   System.out.print("in thread---------");
      // System.out.print(result);
      if (!result.equals("")) {

        ArrayOfData = StringUtil.split(result.toString().trim(), "~~");
      }
    } catch (Exception e) {
      System.out.print(e);
      controller.ShowPointingCanvas();
      controller.showAlert("Network Error", 3, AlertType.ERROR);
    }

    return ArrayOfData;
  }
  /**
   * A target system is required to create an AU - was it provided?
   *
   * @return true If at least one target was specified
   */
  private boolean verifyTarget() {
    if (!isCreateCommand()) {
      return true;
    }

    return !StringUtil.isNullString(getParameter(AP_E_TARGET));
  }
  /** monitors the run. */
  public boolean monitorAndCleanUpShell() {
    lastModified = null;
    boolean stillGoing = true;
    if (outputFilePaths != null) {
      lastModified = new long[outputFilePaths.length];
      LongArray.deassignArray(lastModified);
    }

    if (!StringUtil.blank(
        runningFilePath)) // is file at runningFilePath; watch for its disappearance
    while (MesquiteFile.fileExists(runningFilePath) && stillGoing) {
        processOutputFiles();
        try {
          Thread.sleep(sleepTime);
        } catch (InterruptedException e) {
          MesquiteMessage.notifyProgrammer(
              "InterruptedException in shell script executed by " + name);
          return false;
        }
        stillGoing = watcher == null || watcher.continueShellProcess(proc);
      }

    if (outputFileProcessor != null)
      outputFileProcessor.processCompletedOutputFiles(outputFilePaths);
    return true;
  }