Пример #1
0
  protected final void command_set_indent(String indent) {
    if (indent.equals("null")) {
      format.setIndent(null);
      System.out.printf("Indentation unset", indent);
    } else {
      format.setIndent(indent);
      System.out.printf("Indentation set to \"%s\"\n", indent);
    }

    // update outputter
    xmloutputter.setFormat(format);
  } // command_set_indent()
 /** 保存文件 */
 public int writeModelXml(Hashtable has, Hashtable hat) {
   int done = 1;
   try {
     for (int i = 0; i < has.size(); i++) {
       String[] str1 = ((String) has.get(i)).split(",");
       System.out.println(str1.length);
       // 创建节点 node;
       String index = str1[2];
       String direction = (String) hat.get(i);
       index = index.replaceAll("index", "");
       addNodes(index, "image/up_green.gif", str1[0], str1[1], direction);
     }
     Format format = Format.getCompactFormat();
     format.setEncoding("GB2312");
     format.setIndent("	");
     serializer = new XMLOutputter(format);
     fos = new FileOutputStream(fullPath);
     fos.write(headBytes.getBytes());
     serializer.output(doc, fos);
     fos.close();
   } catch (Exception e) {
     done = 0;
     e.printStackTrace();
     SysLogger.error("Error in XmlOperator.close()", e);
   }
   return done;
 }
Пример #3
0
  public void convertPageToXML(Page page) {
    try {
      for (Question ques : page.items) {
        Element newQues = new Element("DOC");
        Element docNo = new Element("DOCNO");
        Element docUrl = new Element("DOCURL");

        String link = ques.link;
        String quesitonID = link.split("/")[4];
        docNo.setText(quesitonID);
        docUrl.setText(link);
        newQues.addContent(docNo);
        newQues.addContent(docUrl);

        MyParser myParser = new MyParser();
        MyQuestion myQues = myParser.parseStacakOverFlowUrl(link);

        Element title = new Element("title");
        title.setText(myQues.title);
        newQues.addContent(title);

        Element content = new Element("p");
        content.setText(myQues.content);
        newQues.addContent(content);

        Element answers = new Element("answers");
        for (MyAnswer ans : myQues.answers) {
          Element answer = new Element("answer");

          Element votes = new Element("votes");
          votes.setText(ans.votes);
          answer.addContent(votes);

          Element text = new Element("p");
          text.setText(ans.content);
          answer.addContent(text);

          answers.addContent(answer);
        }
        newQues.addContent(answers);

        rootElement.addContent(newQues);
      }

      Document document = new Document(rootElement);
      Format format = Format.getCompactFormat();
      format.setIndent("");
      XMLOutputter xmloutputter = new XMLOutputter(format);
      OutputStream outputStream;
      outputStream = new FileOutputStream("document.xml");
      xmloutputter.output(document, outputStream);
      System.out.println("xml文档生成成功!");

    } catch (IOException e) {
      e.printStackTrace();
    }
  }
