*/
private static int iNumberOfHosts;
public static void writeHosts(LinkedList<JHost> hostList,String splash,String updatePath,String updateMode,String installDir,String setupPassword) {
final Logger logger = Logger.getLogger(JXMLHost.class);
final JFileIO fio = new JFileIO();
Common.updateURL=updatePath;
Common.updateMODE=updateMode;
Common.updateInstallDir=installDir;
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
try
{
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.newDocument();
// Create the root element - hosts //
Element hosts = (Element) document.createElement("Hosts");
// Number of Hosts //
Element numberofhosts = (Element) document.createElement("NumberOfSites");
Text text = document.createTextNode(Integer.toString(hostList.size()));
numberofhosts.appendChild(text);
hosts.appendChild(numberofhosts);
// Splash Screen Enabled //
Element splashScreen = (Element) document.createElement("SplashScreen");
text = document.createTextNode(splash);
splashScreen.appendChild(text);
hosts.appendChild(splashScreen);
Element updateURL = (Element) document.createElement("UpdateURL");
text = document.createTextNode(updatePath);
updateURL.appendChild(text);
hosts.appendChild(updateURL);
Element updateMODE = (Element) document.createElement("UpdateMODE");
text = document.createTextNode(updateMode);
updateMODE.appendChild(text);
hosts.appendChild(updateMODE);
Element updateDIR = (Element) document.createElement("UpdateDIR");
text = document.createTextNode(installDir);
updateDIR.appendChild(text);
hosts.appendChild(updateDIR);
Element configPassword = (Element) document.createElement("SetupPassword");
text = document.createTextNode(JEncryption.encrypt(setupPassword));
configPassword.appendChild(text);
hosts.appendChild(configPassword);
for (int j = 0; j < hostList.size(); j++)
{
// Create the 1st level - site //
Element site = (Element) document.createElement("Site");
site.setAttribute("Number", hostList.get(j).getSiteNumber());
Element enabled = (Element) document.createElement("Enabled");
text = document.createTextNode(hostList.get(j).getEnabled().trim());
enabled.appendChild(text);
Element uniqueid = (Element) document.createElement("UniqueID");
text = document.createTextNode(hostList.get(j).getUniqueID().trim());
uniqueid.appendChild(text);
Element description = (Element) document.createElement("Description");
text = document.createTextNode(hostList.get(j).getSiteDescription().trim());
description.appendChild(text);
Element url = (Element) document.createElement("URL");
text = document.createTextNode(hostList.get(j).getSiteURL().trim());
url.appendChild(text);
Element databasedriver = (Element) document.createElement("DatabaseDriver");
Element jdbcDriver = (Element) document.createElement("jdbcDriver");
text = document.createTextNode(hostList.get(j).getDatabaseParameters().getjdbcDriver().trim());
jdbcDriver.appendChild(text);
Element jdbcConnectString = (Element) document.createElement("jdbcConnectString");
text = document.createTextNode(hostList.get(j).getDatabaseParameters().getjdbcConnectString().trim());
jdbcConnectString.appendChild(text);
Element jdbcDatabaseDateTimeToken = (Element) document.createElement("jdbcDatabaseDateTimeToken");
text = document.createTextNode(hostList.get(j).getDatabaseParameters().getjdbcDatabaseDateTimeToken().trim());
jdbcDatabaseDateTimeToken.appendChild(text);
Element jdbcDatabaseSelectLimit = (Element) document.createElement("jdbcDatabaseSelectLimit");
text = document.createTextNode(hostList.get(j).getDatabaseParameters().getjdbcDatabaseSelectLimit().trim());
jdbcDatabaseSelectLimit.appendChild(text);
Element jdbcDatabaseSchema = (Element) document.createElement("jdbcDatabaseSchema");
text = document.createTextNode(hostList.get(j).getDatabaseParameters().getjdbcDatabaseSchema().trim());
jdbcDatabaseSchema.appendChild(text);
databasedriver.appendChild(jdbcDriver);
databasedriver.appendChild(jdbcConnectString);
databasedriver.appendChild(jdbcDatabaseDateTimeToken);
databasedriver.appendChild(jdbcDatabaseSelectLimit);
databasedriver.appendChild(jdbcDatabaseSchema);
Element DatabaseParameters = (Element) document.createElement("DatabaseParameters");
Element jdbcUsername = (Element) document.createElement("jdbcUsername");
text = document.createTextNode(hostList.get(j).getDatabaseParameters().getjdbcUsername().trim());
jdbcUsername.appendChild(text);
Element jdbcPassword = (Element) document.createElement("jdbcPassword");
text = document.createTextNode(JEncryption.encrypt(hostList.get(j).getDatabaseParameters().getjdbcPassword().trim()));
jdbcPassword.appendChild(text);
Element jdbcServer = (Element) document.createElement("jdbcServer");
text = document.createTextNode(hostList.get(j).getDatabaseParameters().getjdbcServer().trim());
jdbcServer.appendChild(text);
Element jdbcPort = (Element) document.createElement("jdbcPort");
text = document.createTextNode(hostList.get(j).getDatabaseParameters().getjdbcPort().trim());
jdbcPort.appendChild(text);
Element jdbcSID = (Element) document.createElement("jdbcSID");
text = document.createTextNode(hostList.get(j).getDatabaseParameters().getjdbcSID().trim());
jdbcSID.appendChild(text);
Element jdbcDatabase = (Element) document.createElement("jdbcDatabase");
text = document.createTextNode(hostList.get(j).getDatabaseParameters().getjdbcDatabase().trim());
jdbcDatabase.appendChild(text);
DatabaseParameters.appendChild(jdbcUsername);
DatabaseParameters.appendChild(jdbcPassword);
DatabaseParameters.appendChild(jdbcServer);
DatabaseParameters.appendChild(jdbcPort);
DatabaseParameters.appendChild(jdbcSID);
DatabaseParameters.appendChild(jdbcDatabase);
site.appendChild(enabled);
site.appendChild(uniqueid);
site.appendChild(description);
site.appendChild(url);
site.appendChild(databasedriver);
site.appendChild(DatabaseParameters);
hosts.appendChild(site);
}
document.appendChild(hosts);
fio.writeToDisk("xml/hosts/", document,-1, "hosts.xml");
}
catch (ParserConfigurationException pce)
{