Skip to Content.
Sympa Menu

perfsonar-dev - perfsonar: r4321 - in branches/WebAdmin: . perfSONARWebAdmin/admin/sqlma perfSONARWebAdmin/admin/stitching perfSONARWebAdmin/admin/wizard/services perfSONARWebAdmin/auxiliary/sql perfSONARWebAdmin/auxiliary/sqlma perfSONARWebAdmin/auxiliary/stitching perfSONARWebAdmin/auxiliary/wizard

Subject: perfsonar development work

List archive

perfsonar: r4321 - in branches/WebAdmin: . perfSONARWebAdmin/admin/sqlma perfSONARWebAdmin/admin/stitching perfSONARWebAdmin/admin/wizard/services perfSONARWebAdmin/auxiliary/sql perfSONARWebAdmin/auxiliary/sqlma perfSONARWebAdmin/auxiliary/stitching perfSONARWebAdmin/auxiliary/wizard


Chronological Thread 
  • From:
  • To:
  • Subject: perfsonar: r4321 - in branches/WebAdmin: . perfSONARWebAdmin/admin/sqlma perfSONARWebAdmin/admin/stitching perfSONARWebAdmin/admin/wizard/services perfSONARWebAdmin/auxiliary/sql perfSONARWebAdmin/auxiliary/sqlma perfSONARWebAdmin/auxiliary/stitching perfSONARWebAdmin/auxiliary/wizard
  • Date: Fri, 1 Aug 2008 05:50:41 -0400

Author: michalis
Date: 2008-08-01 05:50:40 -0400 (Fri, 01 Aug 2008)
New Revision: 4321

Added:
branches/WebAdmin/tick.gif
Modified:
branches/WebAdmin/default.css
branches/WebAdmin/index.jsp
branches/WebAdmin/perfSONARWebAdmin/admin/sqlma/SQLMAdmin.java
branches/WebAdmin/perfSONARWebAdmin/admin/stitching/StitchingServlet.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/stitching/ElementParser.java
branches/WebAdmin/perfSONARWebAdmin/auxiliary/stitching/HTMLOutput.java

branches/WebAdmin/perfSONARWebAdmin/auxiliary/stitching/MetadataManager.java

branches/WebAdmin/perfSONARWebAdmin/auxiliary/stitching/MetadataManagerImpl.java
branches/WebAdmin/perfSONARWebAdmin/auxiliary/stitching/test.java
branches/WebAdmin/perfSONARWebAdmin/auxiliary/wizard/HTMLOutput.java
branches/WebAdmin/perfSONARWebAdmin/auxiliary/wizard/WizardProperties.java
branches/WebAdmin/perfSONARWebAdmin/auxiliary/wizard/WizardProperty.java
Log:
Committing resent code changes and additions(Stitching Servlet)

Modified: branches/WebAdmin/default.css
===================================================================
--- branches/WebAdmin/default.css 2008-07-31 13:04:54 UTC (rev 4320)
+++ branches/WebAdmin/default.css 2008-08-01 09:50:40 UTC (rev 4321)
@@ -14,7 +14,7 @@
font-family: arial;
}

-a img {
+a img{
border: none;
}
/* Wizard CSS */
@@ -328,9 +328,6 @@
background: transparent url(graphics/manage_collections_on_tab.gif)
no-repeat center top;
}

-.collections_option_on a:visited, a:active {
- background: transparent url(graphics/manage_collections_on_tab.gif)
no-repeat center top;
-}

.collections_option_off a {
padding: 7px 80px 7px 80px;
@@ -340,33 +337,23 @@
background: transparent url(graphics/manage_collections_off_tab.gif)
no-repeat center top;
}

-.collections_option_off a:visited, a:active {
- background: transparent url(graphics/manage_collections_off_tab.gif)
no-repeat center top;
-}

-.users_option_on a {
+.users_option_off a{
padding: 7px 65px 7px 65px;
width: 210px;
height: 28px;
text-decoration: none;
- background: transparent url(graphics/manage_users_on_tab.gif) no-repeat
center top;
+ background: transparent url(graphics/manage_users_off_tab.gif) no-repeat
center top;
}

-users_option_on a:visited, a:active {
- background: transparent url(graphics/manage_users_on_tab.gif) no-repeat
center top;
-}
-
-.users_option_off a {
+.users_option_on a {
padding: 7px 65px 7px 65px;
width: 210px;
height: 28px;
text-decoration: none;
- background: transparent url(graphics/manage_users_off_tab.gif) no-repeat
center top;
+ background: transparent url(graphics/manage_users_on_tab.gif) no-repeat
center top;
}

-users_option_off a:visited, a:active {
- background: transparent url(graphics/manage_users_off_tab.gif) no-repeat
center top;
-}

.login_button {
width: 54px;
@@ -664,13 +651,64 @@
#main_iface_panel{
margin-top: 2%;
margin-left:2%;
- background-color: #A0A0D8;
- width: 50%;
+ background-color: #ffffff;
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ font-size: 13px;
height:100%

}
+#main_iface_panel a{
+
+}

+#main_iface_panel a:visited a:active{
+
+}
+#iface_panel_body table{
+
+}
+#iface_panel_body td{
+ vertical-align:top;
+ height:100%;
+ padding:0px;
+}
+#file_management{
+ border: 1px solid blue;
+ padding:10px;
+ font-weight:bold;
+}
+
+#file_management table{
+ width:100%;
+}
+#file_info{
+ background-color:#BBBBE6;
+ padding:0px;
+}
+
+#file_info table{
+ width:100%;
+}
+#file_info th{
+
+ background-color:#8282C9;
+ color:#000000;
+ padding: 5px;
+ text-align:left;
+}
+#file_info_header{
+ color:white;
+ background-color:#8282C9;
+ font-weight:bold;
+}
+#file_info td{
+
+ padding: 5px;
+ text-align:left;
+}
+
#iface_panel_header{
+
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 13px;
padding: 5px;
@@ -678,38 +716,55 @@
margin:1px;

}
-
-#iface_panel_body{
- margin:1px;
-}
-
-#iface_panel_body td{
- vertical-align:top;;
-}
#panel_body_sidebar{

- background-color: #A0A0D8;
+ background-color: #CBCBED;
+}
+#panel_body_sidebar_devices{
+ height:100%;
+ background-color: #CBCBED;
float:left;
padding: 5px;
margin:1px;
+
}

+#panel_body_sidebar table{
+ width:100%;
+ height:100%;
+}
+#panel_body_sidebar tr{
+ height:100%;
+}
#panel_body_sidebar td{
padding: 8px;
-
}

+#panel_body_sidebar a a:visited a:link{
+ padding: 0px;
+ margin:0px
+}
+
#panel_body_ifaces{
- background-color: #ccccff;
+ background-color: #DEDEF9;
float:left;
- margin-left:0%;
- padding: 5px;
- margin:1px;
+ padding-left: 10px;
+ padding-right: 10px;
+ padding-bottom:20px;
+ padding-top:8px;
+ margin:0px;
}
+#host_name{
+ font-size:15px;
+ font-weight:bold;
+}

#ifaces_table{
- margin-top: 0px;
+ margin-top: 15px;
+ background-color:#ECECFC;
+ width:100%;
border-spacing: 1px 0px;
+ width:100%;
}

#ifaces_table td{
@@ -717,3 +772,30 @@
border-top:none;
}

+
+.ifaces_header1{
+ text-align:left;
+ font-weight:bold;
+ background-color:#8282C9;
+}
+.ifaces_header2{
+ background-color:#8282C9;
+ font-weight:bold;
+ text-align:center;
+}
+
+.execute_button_stitching {
+ display: block;
+ margin-top: 0px;
+ width: 120px;
+ height: 28px;
+ float: left;
+ border: none;
+ font-family: Helvetica, Calibri, Arial, sans-serif;
+ font-size: 90%;
+ font-weight: 600;
+ text-decoration: none;
+ cursor: pointer;
+ background: transparent url(graphics/button_1_large.gif) no-repeat
center;
+}
+

Modified: branches/WebAdmin/index.jsp
===================================================================
--- branches/WebAdmin/index.jsp 2008-07-31 13:04:54 UTC (rev 4320)
+++ branches/WebAdmin/index.jsp 2008-08-01 09:50:40 UTC (rev 4321)
@@ -84,6 +84,9 @@
</td>
</tr>
</table>
+ </td>
+ </tr>
+ </table>
</div>
<div class="mainWindow">
<div class="sidebar">
@@ -102,9 +105,9 @@
</span>
</p>
<p>
- <span class="navtex"><a
onclick="highlight()" href="Wizard" target="main">Service</a></span>
+ <span class="navtex"><a href="Wizard"
target="main">Service</a></span>
<br>
- <a onclick="highlight()"
href="testdepl.jsp" target="main">Test</a>
+ <a href="testdepl.jsp"
target="main">Test</a>
</p>
</td>
</tr>
@@ -118,13 +121,13 @@
</span>
</p>
<p>
- <span class="navtex style3"><a
onclick="highlight()" href="ServiceAdmin?serviceProperties"
target="main">Service</a>
+ <span class="navtex style3"><a
href="ServiceAdmin?serviceProperties" target="main">Service</a>
<br>
- <a onclick="highlight()"
href="ServiceAdmin?loggingProperties" target="main">Logging</a>
+ <a
href="ServiceAdmin?loggingProperties" target="main">Logging</a>
<br>
- <a onclick="highlight()"
href="eXistAdmin" target="main">eXist Database</a>
+ <a href="eXistAdmin"
target="main">eXist Database</a>
<br>
- <a onclick="highlight()"
href="MetadataAdmin" target="main">Config File Management</a>
+ <a href="MetadataAdmin"
target="main">Config File Management</a>
<br>

</span>

