perfsonar-dev - perfsonar: r3343 - in branches/WebAdmin: . perfSONARWebAdmin/admin/service perfSONARWebAdmin/admin/sqlma perfSONARWebAdmin/admin/wizard/services perfSONARWebAdmin/auxiliary/sql perfSONARWebAdmin/auxiliary/sqlma perfSONARWebAdmin/auxiliary/wizard
Subject: perfsonar development work
List archive
perfsonar: r3343 - in branches/WebAdmin: . perfSONARWebAdmin/admin/service perfSONARWebAdmin/admin/sqlma perfSONARWebAdmin/admin/wizard/services perfSONARWebAdmin/auxiliary/sql perfSONARWebAdmin/auxiliary/sqlma perfSONARWebAdmin/auxiliary/wizard
Chronological Thread
- From:
- To:
- Subject: perfsonar: r3343 - in branches/WebAdmin: . perfSONARWebAdmin/admin/service perfSONARWebAdmin/admin/sqlma perfSONARWebAdmin/admin/wizard/services perfSONARWebAdmin/auxiliary/sql perfSONARWebAdmin/auxiliary/sqlma perfSONARWebAdmin/auxiliary/wizard
- Date: Tue, 12 Feb 2008 07:13:16 -0500
Author: michalis
Date: 2008-02-12 07:13:16 -0500 (Tue, 12 Feb 2008)
New Revision: 3343
Added:
branches/WebAdmin/sqlma_admin_script.js
Modified:
branches/WebAdmin/default.css
branches/WebAdmin/perfSONARWebAdmin/admin/service/Admin.java
branches/WebAdmin/perfSONARWebAdmin/admin/sqlma/SQLMAdmin.java
branches/WebAdmin/perfSONARWebAdmin/admin/wizard/services/RRDMAHandler.java
branches/WebAdmin/perfSONARWebAdmin/auxiliary/sql/SQLDBManager.java
branches/WebAdmin/perfSONARWebAdmin/auxiliary/sqlma/HTMLOutput.java
branches/WebAdmin/perfSONARWebAdmin/auxiliary/sqlma/IbatisConf.java
branches/WebAdmin/perfSONARWebAdmin/auxiliary/sqlma/ibatisFileManager.java
branches/WebAdmin/perfSONARWebAdmin/auxiliary/wizard/HTMLOutput.java
Log:
Committing latest code changes. SQLMA admin now ready.
Modified: branches/WebAdmin/default.css
===================================================================
--- branches/WebAdmin/default.css 2008-02-12 09:10:22 UTC (rev 3342)
+++ branches/WebAdmin/default.css 2008-02-12 12:13:16 UTC (rev 3343)
@@ -1,162 +1,171 @@
/* standard elements */
+html {
+ min-height: 100%;
+}
-html {min-height: 100%;}
-
-
* {
- margin: 0;
- padding: 0;
+ margin: 0;
+ padding: 0;
}
-
-body{
- background-color: #ffffff;
- font-family: arial;
+body {
+ background-color: #ffffff;
+ font-family: arial;
}
-
-
/* title */
-
.top {
- display: block;
- font-family: arial;
- font-weight: bold;
- margin: 2% 1% 0 1%;
- border-top: 1px solid green;
- border-right: 1px solid green;
- border-left: 1px solid green;
- padding: 7px;
- background: #afdfc0;
+ display: block;
+ font-family: arial;
+ font-weight: bold;
+ margin: 2% 1% 0 1%;
+ border-top: 1px solid green;
+ border-right: 1px solid green;
+ border-left: 1px solid green;
+ padding: 7px;
+ background: #afdfc0;
}
-.properties{
-
+.properties {
font-family: arial;
- border: 1px solid green;
- padding: 10px;
- margin: 0% 1% 0 1%;
+ border: 1px solid green;
+ padding: 10px;
+ margin: 0% 1% 0 1%;
}
- .properties p{
+
+.properties p {
font-size: 120%;
-
}
-.properties table{
- border-bottom: 1px solid green;
- margin-bottom: 20px;
+.properties table {
+ border-bottom: 1px solid green;
+ margin-bottom: 20px;
}
-.properties td{
- padding: 15px;
+.properties td {
+ padding: 15px;
}
-.properties em{
- display: block;
- color: red;
- font-size: 95%;
+.properties em {
+ display: block;
+ color: red;
+ font-size: 95%;
}
.info {
+ font-family: arial;
+ font-size: 120%;
+}
- font-family: arial;
- font-size: 120%;
+.info p {
+ position: relative;
+ left: -230px;
}
-.info p{
- position: relative;
- left: -230px;
+.tablessContent {
+ margin: 2% 1% 0 1%;
+ background: #ffffff;
+ border-top: 1px solid green;
+ border-left: 1px solid green;
+ border-right: 1px solid green;
}
-.content{
- font-family: arial;
- font-size: 120%;
- margin:2% 1% 0 1%;
- background: #ffffff;
- }
-
+.content {
+ font-family: arial;
+ font-size: 120%;
+ margin: 2% 1% 0 1%;
+ background: #ffffff;
+}
+
.content ul {
- margin-top: 5px;
- display: block;
- list-style: none outside;
- padding: 5px;
- border-top: 1px solid green;
- border-left: 1px solid green;
- border-right: 1px solid green;
- }
-
+ margin-top: 5px;
+ display: block;
+ list-style: none outside;
+ padding: 5px;
+ border-top: 1px solid green;
+ border-left: 1px solid green;
+ border-right: 1px solid green;
+}
+
.content li {
- margin: 0 0 0 0;
- padding: 0px;
- display: block;
- float: left;
- position: relative;
- top: -1.32em;
- }
-
+ margin: 0 0 0 0;
+ padding: 0px;
+ display: block;
+ float: left;
+ position: relative;
+ top: -1.32em;
+}
+
.content a {
- padding: 5px;
- text-decoration: none;
- color: green;
- background: #ffffff;
- }
-
+ padding: 5px;
+ text-decoration: none;
+ color: green;
+ background: #ffffff;
+}
+
.content a:hover {
- background: #3CB371;
- color: green;
- }
-
+ background: #3CB371;
+ color: green;
+}
+
.content #selected {
- }
-
+}
+
.content #selected a {
-
- font-weight: bold;
- color: green;
- background: #3CB3A1;
- }
-
+ font-weight: bold;
+ color: green;
+ background: #3CB3A1;
+}
+
.manage {
+ background: #ffffff;
+ border-bottom: 1px solid green;
+ border-left: 1px solid green;
+ border-right: 1px solid green;
+ margin: 0 1% 0 1%;
+ padding: 1em;
+}
- background: #ffffff;
- border-bottom: 1px solid green;
- border-left: 1px solid green;
- border-right: 1px solid green;
- margin:0 1% 0 1%;
- padding: 1em;
- }
+.manage table {
+ padding: 5px;
+}
-.showResource{
- font-weight: bold;
- text-indent: 0%;
- text-align:inherit;
- background: #ffffff;
-
+.manage td {
+ padding: 5px;
}
-.showResource td{
- padding: 7px;
-
+.manage th {
+ padding: 5px;
+ text-align: left;
}
-.input {
- padding: 1em;
- font-size: 110%;
- font-family: arial;
+.showResource {
+ font-weight: bold;
+ text-indent: 0%;
+ text-align: inherit;
+ background: #ffffff;
+}
+.showResource td {
+ padding: 7px;
}
-.input table{
- padding: 5px;
+.input {
+ padding: 1em;
+ font-size: 110%;
+ font-family: arial;
+}
+.input table {
+ padding: 5px;
}
-.input td{
- padding: 5px;
+
+.input td {
+ padding: 5px;
}
-.input th{
- padding: 5px;
- text-align: left;
-
+.input th {
+ padding: 5px;
+ text-align: left;
}
Modified: branches/WebAdmin/perfSONARWebAdmin/admin/service/Admin.java
===================================================================
--- branches/WebAdmin/perfSONARWebAdmin/admin/service/Admin.java
2008-02-12 09:10:22 UTC (rev 3342)
+++ branches/WebAdmin/perfSONARWebAdmin/admin/service/Admin.java
2008-02-12 12:13:16 UTC (rev 3343)
@@ -47,6 +47,8 @@
// Path to service installation directory
private static String servicePath = null;
+
+ private static String extraFunctionalities="off";
//
-----------------------------------------------------------------------
// public methods
@@ -108,6 +110,14 @@
// Loading the servlet properties
ServletProperties servletProperties = new
ServletPropertiesImpl(
servicePath + ServletPropertiesPath);
+ String
extra=servletProperties.getProperties().getProperty("servlet.extra_functionalities");
+ if(extra!=null){
+ if(extra.equals("off")){
+ extraFunctionalities="off";
+ }else{
+ extraFunctionalities="on";
+ }
+ }
Authenticator authenticator = new
AuthenticatorImpl(servletProperties);
String lock = "disabled";
String filePath = "";
@@ -409,8 +419,9 @@
out.println("<input type=\"reset\" value=\"Cancel\"
/> ");
}
out.println("</p>");
- if (lock.equals("enabled")) {
+ if
(lock.equals("enabled")&&extraFunctionalities.equals("on")) {
// Options foa adding and deleting a property are
added
+
out.println("<form action=\"ServiceAdmin\"
method=\"POST\"> ");
out
.println("<p>Add new property name to
the left column and the property value to the right column.</p>");
Modified: branches/WebAdmin/perfSONARWebAdmin/admin/sqlma/SQLMAdmin.java
===================================================================
--- branches/WebAdmin/perfSONARWebAdmin/admin/sqlma/SQLMAdmin.java
2008-02-12 09:10:22 UTC (rev 3342)
+++ branches/WebAdmin/perfSONARWebAdmin/admin/sqlma/SQLMAdmin.java
2008-02-12 12:13:16 UTC (rev 3343)
@@ -115,7 +115,17 @@
String function = request.getParameter("Execute");
if (function != null) {
if (function.equals("Delete File")) {
- deleteActions(request);
+ try {
+ deleteActions(request);
+ output
+ .infoPage(
+ "SQL
MA administration page.",
+
"Finished deleting ibatis files <a href=\"SQLMAdmin\">Back</a>.",
+
"manage");
+ } catch (Exception e) {
+ output.infoPage("SQL MA
administration page.", "Error!\n"
+ + getFault(e),
"manage");
+ }
} else if (function.equals("Edit File")) {
String ibatisFile =
request.getParameter("ibatisFile");
try {
@@ -137,51 +147,84 @@
}
else if (function.equals("Create")) {
- createActions(request);
- } else {
try {
- output.mainPage("SQL MA configuration
page!", manager
- .getIbatisFiles(),
type, null, null);
+ createActions(request);
} catch (Exception e) {
- throw new
ServletException(getFault(e));
+
+ output.infoPage("SQL MA
administration page.", "Error!\n"
+ + getFault(e),
"manage");
}
- }
- } else if (function.equals("Initialize")) {
+ } else if (function.equals("Initialize")) {
- String ibatisFile =
request.getParameter("ibatisFile").trim();
- String action = request.getParameter("action").trim();
- String initDatabase =
request.getParameter("createDatabase").trim();
- String initUser =
request.getParameter("createUser").trim();
- String initTable =
request.getParameter("createTable").trim();
- String password =
request.getParameter("rtPass").trim();
+ String ibatisFile =
request.getParameter("ibatisFile");
+ String action =
request.getParameter("action");
+ String initDatabase =
request.getParameter("createDatabase");
+ String initUser =
request.getParameter("createUser");
+ String initTable =
request.getParameter("createTable");
+ String password =
request.getParameter("rtPass");
- try {
- initDB(ibatisFile, action, initDatabase,
initUser, initTable,
- password);
- } catch (Exception e) {
+ if (ibatisFile != null) {
+ ibatisFile = ibatisFile.trim();
+ }
- output.infoPage("SQL MA administration
page.", "Error!\n"
- + getFault(e), "manage");
- }
- } else if (function.equals("No")) {
- String ibatisFile =
request.getParameter("ibatisFile");
- String action = request.getParameter("action");
- if (action.equals("edit"))
+ if (action != null) {
+ action = action.trim();
+ }
+
+ if (password != null) {
+ password = password.trim();
+ }
+
try {
- if (deleteOldFiles(ibatisFile))
- output.infoPage("SQL MA
administration page.",
- "Finished
configuring ibatis files", "manage");
- else
- output
- .infoPage(
-
"SQL MA administration page.",
-
"Problem encountered while finishing configuration of ibatis files",
-
"manage");
+ initDB(ibatisFile, action,
initDatabase, initUser,
+ initTable, password);
+ output
+ .infoPage(
+ "SQL
MA administration page.",
+
"Finished configuring ibatis files <a href=\"SQLMAdmin\">Back</a>.",
+
"manage");
} catch (Exception e) {
+
output.infoPage("SQL MA
administration page.", "Error!\n"
+ getFault(e),
"manage");
+ }
+ } else if (function.equals("No")) {
+ String ibatisFile =
request.getParameter("ibatisFile");
+ String action =
request.getParameter("action");
+ if (action.equals("edit")) {
+ try {
+ if
(deleteOldFiles(ibatisFile))
+ output
+
.infoPage(
+
"SQL MA administration page.",
+
"Finished configuring ibatis files <a href=\"SQLMAdmin\">Back</a>.",
+
"manage");
+ else
+ output
+
.infoPage(
+
"SQL MA administration page.",
+
"Problem encountered while finishing configuration of ibatis files",
+
"manage");
+ } catch (Exception e) {
+ output.infoPage("SQL MA
administration page.",
+ "Error!\n" +
getFault(e), "manage");
+ }
+ } else if (action.equals("create")) {
+ output
+ .infoPage(
+ "SQL
MA administration page.",
+
"Finished configuring ibatis files <a href=\"SQLMAdmin\">Back</a>.",
+
"manage");
}
+ } else {
+ try {
+ output.mainPage("SQL MA configuration
page!", manager
+ .getIbatisFiles(),
type, null, null);
+ } catch (Exception e) {
+ throw new
ServletException(getFault(e));
+ }
+ }
} else {
try {
output.mainPage("SQL MA configuration page!",
manager
@@ -190,6 +233,7 @@
throw new ServletException(getFault(e));
}
}
+
}
//
-----------------------------------------------------------------------
@@ -197,10 +241,23 @@
/**
* @param request
+ * @throws Exception
*/
- private void deleteActions(HttpServletRequest request) {
- // TODO Auto-generated method stub
+ private void deleteActions(HttpServletRequest request) throws
Exception {
+ String ibatisFile = request.getParameter("ibatisFile").trim();
+ String deleteData = request.getParameter("deleteData");
+ ibatisFileManager manager = new ibatisFileManager(ServicePath
+ + ibatisFilesPath);
+ if (deleteData != null) {
+ String[] properties =
manager.getIbatisFileProperties(ibatisFile);
+ SQLDBManager managerDB = new
SQLDBManager(properties[7],
+ properties[5]);
+ managerDB.deleteData(properties[2], properties[4],
properties[3],
+ properties[5]);
+ }
+ manager.deleteFiles(ibatisFile);
+
}
/**
@@ -213,8 +270,8 @@
String ibatisFile = request.getParameter("ibatisFile").trim();
String databaseURL =
request.getParameter("dataBaseURL").trim();
String databaseName =
request.getParameter("databaseName").trim();
- String username = request.getParameter("username").trim();
- String password = request.getParameter("password").trim();
+ String username = request.getParameter("userName").trim();
+ String password = request.getParameter("userPassword").trim();
String tableName = request.getParameter("tableName").trim();
String metric = request.getParameter("metric");
String mapFile = request.getParameter("mapFile");
@@ -234,10 +291,31 @@
/**
* @param request
+ * @throws Exception
*/
- private void createActions(HttpServletRequest request) {
- // TODO Auto-generated method stub
+ private void createActions(HttpServletRequest request) throws
Exception {
+ String ibatisFile = request.getParameter("fileName").trim();
+ String databaseURL =
request.getParameter("dataBaseURL").trim();
+ String databaseName =
request.getParameter("databaseName").trim();
+ String username = request.getParameter("userName").trim();
+ String password = request.getParameter("userPassword").trim();
+ String tableName = request.getParameter("tableName").trim();
+ String metric = request.getParameter("metricType").trim();
+
+ ibatisFileManager manager = new ibatisFileManager(ServicePath
+ + ibatisFilesPath);
+ String mapFile = "ibatis-" + ibatisFile + ".xml";
+ ibatisFile = "ibatis-SqlMapConfig-" + ibatisFile + ".xml";
+ if (manager.createIbatisFile(ibatisFile, databaseURL + "/"
+ + databaseName, username, password,
tableName, metric, mapFile)) {
+
+ output
+ .confirmPage(
+ "ibatis file has been
created succesfull. Would you like to initialize/modify the sql database",
+ "create", ibatisFile);
+ }
+
}
/**
@@ -252,6 +330,16 @@
}
+ /**
+ * @param ibatisFile
+ * @param action
+ * @param initDatabase
+ * @param initUser
+ * @param initTable
+ * @param rootPass
+ * @return
+ * @throws Exception
+ */
private boolean initDB(String ibatisFile, String action,
String initDatabase, String initUser, String
initTable,
String rootPass) throws Exception {
@@ -260,37 +348,79 @@
+ ibatisFilesPath);
String[] properties =
manager.getIbatisFileProperties(ibatisFile);
- String[] propertiesOld =
manager.getIbatisFileProperties(ibatisFile
- + ".old");
+ String[] propertiesOld = null;
+ if (action.equals("edit")) {
+ propertiesOld = manager
+ .getIbatisFileProperties(ibatisFile +
".old");
+ }
+
SQLDBManager managerDB = new SQLDBManager(properties[7],
rootPass);
managerDB.setDBURL(properties[1] + "/");
boolean createDB = false;
- if (initDatabase != null &&
(!properties[1].equals(propertiesOld[1]))
- && (!properties[2].equals(propertiesOld))) {
- managerDB.createDatabase(properties[1]);
- createDB = true;
- } else {
- if ((properties[1].equals(propertiesOld[1]))
- &&
(properties[2].equals(propertiesOld))) {
+ if (initDatabase != null) {
+ if (action.equals("edit")) {
+ if
((!properties[1].equals(propertiesOld[1]))) {
+
+
managerDB.createDatabase(properties[2]);
+ createDB = true;
+
+ } else {
+ if
(!properties[2].equals(propertiesOld[2])) {
+
managerDB.createDatabase(properties[2]);
+ createDB = true;
+
+ } else {
+ createDB = true;
+ }
+ }
+ } else if (action.equals("create")) {
+
+ managerDB.createDatabase(properties[2]);
createDB = true;
}
+
+ } else {
+ createDB = true;
}
+
boolean createUser = false;
- if (initUser != null) {
+ if (initUser != null && createDB) {
managerDB.createUser(properties[3], "%",
properties[5]);
+ managerDB.createUser(properties[3], "localhost",
properties[5]);
createUser = true;
} else {
createUser = true;
}
boolean createTable = false;
- if (initTable != null) {
- managerDB.createTable(properties[1], properties[4],
null);
+ if (initTable != null && createDB) {
+ if (properties[0].equals("L2-Path-Status Metric")) {
+
managerDB.createPerfsonarL2PathStatusMetricTable(properties[2],
+ properties[4]);
+
+ } else {
+
managerDB.createPerfsonarPacketMetricTable(properties[2],
+ properties[4]);
+ }
+ if (createUser) {
+ managerDB
+
.grantPerfsonarPrivileges(properties[2], properties[3]);
+ }
createTable = true;
} else {
createTable = true;
}
- return false;
+ if (createUser && createTable && createDB) {
+
+ if (action.equals("edit")) {
+ return manager.deleteOldFiles(ibatisFile);
+ } else {
+ return true;
+ }
+ } else {
+ return false;
+ }
+
}
/**
Modified:
branches/WebAdmin/perfSONARWebAdmin/admin/wizard/services/RRDMAHandler.java
===================================================================
---
branches/WebAdmin/perfSONARWebAdmin/admin/wizard/services/RRDMAHandler.java
2008-02-12 09:10:22 UTC (rev 3342)
+++
branches/WebAdmin/perfSONARWebAdmin/admin/wizard/services/RRDMAHandler.java
2008-02-12 12:13:16 UTC (rev 3343)
@@ -13,7 +13,6 @@
import javax.servlet.http.HttpServletRequest;
-
import perfSONARWebAdmin.auxiliary.ServiceProperties;
import perfSONARWebAdmin.auxiliary.ServicePropertiesImpl;
import perfSONARWebAdmin.auxiliary.wizard.ConfigurationHandler;
@@ -351,78 +350,72 @@
// 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);
+ // 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
+ /*
+ * 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 likes
+ */
- // 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();
- // Get the parameter
- String value =
request.getParameter(key).trim();
- // Get the property
- WizardProperty pr =
existProperties.getWizardProperty(key);
- // Set value and proposed value
- pr.setPropertyValue(value);
- pr.setProposedValue(value);
- // Set the property in the exist group
properties
- existProperties.setWizardProperty(key, pr);
- }
- // Update the exist group Property
- groupedProperties.put("eXist", existProperties);
- try {
- // Call for the needed actions for exist
configuration.The exist
- // group properties are used as input
- existActions(existProperties);
- done = true;
- } catch (Exception e) {
- // Set doen to false if anything happens
- done = false;
- throw new Exception(getFault(e));
- }
- return done;
+ /*
+ * 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();
+ // Get the parameter
+ String value = request.getParameter(key).trim();
+ // Get the property
+ WizardProperty pr =
existProperties.getWizardProperty(key);
+ // Set value and proposed value
+ pr.setPropertyValue(value);
+ pr.setProposedValue(value);
+ // Set the property in the exist group properties
+ existProperties.setWizardProperty(key, pr);
}
+ // Update the exist group Property
+ groupedProperties.put("eXist", existProperties);
+ try {
+ // Call for the needed actions for exist
configuration.The exist
+ // group properties are used as input
+ existActions(existProperties);
+ done = true;
+ } catch (Exception e) {
+ // Set doen to false if anything happens
+ done = false;
+ throw new Exception(getFault(e));
+ }
+ return done;
+ // }
}
@@ -600,7 +593,7 @@
username);
// Modifying the admin user password
manager.modifyUser("admin", newAdminPass, null, null);
-
+
serviceProperties.storeProperties();
properties.storeToXML(new FileOutputStream(new
File(ServicePath
+ WizardPropertiesPath)), " Last
Modification "
Modified: branches/WebAdmin/perfSONARWebAdmin/auxiliary/sql/SQLDBManager.java
===================================================================
--- branches/WebAdmin/perfSONARWebAdmin/auxiliary/sql/SQLDBManager.java
2008-02-12 09:10:22 UTC (rev 3342)
+++ branches/WebAdmin/perfSONARWebAdmin/auxiliary/sql/SQLDBManager.java
2008-02-12 12:13:16 UTC (rev 3343)
@@ -15,24 +15,10 @@
*
*/
public class SQLDBManager {
+
//
-----------------------------------------------------------------------
// class fields
- // The path to the conf folder
- 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 servlet.properties file
- private static final String ServletPropertiesPath = confPath
- + "servlet.properties";
-
- // The path to the folder under the webapps directory in which the
service
- // is installed
- private static String ServicePath;
-
private static String adminPassword;
private static String Driver;
@@ -43,7 +29,7 @@
private String[] privilegesAlias;
- private Hashtable privAliasTable;
+ private Hashtable<String, String> privAliasTable;
//
-----------------------------------------------------------------------
// constructors
@@ -61,13 +47,12 @@
adminPassword = password;
if (adminPassword == null)
adminPassword = "";
-
if (Driver.equals("com.mysql.jdbc.Driver")) {
DBURI = "jdbc:mysql://localhost/";
} else if (Driver.equals("org.postgresql.Driver")) {
DBURI = "jdbc:postgresql://localhost/";
} else {
- throw new Exception("Database driver is
unsupported!");
+ throw new Exception("Database driver is unsupported!
" + Driver);
}
String[] pr = { "Select_priv", "Insert_priv", "Update_priv",
"Delete_priv", "Create_priv", "Drop_priv",
"Grant_priv",
@@ -78,7 +63,7 @@
"LOCK TABLES" };
privileges = pr;
privilegesAlias = prAlias;
- privAliasTable = new Hashtable();
+ privAliasTable = new Hashtable<String, String>();
for (int i = 0; i < pr.length; i++) {
privAliasTable.put(prAlias[i], pr[i]);
}
@@ -522,6 +507,90 @@
/**
* @param database
+ * @param tableName
+ * @return
+ * @throws Exception
+ */
+ public boolean createPerfsonarPacketMetricTable(String database,
+ String tableName) throws Exception {
+
+ Class.forName(Driver);
+ Connection connnection = DriverManager.getConnection(DBURI +
database,
+ "root", adminPassword);
+ if (!connnection.isClosed()) {
+ String statement = "CREATE TABLE " + tableName
+ + "(metadataId VARCHAR(30) NOT NULL,"
+ + "value FLOAT (16,4) NOT NULL,"
+ + "valueUnits VARCHAR(30) NULL,"
+ + "timeValue INT NOT NULL," + "ts
TIMESTAMP DEFAULT NOW())";
+
+ PreparedStatement ps =
connnection.prepareStatement(statement);
+ boolean result = ps.execute();
+ connnection.close();
+ return result;
+ } else {
+ throw new Exception("Cannot connect to database!");
+ }
+ }
+
+ /**
+ * @param database
+ * @param tableName
+ * @return
+ * @throws Exception
+ */
+ public boolean createPerfsonarL2PathStatusMetricTable(String database,
+ String tableName) throws Exception {
+
+ Class.forName(Driver);
+ Connection connnection = DriverManager.getConnection(DBURI +
database,
+ "root", adminPassword);
+ if (!connnection.isClosed()) {
+ String statement = "CREATE TABLE " + tableName
+ + "(id VARCHAR(255) NOT NULL,"
+ + "time TIMESTAMP DEFAULT NOW(),"
+ + "status_oper VARCHAR(255) DEFAULT
'UNKNOWN',"
+ + "status_admin VARCHAR(255) DEFAULT
'UNKNOWN',"
+ + "alarm_id_set VARCHAR(255)," +
"comments VARCHAR(255))";
+ PreparedStatement ps =
connnection.prepareStatement(statement);
+ boolean result = ps.execute();
+ connnection.close();
+ return result;
+ } else {
+ throw new Exception("Cannot connect to database!");
+ }
+ }
+
+ /**
+ * @param database
+ * @param userName
+ * @return
+ * @throws Exception
+ */
+ public boolean grantPerfsonarPrivileges(String database, String
userName)
+ throws Exception {
+
+ Class.forName(Driver);
+ Connection connnection = DriverManager.getConnection(DBURI +
"mysql",
+ "root", adminPassword);
+ if (!connnection.isClosed()) {
+ String statement = "GRANT SELECT, INSERT, UPDATE,
DELETE ON "
+ + database + ".* TO '" + userName +
"'@'%' ";
+ PreparedStatement ps =
connnection.prepareStatement(statement);
+ ps.execute();
+ statement = "GRANT SELECT, INSERT, UPDATE, DELETE ON
" + database
+ + ".* TO '" + userName +
"'@'localhost' ";
+ ps.execute();
+ connnection.close();
+ boolean result = true;
+ return result;
+ } else {
+ throw new Exception("Cannot connect to database!");
+ }
+ }
+
+ /**
+ * @param database
* @param user
* @param file
* @return
@@ -550,12 +619,37 @@
}
}
}
-
+
/**
+ * @param database
+ * @param table
+ * @param username
+ * @param password
+ * @return
+ * @throws Exception
+ */
+ public boolean deleteData(String database, String table, String
username,
+ String password) throws Exception {
+
+ Class.forName(Driver);
+ Connection connnection = DriverManager.getConnection(DBURI +
database,
+ username, password);
+ if (!connnection.isClosed()) {
+ String statement = "DELETE FROM " + table;
+ PreparedStatement ps =
connnection.prepareStatement(statement);
+ ps.execute();
+ connnection.close();
+ return true;
+ } else {
+ throw new Exception("Cannot connect to database!");
+ }
+ }
+
+ /**
* @param DBURL
*/
- public void setDBURL(String DBURL){
- DBURI=DBURL;
+ public void setDBURL(String DBURL) {
+ DBURI = DBURL;
}
public static void main(String args[]) {
@@ -563,31 +657,28 @@
try {
Class.forName("com.mysql.jdbc.Driver");
Connection connnection = DriverManager.getConnection(
-
"jdbc:mysql://192.168.10.86:3306/perfsonar_ma", "root",
- "michael");
+
"jdbc:mysql://192.168.10.86:3306/mysql", "root", "michael");
if (!connnection.isClosed()) {
- String statement = "SHOW DATABASES";
+ String statement = "CREATE DATABASE " +
"somedb";
PreparedStatement ps =
connnection.prepareStatement(statement);
- // ps.setString(1, "robinio");
- ResultSet rs = ps.executeQuery();
- String[] description = new String[10];
- int i = 0;
- rs.last();
- String[] databases = new String[rs.getRow()];
- rs.beforeFirst();
+ boolean result = ps.execute(statement);
+ connnection.close();
+ System.out.println(result);
+ /*
+ * String statement = "SHOW DATABASES";
PreparedStatement ps =
+ * connnection.prepareStatement(statement);
// ps.setString(1,
+ * "robinio"); ResultSet rs =
ps.executeQuery();
+ * @SuppressWarnings("unused") String[]
description = new
+ * String[10]; int i = 0; rs.last(); String[]
databases = new
+ * String[rs.getRow()]; rs.beforeFirst();
+ *
+ * while (rs.next()) { i++; databases[i - 1]
= rs.getString(1);
+ * System.out.println(databases[i - 1]);// +"
//
+ * "+rs.getString(2)+" // "+rs.getString(3)+"
//
+ * "+rs.getString(4)+" // "+rs.getString(5)+"
//
+ * "+rs.getString(6)); //
users[i]=rs.getString("user"); }
+ */
- while (rs.next()) {
- i++;
- databases[i - 1] = rs.getString(1);
- System.out.println(databases[i -
1]);// +"
- // "+rs.getString(2)+"
- // "+rs.getString(3)+"
- // "+rs.getString(4)+"
- // "+rs.getString(5)+"
- // "+rs.getString(6));
- // users[i]=rs.getString("user");
- }
-
} else {
throw new Exception("Cannot connect to
database!");
}
Modified: branches/WebAdmin/perfSONARWebAdmin/auxiliary/sqlma/HTMLOutput.java
===================================================================
--- branches/WebAdmin/perfSONARWebAdmin/auxiliary/sqlma/HTMLOutput.java
2008-02-12 09:10:22 UTC (rev 3342)
+++ branches/WebAdmin/perfSONARWebAdmin/auxiliary/sqlma/HTMLOutput.java
2008-02-12 12:13:16 UTC (rev 3343)
@@ -86,7 +86,7 @@
out.println("<div id=\"Options\" >");
out.println("<br/>");
- out.println("<form action=\"SQLMAdmin\" method=\"POST\"> ");
+ out.println("<form action=\"SQLMAdmin\" method=\"POST\" > ");
out.println("<table align=\"center\">");
out.println("<tr>");
out.println("<th>Choose File:</th>");
@@ -111,7 +111,7 @@
out
.println("<input type=\"submit\"
name=\"Execute\" value=\"Edit File\" />");
out
- .println("<input type=\"submit\"
name=\"Execute\" value=\"Delete File\" />");
+ .println("<input type=\"submit\"
name=\"Execute\" value=\"Delete File\" onclick=\"return
confirmDelete(this.form)\"/>");
out
.println("<button type=\"button\"
name=\"Execute\" value=\"Create New\""
+ onClick + ">Create New
File</button>");
@@ -131,7 +131,7 @@
out.println("<input type=\"hidden\" name=\"metric\"
value=\""
+ fileProperties[0] + "\" />");
out.println("<input type=\"hidden\" name=\"mapFile\"
value=\""
- + fileProperties[5] + "\" />");
+ + fileProperties[6] + "\" />");
out.println("<table align=\"center\">");
out.println("<tr><th>File Name:</th><td>" + ibatisFile
+ "</td><td/></tr>");
@@ -169,7 +169,7 @@
.println("<form action=\"SQLMAdmin\"
method=\"POST\" onsubmit=\"return confirmForm(this)\"> ");
out.println("<table align=\"center\">");
out
- .println("<tr><th>File
Name:</th><td>ibatis-SqlMapConfig-<input type=\"text\" name=\"fileName\"
value=\"\" size=\"20\" /></td></tr>");
+ .println("<tr><th>File
Name:</th><td>ibatis-SqlMapConfig-<input type=\"text\" name=\"fileName\"
value=\"\" size=\"20\" />.xml</td></tr>");
out
.println("<tr><th>Database
URL:</th><td><input type=\"text\" name=\"dataBaseURL\" value=\"\" size=\"20\"
/></td></tr>");
out
@@ -206,20 +206,20 @@
throws IOException {
preempt("default.css", true);
- String onClick = " onclick=\"showOptions();\"";
+ String onClick = " onclick=\"showOptions()\"";
out.println("<div align=\"left\" id=\"prompt\"
class=\"manage\">");
out.println("<form action=\"SQLMAdmin\" method=\"POST\" > ");
out.println("<input type=\"hidden\" name=\"ibatisFile\"
value=\""
+ ibatisFile + "\" />");
out.println("<input type=\"hidden\" name=\"action\" value=\""
+ action
+ "\" />");
+ out.println("<p>" + message + "</p>");
out.println("<table align=\"center\">");
out
- .println("<tr><td><button type=\"submit\" "
+ .println("<tr><td><button "
+ onClick
- + " name=\"databaseAction\"
value=\"Yes\" >Yes</button></td><td><input type=\"submit\" name=\"Execute\"
value=\"No\" /></td> </tr>");
+ + " type=\"button\"
value=\"Yes\" >Yes</button></td><td><input type=\"submit\" name=\"Execute\"
value=\"No\" /></td> </tr>");
out.println("</table></form>");
- out.println("</div>");
String display = "none";
out.println("<div id=\"options\" style=\"display:" + display
+ ";\">");
@@ -232,15 +232,17 @@
+ "\" />");
out.println("<table align=\"center\">");
out
- .println("<tr><th>Choose what to
initialize</th><td>input type=\"checkbox\" name=\"createDatabase\"
value=\"Yes\" />Create Database</td></tr>");
+ .println("<tr><th>Choose what to initialize:
</th><td><input type=\"checkbox\" name=\"createDatabase\" value=\"Yes\"
/>Create Database</td></tr>");
out
- .println("<tr><th.><td><input
type=\"checkbox\" name=\"createUser\" value=\"Yes\" />Create User</td></tr>");
+ .println("<tr><th/><td><input
type=\"checkbox\" name=\"createUser\" value=\"Yes\" />Create User</td></tr>");
out
.println("<tr><th/><td><input
type=\"checkbox\" name=\"createTable\" value=\"Yes\"/>Initialize Table</tr>");
out
.println("<tr><td><input type=\"submit\"
name=\"Execute\" value=\"Initialize\" /></td><td/></tr>");
out.println("</table></form>");
out.println("</div>");
+
+ out.println("</div>");
out.println("</body>");
out.println("</html>");
out.close();
@@ -270,8 +272,8 @@
out.println("</head>");
out.println("<body>");
out.println(getScript());
- out.println("<div class=\"content\" >");
- out.println("</p>");
+ out.println("<div class=\"tablessContent\" >");
+ out.println("<br/><p> </p>");
out.println("</div>");
}
Modified: branches/WebAdmin/perfSONARWebAdmin/auxiliary/sqlma/IbatisConf.java
===================================================================
--- branches/WebAdmin/perfSONARWebAdmin/auxiliary/sqlma/IbatisConf.java
2008-02-12 09:10:22 UTC (rev 3342)
+++ branches/WebAdmin/perfSONARWebAdmin/auxiliary/sqlma/IbatisConf.java
2008-02-12 12:13:16 UTC (rev 3343)
@@ -4,6 +4,7 @@
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
+import java.util.Calendar;
/**
* @author Michalis Michael
@@ -33,7 +34,7 @@
"<!-- $Id: "
+ fileName
- + ".xml 2566 2007-07-24 11:50:27Z roman $
-->\n"
+ + "
"+(Calendar.getInstance().getTime().toString())+" -->\n"
+
"<sqlMap namespace=\"Results\">\n"
@@ -139,7 +140,7 @@
"<!-- $Id: "
+ fileName
- + ".xml $ -->\n"
+ + "
"+(Calendar.getInstance().getTime().toString())+" -->\n"
+
"<sqlMap namespace=\"Results\">\n\n"
@@ -228,7 +229,8 @@
+ "PUBLIC \"-//iBATIS.com//DTD SQL Map Config
2.0//EN\"\n"
+
"\"http://www.ibatis.com/dtd/sql-map-config-2.dtd\">\n\n" +
- "<!-- $Id$ -->\n"
+ "<!-- $Id: " + fileName
+ + "
"+(Calendar.getInstance().getTime().toString())+" -->\n"
+ "<sqlMapConfig>\n\n" +
"<settings useStatementNamespaces=\"false\"
/>\n\n" +
Modified:
branches/WebAdmin/perfSONARWebAdmin/auxiliary/sqlma/ibatisFileManager.java
===================================================================
---
branches/WebAdmin/perfSONARWebAdmin/auxiliary/sqlma/ibatisFileManager.java
2008-02-12 09:10:22 UTC (rev 3342)
+++
branches/WebAdmin/perfSONARWebAdmin/auxiliary/sqlma/ibatisFileManager.java
2008-02-12 12:13:16 UTC (rev 3343)
@@ -90,18 +90,29 @@
String[] str = url.split("/");
String database = str[str.length - 1];
url = str[0] + "/" + str[1] + "/" + str[2];
- properties[0] = getType(mapFile);
- properties[1] = url;
- properties[2] = database;
- properties[3] = username;
- properties[4] = getTable(mapFile);
- properties[5] = password;
- properties[6] = sqlMapFile;
- properties[7] = driver;
+ properties[0] = getType(mapFile).trim();
+ properties[1] = url.trim();
+ properties[2] = database.trim();
+ properties[3] = username.trim();
+ properties[4] = getTable(mapFile).trim();
+ properties[5] = password.trim();
+ properties[6] = sqlMapFile.trim();
+ properties[7] = driver.trim();
return properties;
}
+ /**
+ * @param ibatisFile
+ * @param databaseURL
+ * @param username
+ * @param password
+ * @param tableName
+ * @param metric
+ * @param mapFile
+ * @return
+ * @throws Exception
+ */
public boolean modifyIbatisFile(String ibatisFile, String databaseURL,
String username, String password, String tableName,
String metric,
String mapFile) throws Exception {
@@ -121,7 +132,7 @@
driver = "com.mysql.jdbc.Driver";
}
String newIbatisFileContents =
conf.createIbatisConfigFile(mapFile,
- "", databaseURL, username, password,
ibatisFile);
+ driver, databaseURL, username,
password, ibatisFile);
String sqlMapFileContents = "";
if (metric.equals("L2-Path-Status Metric")) {
sqlMapFileContents =
conf.createIbatisFileL2PathStatus(
@@ -135,22 +146,79 @@
FileWriter fw = new FileWriter(newIbatisFile, true);
BufferedWriter bw = new BufferedWriter(fw);
bw.write(newIbatisFileContents);
+ bw.close();
fw.close();
- fw = new FileWriter(newMapFile, true);
- bw = new BufferedWriter(fw);
- bw.write(sqlMapFileContents);
- bw.close();
- fw.close();
+ FileWriter fw2 = new FileWriter(newMapFile, true);
+ BufferedWriter bw2 = new BufferedWriter(fw2);
+ bw2.write(sqlMapFileContents);
+ bw2.close();
+ fw2.close();
return true;
} else {
throw new Exception(
- "Error while modifying file, old file
cannot be renamed!");
+ "Error while modifying file, old file
cannot be renamed!"
+ + ibatisDirectory +
"/" + ibatisFile + " "
+ + ibatisDirectory +
"/" + mapFile);
}
}
+ /**
+ * @param ibatisFile
+ * @param databaseURL
+ * @param username
+ * @param password
+ * @param tableName
+ * @param metric
+ * @param mapFile
+ * @return
+ * @throws Exception
+ */
+ public boolean createIbatisFile(String ibatisFile, String databaseURL,
+ String username, String password, String tableName,
String metric,
+ String mapFile) throws Exception {
+
+ IbatisConf conf = new IbatisConf();
+
+ @SuppressWarnings("unused")
+ String driver = "com.mysql.jdbc.Driver";
+ if (databaseURL.startsWith("jdbc:mysql")) {
+ driver = "com.mysql.jdbc.Driver";
+ }
+ String newIbatisFileContents =
conf.createIbatisConfigFile(mapFile,
+ driver, databaseURL, username, password,
ibatisFile);
+ String sqlMapFileContents = "";
+ if (metric.equals("L2-Path-Status Metric")) {
+ sqlMapFileContents =
conf.createIbatisFileL2PathStatus(tableName,
+ mapFile);
+ } else {
+ sqlMapFileContents =
conf.createIbatisFilePacketMetric(tableName,
+ mapFile);
+ }
+ File newIbatisFile = new File(ibatisDirectory + "/" +
ibatisFile);
+ File newMapFile = new File(ibatisDirectory + "/" + mapFile);
+ FileWriter fw = new FileWriter(newIbatisFile, true);
+ BufferedWriter bw = new BufferedWriter(fw);
+ bw.write(newIbatisFileContents);
+ bw.close();
+ fw.close();
+
+ FileWriter fw2 = new FileWriter(newMapFile, true);
+ BufferedWriter bw2 = new BufferedWriter(fw2);
+ bw2.write(sqlMapFileContents);
+ bw2.close();
+ fw2.close();
+ return true;
+
+ }
+
+ /**
+ * @param ibatisFile
+ * @return
+ * @throws Exception
+ */
public boolean deleteOldFiles(String ibatisFile) throws Exception {
File file = new File(ibatisDirectory + "/" + ibatisFile +
".old");
@@ -168,6 +236,31 @@
}
}
+ /**
+ * @param ibatisFile
+ * @return
+ * @throws Exception
+ */
+ public boolean deleteFiles(String ibatisFile) throws Exception {
+
+ File file = new File(ibatisDirectory + "/" + ibatisFile);
+ String mapFile =
ibatisFile.substring("ibatis-SqlMapConfig-".length());
+ mapFile = "ibatis-" + mapFile;
+ File file2 = new File(ibatisDirectory + "/" + mapFile);
+ if (file.exists() && file2.exists()) {
+ if (file.canWrite() && file2.canWrite()) {
+ return (file.delete() && file2.delete());
+ } else {
+ throw new Exception(
+ "Selected ibatis files are
write protected. "
+ + ibatisFile);
+ }
+ } else {
+ throw new Exception("Selected ibatis files do not
exist. "
+ + ibatisFile);
+ }
+ }
+
//
-----------------------------------------------------------------------
// private methods
@@ -247,6 +340,7 @@
System.out.println(pr[i]);
}
}
+
/*
* file = new File("C:/Documents and Settings/IBM/My
* Documents/ibatis"); File[] f=file.listFiles();
for(int i=0;i<f.length;i++){
Modified: branches/WebAdmin/perfSONARWebAdmin/auxiliary/wizard/HTMLOutput.java
===================================================================
--- branches/WebAdmin/perfSONARWebAdmin/auxiliary/wizard/HTMLOutput.java
2008-02-12 09:10:22 UTC (rev 3342)
+++ branches/WebAdmin/perfSONARWebAdmin/auxiliary/wizard/HTMLOutput.java
2008-02-12 12:13:16 UTC (rev 3343)
@@ -253,10 +253,10 @@
out
.println("<tr><td>Do
you wish to register to an LS?</td><td>");
out
- .println("<input
type=\"radio\" checked name=\"useLS\" value=\"yes\" "
+ .println("<input
type=\"radio\" name=\"useLS\" value=\"yes\" "
+
onClick + ">yes</input>");
out
- .println("<input
type=\"radio\" name=\"useLS\" value=\"no\" "
+ .println("<input
type=\"radio\" checked name=\"useLS\" value=\"no\" "
+
onClick + ">no</input>");
out.println("</td></tr>");
Added: branches/WebAdmin/sqlma_admin_script.js
- perfsonar: r3343 - in branches/WebAdmin: . perfSONARWebAdmin/admin/service perfSONARWebAdmin/admin/sqlma perfSONARWebAdmin/admin/wizard/services perfSONARWebAdmin/auxiliary/sql perfSONARWebAdmin/auxiliary/sqlma perfSONARWebAdmin/auxiliary/wizard, svnlog, 02/12/2008
Archive powered by MHonArc 2.6.16.