Exemplo n.º 1
0
  private void updateChipsterConfigFilePasswords(File configFile) throws Exception {
    Document doc = openForUpdating("Chipster", configFile);

    Element securityModule =
        XmlUtil.getChildWithAttributeValue(doc.getDocumentElement(), "moduleId", "security");
    Element usernameElement =
        XmlUtil.getChildWithAttributeValue(securityModule, "entryKey", "username");
    String username =
        ((Element) usernameElement.getElementsByTagName("value").item(0)).getTextContent();
    for (int i = 0; i < passwords.length; i++) {
      if (username.equals(passwords[i][KEY_INDEX])) {
        updateConfigEntryValue(securityModule, "password", passwords[i][VAL_INDEX]);
        break;
      }
    }
    writeLater(configFile, doc);
  }
Exemplo n.º 2
0
 private void writeChangesToDisk()
     throws TransformerException, UnsupportedEncodingException, FileNotFoundException {
   // write out files
   for (String file : documentsToWrite.keySet()) {
     System.out.println("Writing changes to " + file + "...");
     XmlUtil.printXml(
         documentsToWrite.get(file), new OutputStreamWriter(new FileOutputStream(file)));
   }
   System.out.println("\nAll changes successfully written!");
 }
Exemplo n.º 3
0
  private void updateRuntimesConfigFile(File configFile) throws Exception {

    boolean ok = false;
    Document doc = openForUpdating("Runtimes", configFile);
    Element runtimesElement = (Element) doc.getElementsByTagName("runtimes").item(0);
    for (Element runtimeElement : XmlUtil.getChildElements(runtimesElement, "runtime")) {
      String runtimeName = XmlUtil.getChildElement(runtimeElement, "name").getTextContent();
      if (runtimeName.equals(CURRENT_R_VERSION)) {
        Element handlerElement = XmlUtil.getChildElement(runtimeElement, "handler");
        for (Element parameterElement : XmlUtil.getChildElements(handlerElement, "parameter")) {
          String paramName = XmlUtil.getChildElement(parameterElement, "name").getTextContent();
          if (paramName.equals("command")) {
            Element commandValueElement = XmlUtil.getChildElement(parameterElement, "value");
            updateElementValue(
                commandValueElement, "R-2.6.1 command", configs[R_COMMAND_INDEX][VAL_INDEX]);
            ok = true;
          }
        }
      }
    }

    if (ok) {
      writeLater(configFile, doc);
    } else {
      throw new RuntimeException("Could not update R-2.6.1 command to runtimes.xml");
    }
  }
Exemplo n.º 4
0
  private void updateChipsterConfigFile(File configFile) throws Exception {
    Document doc = openForUpdating("Chipster", configFile);

    Element messagingModule =
        XmlUtil.getChildWithAttributeValue(doc.getDocumentElement(), "moduleId", "messaging");
    updateConfigEntryValue(messagingModule, "broker-host", configs[BROKER_HOST_INDEX][VAL_INDEX]);
    updateConfigEntryValue(
        messagingModule, "broker-protocol", configs[BROKER_PROTOCOL_INDEX][VAL_INDEX]);
    updateConfigEntryValue(messagingModule, "broker-port", configs[BROKER_PORT_INDEX][VAL_INDEX]);

    Element filebrokerModule =
        XmlUtil.getChildWithAttributeValue(doc.getDocumentElement(), "moduleId", "filebroker");
    if (filebrokerModule != null) {
      updateConfigEntryValue(filebrokerModule, "port", configs[FILEBROKER_PORT_INDEX][VAL_INDEX]);
      updateConfigEntryValue(filebrokerModule, "url", createFilebrokerUrl());
    }

    Element analyserModule =
        XmlUtil.getChildWithAttributeValue(doc.getDocumentElement(), "moduleId", "comp");
    if (analyserModule != null) {
      updateConfigEntryValue(analyserModule, "max-jobs", configs[MAX_JOBS_INDEX][VAL_INDEX]);
    }

    Element webstartModule =
        XmlUtil.getChildWithAttributeValue(doc.getDocumentElement(), "moduleId", "webstart");
    if (webstartModule != null) {
      updateConfigEntryValue(webstartModule, "port", configs[WS_PORT][VAL_INDEX]);
    }

    Element clientModule =
        XmlUtil.getChildWithAttributeValue(doc.getDocumentElement(), "moduleId", "client");
    if (clientModule != null) {
      updateConfigEntryValue(
          clientModule, "manual-root", configs[WS_CODEBASE_INDEX][VAL_INDEX] + "/manual/");
    }

    Element managerModule =
        XmlUtil.getChildWithAttributeValue(doc.getDocumentElement(), "moduleId", "manager");
    if (managerModule != null) {
      updateConfigEntryValue(managerModule, "web-console-port", configs[MANAGER_PORT][VAL_INDEX]);
      updateConfigEntryValue(managerModule, "admin-email", configs[MANAGER_EMAIL][VAL_INDEX]);
    }

    writeLater(configFile, doc);
  }
Exemplo n.º 5
0
 private Document openForUpdating(String name, File configFile)
     throws SAXException, IOException, ParserConfigurationException {
   System.out.println("Updating " + name + " config in " + configFile.getAbsolutePath());
   Document doc = XmlUtil.parseFile(configFile);
   return doc;
 }
Exemplo n.º 6
0
 private void updateConfigEntryValue(Element module, String name, String newValue) {
   Element entry = XmlUtil.getChildWithAttributeValue(module, "entryKey", name);
   Element value = (Element) entry.getElementsByTagName("value").item(0);
   updateElementValue(value, name, newValue);
 }