Пример #4
0
 /*     */ private void outputDocumentToFile(Document myDocument, String path) {
   /*     */ try {
     /* 242 */ Format format = Format.getCompactFormat();
     /* 243 */ format.setEncoding("UTF-8");
     /* 244 */ format.setIndent("    ");
     /* 245 */ XMLOutputter outputter = new XMLOutputter(format);
     /* 246 */ outputter.output(myDocument, new FileOutputStream(path));
     /*     */ } catch (IOException e) {
     /* 248 */ e.printStackTrace();
     /*     */ }
   /*     */ }
  @Override
  public void generate(final File reportsDir, final VersionManagerSession session)
      throws VManException {
    Map<VersionlessProjectKey, Set<Plugin>> missingPlugins = session.getUnmanagedPluginRefs();
    if (missingPlugins.isEmpty()) {
      return;
    }
    Element plugins = new Element("plugins");

    for (Map.Entry<VersionlessProjectKey, Set<Plugin>> pluginsEntry : missingPlugins.entrySet()) {
      if (plugins.getContentSize() > 0) {
        plugins.addContent("\n\n");
      }

      plugins.addContent(new Comment("START: " + pluginsEntry.getKey()));

      for (Plugin dep : pluginsEntry.getValue()) {
        Element d = new Element("plugin");
        plugins.addContent(d);

        d.addContent(new Element("groupId").setText(dep.getGroupId()));
        d.addContent(new Element("artifactId").setText(dep.getArtifactId()));
        d.addContent(new Element("version").setText(dep.getVersion()));
      }

      plugins.addContent(new Comment("END: " + pluginsEntry.getKey()));
    }

    Element build = new Element("build");
    build.addContent(new Element("pluginManagement").setContent(plugins));

    Document doc = new Document(build);

    Format fmt = Format.getPrettyFormat();
    fmt.setIndent("  ");
    fmt.setTextMode(TextMode.PRESERVE);

    XMLOutputter output = new XMLOutputter(fmt);

    File report = new File(reportsDir, ID + ".xml");
    FileWriter writer = null;
    try {
      reportsDir.mkdirs();

      writer = new FileWriter(report);
      output.output(doc, writer);
    } catch (IOException e) {
      throw new VManException("Failed to generate %s report! Error: %s", e, ID, e.getMessage());
    } finally {
      closeQuietly(writer);
    }
  }
 /** 保存文件 */
 public void writeXml() {
   try {
     Format format = Format.getCompactFormat();
     format.setEncoding("GB2312");
     format.setIndent("	");
     serializer = new XMLOutputter(format);
     fos = new FileOutputStream(fullPath);
     fos.write(headBytes.getBytes());
     serializer.output(doc, fos);
     fos.close();
   } catch (Exception e) {
     e.printStackTrace();
     SysLogger.error("Error in XmlOperator.close()", e);
   }
 }
  public static void main(String[] args) {
    SAXBuilder saxBuilder = new SAXBuilder();
    try {
      Document doc = saxBuilder.build(new File("domdb.xml"));

      // 首先创建好节点
      Element eltDb = new Element("db");
      Element eltDriver = new Element("driver");
      Element eltUrl = new Element("url");
      Element eltUser = new Element("user");
      Element eltPassword = new Element("password");

      // 设置节点的值
      eltDriver.setText("com.mysql.jdbc.Driver");
      eltUrl.setText("jdbc:mysql://localhost/mySql");
      eltUser.setText("root");
      eltPassword.setText("xlc");

      // 添加到根节点
      eltDb.addContent(eltDriver);
      eltDb.addContent(eltUrl);
      eltDb.addContent(eltUser);
      eltDb.addContent(eltPassword);
      // 根节点设置属性
      eltDb.setAttribute("type", "mysql");

      Element root = doc.getRootElement();
      // root.removeChild("db");//删除节点
      root.addContent(eltDb); // 增加节点

      // 修改db节点中内容
      root.getChild("db").getChild("user").setText("system");
      root.getChild("db").getChild("password").setText("manager");

      XMLOutputter xmlOut = new XMLOutputter();

      // 设置XML格式
      Format fmt = Format.getPrettyFormat();
      fmt.setIndent("    ");
      fmt.setEncoding("utf-8");

      xmlOut.setFormat(fmt);
      xmlOut.output(doc, System.out);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Пример #8
0
  private void storeConfig(boolean isTemporary) {
    // Test that the custom config is OK
    Document customConfig = validateCustomFields();
    if (customConfig == null) {
      return;
    }

    // Build the framework config XML tree
    Document doc = new Document();
    Element root = new Element("Document");
    doc.setRootElement(root);
    Element framework = new Element("Framework");
    root.addContent(framework);
    Element custom = new Element("Custom");
    root.addContent(custom);
    custom.addContent(
        new Element(
            "_xml_custom_")); // this tag will be replaced by the config text in a second step

    for (ConfigEntry e : projectEntries) {
      if (e.valueComponent != null) { // there is a value field in the GUI
        if (e.comment != "") { // the comment is not "", add it
          framework.addContent(
              new Comment(e.comment.replace("\n", " "))); // without the newline chars
        }
        // get the value of this entry from the GUI
        String value = "";
        if (e.valueComponent instanceof JComboBox) {
          value = (String) ((JComboBox) e.valueComponent).getSelectedItem();
        } else if (e.valueComponent instanceof JTextComponent) {
          value = ((JTextComponent) e.valueComponent).getText();
        }
        // create and add a new entry in the XML file
        Element elem = new Element(e.key);
        elem.setAttribute("value", value);
        framework.addContent(elem);
        framework.addContent(
            new Element(
                "_xml_NL_")); // after each entry, we would like a new-line in the document - these
                              // tags are replaced in a second step
      } else {
        // this is a section entry, which will be inserted as comment
        // String line = " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ";
        String line = "***********************************************************************";
        framework.addContent(new Comment(line));
        String name = "  " + e.key;
        while (name.length()
            < line.length()) { // fill the name with spaces s.t. the '-->' are aligned
          name += " ";
        }
        framework.addContent(new Comment(name));
        framework.addContent(new Comment(line));
      }
    }

    String outputPath =
        Configuration.sourceDirPrefix
            + "/"
            + Configuration.projectDirInSourceFolder
            + "/"
            + selectedProjectName;
    File outputFile =
        new File(outputPath + "/" + Configuration.configfileFileName + (isTemporary ? ".run" : ""));

    // And write the xml tree to the file
    XMLOutputter outputter = new XMLOutputter();
    Format f = Format.getPrettyFormat();
    f.setIndent("\t");
    outputter.setFormat(f);
    File tempOutputFile = new File(outputPath + "/" + Configuration.configfileFileName + ".temp");
    try {
      FileWriter fW = new FileWriter(tempOutputFile);
      outputter.output(doc, fW);
      fW.flush();
      fW.close();
    } catch (IOException e) {
      Main.minorError("Could not write a temporary configuration file!\n\n" + e.getMessage());
      return;
    }

    // in a second step, parse the temp file, replace the _xml_nl_ by new-lines and the _xml_custom_
    // by the custom text

    try {
      BufferedWriter output = new BufferedWriter(new FileWriter(outputFile));
      LineNumberReader input = new LineNumberReader(new FileReader(tempOutputFile));
      String line = input.readLine();
      while (line != null) {
        if (line.contains("<_xml_NL_")) {
          output.newLine();
        } else if (line.contains("<_xml_custom_")) {
          output.write(customParameters.getText());
        } else {
          output.write(line);
          output.newLine();
        }
        line = input.readLine();
      }
      output.flush();
      output.close();
      input.close();
      tempOutputFile.delete();
    } catch (IOException e1) {
      Main.minorError("Could not write the configuration file!\n\n" + e1.getMessage());
    }

    userInputListener.reset(); // finally reset the 'modified' flag
  }
  @Override
  public void generate(final File reportsDir, final VersionManagerSession session)
      throws VManException {
    final Map<VersionlessProjectKey, Set<Dependency>> missingDependencies =
        session.getMissingDependencies();
    if (missingDependencies.isEmpty()) {
      return;
    }

    final Element deps = new Element("dependencies");

    for (final Map.Entry<VersionlessProjectKey, Set<Dependency>> depsEntry :
        missingDependencies.entrySet()) {
      if (deps.getContentSize() > 0) {
        deps.addContent("\n\n");
      }

      deps.addContent(new Comment("START: " + depsEntry.getKey()));

      for (final Dependency dep : depsEntry.getValue()) {
        final Element d = new Element("dependency");
        deps.addContent(d);

        d.addContent(new Element("groupId").setText(dep.getGroupId()));
        d.addContent(new Element("artifactId").setText(dep.getArtifactId()));
        d.addContent(new Element("version").setText(dep.getVersion()));

        if (isNotEmpty(dep.getType()) && !"jar".equals(dep.getType())) {
          d.addContent(new Element("type").setText(dep.getType()));
        }

        if (isNotEmpty(dep.getClassifier())) {
          d.addContent(new Element("classifier").setText(dep.getClassifier()));
        }

        // if ( dep.isOptional() )
        // {
        // d.addContent( new Element( "optional" ).setText( Boolean.toString( true ) ) );
        // }
        //
        // if ( dep.getExclusions() != null && !dep.getExclusions().isEmpty() )
        // {
        // Element ex = new Element( "exclusions" );
        // d.addContent( ex );
        //
        // for ( Exclusion exclusion : dep.getExclusions() )
        // {
        // ex.addContent( new Element( "groupId" ).setText( exclusion.getGroupId() ) );
        // ex.addContent( new Element( "artifactId" ).setText( exclusion.getArtifactId() ) );
        // }
        // }
      }

      deps.addContent(new Comment("END: " + depsEntry.getKey()));
    }

    final Element dm = new Element("dependencyManagement");
    dm.setContent(deps);

    final Document doc = new Document(dm);

    final Format fmt = Format.getPrettyFormat();
    fmt.setIndent("  ");
    fmt.setTextMode(TextMode.PRESERVE);

    final XMLOutputter output = new XMLOutputter(fmt);

    final File report = new File(reportsDir, ID);
    FileWriter writer = null;
    try {
      reportsDir.mkdirs();

      writer = new FileWriter(report);
      output.output(doc, writer);
    } catch (final IOException e) {
      throw new VManException("Failed to generate %s report! Error: %s", e, ID, e.getMessage());
    } finally {
      closeQuietly(writer);
    }
  }
  /**
   * Create an xml containing the jpwebmail configuration.
   *
   * @param config The jpwebmail configuration.
   * @return The xml containing the configuration.
   * @throws ApsSystemException In case of errors.
   */
  public String createConfigXml(WebMailConfig config) throws ApsSystemException {
    Element root = new Element(ROOT);
    try {
      if (config.getLocalhost() != null && config.getLocalhost().trim().length() > 0) {
        Element localhostElem = new Element(LOCALHOST_ELEM);
        localhostElem.addContent(config.getLocalhost().trim());
        root.addContent(localhostElem);
      }
      if (config.getDomainName() != null && config.getDomainName().trim().length() > 0) {
        Element domainElem = new Element(DOMAIN_ELEM);
        domainElem.addContent(new CDATA(config.getDomainName()));
        root.addContent(domainElem);
      }
      Element entandoUserPasswordElem = new Element(ENTANDO_PASSWORD_ELEM);
      entandoUserPasswordElem.addContent(String.valueOf(config.isUseEntandoUserPassword()));
      root.addContent(entandoUserPasswordElem);

      Element certificatesElem = new Element(CERTIFICATES_ELEM);
      Element enableElem = new Element(CERTIFICATES_ENABLE_CHILD);
      enableElem.addContent(String.valueOf(config.isCertificateEnable()));
      certificatesElem.addContent(enableElem);
      Element lazyCheckElem = new Element(CERTIFICATES_LAZYCHECK_CHILD);
      lazyCheckElem.addContent(String.valueOf(config.isCertificateLazyCheck()));
      certificatesElem.addContent(lazyCheckElem);
      Element certPathElem = new Element(CERTIFICATES_CERTPATH_CHILD);
      certPathElem.addContent(new CDATA(config.getCertificatePath()));
      certificatesElem.addContent(certPathElem);
      Element debugOnConsoleElem = new Element(CERTIFICATES_DEBUGONCONSOLE_CHILD);
      debugOnConsoleElem.addContent(String.valueOf(config.isCertificateDebugOnConsole()));
      certificatesElem.addContent(debugOnConsoleElem);
      root.addContent(certificatesElem);

      Element imapElem = new Element(IMAP_ELEM);
      Element imapHostElem = new Element(IMAP_HOST_CHILD);
      imapHostElem.addContent(new CDATA(config.getImapHost()));
      imapElem.addContent(imapHostElem);
      Element imapProtocolElem = new Element(IMAP_PROTOCOL_CHILD);
      imapProtocolElem.addContent(config.getImapProtocol());
      imapElem.addContent(imapProtocolElem);
      Element imapPortElem = new Element(IMAP_PORT_CHILD);
      Integer imapPort = config.getImapPort();
      imapPortElem.addContent(imapPort == null ? "" : imapPort.toString());
      imapElem.addContent(imapPortElem);
      root.addContent(imapElem);

      Element smtpElem = new Element(SMTP_ELEM);
      smtpElem.setAttribute(SMTP_DEBUG_ATTR, String.valueOf(config.isDebug()));
      smtpElem.setAttribute(SMTP_AUTH_ATTR, String.valueOf(config.getSmtpAuth()));
      Element smtpHostElem = new Element(IMAP_HOST_CHILD);
      smtpHostElem.addContent(new CDATA(config.getSmtpHost()));
      smtpElem.addContent(smtpHostElem);
      Element smtpUserElem = new Element(SMTP_USER_CHILD);
      smtpUserElem.addContent(config.getSmtpUserName());
      smtpElem.addContent(smtpUserElem);
      Element smtpPasswordElem = new Element(SMTP_PASSWORD_CHILD);
      smtpPasswordElem.addContent(config.getSmtpPassword());
      smtpElem.addContent(smtpPasswordElem);
      Element smtpPortElem = new Element(SMTP_PORT_CHILD);
      Integer smtpPort = config.getSmtpPort();
      smtpPortElem.addContent(smtpPort == null ? "" : smtpPort.toString());
      smtpElem.addContent(smtpPortElem);
      if (null != config.getSmtpProtocol()) {
        Element protocolElem = new Element(SMTP_PROTOCOL_CHILD);
        if (config.getSmtpProtocol() == WebMailConfig.PROTO_SSL) {
          protocolElem.addContent(PROTO_SSL);
        } else if (config.getSmtpProtocol() == WebMailConfig.PROTO_TLS) {
          protocolElem.addContent(PROTO_TLS);
        } else {
          // any other (unsupported) protocol falls back to STD (no security transport layer)
          protocolElem.addContent(PROTO_STD);
        }
        smtpElem.addContent(protocolElem);
      }
      root.addContent(smtpElem);

      Element folderElem = new Element(FOLDER_ELEM);
      Element trashFolderElem = new Element(FOLDER_TRASH_CHILD);
      trashFolderElem.addContent(config.getTrashFolderName());
      folderElem.addContent(trashFolderElem);
      Element sentFolderElem = new Element(FOLDER_SENT_CHILD);
      sentFolderElem.addContent(config.getSentFolderName());
      folderElem.addContent(sentFolderElem);
      root.addContent(folderElem);
    } catch (Throwable t) {
      ApsSystemUtils.logThrowable(t, this, "createConfigXml");
      throw new ApsSystemException("Error creating config", t);
    }
    Document doc = new Document(root);
    XMLOutputter out = new XMLOutputter();
    Format format = Format.getPrettyFormat();
    format.setIndent("\t");
    out.setFormat(format);
    return out.outputString(doc);
  }
Пример #11
0
  public void saveToFile(File dest) throws IOException {
    File temp = File.createTempFile(dest.getName(), ".tmp", dest.getParentFile());

    try {
      Element root = new Element("MarrsProject");
      root.setAttribute("title", title);
      root.setAttribute("schemaversion", "" + CURRENT_SCHEMAVERSION);

      for (MarrsQuery q : rows) {
        Element queryElt = new Element("Query");
        CDATA data = new CDATA(q.getQueryText());
        queryElt.addContent(data);

        queryElt.setAttribute("title", q.getTitle());
        queryElt.setAttribute("type", "" + q.getQueryType());

        if (q.getAskBefore() != null) {
          Element askElt = new Element("AskBefore");
          askElt.setAttribute("key", q.getAskBefore());
          queryElt.addContent(askElt);
        }

        for (Map.Entry<String, String> context : q.getContext().entrySet()) {
          Element contextElt = new Element("Context");
          contextElt.setAttribute(
              "key", context.getKey()); // for now, we only use "type" to filter context, so this is
          // hardcoded.
          contextElt.setAttribute("value", context.getValue());
          queryElt.addContent(contextElt);
        }

        for (String var : q.getPostProcessingVars()) {
          Element processElt = new Element("PostProcessing");
          processElt.setAttribute(
              "var", var); // for now, we only use "type" to filter context, so this is hardcoded.
          processElt.setAttribute("operation", q.getPostProcessingOperation(var));
          queryElt.addContent(processElt);
        }

        root.addContent(queryElt);
      }

      for (Map.Entry<String, String> param : parameters.entrySet()) {
        Element paramElt = new Element("Param");
        paramElt.setAttribute("key", param.getKey());
        paramElt.setAttribute("val", param.getValue());
        root.addContent(paramElt);
      }

      for (NodeAttribute attr : nodeAttributes) {
        Element nodeAttr = new Element("NodeAttribute");
        nodeAttr.setAttribute("key", attr.key);
        nodeAttr.setAttribute("value", attr.value);

        for (Map.Entry<String, String> e : attr.vizprops.entrySet()) {
          Element vizprop = new Element("Vizmap");
          vizprop.setAttribute("prop", e.getKey());
          vizprop.setAttribute("value", e.getValue());
          nodeAttr.addContent(vizprop);
        }
        root.addContent(nodeAttr);
      }

      Document doc = new Document(root);
      XMLOutputter xout = new XMLOutputter();
      Format format = Format.getPrettyFormat();
      format.setIndent("\t");
      format.setLineSeparator("\n");
      format.setTextMode(TextMode.PRESERVE);
      xout.setFormat(format);
      xout.output(doc, new FileOutputStream(temp));

      temp.renameTo(dest);
      dirty = false;
    } finally {
      temp.delete();
    }
  }
  /** @author nielin modify at 2010-01-08 */
  public int writeXml(int flag) {
    int done = 0;
    // 需要做分布式判断
    String runmodel = PollingEngine.getCollectwebflag();
    try {
      I_HostLastCollectData hostlastmanager = new HostLastCollectDataManager();
      Hashtable ipAllData = (Hashtable) ShareData.getSharedata().get(ipaddress);

      Vector vector = new Vector();
      String[] netInterfaceItem = {
        "index",
        "ifDescr",
        "ifSpeed",
        "ifAdminStatus",
        "ifOperStatus",
        "OutBandwidthUtilHdx",
        "InBandwidthUtilHdx"
      };
      try {
        if ("0".equals(runmodel)) {
          // 采集与访问是集成模式
          vector = hostlastmanager.getInterface_share(ipaddress, netInterfaceItem, "index", "", "");
        } else {
          // 采集与访问是分离模式
          vector = hostlastmanager.getInterface(ipaddress, netInterfaceItem, "index", "", "");
        }
      } catch (Exception e) {
        e.printStackTrace();
        return done;
      }
      try {
        _fis =
            new FileInputStream(
                ResourceCenter.getInstance().getSysPath()
                    + "panel/model/"
                    + oid
                    + "_"
                    + imageType
                    + ".jsp");
      } catch (Exception e) {
        e.printStackTrace();
        _fis.close();
        return done;
      }
      _fis.skip(headBytes.getBytes().length);
      _builder = new SAXBuilder();
      _doc = _builder.build(_fis);
      _root = _doc.getRootElement();
      _nodes = _root.getChild("nodes");

      List list = _nodes.getChildren();

      PortconfigDao dao = new PortconfigDao();

      try {

        for (int i = 0; i < list.size(); i++) {
          Element eleNode = (Element) list.get(i);
          if (eleNode.getChildText("index") == null) break;
          int index = Integer.valueOf(eleNode.getChildText("index")).intValue();
          String x = eleNode.getChildText("x");
          String y = eleNode.getChildText("y");
          String img = eleNode.getChildText("img");
          String direction = eleNode.getChildText("direction");
          String ifname = "";
          String OutBandwidthUtilHdx = "0";
          String InBandwidthUtilHdx = "0";
          String portuse = "";
          if (vector != null && vector.size() > 0) {
            for (int m = 0; m < vector.size(); m++) {
              String[] strs = (String[]) vector.get(m);
              String _ifname = strs[1];
              String _index = strs[0];
              String opstatus = strs[4];
              OutBandwidthUtilHdx = strs[5];
              InBandwidthUtilHdx = strs[6];

              Portconfig portconfig = null;
              try {
                portconfig = dao.getPanelByipandindex(ipaddress, index + "");
              } catch (Exception e) {

              }
              if (portconfig != null
                  && portconfig.getLinkuse() != null
                  && portconfig.getLinkuse().trim().length() > 0) {
                portuse = portconfig.getLinkuse();
              }

              // SysLogger.info(ipaddress+"====ifOperStatus====="+strs[4]);
              if (Integer.parseInt(_index) == index) {
                ifname = _ifname;
                if ("down".equalsIgnoreCase(opstatus)) {
                  // DOWN
                  if ("1".equalsIgnoreCase(direction)) {
                    // 向上的端口
                    img = "image/up_down_gray.gif";
                  } else {
                    // 向下的端口
                    img = "image/down_down_gray.gif";
                  }
                } else {
                  // UP
                  if ("1".equalsIgnoreCase(direction)) {
                    // 向上的端口
                    img = "image/up_up_green.gif";
                  } else {
                    // 向下的端口
                    img = "image/down_up_green.gif";
                  }
                }
                break;
              }
            }
          }
          addNode(
              index + "",
              InBandwidthUtilHdx,
              OutBandwidthUtilHdx,
              img,
              ipaddress,
              ifname,
              portuse,
              x,
              y);
        }

      } catch (Exception e) {
        e.printStackTrace();
      } finally {
        dao.close();
      }

      Format format = Format.getCompactFormat();
      format.setEncoding("GB2312");
      format.setIndent("	");
      serializer = new XMLOutputter(format);
      // SysLogger.info("path==="+fullPath);
      fos = new FileOutputStream(fullPath);
      fos.write(headBytes.getBytes());
      serializer.output(doc, fos);
      fos.close();
      done = 1;
    } catch (Exception e) {
      done = 0;
      e.printStackTrace();
      SysLogger.error("Error in XmlOperator.close()", e);
    }
    return done;
  }