Skip to Content.
Sympa Menu

perfsonar-dev - perfsonar: r4634 - in branches/WebAdmin: . ant perfSONARWebAdmin/admin/service perfSONARWebAdmin/admin/wizard perfSONARWebAdmin/admin/wizard/services perfSONARWebAdmin/auxiliary perfSONARWebAdmin/auxiliary/wizard

Subject: perfsonar development work

List archive

perfsonar: r4634 - in branches/WebAdmin: . ant perfSONARWebAdmin/admin/service perfSONARWebAdmin/admin/wizard perfSONARWebAdmin/admin/wizard/services perfSONARWebAdmin/auxiliary perfSONARWebAdmin/auxiliary/wizard


Chronological Thread 
  • From:
  • To:
  • Subject: perfsonar: r4634 - in branches/WebAdmin: . ant perfSONARWebAdmin/admin/service perfSONARWebAdmin/admin/wizard perfSONARWebAdmin/admin/wizard/services perfSONARWebAdmin/auxiliary perfSONARWebAdmin/auxiliary/wizard
  • Date: Mon, 20 Oct 2008 10:15:47 -0400

Author: pgerakios
Date: 2008-10-20 10:15:47 -0400 (Mon, 20 Oct 2008)
New Revision: 4634

Modified:
branches/WebAdmin/CHANGELOG
branches/WebAdmin/ant/const.properties
branches/WebAdmin/index.jsp
branches/WebAdmin/perfSONARWebAdmin/admin/service/Admin.java
branches/WebAdmin/perfSONARWebAdmin/admin/wizard/Wizard.java

branches/WebAdmin/perfSONARWebAdmin/admin/wizard/services/LSWizardHandler.java
branches/WebAdmin/perfSONARWebAdmin/admin/wizard/services/RRDMAHandler.java
branches/WebAdmin/perfSONARWebAdmin/auxiliary/PerfsonarProperties.java
branches/WebAdmin/perfSONARWebAdmin/auxiliary/PerfsonarPropertiesImpl.java

branches/WebAdmin/perfSONARWebAdmin/auxiliary/wizard/ConfigurationHandler.java
Log:
version 0.9.7b

Modified: branches/WebAdmin/CHANGELOG
===================================================================
--- branches/WebAdmin/CHANGELOG 2008-10-20 13:46:17 UTC (rev 4633)
+++ branches/WebAdmin/CHANGELOG 2008-10-20 14:15:47 UTC (rev 4634)
@@ -1 +1,8 @@
-Version 0.9.4b:
\ No newline at end of file
+
+version 0.9.7b.jar
+
+- Modified internal structure of Web-Admin code
+- log4j properties path is now stored
+- index.jsp -> dead code has been removed
+- Better support for exceptions
+

Modified: branches/WebAdmin/ant/const.properties
===================================================================
--- branches/WebAdmin/ant/const.properties 2008-10-20 13:46:17 UTC (rev
4633)
+++ branches/WebAdmin/ant/const.properties 2008-10-20 14:15:47 UTC (rev
4634)
@@ -9,7 +9,7 @@
target.server=127.0.0.1
service.name=perfsonar-web-admin
jarfilename=perfsonar-web-admin
-version=0.9.5b
+version=0.9.7b

antcontrib.jar=${basedir}/lib/misc/ant-contrib-1.0b3.jar
antpsbase.jar=${basedir}/lib/misc/perfsonar-base-ant-1.0.20080303.jar

Modified: branches/WebAdmin/index.jsp
===================================================================
--- branches/WebAdmin/index.jsp 2008-10-20 13:46:17 UTC (rev 4633)
+++ branches/WebAdmin/index.jsp 2008-10-20 14:15:47 UTC (rev 4634)
@@ -72,9 +72,9 @@
<body>
<%

