perfsonar-dev - perfsonar: r3185 - in branches/WebAdmin/perfSONARWebAdmin: admin/exist admin/service admin/wizard admin/wizard/services auxiliary auxiliary/xmlDB
Subject: perfsonar development work
List archive
perfsonar: r3185 - in branches/WebAdmin/perfSONARWebAdmin: admin/exist admin/service admin/wizard admin/wizard/services auxiliary auxiliary/xmlDB
Chronological Thread
- From:
- To:
- Subject: perfsonar: r3185 - in branches/WebAdmin/perfSONARWebAdmin: admin/exist admin/service admin/wizard admin/wizard/services auxiliary auxiliary/xmlDB
- Date: Tue, 8 Jan 2008 03:23:40 -0500
Author: michalis
Date: 2008-01-08 03:23:40 -0500 (Tue, 08 Jan 2008)
New Revision: 3185
Modified:
branches/WebAdmin/perfSONARWebAdmin/admin/exist/eXistAdmin.java
branches/WebAdmin/perfSONARWebAdmin/admin/service/Admin.java
branches/WebAdmin/perfSONARWebAdmin/admin/wizard/Wizard.java
branches/WebAdmin/perfSONARWebAdmin/admin/wizard/services/RRDMAHandler.java
branches/WebAdmin/perfSONARWebAdmin/auxiliary/Authenticator.java
branches/WebAdmin/perfSONARWebAdmin/auxiliary/ServicePropertiesImpl.java
branches/WebAdmin/perfSONARWebAdmin/auxiliary/xmlDB/XMLDocument.java
branches/WebAdmin/perfSONARWebAdmin/auxiliary/xmlDB/XMLDocumentImpl.java
branches/WebAdmin/perfSONARWebAdmin/auxiliary/xmlDB/eXistServletProperties.java
branches/WebAdmin/perfSONARWebAdmin/auxiliary/xmlDB/eXistServletPropertiesImpl.java
branches/WebAdmin/perfSONARWebAdmin/auxiliary/xmlDB/existAuthenticatorImpl.java
branches/WebAdmin/perfSONARWebAdmin/auxiliary/xmlDB/existDocument.java
branches/WebAdmin/perfSONARWebAdmin/auxiliary/xmlDB/xmlDBCollectionImpl.java
branches/WebAdmin/perfSONARWebAdmin/auxiliary/xmlDB/xmlDBManager.java
branches/WebAdmin/perfSONARWebAdmin/auxiliary/xmlDB/xmlDBManagerImpl.java
Log:
Committing recent code changes
Modified: branches/WebAdmin/perfSONARWebAdmin/admin/exist/eXistAdmin.java
===================================================================
--- branches/WebAdmin/perfSONARWebAdmin/admin/exist/eXistAdmin.java
2008-01-08 06:04:22 UTC (rev 3184)
+++ branches/WebAdmin/perfSONARWebAdmin/admin/exist/eXistAdmin.java
2008-01-08 08:23:40 UTC (rev 3185)
@@ -2,7 +2,11 @@
import java.io.File;
import java.io.IOException;
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.net.SocketException;
+import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
@@ -45,32 +49,34 @@
// class fields
// Properties file for the admin servlet
-
- //The full path where the service is installed
- private static String servicePath;
- //The path to the conf directory
- private static final String
confPath="/WEB-INF/classes/perfsonar/conf/";
- //The path to the exist properties
- private static final String existProperties =
confPath+"servlet.properties";
- //The driver to use for connecting to exist
+ // The full path where the service is installed
+ private static String servicePath;
+
+ // The path to the conf directory
+ private static final String confPath =
"/WEB-INF/classes/perfsonar/conf/";
+
+ // The path to the exist properties
+ private static final String existProperties = confPath
+ + "service.properties";
+
+ // The driver to use for connecting to exist
public static final String driver = "org.exist.xmldb.DatabaseImpl";
- //eXist db manager
+ // eXist db manager
private xmlDBManager manager;
- //xmldb collection
+ // xmldb collection
private xmlDBCollection collection;
- private eXistServletProperties servletProperties;
+ private eXistServletPropertiesImpl servletProperties;
- //Authenticator class used for authentication
+ // Authenticator class used for authentication
private Authenticator authenticator;
-
- //The doctypr of the html document. Currently Html 4.01 transitional
+
+ // The doctypr of the html document. Currently Html 4.01 transitional
private static final String doctype = "<!DOCTYPE HTML PUBLIC
\"-//W3C//DTD HTML 4.01 Transitional//EN\"
\"http://www.w3.org/TR/html4/loose.dtd\">";
-
//
-----------------------------------------------------------------------
// public methods
@@ -83,19 +89,19 @@
super.init(config);
ServletContext sc = getServletContext();
- servicePath=sc.getRealPath("/");
+ servicePath = sc.getRealPath("/");
// Loading servlet properties and initializing authenticator
try {
- servletProperties = new eXistServletPropertiesImpl(
- servicePath+ existProperties);
+ servletProperties = new
eXistServletPropertiesImpl(servicePath
+ + existProperties);
authenticator = new
existAuthenticatorImpl("xmldb:exist://"
- + servletProperties.getDBLocation(),
servletProperties
+ +
servletProperties.getModDBLocation(), servletProperties
.getAdminPassword());
} catch (Exception e) {
// TODO Auto-generated catch block
throw new ServletException("Failed loading
Properties\n"
-
+servletProperties.getDBLocation()+"\n"
-
+servletProperties.getAdminPassword()+"\n"
+ + servletProperties.getDBLocation() +
"\n"
+ +
servletProperties.getAdminPassword() + "\n"
+ e.getMessage());
}
@@ -129,8 +135,8 @@
HttpSession session = request.getSession(true);
ServletOutputStream out = response.getOutputStream();
- servletProperties = new eXistServletPropertiesImpl(
- servicePath+ existProperties);
+ servletProperties = new eXistServletPropertiesImpl(servicePath
+ + existProperties);
// Set the inactive interval for this session
if (session.isNew())
session.setMaxInactiveInterval(1800);
@@ -151,10 +157,10 @@
} else {
// else reload the manager so that changes
can be shown
try {
- manager = new
xmlDBManagerImpl(servletProperties
- .getDBLocation(),
(String) session
-
.getAttribute("user"), (String) session
-
.getAttribute("password"));
+ manager = new
xmlDBManagerImpl("xmldb:exist://"
+ +
servletProperties.getModDBLocation(),
+ (String)
session.getAttribute("user"),
+ (String)
session.getAttribute("password"));
collection =
manager.getCollection(null);
} catch (Exception e) {
@@ -208,13 +214,14 @@
session.setAttribute("authenticated", false);
try {
// Authenticate user
-
+
if (authenticator.authenticate(user,
password)) {
-
- // If the user is
authenticated the create the db
+
+ // If the user is
authenticated then create the db
// manager
- manager = new
xmlDBManagerImpl(servletProperties
-
.getDBLocation(), user, password);
+ manager = new
xmlDBManagerImpl("xmldb:exist://"
+ +
servletProperties.getModDBLocation(), user,
+ password);
collection =
manager.getCollection(null);
session.setAttribute("authenticated", true);
session.setAttribute("user",
user);
@@ -300,7 +307,7 @@
private void collections_page(ServletOutputStream out,
HttpServletRequest request) throws Exception {
// Outputting the page
- preempt(out,true);
+ preempt(out, true);
String create = null;
String edit = null;
String action = null;
@@ -361,12 +368,10 @@
edit = request.getParameter("Edit");
// Outputting the management section. Contains all child and
resources
// of the requests collection starting with the root /db
- out
- .println("<div class=\"manage\" >");
-
- out
- .println("<div class=\"showResource\" >");
-
+ out.println("<div class=\"manage\" >");
+
+ out.println("<div class=\"showResource\" >");
+
out.println("<br><p><h4>Collection Management<h4></p>");
out.println("<p>");
@@ -398,7 +403,7 @@
}
} catch (Exception e1) {
error_message("An error occurred!\n" + getFault(e1),
out, true);
-
+
}
out.println("<form action=\"eXistAdmin\" method=\"GET\"> ");
@@ -490,9 +495,9 @@
+ documents[i] + "\" >");
out.println("</td>");
out.println("<td>");
- String DBLocation = servletProperties.getDBLocation();
+ String DBLocation =
servletProperties.getModDBLocation();
DBLocation = DBLocation.substring(0,
DBLocation.indexOf("/xmlrpc"));
-
+ DBLocation=getRealIp(DBLocation);
out.println("<a href=http://" + DBLocation + "/rest/"
+ currentCollection.getName() + "/" +
documents[i] + " >"
+ documents[i] + "</a>");
@@ -842,8 +847,7 @@
false);
} else {
// Present the input fields
- out
- .println("<div
class=\"input\" >");
+ out.println("<div class=\"input\" >");
out
.println("<p><form
action=\"eXistAdmin\" method=\"POST\""
@@ -884,7 +888,7 @@
.println("Enter the new collections name(/db/newcollection)");
out.println("</td></tr>");
out.println("<tr><td>");
-
+
out
.println("<input type=\"radio\" name=\"type\" value=\"Resource\" >
Resource");
out.println("</td>");
@@ -893,13 +897,15 @@
.println("<input type=\"file\" name=\"newResource\" value=\"\" >");
out.println("</td>");
out.println("<td>");
- out.println("Upload your
resource(Only xml files will be accepted!)!");
+ out
+
.println("Upload your resource(Only xml files will be accepted!)!");
out.println("</td></tr>");
out.println("</table></p>");
} else {
// If this is an edit then we
just show the name of the
// resource to be edited
- out.println("<p><h4>Selected
Resource: " + document+"</h4>");
+ out.println("<p><h4>Selected
Resource: " + document
+ + "</h4>");
out
.println("<input type=\"hidden\" name=\"resource\" value=\""
+ document + "\" >");
@@ -997,6 +1003,43 @@
}
/**
+ * Method used for converting localhost and 127.0.0.1 address to real
ip adress
+ * @param location
+ * The address of the DB
+ * @return
+ * The real ip of the db
+ * @throws Exception
+ */
+ private String getRealIp(String location) throws Exception {
+ // A small piece off code for converting possible "localhost"
or
+ // "127.0.0.1" addresses to real ip. This is necessaru
because some
+ // functionalities of the exist admin servlet will not work
without
+ // a real ip address
+ if (location.startsWith("localhost")
+ || location.startsWith("127.0.0.1")) {
+ Enumeration<NetworkInterface> e = NetworkInterface
+ .getNetworkInterfaces();
+ while (e.hasMoreElements()) {
+ NetworkInterface netface = (NetworkInterface)
e
+ .nextElement();
+ if (netface.getName().equals("eth0")) {
+ Enumeration e2 =
netface.getInetAddresses();
+ if (e2.hasMoreElements()) {
+ e2.nextElement();
+ InetAddress ip =
(InetAddress) e2.nextElement();
+ location = ip.getHostAddress()
+ +
location.substring(location
+
.indexOf(":"));
+ }
+
+ }
+
+ }
+ }
+ return location;
+ }
+
+ /**
* Method to output the users mmanage page
*
* @param out
@@ -1008,14 +1051,12 @@
private void users_page(ServletOutputStream out, HttpServletRequest
request)
throws Exception {
- preempt(out,true);
+ preempt(out, true);
// Displaying all the users and their information
- out
- .println("<div class=\"manage\" >");
-
- out
- .println("<div class=\"showResource\" >");
+ out.println("<div class=\"manage\" >");
+ out.println("<div class=\"showResource\" >");
+
out.println("<br><p><h4>User Management<h4></p>");
out.println("<p>");
@@ -1189,9 +1230,11 @@
}
if (formUser.equals("admin")) {
servletProperties
-
.setAdminPassword(password.trim());
+
.setAdminPassword(password
+
.trim());
servletProperties.store();
-
authenticator.setPassword(password.trim());
+
authenticator.setPassword(password
+
.trim());
}
refresh_message(
"Action copleted successfully! Please refresh!",
@@ -1293,7 +1336,7 @@
}
}
-
+
// This means that the user wants to
create a new user. We
// add an additional field
if (!noUser) {
@@ -1330,7 +1373,7 @@
out
.println("<td><input type=\"checkbox\" name=\"keep\" value=\"\" size=20
></td>");
out.println("</tr>");
-
+
}
// The home collection fields
out.println("<tr><th>Home
Collection</th>");
@@ -1427,12 +1470,11 @@
private void error_page(String message, ServletOutputStream out,
boolean back) throws IOException {
- preempt(out,true);
+ preempt(out, true);
out.println("<div class=\"info\">");
- out.println("<br><p><h3>"+message+"</h3>");
+ out.println("<br><p><h3>" + message + "</h3>");
if (back) {
- out
- .println("<a
href=\"/perfSONAR/eXistAdmin\" \">Go Back</a>");
+ out.println("<a href=\"/perfSONAR/eXistAdmin\" \">Go
Back</a>");
}
out.println("</p>");
out.println("</div>");
@@ -1457,14 +1499,14 @@
if (!logged) {
login = "Please login in order to make
modifications.";
}
- preempt(out,logged);
+ preempt(out, logged);
out.println("<div class=\"manage\" >");
-
+
out.println("<div class=\"showResource\" >");
out
.println("<br/><p>Welcome to the eXist
database configuration service for perfSONAR services. "
- + login );
+ + login);
if (!logged) {
@@ -1485,8 +1527,7 @@
.println("<input type=\"submit\"
name=\"login\" value=\"login\" />");
out.println("</form>");
out.println("</p>");
- }
- else{
+ } else {
out.println("</p>");
}
@@ -1530,7 +1571,7 @@
out.println("<div class=\"info\" >");
out.println("<p>");
- out.println("<h3>"+message+"</h3>");
+ out.println("<h3>" + message + "</h3>");
if (back) {
out
@@ -1559,16 +1600,11 @@
private void refresh_message(String message, ServletOutputStream out,
String manage, String collection) throws IOException {
- out
- .println("<div class=\"info\">");
+ out.println("<div class=\"info\">");
out.println("<p> ");
- out.println("<h3>"+message+"</h3>");
- out
- .println("<a href=\"eXistAdmin?function="
- + manage
- + "&ChildCollection="
- + collection
- + "\">Refresh</a>");
+ out.println("<h3>" + message + "</h3>");
+ out.println("<a href=\"eXistAdmin?function=" + manage
+ + "&ChildCollection=" + collection +
"\">Refresh</a>");
out.println("</p>");
out.println("</div>");
out.println("</body>");
@@ -1576,24 +1612,24 @@
out.close();
}
-
+
/**
* @param out
* @param logged
* @throws IOException
*/
- private void preempt(ServletOutputStream out,boolean logged) throws
IOException{
+ private void preempt(ServletOutputStream out, boolean logged)
+ throws IOException {
out.println("<html>");
- out.println("<head><link rel=\"stylesheet\" type=\"text/css\"
href=\"default.css\">");
+ out
+ .println("<head><link rel=\"stylesheet\"
type=\"text/css\" href=\"default.css\">");
out.println("<title >");
out.println("perfSONAR eXist database administration page.");
out.println("</title>");
out.println("</head>");
- out
- .println("<body>");
+ out.println("<body>");
- out
- .println("<div class=\"content\" >");
+ out.println("<div class=\"content\" >");
out.println("<p>");
out.println("<ul>");
out
@@ -1602,12 +1638,13 @@
.println("<li><a
href=\"eXistAdmin?function=users\" >Manage Users</a></li>");
if (logged) {
- out.println("<li><a href=\"eXistAdmin?logout=LogOut\"
>Log Out</a></li>");
+ out
+ .println("<li><a
href=\"eXistAdmin?logout=LogOut\" >Log Out</a></li>");
}
out.println("</ul>");
out.println("</p>");
-
+
out.println("</div>");
-
+
}
}
Modified: branches/WebAdmin/perfSONARWebAdmin/admin/service/Admin.java
===================================================================
--- branches/WebAdmin/perfSONARWebAdmin/admin/service/Admin.java
2008-01-08 06:04:22 UTC (rev 3184)
+++ branches/WebAdmin/perfSONARWebAdmin/admin/service/Admin.java
2008-01-08 08:23:40 UTC (rev 3185)
@@ -14,6 +14,8 @@
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
+import org.apache.commons.codec.binary.Base64;
+
import perfSONARWebAdmin.auxiliary.Authenticator;
import perfSONARWebAdmin.auxiliary.AuthenticatorImpl;
import perfSONARWebAdmin.auxiliary.ServiceProperties;
@@ -34,17 +36,18 @@
//
-----------------------------------------------------------------------
// class fields
- //Path to service properties
+ // Path to service properties
private static final String serviceProperties =
"/WEB-INF/classes/perfsonar/conf/service.properties";
- //Path to logging properties
+ // Path to logging properties
private static final String log4jProperties =
"/WEB-INF/classes/perfsonar/conf/log4j.properties";
-
- //Path to servlet properties
- private static final String
ServletPropertiesPath="/WEB-INF/classes/perfsonar/conf/servlet.properties";
- //Path to service installation directory
- private static String servicePath=null;
+ // Path to servlet properties
+ private static final String ServletPropertiesPath =
"/WEB-INF/classes/perfsonar/conf/servlet.properties";
+
+ // Path to service installation directory
+ private static String servicePath = null;
+
//
-----------------------------------------------------------------------
// public methods
@@ -91,7 +94,7 @@
}
public void doPost(HttpServletRequest request, HttpServletResponse
response)
- throws IOException {
+ throws IOException, ServletException {
String Type = "";
HttpSession session = request.getSession(true);
@@ -99,18 +102,17 @@
session.setMaxInactiveInterval(1800);
ServletOutputStream out = response.getOutputStream();
ServletContext sc = getServletContext();
-// Getting the service path
- servicePath =sc.getRealPath("/") ;
+ // Getting the service path
+ servicePath = sc.getRealPath("/");
ServiceProperties properties;
// Loading the servlet properties
- ServletProperties servletProperties = new
ServletPropertiesImpl(servicePath
- + ServletPropertiesPath);
+ ServletProperties servletProperties = new
ServletPropertiesImpl(
+ servicePath + ServletPropertiesPath);
Authenticator authenticator = new
AuthenticatorImpl(servletProperties);
String lock = "disabled";
String filePath = "";
response.setContentType("text/html");
-
// Setting the path for the properties file based on the type
of
// properties file
if (session.getAttribute("propertyType") != null) {
@@ -129,7 +131,7 @@
* response.setStatus(response.SC_NOT_FOUND);
session.invalidate(); }
*/
- // If the properties haven't been set is seession the set them
+ // If the properties haven't been set in session the set them
if (session.getAttribute("properties") == null) {
// Checking firstly if the files really exists
@@ -141,6 +143,8 @@
else {
properties = null;
session.setAttribute("properties",
properties);
+ throw new ServletException("Properties file
does not exist! "
+ + filePath + "\n"
+filePath);
}
}
// Else get the properties from the session
@@ -176,9 +180,10 @@
// The validation process
// Getting the user name and password
String userInfo =
authorization.substring(6).trim();
- BASE64Decoder decoder = new BASE64Decoder();
- String nameAndPassword = new String(decoder
- .decodeBuffer(userInfo));
+ Base64 coder = new Base64();
+ // BASE64Decoder decoder = new
BASE64Decoder();
+ String nameAndPassword = new
String(coder.decode(userInfo
+ .getBytes()));
int index = nameAndPassword.indexOf(":");
String user = nameAndPassword.substring(0,
index);
String password =
nameAndPassword.substring(index + 1);
@@ -256,8 +261,15 @@
if (properties != null) {
main_page(out, properties, lock);
} else {
+ String path;
+ if(Type.equals("loggingProperties")){
+ path=
servicePath+this.log4jProperties;
+ }
+ else{
+ path=
servicePath+this.serviceProperties;
+ }
error_page(out, "service properties
file does not exist! "
- + filePath + "\n" +
servicePath, Type);
+ + filePath + "\n"
+path , Type);
}
}
}
@@ -272,7 +284,7 @@
* @param response
* The httpServlet response
*/
-
+
private void askForPassword(HttpServletResponse response) {
response.setStatus(response.SC_UNAUTHORIZED); // I.e., 401
@@ -293,7 +305,7 @@
*/
private void restart_page(ServletOutputStream out, String Type)
throws IOException {
-
+
preempt(out);
out.println("<div class=\"info\" >");
out.println("<h3>perfSONAR Administration page</h3>");
@@ -301,9 +313,7 @@
out.println("<h4>");
out
.println("The properties file has been
modifyied. Please restart tomcat for any changes to take effect!</h4>");
- out
- .println("<a href=\"ServiceAdmin?"
- + Type + "\">Go Back");
+ out.println("<a href=\"ServiceAdmin?" + Type + "\">Go Back");
out.println("</p>");
out.println("</div>");
out.println("</body>");
@@ -328,11 +338,9 @@
preempt(out);
out.println("<div class=\"info\" >");
out.println("<h3>perfSONAR Administration page</h2>");
- out.println("<p><h4>"+error+"</h4></p>");
+ out.println("<p><h4>" + error + "</h4></p>");
out.println("<p> ");
- out
- .println("<a href=\"ServiceAdmin?"
- + Type + "\">Go Back");
+ out.println("<a href=\"ServiceAdmin?" + Type + "\">Go Back");
out.println("</p>");
out.println("</div>");
out.println("</body>");
@@ -342,9 +350,10 @@
private void main_page(ServletOutputStream out,
ServiceProperties properties, String lock) throws
IOException {
- preempt(out);
+ preempt(out);
out.println("<div class=\"manage\">");
- out.println("<h3>perfSONAR service properties Administration
page</h3>");
+ out
+ .println("<h3>perfSONAR service properties
Administration page</h3>");
out.println("<h4>Service Properties Table</h4>");
// Different output depending on the user unlocking or
locking the table
if (!lock.equals("enabled")) {
@@ -425,8 +434,7 @@
+ " type=\"submit\"
name=\"add\" value=\"Add property\" /> ");
out.println("</p>");
out.println("</form>");
- out
- .println("<p>Choose a property to
remove.</p>");
+ out.println("<p>Choose a property to remove.</p>");
out.println("<form action=\"ServiceAdmin\"
method=\"POST\"> ");
out.println("<p>");
out.println("<select name=\"property\">");
@@ -448,11 +456,12 @@
out.println("</html>");
}
-
- private void preempt(ServletOutputStream out) throws IOException{
-
+
+ private void preempt(ServletOutputStream out) throws IOException {
+
out.println("<html>");
- out.println("<head><link rel=\"stylesheet\" type=\"text/css\"
href=\"default.css\">");
+ out
+ .println("<head><link rel=\"stylesheet\"
type=\"text/css\" href=\"default.css\">");
out.println("<title>");
out.println("perfSONAR service administration page.");
out.println("</title>");
Modified: branches/WebAdmin/perfSONARWebAdmin/admin/wizard/Wizard.java
===================================================================
--- branches/WebAdmin/perfSONARWebAdmin/admin/wizard/Wizard.java
2008-01-08 06:04:22 UTC (rev 3184)
+++ branches/WebAdmin/perfSONARWebAdmin/admin/wizard/Wizard.java
2008-01-08 08:23:40 UTC (rev 3185)
@@ -20,6 +20,8 @@
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
+import org.apache.commons.codec.binary.Base64;
+
import perfSONARWebAdmin.auxiliary.Authenticator;
import perfSONARWebAdmin.auxiliary.AuthenticatorImpl;
@@ -30,7 +32,6 @@
import perfSONARWebAdmin.auxiliary.wizard.WizardProperties;
import perfSONARWebAdmin.auxiliary.wizard.WizardProperty;
-import sun.misc.BASE64Decoder;
/**
* Servlet to be used as a wizard for configurating perfSONAR service
@@ -147,6 +148,7 @@
// TO DO: Add feature to prevent simultainous configuration
// Getting the ServletOutputStream, necessary for html output
+ response.setContentType("text/html");
ServletOutputStream out = response.getOutputStream();
// Setting the stream to the HTMLOutput class
output.setOuputStream(out);
@@ -232,10 +234,10 @@
// The validation process
// Getting the user name and password
String userInfo =
authorization.substring(6).trim();
- // TO DO the decoder needs to change into a
better supported one
- BASE64Decoder decoder = new BASE64Decoder();
- String nameAndPassword = new String(decoder
- .decodeBuffer(userInfo));
+ Base64 coder = new Base64();
+ // BASE64Decoder decoder = new
BASE64Decoder();
+ String nameAndPassword = new
String(coder.decode(userInfo
+ .getBytes()));
int index = nameAndPassword.indexOf(":");
String user = nameAndPassword.substring(0,
index);
String password =
nameAndPassword.substring(index + 1);
Modified:
branches/WebAdmin/perfSONARWebAdmin/admin/wizard/services/RRDMAHandler.java
===================================================================
---
branches/WebAdmin/perfSONARWebAdmin/admin/wizard/services/RRDMAHandler.java
2008-01-08 06:04:22 UTC (rev 3184)
+++
branches/WebAdmin/perfSONARWebAdmin/admin/wizard/services/RRDMAHandler.java
2008-01-08 08:23:40 UTC (rev 3185)
@@ -7,10 +7,7 @@
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
-import java.net.InetAddress;
-import java.net.NetworkInterface;
import java.util.Calendar;
-import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Iterator;
@@ -23,8 +20,6 @@
import perfSONARWebAdmin.auxiliary.wizard.HTMLOutput;
import perfSONARWebAdmin.auxiliary.wizard.WizardProperties;
import perfSONARWebAdmin.auxiliary.wizard.WizardProperty;
-import perfSONARWebAdmin.auxiliary.xmlDB.eXistServletProperties;
-import perfSONARWebAdmin.auxiliary.xmlDB.eXistServletPropertiesImpl;
import perfSONARWebAdmin.auxiliary.xmlDB.xmlDBManager;
import perfSONARWebAdmin.auxiliary.xmlDB.xmlDBManagerImpl;
@@ -600,12 +595,7 @@
if (existURI == null) {
throw new Exception("eXist xmldb URI is empty!\n");
} else {
- // Have to modify the existURI so that it will work
with my
- // xmlDBManager class.Note to self: Have to change
the way it uses
- // the URI to be consistant with the way the service
is using it.
- String modExistURI = existURI
- .substring(existURI.indexOf("://") +
3);
- xmlDBManager manager = new
xmlDBManagerImpl(modExistURI, "admin",
+ xmlDBManager manager = new xmlDBManagerImpl(existURI,
"admin",
adminPass);
// Creating collection and users
manager.createCollection(dbCollection);
@@ -615,41 +605,7 @@
username);
// Modifying the admin user password
manager.modifyUser("admin", newAdminPass, null, null);
-
- // eXistServletProperties is a wrapper class, so that
we can apply
- // changes to admin password. This is necessary
because th exist
- // admin servlet will not work otherwise
- eXistServletProperties pr = new
eXistServletPropertiesImpl(
- ServicePath + ServletPropertiesPath);
- pr.setAdminPassword(newAdminPass);
- // A small piece off code for converting possible
"localhost" or
- // "127.0.0.1" addresses to real ip. This is
necessaru because some
- // functionalities of the exist admin servlet will
not work without
- // a real ip address
- if (modExistURI.startsWith("localhost")
- ||
modExistURI.startsWith("127.0.0.1")) {
- Enumeration<NetworkInterface> e =
NetworkInterface
- .getNetworkInterfaces();
- while (e.hasMoreElements()) {
- NetworkInterface netface =
(NetworkInterface) e
- .nextElement();
- if (netface.getName().equals("eth0"))
{
- Enumeration e2 =
netface.getInetAddresses();
- if (e2.hasMoreElements()) {
- e2.nextElement();
- InetAddress ip =
(InetAddress) e2.nextElement();
- modExistURI =
ip.getHostAddress()
- +
modExistURI.substring(modExistURI
-
.indexOf(":"));
- }
-
- }
-
- }
- }
- pr.setDBLocation(modExistURI);
- // Storing all changes
- pr.store();
+
serviceProperties.storeProperties();
properties.storeToXML(new FileOutputStream(new
File(ServicePath
+ WizardPropertiesPath)), " Last
Modification "
Modified: branches/WebAdmin/perfSONARWebAdmin/auxiliary/Authenticator.java
===================================================================
--- branches/WebAdmin/perfSONARWebAdmin/auxiliary/Authenticator.java
2008-01-08 06:04:22 UTC (rev 3184)
+++ branches/WebAdmin/perfSONARWebAdmin/auxiliary/Authenticator.java
2008-01-08 08:23:40 UTC (rev 3185)
@@ -1,6 +1,5 @@
package perfSONARWebAdmin.auxiliary;
-import org.xmldb.api.base.XMLDBException;
/**
* Interface for authentication on admin servlets
Modified:
branches/WebAdmin/perfSONARWebAdmin/auxiliary/ServicePropertiesImpl.java
===================================================================
--- branches/WebAdmin/perfSONARWebAdmin/auxiliary/ServicePropertiesImpl.java
2008-01-08 06:04:22 UTC (rev 3184)
+++ branches/WebAdmin/perfSONARWebAdmin/auxiliary/ServicePropertiesImpl.java
2008-01-08 08:23:40 UTC (rev 3185)
@@ -1,7 +1,6 @@
package perfSONARWebAdmin.auxiliary;
import java.io.FileInputStream;
-import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Date;
Modified: branches/WebAdmin/perfSONARWebAdmin/auxiliary/xmlDB/XMLDocument.java
===================================================================
--- branches/WebAdmin/perfSONARWebAdmin/auxiliary/xmlDB/XMLDocument.java
2008-01-08 06:04:22 UTC (rev 3184)
+++ branches/WebAdmin/perfSONARWebAdmin/auxiliary/xmlDB/XMLDocument.java
2008-01-08 08:23:40 UTC (rev 3185)
@@ -1,11 +1,8 @@
package perfSONARWebAdmin.auxiliary.xmlDB;
-import java.util.Date;
-
import javax.xml.transform.TransformerException;
import org.w3c.dom.Document;
-import org.xmldb.api.base.XMLDBException;
/**
* Interface describing an xml Document in exist
Modified:
branches/WebAdmin/perfSONARWebAdmin/auxiliary/xmlDB/XMLDocumentImpl.java
===================================================================
--- branches/WebAdmin/perfSONARWebAdmin/auxiliary/xmlDB/XMLDocumentImpl.java
2008-01-08 06:04:22 UTC (rev 3184)
+++ branches/WebAdmin/perfSONARWebAdmin/auxiliary/xmlDB/XMLDocumentImpl.java
2008-01-08 08:23:40 UTC (rev 3185)
@@ -1,6 +1,6 @@
package perfSONARWebAdmin.auxiliary.xmlDB;
-import java.io.OutputStream;
+
import java.io.StringWriter;
import java.util.Date;
@@ -15,7 +15,6 @@
import org.w3c.dom.Document;
import org.xmldb.api.base.Resource;
import org.xmldb.api.base.XMLDBException;
-import org.xmldb.api.modules.BinaryResource;
import org.xmldb.api.modules.XMLResource;
/**
Modified:
branches/WebAdmin/perfSONARWebAdmin/auxiliary/xmlDB/eXistServletProperties.java
===================================================================
---
branches/WebAdmin/perfSONARWebAdmin/auxiliary/xmlDB/eXistServletProperties.java
2008-01-08 06:04:22 UTC (rev 3184)
+++
branches/WebAdmin/perfSONARWebAdmin/auxiliary/xmlDB/eXistServletProperties.java
2008-01-08 08:23:40 UTC (rev 3185)
@@ -1,6 +1,5 @@
package perfSONARWebAdmin.auxiliary.xmlDB;
-import java.io.FileNotFoundException;
import java.util.Properties;
/**
Modified:
branches/WebAdmin/perfSONARWebAdmin/auxiliary/xmlDB/eXistServletPropertiesImpl.java
===================================================================
---
branches/WebAdmin/perfSONARWebAdmin/auxiliary/xmlDB/eXistServletPropertiesImpl.java
2008-01-08 06:04:22 UTC (rev 3184)
+++
branches/WebAdmin/perfSONARWebAdmin/auxiliary/xmlDB/eXistServletPropertiesImpl.java
2008-01-08 08:23:40 UTC (rev 3185)
@@ -1,10 +1,10 @@
package perfSONARWebAdmin.auxiliary.xmlDB;
import java.io.FileInputStream;
-import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Calendar;
+import java.util.Iterator;
import java.util.Properties;
/**
@@ -22,6 +22,16 @@
private Properties servletProperties;
+ private String DBLocation;
+
+ private String DBLocationKey;
+
+ private String ModDBLocation;
+
+ private String AdminPassword;
+
+ private String AdminPassKey;
+
//
-----------------------------------------------------------------------
// public methods
@@ -38,6 +48,24 @@
servletPropertiesFile = propertiesFile;
FileInputStream in = new
FileInputStream(servletPropertiesFile);
servletProperties.load(in);
+ Iterator it = servletProperties.keySet().iterator();
+ while (it.hasNext()) {
+
+ String key = (String) it.next();
+
+ if (key.endsWith("xmldb.db_uri")) {
+ DBLocationKey = key;
+ DBLocation =
servletProperties.getProperty(key);
+ ModDBLocation = DBLocation.substring(
+ DBLocation.indexOf("://") +
3, DBLocation
+
.indexOf("/xmlrpc") + 7);
+
+ }
+ if (key.endsWith("xmldb.db_adminpassword")) {
+ AdminPassKey = key;
+ AdminPassword =
servletProperties.getProperty(key);
+ }
+ }
in.close();
}
@@ -48,9 +76,17 @@
*/
public String getDBLocation() {
- return (String)
servletProperties.get("servlet.exist.location");
+ return DBLocation;
}
+ /**
+ * @return
+ */
+ public String getModDBLocation() {
+
+ return ModDBLocation;
+ }
+
/*
* (non-Javadoc)
*
@@ -68,29 +104,39 @@
*/
public void setDBLocation(String location) {
- servletProperties.setProperty("servlet.exist.location",
location);
+ servletProperties.setProperty(DBLocationKey, location);
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see
perfSONARWebAdmin.auxiliary.xmlDB.eXistServletProperties#getAdminPassword()
*/
public String getAdminPassword() {
- return (String)
servletProperties.get("servlet.exist.admin_password");
+ return AdminPassword;
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see
perfSONARWebAdmin.auxiliary.xmlDB.eXistServletProperties#setAdminPassword(java.lang.String)
+ */
public void setAdminPassword(String password) throws IOException {
- servletProperties.setProperty("servlet.exist.admin_password",
password);
+ servletProperties.setProperty(AdminPassKey, password);
}
- /**
- * @throws IOException
+ /*
+ * (non-Javadoc)
+ *
+ * @see
perfSONARWebAdmin.auxiliary.xmlDB.eXistServletProperties#store()
*/
public void store() throws IOException {
FileOutputStream out = new
FileOutputStream(servletPropertiesFile);
- servletProperties.store(out, "Modified at
"+Calendar.getInstance().getTime().toString());
+ servletProperties.store(out, "Modified at "
+ +
Calendar.getInstance().getTime().toString());
}
}
Modified:
branches/WebAdmin/perfSONARWebAdmin/auxiliary/xmlDB/existAuthenticatorImpl.java
===================================================================
---
branches/WebAdmin/perfSONARWebAdmin/auxiliary/xmlDB/existAuthenticatorImpl.java
2008-01-08 06:04:22 UTC (rev 3184)
+++
branches/WebAdmin/perfSONARWebAdmin/auxiliary/xmlDB/existAuthenticatorImpl.java
2008-01-08 08:23:40 UTC (rev 3185)
@@ -1,6 +1,6 @@
package perfSONARWebAdmin.auxiliary.xmlDB;
-import org.exist.security.User;
+
import org.exist.xmldb.UserManagementService;
import org.exist.xmldb.XQueryService;
import org.xmldb.api.DatabaseManager;
@@ -9,8 +9,8 @@
import org.xmldb.api.base.ResourceIterator;
import org.xmldb.api.base.ResourceSet;
import org.xmldb.api.base.XMLDBException;
-import org.xmldb.api.modules.XPathQueryService;
+
import perfSONARWebAdmin.auxiliary.Authenticator;
/**
@@ -142,7 +142,7 @@
System.out.println(String.valueOf(auth.authenticate("admin",
oldp)));
System.out.println("Connected with old password");
xmlDBManager manager = new xmlDBManagerImpl(
- "192.168.10.86:8080/exist/xmlrpc", "admin",
oldp);
+
"xmldb:exist://192.168.10.86:8080/exist/xmlrpc", "admin", oldp);
try {
manager.modifyUser("admin", newp, null, null);
System.out.println("Changed the admin password");
Modified:
branches/WebAdmin/perfSONARWebAdmin/auxiliary/xmlDB/existDocument.java
===================================================================
--- branches/WebAdmin/perfSONARWebAdmin/auxiliary/xmlDB/existDocument.java
2008-01-08 06:04:22 UTC (rev 3184)
+++ branches/WebAdmin/perfSONARWebAdmin/auxiliary/xmlDB/existDocument.java
2008-01-08 08:23:40 UTC (rev 3185)
@@ -2,10 +2,7 @@
import java.util.Date;
-import javax.xml.transform.TransformerException;
-import org.w3c.dom.Document;
-
/**
* @author Michalis Michael.CyNet
*
Modified:
branches/WebAdmin/perfSONARWebAdmin/auxiliary/xmlDB/xmlDBCollectionImpl.java
===================================================================
---
branches/WebAdmin/perfSONARWebAdmin/auxiliary/xmlDB/xmlDBCollectionImpl.java
2008-01-08 06:04:22 UTC (rev 3184)
+++
branches/WebAdmin/perfSONARWebAdmin/auxiliary/xmlDB/xmlDBCollectionImpl.java
2008-01-08 08:23:40 UTC (rev 3185)
@@ -2,14 +2,7 @@
import java.io.File;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
import org.exist.security.Permission;
-import org.exist.security.User;
-import org.exist.soap.Permissions;
-import org.exist.storage.BrokerPool;
-import org.exist.xmldb.LocalXMLResource;
import org.exist.xmldb.UserManagementService;
import org.w3c.dom.Document;
import org.xmldb.api.base.Collection;
@@ -18,7 +11,6 @@
import org.xmldb.api.base.ResourceSet;
import org.xmldb.api.base.XMLDBException;
import org.xmldb.api.modules.XMLResource;
-import org.xmldb.api.modules.XPathQueryService;
import org.xmldb.api.modules.XQueryService;
/**
Modified:
branches/WebAdmin/perfSONARWebAdmin/auxiliary/xmlDB/xmlDBManager.java
===================================================================
--- branches/WebAdmin/perfSONARWebAdmin/auxiliary/xmlDB/xmlDBManager.java
2008-01-08 06:04:22 UTC (rev 3184)
+++ branches/WebAdmin/perfSONARWebAdmin/auxiliary/xmlDB/xmlDBManager.java
2008-01-08 08:23:40 UTC (rev 3185)
@@ -2,7 +2,6 @@
import org.exist.security.User;
import org.xmldb.api.base.Collection;
-import org.xmldb.api.base.XMLDBException;
/**
* Interface for the exist DB manager
Modified:
branches/WebAdmin/perfSONARWebAdmin/auxiliary/xmlDB/xmlDBManagerImpl.java
===================================================================
--- branches/WebAdmin/perfSONARWebAdmin/auxiliary/xmlDB/xmlDBManagerImpl.java
2008-01-08 06:04:22 UTC (rev 3184)
+++ branches/WebAdmin/perfSONARWebAdmin/auxiliary/xmlDB/xmlDBManagerImpl.java
2008-01-08 08:23:40 UTC (rev 3185)
@@ -1,6 +1,5 @@
package perfSONARWebAdmin.auxiliary.xmlDB;
-import java.util.Arrays;
import org.exist.security.User;
import org.exist.xmldb.UserManagementService;
@@ -51,7 +50,7 @@
throws ClassNotFoundException, XMLDBException,
InstantiationException, IllegalAccessException {
- DBURI = "xmldb:exist://" + dbAddress;
+ DBURI = dbAddress;
Class cl = Class.forName(driver);
Database database = (Database) cl.newInstance();
DatabaseManager.registerDatabase(database);
- perfsonar: r3185 - in branches/WebAdmin/perfSONARWebAdmin: admin/exist admin/service admin/wizard admin/wizard/services auxiliary auxiliary/xmlDB, svnlog, 01/08/2008
Archive powered by MHonArc 2.6.16.