perfsonar-dev - perfsonar: r3485 - in branches/WebAdmin: . ant lib lib/misc perfSONARWebAdmin/admin/service perfSONARWebAdmin/admin/sqlma perfSONARWebAdmin/admin/wizard/services perfSONARWebAdmin/auxiliary perfSONARWebAdmin/auxiliary/sqlma
Subject: perfsonar development work
List archive
perfsonar: r3485 - in branches/WebAdmin: . ant lib lib/misc perfSONARWebAdmin/admin/service perfSONARWebAdmin/admin/sqlma perfSONARWebAdmin/admin/wizard/services perfSONARWebAdmin/auxiliary perfSONARWebAdmin/auxiliary/sqlma
Chronological Thread
- From:
- To:
- Subject: perfsonar: r3485 - in branches/WebAdmin: . ant lib lib/misc perfSONARWebAdmin/admin/service perfSONARWebAdmin/admin/sqlma perfSONARWebAdmin/admin/wizard/services perfSONARWebAdmin/auxiliary perfSONARWebAdmin/auxiliary/sqlma
- Date: Thu, 6 Mar 2008 10:40:32 -0500
Author: michalis
Date: 2008-03-06 10:40:31 -0500 (Thu, 06 Mar 2008)
New Revision: 3485
Added:
branches/WebAdmin/ant/
branches/WebAdmin/ant/build.xml
branches/WebAdmin/ant/compile.xml
branches/WebAdmin/ant/const.properties
branches/WebAdmin/ant/libs-download-targets.xml
branches/WebAdmin/lib/
branches/WebAdmin/lib/misc/
branches/WebAdmin/lib/misc/ant-contrib-1.0b3.jar
branches/WebAdmin/lib/misc/maven-artifact-ant-2.0.4-dep.jar
branches/WebAdmin/lib/misc/perfsonar-base-ant-1.0.20080303.jar
branches/WebAdmin/perfSONARWebAdmin/admin/wizard/services/RRDMA.class
branches/WebAdmin/perfSONARWebAdmin/admin/wizard/services/RRDMAHandler.class
Removed:
branches/WebAdmin/perfSONARWebAdmin/admin/sqlma/TestAdmin.java
Modified:
branches/WebAdmin/Service_Admin.js
branches/WebAdmin/perfSONARWebAdmin/admin/service/Admin.java
branches/WebAdmin/perfSONARWebAdmin/admin/sqlma/SQLMAdmin.java
branches/WebAdmin/perfSONARWebAdmin/auxiliary/PerfsonarPropertiesImpl.java
branches/WebAdmin/perfSONARWebAdmin/auxiliary/sqlma/HTMLOutput.java
branches/WebAdmin/perfSONARWebAdmin/auxiliary/sqlma/SQLMAFilter.java
branches/WebAdmin/perfSONARWebAdmin/auxiliary/sqlma/ibatisFileManager.java
branches/WebAdmin/sqlma_admin_script.js
Log:
Updating Code, Adding ant targets for downloading libraries and building the
web admin jar
Modified: branches/WebAdmin/Service_Admin.js
===================================================================
--- branches/WebAdmin/Service_Admin.js 2008-03-06 11:00:34 UTC (rev 3484)
+++ branches/WebAdmin/Service_Admin.js 2008-03-06 15:40:31 UTC (rev 3485)
@@ -1,10 +1,10 @@
/**
* @author Michalis Michael,Cynet
*/
-function setTip(group,description){
-
- //document.getElementById('description').text=description;
- //document.getElementById('groupName').text=group;
+function setTip(el,description){
+ if (el) {
+ el.style.cursor = 'pointer';
+ }
var text='<span style=\"font-size: 12px;
width:20px;\">'+description+'</span>';
Tip(text,BALLOON, true,WIDTH, 260, PADDING, 8, TEXTALIGN, 'justify',
ABOVE, true);
}
Added: branches/WebAdmin/ant/build.xml
Property changes on: branches/WebAdmin/ant/build.xml
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: branches/WebAdmin/ant/compile.xml
Property changes on: branches/WebAdmin/ant/compile.xml
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: branches/WebAdmin/ant/const.properties
Added: branches/WebAdmin/ant/libs-download-targets.xml
Property changes on: branches/WebAdmin/ant/libs-download-targets.xml
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: branches/WebAdmin/lib/misc/ant-contrib-1.0b3.jar
Property changes on: branches/WebAdmin/lib/misc/ant-contrib-1.0b3.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/WebAdmin/lib/misc/maven-artifact-ant-2.0.4-dep.jar
Property changes on:
branches/WebAdmin/lib/misc/maven-artifact-ant-2.0.4-dep.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/WebAdmin/lib/misc/perfsonar-base-ant-1.0.20080303.jar
Property changes on:
branches/WebAdmin/lib/misc/perfsonar-base-ant-1.0.20080303.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: branches/WebAdmin/perfSONARWebAdmin/admin/service/Admin.java
===================================================================
--- branches/WebAdmin/perfSONARWebAdmin/admin/service/Admin.java
2008-03-06 11:00:34 UTC (rev 3484)
+++ branches/WebAdmin/perfSONARWebAdmin/admin/service/Admin.java
2008-03-06 15:40:31 UTC (rev 3485)
@@ -273,7 +273,9 @@
// Stroring the new property to
properties
PerfsonarProperty property = new
PerfsonarProperty(request
.getParameter("propertyName"), request
-
.getParameter("propertyValue"), "", "");
+
.getParameter("propertyValue"), request
+
.getParameter("propertyDescription"), request
+
.getParameter("propertyGroup"));
properties.setProperty(property.getKey(), property);
}
// Te user wants to remove a property
@@ -487,20 +489,21 @@
out.println("</tr>");
out.println("<tr>");
out.println("<th/>");
- group=group.replace("'", "\\'");
- group=group.replace("(", "[").replace(")", "]");
- String
description=property.getDescription().replace("'", "\\'");
- description=description.replace(")", "]");
- description=description.replace("(", "[");
- description=description.replace("#", "");
- out.println("<td onmouseover=\"setTip('" + group +
"','"
- + description + "')\" >");
+ group = group.replace("'", "\\'");
+ group = group.replace("(", "[").replace(")", "]");
+ String description =
property.getDescription().replace("'", "\\'");
+ description = description.replace(")", "]");
+ description = description.replace("(", "[");
+ description = description.replace("#", "");
+ out.println("<td onmouseover=\"setTip(this,'" +
description + "')\" >");
out.println(property.getKey());
out.println("</td>");
- out.println("<td>");
- out.println("<input " + lock + " type=\"text\"
size=70 name=\""
+ out.println("<td onmouseover=\"setTip(this,'" +
property.getValue()
+ + "')\" >");
+ out.println("<input " + lock + " type=\"text\"
size=60 name=\""
+ property.getKey() + "\" value=\"" +
property.getValue()
- + "\" />");
+ + "\" onmouseover=\"setTip(null,'" +
property.getValue()
+ + "')\" />");
out.println();
out.println("</td>");
out.println("</tr>");
@@ -508,20 +511,23 @@
while (propIt.hasNext()) {
key = (String) propIt.next();
property = properties.getProperty(key);
-
description=property.getDescription().replace("'", "\\'");
- description=description.replace(")", "]");
- description=description.replace("(", "[");
- description=description.replace("#", "");
+ description =
property.getDescription().replace("'", "\\'");
+ description = description.replace(")", "]");
+ description = description.replace("(", "[");
+ description = description.replace("#", "");
out.println("<tr>");
out.println("<td/>");
- out.println("<td onmouseover=\"setTip('" +
group+ "','"
- + description + "')\">");
+ out.println("<td onmouseover=\"setTip(this,'"
+ description
+ + "')\">");
out.println(property.getKey());
out.println("</td>");
- out.println("<td>");
+ out.println("<td onmouseover=\"setTip(this,'"
+ property.getValue()
+ + "')\" >");
out.println("<input " + lock
- + " type=\"text\" size=70
name=\"" + property.getKey()
- + "\" value=\"" +
property.getValue() + "\" />");
+ + " type=\"text\" size=60
name=\"" + property.getKey()
+ + "\" value=\"" +
property.getValue()
+ + "\"
onmouseover=\"setTip(null,'" + property.getValue()
+ + "')\" />");
out.println();
out.println("</td>");
out.println("</tr>");
@@ -547,9 +553,15 @@
// Options foa adding and deleting a property are
added
out.println("<form action=\"ServiceAdmin\"
method=\"POST\"> ");
+ out.println("<p>");
+ out.println("<table>");
+ out.println("<tr>");
out
- .println("<p>Add new property name to
the left column and the property value to the right column.</p>");
+ .println("<th>Add new property name
to the left column and the property value to the right column. Below add
Group and Description</th>");
+ out.println("</tr>");
+ out.println("</table>");
out.println("<p>");
+ out.println("<p>");
out.println("<table>");
out.println("<tr>");
out.println("<th>Property Name</th><th>Property
Value</th>");
@@ -560,19 +572,37 @@
.println("<input type=\"text\"
size=60 name=\"propertyName\" value=\" \" />");
out.println("</td><td>");
out
- .println("<input type=\"text\"
name=\"propertyValue\" size=70 value=\" \" />");
+ .println("<input type=\"text\"
name=\"propertyValue\" size=60 value=\" \" />");
out.println("</td>");
out.println("</tr>");
- out.println("</table>");
+ out.println("<tr>");
+ out.println("<th>Group</th><th>Description</th>");
+ out.println("</tr>");
+ out.println("<tr>");
+ out.println("<td>");
out
+ .println("<input type=\"text\"
size=60 name=\"propertyGroup\" value=\" \" />");
+ out.println("</td><td>");
+ out
+ .println("<input type=\"text\"
name=\"propertyDescription\" size=60 value=\" \" />");
+ out.println("</td>");
+ out.println("<tr>");
+ out.println("<td>");
+ out
.println("<input "
+ " type=\"submit\"
name=\"add\" value=\"Add property\" /> ");
+ out.println("</td>");
+ out.println("</tr>");
+ out.println("</table>");
out.println("</p>");
out.println("</form>");
- out.println("<p>Choose a property to remove.</p>");
+
out.println("<form action=\"ServiceAdmin\"
method=\"POST\"> ");
out.println("<p>");
- out.println("<select name=\"property\">");
+ out.println("<table>");
+ out.println("<tr><th>Choose a propperty to
remove</th><th/></tr>");
+ out.println("<tr>");
+ out.println("<th>Property Name</th><td><select
name=\"property\">");
it = groupedProperties.keySet().iterator();
while (it.hasNext()) {
String group = (String) it.next();
@@ -580,17 +610,19 @@
out.println("<optgroup label=\"" + group +
"\" >");
Iterator propIt = pr.getKeysIterator();
while (propIt.hasNext()) {
- String property = (String) it.next();
+ String property = (String)
propIt.next();
out.println("<option value=\"" +
property + "\">"
+ property +
"</option>");
}
out.println("</optgroup>");
}
- out.println("</select>");
+ out.println("</select></td>");
+ out.println("</tr>");
out
- .println("<input "
- + " type=\"submit\"
name=\"remove\" value=\"Remove property\" /> ");
- out.println("</p> <p/>");
+ .println("<tr><td><input "
+ + " type=\"submit\"
name=\"remove\" value=\"Remove property\" /> </td><td/></tr>");
+ out.println("</table>");
+ out.println("</p>");
out.println("</form>");
}
out.println("</div>");
Modified: branches/WebAdmin/perfSONARWebAdmin/admin/sqlma/SQLMAdmin.java
===================================================================
--- branches/WebAdmin/perfSONARWebAdmin/admin/sqlma/SQLMAdmin.java
2008-03-06 11:00:34 UTC (rev 3484)
+++ branches/WebAdmin/perfSONARWebAdmin/admin/sqlma/SQLMAdmin.java
2008-03-06 15:40:31 UTC (rev 3485)
@@ -13,6 +13,12 @@
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
+import org.apache.commons.codec.binary.Base64;
+
+import perfSONARWebAdmin.auxiliary.Authenticator;
+import perfSONARWebAdmin.auxiliary.AuthenticatorImpl;
+import perfSONARWebAdmin.auxiliary.ServletProperties;
+import perfSONARWebAdmin.auxiliary.ServletPropertiesImpl;
import perfSONARWebAdmin.auxiliary.sql.SQLDBManager;
import perfSONARWebAdmin.auxiliary.sqlma.HTMLOutput;
import perfSONARWebAdmin.auxiliary.sqlma.ibatisFileManager;
@@ -102,135 +108,222 @@
HttpSession session = request.getSession(true);
if (session.isNew())
session.setMaxInactiveInterval(1800);
+
+ // Preparing authentication process
+ ServletProperties servletProperties = new
ServletPropertiesImpl(
+ ServicePath + ServletPropertiesPath);
+ Authenticator authenticator = new
AuthenticatorImpl(servletProperties);
+
response.setContentType("text/html");
ServletOutputStream out = response.getOutputStream();
output = new HTMLOutput();
output.setOuputStream(out);
ibatisFileManager manager = new ibatisFileManager(ServicePath
+ ibatisFilesPath);
- if (session.isNew()) {
- session.setMaxInactiveInterval(18600);
- }
- String function = request.getParameter("Execute");
- if (function != null) {
- if (function.equals("Delete File")) {
- try {
- deleteActions(request);
- output
- .infoPage(
- "SQL
MA administration page.",
-
"Finished deleting ibatis files <a href=\"SQLMAdmin\">Back</a>.",
-
"manage");
- } catch (Exception e) {
- output.infoPage("SQL MA
administration page.", "Error!\n"
- + getFault(e),
"manage");
- }
- } else if (function.equals("Edit File")) {
- String ibatisFile =
request.getParameter("ibatisFile");
- try {
- output.mainPage("SQL MA configuration
page!", manager
- .getIbatisFiles(),
type, manager
-
.getIbatisFileProperties(ibatisFile), ibatisFile);
- } catch (Exception e) {
- throw new
ServletException(getFault(e));
- }
+ // If the user is authenticated
+ if (session.getAttribute("authenticated") != null) {
+ if (((Boolean) session.getAttribute("authenticated"))
+ .booleanValue()) {
- } else if (function.equals("Edit")) {
- try {
- editActions(request);
- } catch (Exception e) {
+ String function =
request.getParameter("Execute");
+ if (function != null) {
+ if (function.equals("Delete File")) {
+ try {
+
deleteActions(request);
+ output
+
.infoPage(
+
"SQL MA administration page.",
+
"Finished deleting ibatis files <a href=\"SQLMAdmin\">Back</a>.",
+
"manage");
+ } catch (Exception e) {
+ output.infoPage("SQL
MA administration page.",
+
"Error!\n" + getFault(e), "manage");
+ }
+ } else if (function.equals("Edit
File")) {
+ String ibatisFile =
request.getParameter("ibatisFile");
+ try {
+ output
+
.mainPage(
+
"SQL MA configuration page!",
+
manager.getIbatisFiles(),
+
type,
+
manager
+
.getIbatisFileProperties(ibatisFile),
+
ibatisFile, "Edit");
+ } catch (Exception e) {
+ throw new
ServletException(getFault(e));
+ }
- output.infoPage("SQL MA
administration page.", "Error!\n"
- + getFault(e),
"manage");
- }
- }
+ } else if (function.equals("Edit")) {
+ try {
+ editActions(request);
+ } catch (Exception e) {
- else if (function.equals("Create")) {
- try {
- createActions(request);
- } catch (Exception e) {
+ output.infoPage("SQL
MA administration page.",
+
"Error!\n" + getFault(e), "manage");
+ }
+ }
- output.infoPage("SQL MA
administration page.", "Error!\n"
- + getFault(e),
"manage");
- }
- } else if (function.equals("Initialize")) {
+ else if (function.equals("Create")) {
+ try {
+
createActions(request);
+ } catch (Exception e) {
- String ibatisFile =
request.getParameter("ibatisFile");
- String action =
request.getParameter("action");
- String initDatabase =
request.getParameter("createDatabase");
- String initUser =
request.getParameter("createUser");
- String initTable =
request.getParameter("createTable");
- String password =
request.getParameter("rtPass");
+ output.infoPage("SQL
MA administration page.",
+
"Error!\n" + getFault(e), "manage");
+ }
+ } else if
(function.equals("Initialize")) {
- if (ibatisFile != null) {
- ibatisFile = ibatisFile.trim();
- }
+ String ibatisFile =
request.getParameter("ibatisFile");
+ String action =
request.getParameter("action");
+ String initDatabase = request
+
.getParameter("createDatabase");
+ String initUser =
request.getParameter("createUser");
+ String initTable =
request.getParameter("createTable");
+ String password =
request.getParameter("rtPass");
- if (action != null) {
- action = action.trim();
- }
+ if (ibatisFile != null) {
+ ibatisFile =
ibatisFile.trim();
+ }
- if (password != null) {
- password = password.trim();
- }
+ if (action != null) {
+ action =
action.trim();
+ }
- try {
- initDB(ibatisFile, action,
initDatabase, initUser,
- initTable, password);
- output
- .infoPage(
- "SQL
MA administration page.",
-
"Finished configuring ibatis files <a href=\"SQLMAdmin\">Back</a>.",
-
"manage");
- } catch (Exception e) {
+ if (password != null) {
+ password =
password.trim();
+ }
- output.infoPage("SQL MA
administration page.", "Error!\n"
- + getFault(e),
"manage");
- }
- } else if (function.equals("No")) {
- String ibatisFile =
request.getParameter("ibatisFile");
- String action =
request.getParameter("action");
- if (action.equals("edit")) {
- try {
- if
(deleteOldFiles(ibatisFile))
+ try {
+ initDB(ibatisFile,
action, initDatabase, initUser,
+
initTable, password);
output
.infoPage(
"SQL MA administration page.",
-
"Finished configuring ibatis files <a href=\"SQLMAdmin\">Back</a>.",
+
"Finished configuring ibatis files <a
href=\"SQLMAdmin\">Back</a>.",
"manage");
- else
+ } catch (Exception e) {
+
+ output.infoPage("SQL
MA administration page.",
+
"Error!\n" + getFault(e), "manage");
+ }
+ } else if (function.equals("No")) {
+ String ibatisFile =
request.getParameter("ibatisFile");
+ String action =
request.getParameter("action");
+ if (action.equals("edit")) {
+ try {
+ if
(deleteOldFiles(ibatisFile))
+ output
+
.infoPage(
+
"SQL MA administration page.",
+
"Finished configuring ibatis files <a
href=\"SQLMAdmin\">Back</a>.",
+
"manage");
+ else
+ output
+
.infoPage(
+
"SQL MA administration page.",
+
"Problem encountered while finishing configuration
of ibatis files",
+
"manage");
+ } catch (Exception e)
{
+
output.infoPage("SQL MA administration page.",
+
"Error!\n" + getFault(e), "manage");
+
+ }
+ } else if
(action.equals("create")) {
output
.infoPage(
"SQL MA administration page.",
-
"Problem encountered while finishing configuration of ibatis files",
+
"Finished configuring ibatis files <a href=\"SQLMAdmin\">Back</a>.",
"manage");
+ }
+ } else {
+ try {
+ String ibatisFile =
request
+
.getParameter("ibatisFile");
+ String[] files =
manager.getIbatisFiles();
+ if (ibatisFile ==
null) {
+ if (files !=
null) {
+
ibatisFile = files[0];
+ }
+ }
+ output
+
.mainPage(
+
"SQL MA configuration page!",
+
files,
+
type,
+
manager
+
.getIbatisFileProperties(ibatisFile),
+
ibatisFile, "");
+ } catch (Exception e) {
+ throw new
ServletException(getFault(e));
+ }
+ }
+ } else {
+ try {
+ String ibatisFile =
request.getParameter("ibatisFile");
+ String[] files =
manager.getIbatisFiles();
+ if (ibatisFile == null) {
+ if (files != null) {
+ ibatisFile =
files[0];
+ }
+ }
+ output.mainPage("SQL MA
configuration page!", files,
+ type, manager
+
.getIbatisFileProperties(ibatisFile),
+ ibatisFile,
"");
} catch (Exception e) {
- output.infoPage("SQL MA
administration page.",
- "Error!\n" +
getFault(e), "manage");
-
+ throw new
ServletException(getFault(e));
}
- } else if (action.equals("create")) {
- output
- .infoPage(
- "SQL
MA administration page.",
-
"Finished configuring ibatis files <a href=\"SQLMAdmin\">Back</a>.",
-
"manage");
}
} else {
- try {
- output.mainPage("SQL MA configuration
page!", manager
- .getIbatisFiles(),
type, null, null);
- } catch (Exception e) {
- throw new
ServletException(getFault(e));
- }
+ // If "authenticated" is false we invalidate
the session so that
+ // the user can try again
+ session.invalidate();
}
} else {
- try {
- output.mainPage("SQL MA configuration page!",
manager
- .getIbatisFiles(), type,
null, null);
- } catch (Exception e) {
- throw new ServletException(getFault(e));
+ // If the "authentcated" parameter has not been set
then we ask for
+ // a username and password
+ String authorization =
request.getHeader("Authorization");
+ // if there is non in the headers we ask for it
+ if (authorization == null) {
+ askForPassword(response);
+ } else {
+
+ // The validation process
+ // Getting the user name and password
+ String userInfo =
authorization.substring(6).trim();
+ Base64 coder = new Base64();
+ // BASE64Decoder decoder = new
BASE64Decoder();
+ String nameAndPassword = new
String(coder.decode(userInfo
+ .getBytes()));
+ int index = nameAndPassword.indexOf(":");
+ String user = nameAndPassword.substring(0,
index);
+ String password =
nameAndPassword.substring(index + 1);
+
+ // Using the authenticator to authenticate
the user
+ if (authenticator.authenticate(user,
password)) {
+ // Authetnication was successful we
show the user all
+ // properties to be configured
+ session.setAttribute("authenticated",
true);
+ try {
+ String ibatisFile = null;
+ String[] files =
manager.getIbatisFiles();
+ if (files != null) {
+ ibatisFile = files[0];
+ }
+ output.mainPage("SQL MA
configuration page!", files,
+ type, manager
+
.getIbatisFileProperties(ibatisFile),
+ ibatisFile,
"");
+ } catch (Exception e) {
+ throw new
ServletException(getFault(e));
+ }
+
+ } else {
+ askForPassword(response);
+ session.invalidate();
+ }
}
}
@@ -438,4 +531,19 @@
}
return fault;
}
+
+ /**
+ * Method for sending back a http request requesting authentication
+ *
+ * @param response
+ * The httpServlet response
+ */
+
+ private void askForPassword(HttpServletResponse response) {
+
+ response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
+ response.setHeader("WWW-Authenticate",
+ "BASIC realm=\"perfSONAR-Admin\"");
+
+ }
}
Deleted: branches/WebAdmin/perfSONARWebAdmin/admin/sqlma/TestAdmin.java
Added: branches/WebAdmin/perfSONARWebAdmin/admin/wizard/services/RRDMA.class
Property changes on:
branches/WebAdmin/perfSONARWebAdmin/admin/wizard/services/RRDMA.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
branches/WebAdmin/perfSONARWebAdmin/admin/wizard/services/RRDMAHandler.class
Property changes on:
branches/WebAdmin/perfSONARWebAdmin/admin/wizard/services/RRDMAHandler.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified:
branches/WebAdmin/perfSONARWebAdmin/auxiliary/PerfsonarPropertiesImpl.java
===================================================================
---
branches/WebAdmin/perfSONARWebAdmin/auxiliary/PerfsonarPropertiesImpl.java
2008-03-06 11:00:34 UTC (rev 3484)
+++
branches/WebAdmin/perfSONARWebAdmin/auxiliary/PerfsonarPropertiesImpl.java
2008-03-06 15:40:31 UTC (rev 3485)
@@ -4,6 +4,7 @@
import java.io.BufferedWriter;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
@@ -56,7 +57,7 @@
*/
public void loadProperties(InputStream in) throws IOException {
- InputStreamReader reader = new InputStreamReader(in,
"ISO-8859-1");
+ InputStreamReader reader = new InputStreamReader(in);
BufferedReader br = new BufferedReader(reader);
String line = null;
@@ -115,6 +116,29 @@
}
}
+ }else{
+ if(line.contains("=")&&
!line.startsWith("#")){
+ String[] prop = line.split("=");
+ if (prop != null) {
+ if (prop.length >= 1 &&
prop.length <= 2) {
+ if
(!prop[0].equals("")) {
+
PerfsonarProperty property = new PerfsonarProperty();
+
property.setGroup("Not Specified");
+
property.setDescription("Not Specified");
+
property.setKey(prop[0]);
+ if
(prop.length == 2) {
+
property.setValue(prop[1]);
+ } else {
+
property.setValue("");
+ }
+
this.put(property.getKey(),
+
property);
+ }
+
+ }
+
+ }
+ }
}
}
@@ -203,23 +227,23 @@
PerfsonarProperties properties = new
PerfsonarPropertiesImpl();
try {
properties.loadProperties(new FileInputStream(
- "test_service3.properties"));
+ "service_mod.properties"));
Iterator it = properties.getKeysIterator();
while (it.hasNext()) {
String key = (String) it.next();
PerfsonarProperty pr =
properties.getProperty(key);
System.out.println("#Group=" + pr.getGroup());
- System.out.println("#Descritpion=" +
pr.getDescription());
+ System.out.println("#Description=" +
pr.getDescription());
System.out.println(pr.getKey() + "=" +
pr.getValue() + "\n\n");
}
+ properties.storeProperties(new
FileOutputStream("test_service3.properties"));
+ //PerfsonarProperty pro = new PerfsonarProperty();
+ //pro.setDescription("A test property");
+ //pro.setGroup("Test");
+ //pro.setKey("testProperty2");
+ //pro.setValue("test");
- PerfsonarProperty pro = new PerfsonarProperty();
- pro.setDescription("A test property");
- pro.setGroup("Test");
- pro.setKey("testProperty2");
- pro.setValue("test");
-
// properties.setProperty("testProperty2", pro);
// properties.removeProperty("testProperty2");
// properties.storeProperties(new FileOutputStream(
Modified: branches/WebAdmin/perfSONARWebAdmin/auxiliary/sqlma/HTMLOutput.java
===================================================================
--- branches/WebAdmin/perfSONARWebAdmin/auxiliary/sqlma/HTMLOutput.java
2008-03-06 11:00:34 UTC (rev 3484)
+++ branches/WebAdmin/perfSONARWebAdmin/auxiliary/sqlma/HTMLOutput.java
2008-03-06 15:40:31 UTC (rev 3485)
@@ -76,21 +76,21 @@
* @throws IOException
*/
public void mainPage(String message, String[] ibatisFileName,
- String[] type, String fileProperties[], String
ibatisFile)
+ String[] type, String fileProperties[], String
ibatisFile,String function)
throws IOException {
String display = "block";
String onClick = " onclick=\"createFile();\"";
preempt("default.css", true);
out.println("<div class=\"manage\" >");
-
+ out.println("<p><h4>"+message+"</h4></p>");
out.println("<div id=\"Options\" >");
out.println("<br/>");
out.println("<form action=\"SQLMAdmin\" method=\"POST\" > ");
out.println("<table align=\"center\">");
out.println("<tr>");
out.println("<th>Choose File:</th>");
- out.println("<td><select name=\"ibatisFile\" >");
+ out.println("<td><select name=\"ibatisFile\"
onchange=\"sendRequest(this.options[this.selectedIndex].value)\" >");
String selected = "";
for (int i = 0; i < ibatisFileName.length; i++) {
if (ibatisFile != null) {
@@ -120,7 +120,10 @@
if (ibatisFile != null && !ibatisFile.equals("")
&& fileProperties != null) {
+
display = "block";
+
+ if(function.equals("Edit")){
out.println("<div id=\"EditFile\" style=\"display:"
+ display
+ ";\">");
out.println("<br/>");
@@ -159,7 +162,30 @@
.println("<tr><td><input
type=\"submit\" name=\"Execute\" value=\"Edit\" /></td><td/></tr>");
out.println("</table></form>");
out.println("</div>");
+ }
+ else{
+
+ out.println("<div id=\"EditFile\"
style=\"display:" + display
+ + ";\">");
+ out.println("<table align=\"center\">");
+ out.println("<tr><th>File Name:</th><td>" +
ibatisFile
+ + "</td><td/></tr>");
+ out.println("<tr><th>Metric Type:</th>");
+ out.println("<td>" + fileProperties[0] +
"</td><td/></tr>");
+ out
+ .println("<tr><th>Database
URL:</th><td>"+ fileProperties[1] +"</td></tr>");
+ out
+ .println("<tr><th>Database
Name:</th><td>"+ fileProperties[2] + "</td></tr>");
+ out
+ .println("<tr><th>User
Name:</th><td>"+ fileProperties[3] + "</td></tr>");
+ out
+ .println("<tr><th>Table
Name:</th><td>"+ fileProperties[4] + "</td></tr>");
+ out.println("</table>");
+ out.println("</div>");
+
+ }
+
}
display = "none";
out.println("<div id=\"CreateNewFile\" style=\"display:" +
display
@@ -225,7 +251,7 @@
out.println("<div id=\"options\" style=\"display:" + display
+ ";\">");
out.println("<br/>");
out
- .println("<form action=\"SQLMAdmin\"
method=\"POST\" onsubmit=\"return checkForPrompt(this)\" > ");
+ .println("<form action=\"SQLMAdmin\"
method=\"POST\" > ");
out.println("<input type=\"hidden\" name=\"ibatisFile\"
value=\""
+ ibatisFile + "\" />");
out.println("<input type=\"hidden\" name=\"action\" value=\""
+ action
@@ -236,8 +262,10 @@
out
.println("<tr><th/><td><input
type=\"checkbox\" name=\"createUser\" value=\"Yes\" />Create User</td></tr>");
out
- .println("<tr><th/><td><input
type=\"checkbox\" name=\"createTable\" value=\"Yes\"/>Initialize Table</tr>");
+ .println("<tr><th/><td><input
type=\"checkbox\" name=\"createTable\" value=\"Yes\"/>Initialize
Table</td></tr>");
out
+ .println("<tr><th>Enter the SQL DB root password:
</th><td><input type=\"password\" size=20 name=\"rtPass\"
value=\"\"/></td></tr>");
+ out
.println("<tr><td><input type=\"submit\"
name=\"Execute\" value=\"Initialize\" /></td><td/></tr>");
out.println("</table></form>");
out.println("</div>");
Modified: branches/WebAdmin/perfSONARWebAdmin/auxiliary/sqlma/SQLMAFilter.java
===================================================================
--- branches/WebAdmin/perfSONARWebAdmin/auxiliary/sqlma/SQLMAFilter.java
2008-03-06 11:00:34 UTC (rev 3484)
+++ branches/WebAdmin/perfSONARWebAdmin/auxiliary/sqlma/SQLMAFilter.java
2008-03-06 15:40:31 UTC (rev 3485)
@@ -15,7 +15,7 @@
public boolean accept(File arg0, String arg1) {
String name=arg1.toLowerCase();
-
if((name.endsWith(".xml"))&&(name.startsWith("ibatis-SqlMapConfig".toLowerCase()))&&
(!name.endsWith("template.xml"))){
+
if((name.endsWith(".xml"))&&(name.startsWith("ibatis-SqlMapConfig-".toLowerCase()))&&
(!name.endsWith("template.xml"))){
return true;
}
else return false;
Modified:
branches/WebAdmin/perfSONARWebAdmin/auxiliary/sqlma/ibatisFileManager.java
===================================================================
---
branches/WebAdmin/perfSONARWebAdmin/auxiliary/sqlma/ibatisFileManager.java
2008-03-06 11:00:34 UTC (rev 3484)
+++
branches/WebAdmin/perfSONARWebAdmin/auxiliary/sqlma/ibatisFileManager.java
2008-03-06 15:40:31 UTC (rev 3485)
@@ -90,11 +90,17 @@
String[] str = url.split("/");
String database = str[str.length - 1];
url = str[0] + "/" + str[1] + "/" + str[2];
- properties[0] = getType(mapFile).trim();
+ if (mapFile.exists()) {
+ properties[0] = getType(mapFile).trim();
+ properties[4] = getTable(mapFile).trim();
+ } else {
+ properties[0] = "Not available";
+ properties[4] = "Not available";
+ }
properties[1] = url.trim();
properties[2] = database.trim();
properties[3] = username.trim();
- properties[4] = getTable(mapFile).trim();
+
properties[5] = password.trim();
properties[6] = sqlMapFile.trim();
properties[7] = driver.trim();
Modified: branches/WebAdmin/sqlma_admin_script.js
===================================================================
--- branches/WebAdmin/sqlma_admin_script.js 2008-03-06 11:00:34 UTC (rev
3484)
+++ branches/WebAdmin/sqlma_admin_script.js 2008-03-06 15:40:31 UTC (rev
3485)
@@ -118,6 +118,23 @@
document.getElementById('options').style.display = "block";
}
+function sendRequest(file){
+ document.body.style.cursor='wait';
+ var input=document.createElement("input");
+ input.type = "hidden";
+ input.name = "ibatisFile";
+ input.value = file;
+ var form=document.createElement("form");
+ form.name="ShowForm"
+ form.method='post';
+ form.action='SQLMAdmin';
+ form.appendChild(input);
+ document.getElementById('EditFile').appendChild(form);
+ document.ShowForm.submit();
+
+}
+
+
function checkForPrompt(form){
if (form.createDatabase != null || form.createUser != null) {
- perfsonar: r3485 - in branches/WebAdmin: . ant lib lib/misc perfSONARWebAdmin/admin/service perfSONARWebAdmin/admin/sqlma perfSONARWebAdmin/admin/wizard/services perfSONARWebAdmin/auxiliary perfSONARWebAdmin/auxiliary/sqlma, svnlog, 03/06/2008
Archive powered by MHonArc 2.6.16.