Skip to Content.
Sympa Menu

perfsonar-dev - WebAdmin layout problem

Subject: perfsonar development work

List archive

WebAdmin layout problem


Chronological Thread 
  • From: Stijn Melis <>
  • To: "" <>
  • Subject: WebAdmin layout problem
  • Date: Mon, 08 Sep 2008 17:18:29 +0200

Hello all,

I am trying to upgrade the WebAdmin for SSHTELNET MP, but I am having some trouble getting the layout right.

The first and biggest problem (the red circles in the picture) is that the checkboxes in the eXist part of the basic configuration page (this is the only part that's updated with the new WebAdmin jar) aren't working correctly. In the AuthN and LS Registration part, when you click "yes", some other options appear, however, in the eXist part, they are already visible by default (even though "no" is selected). I checked with the SQL MA, and there this problem doesn't exist (no pun intended ;)).
Furthermore, the second question (i.e. "Confirm new eXist administration password:") should be a part of the "Do you wish to change the exist Admin password?" part. Yet it is situated at the top, even though it has order number 10, and depends on 8...

A second problem (the blue circle in the picture) is the fact that at the top right op the page, the name, date and version isn't aligned correctly.

I attached both my wizard.properties file, servlet.properties file as well as my SSHTelnetHandler.java class which does the logic behind the page.

I checked the source code and the properties files for the SQL MA, RRD MA, and AS and I can't really find anything which I am doing different. If anyone could have a look at what I am doing wrong, I'd be most grateful.

Should you wish more information about other files, then you can have a look in the SVN trunk. I updated the SVN with the current files I am using at the moment.

Thanks a lot in advance,

Stijn
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE properties [
 <!ELEMENT properties ( comment?, property* )>
<!ATTLIST properties version CDATA #FIXED "0.1">
<!ELEMENT comment (#PCDATA) >
<!ELEMENT property (entry,Comment,ProposedValue,Group+,AcceptedValue*) >
<!ELEMENT entry (#PCDATA) >
<!ATTLIST entry
key CDATA #REQUIRED
		password (true|false) #IMPLIED
		required (true|false) #IMPLIED	>
<!ELEMENT Comment (#PCDATA) >
<!ELEMENT ProposedValue (#PCDATA) >
<!ELEMENT Group (#PCDATA) >
<!ATTLIST Group 
  order CDATA #REQUIRED 
 check (true|false) #IMPLIED 
>
<!ELEMENT AcceptedValue (#PCDATA) >
]>
<properties>
  <comment>Last Modification Thu Mar 06 19:53:22 CET 2008</comment>
  
  <property>
    <entry key="service.r.service_name" required="true">geant2-java-sshtelnet-mp</entry>
    <Comment>Enter the service name:</Comment>
    <ProposedValue>geant2-java-sshtelnet-mp</ProposedValue>
    <Group order="1">LS</Group>
  </property>

  <property>
    <entry key="service.r.service_description">perfSONAR Java SSH TELNET MP</entry>
    <Comment>Enter a description for the service:</Comment>
    <ProposedValue>perfSONAR Java SSH TELNET MP</ProposedValue>
    <Group order="2">LS</Group>
  </property>

  <property>
    <entry key="service.r.contact_email">user@domain</entry>
    <Comment>Enter the service administrator's email address:</Comment>
    <ProposedValue>user@domain</ProposedValue>
    <Group order="3">LS</Group>
  </property>

  <property>
    <entry key="service.r.organization_name">Institution</entry>
    <Comment>Enter the name of the organisation running this service:</Comment>
    <ProposedValue>Institution</ProposedValue>
    <Group order="4">LS</Group>
  </property>

  <property>
    <entry key="service.r.ls_url" required="true">http://somewhere</entry>
    <Comment>Enter the LS URL:</Comment>
    <ProposedValue>http://somewhere</ProposedValue>
    <Group order="5">LS</Group>
  </property>

  <property>
    <entry key="component.registrator.interval">30000</entry>
    <Comment>Set the registration interval (milliseconds):</Comment>
    <ProposedValue>30000</ProposedValue>
    <Group order="6">LS</Group>
  </property>

  <property>
    <entry key="service.r.access_point" required="true">http://somewhere</entry>
    <Comment>Enter the service access point:</Comment>
    <ProposedValue>http://somewhere</ProposedValue>
    <Group order="7">LS</Group>
  </property>  
  
  <!--
  <property>
    <entry key="service.ls.registration_file" required="true">/opt/perfsonar/services/geant2-java-sshtelnet-mp/WEB-INF/classes/perfsonar/conf/sshtelnetmetadata.xml</entry>
    <Comment>Enter the path to the metadata configuration file which needs to be uploaded to the LS:</Comment>
    <ProposedValue>/opt/perfsonar/services/geant2-java-sshtelnet-mp/WEB-INF/classes/perfsonar/conf/sshtelnetmetadata.xml</ProposedValue>
    <Group order="8">LS</Group>
  </property>
  -->  
  
  
  <property>
    <entry key="component.mp.xmldb.db_uri" required="true">xmldb:exist://localhost:8080/exist/xmlrpc/db </entry>
    <Comment>Enter the URI location of the eXist database:</Comment>
    <ProposedValue>xmldb:exist://localhost:8080/exist/xmlrpc/db </ProposedValue>
    <Group order="1">eXist</Group>
  </property>
  
  <property>
    <entry key="component.mp.xmldb.db_username" required="true">sshtelnet</entry>
    <Comment>Enter the service username for the eXist user:</Comment>
    <ProposedValue>sshtelnet</ProposedValue>
    <Group order="2">eXist</Group>
  </property>
  
  <property>
    <entry key="component.mp.xmldb.db_password" required="true" password="true">sshtelnet</entry>
    <Comment>Enter the password for the eXist user:</Comment>
    <ProposedValue>sshtelnet</ProposedValue>
    <Group order="3">eXist</Group>
  </property>
  
  <property>
    <entry key="create_user" required="true">no</entry>
    <Comment>Do you wish to create a user with this name?</Comment>
    <ProposedValue>no</ProposedValue>
    <Group order="4" check="true">eXist</Group>
    <AcceptedValue>yes</AcceptedValue>
    <AcceptedValue>no</AcceptedValue>
  </property>
  
  <property>
    <entry key="old_adminpassword_1" required="true" password="true" />
    <Comment>Enter the eXist administration password:</Comment>
    <ProposedValue />
    <Group order="5" dependsOn="4">eXist</Group>
  </property>

  <property>
    <entry key="component.mp.xmldb.metadata_file_name" required="true">sshtelnetmetadata.xml</entry>
    <Comment>Enter the name of the metadata configuration file:</Comment>
    <ProposedValue>sshtelnetmetadata.xml</ProposedValue>
    <Group order="6">eXist</Group>
  </property>
  
  <property>
    <entry key="component.mp.xmldb.metadata_file_path" required="true">/opt/perfsonar/services/geant2-java-sshtelnet-mp/WEB-INF/classes/perfsonar/conf/sshtelnetmetadata.xml</entry>
    <Comment>Enter the full path of the metadata configuration file:</Comment>
    <ProposedValue>/opt/perfsonar/services/geant2-java-sshtelnet-mp/WEB-INF/classes/perfsonar/conf/sshtelnetmetadata.xml</ProposedValue>
    <Group order="7">eXist</Group>
  </property>
  
  <property>
    <entry key="change_admin_pass" required="true">no</entry>
    <Comment>Do you wish to change the exist Admin password?</Comment>
    <ProposedValue>no</ProposedValue>
    <Group order="8" check="true">eXist</Group>
    <AcceptedValue>yes</AcceptedValue>
    <AcceptedValue>no</AcceptedValue>
  </property>
  
  <property>
    <entry key="component.mp.xmldb.db_adminpassword" required="true" password="true" />
    <Comment>Enter the eXist administration password:</Comment>
    <ProposedValue />
    <Group order="9" dependsOn="8">eXist</Group>
  </property>
  
  <property>
    <entry key="component.ma.xmldb.db_adminpassword_confirm" required="true" password="true" />
    <Comment>Confirm new eXist administration password:</Comment>
    <ProposedValue />
    <Group order="10" dependsOn="8">eXist</Group>
  </property>
  
  <property>
    <entry key="old_adminpassword" required="true" password="true" />
    <Comment>Enter the old eXist administration password:</Comment>
    <ProposedValue />
    <Group order="99" dependsOn="8">eXist</Group>
  </property>
  
 
  <property>
    <entry key="servlet.username" required="true">perfsonaruser</entry>
    <Comment>Enter the username for logging in to the admin pages:</Comment>
    <ProposedValue>perfsonaruser</ProposedValue>
    <Group order="1" check="false">Administration</Group>
  </property>
  
  <property>
    <entry key="servlet.password" required="true" password="true">perfsonarpass</entry>
    <Comment>Enter the password for logging in to the admin pages:</Comment>
    <ProposedValue>perfsonarpass</ProposedValue>
    <Group order="2">Administration</Group>
  </property>
  
  
   <property>
    <entry key="service.as.authn_active" required="true">no</entry>
    <Comment>Do you wish to enable authentication?</Comment>
    <ProposedValue>yes</ProposedValue>
    <Group order="1" check="true">Authentication</Group>
    <AcceptedValue>yes</AcceptedValue>
    <AcceptedValue>no</AcceptedValue>
  </property>
  
  <property>
    <entry key="service.as.point" required="true">http://homer.rediris.es:8080/perfSONAR-AS/services/AuthService</entry>
    <Comment>Enter the URL address of the Authentication Service:</Comment>
    <ProposedValue>http://homer.rediris.es:8080/perfSONAR-AS/services/AuthService</ProposedValue>
    <Group order="2">Authentication</Group>
  </property>
  
    <property>
    <entry key="service.as.authn_for_msg_types" required="true">SetupDataRequest,MetadataKeyRequest</entry>
    <Comment>Enter the message types which should be authenticated:</Comment>
    <ProposedValue>SetupDataRequest,MetadataKeyRequest</ProposedValue>
    <Group order="3">Authentication</Group>
  </property>
</properties>


package org.perfsonar.service.measurementPoint.webAdmin;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Calendar;
import java.util.Hashtable;
import java.util.Iterator;

import javax.servlet.http.HttpServletRequest;

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;
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 SSHTelnetHandler 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 SSHTelnetHandler() {

}

//
-----------------------------------------------------------------------
// 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;
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);
//eXistDone = true;
} 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

/**
* Method used for handling other groups configuration(That is other
than LS
* and exist)
*
* @param request
* 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();
// 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;
}
// 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();


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);
if (!pr.getCheck()) {
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;
} catch (Exception e) {
// Set doen to false if anything happens
done = false;
throw new Exception(e.getMessage());
}
return done;
}

/**
* 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
*/
/**
* 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 group, WizardProperties
functionProperties)
throws IOException {

//System.out.println("otherActions("+group+",
"+functionProperties+") called");
// The only other group for rrd ma is the Store group
// So in this case changes go into the service.property file
that uses
// groupig and description
// In order to keep that functionality we need in this case
to use the
// PerfsonarProperties class
if (!group.equals("Administration")) {
//System.out.println("Group not equal to
Administrator");
// Using PerfsonarProperties in order to keep the
grouping and
// description
PerfsonarProperties serviceProperties = null;
serviceProperties = new PerfsonarPropertiesImpl();
serviceProperties.loadProperties(new
FileInputStream(ServicePath
+ ServicePropertiesPath));
// Getting the names for every property of the group
Iterator it = functionProperties.orderedKeys();
// Setting the value of each property

// An object that holds the property
group,description,value and key
PerfsonarProperty property = new PerfsonarProperty();
while (it.hasNext()) {
String key = (String) it.next();
// Setting service properties and wizard
properties

// Get the property
property = serviceProperties.getProperty(key);
// If key property does not exist the throw
an exception
if (property == null) {
throw new IOException("Key is invalid
" + key + " ");
} else {
//System.out.println("\n\nBefore
change: ");

//System.out.println("--------------");
//System.out.println("Property: " +
property.getKey());
//System.out.println("Property Value:
" + property.getValue());
//System.out.println("Property Group:
" + property.getGroup());
//System.out.println("Property
Description: " + property.getDescription());
// Change the value of the property

if(functionProperties.getProperty(key).equals("yes"))
property.setValue("on");
else if
(functionProperties.getProperty(key).equals("no"))
property.setValue("off");
else

property.setValue(functionProperties.getProperty(key));

serviceProperties.setProperty(key,
property);
//System.out.println("After change:
");
//System.out.println("-------------");
//System.out.println("Property: " +
property.getKey());
//System.out.println("Property Value:
" + property.getValue());
//System.out.println("Property Group:
" + property.getGroup());
//System.out.println("Property
Description: " + property.getDescription());
}
properties.setWizardProperty(key,
functionProperties
.getWizardProperty(key));
}
// Storing all changes
serviceProperties.storeProperties(new
FileOutputStream(ServicePath
+ ServicePropertiesPath));

}
// We don't really have any other groups just the ones for
the servlet
// administration, that does not use grouping and description
so we can
// use
// the ServiceProperties class as usual
else {
//System.out.println("Group equals Administrator");
// A class that makes modifying service properties a
little bit
// easier
ServiceProperties serviceProperties = new
ServicePropertiesImpl(
ServicePath + ServletPropertiesPath);
// Getting the names for every property of the group
Iterator it = functionProperties.orderedKeys();
// Setting the value of each property
String value = null;
while (it.hasNext()) {
String key = (String) it.next();
// Setting service properties and wizard
properties
value = functionProperties.getProperty(key);
//System.out.println("\n\nBefore change: ");
//System.out.println("--------------");
//System.out.println("Property: " + key);
//System.out.println("Property Value: " +
functionProperties.getProperty(key));
if (value == null) {
throw new IOException("Key is invalid
" + key + " ");
} else {
serviceProperties.setProperty(key,
value);
//System.out.println("After change:
");
//System.out.println("-------------");
//System.out.println("Property: " +
key);
//System.out.println("Property Value:
" + functionProperties.getProperty(key));
}
properties.setWizardProperty(key,
functionProperties
.getWizardProperty(key));
}
serviceProperties.storeProperties();

}
properties.storeToXML(new FileOutputStream(new
File(ServicePath
+ WizardPropertiesPath)), " Last Modification
"
+
Calendar.getInstance().getTime().toString());
}


/**
* 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 {
//System.out.println("lsActions("+finalProperties+") called");


// Changes happen into the service.property file that uses
groupig and
// description
// In order to keep that functionality we need in this case
to use the
// PerfsonarProperties class
PerfsonarProperties serviceProperties = new
PerfsonarPropertiesImpl();
serviceProperties.loadProperties(new
FileInputStream(ServicePath
+ ServicePropertiesPath));
Iterator it = finalProperties.orderedKeys();
// Iterating through the LS registration properties properties

// Initializing the PerfsonarProperty object that holds
information
// about grouping and description
PerfsonarProperty property = new PerfsonarProperty();
while (it.hasNext()) {
String key = (String) it.next();
// Set the service properties

// Get the PerfsonarProperty object
property = serviceProperties.getProperty(key);

// If property key does not exist throw an exceptrion
if (property == null) {
throw new IOException("Key is invalid " + key
+ " ");
} else {
//System.out.println("\n\nBefore change: ");
//System.out.println("--------------");
//System.out.println("Property: " +
property.getKey());
//System.out.println("Property Value: " +
property.getValue());
//System.out.println("Property Group: " +
property.getGroup());
//System.out.println("Property Description: "
+ property.getDescription());
// Else set the value right

property.setValue(finalProperties.getProperty(key));
serviceProperties.setProperty(key, property);
//System.out.println("After change: ");
//System.out.println("--------------");
//System.out.println("Property: " +
property.getKey());
//System.out.println("Property Value: " +
property.getValue());
//System.out.println("Property Group: " +
property.getGroup());
//System.out.println("Property Description: "
+ property.getDescription());
}
// Set the wizard properties
properties.setWizardProperty(key, finalProperties
.getWizardProperty(key));
}
// Storing service properties
serviceProperties.storeProperties(new
FileOutputStream(ServicePath
+ ServicePropertiesPath));
// 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 {
//System.out.println("existActions("+finalProperties+")
called");

try {
// Initiating ServiceProperties classes for handling
input to the
// service.properties and servlet.properties file
PerfsonarProperties serviceProperties = new
PerfsonarPropertiesImpl();
serviceProperties.loadProperties(new
FileInputStream(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.getKeysIterator();
// Get the type of the service. Will be used for
making the new db
// collection

// Naming the new collection on exist db
// 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")) {

newAdminPass =
finalProperties.getProperty(key).trim();
//System.out.println("newAdminPass: "
+ newAdminPass);
}
if (key.endsWith("xmldb.db_uri")) {
existURI =
finalProperties.getProperty(key);
//System.out.println("eXistURI: " +
existURI);
}

}

//System.out.println("adminPass: " + adminPass +
"\nnewAdminPass: " + newAdminPass);

// If admin pass is not set than its considered to be
empty
if (adminPass == null) {
adminPass = "";
}

it = finalProperties.orderedKeys();
// Iterating though the users input
while (it.hasNext()) {

String key = (String) it.next();
// 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
PerfsonarProperty property = new
PerfsonarProperty();
if (key.equals("old_adminpassword")) {

adminPass =
finalProperties.getProperty(key).trim();

} else {
property =
serviceProperties.getProperty(key);
// If property key does not exist
throw an exceptrion
if (property == null) {
throw new Exception("Key is
invalid " + key + " ");
} else {

//System.out.println("\n\nBefore change: ");

//System.out.println("--------------");

//System.out.println("Property: " + property.getKey());

//System.out.println("Property Value: " + property.getValue());

//System.out.println("Property Group: " + property.getGroup());

//System.out.println("Property Description: " + property.getDescription());

property.setValue(finalProperties.getProperty(key));

serviceProperties.setProperty(key, property);
//System.out.println("After
change: ");

//System.out.println("--------------");

//System.out.println("Property: " + property.getKey());

//System.out.println("Property Value: " + property.getValue());

//System.out.println("Property Group: " + property.getGroup());

//System.out.println("Property Description: " + property.getDescription());
}
}

// 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).trim();
}
if (key.endsWith("xmldb.db_password")) {
password =
finalProperties.getProperty(key).trim();
}
if (key.endsWith("metadata_file_path")) {
confFile =
finalProperties.getProperty(key).trim();
}
}

// Creating all necessary collections and users in
exist
if (existURI == null) {
throw new Exception("eXist xmldb URI is
empty!\n");
} else {
//System.out.println("creating eXist stuff");
//if (existURI.startsWith("xmldb:exist://"))
// existURI =
existURI.substring("xmld:exist://".length()+1, existURI.length());
if (existURI.endsWith("/db"))
existURI = existURI.substring(0,
existURI.length()-"/db".length());
//System.out.println("existURI to connect to:
" + existURI + "\nusername to use: admin\npassword to use: " + adminPass);
xmlDBManager manager = new
xmlDBManagerImpl(existURI, "admin",
adminPass);
//System.out.println("eXistManager : " +
manager);
// Creating collection and users
//manager.createCollection(dbCollection);
//System.out.println("eXist creating user
with info: " + null + ", " + username + ", " + password);
String[] groups = {"dba"};
manager.createUser(null, username, password,
groups);
//System.out.println("eXist user created");
// Adding the metadata config document
manager.getCollection(null).addDocument(new
File(confFile),
username);
//System.out.println("eXist metadata added");
// Modifying the admin user password
if (newAdminPass != null){
manager.modifyUser("admin",
newAdminPass, null, null);
//System.out.println("eXist admin
password changed");
}

serviceProperties.storeProperties(new
FileOutputStream(ServicePath
+ ServicePropertiesPath));

properties.storeToXML(new
FileOutputStream(new File(ServicePath
+ WizardPropertiesPath)), "
Last Modification "
+
Calendar.getInstance().getTime().toString());
//System.out.println("eXist xml stored");
}
} catch (Exception e) {
e.printStackTrace();
}

}*/

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

// Changes happen into the service.property file that uses
groupig and
// description in order to keep that functionality we need in
this case
// to use the PerfsonarProperties class
PerfsonarProperties serviceProperties = new
PerfsonarPropertiesImpl();
serviceProperties.loadProperties(new
FileInputStream(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.getKeysIterator();
// 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;
String old_adminPass = null;
String old_adminPass1 = null;
String new_adminPassConfirm = null;
String createUser = null;
String changePass = 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_uri")) {
existURI = finalProperties.getProperty(key);
}

}

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
PerfsonarProperty property = new PerfsonarProperty();

if (!key.endsWith("xmldb.db_uri")) {

if (key.equals("create_user")) {

createUser =
finalProperties.getProperty(key).trim();

}

else if (key.equals("old_adminpassword_1")) {

old_adminPass1 =
finalProperties.getProperty(key).trim();

}

else if (key.equals("change_admin_pass")) {

changePass =
finalProperties.getProperty(key).trim();

} else if
(key.endsWith("xmldb.db_adminpassword_confirm")) {

new_adminPassConfirm =
finalProperties.getProperty(key)
.trim();

} else if (key.equals("old_adminpassword")) {

old_adminPass =
finalProperties.getProperty(key).trim();

} else {

property =
serviceProperties.getProperty(key);
// If property key does not exist
throw an exceptrion
if (property == null) {
throw new Exception("Key is
invalid " + key + " ");
} else {

if(!key.endsWith("xmldb.db_adminpassword")||(finalProperties.getProperty("change_admin_pass").equals("yes"))){

property.setValue(finalProperties.getProperty(key));

serviceProperties.setProperty(key, property);
}
}
}
} else {

property = serviceProperties.getProperty(key);
property.setValue(existURI);
serviceProperties.setProperty(key, property);

}
// 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).trim();
}
if (key.endsWith("xmldb.db_password")) {
password =
finalProperties.getProperty(key).trim();
}
if (key.endsWith("xmldb.metadata_file_path")) {
confFile =
finalProperties.getProperty(key).trim();
}
if (key.endsWith("xmldb.db_adminpassword")) {

newAdminPass =
finalProperties.getProperty(key).trim();
}

}

// If admin pass is not set than its considered to be empty
if (adminPass == null) {
adminPass = "";
}

// Creating all necessary collections and users in exist
if (existURI == null) {
throw new Exception("eXist xmldb URI is empty!\n");
} else {

if (createUser.equals("yes")) {

xmlDBManager manager = new
xmlDBManagerImpl(existURI, "admin",
old_adminPass1);
// Creating collection and users
//manager.createCollection(dbCollection); //
we do not use a collection
String[] groups = {"dba"};
manager.createUser(null, username, password,
groups);
// Adding the metadata config document
manager.getCollection(null).addDocument(
new File(confFile), username);
} else {
xmlDBManager manager = new
xmlDBManagerImpl(existURI, username,
password);
// Creating collection and users
//manager.createCollection(dbCollection); //
we do not use a collection
// Adding the metadata config document
manager.getCollection(null).addDocument(
new File(confFile), username);
}
// Modifying the admin user password
if (changePass.equals("yes")) {
if
(newAdminPass.equals(new_adminPassConfirm)) {

xmlDBManager manager = new
xmlDBManagerImpl(existURI,
"admin",
old_adminPass);
manager.modifyUser("admin",
newAdminPass, null, null);

} else {
throw new Exception(
"New eXist Admin
passwords don't match.Please re-enter passwords.");
}
}
serviceProperties.storeProperties(new
FileOutputStream(ServicePath
+ ServicePropertiesPath));
properties.storeToXML(new FileOutputStream(new
File(ServicePath
+ WizardPropertiesPath)), " Last
Modification "
+
Calendar.getInstance().getTime().toString());
}

}

/**
* Method used for adding registration componenets to the
* componenets.properties file
*
* @throws IOException
*/
private void addRegistrationComponents() throws IOException {
File comp = new File(ServicePath + ComponentsPropertiesPath);
FileReader fr = new FileReader(comp);
StringBuffer contents = new StringBuffer();
BufferedReader br = new BufferedReader(fr);
String line = "";
while (line != null) {
if (line.startsWith("#scheduler")) {
line = line.substring(1);
}
if (line.startsWith("#registrator")) {
line = line.substring(1);
}
contents.append(line + "\n");
line = br.readLine();
}

FileWriter fw = new FileWriter(comp);
BufferedWriter bw = new BufferedWriter(fw);
bw.write(contents.toString().trim());
bw.close();
fw.close();
br.close();
fr.close();
}

/**
* Method for removing ls registration components from
components.properties
* file
*
* @throws IOException
*/
private void removeRegistrationComponents() throws IOException {
File comp = new File(ServicePath + ComponentsPropertiesPath);
FileReader fr = new FileReader(comp);
StringBuffer contents = new StringBuffer();
BufferedReader br = new BufferedReader(fr);
String line = "";
while (line != null) {
if (line.startsWith("scheduler")) {
line = "#" + line;
}
if (line.startsWith("registrator")) {
line = "#" + line;
}
contents.append(line + "\n");
line = br.readLine();
}

FileWriter fw = new FileWriter(comp);
BufferedWriter bw = new BufferedWriter(fw);
bw.write(contents.toString().trim());
bw.close();
fw.close();
br.close();
fr.close();
}

/**
* 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
* 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;
}

}

#Changed at Wed Jan 30 11:12:44 CET 2008
#Wed Jan 30 11:12:44 CET 2008

# Group=Servlet
# Description=Type of service
servlet.service_type=sshtelnetmp

# Group=Wizard
# Description=The class for handling the wizard for the SSHTELNET MP
servlet.wizard.external_handler=org.perfsonar.service.measurementPoint.webAdmin.SSHTelnetHandler

# Group=Servlet
# Description=The property in the service.properties file responsible for
holding the admin password for the eXist database
servlet.exist_adminpass.property=component.mp.xmldb.db_adminpassword

# Group=Servlet
# Description=The username for the servlet
servlet.username=perfsonaruser

# Group=Servlet
# Description=The password for the servlet
servlet.password=perfsonarpass

# Group=Servlet
# Description=The property in the service.properties file responsible for
holding the location of the eXist database
servlet.exist_location.property=component.mp.xmldb.db_uri

# Group=Servlet
# Description=Controls the use of advanced features in the properties
management servlet. Default value is “off”
servlet.extra_functionalities=off

JPEG image



  • WebAdmin layout problem, Stijn Melis, 09/08/2008

Archive powered by MHonArc 2.6.16.

Top of Page