- java.text.DateFormat dateFormat = new java.text.SimpleDateFormat("EEE
MMM dd HH:mm:ss zzz yyyy");
- java.util.Date now= new java.util.Date();
- java.util.Date date= dateFormat.parse(now.toString());
+ // java.text.DateFormat dateFormat = new
java.text.SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy");
+ //java.util.Date now= new java.util.Date();
+ //java.util.Date date= dateFormat.parse(now.toString());
String confPath = "WEB-INF/classes/perfsonar/conf/";
String ServicePropertiesPath = confPath+ "service.properties";
ServletContext sc = getServletContext();

Modified: branches/WebAdmin/perfSONARWebAdmin/admin/service/Admin.java
===================================================================
--- branches/WebAdmin/perfSONARWebAdmin/admin/service/Admin.java
2008-10-20 13:46:17 UTC (rev 4633)
+++ branches/WebAdmin/perfSONARWebAdmin/admin/service/Admin.java
2008-10-20 14:15:47 UTC (rev 4634)
@@ -45,15 +45,15 @@

//
-----------------------------------------------------------------------
// class fields
-
+ private static final String confPath =
"/WEB-INF/classes/perfsonar/conf/";
// Path to service properties
- private static final String serviceProperties =
"/WEB-INF/classes/perfsonar/conf/service.properties";
+ private static String serviceProperties = confPath +
"service.properties";

// Path to logging properties
- private static final String log4jProperties =
"/WEB-INF/classes/perfsonar/conf/log4j.properties";
+ private static String log4jProperties = confPath +
"log4j.properties";

// Path to servlet properties
- private static final String ServletPropertiesPath =
"/WEB-INF/classes/perfsonar/conf/servlet.properties";
+ private static final String ServletPropertiesPath = confPath +
"servlet.properties";

// Path to service installation directory
private static String servicePath = null;
@@ -63,9 +63,44 @@

private static String extraFunctionalities = "off";

+ private static final String log4j_key = "servlet.log4j_path";
+
//
-----------------------------------------------------------------------
// public methods

+ private static String getLog4jProperty()
+ {
+ String log4j_keyprop = null;
+
+ if( log4j_keyprop == null ) try
+ {
+ Properties pr = new Properties();
+ pr.load(new
java.io.FileInputStream(new java.io.File(servicePath+
ServletPropertiesPath)));
+ String value =
pr.getProperty(log4j_key);
+ if( value != null )
+ {
+ log4j_keyprop = value.trim();
+ }
+ }
+ catch( Throwable t )
+ {
+ t.printStackTrace();
+ }
+
+ if( log4j_keyprop != null ) // update logging path
+ {
+ try
+ {
+ PerfsonarProperty p = new
PerfsonarPropertiesImpl(servicePath+serviceProperties).getProperty(log4j_keyprop);
+ if( p != null && p.getValue() != null )
return p.getValue().trim();
+ }
+ catch( Throwable t )
+ {
+ t.printStackTrace();
+ }
+ }
+ return "log4j.properties";
+ }
/*
* (non-Javadoc)
*
@@ -125,6 +160,9 @@
servicePath + ServletPropertiesPath);
String extra = servletProperties.getProperties().getProperty(
"servlet.extra_functionalities");
+
+ log4jProperties = confPath + getLog4jProperty();
+
if (extra != null) {
if (extra.equals("off")) {
extraFunctionalities = "off";

Modified: branches/WebAdmin/perfSONARWebAdmin/admin/wizard/Wizard.java
===================================================================
--- branches/WebAdmin/perfSONARWebAdmin/admin/wizard/Wizard.java
2008-10-20 13:46:17 UTC (rev 4633)
+++ branches/WebAdmin/perfSONARWebAdmin/admin/wizard/Wizard.java
2008-10-20 14:15:47 UTC (rev 4634)
@@ -33,6 +33,9 @@
import perfSONARWebAdmin.auxiliary.wizard.WizardProperties;
import perfSONARWebAdmin.auxiliary.wizard.WizardProperty;

+import perfSONARWebAdmin.auxiliary.LoadClass;
+import perfSONARWebAdmin.auxiliary.MaskedException;
+
/**
* Servlet to be used as a wizard for configurating perfSONAR service
*
@@ -101,13 +104,13 @@
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();
+ //Class clas = Class.forName(cl, true,
Thread.currentThread().getContextClassLoader());
+ //clas.newInstance();
+ handler = (ConfigurationHandler)
LoadClass.load(cl, new Object[]{ ServicePath,properties,groupedProperties} );
// And assign him all necessary fields
- handler.setProperties(properties);
-
handler.setGroupedProperties(groupedProperties);
- handler.setServicePath(ServicePath);
+ //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");
@@ -187,32 +190,25 @@
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",
-
"You have succesfully configured the service!You can
restart tomcat for the changes to take effect.\n Or go "
-
+ 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);
- }
- } catch (Exception e) {
+
handler.handleRequest(request);
+ output.infoPage
+ ("perfSONAR
configuration Wizard",
+ "You have
succesfully configured the service!You can restart tomcat"+
+ " for the
changes to take effect.\n Or go "+ goBack);
+ }
+ catch (MaskedException e) {
+ e.print();
// If an exceprion
has happened we notify the user

output.infoPage("perfSONAR configuration Wizard",
-
"Problem occured while finishing the configuration process!"
+
"Problem occured while finishing the configuration process."

+ goBack + "\n" + getFault(e));
}
+ catch( Exception e )
+ {
+ e.printStackTrace();
+ output.infoPage("perfSONAR
configuration Wizard","An unexpected exception has occured. This is probably
a bug." + goBack + "\n" +
+
getFault(e));
+ }
}

}

Modified:
branches/WebAdmin/perfSONARWebAdmin/admin/wizard/services/LSWizardHandler.java
===================================================================
---
branches/WebAdmin/perfSONARWebAdmin/admin/wizard/services/LSWizardHandler.java
2008-10-20 13:46:17 UTC (rev 4633)
+++
branches/WebAdmin/perfSONARWebAdmin/admin/wizard/services/LSWizardHandler.java
2008-10-20 14:15:47 UTC (rev 4634)
@@ -22,171 +22,15 @@
import perfSONARWebAdmin.auxiliary.xmlDB.xmlDBManager;
import perfSONARWebAdmin.auxiliary.xmlDB.xmlDBManagerImpl;

+import perfSONARWebAdmin.auxiliary.MaskedException;

-public class LSWizardHandler implements ConfigurationHandler {
+public class LSWizardHandler extends ConfigurationHandler {

+ public LSWizardHandler( String ServicePath , WizardProperties
properties, Hashtable<String, WizardProperties> groupedProperties )
+ {
+ super(ServicePath , properties, groupedProperties );
+ }
//
-----------------------------------------------------------------------
- // 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
- @SuppressWarnings("unused")
- 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 LSWizardHandler() {
-
- }
-
- //
-----------------------------------------------------------------------
- // public methods
-
- /*
- * (non-Javadoc)
- *
- * @see
perfSONARWebAdmin.auxiliary.wizard.ConfigurationHandler#handleRequest(javax.servlet.http.HttpServletRequest)
- */
- 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;
-
- // 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) {
-
- throw new Exception(
- "Problem with eXist configuration!Please check your
input.\n"
- + getFault(e));
- }
-
- // if every group has configured successfully then the final
- // configuration procedures are called
- if (eXistDone) {
- try {
-
- configured = finishConfiguration();
-
- } catch (Exception e) {
- throw new Exception("Problem finishing configuration.\n"
- + getFault(e));
- }
- }
-
- return configured;
-
- }
-
- /*
- * (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


@@ -198,13 +42,13 @@
* @return True if LS registration is configured successfully
* @throws Exception
*/
- private boolean handleExist(HttpServletRequest request) throws
Exception {
-
- boolean done = false;
-
+ protected void handleExist(HttpServletRequest request) throws
MaskedException
+ {
+
+ try
+ {
// 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
@@ -218,7 +62,6 @@
// 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
@@ -227,7 +70,6 @@
properties.setWizardProperty(statusKey, useExistProperty);
// Update exist group properties
groupedProperties.put("eXist", existProperties);
- try {
// Using the serviceProperties class for setting the
property

//Changing to PerfsonarProperties to maintain
grouping and description
@@ -251,25 +93,8 @@
// new Properties stored
serviceProperties.storeProperties(new
FileOutputStream(ServicePath
+ ServicePropertiesPath));
- // Set done to true
- done = true;

- } catch (IOException e) {
-
- // If anything happens set done to false
- done = false;
- throw new Exception(getFault(e));
-
- }
-
-
-
- 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
@@ -289,19 +114,17 @@
}
// 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;
- } catch (Exception e) {
- // Set doen to false if anything happens
- done = false;
- throw new Exception(getFault(e));
- }
- return done;
+ // Call for the needed actions for exist configuration.The
exist
+ // group properties are used as input
+ existActions(existProperties);
}

