コード例 #1
0
 public static Collection<FieldConnectionEntry> parseEntries(Element entries)
     throws XMLException, CipherException, IOException {
   if (!entries.getTagName().equals("jdbc-entries")) {
     throw new XMLException("Outer tag must be <jdbc-entries>");
   }
   String base64Key = entries.getAttribute("key");
   if (base64Key == null) {
     throw new XMLException("Cipher key attribute missing.");
   }
   Key key = KeyGeneratorTool.makeKey(Base64.decode(base64Key));
   Collection<FieldConnectionEntry> result = new LinkedList<FieldConnectionEntry>();
   NodeList children = entries.getElementsByTagName(FieldConnectionEntry.XML_TAG_NAME);
   for (int i = 0; i < children.getLength(); i++) {
     result.add(new FieldConnectionEntry((Element) children.item(i), key));
   }
   return result;
 }
コード例 #2
0
  public static void writeXMLConnectionsEntries(
      Collection<FieldConnectionEntry> connectionEntries, File connectionEntriesFile) {
    Key key;
    try {
      key = KeyGeneratorTool.getUserKey();
    } catch (IOException e) {
      // LogService.getRoot().log(Level.WARNING, "Cannot retrieve key, probably no one was created:
      // "+e, e);
      LogService.getRoot()
          .log(
              Level.WARNING,
              I18N.getMessage(
                  LogService.getRoot().getResourceBundle(),
                  "com.rapidminer.tools.jdbc.connection.DatabaseConnectionService.retrieving_key_error",
                  e),
              e);
      return;
    }

    try {
      XMLTools.stream(
          toXML(connectionEntries, key, null, false),
          connectionEntriesFile,
          Charset.forName("UTF-8"));
    } catch (Exception e) {
      // LogService.getRoot().log(Level.WARNING, "Failed to write database connections file: "+e,
      // e);
      LogService.getRoot()
          .log(
              Level.WARNING,
              I18N.getMessage(
                  LogService.getRoot().getResourceBundle(),
                  "com.rapidminer.tools.jdbc.connection.DatabaseConnectionService.writing_database_connection_error",
                  e),
              e);
    }
  }