perfsonar-dev - webadmin eXist db connection for creation of SSHTELNET MP 3.0-RC1
Subject: perfsonar development work
List archive
- From: Stijn Melis <>
- To: 'Michael Michalis' <>, Loukik Kudarimoti <>, "" <>
- Subject: webadmin eXist db connection for creation of SSHTELNET MP 3.0-RC1
- Date: Tue, 29 Jan 2008 16:44:03 +0100
Hello,
I am trying to implement the action for storing the metadata file into the eXist database, but I keep getting errors.
I'd like the metadata file to be located into the root of the eXist, e.g. when I log in to xmldb:exist://127.0.0.1:8680/exist/xmlrpc I see the following:
rss collection
system collection
sshtelnetmetadata.xml
I used the RRDMAHandler as a template, but this does not seem to do what I want it to do. I attached the corresponding method to the mail.
It gets to the part where the xmlDbManager is created, but then generates an Exception. This is the output I get:
adminPass: admin
newAdminPass: admin
key: component.mp.xmldb.metadata_file_name
value: sshtelnetmetadata.xml
key: component.mp.xmldb.db_uri
value: xmldb:exist://127.0.0.1:8680/exist/xmlrpc/db
key: component.mp.xmldb.db_username
value: sshtelnet
key: component.mp.xmldb.db_password
value: sshtelnet
key: component.mp.xmldb.db_adminpassword
value: admin
creating eXist stuff
existURI: 127.0.0.1:8680/exist/xmlrpc
username: admin
pass: admin
org.xmldb.api.base.XMLDBException:
at org.xmldb.api.DatabaseManager.getDatabase(Unknown Source)
at org.xmldb.api.DatabaseManager.getCollection(Unknown Source)
at perfSONARWebAdmin.auxiliary.xmlDB.xmlDBManagerImpl.<init>(xmlDBManagerImpl.java:57)
at org.perfsonar.service.measurementPoint.webAdmin.SSHTelnetHandler.existActions(Unknown Source)
at org.perfsonar.service.measurementPoint.webAdmin.SSHTelnetHandler.handleExist(Unknown Source)
...
I tried it with the URI equal to xmldb:exist://127.0.0.1:8680/exist/xmlrpc/db and also with 127.0.0.1:8680/exist/xmlrpc/db, but this doesn't seem to work either.
Does anyone know what I'm doing wrong here?
thanks in advance,
Stijn
private void existActions(WizardProperties finalProperties)
throws Exception {
try {
// Initiating ServiceProperties classes for handling
input to the
// service.properties and servlet.properties file
ServiceProperties serviceProperties = new
ServicePropertiesImpl(
ServicePath + ServicePropertiesPath);
// Any changes happening to the URL of the exist db
and on the admin
// password should be reflected on the
servlet.properties as well
ServiceProperties servletProperties = new
ServicePropertiesImpl(
ServicePath + ServletPropertiesPath);
// Get an iterator for all service properties
Iterator it =
serviceProperties.getProperties().keySet().iterator();
// Get the type of the service. Will be used for
making the new db
// collection
String metadataName = servletProperties.getProperty(
"component.mp.xmldb.metadata_file_name").trim();
// Naming the new collection on exist db
String dbCollection = metadataName;
// Initializing all necessary fileds
String adminPass = null;
String existURI = "";
String newAdminPass = null;
String username = null;
String password = null;
String confFile = null;
// Need to get the new xmlDBURI and old and new admin
password so that
// we can make the changes
while (it.hasNext()) {
String key = (String) it.next();
if (key.endsWith("xmldb.db_adminpassword")) {
adminPass =
serviceProperties.getProperty(key).trim();
newAdminPass =
finalProperties.getProperty(key).trim();
}
if (key.endsWith("xmldb.db_uri")) {
existURI =
finalProperties.getProperty(key);
}
}
System.out.println("adminPass: " + adminPass +
"\nnewAdminPass: " + newAdminPass);
// If admin pass is not set than its considered to be
empty
if (adminPass == null) {
adminPass = "";
}
it = finalProperties.orderedKeys();
// Iterating though the users input
while (it.hasNext()) {
String key = (String) it.next();
System.out.println("key: " + key + "\nvalue:
" + finalProperties
.getProperty(key));
// The input from the user is also set in
service properties with a
// slight modification for the xmldb uri. We
need to add the
// collection at the end of the URI
if (!key.endsWith("xmldb.db_uri")) {
serviceProperties.setProperty(key,
finalProperties
.getProperty(key));
} else {
serviceProperties.setProperty(key,
existURI + "/db/");
}
// Setting also the wizard properties
properties.setWizardProperty(key,
finalProperties
.getWizardProperty(key));
// Also getting all needed information in
orer to configure the
// exist db
if (key.endsWith("xmldb.db_username")) {
username =
finalProperties.getProperty(key);
}
if (key.endsWith("xmldb.db_password")) {
password =
finalProperties.getProperty(key);
}
if (key.endsWith("metadata_file_name")) {
confFile =
finalProperties.getProperty(key);
}
}
// Creating all necessary collections and users in
exist
if (existURI == null) {
throw new Exception("eXist xmldb URI is
empty!\n");
} else {
System.out.println("creating eXist stuff");
if (existURI.startsWith("xmldb:exist://"))
existURI =
existURI.substring("xmld:exist://".length()+1, existURI.length());
if (existURI.endsWith("/db"))
existURI = existURI.substring(0,
existURI.length()-"/db".length());
System.out.println("existURI: " + existURI +
"\nusername: admin\npass: " + adminPass);
xmlDBManager manager = new
xmlDBManagerImpl(existURI, "admin",
adminPass);
System.out.println("eXistManager : " +
manager);
// Creating collection and users
//manager.createCollection(dbCollection);
System.out.println("eXist creating user with
info: " + dbCollection + ", " + username + ", " + password);
manager.createUser(dbCollection, username,
password, null);
System.out.println("eXist user created");
// Adding the metadata config document
manager.getCollection(dbCollection).addDocument(new File(confFile),
username);
System.out.println("eXist metadata added");
// Modifying the admin user password
if (newAdminPass != null){
manager.modifyUser("admin",
newAdminPass, null, null);
System.out.println("eXist admin
password changed");
}
serviceProperties.storeProperties();
properties.storeToXML(new
FileOutputStream(new File(ServicePath
+ WizardPropertiesPath)), "
Last Modification "
+
Calendar.getInstance().getTime().toString());
System.out.println("eXist xml stored");
}
} catch (Exception e) {
e.printStackTrace();
}
}
- webadmin eXist db connection for creation of SSHTELNET MP 3.0-RC1, Stijn Melis, 01/29/2008
- Re: [pS-dev] webadmin eXist db connection for creation of SSHTELNET MP 3.0-RC1, Michael Michalis, 01/29/2008
- Re: [pS-dev] webadmin eXist db connection for creation of SSHTELNET MP 3.0-RC1, Stijn Melis, 01/29/2008
- Re: [pS-dev] webadmin eXist db connection for creation of SSHTELNET MP 3.0-RC1, Michael Michalis, 01/30/2008
- Re: [pS-dev] webadmin eXist db connection for creation of SSHTELNET MP 3.0-RC1, Stijn Melis, 01/30/2008
- Re: [pS-dev] webadmin eXist db connection for creation of SSHTELNET MP 3.0-RC1, Michael Michalis, 01/30/2008
- Re: [pS-dev] webadmin eXist db connection for creation of SSHTELNET MP 3.0-RC1, Stijn Melis, 01/29/2008
- Re: [pS-dev] webadmin eXist db connection for creation of SSHTELNET MP 3.0-RC1, Michael Michalis, 01/29/2008
Archive powered by MHonArc 2.6.16.