+ }
+ catch( Exception e )
+ {
+ throw new MaskedException(e, "Problem with eXist configuration.
Please check your input.");
+ }
+
}


@@ -513,55 +336,7 @@

}

-
/**
- * Method for performing final actions for service configuration
- *
- * @return
- * @throws Exception
- */
- public boolean finishConfiguration() throws Exception {
-
- PerfsonarProperties serviceProperties = new
PerfsonarPropertiesImpl();
- serviceProperties.loadProperties(new
FileInputStream(ServicePath
- + ServicePropertiesPath));
- PerfsonarProperty property = new PerfsonarProperty();
- property.setKey("service.sax_parser.config");
- property.setValue(ServicePath + ObjectsConfigPath);
- property.setGroup("Internals");
- property.setDescription("Sax parser configuration parameter");
- serviceProperties.setProperty(property.getKey(), property);
- property = new PerfsonarProperty();
- property.setKey("service.log.log4j.config");
- property.setValue(ServicePath + LoggingPropertiesPath);
- property.setGroup("Internals");
- property.setDescription("Logging Properties path");
- serviceProperties.setProperty(property.getKey(), property);
- serviceProperties.storeProperties(new
FileOutputStream(ServicePath
- + ServicePropertiesPath));
-
- return true;
-
- }
-
- /**
- * Method to get the stack trace of an exception
- *
- * @param e
- * The exception
- * @return A string with stack the trace
- */
- private 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;
- }
-
-
- /**
* Translate to XML RPC uri if necessary
*/
private String getXMLDBUri(String uri) {

Modified:
branches/WebAdmin/perfSONARWebAdmin/admin/wizard/services/RRDMAHandler.java
===================================================================
---
branches/WebAdmin/perfSONARWebAdmin/admin/wizard/services/RRDMAHandler.java
2008-10-20 13:46:17 UTC (rev 4633)
+++
branches/WebAdmin/perfSONARWebAdmin/admin/wizard/services/RRDMAHandler.java
2008-10-20 14:15:47 UTC (rev 4634)
@@ -14,6 +14,7 @@

import javax.servlet.http.HttpServletRequest;

+import perfSONARWebAdmin.auxiliary.MaskedException;
import perfSONARWebAdmin.auxiliary.PerfsonarProperties;
import perfSONARWebAdmin.auxiliary.PerfsonarPropertiesImpl;
import perfSONARWebAdmin.auxiliary.PerfsonarProperty;
@@ -26,196 +27,33 @@
import perfSONARWebAdmin.auxiliary.xmlDB.xmlDBManager;
import perfSONARWebAdmin.auxiliary.xmlDB.xmlDBManagerImpl;

+import perfSONARWebAdmin.auxiliary.MaskedException;
/**
* Class implementing the ConfigurationHandler Interface. This is a reference
* imlementation to be used exam
*
* @author Michalis Michael,CyNet
+ * @author Prodromos Gerakios, GRNET
*
*/
-public class RRDMAHandler implements ConfigurationHandler {
+public class RRDMAHandler extends ConfigurationHandler {

- //
-----------------------------------------------------------------------
- // class fields
+ public RRDMAHandler( String ServicePath , WizardProperties properties,
Hashtable<String, WizardProperties> groupedProperties )
+ {
+ super(ServicePath , properties, groupedProperties );
+ }

- // 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)
*
- * @see
perfSONARWebAdmin.auxiliary.wizard.ConfigurationHandler#handleRequest(javax.servlet.http.HttpServletRequest)
+ * @see
perfSONARWebAdmin.auxiliary.wizard.ConfigurationHandler#handleSpecific(javax.servlet.http.HttpServletRequest)
*/
- 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) {
-
- throw new Exception(
- "Problem with eXist
configuration!Please check your input.\n"
- + getFault(e));
- }
- try {
- // Handling LS configuration
- // True if all is done properly
- LSDone = handleLS(request);
- } catch (Exception e) {
- throw new Exception(
- "Problem with LS configuration!Please
check your input.\n"
- + getFault(e));
- }
- try {
- // Handling other groups configuration
- // True if all is done properly
- otherDone = handleOther(request);
- } catch (Exception e) {
-
- throw new Exception(
- "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"
- + getFault(e));
- }
- } else {
- return configured;
- }
-
+ protected void handleSpecific(HttpServletRequest request) throws
MaskedException
+ {
+ handleLS(request);
+ handleOther(request);
}

- /*
- * (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

@@ -228,12 +66,12 @@
* @return True if other groups are configured successfully
* @throws Exception
*/
- private boolean handleOther(HttpServletRequest request) throws
Exception {
+ private void handleOther(HttpServletRequest request) throws
MaskedException {

+ try
+ {
// 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();
@@ -269,17 +107,14 @@
// 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;
+ }
+ catch( Exception e )
+ {
+ throw new MaskedException(e,"Problem with Store configuration.
Please check your input.");
+ }
}

/**
@@ -287,11 +122,11 @@
*
* @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
{
-
+ private void handleLS(HttpServletRequest request) throws
MaskedException {
+ try
+ {
// 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
@@ -317,25 +152,17 @@
}
// 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;
+ lsActions(lsProperties);
}
// If no then the registration componenets are commented in
the
// components.properties file
- else {
- removeRegistrationComponents();
- return true;
- }
+ else removeRegistrationComponents();
+ }
+ catch( Exception e )
+ {
+ throw new MaskedException(e,"Problem with LS configuration.
Please check your input.");
+ }
}

/**
@@ -346,53 +173,13 @@
* @return True if LS registration is configured successfully
* @throws Exception
*/
- private boolean handleExist(HttpServletRequest request) throws
Exception {
- boolean done = false;
+ protected void handleExist(HttpServletRequest request) throws
MaskedException {
+ try
+ {
// Getting the exist database associated properties
WizardProperties existProperties =
groupedProperties.get("eXist");
Iterator it = existProperties.orderedKeys();

- /*
- * This piece of code was commented after Romans request
because now the
- * use of eXist in RRDMA is compalsury. Enyone else can use
the code if
- * he/she wishes to
- */
-
- // 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
- * setting 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)); }
- *
- * 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();
@@ -411,20 +198,14 @@
}
// Update the exist group Property
groupedProperties.put("eXist", existProperties);
- try {
- // Call for the needed actions for exist
configuration.The exist
+ // Call for the needed actions for exist
configuration.The exist
// group properties are used as input
existActions(existProperties);
- done = true;
- } catch (Exception e) {
- // Set doen to false if anything happens
- done = false;
- e.printStackTrace();
- System.out.println(" ...................... ");
- throw new Exception(e.getMessage());
- }
- return done;
- // }
+ }
+ catch (Exception e)
+ {
+ throw new MaskedException(e, "Problem with eXist configuration.
Please check your input.");
+ }

}

@@ -819,36 +600,6 @@
}

