public void store(URI baseURI,ItemDestination dest)
throws XMLException
{
String baseURIValue = baseURI.toString();
URI baseDir = URI.create(baseURIValue.substring(0,baseURIValue.lastIndexOf('/')+1));
ItemConstructor constructor = InfosetFactory.getDefaultInfoset().createItemConstructor();
dest.send(constructor.createDocument(baseURI));
Element top = constructor.createElement(AdminXML.NM_SERVER);
if (autoconfCheck!=((long)(180*1000))) {
top.setAttributeValue("autoconf-check",Long.toString(autoconfCheck/1000));
}
dest.send(top);
dest.send(constructor.createCharacters("\n"));
Element keystoreE = constructor.createElement(AdminXML.NM_KEYSTORE);
keystoreE.setAttributeValue("href",baseDir.relativize(keystoreFile.toURI()).toString());
keystoreE.setAttributeValue("password",keystorePassword);
if (!keystorePassword.equals(keyPassword)) {
keystoreE.setAttributeValue("key-password",keyPassword);
}
dest.send(keystoreE);
dest.send(constructor.createElementEnd(AdminXML.NM_KEYSTORE));
dest.send(constructor.createCharacters("\n"));
for (Auth auth : authServices.values()) {
Element authE = constructor.createElement(AdminXML.NM_AUTH);
for (Object nameO : auth.getProperties().keySet()) {
String name = nameO.toString();
authE.setAttributeValue(name,auth.getProperties().getProperty(name));
}
dest.send(authE);
dest.send(constructor.createElementEnd(AdminXML.NM_AUTH));
dest.send(constructor.createCharacters("\n"));
}
for (Link link : autoconfs) {
Element autoconfE = constructor.createElement(AdminXML.NM_AUTOCONF);
autoconfE.setAttributeValue("href",baseURI.relativize(link.getLink()).toString());
if (link.getUsername()!=null) {
autoconfE.setAttributeValue("username",link.getUsername());
autoconfE.setAttributeValue("password",link.getPassword());
}
dest.send(autoconfE);
dest.send(constructor.createElementEnd(AdminXML.NM_AUTOCONF));
dest.send(constructor.createCharacters("\n"));
}
for (Database database : databases.values()) {
Element databaseE = constructor.createElement(AdminXML.NM_DATABASE);
databaseE.setAttributeValue("name",database.getName());
databaseE.setAttributeValue("auth",database.getAuthName());
dest.send(databaseE);
dest.send(constructor.createElementEnd(AdminXML.NM_DATABASE));
dest.send(constructor.createCharacters("\n"));
}
for (Interface iface : interfaces) {
Element ifaceE = constructor.createElement(AdminXML.NM_INTERFACE);
ifaceE.setAttributeValue("address",iface.getAddress());
ifaceE.setAttributeValue("port",Integer.toString(iface.getPort()));
ifaceE.setAttributeValue("secure",iface.isSecure() ? "true" : "false");
dest.send(ifaceE);
dest.send(constructor.createElementEnd(AdminXML.NM_INTERFACE));
dest.send(constructor.createCharacters("\n"));
}
for (AdminHost host : admins.values()) {
Element hostE = constructor.createElement(AdminXML.NM_ADMIN);
hostE.setAttributeValue("name",host.getName());
if (host.getAddress()!=null) {
hostE.setAttributeValue("address",host.getAddress());
}
if (host.getPort()>0) {
hostE.setAttributeValue("port",Integer.toString(host.getPort()));
}
if (host.getAuthName()!=null) {
hostE.setAttributeValue("auth",host.getAuthName());
}
dest.send(hostE);
dest.send(constructor.createElementEnd(AdminXML.NM_ADMIN));
dest.send(constructor.createCharacters("\n"));
}
for (Host host : hosts.values()) {
Element hostE = constructor.createElement(AdminXML.NM_HOST);
hostE.setAttributeValue("database",host.getDatabaseName());
hostE.setAttributeValue("name",host.getName());
if (host.getAddress()!=null) {
hostE.setAttributeValue("address",host.getAddress());
}
if (host.getPort()>0) {
hostE.setAttributeValue("port",Integer.toString(host.getPort()));
}
dest.send(hostE);
dest.send(constructor.createElementEnd(AdminXML.NM_HOST));
dest.send(constructor.createCharacters("\n"));
}
dest.send(constructor.createElementEnd(AdminXML.NM_SERVER));
dest.send(constructor.createDocumentEnd());
}