perfsonar-dev - perfsonar: r3142 - in branches/WebAdmin/perfSONARWebAdmin: . admin/wizard admin/wizard/services auxiliary/wizard test
Subject: perfsonar development work
List archive
perfsonar: r3142 - in branches/WebAdmin/perfSONARWebAdmin: . admin/wizard admin/wizard/services auxiliary/wizard test
Chronological Thread
- From:
- To:
- Subject: perfsonar: r3142 - in branches/WebAdmin/perfSONARWebAdmin: . admin/wizard admin/wizard/services auxiliary/wizard test
- Date: Tue, 18 Dec 2007 03:19:24 -0500
Author: michalis
Date: 2007-12-18 03:19:23 -0500 (Tue, 18 Dec 2007)
New Revision: 3142
Added:
branches/WebAdmin/perfSONARWebAdmin/test/
branches/WebAdmin/perfSONARWebAdmin/test/ExistTesterXmlRpc.java
branches/WebAdmin/perfSONARWebAdmin/test/PractisingWizard.java
branches/WebAdmin/perfSONARWebAdmin/test/Tester.java
Removed:
branches/WebAdmin/perfSONARWebAdmin/ExistTesterXmlRpc.java
branches/WebAdmin/perfSONARWebAdmin/PractisingWizard.java
branches/WebAdmin/perfSONARWebAdmin/Tester.java
Modified:
branches/WebAdmin/perfSONARWebAdmin/admin/wizard/Wizard.java
branches/WebAdmin/perfSONARWebAdmin/admin/wizard/services/RRDMAHandler.java
branches/WebAdmin/perfSONARWebAdmin/auxiliary/wizard/ConfigurationHandler.java
branches/WebAdmin/perfSONARWebAdmin/auxiliary/wizard/HTMLOutput.java
branches/WebAdmin/perfSONARWebAdmin/auxiliary/wizard/WizardProperties.java
branches/WebAdmin/perfSONARWebAdmin/auxiliary/wizard/WizardProperty.java
Log:
Adding some more commends to the code
Deleted: branches/WebAdmin/perfSONARWebAdmin/ExistTesterXmlRpc.java
Deleted: branches/WebAdmin/perfSONARWebAdmin/PractisingWizard.java
Deleted: branches/WebAdmin/perfSONARWebAdmin/Tester.java
Modified: branches/WebAdmin/perfSONARWebAdmin/admin/wizard/Wizard.java
===================================================================
--- branches/WebAdmin/perfSONARWebAdmin/admin/wizard/Wizard.java
2007-12-17 15:39:05 UTC (rev 3141)
+++ branches/WebAdmin/perfSONARWebAdmin/admin/wizard/Wizard.java
2007-12-18 08:19:23 UTC (rev 3142)
@@ -32,42 +32,48 @@
import perfSONARWebAdmin.auxiliary.wizard.WizardProperty;
import sun.misc.BASE64Decoder;
+/**
+ * Servlet to be used as a wizard for configurating perfSONAR service
+ *
+ * @author Michalis Michael, CyNet
+ *
+ */
@SuppressWarnings("serial")
public class Wizard extends HttpServlet {
+ //
-----------------------------------------------------------------------
+ // class fields
+
+ // The path to the conf folder
private static final String confPath =
"WEB-INF/classes/perfsonar/conf/";
- private static final String ServicePropertiesPath = confPath
- + "service.properties";
-
- private static final String LoggingPropertiesPath = confPath
- + "log4j.properties";
-
- private static final String ComponentsPropertiesPath = confPath
- + "components.properties";
-
- private static final String ObjectsConfigPath = confPath +
"objects.config";
-
+ // The path to the wizard.properties file
private static final String WizardPropertiesPath = confPath
+ "wizard.properties";
+ // The path to the servlet.properties file
private static final String ServletPropertiesPath = confPath
+ "servlet.properties";
- private static final String listener = "\n\n<listener>\n
<listener-class>org.perfsonar.service.base.container.listeners.StartupInitializer</listener-class>\n</listener>\n";
-
+ // The path to the folder under the webapps directory in which the
service
+ // is installed
private static String ServicePath;
+ // The WizardProperties to be configured
private static WizardProperties properties;
+ // Hashatable used for seperating the wizard properties into groups
private static Hashtable<String, WizardProperties> groupedProperties
= null;
- private static Hashtable<String, Boolean> configuredGroups = null;
-
+ // The handler that will eventually handle the users input
private static ConfigurationHandler handler = null;
+ // A class responsible for generation the html code
private static HTMLOutput output = null;
+ //
-----------------------------------------------------------------------
+ // public methods
+
/*
* (non-Javadoc)
*
@@ -76,26 +82,34 @@
@Override
public void init(ServletConfig arg0) throws ServletException {
super.init(arg0);
-
+ // Initializing all fields
properties = new WizardProperties();
- configuredGroups = new Hashtable<String, Boolean>();
+ groupedProperties = new Hashtable<String, WizardProperties>();
ServletContext sc = getServletContext();
+ ServicePath = sc.getRealPath("/");
- ServicePath = sc.getRealPath("/");
try {
output = new HTMLOutput();
+ // Loading the wizard properties
properties.loadFromXML(sc.getResourceAsStream("/"
+ WizardPropertiesPath));
- prepareProperties(properties);
+ // Preparing properties into groups
+ groupedProperties = prepareProperties(properties);
+ // Check to see if there is a configuration handler
avalable
String cl = checkForExternalHandler();
if (cl != null) {
+ // if the developer has specified a
configuration handler then
+ // we dynamically load it
Class clas = Class.forName(cl, true,
Thread.currentThread()
.getContextClassLoader());
handler = (ConfigurationHandler)
clas.newInstance();
-
+ // And assign him all necessary fields
handler.setProperties(properties);
handler.setGroupedProperties(groupedProperties);
handler.setServicePath(ServicePath);
+ } else {
+ throw new ServletException(
+ "Error! No configuration
handler has been set in servlet.properties file!\n");
}
} catch (Exception e) {
@@ -105,6 +119,9 @@
}
+ //
-----------------------------------------------------------------------
+ // protected methods
+
/*
* (non-Javadoc)
*
@@ -129,33 +146,50 @@
HttpServletResponse response) throws
ServletException, IOException {
// TO DO: Add feature to prevent simultainous configuration
+ // Getting the ServletOutputStream, necessary for html output
ServletOutputStream out = response.getOutputStream();
+ // Setting the stream to the HTMLOutput class
output.setOuputStream(out);
HttpSession session = request.getSession(true);
+ // Set max interval to session
if (session.isNew())
session.setMaxInactiveInterval(3600);
+ // Preparing authentication process
ServletProperties servletProperties = new
ServletPropertiesImpl(
ServicePath + ServletPropertiesPath);
Authenticator authenticator = new
AuthenticatorImpl(servletProperties);
+ // If the user is authenticated
if (session.getAttribute("authenticated") != null) {
if (((Boolean) session.getAttribute("authenticated"))
.booleanValue()) {
+ // Set the the HTMLOutput class of the handler
if (handler != null) {
handler.setHTMLOutput(output);
}
+ // If there are no parameters in the request
this means, that
+ // the user is request the first page of the
servlet
+ // So we will show him all properties!!!
if (request.getParameterMap().isEmpty()) {
-
output.showAllProperties(groupedProperties,
- "Please fill in all
fields. Mandatory fileds are marked with an asterisk.");
+ output
+
.showAllProperties(groupedProperties,
+
"Please fill in all fields. Mandatory fileds are marked with an asterisk.");
} else {
+ // If there are parameters in the
request, that means the
+ // user has probably used the
sercvlet to provide input
+
+ // We are accessiong the function
parameter. If its equal to
+ // finish then we have the right input
String function =
request.getParameter("function").trim();
if (function.equals("finish")) {
String goBack = "<a
href=\"Wizard\">Back</a>";
try {
+ // The servlet lets
the configuration handler to
+ // deal with the
users inout
boolean ok =
handler.handleRequest(request);
if (ok) {
-
+ // If all
went well we show a success message
output
.infoPage(
"perfSONAR configuration Wizard",
@@ -163,25 +197,34 @@
+ goBack);
} else {
+ // If
something went wrong we show a failure
+ // message
output
.infoPage(
"perfSONAR configuration Wizard",
-
"There was a problem finishing the configuration! Please
check your input again.\n"+goBack);
+
"There was a problem finishing the configuration! Please
check your input again.\n"
+
+ goBack);
}
} catch (Exception e) {
+ // If an exceprion
has happened we notify the user
output.infoPage("perfSONAR configuration Wizard",
-
"Problem occured while finishing the configuration process!"+goBack+"\n"
-
+ getFault(e));
+
"Problem occured while finishing the configuration process!"
+
+ goBack + "\n" + getFault(e));
}
}
}
} else {
+ // If "authenticated" is false we invalidate
the session so that
+ // the user can try again
session.invalidate();
}
} else {
+ // If the "authentcated" parameter has not been set
then we ask for
+ // a username and password
String authorization =
request.getHeader("Authorization");
+ // if there is non in the headers we ask for it
if (authorization == null) {
askForPassword(response);
} else {
@@ -189,6 +232,7 @@
// 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));
@@ -198,67 +242,88 @@
// Using the authenticator to authenticate
the user
if (authenticator.authenticate(user,
password)) {
+ // Authetnication was successful we
show the user all
+ // properties to be configured
session.setAttribute("authenticated",
true);
-
output.showAllProperties(groupedProperties,
- "Please fill in all
fields. Mandatory fileds are marked with an asterisk.");
+ output
+
.showAllProperties(groupedProperties,
+
"Please fill in all fields. Mandatory fileds are marked with an asterisk.");
} else {
askForPassword(response);
session.invalidate();
- throw new IOException(" " + user + "
" + password + " ");
}
}
}
}
+ //
-----------------------------------------------------------------------
+ // private methods
+
/**
- * Grouping and preparing properties
+ * Method used for grouping properties
*
* @param loadedProperties
* The properties loaded from the configuration file
+ * @return A hashtable with the group names as keys and
WizardProperties
+ * classes as values
*/
- private void prepareProperties(WizardProperties loadedProperties) {
+ private Hashtable<String, WizardProperties> prepareProperties(
+ WizardProperties loadedProperties) {
+ // Check to see if any property was actually loaded
if (!loadedProperties.isEmpty()) {
+ // Creating new hashtable
+ Hashtable<String, WizardProperties> groupTable = new
Hashtable<String, WizardProperties>();
Iterator it = loadedProperties.keySet().iterator();
+ // Iterating through the properties so that we can
divide them into
+ // groups
while (it.hasNext()) {
+ // Get the property
WizardProperty property = loadedProperties
.getWizardProperty((String)
it.next());
-
- if (groupedProperties == null) {
- groupedProperties = new
Hashtable<String, WizardProperties>();
- }
+ // If the property group has not been set
then it is placed in a
+ // generic "Other" group
if (property.getGroup() == null) {
- if
(!groupedProperties.containsKey("Other")) {
+ if (!groupTable.containsKey("Other"))
{
-
groupedProperties.put("Other", new WizardProperties());
+ groupTable.put("Other", new
WizardProperties());
}
- ((WizardProperties)
groupedProperties.get("Other"))
+ ((WizardProperties)
groupTable.get("Other"))
.putWizardProperty(property.getKey(), property);
} else {
- if
(!groupedProperties.containsKey(property.getGroup())) {
-
groupedProperties.put(property.getGroup(),
+ // If the property group does not
exist as a key yet, we
+ // create a new key(group)
value(WizardProperties) pair
+ if
(!groupTable.containsKey(property.getGroup())) {
+
groupTable.put(property.getGroup(),
new
WizardProperties());
}
- ((WizardProperties)
groupedProperties.get(property
-
.getGroup())).putWizardProperty(property.getKey(),
- property);
+ // We add the property to the
WizardProperties of that group
+ ((WizardProperties)
groupTable.get(property.getGroup()))
+
.putWizardProperty(property.getKey(), property);
}
}
+ return groupTable;
+ } else {
+ return null;
}
}
/**
+ * Method for retreiving the name of a class implementing the
+ * ConfigurationHandler interface. The name of the class should be
places
+ * inside the servlet.properties file.
+ *
+ * @return A String with the name of the class
+ * @throws FileNotFoundException
* @throws IOException
- * @throws FileNotFoundException
- *
*/
private String checkForExternalHandler() throws FileNotFoundException,
IOException {
@@ -289,7 +354,7 @@
private void askForPassword(HttpServletResponse response) {
- response.setStatus(response.SC_UNAUTHORIZED); // I.e., 401
+ response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
response.setHeader("WWW-Authenticate",
"BASIC realm=\"perfSONAR-Admin\"");
Modified:
branches/WebAdmin/perfSONARWebAdmin/admin/wizard/services/RRDMAHandler.java
===================================================================
---
branches/WebAdmin/perfSONARWebAdmin/admin/wizard/services/RRDMAHandler.java
2007-12-17 15:39:05 UTC (rev 3141)
+++
branches/WebAdmin/perfSONARWebAdmin/admin/wizard/services/RRDMAHandler.java
2007-12-18 08:19:23 UTC (rev 3142)
@@ -15,9 +15,7 @@
import java.util.Iterator;
import javax.servlet.http.HttpServletRequest;
-import javax.xml.parsers.ParserConfigurationException;
-import org.xml.sax.SAXException;
import perfSONARWebAdmin.auxiliary.ServiceProperties;
import perfSONARWebAdmin.auxiliary.ServicePropertiesImpl;
@@ -30,44 +28,76 @@
import perfSONARWebAdmin.auxiliary.xmlDB.xmlDBManager;
import perfSONARWebAdmin.auxiliary.xmlDB.xmlDBManagerImpl;
+/**
+ * Class implementing the ConfigurationHandler Interface. This is a reference
+ * imlementation to be used exam
+ *
+ * @author Michalis Michael,CyNet
+ *
+ */
public class RRDMAHandler implements ConfigurationHandler {
+ //
-----------------------------------------------------------------------
+ // class fields
+
+ // Hashtable containg Wizard Properties as values and the various
groups in
+ // which the properties are divided to as keys
private Hashtable<String, WizardProperties> groupedProperties = null;
+ // All of the Wizard Properties
private WizardProperties properties = null;
+ // The HtTMLOutput class that is used for outputting html code to the
user.
+ // Currently not used by this reference implementation
+ @SuppressWarnings("unused")
private HTMLOutput htmlOutput;
+ // The path to the configuration directory
private static final String confPath =
"WEB-INF/classes/perfsonar/conf/";
+ // The path to the service.properties file
private static final String ServicePropertiesPath = confPath
+ "service.properties";
+ // The path to the logging properties file
private static final String LoggingPropertiesPath = confPath
+ "log4j.properties";
+ // The path to the componenets.properties file
private static final String ComponentsPropertiesPath = confPath
+ "components.properties";
+ // The path to the objects properties file
private static final String ObjectsConfigPath = confPath +
"objects.config";
+ // The path to the wizard.properties file
private static final String WizardPropertiesPath = confPath
+ "wizard.properties";
+ // The path to the servlet.properties file
private static final String ServletPropertiesPath = confPath
+ "servlet.properties";
+ // The path to the directory under the webapps folder in which the
service
+ // is installed
private static String ServicePath;
+ // Bollean that states if the configuration process is finished
private static boolean configured = false;
+ //
-----------------------------------------------------------------------
+ // constructors
+
/**
- *
+ * Class constructor
*/
public RRDMAHandler() {
}
+ //
-----------------------------------------------------------------------
+ // public methods
+
/*
* (non-Javadoc)
*
@@ -75,12 +105,22 @@
*/
public boolean handleRequest(HttpServletRequest request) throws
Exception {
+ // Setting configured to false
configured = false;
+ // Also definining some more booleans for every different
group to be
+ // configured
boolean eXistDone = false;
boolean LSDone = false;
+ // Other is every other group besides LS and eXist. This
seperation is
+ // made because LS registration and eXist configuration are
common for
+ // all java services
boolean otherDone = false;
+ // Each group is independent from each other and can be
configured
+ // without any depemdencies
try {
+ // Handling exist configuration
+ // True if this is done properly
eXistDone = handleExist(request);
} catch (Exception e) {
@@ -89,6 +129,8 @@
+ getFault(e));
}
try {
+ // Handling LS configuration
+ // True if all is done properly
LSDone = handleLS(request);
} catch (Exception e) {
throw new Exception(
@@ -96,6 +138,8 @@
+ getFault(e));
}
try {
+ // Handling other groups configuration
+ // True if all is done properly
otherDone = handleOther(request);
} catch (Exception e) {
@@ -103,9 +147,12 @@
"Problem with Store
configuration!Please check your input.\n"
+ getFault(e));
}
+ // if every group has configured successfully then the final
+ // configuration procedures are called
if (eXistDone && LSDone && otherDone) {
try {
configured = finishConfiguration();
+ // if everything has gone OK then true is
returned
return configured;
} catch (Exception e) {
throw new Exception("Problem finishing
configuration.\n"
@@ -117,100 +164,232 @@
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see
perfSONARWebAdmin.auxiliary.wizard.ConfigurationHandler#isConfigured()
+ */
+ public boolean isConfigured() {
+
+ return configured;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
perfSONARWebAdmin.auxiliary.wizard.ConfigurationHandler#setHTMLOutput(perfSONARWebAdmin.auxiliary.wizard.HTMLOutput)
+ */
+ public void setHTMLOutput(HTMLOutput output) {
+
+ htmlOutput = output;
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
perfSONARWebAdmin.auxiliary.wizard.ConfigurationHandler#setProperties(perfSONARWebAdmin.auxiliary.wizard.WizardProperties)
+ */
+ public void setProperties(WizardProperties loadedProperties) {
+
+ properties = loadedProperties;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
perfSONARWebAdmin.auxiliary.wizard.ConfigurationHandler#setGroupedProperties(java.util.Hashtable)
+ */
+ public void setGroupedProperties(
+ Hashtable<String, WizardProperties> otherProperties) {
+
+ groupedProperties = otherProperties;
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
perfSONARWebAdmin.auxiliary.wizard.ConfigurationHandler#setServicePath(java.lang.String)
+ */
+ public void setServicePath(String servicePath) {
+
+ ServicePath = servicePath;
+
+ }
+
+ //
-----------------------------------------------------------------------
+ // private methods
+
/**
+ * Method used for handling other groups configuration(That is other
than LS
+ * and exist)
+ *
* @param request
- * @return
+ * The HttpServletRequest containing input from the user
+ * @return True if other groups are configured successfully
* @throws Exception
*/
private boolean handleOther(HttpServletRequest request) throws
Exception {
+ // Getting all groups
Iterator groupIt = groupedProperties.keySet().iterator();
+ // Setting done to true, You will see later why
boolean done = true;
+ // Iterating through the groups
while (groupIt.hasNext()) {
String group = (String) groupIt.next();
- if (!(group.equals("eXist")||group.equals("LS"))) {
+ // Every other group should be handled except for
eXist and LS
+ if (!(group.equals("eXist") || group.equals("LS"))) {
+ // Retrieving the properties belonging to the
group
WizardProperties groupProperties =
groupedProperties.get(group);
+ // Iterating through the properties. This way
using the key of
+ // each property we can retrieve the users
input from the
+ // request
Iterator it = groupProperties.orderedKeys();
-
while (it.hasNext()) {
String key = (String) it.next();
+ // get the value from the request
String value =
request.getParameter(key).trim();
WizardProperty pr =
groupProperties.getWizardProperty(key);
+ // Set the property value
pr.setPropertyValue(value);
+ // if the property does not the check
field set, the also
+ // put the user input as the proposed
value also
+ // This happens, because properties
that have the check
+ // property set, are usually
important for the rest of the
+ // group properties since their value
would determine if the
+ // rest need to be configured. So
their proposed value is
+ // left to thr developer
if (!pr.getCheck()) {
pr.setProposedValue(value);
}
+ // Updating the property inside the
group propereties
groupProperties.setWizardProperty(key, pr);
}
+ // Updating the grouped properties
groupedProperties.put(group, groupProperties);
+ // Applying the configuration input from the
user to the service
try {
otherActions(group, groupProperties);
} catch (Exception e) {
+ // If actions had a problem then done
is set to false
done = false;
throw new Exception(getFault(e));
}
}
}
+
return done;
}
+ /**
+ * Method used for handling LS registration configuration
+ *
+ * @param request
+ * The HttpServletRequest containing input from the user
+ * @return True if LS registration is configured successfully
+ * @throws Exception
+ */
private boolean handleLS(HttpServletRequest request) throws Exception
{
+ // Retrieving the useLS parameter. The useLS parammeter is
inserted as
+ // input by the shoaAllProperties method of the HTMLOutput
class
+ // automatically. It is the answer to if the user wants to
register to
+ // an LS since their is no service property that corresponds
to this
+ // question
String useLS = request.getParameter("useLS").trim();
+ // If yes all other properties regarding LS registration are
retrieved
if (useLS.equals("yes")) {
+ // Retrieving all propertie associated with LS
WizardProperties lsProperties =
groupedProperties.get("LS");
+ // Getting the keys of the properties
Iterator it = lsProperties.orderedKeys();
while (it.hasNext()) {
String key = (String) it.next();
+ // Using the keys for retrieving the users
input
String value =
request.getParameter(key).trim();
WizardProperty pr =
lsProperties.getWizardProperty(key);
+ // Setting property value and proposed value
pr.setPropertyValue(value);
pr.setProposedValue(value);
+ // Setting property
lsProperties.setWizardProperty(key, pr);
}
+ // Setting the LS group properties
groupedProperties.put("LS", lsProperties);
boolean done = false;
+ // Trying to perfom the LS configuration actions to
the service
try {
lsActions(lsProperties);
done = true;
} catch (Exception e) {
+ // False if an error happens
done = false;
throw new Exception(getFault(e));
}
return done;
- } else {
+ }
+ // If no then the registration componenets are commented in
the
+ // components.properties file
+ else {
removeRegistrationComponents();
return true;
}
}
+ /**
+ * Method used for handling eXist database configuration
+ *
+ * @param request
+ * The HttpServletRequest containing input from the user
+ * @return True if LS registration is configured successfully
+ * @throws Exception
+ */
private boolean handleExist(HttpServletRequest request) throws
Exception {
boolean done = false;
+ // Getting the exist database associated properties
WizardProperties existProperties =
groupedProperties.get("eXist");
Iterator it = existProperties.orderedKeys();
+ // The first key is about using or not the database.So this
parameter is
+ // retrieved from the request
String statusKey = (String) it.next();
String status = request.getParameter(statusKey);
WizardProperty useExistProperty = existProperties
.getWizardProperty(statusKey);
+
if (status.equals("off")) {
+ // if the user does not wish to use exist then the
property is set
+ // to off
+ // and nothing else happens
+ // Seeting property value
useExistProperty.setPropertyValue("off");
+ // Setting property to exist group properties
existProperties.setWizardProperty(statusKey,
useExistProperty);
+ // Set property to wizard properties
properties.setWizardProperty(statusKey,
useExistProperty);
+ // Update exist group properties
groupedProperties.put("eXist", existProperties);
try {
+ // Using the serviceProperties class for
xetting the property
ServiceProperties serviceProperties;
serviceProperties = new
ServicePropertiesImpl(ServicePath
+ ServicePropertiesPath);
+ // Property set
serviceProperties.setProperty(useExistProperty.getKey(),
useExistProperty.getValue());
+ // new Properties stored
serviceProperties.storeProperties();
+ // Set done to true
done = true;
} catch (IOException e) {
+
+ // If anything happens set done to false
done = false;
throw new Exception(getFault(e));
@@ -218,18 +397,28 @@
return done;
} else {
+ // If the user wishes to use exist then set the
property value
useExistProperty.setPropertyValue("on");
+ // Set the wizard property to the exist group
properties
existProperties.setWizardProperty(statusKey,
useExistProperty);
+ // Get all other parameters regarding exist in the
users reqauest
while (it.hasNext()) {
String key = (String) it.next();
+ // Get the parameter
String value =
request.getParameter(key).trim();
+ // Get the property
WizardProperty pr =
existProperties.getWizardProperty(key);
+ // Set value and proposed value
pr.setPropertyValue(value);
pr.setProposedValue(value);
+ // Set the property in the exist group
properties
existProperties.setWizardProperty(key, pr);
}
+ // Update the exist group Property
groupedProperties.put("eXist", existProperties);
try {
+ // Call for the needed actions for exist
configuration.The exist
+ // group properties are used as input
existActions(existProperties);
done = true;
/*
@@ -238,7 +427,7 @@
* properties.storeToXML(out,""); out.close();
*/
} catch (Exception e) {
-
+ // Set doen to false if anything happens
done = false;
throw new Exception(getFault(e));
}
@@ -248,28 +437,42 @@
}
/**
- * @param function
+ * Method for handling all configuration actions regarding any other
group
+ * besides LS and eXist
+ *
+ * @param group
+ * The group
* @param functionProperties
+ * The properties regardung the group
* @throws IOException
*/
- private void otherActions(String function,
- WizardProperties functionProperties) throws
IOException {
+ private void otherActions(String group, WizardProperties
functionProperties)
+ throws IOException {
+ // A class that makes modifying service properties a little
bit easier
ServiceProperties serviceProperties = null;
- if (function.equals("Store")) {
+ // The only other group for rrd ma is the Store group
+ if (group.equals("Store")) {
serviceProperties = new
ServicePropertiesImpl(ServicePath
+ ServicePropertiesPath);
- } else {
+ }
+ // We don't really have any other groups just the ones for
the servlet
+ // administration
+ else {
serviceProperties = new
ServicePropertiesImpl(ServicePath
+ ServletPropertiesPath);
}
+ // Getting the names for every property of the group
Iterator it = functionProperties.orderedKeys();
+ // Setting the value of each property
while (it.hasNext()) {
String key = (String) it.next();
+ // Setting service properties and wizard properties
serviceProperties.setProperty(key, functionProperties
.getProperty(key));
properties.setWizardProperty(key, functionProperties
.getWizardProperty(key));
}
+ // Storing all changes
serviceProperties.storeProperties();
properties.storeToXML(new FileOutputStream(new
File(ServicePath
+ WizardPropertiesPath)), " Last Modification
"
@@ -277,48 +480,75 @@
}
/**
+ * Method for handling all configuration actions regarding the LS
+ * registration
+ *
* @param finalProperties
+ * The WizardProperties that belong to the LS registration
group
* @throws IOException
*/
private void lsActions(WizardProperties finalProperties) throws
IOException {
+ // Using the ServiceProperties class to acces the
service.properties
+ // file
ServiceProperties serviceProperties = new
ServicePropertiesImpl(
ServicePath + ServicePropertiesPath);
Iterator it = finalProperties.orderedKeys();
+ // Iterating through the LS registration properties properties
while (it.hasNext()) {
String key = (String) it.next();
+ // Set the service properties
serviceProperties
.setProperty(key,
finalProperties.getProperty(key));
+ // Set the wizard properties
properties.setWizardProperty(key, finalProperties
.getWizardProperty(key));
}
+ // Storing service properties
serviceProperties.storeProperties();
+ // Setting the LS registration componenets in components
properties file
addRegistrationComponents();
+ // Storing the wizard properties
properties.storeToXML(new FileOutputStream(new
File(ServicePath
+ WizardPropertiesPath)), " Last Modification
"
+
Calendar.getInstance().getTime().toString());
}
/**
+ * Method used for handling all actions associated with exist db
+ * confoguration
+ *
* @param finalProperties
+ * The Wizard Properties associated with the exist group
* @throws Exception
*/
private void existActions(WizardProperties finalProperties)
throws Exception {
+ // 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 serviceName = servletProperties.getProperty(
"servlet.service_type").trim();
+ // Naming the new collection on exist db
String dbCollection = serviceName + "config";
+ // 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")) {
@@ -330,13 +560,18 @@
}
}
+ // If admin pass is not set than its considered to be empty
if (adminPass == null) {
adminPass = "";
}
it = finalProperties.orderedKeys();
+ // Iterating though tthe users input
while (it.hasNext()) {
String key = (String) it.next();
+ // The input from the user is also set in service
properties with a
+ // slight modification for tyhe 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));
@@ -344,9 +579,12 @@
serviceProperties.setProperty(key, existURI +
"/db/"
+ dbCollection);
}
+ // 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);
}
@@ -362,19 +600,32 @@
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",
adminPass);
+ // Creating collection and users
manager.createCollection(dbCollection);
manager.createUser(dbCollection, username, password,
null);
+ // Adding the metadata config document
manager.getCollection(dbCollection).addDocument(new
File(confFile),
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
@@ -397,6 +648,7 @@
}
}
pr.setDBLocation(modExistURI);
+ // Storing all changes
pr.store();
serviceProperties.storeProperties();
properties.storeToXML(new FileOutputStream(new
File(ServicePath
@@ -407,10 +659,10 @@
}
/**
- * @throws ParserConfigurationException
+ * Method used for adding registration componenets to the
+ * componenets.properties file
+ *
* @throws IOException
- * @throws SAXException
- *
*/
private void addRegistrationComponents() throws IOException {
File comp = new File(ServicePath + ComponentsPropertiesPath);
@@ -439,10 +691,10 @@
}
/**
- * @throws ParserConfigurationException
+ * Method for removing ls registration components from
components.properties
+ * file
+ *
* @throws IOException
- * @throws SAXException
- *
*/
private void removeRegistrationComponents() throws IOException {
File comp = new File(ServicePath + ComponentsPropertiesPath);
@@ -471,6 +723,8 @@
}
/**
+ * Method for performing final actions for service configuration
+ *
* @return
* @throws Exception
*/
@@ -488,60 +742,6 @@
}
- /*
- * (non-Javadoc)
- *
- * @see
perfSONARWebAdmin.auxiliary.wizard.ConfigurationHandler#isConfigured()
- */
- public boolean isConfigured() {
-
- return configured;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
perfSONARWebAdmin.auxiliary.wizard.ConfigurationHandler#setHTMLOutput(perfSONARWebAdmin.auxiliary.wizard.HTMLOutput)
- */
- public void setHTMLOutput(HTMLOutput output) {
-
- htmlOutput = output;
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
perfSONARWebAdmin.auxiliary.wizard.ConfigurationHandler#setProperties(perfSONARWebAdmin.auxiliary.wizard.WizardProperties)
- */
- public void setProperties(WizardProperties loadedProperties) {
-
- properties = loadedProperties;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
perfSONARWebAdmin.auxiliary.wizard.ConfigurationHandler#setGroupedProperties(java.util.Hashtable)
- */
- public void setGroupedProperties(
- Hashtable<String, WizardProperties> otherProperties) {
-
- groupedProperties = otherProperties;
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
perfSONARWebAdmin.auxiliary.wizard.ConfigurationHandler#setServicePath(java.lang.String)
- */
- public void setServicePath(String servicePath) {
-
- ServicePath = servicePath;
-
- }
-
/**
* Method to get the stack trace of an exception
*
Modified:
branches/WebAdmin/perfSONARWebAdmin/auxiliary/wizard/ConfigurationHandler.java
===================================================================
---
branches/WebAdmin/perfSONARWebAdmin/auxiliary/wizard/ConfigurationHandler.java
2007-12-17 15:39:05 UTC (rev 3141)
+++
branches/WebAdmin/perfSONARWebAdmin/auxiliary/wizard/ConfigurationHandler.java
2007-12-18 08:19:23 UTC (rev 3142)
@@ -4,39 +4,76 @@
import javax.servlet.http.HttpServletRequest;
+/**
+ * Interface used for handling the configuration data data returned by the
end
+ * user in the Service Configuration Wizard Servlet
+ *
+ * @author Michalis Michael,CyNNet
+ *
+ */
public interface ConfigurationHandler {
/**
+ * Method used by the Wizard servlet to pass the data returned by the
user
+ * to the Configuration Handler. The handler will handle the rest of
the
+ * wizard functionality
+ *
* @param request
- * @return
+ * The http request that was send by the user containg
+ * configuration data
+ * @return A boolean stating if the configuration process was
successful or
+ * not
* @throws Exception
*/
public boolean handleRequest(HttpServletRequest request) throws
Exception;
-
-
+
/**
- * @return
+ * Method that indicates if that all configuration actions have been
done
+ * successfully
+ *
+ * @return A boolean stating if configuration is finished and
succesful or
+ * not
*/
public boolean isConfigured();
/**
+ * Method used by the Wizard servlet in order to pass the properties
to be
+ * configured to the configuration handler
+ *
* @param loadedProperties
+ * The Wizard Properties that are passed form the servlet
to the
+ * handler
*/
public void setProperties(WizardProperties loadedProperties);
+
/**
+ * Method used by the configuration wizard servlet to pass grouped
+ * properties
+ *
* @param otherProperties
+ * A hashtable using as key the group of the properties
and as
+ * value A WizardProperties Object containing the
properties of
+ * the group
*/
- public void setGroupedProperties(Hashtable<String, WizardProperties>
otherProperties);
+ public void setGroupedProperties(
+ Hashtable<String, WizardProperties>
groupedProperties);
-
/**
+ * Method used by the wizard servlet to set the service path of the
+ * configuration handler
+ *
* @param servicePath
+ * The real path to the directory of the service inside the
+ * webappas folder
*/
public void setServicePath(String servicePath);
-
/**
+ * Method used by the wizard servlet in order to set the HTMLOutoput
Object
+ * used by the cinfiguration handler
+ *
* @param output
+ * The HTNLOutput object
*/
public void setHTMLOutput(HTMLOutput output);
}
Modified: branches/WebAdmin/perfSONARWebAdmin/auxiliary/wizard/HTMLOutput.java
===================================================================
--- branches/WebAdmin/perfSONARWebAdmin/auxiliary/wizard/HTMLOutput.java
2007-12-17 15:39:05 UTC (rev 3141)
+++ branches/WebAdmin/perfSONARWebAdmin/auxiliary/wizard/HTMLOutput.java
2007-12-18 08:19:23 UTC (rev 3142)
@@ -9,21 +9,34 @@
import javax.servlet.http.HttpServletRequest;
/**
+ * Class used as front end for creation the html output. It hides the html
+ * creation details from the user making his job easier(hopefully)
+ *
* @author Michalis Michael, CyNet
*
*/
public class HTMLOutput {
+ //
-----------------------------------------------------------------------
+ // class fields
+
+ // 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\">";
+ // The servlet output stream that will be used to output the html code
private static ServletOutputStream out = null;
+ // A Linked List containing the various grouped to be configured
private static LinkedList Groups;
+ //
-----------------------------------------------------------------------
+ // constructors
+
/**
- * @param existPro
- * @param lsPro
- * @param otherPro
+ * Class constructor. Used by older wizard servlet
+ *
+ * @param groups
+ * A linked list containg all groups to be handled
*/
public HTMLOutput(LinkedList groups) {
@@ -31,13 +44,21 @@
}
/**
- *
+ * Class Constructor
*/
public HTMLOutput() {
}
+ //
-----------------------------------------------------------------------
+ // public methods
+
/**
+ * Method that sets the ServletOutputStream that is used by the
HTMLOutput
+ * class. The stream is set by the wizard servlet,and its retrieved
by teh
+ * HttpResponnse Object
+ *
* @param stream
+ * The ServletOutputStream
*/
public void setOuputStream(ServletOutputStream stream) {
@@ -45,10 +66,19 @@
}
/**
+ * Method used for showing the properties to be configured. Used by
an older
+ * Wizard servlet object
+ *
* @param request
- * @param out
- * @param existProperties2
- * @param string
+ * The HttpServletRequest Object containing info from the
user
+ * @param showProperties
+ * The properties to be shown
+ * @param function
+ * The group that the properties belong to
+ * @param ignoreFirst
+ * The user can set this to true if he doesn't want the
first
+ * property to be shown(In case its a property that was set
+ * before)
* @throws IOException
*/
public void showProperties(HttpServletRequest request,
@@ -101,10 +131,18 @@
}
/**
- * @param out
+ * Method used by older wizard servlet. Its purpose is to display to
the
+ * user a sindle property which its value would determine if the rest
of the
+ * group properties will be shown to the user. i.e |Do you want to
register
+ * to a LS
+ *
* @param property
+ * The properety to be dispalyed
* @param function
+ * The group the property belongs to
* @param phase
+ * The phase that the configuration process is for this
+ * particular group
* @throws IOException
*/
public void continuePage(WizardProperty property, String function,
@@ -138,7 +176,12 @@
}
/**
- * @param out
+ * Method used for displaing information messages to the user
+ *
+ * @param topMessage
+ * The message that will appear at the top of the page
+ * @param message
+ * The main message to the user
* @throws IOException
*/
public void infoPage(String topMessage, String message) throws
IOException {
@@ -156,89 +199,14 @@
}
- private void preempt(String cssFile) throws IOException {
- out.println(doctype);
- out.println("<html>");
- out.println("<head>" + getCSS(cssFile));
- out.println("<title>");
- out.println("perfSONAR services configuration wizard");
- out.println("</title>");
- out.println("<body>");
- out.println("<div align=\"top\" class=\"banner\">");
- out.println("<h1>PerfSONAR");
- out.println("</div>");
- out.println("<div class=\"main\">");
- out.println("<div align=\"left\" class=\"config_option\">");
- out.println("<ul>");
- out.println("<li>Configuration options</li>");
- Iterator it = Groups.iterator();
- while (it.hasNext()) {
- String group = (String) it.next();
-
- if (group.equals("exist")) {
- out
- .println("<li><a
href=\"ConfigurationWizard?function=exist&phase=initial\">Exist
Configuration</a></li>");
- } else if (group.equals("ls")) {
-
- out
- .println("<li><a
href=\"ConfigurationWizard?function=ls&phase=initial\">LS Registration
Configuration</a></li>");
- } else {
-
- out.println("<li><a
href=\"ConfigurationWizard?function="
- + group + "&phase=initial\">"
+ group
- + " Configuration</a></li>");
- }
-
- }
- out
- .println("<li><a
href=\"ConfigurationWizard?function=finish\">Finish Configuration</a></li>");
- out.println("</ul>");
- out.println("</div>");
- }
-
- private void preemptModified(String cssFile) throws IOException {
- out.println(doctype);
- out.println("<html>");
- out.println("<head>" + getCSS(cssFile));
- out.println("<title>");
- out.println("perfSONAR services configuration wizard");
- out.println("</title>");
- out.println("<body>");
- out.println(getScript());
- out.println("<div align=\"top\" class=\"banner\">");
- out.println("<h1>perfSONAR</h1>");
- out.println("</div>");
- out.println("<div class=\"main\">");
- }
-
/**
- * @param cssFile
- * @return
- */
- private String getCSS(String cssFile) {
- String css = "<link rel=\"stylesheet\" type=\"text/css\"
href=\""
- + cssFile + "\">";
- return css;
- }
-
- /**
- * Method to get the stack trace of an exception
+ * Method used for displaying all properties to be configured, divided
+ * accodring to the group they belong to.
*
- * @param e
- * The exception
- * @return A string with stack the trace
- */
- public String getFault(Exception e) {
- StackTraceElement[] trace = e.getStackTrace();
- String fault = e.getMessage();
- for (int j = 0; j < trace.length; j++) {
- fault += trace[j].toString() + "\n";
- }
- return fault;
- }
-
- /**
- * @param otherProperties
+ * @param Properties
+ * The Wizard Properties to be configured
+ * @param message
+ * The top message to the user
* @throws IOException
*/
public void showAllProperties(
@@ -325,30 +293,12 @@
+ display + ";\">");
out.println("<table align=\"center\">");
this.showProperty(pr);
-
+
}
while (it.hasNext()) {
pr = pro.getWizardProperty((String)
it.next());
this.showProperty(pr);
- /*
- * pr = pro.getWizardProperty((String)
it.next()); out.println("<tr><td>" +
- * pr.getPropertyComment() + "</td><td>");
String[] values =
- * pr.getAcceptedValues(); if (values !=
null) {
- *
- * for (int i = 0; i < values.length; i++) {
String checked =
- * values[i] .equals(pr.getProposedValue()) ?
- * "checked=\"checked\"" : "";
out.println("<input
- * type=\"radio\"" + checked + " name=\"" +
pr.getKey() + "\"
- * value=\"" + values[i] + "\">" + values[i]
+ "</input>"); } }
- * else { String type="text";
- *
- * if(pr.isPassword()){ type="password"; }
out.println("<input
- * type=\""+type+"\" name=\"" + pr.getKey() +
"\" size=60
- * value=\"" + pr.getProposedValue() + "
\"/>"); } out.println("</td>");
- * String fill=" "; if(pr.isRequired()){
fill="*"; }
- * out.println("<td><label
for=\""+pr.getKey()+"\"><em>"+fill+"</em></label></td></tr>");
- */
}
out.println("</table>");
out.println("</div>");
@@ -364,6 +314,113 @@
}
+ //
-----------------------------------------------------------------------
+ // private mmathods
+
+ /**
+ * Used by older wizard servlet
+ *
+ * @param cssFile
+ * @throws IOException
+ */
+ private void preempt(String cssFile) throws IOException {
+ out.println(doctype);
+ out.println("<html>");
+ out.println("<head>" + getCSS(cssFile));
+ out.println("<title>");
+ out.println("perfSONAR services configuration wizard");
+ out.println("</title>");
+ out.println("<body>");
+ out.println("<div align=\"top\" class=\"banner\">");
+ out.println("<h1>PerfSONAR");
+ out.println("</div>");
+ out.println("<div class=\"main\">");
+ out.println("<div align=\"left\" class=\"config_option\">");
+ out.println("<ul>");
+ out.println("<li>Configuration options</li>");
+ Iterator it = Groups.iterator();
+ while (it.hasNext()) {
+ String group = (String) it.next();
+
+ if (group.equals("exist")) {
+ out
+ .println("<li><a
href=\"ConfigurationWizard?function=exist&phase=initial\">Exist
Configuration</a></li>");
+ } else if (group.equals("ls")) {
+
+ out
+ .println("<li><a
href=\"ConfigurationWizard?function=ls&phase=initial\">LS Registration
Configuration</a></li>");
+ } else {
+
+ out.println("<li><a
href=\"ConfigurationWizard?function="
+ + group + "&phase=initial\">"
+ group
+ + " Configuration</a></li>");
+ }
+
+ }
+ out
+ .println("<li><a
href=\"ConfigurationWizard?function=finish\">Finish Configuration</a></li>");
+ out.println("</ul>");
+ out.println("</div>");
+ }
+
+ /**
+ * Used by current wizard servlet
+ *
+ * @param cssFile
+ * The css file used by the html output
+ * @throws IOException
+ */
+ private void preemptModified(String cssFile) throws IOException {
+ out.println(doctype);
+ out.println("<html>");
+ out.println("<head>" + getCSS(cssFile));
+ out.println("<title>");
+ out.println("perfSONAR services configuration wizard");
+ out.println("</title>");
+ out.println("<body>");
+ out.println(getScript());
+ out.println("<div align=\"top\" class=\"banner\">");
+ out.println("<h1>perfSONAR</h1>");
+ out.println("</div>");
+ out.println("<div class=\"main\">");
+ }
+
+ /**
+ * Method returning the tag for css file to be used
+ *
+ * @param cssFile
+ * The css file
+ * @return The tag for the css file.
+ */
+ private String getCSS(String cssFile) {
+ String css = "<link rel=\"stylesheet\" type=\"text/css\"
href=\""
+ + cssFile + "\">";
+ return css;
+ }
+
+ /**
+ * Method to get the stack trace of an exception
+ *
+ * @param e
+ * The exception
+ * @return A string with stack the trace
+ */
+ public String getFault(Exception e) {
+ StackTraceElement[] trace = e.getStackTrace();
+ String fault = e.getMessage();
+ for (int j = 0; j < trace.length; j++) {
+ fault += trace[j].toString() + "\n";
+ }
+ return fault;
+ }
+
+ /**
+ * Method called by the shoaAllProperties method
+ *
+ * @param pr
+ * The wizard property
+ * @throws IOException
+ */
private void showProperty(WizardProperty pr) throws IOException {
out.println("<tr><td>" + pr.getPropertyComment() +
"</td><td>");
String[] values = pr.getAcceptedValues();
@@ -395,6 +452,11 @@
+ "</em></label></td></tr>");
}
+ /**
+ * Method for getting the java script used by the showAllPrperties
Method
+ *
+ * @return The javascript
+ */
private String getScript() {
String script = "<script type=\"text/javascript\">\n"
+ "function checkIt(el) {\n"
Modified:
branches/WebAdmin/perfSONARWebAdmin/auxiliary/wizard/WizardProperties.java
===================================================================
---
branches/WebAdmin/perfSONARWebAdmin/auxiliary/wizard/WizardProperties.java
2007-12-17 15:39:05 UTC (rev 3141)
+++
branches/WebAdmin/perfSONARWebAdmin/auxiliary/wizard/WizardProperties.java
2007-12-18 08:19:23 UTC (rev 3142)
@@ -8,7 +8,6 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.util.HashMap;
-import java.util.Hashtable;
import java.util.InvalidPropertiesFormatException;
import java.util.Iterator;
import java.util.LinkedList;
@@ -110,6 +109,8 @@
// A map containing the wizard properties
private Map<String, WizardProperty> properties;
+ // A map havinf as key the order of each property and as value the
+ // key(property name) of the property
private Map<String, String> orderedProperties;
//
-----------------------------------------------------------------------
@@ -245,8 +246,11 @@
}
/**
+ * Method for adding a Wizard Property
* @param key
+ * The key of the property(most likely the name)
* @param property
+ * The actula Wizard Property
*/
public Object setWizardProperty(String key, WizardProperty property) {
@@ -257,12 +261,12 @@
}
/**
+ * Returns the Wizard Properties keys in order as it is stated by
their order fileds
* @return
+ * An iterator containing the properties keys in order.
*/
public Iterator orderedKeys() {
- // System.out.println(orderedProperties.isEmpty());
- TreeMap map = new TreeMap(orderedProperties);
- // System.out.println(map.firstKey());
+ TreeMap<String,String> map = new
TreeMap<String,String>(orderedProperties);
return map.values().iterator();
}
@@ -273,9 +277,8 @@
/**
* Populates the properties map, based on the root element of the xml
* properties file
- *
* @param rootElement
- * the root element of the document read from the xml
properties
+ * The root element of the document read from the xml
properties
* file
*/
private void populateProperties(Element root) {
@@ -286,22 +289,21 @@
while (it.hasNext()) {
Element property = (Element) it.next();
WizardProperty pr = new WizardProperty();
- Element entry= property.getChild("entry");
+ Element entry = property.getChild("entry");
pr.setPropertyValue(entry.getText());
- if(entry.getAttribute("password")!=null){
-
pr.setPassword(Boolean.parseBoolean(entry.getAttributeValue("password")));
- }
- else{
+ if (entry.getAttribute("password") != null) {
+
pr.setPassword(Boolean.parseBoolean(entry
+
.getAttributeValue("password")));
+ } else {
pr.setPassword(false);
}
- if(entry.getAttribute("required")!=null){
-
pr.setRequired(Boolean.parseBoolean(entry.getAttributeValue("required")));
- }
- else{
+ if (entry.getAttribute("required") != null) {
+
pr.setRequired(Boolean.parseBoolean(entry
+
.getAttributeValue("required")));
+ } else {
pr.setRequired(false);
}
- pr.setPropertyKey(entry.getAttributeValue(
- "key").trim());
+
pr.setPropertyKey(entry.getAttributeValue("key").trim());
pr.setPropertyComment(property.getChild("Comment").getText());
pr
.setPropertyValue(property.getChild("entry").getText()
@@ -368,15 +370,16 @@
Element propertyElement = new Element("property");
Element entryElement = new Element("entry");
entryElement.setAttribute("key", pr.getKey());
- if(pr.isRequired()){
- entryElement.setAttribute("required","true");
+ if (pr.isRequired()) {
+ entryElement.setAttribute("required", "true");
}
- if(pr.isPassword()){
- entryElement.setAttribute("password","true");
+ if (pr.isPassword()) {
+ entryElement.setAttribute("password", "true");
}
entryElement.setText(pr.getValue());
propertyElement.addContent(entryElement);
- propertyElement.addContent(new
Element("Comment").setText(pr.getPropertyComment()));
+ propertyElement.addContent(new
Element("Comment").setText(pr
+ .getPropertyComment()));
propertyElement.addContent(new
Element("ProposedValue").setText(pr
.getProposedValue()));
Element group = new
Element("Group").setText(pr.getGroup());
Modified:
branches/WebAdmin/perfSONARWebAdmin/auxiliary/wizard/WizardProperty.java
===================================================================
--- branches/WebAdmin/perfSONARWebAdmin/auxiliary/wizard/WizardProperty.java
2007-12-17 15:39:05 UTC (rev 3141)
+++ branches/WebAdmin/perfSONARWebAdmin/auxiliary/wizard/WizardProperty.java
2007-12-18 08:19:23 UTC (rev 3142)
@@ -31,22 +31,22 @@
// The group of that the propertu belongs to
private String Group;
-
+
+ // The order of the property inside the group
private String order;
-
+
+ // Boolean indication if the property should be checked
private boolean check;
-
+
+ // Bollean indicatin if the property is a password
private boolean password;
-
+
+ // Booleasn indicating if the property is mandatory
private boolean required;
//
-----------------------------------------------------------------------
// class constructors
-
-
-
-
/**
* Class constructor
*
@@ -60,18 +60,25 @@
* The proposed value for the property
* @param acceptedValues
* The accepted values of the property
+ * @param chck
+ * Indicating if the property is to be checked
+ * @param pass
+ * Indicating if the property is to be checked
+ * @param req
+ * Inndicating if the property is required
*/
public WizardProperty(String key, String value, String comment,
- String proposedValue, String group, String[]
acceptedValues,boolean chck,boolean pass,boolean req) {
+ String proposedValue, String group, String[]
acceptedValues,
+ boolean chck, boolean pass, boolean req) {
PropertyKey = key;
PropertyValue = value;
PropertyComment = comment;
ProposedValue = proposedValue;
Group = group;
AcceptedValues = acceptedValues;
- check=chck;
- password=pass;
- required=req;
+ check = chck;
+ password = pass;
+ required = req;
}
@@ -85,9 +92,9 @@
ProposedValue = null;
Group = null;
AcceptedValues = null;
- check=false;
- password=false;
- required=false;
+ check = false;
+ password = false;
+ required = false;
}
@@ -214,60 +221,84 @@
}
/**
- * @return
+ * Method used for getting the order of the property inside the group
+ *
+ * @return The order of the property
*/
public String getOrder() {
return order;
}
/**
+ * Method for setting the order of the property inside the group
+ *
* @param order
+ * The order of the property
*/
public void setOrder(String order) {
this.order = order;
}
-
+
/**
- * @return
+ * Method used to determine if the property needs to be checked,
meaning
+ * that the value of this properties determines if the rest of the
group
+ * properties are to be shown to the user.(i.e xmldb status)
+ *
+ * @return True if the property is to be checked, false if not
*/
public boolean getCheck() {
return check;
}
/**
+ * Method used to set the check value of the property
+ *
* @param check
+ * Boolean that states if the property is to be checked
*/
public void setCheck(boolean chck) {
this.check = chck;
}
-
+
/**
- * @return
+ * Method used for checking if the property is a password
+ *
+ * @return True if the propeerty is a password, false if not
*/
public boolean isPassword() {
return password;
}
/**
+ * Method used for indicating if a property is a password
+ *
* @param password
+ * True if its a password, false if not
*/
public void setPassword(boolean password) {
this.password = password;
}
/**
- * @return
+ * Method used to determine if a property is required
+ *
+ * @return True if the property is mandatory, false if not
+ *
*/
public boolean isRequired() {
return required;
}
/**
+ * Method used to set the requiered field of the property
+ *
* @param required
+ * True if the property is mandatory, false if not.
*/
public void setRequired(boolean required) {
this.required = required;
}
+
/**
* @param args
*/
@@ -276,6 +307,4 @@
}
-
-
}
Added: branches/WebAdmin/perfSONARWebAdmin/test/ExistTesterXmlRpc.java
Property changes on:
branches/WebAdmin/perfSONARWebAdmin/test/ExistTesterXmlRpc.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: branches/WebAdmin/perfSONARWebAdmin/test/PractisingWizard.java
Property changes on:
branches/WebAdmin/perfSONARWebAdmin/test/PractisingWizard.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: branches/WebAdmin/perfSONARWebAdmin/test/Tester.java
Property changes on: branches/WebAdmin/perfSONARWebAdmin/test/Tester.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
- perfsonar: r3142 - in branches/WebAdmin/perfSONARWebAdmin: . admin/wizard admin/wizard/services auxiliary/wizard test, svnlog, 12/18/2007
Archive powered by MHonArc 2.6.16.