/**
- * Method for performing final actions for service configuration
- *
- * @return
- * @throws Exception
- */
- public boolean finishConfiguration() throws Exception {
-
- PerfsonarProperties serviceProperties = new
PerfsonarPropertiesImpl();
- serviceProperties.loadProperties(new
FileInputStream(ServicePath
- + ServicePropertiesPath));
- PerfsonarProperty property = new PerfsonarProperty();
- property.setKey("service.sax_parser.config");
- property.setValue(ServicePath + ObjectsConfigPath);
- property.setGroup("Internals");
- property.setDescription("Sax parser configuration paramater");
- serviceProperties.setProperty(property.getKey(), property);
- property = new PerfsonarProperty();
- property.setKey("service.log.log4j.config");
- property.setValue(ServicePath + LoggingPropertiesPath);
- property.setGroup("Internals");
- property.setDescription("Logging Properties path");
- serviceProperties.setProperty(property.getKey(), property);
- serviceProperties.storeProperties(new
FileOutputStream(ServicePath
- + ServicePropertiesPath));
-
- return true;
-
- }
-
- /**
* Method to get the stack trace of an exception
*
* @param e

Modified:
branches/WebAdmin/perfSONARWebAdmin/auxiliary/PerfsonarProperties.java
===================================================================
--- branches/WebAdmin/perfSONARWebAdmin/auxiliary/PerfsonarProperties.java
2008-10-20 13:46:17 UTC (rev 4633)
+++ branches/WebAdmin/perfSONARWebAdmin/auxiliary/PerfsonarProperties.java
2008-10-20 14:15:47 UTC (rev 4634)
@@ -20,6 +20,8 @@
*/
public interface PerfsonarProperties {

+ public void store() throws Exception;
+
/**
* Loads PerfsonarProperties
*

Modified:
branches/WebAdmin/perfSONARWebAdmin/auxiliary/PerfsonarPropertiesImpl.java
===================================================================
---
branches/WebAdmin/perfSONARWebAdmin/auxiliary/PerfsonarPropertiesImpl.java
2008-10-20 13:46:17 UTC (rev 4633)
+++
branches/WebAdmin/perfSONARWebAdmin/auxiliary/PerfsonarPropertiesImpl.java
2008-10-20 14:15:47 UTC (rev 4634)
@@ -23,9 +23,29 @@
*
*/
@SuppressWarnings("serial")
-public class PerfsonarPropertiesImpl extends
- Hashtable<String, PerfsonarProperty> implements
PerfsonarProperties {
+public class PerfsonarPropertiesImpl extends Hashtable<String,
PerfsonarProperty> implements PerfsonarProperties {

+ private String file = null;
+
+ public static void update( String file , PerfsonarProperty ... ppl )
throws Exception
+ {
+ PerfsonarProperties serviceProperties = new
PerfsonarPropertiesImpl();
+ serviceProperties.loadProperties(new FileInputStream(file));
+ for( PerfsonarProperty pp : ppl )
serviceProperties.setProperty(pp.getKey(),pp);
+ serviceProperties.storeProperties(new FileOutputStream(file));
+ }
+
+ public PerfsonarPropertiesImpl( String file ) throws Exception
+ {
+ loadProperties(new FileInputStream(file));
+ this.file = file;
+ }
+
+ public void store() throws Exception
+ {
+ if( file == null ) throw new Exception("Invalid method call");
+ else storeProperties(new FileOutputStream(file));
+ }
//
-----------------------------------------------------------------------
// constructors


Modified:
branches/WebAdmin/perfSONARWebAdmin/auxiliary/wizard/ConfigurationHandler.java
===================================================================
---
branches/WebAdmin/perfSONARWebAdmin/auxiliary/wizard/ConfigurationHandler.java
2008-10-20 13:46:17 UTC (rev 4633)
+++
branches/WebAdmin/perfSONARWebAdmin/auxiliary/wizard/ConfigurationHandler.java
2008-10-20 14:15:47 UTC (rev 4634)
@@ -1,18 +1,104 @@
package perfSONARWebAdmin.auxiliary.wizard;
-
import java.util.Hashtable;
-
import javax.servlet.http.HttpServletRequest;
-
+import perfSONARWebAdmin.auxiliary.MaskedException;
+import perfSONARWebAdmin.auxiliary.wizard.WizardProperties;
+import perfSONARWebAdmin.auxiliary.wizard.WizardProperty;
+import perfSONARWebAdmin.auxiliary.PerfsonarProperties;
+import perfSONARWebAdmin.auxiliary.PerfsonarPropertiesImpl;
+import perfSONARWebAdmin.auxiliary.PerfsonarProperty;
+import java.util.Properties;
/**
* Interface used for handling the configuration data data returned by the
end
* user in the Service Configuration Wizard Servlet
*
* @author Michalis Michael,CyNNet
- *
+ * @author Prodromos Gerakios, GRNET
*/
-public interface ConfigurationHandler {
+public abstract class ConfigurationHandler {

+ // Hashtable containg Wizard Properties as values and the various
groups in
+ // which the properties are divided to as keys
+ protected Hashtable<String, WizardProperties> groupedProperties =
null;
+
+ // All of the Wizard Properties
+ protected WizardProperties properties = null;
+
+ // The path to the configuration directory
+ protected static final String confPath =
"WEB-INF/classes/perfsonar/conf/";
+
+ // The path to the service.properties file
+ protected static final String ServicePropertiesPath = confPath
+ + "service.properties";
+
+ // The path to the logging properties file
+ protected static String LoggingPropertiesPath = confPath +
"log4j.properties";
+
+ // The path to the componenets.properties file
+ @SuppressWarnings("unused")
+ protected static final String ComponentsPropertiesPath =
confPath + "components.properties";
+
+ // The path to the objects properties file
+ protected static final String ObjectsConfigPath = confPath +
"objects.config";
+
+ // The path to the wizard.properties file
+ protected static final String WizardPropertiesPath = confPath +
"wizard.properties";
+
+ // The path to the servlet.properties file
+ protected static final String ServletPropertiesPath = confPath
+ "servlet.properties";
+
+ protected static String ServicePath;
+
+ protected static HTMLOutput output = null;
+
+ protected static boolean configured = false;
+
+ private static final String log4j_key =
"servlet.log4j_path";
+
+ private static String log4j_keyprop = null;
+
+ private void updateLoggingPath( String str ) throws
MaskedException
+ {
+ if( str != null &&
str.indexOf(java.io.File.separator) < 0)
+ LoggingPropertiesPath = confPath + str.trim();
+ else throw new MaskedException(new
Exception(),"Invalid logging path " + str + "\n");
+ }
+
+ public ConfigurationHandler( String ServicePath ,
WizardProperties properties, Hashtable<String, WizardProperties>
groupedProperties )
+ {
+ this.ServicePath = ServicePath;
+ this.properties = properties;
+ this.groupedProperties = groupedProperties;
+
+ if( log4j_keyprop == null ) try
+ {
+ Properties pr = new Properties();
+ pr.load(new
java.io.FileInputStream(new java.io.File(ServicePath+
ServletPropertiesPath)));
+ String value =
pr.getProperty(log4j_key);
+ if( value != null )
+ {
+ log4j_keyprop = value.trim();
+ }
+ }
+ catch( Throwable t )
+ {
+ t.printStackTrace();
+ }
+
+ if( log4j_keyprop != null ) // update logging path
+ {
+ try
+ {
+ PerfsonarProperty p = new
PerfsonarPropertiesImpl(ServicePath+ServicePropertiesPath).getProperty(log4j_keyprop);
+ if( p != null )
updateLoggingPath(p.getValue());
+ }
+ catch( Throwable t )
+ {
+ t.printStackTrace();
+ }
+ }
+ }
+
/**
* 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
@@ -21,12 +107,22 @@
* @param request
* The http request that was send by the user containg
* configuration data
- * @return A boolean stating if the configuration process was
successful or
- * not
+ * @return void
* @throws Exception
*/
- public boolean handleRequest(HttpServletRequest request) throws
Exception;
+ public final void handleRequest(HttpServletRequest request) throws
MaskedException
+ {
+ handleExist(request);
+ handleSpecific(request);
+ finishConfiguration(request);
+ }
+
+ abstract protected void handleExist(HttpServletRequest request)
throws MaskedException;

+ protected void handleSpecific(HttpServletRequest request) throws
MaskedException // override if necessary,default behaviour: do nothing
+ {
+ }
+
/**
* Method that indicates if that all configuration actions have been
done
* successfully
@@ -34,46 +130,42 @@
* @return A boolean stating if configuration is finished and
succesful or
* not
*/
- public boolean isConfigured();
+ public final boolean isConfigured()
+ {
+ return configured;
+ }

/**
- * 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>
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);
+ public final void setHTMLOutput(HTMLOutput output)
+ {
+ this.output = output;
+ }
+
+ private final void finishConfiguration(HttpServletRequest request)
throws MaskedException
+ {
+ if( log4j_keyprop != null )
+ {
+ String value =
request.getParameter(log4j_keyprop).trim();
+ if( value != null ) updateLoggingPath(value);
+ }
+
+ try
+ {
+ PerfsonarPropertiesImpl.
+ update(ServicePath + ServicePropertiesPath,
+ new
PerfsonarProperty("service.sax_parser.config",ServicePath +
ObjectsConfigPath,"Internals","Sax parser configuration parameter"),
+ new
PerfsonarProperty("service.log.log4j.config",ServicePath +
LoggingPropertiesPath,"Internals","Logging Properties path")
+ );
+ }
+ catch (Exception e)
+ {
+ throw new MaskedException(e,"Problem finishing
configuration.\n");
+ }
+ }
}



  • perfsonar: r4634 - in branches/WebAdmin: . ant perfSONARWebAdmin/admin/service perfSONARWebAdmin/admin/wizard perfSONARWebAdmin/admin/wizard/services perfSONARWebAdmin/auxiliary perfSONARWebAdmin/auxiliary/wizard, svnlog, 10/20/2008

Archive powered by MHonArc 2.6.16.

Top of Page