perfsonar-dev - perfsonar: r4649 - trunk/geant2_java-xml-ls/src/main/java/org/perfsonar/service/lookupService/xmlType/webadmin
Subject: perfsonar development work
List archive
perfsonar: r4649 - trunk/geant2_java-xml-ls/src/main/java/org/perfsonar/service/lookupService/xmlType/webadmin
Chronological Thread
- From:
- To:
- Subject: perfsonar: r4649 - trunk/geant2_java-xml-ls/src/main/java/org/perfsonar/service/lookupService/xmlType/webadmin
- Date: Tue, 21 Oct 2008 10:00:20 -0400
Author: mac
Date: 2008-10-21 10:00:20 -0400 (Tue, 21 Oct 2008)
New Revision: 4649
Modified:
trunk/geant2_java-xml-ls/src/main/java/org/perfsonar/service/lookupService/xmlType/webadmin/LSWizardHandler.java
Log:
Compile and works however the problem with exist properties is not solved
yet.
Modified:
trunk/geant2_java-xml-ls/src/main/java/org/perfsonar/service/lookupService/xmlType/webadmin/LSWizardHandler.java
===================================================================
---
trunk/geant2_java-xml-ls/src/main/java/org/perfsonar/service/lookupService/xmlType/webadmin/LSWizardHandler.java
2008-10-21 13:54:02 UTC (rev 4648)
+++
trunk/geant2_java-xml-ls/src/main/java/org/perfsonar/service/lookupService/xmlType/webadmin/LSWizardHandler.java
2008-10-21 14:00:20 UTC (rev 4649)
@@ -14,13 +14,13 @@
import javax.servlet.http.HttpServletRequest;
+import perfSONARWebAdmin.auxiliary.MaskedException;
import perfSONARWebAdmin.auxiliary.PerfsonarProperties;
import perfSONARWebAdmin.auxiliary.PerfsonarPropertiesImpl;
import perfSONARWebAdmin.auxiliary.PerfsonarProperty;
import perfSONARWebAdmin.auxiliary.ServiceProperties;
import perfSONARWebAdmin.auxiliary.ServicePropertiesImpl;
import perfSONARWebAdmin.auxiliary.wizard.ConfigurationHandler;
-import perfSONARWebAdmin.auxiliary.wizard.HTMLOutput;
import perfSONARWebAdmin.auxiliary.wizard.WizardProperties;
import perfSONARWebAdmin.auxiliary.wizard.WizardProperty;
import perfSONARWebAdmin.auxiliary.xmlDB.xmlDBManager;
@@ -33,203 +33,31 @@
* @author Maciej Glowiak
*
*/
-public class LSWizardHandler implements ConfigurationHandler {
+public class LSWizardHandler extends 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
- @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 LSWizardHandler(
+ String servicePath,
+ WizardProperties properties, Hashtable<String,
WizardProperties> groupedProperties) {
+ super(servicePath, properties, groupedProperties);
}
- //
-----------------------------------------------------------------------
- // public methods
+ protected void handleSpecific(HttpServletRequest request) throws
MaskedException
+ {
+ handleLS(request);
+ handleOther(request);
+ }
- /*
- * (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;
- boolean lsDone = false;
- 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;
- }
-
- }
-
-
- /*
- * (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
@@ -239,15 +67,15 @@
*
* @param request
* The HttpServletRequest containing input from the user
- * @return True if other groups are configured successfully
- * @throws Exception
+ * @throws MaskedException
*/
- 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();
@@ -283,17 +111,15 @@
// 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));
}
}
- }
+ }
+ catch( Exception t )
+ {
+ throw new MaskedException(t, "Problem with Store
configuration!Please check your input.");
+ }
- return done;
}
@@ -302,11 +128,12 @@
*
* @param request
* The HttpServletRequest containing input from the user
- * @return True if LS registration is configured successfully
- * @throws Exception
+ * @throws MaskedException
*/
- 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
@@ -332,25 +159,19 @@
}
// 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;
}
+ }
+ catch( Exception t )
+ {
+ throw new MaskedException(t, "Problem with LS configuration!Please
check your input.");
+ }
}
@@ -360,12 +181,13 @@
* @param request
* The HttpServletRequest containing input from the user
* @return True if LS registration is configured successfully
- * @throws Exception
+ * @throws MaskedException
*/
- private boolean handleExist(HttpServletRequest request) throws Exception
{
+
+ protected void handleExist(HttpServletRequest request) throws
MaskedException {
- boolean done = false;
-
+ try
+ {
// Getting the exist database associated properties
WizardProperties existProperties = groupedProperties.get("eXist");
@@ -391,7 +213,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
@@ -416,19 +237,7 @@
// 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
@@ -450,19 +259,16 @@
}
// 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;
- }
-
+ }
+ catch(Exception t )
+ {
+ throw new MaskedException(t, "Problem with eXist configuration.
Please check your input.");
+ }
}
@@ -873,55 +679,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 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) {
- perfsonar: r4649 - trunk/geant2_java-xml-ls/src/main/java/org/perfsonar/service/lookupService/xmlType/webadmin, svnlog, 10/21/2008
Archive powered by MHonArc 2.6.16.