Modified: branches/WebAdmin/perfSONARWebAdmin/admin/sqlma/SQLMAdmin.java
===================================================================
--- branches/WebAdmin/perfSONARWebAdmin/admin/sqlma/SQLMAdmin.java
2008-07-31 13:04:54 UTC (rev 4320)
+++ branches/WebAdmin/perfSONARWebAdmin/admin/sqlma/SQLMAdmin.java
2008-08-01 09:50:40 UTC (rev 4321)
@@ -29,6 +29,7 @@
*/
@SuppressWarnings("serial")
public class SQLMAdmin extends HttpServlet {
+
//
-----------------------------------------------------------------------
// class fields

@@ -128,8 +129,16 @@

String function =
request.getParameter("Execute");
if (function != null) {
- if (function.equals("Delete File")) {
+ if(function.equals("Delete File")){
+ String ibatisFile =
request.getParameter("ibatisFile").trim();
+ output
+ .confirmPage(
+ "Would you
like to delete all data inside the metric table?",
+ "delete",
ibatisFile);
+ }
+ else if (function.equals("Delete
Data")) {
try {
+

deleteActions(request);
output

.infoPage(
@@ -137,20 +146,16 @@

"Finished deleting ibatis files <a href=\"SQLMAdmin\">Back</a>.",

"manage_sqlma");
} catch (Exception e) {
- output.infoPage("SQL
MA administration",
-
"Error!\n" + getFault(e), "manage");
+ output.infoPage("SQL
MA administration", "Error!\n"
+ +
getFault(e), "manage");
}
} else if (function.equals("Edit
File")) {
String ibatisFile =
request.getParameter("ibatisFile");
try {
- output
-
.mainPage(
-
"SQL MA administration",
-
manager.getIbatisFiles(),
-
type,
-
manager
-
.getIbatisFileProperties(ibatisFile),
-
ibatisFile, "Edit");
+ output.mainPage("SQL
MA administration", manager
+
.getIbatisFiles(), type, manager
+
.getIbatisFileProperties(ibatisFile),
+
ibatisFile, "Edit");
} catch (Exception e) {
throw new
ServletException(getFault(e));
}
@@ -160,8 +165,8 @@
editActions(request);
} catch (Exception e) {

- output.infoPage("SQL
MA administration",
-
"Error!\n" + getFault(e), "manage_sqlma");
+ output.infoPage("SQL
MA administration", "Error!\n"
+ +
getFault(e), "manage_sqlma");
}
}

@@ -170,8 +175,8 @@

createActions(request);
} catch (Exception e) {

- output.infoPage("SQL
MA administration",
-
"Error!\n" + getFault(e), "manage_sqlma");
+ output.infoPage("SQL
MA administration", "Error!\n"
+ +
getFault(e), "manage_sqlma");
}
} else if
(function.equals("Initialize")) {

@@ -227,7 +232,8 @@

"manage_sqlma");
} catch (Exception e)
{

output.infoPage("SQL MA administration",
-
"Error!\n" + getFault(e), "manage_sqlma");
+
"Error!\n" + getFault(e),
+
"manage_sqlma");

}
} else if
(action.equals("create")) {
@@ -237,6 +243,22 @@

"Finished configuring ibatis files <a href=\"SQLMAdmin\">Back</a>.",

"manage_sqlma");
}
+ else
if(action.equals("delete")){
+
+ try {
+
deleteActions(request);
+
+ output
+ .infoPage(
+
"SQL MA administration",
+
"Finished deleting ibatis files <a href=\"SQLMAdmin\">Back</a>.",
+
"manage_sqlma");
+ } catch (Exception e)
{
+
output.infoPage("SQL MA administration", "Error!\n"
+
+ getFault(e), "manage");
+ }
+
+ }
} else {
try {
String ibatisFile =
request
@@ -268,9 +290,8 @@
ibatisFile =
files[0];
}
}
- output.mainPage("SQL MA
administration", files,
- type, manager
-
.getIbatisFileProperties(ibatisFile),
+ output.mainPage("SQL MA
administration", files, type,
+
manager.getIbatisFileProperties(ibatisFile),
ibatisFile,
"");
} catch (Exception e) {
throw new
ServletException(getFault(e));
@@ -312,9 +333,8 @@
if (files != null) {
ibatisFile = files[0];
}
- output.mainPage("SQL MA
administration", files,
- type, manager
-
.getIbatisFileProperties(ibatisFile),
+ output.mainPage("SQL MA
administration", files, type,
+
manager.getIbatisFileProperties(ibatisFile),
ibatisFile,
"");
} catch (Exception e) {
throw new
ServletException(getFault(e));
@@ -339,15 +359,18 @@
private void deleteActions(HttpServletRequest request) throws
Exception {

String ibatisFile = request.getParameter("ibatisFile").trim();
- String deleteData = request.getParameter("deleteData");
+ String pass = request.getParameter("rtPass");
ibatisFileManager manager = new ibatisFileManager(ServicePath
+ ibatisFilesPath);
- if (deleteData != null) {
+ if (pass != null) {
String[] properties =
manager.getIbatisFileProperties(ibatisFile);
SQLDBManager managerDB = new
SQLDBManager(properties[7],
- properties[5]);
- managerDB.deleteData(properties[2], properties[4],
properties[3],
- properties[5]);
+ pass);
+ if (managerDB.checkTable(properties[2],
properties[4])) {
+
+ managerDB.deleteData(properties[2],
properties[4],
+ properties[3], properties[5]);
+ }
}
manager.deleteFiles(ibatisFile);

@@ -454,21 +477,29 @@
if (action.equals("edit")) {
if
((!properties[1].equals(propertiesOld[1]))) {

-
managerDB.createDatabase(properties[2]);
- createDB = true;
+ if
(!managerDB.checkDB(properties[2])) {
+
managerDB.createDatabase(properties[2]);
+ createDB = true;
+ } else
+ createDB = true;

} else {
if
(!properties[2].equals(propertiesOld[2])) {
-
managerDB.createDatabase(properties[2]);
- createDB = true;
+ if
(!managerDB.checkDB(properties[2])) {
+
managerDB.createDatabase(properties[2]);
+ createDB = true;
+ } else
+ createDB = true;

} else {
createDB = true;
}
}
} else if (action.equals("create")) {
-
- managerDB.createDatabase(properties[2]);
+ if (!managerDB.checkDB(properties[2])) {
+
managerDB.createDatabase(properties[2]);
+ createDB = true;
+ }
createDB = true;
}

@@ -477,9 +508,14 @@
}

boolean createUser = false;
- if (initUser != null && createDB) {
- managerDB.createUser(properties[3], "%",
properties[5]);
- managerDB.createUser(properties[3], "localhost",
properties[5]);
+ if (initUser != null && createDB ) {
+ if(!managerDB.checkUser(properties[3],properties[2])){
+
+ managerDB.createUser(properties[3],
"localhost", properties[5]);
+ managerDB.createUser(properties[3], "%",
properties[5]);
+ }
+
managerDB.grantPerfsonarPrivileges(properties[2],properties[3]);
+
createUser = true;
} else {
createUser = true;
@@ -487,18 +523,26 @@
boolean createTable = false;
if (initTable != null && createDB) {
if (properties[0].equals("L2-Path-Status Metric")) {
-
managerDB.createPerfsonarL2PathStatusMetricTable(properties[2],
- properties[4]);
+ if (!managerDB.checkTable(properties[2],
properties[4])) {
+
managerDB.createPerfsonarL2PathStatusMetricTable(
+ properties[2],
properties[4]);
+ createTable = true;
+ } else
+ createTable = false;

} else {
-
managerDB.createPerfsonarPacketMetricTable(properties[2],
- properties[4]);
+ if (!managerDB.checkTable(properties[2],
properties[4])) {
+
managerDB.createPerfsonarPacketMetricTable(properties[2],
+ properties[4]);
+ createTable = true;
+ } else
+ createTable = false;
+
}
if (createUser) {
managerDB

.grantPerfsonarPrivileges(properties[2], properties[3]);
}
- createTable = true;
} else {
createTable = true;
}

Modified:
branches/WebAdmin/perfSONARWebAdmin/admin/stitching/StitchingServlet.java
===================================================================
--- branches/WebAdmin/perfSONARWebAdmin/admin/stitching/StitchingServlet.java
2008-07-31 13:04:54 UTC (rev 4320)
+++ branches/WebAdmin/perfSONARWebAdmin/admin/stitching/StitchingServlet.java
2008-08-01 09:50:40 UTC (rev 4321)
@@ -1,12 +1,12 @@
package perfSONARWebAdmin.admin.stitching;

import java.io.BufferedWriter;
+import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
-import java.io.InputStream;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
@@ -23,6 +23,12 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
+import javax.xml.XMLConstants;
+import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+import javax.xml.validation.Validator;

import org.apache.commons.codec.binary.Base64;
import org.apache.commons.fileupload.FileItem;
@@ -78,7 +84,7 @@

private ElementParser parser = new ElementParser();

- private HashMap metrics;
+ private HashMap<String, String> metrics;

public void doGet(HttpServletRequest request, HttpServletResponse
response)
throws IOException {
@@ -108,23 +114,23 @@
HttpSession session = request.getSession(true);
if (session.isNew())
session.setMaxInactiveInterval(1800);
- ServletOutputStream out = response.getOutputStream();
+
ServletContext sc = getServletContext();
servicePath = sc.getRealPath("/");
ServletProperties servletProperties = new
ServletPropertiesImpl(
servicePath + ServletPropertiesPath);

Authenticator authenticator = new
AuthenticatorImpl(servletProperties);
- response.setContentType("text/html");
ServiceProperties properties = new
ServicePropertiesImpl(servicePath
+ serviceProperties);
URI = properties.getProperty("component.ma.xmldb.db_uri");
dbpass =
properties.getProperty("component.ma.xmldb.db_password");
username =
properties.getProperty("component.ma.xmldb.db_username");
confFile =
properties.getProperty("service.ma.conf_file").trim();
- output.setOuputStream(out);
+
try {
- manager = new MetadataManagerImpl(URI, username,
dbpass);
+ manager = new MetadataManagerImpl(URI,
confFile.substring(confFile
+ .lastIndexOf("/") + 1), username,
dbpass);
} catch (Exception e) {
throw new IOException(e.getMessage());
}
@@ -134,8 +140,8 @@
.booleanValue()) {

try {
- System.out.println("Getting to
action");
- servletActions(request);
+ //System.out.println("Getting to
action");
+ servletActions(request, response);
} catch (Exception e) {
throw new IOException(getFault(e));
}
@@ -172,8 +178,8 @@
session.setAttribute("authenticated",
true);

try {
- System.out.println("Getting
to action");
- servletActions(request);
+ //System.out.println("Getting
to action");
+ servletActions(request,
response);
} catch (Exception e) {
throw new
IOException(getFault(e));
}
@@ -190,9 +196,13 @@
* @param request
* @throws Exception
*/
- private void servletActions(HttpServletRequest request) throws
Exception {
+ private void servletActions(HttpServletRequest request,
+ HttpServletResponse response) throws Exception {

if (ServletFileUpload.isMultipartContent(request)) {
+ response.setContentType("text/html");
+ ServletOutputStream out = response.getOutputStream();
+ output.setOuputStream(out);

ServletFileUpload servletFileUpload = new
ServletFileUpload(
new DiskFileItemFactory());
@@ -208,34 +218,124 @@
+
"/WEB-INF/classes/perfsonar/conf/"
+
item.getName().trim()));
if (confFile != null) {
+ String newFileName=
servicePath
+ +
"/WEB-INF/classes/perfsonar/conf/"
+ +
item.getName().trim();
File file = new
File(confFile);
if (file.exists() &&
file.isFile()) {
+ try
+ {
+ StreamSource
ss = new StreamSource(new FileInputStream(newFileName));
+
System.out.println("Doc parsed");
+
System.setProperty("javax.xml.validation.SchemaFactory:" +
XMLConstants.RELAXNG_NS_URI,
"org.iso_relax.verifier.jaxp.validation.RELAXNGSchemaFactoryImpl");
+ SchemaFactory
schefactory = SchemaFactory.newInstance(XMLConstants.RELAXNG_NS_URI);
+ Schema schema =
schefactory.newSchema(new File(servicePath
+
+ "/WEB-INF/classes/perfsonar/conf/schema.rng"));
+ Validator
validator = schema.newValidator();
+ validator.validate((Source)
ss);

manager.removeConfigFile(file.getName().trim());
+
+ File newFile
= new File(newFileName);
+
PerfsonarProperties properties = new PerfsonarPropertiesImpl();
+
properties.loadProperties(new FileInputStream(new File(
+
servicePath + serviceProperties)));
+
PerfsonarProperty pr = properties
+
.getProperty("service.ma.conf_file");
+
pr.setValue(servicePath
+
+ "/WEB-INF/classes/perfsonar/conf/"
+
+ newFile.getName().trim());
+
properties.setProperty("service.ma.conf_file", pr);
+
properties.storeProperties(new FileOutputStream(
+
servicePath + serviceProperties));
+
manager.addConfigFile(newFile);
+
+
}catch(Exception e){
+ File
newFile = new File(newFileName);
+
newFile.delete();
+
setDefault(null,"Loading file failed!!!Cause: "+e.getLocalizedMessage());
+ }
}

}
- File newFile = new
File(servicePath
- +
"/WEB-INF/classes/perfsonar/conf/"
- +
item.getName().trim());
- PerfsonarProperties
properties= new PerfsonarPropertiesImpl();
- properties.loadProperties(new
FileInputStream(new File(servicePath + serviceProperties)));
- PerfsonarProperty pr=
properties.getProperty("service.ma.conf_file");
- pr.setValue(servicePath
- +
"/WEB-INF/classes/perfsonar/conf/"
- +
newFile.getName().trim());
-
properties.setProperty("service.ma.conf_file",pr);
-
properties.storeProperties(new FileOutputStream(servicePath +
serviceProperties));
-
manager.addConfigFile(newFile);
+

}

}
}
- setDefault();
+ setDefault(null,"");
} else if (request.getParameterNames().hasMoreElements()) {

- if (request.getParameter("sort") != null) {
+ if (request.getParameter("ifaces") != null) {
+
+ response.setContentType("text/html");
+ ServletOutputStream out =
response.getOutputStream();
+ output.setOuputStream(out);
+ List hosts = manager.getHostnames();
String host = request.getParameter("Host");
+ if (host != null) {
+ setDefault(host,"");
+ } else
+ setDefault(null,"");
+
+ } else if (request.getParameter("fileAction") !=
null) {
+ String action =
request.getParameter("fileAction").trim();
+
+ if (action.equals("Backup")) {
+
+ PerfsonarProperties properties = new
PerfsonarPropertiesImpl();
+ properties.loadProperties(new
FileInputStream(new File(
+ servicePath +
serviceProperties)));
+ PerfsonarProperty pr = properties
+
.getProperty("service.ma.conf_file");
+ String filename = pr.getValue();
+ File file = new File(filename);
+ File backfile=new File(filename +
".bak");
+ if(backfile.exists()){
+ backfile.delete();
+ }
+ if (file.renameTo(new File(filename +
".bak"))) {
+
+ file = new File(filename);
+ FileWriter fw = new
FileWriter(file);
+ BufferedWriter bw = new
BufferedWriter(fw);
+ bw.write(manager.getFile());
+ bw.close();
+ fw.close();
+ file = new File(filename);
+ int length = 0;
+
response.setContentType("application/x-download");
+
response.setContentLength((int) file.length());
+
response.setHeader("Content-Disposition",
+ "attachment;
filename=" + filename.substring(filename.lastIndexOf("/")+1));
+ ServletOutputStream out =
response.getOutputStream();
+ byte[] bbuf = new byte[1000];
+ DataInputStream in = new
DataInputStream(
+ new
FileInputStream(file));
+ while ((in != null) &&
((length = in.read(bbuf)) != -1)) {
+ out.write(bbuf, 0,
length);
+ }
+ in.close();
+ out.flush();
+ out.close();
+ throw new Exception("Done ");
+
+ }else{
+ throw new Exception("Problem
backing up file, file cannot be saved as");
+ }
+
+ }else{
+ throw new Exception("Not back up
"+action+" ");
+ }
+
+ }
+
+ else if (request.getParameter("sort") != null) {
+
+ response.setContentType("text/html");
+ ServletOutputStream out =
response.getOutputStream();
+ output.setOuputStream(out);
+ String host = request.getParameter("Host");
String metric =
request.getParameter("metric");
if (host != null && metric != null) {
List ifaces;
@@ -246,31 +346,45 @@
ifaces =
manager.getIfacesbyMetric(metric);
setInfo(ifaces, host, metric);
} else
- setDefault();
+ setDefault(null,"");
} else if (request.getParameter("Add") != null) {
+ response.setContentType("text/html");
+ ServletOutputStream out =
response.getOutputStream();
+ output.setOuputStream(out);
output.interface_page(null, null);
} else if (request.getParameter("Edit") != null) {
+ response.setContentType("text/html");
+ ServletOutputStream out =
response.getOutputStream();
+ output.setOuputStream(out);
String id = request.getParameter("id");
if (id != null) {
String meta =
manager.getIfacebyId(id);
if (meta != null) {
if (!meta.equals("")) {

output.interface_page(parser.parseMetaData(meta),
-
parser.parseData(manager.getData(id)));
+
parser.parseData((String) manager.getData(
+
id).get(1)));
} else
- setDefault();
+ setDefault(null,"");
} else
- setDefault();
+ setDefault(null,"");
} else
- setDefault();
+ setDefault(null,"");
} else if (request.getParameter("Remove") != null) {
+ response.setContentType("text/html");
+ ServletOutputStream out =
response.getOutputStream();
+ output.setOuputStream(out);
String id = request.getParameter("id");
if (id != null) {
output.remove_page(id);
} else
- setDefault();
+ setDefault(null,"");
} else if (request.getParameter("Create") != null) {

+ response.setContentType("text/html");
+ ServletOutputStream out =
response.getOutputStream();
+ output.setOuputStream(out);
+
String action =
request.getParameter("Create");
if (action.equals("Edit") ||
action.equals("Add")) {

@@ -320,32 +434,41 @@
if (action.equals("Add")) {
manager.addIface(metadata,
data, metadata[7],
(String)
metrics.get(data[3]));
- setDefault();
+ setDefault(null,"");
} else {
manager.updateIface(metadata,
data, metadata[7],
(String)
metrics.get(data[3]));
- setDefault();
+ setDefault(null,"");
}

} else
- setDefault();
+ setDefault(null,"");

} else if (request.getParameter("Delete") != null) {
-
+
+ response.setContentType("text/html");
+ ServletOutputStream out =
response.getOutputStream();
+ output.setOuputStream(out);
String delete =
request.getParameter("Delete");
if (delete.equals("Yes")) {
String id =
request.getParameter("id");
if (id != null) {
manager.removeIfacebyId(id);
- setDefault();
+ setDefault(null,"");
} else
- setDefault();
+ setDefault(null,"");
} else
- setDefault();
+ setDefault(null,"");
} else if (request.getParameter("Manage") != null) {
+ response.setContentType("text/html");
+ ServletOutputStream out =
response.getOutputStream();
+ output.setOuputStream(out);
output.manage_config_file_page();
- }
- else if (request.getParameter("CreateFile") != null) {
+ } else if (request.getParameter("CreateFile") !=
null) {
+ response.setContentType("text/html");
+ ServletOutputStream out =
response.getOutputStream();
+ output.setOuputStream(out);
+
String fileName =
request.getParameter("fileName");
if (fileName != null) {
File newFile = new File(servicePath
@@ -362,24 +485,31 @@
if (confFile
!= null) {
File
file = new File(confFile);
if
(file.exists() && file.isFile()) {
-
manager.removeConfigFile(confFile);
+
manager.removeConfigFile(confFile
+
.substring(confFile
+
.lastIndexOf("/") + 1));
}

}
- newFile = new
File(
-
servicePath
-
+ "/WEB-INF/classes/perfsonar/conf/"
-
+ fileName + ".xml");
-
PerfsonarProperties properties= new PerfsonarPropertiesImpl();
-
properties.loadProperties(new FileInputStream(new File(servicePath +
serviceProperties)));
-
PerfsonarProperty pr= properties.getProperty("service.ma.conf_file");
+ newFile = new
File(servicePath
+
+ "/WEB-INF/classes/perfsonar/conf/"
+
+ fileName + ".xml");
+
PerfsonarProperties properties = new PerfsonarPropertiesImpl();
+
properties.loadProperties(new FileInputStream(
+
new File(servicePath
+
+ serviceProperties)));
+
PerfsonarProperty pr = properties
+
.getProperty("service.ma.conf_file");

pr.setValue(servicePath

+ "/WEB-INF/classes/perfsonar/conf/"

+ newFile.getName().trim());
-
properties.setProperty("service.ma.conf_file",pr);
-
properties.storeProperties(new FileOutputStream(servicePath +
serviceProperties));
+
properties.setProperty("service.ma.conf_file",
+
pr);
+ properties
+
.storeProperties(new FileOutputStream(
+
servicePath + serviceProperties));

manager.addConfigFile(newFile);
- setDefault();
+
setDefault(null,"");

} else
throw new
Exception("Cannot write to new file");
@@ -390,30 +520,133 @@
} else
throw new Exception("No file name");

- } else
- setDefault();
+ } else {

+ response.setContentType("text/html");
+ ServletOutputStream out =
response.getOutputStream();
+ output.setOuputStream(out);
+ setDefault(null,"");
+ }
+
} else {

if (manager != null) {

- setDefault();
+ response.setContentType("text/html");
+ ServletOutputStream out =
response.getOutputStream();
+ output.setOuputStream(out);
+ setDefault(null,"");
}

}

}

+ /**
+ * @param ifaces
+ * @throws Exception
+ */
+ @SuppressWarnings("unchecked")
+ private List processIfaces(List ifaces) throws Exception {
+
+ Map<String, String[]> interfaces = new HashMap<String,
String[]>();
+ Iterator it = ifaces.iterator();
+ while (it.hasNext()) {
+ String iface = (String) it.next();
+ String[] meta_info = parser.parseMetaData(iface);
+ List dataList= manager.getData(meta_info[7]);
+ String[] data_info= new String[9];
+ if(!dataList.isEmpty()){
+ data_info=parser.parseData((String)
dataList.get(0));
+ }
+ if (interfaces.containsKey(meta_info[2])) {
+
+ String[] info = (String[])
interfaces.get(meta_info[2]);
+
+
+ if (meta_info[8]
+
.equals("http://ggf.org/ns/nmwg/characteristic/utilization/2.0";)) {
+
+ if
(meta_info[4].equalsIgnoreCase("in")) {
+ info[4] = "true";
+ info[5]=data_info[0];
+ } else if
(meta_info[4].equalsIgnoreCase("out")) {
+ info[6] = "true";
+ info[7]=data_info[0];
+ }
+
+ info[8] = "true";
+
+ } else if (meta_info[8]
+
.equals("http://ggf.org/ns/nmwg/characteristic/errors/2.0";)) {
+ if
(meta_info[4].equalsIgnoreCase("in")) {
+ info[9] = "true";
+ info[10]=data_info[0];
+ }
+ } else if (meta_info[8]
+
.equals("http://ggf.org/ns/nmwg/characteristic/discards/2.0";)) {
+
+ if
(meta_info[4].equalsIgnoreCase("out")) {
+ info[11] = "true";
+ info[12]=data_info[0];
+ }
+ }
+ interfaces.put(info[0], info);
+
+ } else {
+ String[] info = new String[13];
+ for(int i=0;i<info.length;i++){
+ info[i]="";
+ }
+ info[0] = meta_info[2];
+ info[1] = meta_info[1];
+ info[2] = meta_info[5];
+ info[3] = meta_info[3];
+
+ if (meta_info[8]
+
.equals("http://ggf.org/ns/nmwg/characteristic/utilization/2.0";)) {
+ if
(meta_info[4].equalsIgnoreCase("in")) {
+ info[4] = "true";
+ info[5]=data_info[0];
+ } else if
(meta_info[4].equalsIgnoreCase("out")) {
+ info[5] = "true";
+ info[7]=data_info[0];
+ }
+
+ info[8] = "true";
+ } else if (meta_info[8]
+
.equals("http://ggf.org/ns/nmwg/characteristic/errors/2.0";)) {
+
+ if
(meta_info[4].equalsIgnoreCase("in")) {
+ info[9] = "true";
+ info[10]=data_info[0];
+ }
+
+ } else if (meta_info[8]
+
.equals("http://ggf.org/ns/nmwg/characteristic/discards/2.0";)) {
+
+ if
(meta_info[4].equalsIgnoreCase("out")) {
+ info[11] = "true";
+ info[12]=data_info[0];
+ }
+ }
+ interfaces.put(info[0], info);
+ }
+ }
+ return new LinkedList(interfaces.values());
+
+ }
+
private String getNewStoreFile() {
-
- return " <nmwg:store
xmlns:nmwgt=\"http://ggf.org/ns/nmwg/topology/2.0/\"; " +
- "xmlns:nmtm=\"http://ggf.org/ns/nmwg/time/2.0/\"; "+
- "xmlns:nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\"; "+
- "xmlns:perfsonar=\"http://ggf.org/ns/nmwg/tools/org/perfsonar/1.0/\";
"+
-
"xmlns:netutil=\"http://ggf.org/ns/nmwg/characteristic/utilization/2.0/\"; "+
- "xmlns:errors=\"http://ggf.org/ns/nmwg/characteristic/errors/2.0/\"; "+
-
"xmlns:discards=\"http://ggf.org/ns/nmwg/characteristic/discards/2.0/\"; "+
- "xmlns=\"http://ggf.org/ns/nmwg/base/2.0/\";> </nmwg:store>";
+
+ return " <nmwg:store
xmlns:nmwgt=\"http://ggf.org/ns/nmwg/topology/2.0/\"; "
+ +
"xmlns:nmtm=\"http://ggf.org/ns/nmwg/time/2.0/\"; "
+ +
"xmlns:nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\"; "
+ +
"xmlns:perfsonar=\"http://ggf.org/ns/nmwg/tools/org/perfsonar/1.0/\"; "
+ +
"xmlns:netutil=\"http://ggf.org/ns/nmwg/characteristic/utilization/2.0/\"; "
+ +
"xmlns:errors=\"http://ggf.org/ns/nmwg/characteristic/errors/2.0/\"; "
+ +
"xmlns:discards=\"http://ggf.org/ns/nmwg/characteristic/discards/2.0/\"; "
+ +
"xmlns=\"http://ggf.org/ns/nmwg/base/2.0/\";> </nmwg:store>";
}

/**
@@ -431,16 +664,81 @@
if (res != null)
info.add(res);
}
+ @SuppressWarnings("unused")
List hosts = manager.getHostnames();
- output.main_page(info, hosts, host, metric);
+ // output.main_page(info, hosts, host, metric);
}

/**
+ * @param device
+ * @param string
* @throws Exception
*/
- private void setDefault() throws Exception {
- List ifaces = manager.getIfacesbyMetric("netutil");
- setInfo(ifaces, "netutil", null);
+ private void setDefault(String device, String message) throws
Exception {
+ // List ifaces = manager.getIfacesbyMetric("netutil");
+ // setInfo(ifaces, "netutil", null);
+ List hosts = manager.getHostnames();
+ PerfsonarProperties properties = new
PerfsonarPropertiesImpl();
+ properties.loadProperties(new FileInputStream(new File(
+ servicePath + serviceProperties)));
+ PerfsonarProperty pr = properties
+ .getProperty("service.ma.conf_file");
+ String filename = pr.getValue();
+
+ if (hosts != null && !hosts.isEmpty()) {
+
+ String host = (device != null) ? device : (String)
hosts.get(0);
+ List ifaces = manager.getIfacesbyHostname(host);
+ String[] hostsInfo = new String[5];
+ hostsInfo[2] = null;
+ hostsInfo[3] = null;
+ hostsInfo[4] = null;
+ String[] hostInfo = new String[5];
+ hostInfo[2] = null;
+ hostInfo[3] = null;
+ hostInfo[4] = null;
+ Iterator it = hosts.iterator();
+ int numIfaces = 0;
+ int numDataPoints = 0;
+ while (it.hasNext()) {
+ String ht = (String) it.next();
+ String numIf =
manager.getNumberOfIfacesByHost(ht);
+ String numDat =
manager.getNumberOfDataByHost(ht);
+ numIfaces += Integer.parseInt(numIf);
+ numDataPoints += Integer.parseInt(numDat);
+ if (ht.equals(host)) {
+ hostInfo[0] = numIf;
+ hostInfo[1] = numDat;
+ }
+ List metrics =
manager.getAvailableMetricsByHost(ht);
+
+ if (metrics
+
.contains("http://ggf.org/ns/nmwg/characteristic/utilization/2.0";)) {
+ hostsInfo[2] = "Utilisation";
+ if (ht.equals(host))
+ hostInfo[2] = "Utilisation";
+ }
+
+ if (metrics
+
.contains("http://ggf.org/ns/nmwg/characteristic/errors/2.0";)) {
+ hostsInfo[3] = "Errors";
+ if (ht.equals(host))
+ hostInfo[3] = "Errors";
+ }
+
+ if (metrics
+
.contains("http://ggf.org/ns/nmwg/characteristic/errors/2.0";)) {
+ hostsInfo[4] = "Discards";
+ if (ht.equals(host))
+ hostInfo[4] = "Discards";
+ }
+ }
+ hostsInfo[0] = String.valueOf(numIfaces);
+ hostsInfo[1] = String.valueOf(numDataPoints);
+
output.main_page(filename.substring(filename.lastIndexOf("/")+1),processIfaces(ifaces),
hosts, hostsInfo, host,
+ hostInfo,message );
+ } else
+
output.main_page(filename.substring(filename.lastIndexOf("/")+1),null, null,
null, null, null,message);
}

/**

Modified:
branches/WebAdmin/perfSONARWebAdmin/admin/wizard/services/RRDMAHandler.java
===================================================================
---
branches/WebAdmin/perfSONARWebAdmin/admin/wizard/services/RRDMAHandler.java
2008-07-31 13:04:54 UTC (rev 4320)
+++
branches/WebAdmin/perfSONARWebAdmin/admin/wizard/services/RRDMAHandler.java
2008-08-01 09:50:40 UTC (rev 4321)
@@ -394,16 +394,20 @@
*/

while (it.hasNext()) {
- String key = (String) it.next();
+
+ 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);
+ 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);
@@ -415,7 +419,7 @@
} catch (Exception e) {
// Set doen to false if anything happens
done = false;
- throw new Exception(getFault(e));
+ throw new Exception(e.getMessage());
}
return done;
// }
@@ -465,13 +469,13 @@
throw new IOException("Key is invalid
" + key + " ");
} else {
// Change the value of the property
-
if(functionProperties.getProperty(key).equals("yes"))
+ 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));
-
+
property.setValue(functionProperties.getProperty(key));
+
serviceProperties.setProperty(key,
property);
}
properties.setWizardProperty(key,
functionProperties
@@ -602,15 +606,15 @@
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_adminpassword")) {
- // adminPass =
serviceProperties.getProperty(key).getValue()
- // .trim();
- newAdminPass =
finalProperties.getProperty(key).trim();
- }
if (key.endsWith("xmldb.db_uri")) {
existURI = finalProperties.getProperty(key);
}
@@ -625,19 +629,45 @@
// 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("old_adminpassword")) {

- adminPass =
finalProperties.getProperty(key).trim();
+ 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 {
@@ -648,9 +678,11 @@

}
// Setting also the wizard properties
- properties.setWizardProperty(key, finalProperties
- .getWizardProperty(key));

+ properties.setWizardProperty(key,
finalProperties
+ .getWizardProperty(key));
+
+
// Also getting all needed information in orer to
configure the
// exist db
if (key.endsWith("xmldb.db_username")) {
@@ -662,7 +694,11 @@
if (key.endsWith("conf_file")) {
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
@@ -674,17 +710,39 @@
if (existURI == null) {
throw new Exception("eXist xmldb URI is empty!\n");
} else {
- xmlDBManager manager = new xmlDBManagerImpl(existURI,
"admin",
- adminPass);
- // Creating collection and users
- manager.createCollection(dbCollection);
- manager.createUser(dbCollection, username, password,
null);
- // Adding the metadata config document
- manager.getCollection(dbCollection).addDocument(new
File(confFile),
- username);
+
+ if (createUser.equals("yes")) {
+
+ xmlDBManager manager = new
xmlDBManagerImpl(existURI, "admin",
+ old_adminPass1);
+ // Creating collection and users
+ manager.createCollection(dbCollection);
+ manager.createUser(dbCollection, username,
password, null);
+ // Adding the metadata config document
+
manager.getCollection(dbCollection).addDocument(
+ new File(confFile), username);
+ } else {
+ xmlDBManager manager = new
xmlDBManagerImpl(existURI, username,
+ password);
+ // Creating collection and users
+ manager.createCollection(dbCollection);
+ // Adding the metadata config document
+
manager.getCollection(dbCollection).addDocument(
+ new File(confFile), username);
+ }
// Modifying the admin user password
- manager.modifyUser("admin", newAdminPass, null, null);
+ 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

Modified: branches/WebAdmin/perfSONARWebAdmin/auxiliary/sql/SQLDBManager.java
===================================================================
--- branches/WebAdmin/perfSONARWebAdmin/auxiliary/sql/SQLDBManager.java
2008-07-31 13:04:54 UTC (rev 4320)
+++ branches/WebAdmin/perfSONARWebAdmin/auxiliary/sql/SQLDBManager.java
2008-08-01 09:50:40 UTC (rev 4321)
@@ -39,12 +39,12 @@
* @throws Exception
*/
public SQLDBManager(String driver, String password) throws Exception {
- Driver = driver;
+ Driver = driver.trim();
// FileInputStream in=new
// FileInputStream(ServicePath+ServletPropertiesPath);
// Properties pr= new Properties();
// pr.load(in);
- adminPassword = password;
+ adminPassword = password.trim();
if (adminPassword == null)
adminPassword = "";
if (Driver.equals("com.mysql.jdbc.Driver")) {
@@ -84,7 +84,7 @@
Connection connnection = DriverManager.getConnection(DBURI +
"mysql",
"root", adminPassword);
if (!connnection.isClosed()) {
- String statement = "SHOW DATABASES";
+ String statement = " select SCHEMA_NAME from
information_schema.schemata;";
PreparedStatement ps =
connnection.prepareStatement(statement);
ResultSet rs = ps.executeQuery();
rs.last();
@@ -115,7 +115,7 @@
Connection connnection = DriverManager.getConnection(DBURI +
"mysql",
"root", adminPassword);
if (!connnection.isClosed()) {
- String statement = "SELECT user,host FROM user";
+ String statement = " select DISTINCT grantee from
information_schema.user_privileges";
PreparedStatement ps =
connnection.prepareStatement(statement);
ResultSet rs = ps.executeQuery();
rs.last();
@@ -124,7 +124,7 @@
int i = 0;
while (rs.next()) {
i++;
- users[i - 1] = rs.getString(1) + "@" +
rs.getString(2);
+ users[i - 1] = rs.getString(1);
}
connnection.close();
return users;
@@ -148,7 +148,12 @@
"root", adminPassword);
if (!connnection.isClosed()) {
String statement = "SELECT host FROM user WHERE
user='" + user
+ + "'";
+ if (!Driver.equals("com.mysql.jdbc.Driver")) {
+
+ statement = "SELECT host FROM user WHERE user='" +
user
+ "'";
+ }
PreparedStatement ps =
connnection.prepareStatement(statement);
ResultSet rs = ps.executeQuery();
rs.last();
@@ -157,7 +162,7 @@
int i = 0;
while (rs.next()) {
i++;
- hosts[i - 1] = rs.getString(1);
+ hosts[i - 1] = rs.getString(i);
}
connnection.close();
return hosts;
@@ -621,6 +626,97 @@
}

/**
+ * @param user
+ * @param DBName
+ * @return
+ * @throws Exception
+ */
+ public boolean checkUser(String user, String DBName) throws Exception
{
+ Class.forName(Driver);
+ Connection connnection = DriverManager.getConnection(DBURI +
"mysql",
+ "root", adminPassword);
+ if (!connnection.isClosed()) {
+
+ boolean result = true;
+ String statement = "select PRIVILEGE_TYPE from
information_schema.schema_privileges where GRANTEE=\"'"
+ + DBName + "'@'%'\" and
table_schema='" + DBName + "' ;";
+ PreparedStatement ps =
connnection.prepareStatement(statement);
+ ResultSet rs = ps.executeQuery();
+ LinkedList priv = new LinkedList();
+ if (rs.next()) {
+ result = true;
+ } else
+ result = false;
+
+ connnection.close();
+
+ return result;
+
+ } else {
+ throw new Exception("Cannot connect to database!");
+ }
+ }
+
+ /**
+ * @param DBName
+ * @return
+ * @throws Exception
+ */
+ public boolean checkDB(String DBName) throws Exception {
+ Class.forName(Driver);
+ Connection connnection = DriverManager.getConnection(DBURI +
"mysql",
+ "root", adminPassword);
+ if (!connnection.isClosed()) {
+ String statement = "SELECT SCHEMA_NAME FROM
INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = '"
+ + DBName + "'";
+ PreparedStatement ps =
connnection.prepareStatement(statement);
+ ResultSet set = ps.executeQuery();
+ boolean result;
+ if (set.next()) {
+ result = true;
+ } else {
+ result = false;
+ }
+ connnection.close();
+ return result;
+ } else {
+ throw new Exception("Cannot connect to database!");
+ }
+ }
+
+ /**
+ * @param db
+ * @param table
+ * @return
+ * @throws Exception
+ */
+ public boolean checkTable(String db, String table) throws Exception {
+
+ Class.forName(Driver);
+ Connection connnection = DriverManager.getConnection(DBURI +
"mysql",
+ "root", adminPassword);
+ if (!connnection.isClosed()) {
+ String statement = " select count(*) from
information_schema.tables where table_schema='"
+ + db + "' and table_name='" + table +
"'";
+ PreparedStatement ps =
connnection.prepareStatement(statement);
+ ResultSet set = ps.executeQuery();
+ boolean result;
+ if (set.next()) {
+ if (set.getInt(1) == 1)
+ result = true;
+ else
+ result = false;
+ } else {
+ result = false;
+ }
+ connnection.close();
+ return result;
+ } else {
+ throw new Exception("Cannot connect to database!");
+ }
+ }
+
+ /**
* @param database
* @param table
* @param username
@@ -654,39 +750,7 @@

public static void main(String args[]) {

- try {
- Class.forName("com.mysql.jdbc.Driver");
- Connection connnection = DriverManager.getConnection(
-
"jdbc:mysql://192.168.10.86:3306/mysql", "root", "michael");
- if (!connnection.isClosed()) {
- String statement = "CREATE DATABASE " +
"somedb";
- PreparedStatement ps =
connnection.prepareStatement(statement);
- 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"); }
- */
-
- } else {
- throw new Exception("Cannot connect to
database!");
- }
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
+
}

}

Modified: branches/WebAdmin/perfSONARWebAdmin/auxiliary/sqlma/HTMLOutput.java
===================================================================
--- branches/WebAdmin/perfSONARWebAdmin/auxiliary/sqlma/HTMLOutput.java
2008-07-31 13:04:54 UTC (rev 4320)
+++ branches/WebAdmin/perfSONARWebAdmin/auxiliary/sqlma/HTMLOutput.java
2008-08-01 09:50:40 UTC (rev 4321)
@@ -267,14 +267,17 @@
out.println("<p/>");
out.println("<form action=\"SQLMAdmin\" method=\"POST\" > ");
out.println("<table class=\"init_table\">");
- out
+ if(!action.equals("delete"))
+ {out
.println("<tr><th>Choose what to initialize:
</th><td><input type=\"checkbox\" name=\"createDatabase\" value=\"Yes\"
/>Create Database</td><td/></tr>");
out
.println("<tr><th/><td><input
type=\"checkbox\" name=\"createUser\" value=\"Yes\" />Create
User</td><td/></tr>");
out
.println("<tr><th/><td><input
type=\"checkbox\" name=\"createTable\" value=\"Yes\"/>Initialize
Table</td><td/></tr>");
+ }
+ String subAction=action.equals("delete")?"Delete
Data":"Initialize";
out
- .println("<tr><th>Enter the SQL DB root
password: </th><td><input type=\"password\" size=20 name=\"rtPass\"
value=\"\"/></td><td><input class=\"execute_button_sqlma_large\"
type=\"submit\" name=\"Execute\" value=\"Initialize\" /></td></tr>");
+ .println("<tr><th>Enter the SQL DB root
password: </th><td><input type=\"password\" size=20 name=\"rtPass\"
value=\"\"/></td><td><input class=\"execute_button_sqlma_large\"
type=\"submit\" name=\"Execute\" value=\""+subAction+"\" /></td></tr>");

out.println("</table>");


Modified:
branches/WebAdmin/perfSONARWebAdmin/auxiliary/stitching/ElementParser.java
===================================================================
---
branches/WebAdmin/perfSONARWebAdmin/auxiliary/stitching/ElementParser.java
2008-07-31 13:04:54 UTC (rev 4320)
+++
branches/WebAdmin/perfSONARWebAdmin/auxiliary/stitching/ElementParser.java
2008-08-01 09:50:40 UTC (rev 4321)
@@ -2,6 +2,7 @@

import java.io.ByteArrayInputStream;
import java.util.Iterator;
+import java.util.List;

import org.jdom.Document;
import org.jdom.Element;
@@ -83,12 +84,24 @@
ifaceInfo[3]
= param.getTextTrim();
} else if
(param.getName().equals("direction")) {
ifaceInfo[4]
= param.getTextTrim();
- } else if
(param.getName().equals("authRealm")) {
- ifaceInfo[5]
= param.getTextTrim();
} else if
(param.getName().equals("capacity")) {
ifaceInfo[6]
= param.getTextTrim();
}
}
+ Element params=
meta.getChild("parameters", nmwg);
+ if(params!=null){
+ ifaceInfo[5]="";
+ List parameters=
params.getChildren("parameter",nmwg);
+ it
=parameters.iterator();
+ while(it.hasNext()){
+ Element
param=(Element) it.next();
+
if(param.getAttributeValue("name").equals("keyword")&&param.getAttributeValue("type").equals("project")){
+
ifaceInfo[5]=param.getText().trim();
+ }
+ }
+ }else{
+ ifaceInfo[5]="";
+ }
return ifaceInfo;
} else
return null;
@@ -183,11 +196,13 @@
+
"<nmwgt:ifName>PO2/1/0</nmwgt:ifName>"
+
"<nmwgt:ifDescription>CYNET-GEANT-ATHENA (155Mbps) - SW3
(VCS4003-ports5,6)</nmwgt:ifDescription>"
+
"<nmwgt:direction>in</nmwgt:direction>"
- +
"<nmwgt:authRealm></nmwgt:authRealm>"
+
"<nmwgt:capacity>155000000</nmwgt:capacity>"
+ "</nmwgt:interface>"
+ "</netutil:subject>"
+ "<nmwg:eventType>
http://ggf.org/ns/nmwg/characteristic/utilization/2.0</nmwg:eventType>"
+ +"<nmwg:parameters
id=\"params1\">"
+ +"<nmwg:parameter
name=\"keyword\" type=\"project\">http://foo.bar</nmwg:parameter>"
+ +"</nmwg:parameters>"
+ "</nmwg:metadata>");

for (int i = 0; i < info.length; i++) {

Modified:
branches/WebAdmin/perfSONARWebAdmin/auxiliary/stitching/HTMLOutput.java
===================================================================
--- branches/WebAdmin/perfSONARWebAdmin/auxiliary/stitching/HTMLOutput.java
2008-07-31 13:04:54 UTC (rev 4320)
+++ branches/WebAdmin/perfSONARWebAdmin/auxiliary/stitching/HTMLOutput.java
2008-08-01 09:50:40 UTC (rev 4321)
@@ -1,7 +1,6 @@
package perfSONARWebAdmin.auxiliary.stitching;

import java.io.IOException;
-import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -17,7 +16,7 @@
//
-----------------------------------------------------------------------
// class fields

- // The doctype of the html document. Currently XHtml strict
+ // The doctype of the html document. Currently XHTML strict
private static final String doctype = "<!DOCTYPE html PUBLIC
\"-//W3C//DTD XHTML 1.0 Strict//EN\"
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\";>";

// The servlet output stream that will be used to output the html code
@@ -39,6 +38,7 @@
"errors");

metrics.put("http://ggf.org/ns/nmwg/characteristic/discards/2.0";,
"discards");
+
}

//
-----------------------------------------------------------------------
@@ -65,51 +65,122 @@
* @throws IOException
*/
@SuppressWarnings("unchecked")
- public void main_page(List ifaces, List hosts, String host, String
metric)
+ public void main_page(String file, List ifaces, List hosts,
+ String[] hostsInfo, String host, String[] hostInfo,
String message)
throws IOException {
preempt();
out.println("<div id=\"iface_management\" >");
- out.println("<table >");
- out.println("<tr class=\"headerlavender\" >");
out
- .println("<td>Inteface Management</td><td><a
href=\"?Add=true\">Add Interface</a>&nbsp;&nbsp;&nbsp; <a
href=\"?Manage=true\">Manage Config file</a></td> ");
+ .println("<p
class=\"welcometextlavender\">Configuration File Management</p>");
+ out.println("</div>");
+
+ out.println("<div id=\"main_iface_panel\" >");
+
+ out.println("<div id=\"iface_panel_body\" >");
+
+ out.println("<table>");
+ out.println("<tr><td colspan=\"2\" style=\"color:red;\"
>"+message+"</td></tr>");
+ out.println("<tr>");
+ out.println("<td colspan=\"2\">");
+ out.println("<div id=\"file_management\">");
+ out.println("<table>");
+ out.println("<tr>");
+ out.println("<td colspan=\"2\" >");
+ out.println("Current file " + file + "</td></tr>");
+ out
+ .println("<tr><td ><form
action=\"MetadataAdmin\" method=\"POST\" ENCTYPE=\"multipart/form-data\"
><input class=\"execute_button_stitching\" name=\"fileAction\"
type=\"submit\" value=\"Upload New\"></input><input type=\"file\" size=0
name=\"file\" value=\"\"></input></form></td>");
+ out.println("<td><form action=\"MetadataAdmin\"
method=\"POST\" ><input class=\"execute_button_stitching\" type=\"submit\"
name=\"fileAction\" value=\"Backup\"></input></form></td>");
out.println("</tr>");
- out.println("<form action=\"MetadataAdmin\" method=\"POST\"
>");
- out.println("<tr class=\"headerlavender\" >");
- out.println("<td>Host Name <select name=\"Host\">");
- Iterator it = hosts.iterator();
- while (it.hasNext()) {
- String name = (String) it.next();
- out.println("<option value=\"" + name + "\">" + name
+ "</option>");
+ out.println("</table>");
+ out.println("</div>");
+ out.println("</td>");
+ out.println("</tr>");
+
+ String hostsMetrics = "";
+ if (hostsInfo[2] != null) {
+ hostsMetrics += hostsInfo[2];
}
- out.println("<option value=\"Any\">Any</option>");
- out.println("</select> Metric:<select name=\"metric\">");
- out.println("<option value=\"netutil\">Utilization</option>");
- out.println("<option value=\"errors\">Errors</option>");
- out.println("<option value=\"discards\">Discards</option>");
- out.println("</select></td>");
+ if (hostsInfo[3] != null) {
+ hostsMetrics += ",";
+ hostsMetrics += hostsInfo[3];
+ }
+ if (hostsInfo[4] != null) {
+ hostsMetrics += ",";
+ hostsMetrics += hostsInfo[4];
+ }
+ out.println("<tr>");
+ out.println("<td colspan=\"2\">");
+ out.println("<div id=\"file_info\">");
+ out.println("<table>");
out
- .println("<td><input type=\"submit\"
name=\"sort\" value=\"Fetch\" ></input><input type=\"reset\"
value=\"Reset\"></input></td>");
-
- out.println("</form>");
- out.println("</tr>");
+ .println("<tr><td id=\"file_info_header\"
colspan=\"2\">Configuration file content: Showing file "
+ + file + " </td></tr>");
+ out.println("<tr><td>- " + hosts.size()
+ + " devices</td><td>- Total of " +
hostsInfo[1]
+ + " data points or counters</td></tr>");
+ out.println("<tr><td>- Total of " + hostsInfo[0]
+ + " configured interfaces</td><td>- Metrics
configured: "
+ + hostsMetrics + "</td></tr>");
out.println("</table>");
out.println("</div>");
+ out.println("</td>");
+ out.println("</tr>");

- out.println("<div id=\"ifaces\" >");
+ out.println("<tr>");
+ out.println("<td id=\"panel_body_sidebar\">");
+ out.println("<div id=\"panel_body_sidebar_devices\">");
out.println("<table>");
- out.println("<tr class=\"headerlavender\" >");
+ Iterator it = hosts.iterator();
+ while (it.hasNext()) {
+ String hostName = (String) it.next();
+ out.println("<tr>");
+ out.println("<td><a href=\"?ifaces=true&Host=" +
hostName + "\">"
+ + hostName + "</a></td>");
+ out.println("</tr>");
+ }
+ String hostMetrics = "";
+ if (hostInfo[2] != null) {
+ hostMetrics += hostInfo[2];
+ }
+ if (hostInfo[3] != null) {
+ hostMetrics += ",";
+ hostMetrics += hostInfo[3];
+ }
+ if (hostInfo[4] != null) {
+ hostMetrics += ",";
+ hostMetrics += hostInfo[4];
+ }
+ out.println("</table>");
+ out.println("</div>");
+ out.println("</td>");
+ out.println("<td>");
+ out.println("<div id=\"panel_body_ifaces\" >");
+ out.println("<p id=\"host_name\">" + host + "
Interfaces</p>");
+ out.println("<table id=\"ifaces_table\" >");
+ out.println("<tr class=\"ifaces_header1\" >");
+ out.println("<td colspan=\"7\">Contains: </td>");
+ out.println("</tr>");
+ out.println("<tr>");
+ out.println("<td colspan=\"7\">- " + hostInfo[0] + "
Interfaces</td>");
+ out.println("</tr>");
+ out.println("<tr>");
+ out.println("<td colspan=\"7\">- " + hostInfo[1]
+ + " data points or counters</td>");
+ out.println("</tr>");
+ out.println("<tr>");
+ out.println("<td colspan=\"7\">- Metrics Configured: " +
hostMetrics
+ + "</td>");
+ out.println("</tr>");
+ out.println("<tr class=\"ifaces_header2\" >");
out
-
.println("<td>Interface</td><td>Metric</td><td>Direction</td><td>Action</td>");
+
.println("<td>Name</td><td>Address</td><td>Project</td><td>Util
In</td><td>Util Out</td><td>Errors</td><td>Discards</td> ");
out.println("</tr>");
+ it = ifaces.iterator();
+
boolean change = false;
String cssclass = "lightgrey";
- // Collections.sort(ifaces.);
- it = ifaces.iterator();
while (it.hasNext()) {
-
- String[] iface = (String[]) it.next();
-
+ String[] ifaceInfo = (String[]) it.next();
if (change) {
cssclass = "darkgrey";
change = false;
@@ -117,24 +188,70 @@
cssclass = "lightgrey";
change = true;
}
- String descr = iface[3];
- if (descr.length() > 15) {
- descr = descr.substring(0, 15);
- }
- out.println("<tr class=\"" + cssclass + "\" >");
- out.println("<td>");
- out.println("<a href=\"?Edit=true&id=" + iface[7] +
"\" >" + descr
- + "-" + iface[2] + "-" + iface[1] +
"</a>");
- out.println("</td>");
- out.println("<td>" + getMetric(iface[8]) + "</td>");
- out.println("<td>" + iface[4] + "</td>");
- out.println("<td><a href=\"?Remove=true&id=" +
iface[7]
- + "\" > Remove </a> </td>");
+
+ String utilIn=ifaceInfo[4].equals("true")?"<td
style=\"text-align:center;\" onmouseover=\"setTip(null,'" + ifaceInfo[5]+
"','#D5E9D4')\"><img src=\"tick.gif\" align=\"middle\"
alt=\"tick\"></img></td>":"<td></td>";
+ String utilOut=ifaceInfo[6].equals("true")?"<td
style=\"text-align:center;\" onmouseover=\"setTip(null,'" + ifaceInfo[7]+
"','#D5E9D4')\"><img src=\"tick.gif\" align=\"middle\"
alt=\"tick\"></img></td>":"<td></td>";
+ String errors=ifaceInfo[9].equals("true")?"<td
style=\"text-align:center;\" onmouseover=\"setTip(null,'" + ifaceInfo[10]+
"','#D5E9D4')\"><img src=\"tick.gif\" align=\"middle\"
alt=\"tick\"></img></td>":"<td></td>";
+ String discards=ifaceInfo[11].equals("true")?"<td
style=\"text-align:center;\" onmouseover=\"setTip(null,'" + ifaceInfo[12]+
"','#D5E9D4')\"><img src=\"tick.gif\" align=\"middle\"
alt=\"tick\"></img></td>":"<td></td>";
+ out.println("<tr class=\"" + cssclass + "\" >");
+ out.println("<td onmouseover=\"setTip(null,'" +
ifaceInfo[3]
+ + "','#D5E9D4')\">" + ifaceInfo[0] +
" </td><td>"
+ + ifaceInfo[1] + "</td><td>" +
ifaceInfo[2]
+ +
"</td>"+utilIn+utilOut+errors+discards);
out.println("</tr>");
-
}

+ out.println("</table>");
out.println("</div>");
+ out.println("</td></tr>");
+ out.println("</table>");
+ out.println("</div>");
+
+ out.println("</div>");
+
+ /*
+ * out.println("<table >"); out.println("<tr
class=\"headerlavender\" >");
+ * out .println("<td>Inteface Management</td><td><a
+ * href=\"?Add=true\">Add Interface</a>&nbsp;&nbsp;&nbsp; <a
+ * href=\"?Manage=true\">Manage Config file</a></td> ");
out.println("</tr>");
+ * out.println("<form action=\"MetadataAdmin\"
method=\"POST\" >");
+ * out.println("<tr class=\"headerlavender\" >");
out.println("<td>Host
+ * Name <select name=\"Host\">"); Iterator it =
hosts.iterator(); while
+ * (it.hasNext()) { String name = (String) it.next();
out.println("<option
+ * value=\"" + name + "\">" + name + "</option>"); }
out.println("<option
+ * value=\"Any\">Any</option>"); out.println("</select>
Metric:<select
+ * name=\"metric\">"); out.println("<option
+ * value=\"netutil\">Utilization</option>");
out.println("<option
+ * value=\"errors\">Errors</option>"); out.println("<option
+ * value=\"discards\">Discards</option>");
out.println("</select></td>");
+ * out .println("<td><input type=\"submit\" name=\"sort\"
+ * value=\"Fetch\" ></input><input type=\"reset\"
value=\"Reset\"></input></td>");
+ *
+ * out.println("</form>"); out.println("</tr>");
out.println("</table>");
+ * out.println("</div>");
+ *
+ * out.println("<div id=\"ifaces\" >");
out.println("<table>");
+ * out.println("<tr class=\"headerlavender\" >"); out
.println("<td>Interface</td><td>Metric</td><td>Direction</td><td>Action</td>");
+ * out.println("</tr>"); boolean change = false; String
cssclass =
+ * "lightgrey"; // Collections.sort(ifaces.); it =
ifaces.iterator();
+ * while (it.hasNext()) {
+ *
+ * String[] iface = (String[]) it.next();
+ *
+ * if (change) { cssclass = "darkgrey"; change = false; }
else {
+ * cssclass = "lightgrey"; change = true; } String descr =
iface[3]; if
+ * (descr.length() > 15) { descr = descr.substring(0, 15); }
+ * out.println("<tr class=\"" + cssclass + "\" >");
out.println("<td>");
+ * out.println("<a href=\"?Edit=true&id=" + iface[7] + "\" >"
+ descr +
+ * "-" + iface[2] + "-" + iface[1] + "</a>");
out.println("</td>");
+ * out.println("<td>" + getMetric(iface[8]) + "</td>");
+ * out.println("<td>" + iface[4] + "</td>");
out.println("<td><a
+ * href=\"?Remove=true&id=" + iface[7] + "\" > Remove </a>
</td>");
+ * out.println("</tr>");
+ * }
+ *
+ * out.println("</div>");
+ */
out.println("</body>");
out.println("</html>");
out.close();
@@ -145,24 +262,23 @@
* @param data
* @throws IOException
*/
- public void interface_page(String[] meta, String[] dat)
- throws IOException {
- String action="Edit";
+ public void interface_page(String[] meta, String[] dat) throws
IOException {
+ String action = "Edit";
String[] metadata;
String[] data;
if (meta == null) {
- action="Add";
+ action = "Add";
metadata = new String[9];
data = new String[9];
- for(int i=0;i<metadata.length;i++){
- metadata[i]="";
+ for (int i = 0; i < metadata.length; i++) {
+ metadata[i] = "";
}
- for(int i=0;i<data.length;i++){
- data[i]="";
+ for (int i = 0; i < data.length; i++) {
+ data[i] = "";
}
- }else{
- metadata=meta;
- data=dat;
+ } else {
+ metadata = meta;
+ data = dat;
}
preempt();
out.println("<div id=\"interface_info\">");
@@ -201,7 +317,7 @@
.println("<td>Authentication
Realm</td><td><input type=\"text\" size=60 name=\"authRealm\" value=\""
+ metadata[5] + "\" /></td>");
out.println("</tr>");
-
+
out.println("<tr>");
out
.println("<td>Capacity</td><td><input
type=\"text\" size=60 name=\"Capacity\" value=\""
@@ -210,29 +326,26 @@
out.println("<tr>");
out.println("<td>Metric</td>");
out.println("<td><select name=\"metric\">");
- String metric =metrics.get(metadata[8].trim());
- String selected="";
- if(metric!=null){
- selected= metric.equals("netutil") ? "selected='selected'"
- : "";
- out.println("<option " + selected
- + " value=\"netutil\">Utilization</option>");
- selected = metric.equals("errors") ? "selected='selected'"
- : "";
- out.println("<option " + selected
- + " value=\"errors\">Errors</option>");
- selected = metric.equals("discards") ? "selected='selected'"
- : "";
-
- out.println("<option " + selected
- + " value=\"discards\">Discards</option>");
- }else{
+ String metric = metrics.get(metadata[8].trim());
+ String selected = "";
+ if (metric != null) {
+ selected = metric.equals("netutil") ?
"selected='selected'" : "";
+ out.println("<option " + selected
+ + "
value=\"netutil\">Utilization</option>");
+ selected = metric.equals("errors") ?
"selected='selected'" : "";
+ out.println("<option " + selected
+ + "
value=\"errors\">Errors</option>");
+ selected = metric.equals("discards") ?
"selected='selected'" : "";
+
+ out.println("<option " + selected
+ + "
value=\"discards\">Discards</option>");
+ } else {
out.println("<option
value=\"netutil\">Utilization</option>");
out.println("<option
value=\"errors\">Errors</option>");
out.println("<option
value=\"discards\">Discards</option>");
}
out.println("</select></td>");
-
+
out.println("</tr>");
out.println("</table>");

@@ -254,62 +367,59 @@
out.println("<tr>");
out.println("<td>Value Units</td>");
out.println("<td><select name=\"valueUnits\">");
- if(metric!=null){
- selected = metrics.get(metadata[8].trim()).equals("netutil")
? "selected='selected'"
- : "";
- out.println("<option " + selected
- + " value=\"Bps\">Bps</option>");
- selected = metrics.get(metadata[8].trim()).equals("errors") ?
"selected='selected'"
- : "";
- out.println("<option " + selected
- + " value=\"Eps\">Eps</option>");
- selected = metrics.get(metadata[8].trim()).equals("discards")
? "selected='selected'"
- : "";
- out.println("<option " + selected
- + " value=\"Dps\">Dps</option>");
- }else{
+ if (metric != null) {
+ selected =
metrics.get(metadata[8].trim()).equals("netutil") ? "selected='selected'"
+ : "";
+ out.println("<option " + selected + "
value=\"Bps\">Bps</option>");
+ selected =
metrics.get(metadata[8].trim()).equals("errors") ? "selected='selected'"
+ : "";
+ out.println("<option " + selected + "
value=\"Eps\">Eps</option>");
+ selected =
metrics.get(metadata[8].trim()).equals("discards") ? "selected='selected'"
+ : "";
+ out.println("<option " + selected + "
value=\"Dps\">Dps</option>");
+ } else {
out.println("<option value=\"Bps\">Bps</option>");
out.println("<option value=\"Eps\">Eps</option>");
out.println("<option value=\"Dps\">Dps</option>");
}
-
+
out.println("</select></td>");
out.println("</tr>");
out.println("<tr>");
out.println("<td>Event Type</td>");
out.println("<td><select name=\"eventType\">");
- if(metric!=null){
- selected = metrics.get(metadata[8].trim()).equals("netutil")
? "selected='selected'"
- : "";
- out
- .println("<option "
- + selected
- + "
value=\"http://ggf.org/ns/nmwg/characteristic/utilization/2.0\";>http://ggf.org/ns/nmwg/characteristic/utilization/2.0</option>");
- selected = metrics.get(metadata[8].trim()).equals("errors") ?
"selected='selected'"
- : "";
- out
- .println("<option "
- + selected
- + "
value=\"http://ggf.org/ns/nmwg/characteristic/errors/2.0\";>http://ggf.org/ns/nmwg/characteristic/errors/2.0</option>");
- selected = metrics.get(metadata[8].trim()).equals("discards")
? "selected='selected'"
- : "";
- out
- .println("<option "
- + selected
- + "
value=\"http://ggf.org/ns/nmwg/characteristic/discards/2.0\";>http://ggf.org/ns/nmwg/characteristic/discards/2.0</option>");
- }else{
+ if (metric != null) {
+ selected =
metrics.get(metadata[8].trim()).equals("netutil") ? "selected='selected'"
+ : "";
out
.println("<option "
+ selected
+ "
value=\"http://ggf.org/ns/nmwg/characteristic/utilization/2.0\";>http://ggf.org/ns/nmwg/characteristic/utilization/2.0</option>");
+ selected =
metrics.get(metadata[8].trim()).equals("errors") ? "selected='selected'"
+ : "";
out
.println("<option "
+ selected
+ "
value=\"http://ggf.org/ns/nmwg/characteristic/errors/2.0\";>http://ggf.org/ns/nmwg/characteristic/errors/2.0</option>");
+ selected =
metrics.get(metadata[8].trim()).equals("discards") ? "selected='selected'"
+ : "";
out
.println("<option "
+ selected
+ "
value=\"http://ggf.org/ns/nmwg/characteristic/discards/2.0\";>http://ggf.org/ns/nmwg/characteristic/discards/2.0</option>");
+ } else {
+ out
+ .println("<option "
+ + selected
+ + "
value=\"http://ggf.org/ns/nmwg/characteristic/utilization/2.0\";>http://ggf.org/ns/nmwg/characteristic/utilization/2.0</option>");
+ out
+ .println("<option "
+ + selected
+ + "
value=\"http://ggf.org/ns/nmwg/characteristic/errors/2.0\";>http://ggf.org/ns/nmwg/characteristic/errors/2.0</option>");
+ out
+ .println("<option "
+ + selected
+ + "
value=\"http://ggf.org/ns/nmwg/characteristic/discards/2.0\";>http://ggf.org/ns/nmwg/characteristic/discards/2.0</option>");
}
out.println("</select></td>");
out.println("</tr>");
@@ -339,14 +449,17 @@
+ data[8] + "\" /></td>");
out.println("</tr>");
out.println("<tr>");
+ out.println("<td></td><td>");
out
- .println("<td></td><td>");
- out.println("<input type=\"submit\" value=\""+action+"\"
name=\"Create\" /><input type=\"reset\" value=\"Reset\" name=\"Reset\" />");
+ .println("<input type=\"submit\" value=\""
+ + action
+ + "\" name=\"Create\"
/><input type=\"reset\" value=\"Reset\" name=\"Reset\" />");
out.println("</tr>");
-
+
out.println("</table>");
- if (action.equals("Edit")){
- out.println("<input type=\"hidden\" name=\"id\"
value=\""+metadata[7]+"\" />");
+ if (action.equals("Edit")) {
+ out.println("<input type=\"hidden\" name=\"id\"
value=\""
+ + metadata[7] + "\" />");
}
out.println("</form>");
out.println("</div>");
@@ -370,7 +483,8 @@
.println("<td>Are you sure you want to remove
the interface?</td><td><input type=\"submit\" name=\"Delete\"
value=\"Yes\"/><input type=\"submit\" name=\"Delete\" value=\"No\"/></td>");
out.println("</tr>");
out.println("</table>");
- out.println("<input type=\"hidden\" name=\"id\"
value=\""+id+"\" >");
+ out.println("<input type=\"hidden\" name=\"id\" value=\"" +
id
+ + "\" >");
out.println("</form>");
out.println("</div>");
out.println("</body>");
@@ -385,6 +499,7 @@
* @param metric
* @return
*/
+ @SuppressWarnings("unused")
private String getMetric(String metric) {

return (String) metrics.get(metric.trim());
@@ -404,8 +519,8 @@
out.println("</title>");
out.println("</head>");
out.println("<body>");
- // out.println("<script src=\"Service_Admin.js\">\n" +
"</script>\n");
- // out.println("<script src=\"wz_tooltip.js\">\n" +
"</script>\n");
+ out.println("<script src=\"Service_Admin.js\">\n" +
"</script>\n");
+ out.println("<script src=\"wz_tooltip.js\">\n" +
"</script>\n");

}

@@ -419,7 +534,8 @@
.println("<td>Would you like to create a new
metadata configuration file?<input type=\"text\" name=\"fileName\" size=20
/>.xml</td><td><input type=\"submit\" name=\"CreateFile\"
value=\"Create\"/></td>");
out.println("</tr>");
out.println("</form>");
- out.println("<form action=\"MetadataAdmin\" method=\"POST\"
ENCTYPE=\"multipart/form-data\" > ");
+ out
+ .println("<form action=\"MetadataAdmin\"
method=\"POST\" ENCTYPE=\"multipart/form-data\" > ");
out.println("<tr>");
out
.println("<td>Would you like to upload a new
metadata configuration file?<input type=\"file\" size=0 name=\"file\"
value=\"\"/><td><input type=\"submit\" size name=\"Upload\"
value=\"Upload\"/></td>");
@@ -430,7 +546,7 @@
out.println("</body>");
out.println("</html>");
out.close();
-
+
}

}

Modified:
branches/WebAdmin/perfSONARWebAdmin/auxiliary/stitching/MetadataManager.java
===================================================================
---
branches/WebAdmin/perfSONARWebAdmin/auxiliary/stitching/MetadataManager.java
2008-07-31 13:04:54 UTC (rev 4320)
+++
branches/WebAdmin/perfSONARWebAdmin/auxiliary/stitching/MetadataManager.java
2008-08-01 09:50:40 UTC (rev 4321)
@@ -42,6 +42,34 @@
* @return
* @throws Exception
*/
+
+ /**
+ * @param host
+ * @return
+ * @throws Exception
+ */
+ public String getNumberOfIfacesByHost(String host) throws Exception;
+
+ /**
+ * @param host
+ * @return
+ * @throws Exception
+ */
+ public String getNumberOfDataByHost(String host) throws Exception;
+
+ /**
+ * @param host
+ * @return
+ * @throws Exception
+ */
+ public List getAvailableMetricsByHost(String host) throws Exception;
+
+ /**
+ * @param hostname
+ * @param metric
+ * @return
+ * @throws Exception
+ */
public List getIfacesbyHostnameMetric(String hostname, String metric)
throws Exception;

@@ -93,7 +121,7 @@
* @return
* @throws Exception
*/
- public String getData(String id) throws Exception;
+ public List getData(String id) throws Exception;

/**
* @param id
@@ -144,5 +172,11 @@
* @throws Exception
*/
public void addConfigFile(File file) throws Exception;
+
+ /**
+ * @return
+ * @throws Exception
+ */
+ public String getFile() throws Exception;

}

Modified:
branches/WebAdmin/perfSONARWebAdmin/auxiliary/stitching/MetadataManagerImpl.java
===================================================================
---
branches/WebAdmin/perfSONARWebAdmin/auxiliary/stitching/MetadataManagerImpl.java
2008-07-31 13:04:54 UTC (rev 4320)
+++
branches/WebAdmin/perfSONARWebAdmin/auxiliary/stitching/MetadataManagerImpl.java
2008-08-01 09:50:40 UTC (rev 4321)
@@ -2,6 +2,7 @@

import java.io.File;
import java.util.HashMap;
+import java.util.Hashtable;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
@@ -29,6 +30,8 @@

private static String pass;

+ private static String Document;
+
private static String driver = "org.exist.xmldb.DatabaseImpl";

private Collection collection;
@@ -43,11 +46,12 @@
* @param password
* @throws Exception
*/
- public MetadataManagerImpl(String uri, String username, String
password)
- throws Exception {
+ public MetadataManagerImpl(String uri, String document, String
username,
+ String password) throws Exception {
URI = uri;
user = username;
pass = password;
+ Document = document;
metrics = new HashMap<String, String>();
metrics.put("netutil",

"http://ggf.org/ns/nmwg/characteristic/utilization/2.0";);
@@ -98,7 +102,9 @@
public List getHostnames() throws Exception {
List<String> hostList = new LinkedList<String>();
CompiledExpression expr = service
- .compile("for $meta in
/nmwg:store//nmwg:metadata return data($meta//nmwgt:hostName)");
+ .compile("for $meta in doc(\""
+ + Document
+ +
"\")/nmwg:store//nmwg:metadata return data($meta//nmwgt:hostName)");
ResourceSet set = service.execute(expr);
ResourceIterator it = set.getIterator();
while (it.hasMoreResources()) {
@@ -118,8 +124,8 @@
*/
public List getIfaces() throws Exception {
List<String> ifaceList = new LinkedList<String>();
- CompiledExpression expr = service
- .compile("for $meta in
/nmwg:store//nmwg:metadata return $meta");
+ CompiledExpression expr = service.compile("for $meta in
doc(\""
+ + Document + "\")/nmwg:store//nmwg:metadata
return $meta");
ResourceSet set = service.execute(expr);
ResourceIterator it = set.getIterator();
while (it.hasMoreResources()) {
@@ -141,7 +147,9 @@

List<String> ifaceList = new LinkedList<String>();
CompiledExpression expr = service
- .compile("for $meta in
/nmwg:store//nmwg:metadata where data($meta//nmwgt:hostName)='"
+ .compile("for $meta in doc(\""
+ + Document
+ +
"\")/nmwg:store//nmwg:metadata where data($meta//nmwgt:hostName)='"
+ hostname + "' return
$meta");
ResourceSet set = service.execute(expr);
ResourceIterator it = set.getIterator();
@@ -164,11 +172,10 @@
public List getIfacesbyHostnameMetric(String hostname, String metric)
throws Exception {
List<String> ifaceList = new LinkedList<String>();
- CompiledExpression expr = service
- .compile("for $meta in
/nmwg:store//nmwg:metadata where data($meta/"
- + metric.trim()
- +
":subject//nmwgt:hostName)='"
- + hostname.trim() + "' return
$meta");
+ CompiledExpression expr = service.compile("for $meta in
doc(\""
+ + Document + "\")/nmwg:store//nmwg:metadata
where data($meta/"
+ + metric.trim() +
":subject//nmwgt:hostName)='"
+ + hostname.trim() + "' return $meta");
ResourceSet set = service.execute(expr);
ResourceIterator it = set.getIterator();
while (it.hasMoreResources()) {
@@ -189,9 +196,9 @@
public List getIfacesbyMetric(String metric) throws Exception {

List<String> ifaceList = new LinkedList<String>();
- CompiledExpression expr = service
- .compile("for $meta in
/nmwg:store//nmwg:metadata where $meta/"
- + metric.trim() + ":subject
return $meta");
+ CompiledExpression expr = service.compile("for $meta in
doc(\""
+ + Document + "\")/nmwg:store//nmwg:metadata
where $meta/"
+ + metric.trim() + ":subject return $meta");
ResourceSet set = service.execute(expr);
ResourceIterator it = set.getIterator();
while (it.hasMoreResources()) {
@@ -212,11 +219,15 @@
public void removeIfacesbyHostname(String hostname) throws Exception {

CompiledExpression expr = service
- .compile("for $meta in
/nmwg:store//nmwg:metadata let $data
:=/nmwg:store//nmwg:data[@metadataIdRef=$meta/@id]
where data($meta//nmwgt:hostName)='"
+ .compile("for $meta in doc(\""
+ + Document
+ +
"\")/nmwg:store//nmwg:metadata let $data
:=/nmwg:store//nmwg:data[@metadataIdRef=$meta/@id]
where data($meta//nmwgt:hostName)='"
+ hostname + "' return update
delete $data ");
service.execute(expr);
expr = service
- .compile("for $meta in
/nmwg:store//nmwg:metadata where data($meta//nmwgt:hostName)='"
+ .compile("for $meta in doc(\""
+ + Document
+ +
"\")/nmwg:store//nmwg:metadata where data($meta//nmwgt:hostName)='"
+ hostname + "' return update
delete $meta ");
service.execute(expr);

@@ -231,16 +242,16 @@
public void removeIfacesbyHostnameMetric(String hostname, String
metric)
throws Exception {
CompiledExpression expr = service
- .compile("for $meta in
/nmwg:store//nmwg:metadata let $data
:=/nmwg:store//nmwg:data[@metadataIdRef=$meta/@id]
where data($meta/"
- + metric.trim()
- +
":subject//nmwgt:hostName)='"
+ .compile("for $meta in doc(\""
+ + Document
+ +
"\")/nmwg:store//nmwg:metadata let $data
:=/nmwg:store//nmwg:data[@metadataIdRef=$meta/@id]
where data($meta/"
+ + metric.trim() +
":subject//nmwgt:hostName)='"
+ hostname + "' return update
delete $data ");
service.execute(expr);
- expr = service
- .compile("for $meta in
/nmwg:store//nmwg:metadata where data($meta/"
- + metric.trim()
- +
":subject//nmwgt:hostName)='"
- + hostname + "' return update
delete $meta ");
+ expr = service.compile("for $meta in doc(\"" + Document
+ + "\")/nmwg:store//nmwg:metadata where
data($meta/"
+ + metric.trim() +
":subject//nmwgt:hostName)='" + hostname
+ + "' return update delete $meta ");
service.execute(expr);

}
@@ -253,30 +264,38 @@
public void removeIfacesbyMetric(String metric) throws Exception {

CompiledExpression expr = service
- .compile("for $meta in
/nmwg:store//nmwg:metadata let $data
:=/nmwg:store//nmwg:data[@metadataIdRef=$meta/@id]
where $meta/"
+ .compile("for $meta in doc(\""
+ + Document
+ +
"\")/nmwg:store//nmwg:metadata let $data
:=/nmwg:store//nmwg:data[@metadataIdRef=$meta/@id]
where $meta/"
+ metric.trim() + ":subject
return update delete $data");
service.execute(expr);
- expr = service
- .compile("for $meta in
/nmwg:store//nmwg:metadata where $meta/"
- + metric.trim() + ":subject
return update delete $meta");
+ expr = service.compile("for $meta in doc(\"" + Document
+ + "\")/nmwg:store//nmwg:metadata where
$meta/" + metric.trim()
+ + ":subject return update delete $meta");
service.execute(expr);

}

- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see
perfSONARWebAdmin.auxiliary.stitching.MetadataManager#removeIfacebyId(java.lang.String)
*/
public void removeIfacebyId(String id) throws Exception {
-

CompiledExpression expr = service
- .compile("for $meta in
/nmwg:store//nmwg:metadata let $data
:=/nmwg:store//nmwg:data[@metadataIdRef=$meta/@id]
where
$meta[@id='"+id+"']
return update delete $data");
+ .compile("for $meta in doc(\""
+ + Document
+ +
"\")/nmwg:store//nmwg:metadata let $data
:=/nmwg:store//nmwg:data[@metadataIdRef=$meta/@id]
where
$meta[@id='"
+ + id + "'] return update
delete $data");
service.execute(expr);
- expr = service
- .compile("for $meta in
/nmwg:store//nmwg:metadata where
$meta[@id='"+id+"']
return update delete $meta");
+ expr = service.compile("for $meta in doc(\"" + Document
+ + "\")/nmwg:store//nmwg:metadata where
$meta[@id='"
+ id
+ + "'] return update delete $meta");
service.execute(expr);
-
+
}
+
/*
* (non-Javadoc)
*
@@ -289,9 +308,10 @@
String dat = createData(data, id, metric);
System.out.println(dat);
CompiledExpression expr = service.compile("update insert " +
meta
- + " into /nmwg:store ");
+ + " into doc(\"" + Document + "\")/nmwg:store
");
service.execute(expr);
- expr = service.compile("update insert " + dat + " into
/nmwg:store ");
+ expr = service.compile("update insert " + dat + " into doc(\""
+ + Document + "\")/nmwg:store ");
service.execute(expr);
}

@@ -308,13 +328,13 @@
String dat = createData(data, id, metric);
System.out.println(dat);

- CompiledExpression expr = service
- .compile("update replace
/nmwg:store/nmwg:metadata[@id='"
+ id
- + "'] with " + meta + " ");
+ CompiledExpression expr = service.compile("update replace
doc(\""
+ + Document +
"\")/nmwg:store/nmwg:metadata[@id='"
+ id
+ + "'] with " + meta + " ");
service.execute(expr);
- expr = service
- .compile("update replace
/nmwg:store/nmwg:data[@metadataIdRef='"
- + id + "'] with " + dat + "
");
+ expr = service.compile("update replace doc(\"" + Document
+ +
"\")/nmwg:store/nmwg:data[@metadataIdRef='"
+ id + "'] with "
+ + dat + " ");
service.execute(expr);

}
@@ -324,19 +344,20 @@
*
* @see
perfSONARWebAdmin.auxiliary.stitching.MetadataManager#getData(java.lang.String)
*/
- public String getData(String id) throws XMLDBException {
-
- CompiledExpression expr = service
- .compile("for $data in /nmwg:store/nmwg:data
where
$data[@metadataIdRef='"
- + id + "'] return $data");
+ public List getData(String id) throws XMLDBException {
+ LinkedList data = new LinkedList();
+ CompiledExpression expr = service.compile("for $data in
doc(\""
+ + Document
+ + "\")/nmwg:store/nmwg:data where
$data[@metadataIdRef='"
+ id
+ + "'] return $data");
ResourceSet set = service.execute(expr);
ResourceIterator it = set.getIterator();
- if (it.hasMoreResources()) {
+ while (it.hasMoreResources()) {
Resource r = it.nextResource();

- return (String) r.getContent();
- } else
- return null;
+ data.add((String) r.getContent());
+ }
+ return data;

}

@@ -347,9 +368,9 @@
*/
public String getIfacebyId(String id) throws Exception {

- CompiledExpression expr = service
- .compile("for $meta in
/nmwg:store/nmwg:metadata where
$meta[@id='"
- + id.trim() + "'] return
$meta ");
+ CompiledExpression expr = service.compile("for $meta in
doc(\""
+ + Document + "\")/nmwg:store/nmwg:metadata
where
$meta[@id='"
+ + id.trim() + "'] return $meta ");
ResourceSet set = service.execute(expr);
ResourceIterator it = set.getIterator();
if (it.hasMoreResources()) {
@@ -369,11 +390,10 @@
*/
public String[] getIfaceByNameMetric(String name, String metric)
throws Exception {
- CompiledExpression expr = service
- .compile(" for $meta in
/nmwg:store/nmwg:metadata where $meta/"
- + metric.trim()
- +
":subject/nmwgt:interface[nmwgt:ifName='"
- + name.trim() + "'] return
$meta");
+ CompiledExpression expr = service.compile(" for $meta in
doc(\""
+ + Document + "\")/nmwg:store/nmwg:metadata
where $meta/"
+ + metric.trim() +
":subject/nmwgt:interface[nmwgt:ifName='"
+ + name.trim() + "'] return $meta");
ResourceSet set = service.execute(expr);
ResourceIterator it = set.getIterator();
String[] iface = new String[2];
@@ -396,11 +416,10 @@
public String[] getIfacebyAddresMetric(String address, String metric)
throws Exception {

- CompiledExpression expr = service
- .compile(" for $meta in
/nmwg:store/nmwg:metadata where $meta/"
- + metric.trim()
- +
":subject/nmwgt:interface[nmwgt:ifAddress='"
- + address.trim() + "'] return
$meta ");
+ CompiledExpression expr = service.compile(" for $meta in
doc(\""
+ + Document + "\")/nmwg:store/nmwg:metadata
where $meta/"
+ + metric.trim() +
":subject/nmwgt:interface[nmwgt:ifAddress='"
+ + address.trim() + "'] return $meta ");
ResourceSet set = service.execute(expr);
ResourceIterator it = set.getIterator();
String[] iface = new String[2];
@@ -422,7 +441,9 @@
*/
public List getIfaceByName(String name) throws Exception {
CompiledExpression expr = service
- .compile("for $meta in
/nmwg:store/nmwg:metadata where $meta//nmwgt:interface[nmwgt:ifName='"
+ .compile("for $meta in doc(\""
+ + Document
+ +
"\")/nmwg:store/nmwg:metadata where $meta//nmwgt:interface[nmwgt:ifName='"
+ name.trim() + "'] return
$meta ");
ResourceSet set = service.execute(expr);
ResourceIterator it = set.getIterator();
@@ -442,7 +463,9 @@
*/
public List getIfacebyAddres(String address) throws Exception {
CompiledExpression expr = service
- .compile("for $meta in
/nmwg:store/nmwg:metadata where $meta//nmwgt:interface[nmwgt:ifAddress='"
+ .compile("for $meta in doc(\""
+ + Document
+ +
"\")/nmwg:store/nmwg:metadata where $meta//nmwgt:interface[nmwgt:ifAddress='"
+ address.trim() + "'] return
$meta ");
ResourceSet set = service.execute(expr);
ResourceIterator it = set.getIterator();
@@ -455,7 +478,9 @@

}

- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see
perfSONARWebAdmin.auxiliary.stitching.MetadataManager#addConfigFile(java.io.File)
*/
public void addConfigFile(File file) throws Exception {
@@ -463,16 +488,104 @@
.getName(), "XMLResource");
document.setContent(file);
collection.storeResource(document);
-
+
}

- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see
perfSONARWebAdmin.auxiliary.stitching.MetadataManager#removeConfigFile(java.lang.String)
*/
public void removeConfigFile(String file) throws Exception {
+ try {
+
collection.removeResource(collection.getResource(file));
+ } catch (Exception e) {
+ throw new Exception(file + " " + getFault(e));
+ }
+ }
+
+
+
+ /* (non-Javadoc)
+ * @see
perfSONARWebAdmin.auxiliary.stitching.MetadataManager#getAvailableMetricsByHost(java.lang.String)
+ */
+ public List getAvailableMetricsByHost(String host) throws Exception {

- collection.removeResource(collection.getResource(file));
+ CompiledExpression expr = service
+ .compile("for $meta in doc(\""
+ + Document
+ + "\")/nmwg:store/nmwg:metadata where
$meta//nmwgt:interface[nmwgt:hostName='"
+ + host.trim() + "'] return
$meta/nmwg:eventType/text()");
+
+ ResourceSet set = service.execute(expr);
+ ResourceIterator it = set.getIterator();
+ LinkedList list = new LinkedList();
+ while (it.hasMoreResources()) {
+ String metric = (String)
it.nextResource().getContent();
+ if(!list.contains(metric.trim())){
+ list.add(metric);
+ }
+
+ }
+
+
+ return list;
+
}
+
+ /* (non-Javadoc)
+ * @see
perfSONARWebAdmin.auxiliary.stitching.MetadataManager#getNumberOfDataByHost(java.lang.String)
+ */
+ public String getNumberOfDataByHost(String host) throws Exception {
+ CompiledExpression expr = service.compile("count((doc(\""
+ + Document +
"\")/nmwg:store//nmwg:metadata//nmwgt:interface[nmwgt:hostName='"+host+"']/nmwgt:ifAddress))");
+ ResourceSet set = service.execute(expr);
+ ResourceIterator it = set.getIterator();
+ String number="";
+ while (it.hasMoreResources()) {
+ Resource r = it.nextResource();
+ number=(String)r.getContent();
+ }
+
+ return number;
+ }
+
+ /* (non-Javadoc)
+ * @see
perfSONARWebAdmin.auxiliary.stitching.MetadataManager#getNumberOfIfacesByHost(java.lang.String)
+ */
+ public String getNumberOfIfacesByHost(String host) throws Exception {
+ CompiledExpression expr =
service.compile("count(fn:distinct-values(doc(\""
+ + Document +
"\")/nmwg:store//nmwg:metadata//nmwgt:interface[nmwgt:hostName='"+host+"']/nmwgt:ifAddress))");
+ ResourceSet set = service.execute(expr);
+ ResourceIterator it = set.getIterator();
+ String number="";
+ while (it.hasMoreResources()) {
+ Resource r = it.nextResource();
+ number=(String)r.getContent();
+ }
+
+ return number;
+ }
+
+
+ /* (non-Javadoc)
+ * @see
perfSONARWebAdmin.auxiliary.stitching.MetadataManager#getFile()
+ */
+ public String getFile() throws Exception {
+
+ CompiledExpression expr = service.compile("doc(\""
+ + Document + "\")/nmwg:store ");
+ ResourceSet set = service.execute(expr);
+ ResourceIterator it = set.getIterator();
+ if (it.hasMoreResources()) {
+ Resource r = it.nextResource();
+
+ return (String) r.getContent();
+ } else
+ return null;
+ }
+
+
/**
* @param data
* @param id
@@ -520,44 +633,74 @@
+ "</nmwgt:ifName>\n" + "
<nmwgt:ifDescription>"
+ metadata[3] + "</nmwgt:ifDescription>\n"
+ " <nmwgt:direction>" + metadata[4]
- + "</nmwgt:direction>\n" + "
<nmwgt:authRealm>"
- + metadata[5] + "</nmwgt:authRealm>\n"
+ " <nmwgt:capacity>" + metadata[6]
+ "</nmwgt:capacity>\n" + "
</nmwgt:interface>\n" + " </"
+ metric.trim() + ":subject>\n" + "
<nmwg:eventType>"
+ metrics.get(metric) + "</nmwg:eventType>\n"
+ +"<nmwg:parameters
id=\""+(Math.random()*1000000000)+"\">"
+ +"<nmwg:parameter name=\"keyword\"
type=\"project\">"+metadata[5]+"</nmwg:parameter>"
+ +"</nmwg:parameters>"
+ " </nmwg:metadata>\n\n ";
}

+ /**
+ * 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;
+ }
+
public static void main(String[] argv) {

try {
MetadataManager manager = new MetadataManagerImpl(

"xmldb:exist://perfsonar.srv.cynet.ac.cy:8080/exist/xmlrpc/db/rrdmaconfig",
- "rrdmaservice", "perfsonar");
- Iterator it
=manager.getIfacesbyMetric("netutil").iterator();
- while (it.hasNext()) {
- System.out.println(it.next());
- }
- //String iface =
manager.getIfacebyId("metaUtilsIn0.316771742262976");
+ "Cynet_RRDMA_Config.xml",
"rrdmaservice", "perfsonar");
+
System.out.println(manager.getNumberOfIfacesByHost("CyNet LEF switch"));
+ List list=manager.getAvailableMetricsByHost("CyNet LEF
switch");
+ Iterator it=list.iterator();
+ while(it.hasNext()){
+ System.out.println(it.next());
+ }
+ System.out.println(manager.getFile());
+ /*Iterator it = manager.getIfacesbyHostname("CyNet
LEF switch").iterator();
+ ElementParser parser = new ElementParser();
+ Hashtable list= new Hashtable();
+ int num=0;
+ while (it.hasNext()) {
+ //System.out.println(it.next());
+ String[] info
=parser.parseMetaData((String)it.next());
+ list.put(info[1]," ");
+ num++;
+ }
+ System.out.println(num);
+ System.out.println(list.size());*/
+ // String iface =
+ //
manager.getIfacebyId("metaUtilsIn0.316771742262976");
// String
dat=manager.getData("metaUtilsIn0.316771742262976");
// System.out.println(iface);
// System.out.println(dat);
- /*ElementParser parser = new ElementParser();
- String[] info = parser.parseMetaData(iface);
- info[7] = info[7] + "hello";
- String[] data = new String[9];
- data[0] =
"/var/www/html/cacti/cynets_border_router_traffic_in_8.rrd";
- data[1] = "errors_in";
- data[2] = "Eps";
- data[3] =
"http://ggf.org/ns/nmwg/characteristic/utilization/2.0";;
- data[4] = "300";
- data[5] = "ABSOLUTE";
- data[6] = "400";
- data[7] = "0";
- data[8] = "10000000";
-
- manager.addIface(info, data, info[7], "errors");*/
+ /*
+ * ElementParser parser = new ElementParser();
String[] info =
+ * parser.parseMetaData(iface); info[7] = info[7] +
"hello";
+ * String[] data = new String[9]; data[0] =
+ *
"/var/www/html/cacti/cynets_border_router_traffic_in_8.rrd";
+ * data[1] = "errors_in"; data[2] = "Eps"; data[3] =
+ *
"http://ggf.org/ns/nmwg/characteristic/utilization/2.0";; data[4] =
+ * "300"; data[5] = "ABSOLUTE"; data[6] = "400";
data[7] = "0";
+ * data[8] = "10000000";
+ *
+ * manager.addIface(info, data, info[7], "errors");
+ */
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -577,7 +720,6 @@

}

-




Modified: branches/WebAdmin/perfSONARWebAdmin/auxiliary/stitching/test.java
===================================================================
--- branches/WebAdmin/perfSONARWebAdmin/auxiliary/stitching/test.java
2008-07-31 13:04:54 UTC (rev 4320)
+++ branches/WebAdmin/perfSONARWebAdmin/auxiliary/stitching/test.java
2008-08-01 09:50:40 UTC (rev 4321)
@@ -1,5 +1,24 @@
package perfSONARWebAdmin.auxiliary.stitching;

+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+
+import javax.xml.XMLConstants;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+import javax.xml.validation.Validator;
+
+import org.jdom.input.DOMBuilder;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
import org.xmldb.api.DatabaseManager;
import org.xmldb.api.base.Collection;
import org.xmldb.api.base.CompiledExpression;
@@ -9,8 +28,12 @@
import org.xmldb.api.base.XMLDBException;
import org.xmldb.api.modules.XQueryService;

-public class test {
+import com.thaiopensource.util.PropertyMapBuilder;
+import com.thaiopensource.validate.ValidateProperty;
+import com.thaiopensource.validate.ValidationDriver;

+public class test implements ErrorHandler {
+
/**
* @param args
* @throws ClassNotFoundException
@@ -21,8 +44,41 @@
public static void main(String[] args) throws ClassNotFoundException,
InstantiationException, IllegalAccessException, XMLDBException {
String driver = "org.exist.xmldb.DatabaseImpl";

- Collection collection;
+
+ DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
+ factory.setNamespaceAware(true);
+ DocumentBuilder builder = null;
+ DOMBuilder jbuilder = null;
+ try {
+ builder = factory.newDocumentBuilder();
+ jbuilder = new DOMBuilder();

+
+
+ StreamSource ss = new StreamSource(new
FileInputStream("Cynet_RRDMA_Config.xml"));
+ System.out.println("Doc parsed");
+ SchemaFactory schefactory =
SchemaFactory.newInstance(XMLConstants.RELAXNG_NS_URI);
+ Schema schema = schefactory.newSchema(new
File("MetadataKeyResponse.rng"));
+ Validator validator = schema.newValidator();
+ validator.validate((Source) ss);
+ /* PropertyMapBuilder _map = new
PropertyMapBuilder();
+ InputSource schemaIS = new InputSource(new
FileInputStream("MetadataKeyResponse.rng"));
+ ValidateProperty.ERROR_HANDLER.put(_map,new
test());
+ ValidationDriver _vd = new
ValidationDriver(_map.toPropertyMap());
+ if (_vd.loadSchema(schemaIS)) {
+ System.out.println(_vd.validate(IS));
+
+ }
+
+ }catch(Exception e){
+ e.printStackTrace();
+ }*/
+
+ }catch(Exception e){
+ System.out.println(e.getMessage());
+ }
+ /*Collection collection;
+
XQueryService service;
Class cl = Class.forName(driver);
Database database = (Database) cl.newInstance();
@@ -49,7 +105,24 @@
System.out.println(it.nextResource().getContent());
}

+*/
+

+
}

-}
+ public void error(SAXParseException arg0) throws SAXException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void fatalError(SAXParseException arg0) throws SAXException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void warning(SAXParseException arg0) throws SAXException {
+ // TODO Auto-generated method stub
+
+ }
+}
\ No newline at end of file

Modified: branches/WebAdmin/perfSONARWebAdmin/auxiliary/wizard/HTMLOutput.java
===================================================================
--- branches/WebAdmin/perfSONARWebAdmin/auxiliary/wizard/HTMLOutput.java
2008-07-31 13:04:54 UTC (rev 4320)
+++ branches/WebAdmin/perfSONARWebAdmin/auxiliary/wizard/HTMLOutput.java
2008-08-01 09:50:40 UTC (rev 4321)
@@ -222,7 +222,7 @@
preemptModified("default.css");
out.println("<div class=\"top\"><br>" + message +
"</br></div>");
out.println("<div id=\"properties\" class=\"properties\">");
- out.println("<form action=\"Wizard\" method=\"GET\"> ");
+ out.println("<form action=\"Wizard\" name=\"wizardForm\"
method=\"GET\" onsubmit=\"return checkStarFields()\" > ");
out
.println("<input type=\"hidden\"
name=\"function\" value=\"finish\" >");
while (groupIt.hasNext()) {
@@ -301,10 +301,52 @@

}

+ boolean check=false;
while (it.hasNext()) {
pr = pro.getWizardProperty((String)
it.next());
- this.showProperty(pr);
+ if(pr.getCheck()){
+ if(!check){
+ check=true;
+ }else{
+ out.println("</div>");
+ }
+ display = "none";
+ onClick = "
onclick=\"checkIt(this);\"";
+ out.println("<input type=\"hidden\"
value=\""
+ +
pr.getProposedValue() + "\" id=\"Vl_"
+ + pr.getKey() + "\"
/>");
+ id = pr.getKey();
+ out.println("<tr><td>" +
pr.getPropertyComment()
+ + "</td><td>&nbsp;");
+ String[] values =
pr.getAcceptedValues();
+ if (values != null) {
+
+ for (int i = 0; i <
values.length; i++) {
+ String checked =
!values[i].equals(pr
+
.getProposedValue()) ? "checked=\"checked\""
+ : "";
+ out.println("<input
type=\"radio\"" + checked
+ + "
name=\"" + pr.getKey() + "\" value=\""
+ +
values[i] + "\" " + onClick + ">"
+ +
values[i] + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</input>");
+ }
+ }
+ out.println("&nbsp;");
+ out.println("</td></tr>");
+ out.println("<tr ><td
colspan=\"2\"><div class=\"inner_properties\" id=\"" + id + "\"
style=\"display:"+ display + ";\"><table>");
+ }else{
+ if(pr.getDependency()==null && check){
+
out.println("</table></div></td></tr>");
+ check=false;
+ }
+ this.showProperty(pr);
+ }
+
+
}
+ if(check){
+ out.println("</table></div></td></tr>");
+ }

out.println("</table>");
out.println("</div>");
@@ -428,9 +470,12 @@
*/
private void showProperty(WizardProperty pr) throws IOException {

- String fill = " ";
+ String fill = "";
+
+ String required="";
if (pr.isRequired()) {
fill = "*";
+ required="required";
}
out.println("<tr><td>" + pr.getPropertyComment()+"<span
class=\"greenasterisk\" >"+fill+"</span></td><td>");
String[] values = pr.getAcceptedValues();
@@ -447,14 +492,16 @@
String type = "text";

String value=pr.getProposedValue();
+ String valueText="value=\""
+ + value+ " \"";
if (pr.isPassword()) {
type = "password";
+ valueText="value=\"\" ";
value="";
}
- out.println("<input class=\"input_style\"
onmouseover=\"setTip(null,'"
+ out.println("<input id=\""+required+"\"
class=\"input_style\" onmouseover=\"setTip(null,'"
+value + "','#D5E9D4')\" type=\"" +
type
- + "\" name=\"" + pr.getKey() + "\"
size=40 value=\""
- + value+ " \"/>");
+ + "\" name=\"" + pr.getKey() + "\"
size=40 "+valueText+" />");

}
out.println("</td></tr>");
@@ -471,6 +518,8 @@
+ "</script>\n"
+ "<script src=\"wz_tooltip.js\">"
+ "</script>\n"
+ +"<script src=\"Service_Admin.js\">"
+ + "</script>\n"
+ "<script type=\"text/javascript\">\n"
+ "function checkIt(el) {\n"
+ "if (el.value
==document.getElementById(\"Vl_\"+el.name).value) {\n"

Modified:
branches/WebAdmin/perfSONARWebAdmin/auxiliary/wizard/WizardProperties.java
===================================================================
---
branches/WebAdmin/perfSONARWebAdmin/auxiliary/wizard/WizardProperties.java
2008-07-31 13:04:54 UTC (rev 4320)
+++
branches/WebAdmin/perfSONARWebAdmin/auxiliary/wizard/WizardProperties.java
2008-08-01 09:50:40 UTC (rev 4321)
@@ -55,9 +55,11 @@
*
* order CDATA #REQUIRED
*
- * check (true|false) #IMPLIED >
+ * check (true|false) #IMPLIED
*
+ * dependsOn CDATA #IMPLIED >
*
+ *
* <!ELEMENT AcceptedValue (#PCDATA) > ]>
*
* @author Michalis Michael, CyNet
@@ -101,6 +103,8 @@
+ " order CDATA #REQUIRED \n"

+ " check (true|false) #IMPLIED \n"
+
+ +" dependsOn CDATA #IMPLIED \n"

+ ">\n"

@@ -313,7 +317,15 @@

pr.setGroup(property.getChild("Group").getText().trim());

pr.setOrder(property.getChild("Group").getAttributeValue(
"order").trim());
- Attribute attr =
property.getChild("Group").getAttribute(
+ Attribute
attr=property.getChild("Group").getAttribute(
+ "dependsOn");
+ if(attr!=null){
+ pr.setDependency(attr.getValue());
+ }else{
+ pr.setDependency(null);
+ }
+
+ attr =
property.getChild("Group").getAttribute(
"check");
if (attr != null) {
Boolean b =
Boolean.parseBoolean(attr.getValue().trim());
@@ -383,9 +395,12 @@
.getProposedValue()));
Element group = new
Element("Group").setText(pr.getGroup());
group.setAttribute("order", pr.getOrder());
- if (pr.getOrder().equals("1")) {
+ if (pr.getCheck()) {
group.setAttribute("check",
String.valueOf(pr.getCheck()));
}
+ if(pr.getDependency()!=null){
+ group.setAttribute("dependsOn",
pr.getDependency());
+ }

propertyElement.addContent(group);
String[] acceptValues = pr.getAcceptedValues();
@@ -434,6 +449,7 @@

System.out.println(property.getPropertyComment());

System.out.println(property.isPassword());

System.out.println(property.isRequired());
+
System.out.println(property.getDependency());
}

}

Modified:
branches/WebAdmin/perfSONARWebAdmin/auxiliary/wizard/WizardProperty.java
===================================================================
--- branches/WebAdmin/perfSONARWebAdmin/auxiliary/wizard/WizardProperty.java
2008-07-31 13:04:54 UTC (rev 4320)
+++ branches/WebAdmin/perfSONARWebAdmin/auxiliary/wizard/WizardProperty.java
2008-08-01 09:50:40 UTC (rev 4321)
@@ -41,8 +41,11 @@
// Bollean indicatin if the property is a password
private boolean password;

- // Booleasn indicating if the property is mandatory
+ // Booleas indicating if the property is mandatory
private boolean required;
+
+ //Indicates that the property depends on the value of another property
+ private String dependsOn;

//
-----------------------------------------------------------------------
// class constructors
@@ -68,7 +71,7 @@
* Inndicating if the property is required
*/
public WizardProperty(String key, String value, String comment,
- String proposedValue, String group, String[]
acceptedValues,
+ String proposedValue, String group, String[]
acceptedValues,String depend,
boolean chck, boolean pass, boolean req) {
PropertyKey = key;
PropertyValue = value;
@@ -79,6 +82,7 @@
check = chck;
password = pass;
required = req;
+ dependsOn=depend;

}

@@ -92,6 +96,7 @@
ProposedValue = null;
Group = null;
AcceptedValues = null;
+ dependsOn=null;
check = false;
password = false;
required = false;
@@ -140,6 +145,16 @@

return AcceptedValues;
}
+
+ /**
+ * Returns the property that the property depends on
+ *
+ * @return The property that this property depends on
+ */
+ public String getDependency(){
+
+ return dependsOn;
+ }

/**
* Set the accepted values
@@ -182,6 +197,13 @@
}

/**
+ * The dependency of the property
+ * @param depend
+ */
+ public void setDependency(String depend){
+ dependsOn=depend;
+ }
+ /**
* Returns the comment regarding the property
*
* @return The comment of the property

Added: branches/WebAdmin/tick.gif


Property changes on: branches/WebAdmin/tick.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream



  • perfsonar: r4321 - in branches/WebAdmin: . perfSONARWebAdmin/admin/sqlma perfSONARWebAdmin/admin/stitching perfSONARWebAdmin/admin/wizard/services perfSONARWebAdmin/auxiliary/sql perfSONARWebAdmin/auxiliary/sqlma perfSONARWebAdmin/auxiliary/stitching perfSONARWebAdmin/auxiliary/wizard, svnlog, 08/01/2008

Archive powered by MHonArc 2.6.16.

Top of Page