Skip to Content.
Sympa Menu

perfsonar-dev - [pS-dev] [GEANT/SA2/ps-java-services] r5993 - in trunk/perfsonar-java-web-admin: perfsonar-java-web-ad min-component perfsonar-java-web-admin-component/src/main/ java/org/perfsonar/webadmin/base2/config perfsonar-java-we b-admin-component/src/main/java/org/perfsonar/webadmin/bas e2/servlet perfsonar-java-web-admin-component/src/main/jav a/org/perfsonar/webadmin/base2/servlet/util perfsonar-java -web-admin-component/src/main/java/org/perfsonar/webadmin/ base2/test perfsonar-java-web-admin-component/src/main/jav a/org/perfsonar/webadmin/base2/util perfsonar-java-web-adm in-component/src/main/webapp/views perfsonar-java-web-admi n-exampleservice perfsonar-java-web-admin-exampleservice/s rc/main perfsonar-java-web-admin-exampleservice/src/main/j ava perfsonar-java-web-admin-exampleservice/src/main/java/ org perfsonar-java-web-admin-exampleservice/src/main/java/ org/perfsonar perfsonar-java-web-admin-exampleservice/src/ main/java/org/perfsonar/webadmin perfsonar-java-web-admin- exampleservice/src /main/java/org/perfsonar/webadmin/examp le perfsonar-java-web-admin-exampleservice/src/main/java/o rg/perfsonar/webadmin/example/servlet perfsonar-java-web-a dmin-exampleservice/src/main/webapp perfsonar-java-web-adm in-exampleservice/src/main/webapp/WEB-INF perfsonar-java-w eb-admin-exampleservice/src/main/webapp/WEB-INF/classes/pe rfsonar/conf perfsonar-java-web-admin-exampleservice/src/m ain/webapp/views

Subject: perfsonar development work

List archive

[pS-dev] [GEANT/SA2/ps-java-services] r5993 - in trunk/perfsonar-java-web-admin: perfsonar-java-web-ad min-component perfsonar-java-web-admin-component/src/main/ java/org/perfsonar/webadmin/base2/config perfsonar-java-we b-admin-component/src/main/java/org/perfsonar/webadmin/bas e2/servlet perfsonar-java-web-admin-component/src/main/jav a/org/perfsonar/webadmin/base2/servlet/util perfsonar-java -web-admin-component/src/main/java/org/perfsonar/webadmin/ base2/test perfsonar-java-web-admin-component/src/main/jav a/org/perfsonar/webadmin/base2/util perfsonar-java-web-adm in-component/src/main/webapp/views perfsonar-java-web-admi n-exampleservice perfsonar-java-web-admin-exampleservice/s rc/main perfsonar-java-web-admin-exampleservice/src/main/j ava perfsonar-java-web-admin-exampleservice/src/main/java/ org perfsonar-java-web-admin-exampleservice/src/main/java/ org/perfsonar perfsonar-java-web-admin-exampleservice/src/ main/java/org/perfsonar/webadmin perfsonar-java-web-admin- exampleservice/src /main/java/org/perfsonar/webadmin/examp le perfsonar-java-web-admin-exampleservice/src/main/java/o rg/perfsonar/webadmin/example/servlet perfsonar-java-web-a dmin-exampleservice/src/main/webapp perfsonar-java-web-adm in-exampleservice/src/main/webapp/WEB-INF perfsonar-java-w eb-admin-exampleservice/src/main/webapp/WEB-INF/classes/pe rfsonar/conf perfsonar-java-web-admin-exampleservice/src/m ain/webapp/views


Chronological Thread 
  • From:
  • To:
  • Subject: [pS-dev] [GEANT/SA2/ps-java-services] r5993 - in trunk/perfsonar-java-web-admin: perfsonar-java-web-ad min-component perfsonar-java-web-admin-component/src/main/ java/org/perfsonar/webadmin/base2/config perfsonar-java-we b-admin-component/src/main/java/org/perfsonar/webadmin/bas e2/servlet perfsonar-java-web-admin-component/src/main/jav a/org/perfsonar/webadmin/base2/servlet/util perfsonar-java -web-admin-component/src/main/java/org/perfsonar/webadmin/ base2/test perfsonar-java-web-admin-component/src/main/jav a/org/perfsonar/webadmin/base2/util perfsonar-java-web-adm in-component/src/main/webapp/views perfsonar-java-web-admi n-exampleservice perfsonar-java-web-admin-exampleservice/s rc/main perfsonar-java-web-admin-exampleservice/src/main/j ava perfsonar-java-web-admin-exampleservice/src/main/java/ org perfsonar-java-web-admin-exampleservice/src/main/java/ org/perfsonar perfsonar-java-web-admin-exampleservice/src/ main/java/org/perfsonar/webadmin perfsonar-java-web-admin- exampleservice/src /main/java/org/perfsonar/webadmin/examp le perfsonar-java-web-admin-exampleservice/src/main/java/o rg/perfsonar/webadmin/example/servlet perfsonar-java-web-a dmin-exampleservice/src/main/webapp perfsonar-java-web-adm in-exampleservice/src/main/webapp/WEB-INF perfsonar-java-w eb-admin-exampleservice/src/main/webapp/WEB-INF/classes/pe rfsonar/conf perfsonar-java-web-admin-exampleservice/src/m ain/webapp/views
  • Date: Wed, 5 Sep 2012 12:17:18 +0100 (BST)

Author: dante.delvaux
Date: 2012-09-05 12:17:18 +0100 (Wed, 05 Sep 2012)
New Revision: 5993

Added:

trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-component/src/main/java/org/perfsonar/webadmin/base2/util/HTMLUtil.java

trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-exampleservice/src/main/java/

trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-exampleservice/src/main/java/org/

trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-exampleservice/src/main/java/org/perfsonar/

trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-exampleservice/src/main/java/org/perfsonar/webadmin/

trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-exampleservice/src/main/java/org/perfsonar/webadmin/example/

trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-exampleservice/src/main/java/org/perfsonar/webadmin/example/servlet/

trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-exampleservice/src/main/java/org/perfsonar/webadmin/example/servlet/ExampleServlet.java

trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-exampleservice/src/main/webapp/views/

trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-exampleservice/src/main/webapp/views/example.jsp
Removed:

trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-component/src/main/java/org/perfsonar/webadmin/base2/util/HTMLUtil.java

trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-component/src/main/java/org/perfsonar/webadmin/base2/util/HTMLUtilStringBuffer.java

trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-component/src/main/java/org/perfsonar/webadmin/base2/util/StringOutputStream.java
Modified:
trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-component/pom.xml

trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-component/src/main/java/org/perfsonar/webadmin/base2/config/HTMLGenerator.java

trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-component/src/main/java/org/perfsonar/webadmin/base2/config/ObjectMap.java

trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-component/src/main/java/org/perfsonar/webadmin/base2/servlet/ConfigurationServlet.java

trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-component/src/main/java/org/perfsonar/webadmin/base2/servlet/util/ConfigurationServletHelper.java

trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-component/src/main/java/org/perfsonar/webadmin/base2/test/SOAPClient.java

trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-component/src/main/java/org/perfsonar/webadmin/base2/util/NSContext.java

trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-component/src/main/webapp/views/error.jsp

trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-component/src/main/webapp/views/savedFailed.jsp
trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-exampleservice/

trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-exampleservice/pom.xml

trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-exampleservice/src/main/webapp/WEB-INF/classes/perfsonar/conf/configuration.xml

trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-exampleservice/src/main/webapp/WEB-INF/classes/perfsonar/conf/webAdminConfig.xml

trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-exampleservice/src/main/webapp/WEB-INF/web.xml
Log:
WebAdmin refactoring stage 2:
- simplification of the ConfigurationServletHelper by removing doubled methods
- dropping HTMLUtil with custom StringOutputStream implementation
- replacing it with the then nearly finished HTMLUtilStringBuffer (renamed to
HTMLUtil)
- improved error reporting to the end user
- improved logging
- added comment and documentation
- better description and usage of the example service


Modified:
trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-component/pom.xml
===================================================================
--- trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-component/pom.xml
2012-09-05 10:33:57 UTC (rev 5992)
+++ trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-component/pom.xml
2012-09-05 11:17:18 UTC (rev 5993)
@@ -14,7 +14,11 @@

<properties>
<junit.version>4.8.1</junit.version>
- </properties>
+ <user.language>en</user.language>
+ <user.region>GB</user.region>
+ <user.country>US</user.country>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>

<build>
<finalName>${project.artifactId}</finalName>
@@ -98,8 +102,6 @@
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
- <version>2.5</version>
- <scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>

Modified:
trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-component/src/main/java/org/perfsonar/webadmin/base2/config/HTMLGenerator.java
===================================================================
---
trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-component/src/main/java/org/perfsonar/webadmin/base2/config/HTMLGenerator.java
2012-09-05 10:33:57 UTC (rev 5992)
+++
trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-component/src/main/java/org/perfsonar/webadmin/base2/config/HTMLGenerator.java
2012-09-05 11:17:18 UTC (rev 5993)
@@ -1,6 +1,5 @@
package org.perfsonar.webadmin.base2.config;

-import java.io.PrintStream;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
@@ -9,7 +8,6 @@
import org.apache.log4j.Logger;
import org.perfsonar.webadmin.base2.util.HTMLUtil;
import org.perfsonar.webadmin.base2.util.NSContext;
-import org.perfsonar.webadmin.base2.util.StringOutputStream;
import org.perfsonar.webadmin.base2.util.Tuple;
import org.perfsonar.webadmin.base2.util.XMLUtil;
import org.perfsonar.webadmin.base2.waschema.v20090201.BaseType;
@@ -62,19 +60,11 @@
}
};

- private PrintStream htmlOutput = null;
+ private StringBuffer htmlOutput = null;
private boolean plainContext = true;
private ObjectMap objectMap = null;
private HTMLUtil htmlUtil = null;

- private void println(String s) {
- if (htmlOutput != null) {
- htmlOutput.println(s);
- } else {
- logger.debug("Cannot print an empty output.");
- }
- }
-
private String[] getLinksList(List<LinkType> blist, boolean big,
boolean advanced) {
String basic = "";
@@ -193,7 +183,7 @@
* @param outputStream
* @return
*/
- public boolean translate(String pageName, ObjectMap o, PrintStream
outputStream) {
+ public boolean translate(String pageName, ObjectMap o, StringBuffer
out) {
//TODO: wouldn't it be better to have objectMap set in the
constructor?
objectMap = o;
WebAdminInterface wai = objectMap.getWA();
@@ -201,20 +191,22 @@
logger.warn("Cannot translate a null
WebAdminInterface.");
return false;
}
- htmlOutput = outputStream;
- htmlUtil = new HTMLUtil(htmlOutput);
+
+ // We copy the output buffer, so we can play around with
it... FIXME We really shouldn't do that, all too tricky
+ htmlOutput = out;
+ htmlUtil = new HTMLUtil(out);
List<PageType> pageList = wai.getPage();
for (int i = 0, sz = pageList.size(); i < sz; i++) {
// We look for the requested page
PageType page = pageList.get(i);
if (raw(getData(page.getPageId())).equals(pageName)) {
logger.debug("Let's process page \"" +
pageName + "\"");
- translate(page);
- return true;
+ return translate(page);
}
}
- // We haven't found the requested page
- logger.warn("We haven't found page \"" + pageName + "\" in
the WebAdminInterface object.");
+ String errMsg = "We haven't found page \"" + pageName + "\"
in the WebAdminInterface object.";
+ logger.warn(errMsg);
+ htmlUtil.errorBox(errMsg);
return false;
}

@@ -222,41 +214,58 @@
* Translate a given page object to HTML code
* @param page
*/
- public void translate(PageType page) {
+ public boolean translate(PageType page) {
if (page == null) {
logger.warn("Cannot translate a null page.");
- return;
+ return false;
}
GroupsType groups = page.getGroups();
List<PlainType> plain = page.getPlain();
+ boolean result;
if (groups != null) {
logger.debug("The page contains groups");
// We first have groups of elements
boolean oldContext = plainContext;
plainContext = false;
- translate(groups);
+ result = translate(groups);
plainContext = oldContext;
} else if (plain != null) {
logger.debug("The page contains plain elements");
boolean oldContext = plainContext;
plainContext = true;
- for (int i = 0, sz = plain.size(); i < sz; i++)
+ for (int i = 0, sz = plain.size(); i < sz; i++) {
// We translate each plain element
translate((PlainType) plain.get(i));
+ }
plainContext = oldContext;
+ result = true;
} else {
- logger.warn("Page \"" + page.getPageId() + "\"
doesn't contain any groups nor plain elements.");
- throw new RuntimeException("The given page doesn't
contain any groups nor plain elements.");
+ String errMsg = "Page \"" + page.getPageId() + "\"
doesn't contain any groups nor plain elements.";
+ logger.warn(errMsg);
+ htmlUtil.errorBox(errMsg);
+ result = false;
}
+ return result;
}

- public void translate(GroupsType g) {
- logger.warn("Groups type not implemented yet.");

+ public boolean translate(GroupsType g) {
+ // TODO: implement groups
+ String errMsg = "Groups type not implemented yet.";
+ logger.warn(errMsg);
+ htmlUtil.errorBox(errMsg);
+ return false;
}

+ /**
+ * From here and all the sub types, the tranlate method doesn't
return a boolean.
+ * It just print a error message if something goes wrong, but
continue processing the objectMap
+ * @param p
+ */
public void translate(PlainType p) {
if (p == null) {
- logger.warn("Cannot translate a null plain type.");
+ String errMsg = "Cannot translate a null plain type.";
+ logger.warn(errMsg);
+ htmlUtil.simplelineoftext(errMsg, "red");
return;
}
if (p.getTextbox() != null)
@@ -270,11 +279,17 @@
else if (p.getPassword() != null)
translateBaseUI(p.getPassword(), UIType.PASSOWRD);
else {
- logger.warn("PlainType doesn't contain any known UI
type.");
- throw new RuntimeException("Unexpected UI type.");
+ String errMsg = "PlainType doesn't contain any known
UI type.";
+ logger.warn(errMsg);
+ htmlUtil.simplelineoftext(errMsg, "red");
}
}

+ /**
+ * A BaseUI is either a TEXTBOX or a PASSWORD field.
+ * @param b
+ * @param u
+ */
public void translateBaseUI(BaseUIType b, UIType u) {
switch (u) {
case TEXTBOX:
@@ -285,28 +300,38 @@
break;

default:
- logger.warn("Cannot translate Base UI element, UIType
unknown.");
- throw new RuntimeException("Unexpected BaseUI type.");
+ String errMsg = "Cannot translate Base UI element,
UIType unknown.";
+ logger.warn(errMsg);
+ htmlUtil.simplelineoftext(errMsg, "red");
}
}

+ /**
+ * A ComplexGroupUI can only be a RADIOGROUP
+ * @param cgui
+ * @param u
+ */
public void translate(ComplexGroupUIType cgui, UIType u) {
switch (u) {
case RADIOGROUP:
List<PlainType> plains = cgui.getPlain();
if (plains == null)
return;
- PrintStream oldOut = htmlOutput;
- StringOutputStream sos = new StringOutputStream();
- htmlOutput = new PrintStream(sos);
- for (int i = 0, sz = plains.size(); i < sz; i++)
+ // FIXME: trick, we save the current output buffer,
so we can temporarily generate a new one
+ StringBuffer oldOut = htmlOutput;
+ htmlOutput = new StringBuffer();
+ for (int i = 0, sz = plains.size(); i < sz; i++) {
+ // We loop through all the plain element
inside the Complex Group
translate((PlainType) plains.get(i));
+ }
+ String innerHTML = htmlOutput.toString();
htmlOutput = oldOut;
- drawRadiogroup(getData(cgui.getValues()),
sos.toString());
+ drawRadiogroup(getData(cgui.getValues()), innerHTML);
break;
default:
- logger.warn("Cannot translate Complex Group UI
element, UIType unknown.");
- throw new RuntimeException("Unexpected ComplexGroupUI
type.");
+ String errMsg = "Cannot translate Complex Group UI
element, UIType unknown.";
+ logger.warn(errMsg);
+ htmlUtil.simplelineoftext(errMsg, "red");
}
}

@@ -338,8 +363,9 @@
drawDropdown(getSingleData(cui.getTitle()), ret);
break;
default:
- logger.warn("Cannot translate Complex UI element,
UIType unknown.");
- throw new RuntimeException("Unexpected ComplexUI
type.");
+ String errMsg = "Cannot translate Complex UI element,
UIType unknown.";
+ logger.warn(errMsg);
+ htmlUtil.simplelineoftext(errMsg, "red");
}
}

@@ -457,7 +483,7 @@
try {
htmlUtil.singlerow_begin(5);
htmlUtil.radiogroup_begin("key3", "Grouped box",
"yes", "no", enabled);
- println(innerHTML);
+ htmlUtil.println(innerHTML);
htmlUtil.radiogroup_end();
htmlUtil.singlerow_end();
} catch (Exception e) {

Modified:
trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-component/src/main/java/org/perfsonar/webadmin/base2/config/ObjectMap.java
===================================================================
---
trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-component/src/main/java/org/perfsonar/webadmin/base2/config/ObjectMap.java
2012-09-05 10:33:57 UTC (rev 5992)
+++
trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-component/src/main/java/org/perfsonar/webadmin/base2/config/ObjectMap.java
2012-09-05 11:17:18 UTC (rev 5993)
@@ -27,7 +27,7 @@

/**
*
- * wrapper for Hashtable
+ * Wrapper around Hashtable
*
*
*/
@@ -44,8 +44,7 @@
boolean sync = false;

public ObjectMap(String basePath, String confPath, String file) {
- // TODO: Unix paths
- waconfigfile = basePath + "/" + confPath + "/" + file;
+ waconfigfile = basePath + File.separatorChar + confPath +
File.separatorChar + file;
try {
waconfig = WAXMLReader.parseFile(waconfigfile);
} catch (FileNotFoundException e) {
@@ -85,6 +84,10 @@

}

+ /**
+ * Actually call the file output classes to save to disk
+ * @return
+ */
private boolean saveExternal() {
Set<Entry<String, Document>> entrySet = file2doc.entrySet();
for (Entry<String, Document> o : entrySet) {
@@ -92,13 +95,17 @@
XMLUtil.writeXml(o.getValue(), new
java.io.FileOutputStream(
basePath + "/" + o.getKey()));
} catch (Exception e) {
- e.printStackTrace();
+ logger.error("Error trying to save ourselves
to disk: " + e.getMessage());
return false;
}
}
return true;
}

+ /**
+ * Save ourselves to disk
+ * @return
+ */
public synchronized boolean save() {
boolean saved = saveExternal();
if (saved) {

Modified:
trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-component/src/main/java/org/perfsonar/webadmin/base2/servlet/ConfigurationServlet.java
===================================================================
---
trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-component/src/main/java/org/perfsonar/webadmin/base2/servlet/ConfigurationServlet.java
2012-09-05 10:33:57 UTC (rev 5992)
+++
trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-component/src/main/java/org/perfsonar/webadmin/base2/servlet/ConfigurationServlet.java
2012-09-05 11:17:18 UTC (rev 5993)
@@ -9,6 +9,7 @@
import org.perfsonar.webadmin.base2.servlet.util.ConfigurationServletHelper;

/**
+ * The ConfigurationServlet is in charge of dispatching requests for the
configuration file edition.
*
* @author Slawomir Trzaszczka
* @author Antoine Delvaux - DANTE
@@ -18,29 +19,29 @@
public class ConfigurationServlet extends BasicServlet {

/**
- *
- * get data from config file and send it to form !
- *
+ * We receive a GET request and we present the config file data to be
edited in a form
*/
@Override
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws
ServletException, IOException {

- ConfigurationServletHelper config = new
ConfigurationServletHelper(request, getServletContext());
+ // We get the config file content from the
ConfigurationServletHelper
+ ConfigurationServletHelper config = new
ConfigurationServletHelper(request, response, getServletContext());
String htmlContent = config.getHTMLContent();
+
if (htmlContent != null) {
+ // The "form" attribute will store the generated FORM
request.setAttribute("form", htmlContent);
} else {
- logger.debug("form html content is null !");
+ logger.warn("form html content is null !");
}
+ // We forward the request to the index.jsp that will render
our form
getServletConfig().getServletContext().getRequestDispatcher(
"/index.jsp?page=form").forward(request, response);
}

/**
- *
- * save data
- *
+ * We receive a POST request and we save the received data
*/
@Override
protected void doPost(HttpServletRequest request,
@@ -50,7 +51,9 @@

String urlPath = "index.jsp?page=save";

+ // Try to process the received data and save it
if (config.processData()) {
+ // Everything went smoothly, we'll display a nice OK
page.
urlPath += "&ok";
}
getServletContext().removeAttribute("ObjectMap");

Modified:
trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-component/src/main/java/org/perfsonar/webadmin/base2/servlet/util/ConfigurationServletHelper.java
===================================================================
---
trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-component/src/main/java/org/perfsonar/webadmin/base2/servlet/util/ConfigurationServletHelper.java
2012-09-05 10:33:57 UTC (rev 5992)
+++
trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-component/src/main/java/org/perfsonar/webadmin/base2/servlet/util/ConfigurationServletHelper.java
2012-09-05 11:17:18 UTC (rev 5993)
@@ -1,7 +1,6 @@
package org.perfsonar.webadmin.base2.servlet.util;

import java.io.IOException;
-import java.io.PrintStream;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
@@ -13,9 +12,6 @@
import org.perfsonar.webadmin.base2.config.HTMLGenerator;
import org.perfsonar.webadmin.base2.config.ObjectMap;
import org.perfsonar.webadmin.base2.util.HTMLUtil;
-import org.perfsonar.webadmin.base2.util.HTMLUtilStringBuffer;
-import org.perfsonar.webadmin.base2.util.StringOutputStream;
-import org.perfsonar.webadmin.base2.util.Tuple;

public class ConfigurationServletHelper {

@@ -34,8 +30,6 @@
public static final String WA_FILE_NAME = "webAdminConfig.xml";

private HttpServletRequest request;
- private HttpServletResponse response;
- private PrintStream out;
private HttpSession session;
private ServletContext context;
private HTMLGenerator generator;
@@ -52,130 +46,100 @@
return map;
}
// We don't have it, so let's build it and store it in the
servlet context
- // TODO: Fix Unix-paths
String basePath = servletContext.getRealPath("/") + "WEB-INF";
map = new ObjectMap(basePath, WA_CONFIG_PATH, WA_FILE_NAME);
servletContext.setAttribute("ObjectMap", map);
return map;
}

+ /**
+ * If the context is already existing, we probably can directly
return the objectMap
+ * @return
+ */
+ public ObjectMap objectMap() {
+ return objectMap(context);
+ }
+
public ConfigurationServletHelper(HttpServletRequest request,
HttpServletResponse response, ServletContext context)
{
this.request = request;
- this.response = response;
this.context = context;
- try {
- this.out = new
PrintStream(response.getOutputStream());
- } catch (IOException e) {
- // TODO: add proper exception handling (probably
logging)
- e.printStackTrace();
- }
this.generator = new HTMLGenerator();
+
+ // Get the current session or create it
this.session = request.getSession(true);

+ // We'll deal only with text/html
response.setContentType("text/html");
- // Set max interval to session
- if (session.isNew()) {
- session.setMaxInactiveInterval(SESSION_INTERVAL);
- }

- }
-
- public ConfigurationServletHelper(HttpServletRequest request,
- ServletContext context) {
- this.request = request;
- this.session = request.getSession(true);
- this.context = context;
- this.generator = new HTMLGenerator();
-
- // Set max interval to session
if (session.isNew()) {
+ // Set session max duration
session.setMaxInactiveInterval(SESSION_INTERVAL);
}

}

- public ObjectMap objectMap() {
- return objectMap(context);
- }
-
+ /**
+ * Generates the HTML code for the corresponding page given as HTTP
Parameter
+ * @return
+ */
public String getHTMLContent() {
String pageParameterValue = getHttpParameter("page");
return getHTMLContent(pageParameterValue);
}

/**
- *
- * displays page where pageType is 'basic' or other ...
- *
+ * Generates the HTML code for the given page
* @param pageType
+ * @return
*/
- private void displayPage(String pageType) {
- // TODO: change location of this piece of code
- Tuple<String, String> renderedPage = renderPage(pageType);
-
- if (renderedPage != null) {
- try {
- HTMLUtil u = new HTMLUtil(out);
-
- u.preamble();
- u.form_begin("form_key",
renderedPage.first(), "config?page="
- + renderedPage.first(), 1);
- u.simplelineoftext("Please fill in the
following fields:", "green");
- out.println(renderedPage.second());
- u.form_end();
- u.simplelineoftext("2",
- "<a
href=\"/index.jsp\">Return to main page</a>", "green");
- u.postscript();
- } catch (Exception e) {
- //FIXME: would be better to log the stack
trace and output a sensible message to the user
- e.printStackTrace();
- response.setStatus(500);
- }
- } else {
- response.setStatus(404);
- }
-
- }
-
private String getHTMLContent(String pageType) {
- Tuple<String, String> ret = renderPage(pageType);
+ logger.debug("Looking up page \"" + pageType + "\"");

- StringBuffer sb = new StringBuffer();
-
- if (ret != null) {
- try {
- HTMLUtilStringBuffer u = new
HTMLUtilStringBuffer(sb);
-
- u.preamble();
- u.form_begin("form_key", ret.first(),
"config?page=" + ret.first(), 1);
- u.simplelineoftext("Please fill in the
following fields:", "green");
- sb.append(ret.second());
- u.form_end();
- u.postscript();
- String htmlContent = u.getContent();
- return htmlContent;
- } catch (IOException e) {
- e.printStackTrace();
+ StringBuffer htmlsb = new StringBuffer();
+ HTMLUtil html = new HTMLUtil(htmlsb);
+ try {
+ html.preamble();
+ StringBuffer translatesb = new StringBuffer();
+ if (generator.translate(pageType, objectMap(),
translatesb)) {
+ logger.debug(pageType + " page was found and
content was generated, let's wrap it in a form");
+ html.form_begin("form_key", pageType,
"config?page=" + pageType, 1);
+ html.simplelineoftext("Please fill in the
following fields:", "green");
+ htmlsb.append(translatesb.toString());
+ html.form_end();
+ } else {
+ logger.warn("Page \"" + pageType + "\" not
found!");
+ htmlsb.append(translatesb.toString());
}
- } else {
- return null;
+ html.postscript();
+ } catch (IOException e) {
+ logger.error("Error generating HTML for " + pageType
+ " :" + e.getMessage());
+ return HTMLUtil.colouredtext("Something went wrong
generating the HTML content for " + pageType
+ + ". More information is available in
the log file.", "red");
}
-
- return null;
+ return html.getContent();
}

+ /**
+ * We process the data received from a form POST
(ConfigurationServlet)
+ * and we try to save it to the configuration file.
+ * @return
+ */
@SuppressWarnings("unchecked")
public boolean processData() {
boolean saved = false;
- logger.debug("Processing client data.");
+ logger.debug("Processing data received from a form POST.");
+
+ // We update the objectMap with the data we received
objectMap().updateObjects(request.getParameterMap());
+
+ // Then we try to save the objectMap to the file
if (objectMap().save()) {
- logger.debug("configuration saved");
+ logger.debug("Configuration correctly saved");
saved = true;
} else {
- logger.debug("problem with saving configuration");
- displayPage(getHttpParameter("form_key"));
+ logger.warn("Problem saving the new configuration,
we'll display an error message.");
+ // TODO: It would have been better to display the
form again, so the user could try to fix the issue.
saved = false;
}
logger.debug("Done processing client data.");
@@ -184,41 +148,19 @@
}

/**
+ * Get Parameter from HttpRequest
*
- * get Parameter from HttpRequest
- *
- * @param s
+ * @param paramName Parameter name to look for
* @return
*/
- private String getHttpParameter(String s) {
- String p = request.getParameter(s);
+ private String getHttpParameter(String paramName) {
+ String p = request.getParameter(paramName);
if (p == null) {
- logger.debug("Parameter \"" + s + "\" not found in
HTTPRequest");
+ logger.debug("Parameter \"" + paramName + "\" not
found in HTTPRequest");
return null;
} else {
return p.trim();
}
}

- /**
- * return Tuple where first param is http value and second is HTML
content
- *
- * @param pageName
- * @return
- */
- private Tuple<String, String> renderPage(String pageName) {
- if (pageName == null) {
- //FIXME: wouldn't it be better to throw an exception
here
- return null;
- } else {
- logger.debug("Looking up page \"" + pageName + "\"");
- StringOutputStream sout = new StringOutputStream();
- if (!generator.translate(pageName, objectMap(), new
PrintStream(sout))) {
- logger.warn("Page \"" + pageName + "\" not
found!");
- pageName = null;
- }
- return new Tuple<String, String>(pageName,
sout.toString());
- }
- }
-
};

Modified:
trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-component/src/main/java/org/perfsonar/webadmin/base2/test/SOAPClient.java
===================================================================
---
trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-component/src/main/java/org/perfsonar/webadmin/base2/test/SOAPClient.java
2012-09-05 10:33:57 UTC (rev 5992)
+++
trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-component/src/main/java/org/perfsonar/webadmin/base2/test/SOAPClient.java
2012-09-05 11:17:18 UTC (rev 5993)
@@ -10,6 +10,8 @@
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.DefaultHttpClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;

/**
*
@@ -20,6 +22,8 @@
*/
public class SOAPClient {

+ protected Logger logger = LoggerFactory.getLogger(getClass());
+
private final String url;

public SOAPClient(String url) {
@@ -54,19 +58,22 @@
try {
return httpclient.execute(httpPost,
responseHandler);
} catch (ClientProtocolException e) {
- e.printStackTrace();
+ logger.error("SOAP HTTP POST error: " +
e.getMessage());
+ // TODO: We should use perfSONAR Exceptions
here
throw new SOAPClientException(e);
} catch (IOException e) {
e.printStackTrace();
+ // TODO: We should use perfSONAR Exceptions
here
throw new SOAPClientException(e);
} finally {
if (httpclient != null) {

httpclient.getConnectionManager().shutdown();
}
}
- } catch (UnsupportedEncodingException e1) {
- e1.printStackTrace();
- throw new SOAPClientException(e1);
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();
+ // TODO: We should use perfSONAR Exceptions here
+ throw new SOAPClientException(e);
}
}


Deleted:
trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-component/src/main/java/org/perfsonar/webadmin/base2/util/HTMLUtil.java
===================================================================
---
trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-component/src/main/java/org/perfsonar/webadmin/base2/util/HTMLUtil.java
2012-09-05 10:33:57 UTC (rev 5992)
+++
trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-component/src/main/java/org/perfsonar/webadmin/base2/util/HTMLUtil.java
2012-09-05 11:17:18 UTC (rev 5993)
@@ -1,310 +0,0 @@
-package org.perfsonar.webadmin.base2.util;
-
-import java.io.IOException;
-import java.io.PrintStream;
-
-public class HTMLUtil {
- private PrintStream out = null;
- private int colspan = 3;
-
- public HTMLUtil(PrintStream out) {
- this.out = out;
- }
-
- public void println(String s) {
- if (out != null)
- out.println(s);
- }
-
- public static String tag(String name, String attr, String body) {
- return "<" + name + attr + ">" + body + "</" + name + ">\n";
- }
-
- public static String tag(String name, String body) {
- return "<" + name + ">" + body + "</" + name + ">\n";
- }
-
- public static String atag(String name, String attr) {
- return "<" + name + attr + "/>\n";
- }
-
- public static String btag(String name, String body, String... atts) {
- String ret = "<" + name + " ";
- if (atts != null && atts.length > 0) {
- for (String s : atts)
- ret += s + " ";
- }
- return ret + ">" + body + "</" + name + ">\n";
- }
-
- public static String att(String attr, String val) {
- if (val == null)
- return "";
- else
- return " " + attr + " = \"" + val + "\" ";
- }
-
- public static String table(boolean b, String body) {
- return btag("table", body, att("center", (b ? "center" :
null)));
- }
-
- public static String div(String cls, String id, String align, String
style,
- String body) {
- return btag("div", body, att("class", cls), att("id", id),
att("align",
- align), att("style", style));
- }
-
- public static String form(String action, String name, String method,
- String onsubmit, String body) {
- return btag("form", body, att("action", action), att("name",
name),
- att("method", method), att("onsubmit",
onsubmit));
- }
-
- public static String p(String cls, String body) {
- return btag("p", body, att("class", cls));
- }
-
- public static String input(String type, String name, String value,
- String onClick, String body) {
- return btag("input", body, att("type", type), att("name",
name), att(
- "value", value), att("onClick", onClick));
- }
-
- public static String radio_chk(String type, String name, String value,
- String onClick, String body) {
- return btag("input", body, att("type", type), att("name",
name), att(
- "value", value), att("onClick", onClick),
- att("checked", "true"));
- }
-
- public static String input_id(String type, String id, String value,
- String onClick, String body) {
- return btag("input", body, att("type", type), att("id", id),
att(
- "value", value), att("onClick", onClick));
- }
-
- public static String colouredtext(String text, String colour) {
- return tag("font", att("color", colour), text);
- }
-
- private static final String doctype = "<!DOCTYPE HTML PUBLIC
\"-//W3C//DTD HTML 4.01"
- + " Transitional//EN\"
\"http://www.w3.org/TR/html4/loose.dtd\";> ";
- private static final String cssFile = "default.css";
- private static final String onClickAttribute = "
onclick=\"checkIt(this);\" ";
- private static final String nbsp = "&nbsp;";
- private static final String checkedAttribute = " checked =\"true\" ";
//
- private static final String blockedAttribute = "
style=\"display:block;\" ";
- private static final String unblockedAttribute = "
style=\"display:none;\" ";
-
- private static String times(int i) {
- String ret = "";
- for (int j = 0; j < i; j++)
- ret += nbsp;
- return ret;
- }
-
- private String getCSS() {
- String css = "<link rel=\"stylesheet\" type=\"text/css\"
href=\""
- + cssFile + "\"/>";
- return css;
- }
-
- private String getScript() // FIXME Vl_ stuff
- {
- return "<script src=\"wa/scripts/Service_Admin.js\">"
- + "</script>\n"
- + "<script src=\"wz_tooltip.js\">"
- + "</script>\n"
- + "<script
src=\"wa/scripts/Service_Admin.js\">"
- + "</script>\n"
- + "<script type=\"text/javascript\">\n"
- + "function checkIt(el) {\n"
- // el = clicked element
- // el.value = value attribute of clicked
element el
- // el.name = name attribute of clicked
element el
- // if the clicked element's value is the same
- // as the hidden tag's (whose id=Vl_ + name
clicked elt)
- // default value then
- // disable all elements whose id is the same
as the
- // clicked element's name
- // +
- // "document.write(el.value
+\"\\n\"+document.getElementById(\"Vl_\"+el.name).value+\"\\n\"+document.getElementById(el.name).style.display)\n"
- + "if (el.value == "
- +
"document.getElementById(\"Vl_\"+el.name).value) {\n"
- +
"document.getElementById(el.name).style.display = "
- + "\"block\";\n" + "}\n" + "else {\n"
- +
"document.getElementById(el.name).style.display ="
- + " \"none\";\n" + "}\n" + "}\n" +
"</script>\n";
- }
-
- public void preamble() throws IOException {
- println(doctype);
- println("<html>");
- println("<head>" + getCSS() + "</head>");
- println("<title>");
- println("perfSONAR services configuration wizard");
- println("</title>");
- println("<body>");
- println(getScript());
- println("<div class=\"main\">");
- }
-
- public void postscript() throws IOException {
- println("</div>");
- println("</body>");
- println("</html>");
- }
-
- // Specification:
- // for each grouped radio elt
- // there exists a hidden tag
- // whose
- // id = Vl_+name attr of radio elt
- // and
- // name denotes the disabled value
- // there exist other elements
- // whose
- // id = name attr of radio elt
-
- public void radiogroup_begin(String id, String title, String yesval,
- String noval, boolean enabled) throws IOException {
- println(
- // att("align","center"),
- tag("tr", tag("td", title)
- + // ,att("colspan",""+3)
- times(13)
- + tag("td", atag("input", att("type",
"hidden")
- + att("value", yesval) +
att("id", "Vl_" + id))
- + tag("input", att("type",
"radio") + att("name", id)
- +
att("value", yesval) + onClickAttribute
- + (enabled ?
checkedAttribute : ""), times(2)
- + yesval +
nbsp)
- + tag("input", att("type",
"radio") + att("name", id)
- +
att("value", noval) + onClickAttribute
- + (!enabled ?
checkedAttribute : ""), times(2)
- + noval +
times(14)))));
- println("<tr><td>" + "<div " + att("id", id)
- + att("class", "inner_properties")
- + (!enabled ? unblockedAttribute :
blockedAttribute) + " > ");// +
-

// "<div "+
-

// att("class","properties")
-

// +
-

// " >");
- table_begin();
- }
-
- public void radiogroup_end() {
- table_end();
-
- println("</div></td></tr>");
- }
-
- private void generictextbox(String type, String key, String title,
- String val) throws IOException {
-
- final int size = 30;
- println(tag("tr", tag("td", att("colspan", "" + colspan),
title)
- + tag("td", att("align", "left"),
atag("input", att("class",
- "input_style")
- + att("type", type)
- + att("name", key)
- + att("size", "" + size) +
att("value", val))))
-
- );
- }
-
- public void textbox(String key, String title, String val)
- throws IOException {
- generictextbox("text", key, title, val);
- }
-
- public void passtextbox(String key, String title, String val)
- throws IOException {
- generictextbox("password", key, title, val);
- }
-
- // assumes keys.length = vals.length
- public void radio(String key, String title, String[] vals)
- throws IOException {
- String opts = "";
- for (int i = 0; i < vals.length; i++) {
- opts += tag("input", att("type", "radio") +
att("name", key)
- + att("value", vals[i]) + (i == 0 ?
checkedAttribute : ""),
- times(2) + vals[i] + nbsp);
- }
- println(tag("tr", tag("td", att("colspan", "" + colspan),
title)
- + tag("td", opts)));
- }
-
- public void dropdown(String key, String title, String[] vals) {
- String opts = "";
- for (int i = 0; i < vals.length; i++)
- opts += tag("option", att("value", vals[i]), vals[i]);
- println(tag("tr", tag("td", att("colspan", "" + colspan),
title)
- + tag("td", att("align", "left"),
tag("select",
- att("name", key), opts))));
- }
-
- public void form_begin(String key, String val, String url, int
spacing)
- throws IOException {
- println("<div "
- + att("class", "properties")
- + " > "
- +
- "<form action=\"" + url + "\"
method=\"POST\">\n"
- + "<input type=\"hidden\" name=\"" + key +
"\" value=\"" + val
- + "\">\n" + "<table align=\"center\" "
- + att("cellspacing", spacing + "%") + " >");
- }
-
- public void form_end() throws IOException {
- println(tag("tr", tag("td", nbsp)
- + tag("td", att("align", "right") +
att("colspan", "" + colspan),
- atag("input", att("type", "submit") +
att("class", "submit_button")
- + att("name", "submit") +
att("value", "Submit"))))
- + "</table><p/>\n" + "</form>" +
- "</div>");
- }
-
- public void singlerow_begin(int spacing, int span) {
-
- println("<tr><td " + att("colspan", "" + span) + " >");
- table_begin(spacing);
- }
-
- public void singlerow_begin(int spacing) {
- singlerow_begin(spacing, 1);
- }
-
- public void singlerow_end() {
- table_end();
- println("</td></tr>");
- }
-
- public void table_begin() {
- table_begin(10);
- }
-
- public void table_begin(int spacing) {
- println("<div " + att("class", "properties") + " > "
- + "<table align=\"left\" "
- + att("cellspacing", spacing + "%") + ">");
- }
-
- public void table_end() {
- println("</table></div>");
- }
-
- public void simplelineoftext(String text, String colour) { // +
-
// att("colspan",""+span)
- println("<tr><td " + " >\n"
- + tag("tr", tag("td", tag("p",
colouredtext(text, colour))))
- + "</td></tr>");
- }
-
- public void simplelineoftext(String span, String text, String colour)
{ //
- println("<tr><td " + att("colspan", "" + span) + " >\n"
- + tag("tr", tag("td", tag("p",
colouredtext(text, colour))))
- + "</td></tr>");
- }
-};

Copied:
trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-component/src/main/java/org/perfsonar/webadmin/base2/util/HTMLUtil.java
(from rev 5986,
trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-component/src/main/java/org/perfsonar/webadmin/base2/util/HTMLUtilStringBuffer.java)
===================================================================
---
trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-component/src/main/java/org/perfsonar/webadmin/base2/util/HTMLUtil.java
(rev 0)
+++
trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-component/src/main/java/org/perfsonar/webadmin/base2/util/HTMLUtil.java
2012-09-05 11:17:18 UTC (rev 5993)
@@ -0,0 +1,386 @@
+package org.perfsonar.webadmin.base2.util;
+
+import java.io.IOException;
+
+/**
+ * Generates HTML code for the WebAdmin pages.
+ * This is done in a StringBufffer for ease of use.
+ */
+public class HTMLUtil {
+ private int colspan = 3;
+ private StringBuffer sb;
+
+ public HTMLUtil(StringBuffer sb) {
+ this.sb = sb;
+ }
+
+ public void println(String s) {
+ sb.append(s);
+ }
+
+ public String getContent() {
+ return sb.toString();
+ }
+
+ public static String tag(String name, String attr, String body) {
+ return "<" + name + attr + ">" + body + "</" + name + ">\n";
+ }
+
+ public static String tag(String name, String body) {
+ return "<" + name + ">" + body + "</" + name + ">\n";
+ }
+
+ public static String atag(String name, String attr) {
+ return "<" + name + attr + "/>\n";
+ }
+
+ public static String tag(String name) {
+ return "<" + name + "/>\n";
+ }
+
+ public static String btag(String name, String body, String... atts) {
+ String ret = "<" + name + " ";
+ if (atts != null && atts.length > 0) {
+ for (String s : atts)
+ ret += s + " ";
+ }
+ return ret + ">" + body + "</" + name + ">\n";
+ }
+
+ public static String att(String attr, String val) {
+ if (val == null)
+ return "";
+ else
+ return " " + attr + " = \"" + val + "\" ";
+ }
+
+ public static String table(boolean b, String body) {
+ return btag("table", body, att("center", (b ? "center" :
null)));
+ }
+
+ public static String div(String cls, String id, String align, String
style,
+ String body) {
+ return btag("div", body, att("class", cls), att("id", id),
att("align",
+ align), att("style", style));
+ }
+
+ public static String form(String action, String name, String method,
+ String onsubmit, String body) {
+ return btag("form", body, att("action", action), att("name",
name),
+ att("method", method), att("onsubmit",
onsubmit));
+ }
+
+ public static String p(String cls, String body) {
+ return btag("p", body, att("class", cls));
+ }
+
+ public static String input(String type, String name, String value,
+ String onClick, String body) {
+ return btag("input", body, att("type", type), att("name",
name), att(
+ "value", value), att("onClick", onClick));
+ }
+
+ public static String radio_chk(String type, String name, String value,
+ String onClick, String body) {
+ return btag("input", body, att("type", type), att("name",
name), att(
+ "value", value), att("onClick", onClick),
+ att("checked", "true"));
+ }
+
+ public static String input_id(String type, String id, String value,
+ String onClick, String body) {
+ return btag("input", body, att("type", type), att("id", id),
att(
+ "value", value), att("onClick", onClick));
+ }
+
+ public static String html(String body) {
+ return btag("html", body);
+ }
+
+ public static String body(String bd) {
+ return btag("body", bd);
+ }
+
+ public static String head(String bd) {
+ return btag("head", bd);
+ }
+
+ public static String title(String bd) {
+ return btag("title", bd);
+ }
+
+ public static String ul(String bd) {
+ return btag("ul", bd);
+ }
+
+ public static String li(String bd) {
+ return btag("li", bd);
+ }
+
+ public static String h1(String bd) {
+ return btag("h1", bd);
+ }
+
+ public static String a(String href, String bd) {
+ return btag("a", bd, att("href", href));
+ }
+
+ public static String br(String body) {
+ return btag("br", body);
+ }
+
+ public static String tr(String body) {
+ return btag("tr", body);
+ }
+
+ public static String td(String body) {
+ return btag("td", body);
+ }
+
+ public static String td_col(String body) {
+ return btag("td", body, att("colspan", "2"));
+ }
+
+ public static String span(String cls, String body) {
+ return btag("span", body, att("class", cls));
+ }
+
+ public static String colouredtext(String text, String colour) {
+ return tag("font", att("color", colour), text);
+ }
+
+ public static String greenasterisk() {
+ return "<span class=\"greenasterisk\" >*</span>";
+ }
+
+ private static final String doctype = "<!DOCTYPE HTML PUBLIC
\"-//W3C//DTD HTML 4.01"
+ + " Transitional//EN\"
\"http://www.w3.org/TR/html4/loose.dtd\";> ";
+ private static final String cssFile = "default.css";
+ private static final String onClickAttribute = "
onclick=\"checkIt(this);\" ";
+ private static final String nbsp = "&nbsp;";
+ private static final String checkedAttribute = " checked =\"true\" ";
//
+ private static final String blockedAttribute = "
style=\"display:block;\" ";
+ private static final String unblockedAttribute = "
style=\"display:none;\" ";
+
+ private static String times(int i) {
+ String ret = "";
+ for (int j = 0; j < i; j++)
+ ret += nbsp;
+ return ret;
+ }
+
+ private String getCSS() {
+ String css = "<link rel=\"stylesheet\" type=\"text/css\"
href=\""
+ + cssFile + "\"/>";
+ return css;
+ }
+
+ private String getScript() // FIXME Vl_ stuff
+ {
+ return "<script src=\"Service_Admin.js\">"
+ + "</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"
+ // el = clicked element
+ // el.value = value attribute of clicked
element el
+ // el.name = name attribute of clicked
element el
+ // if the clicked element's value is the same
+ // as the hidden tag's (whose id=Vl_ + name
clicked elt)
+ // default value then
+ // disable all elements whose id is the same
as the
+ // clicked element's name
+ // +
+ // "document.write(el.value
+\"\\n\"+document.getElementById(\"Vl_\"+el.name).value+\"\\n\"+document.getElementById(el.name).style.display)\n"
+ + "if (el.value == "
+ +
"document.getElementById(\"Vl_\"+el.name).value) {\n"
+ +
"document.getElementById(el.name).style.display = "
+ + "\"block\";\n" + "}\n" + "else {\n"
+ +
"document.getElementById(el.name).style.display ="
+ + " \"none\";\n" + "}\n" + "}\n" +
"</script>\n";
+ }
+
+ public void preamble() throws IOException {
+ println(getScript());
+ println("<div class=\"main\">");
+ }
+
+ public void postscript() throws IOException {
+ println("</div>");
+ }
+
+ public void errorBox(String body) {
+ println(btag("div", body, att("class", "failed")));
+ }
+
+ // Specification:
+ // for each grouped radio elt
+ // there exists a hidden tag
+ // whose
+ // id = Vl_+name attr of radio elt
+ // and
+ // name denotes the disabled value
+ // there exist other elements
+ // whose
+ // id = name attr of radio elt
+
+ public void radiogroup_begin(String id, String title, String yesval,
+ String noval, boolean enabled) throws IOException {
+ println(
+ // att("align","center"),
+ tag("tr", tag("td", title)
+ + // ,att("colspan",""+3)
+ times(13)
+ + tag("td", atag("input", att("type",
"hidden")
+ + att("value", yesval) +
att("id", "Vl_" + id))
+ + tag("input", att("type",
"radio") + att("name", id)
+ +
att("value", yesval) + onClickAttribute
+ + (enabled ?
checkedAttribute : ""), times(2)
+ + yesval +
nbsp)
+ + tag("input", att("type",
"radio") + att("name", id)
+ +
att("value", noval) + onClickAttribute
+ + (!enabled ?
checkedAttribute : ""), times(2)
+ + noval +
times(14)))));
+ println("<tr><td>" + "<div " + att("id", id)
+ + att("class", "inner_properties")
+ + (!enabled ? unblockedAttribute :
blockedAttribute) + " > ");// +
+ // "<div "+
+ // att("class","properties")
+ // +
+ // " >");
+ table_begin();
+ }
+
+ public void radiogroup_end() {
+ table_end();
+
+ println("</div></td></tr>");
+ }
+
+ private void generictextbox(String type, String key, String title,
+ String val) throws IOException {
+
+ final int size = 30;
+ println(tag("tr", tag("td", att("colspan", "" + colspan),
title)
+ + tag("td", att("align", "left"),
atag("input", att("class",
+ "input_style")
+ + att("type", type)
+ + att("name", key)
+ + att("size", "" + size) +
att("value", val))))
+
+ );
+ }
+
+ public void textbox(String key, String title, String val)
+ throws IOException {
+ generictextbox("text", key, title, val);
+ }
+
+ public void passtextbox(String key, String title, String val)
+ throws IOException {
+ generictextbox("password", key, title, val);
+ }
+
+ // assumes keys.length = vals.length
+ public void radio(String key, String title, String[] vals)
+ throws IOException {
+ String opts = "";
+ for (int i = 0; i < vals.length; i++) {
+ opts += tag("input", att("type", "radio") +
att("name", key)
+ + att("value", vals[i]) + (i == 0 ?
checkedAttribute : ""),
+ times(2) + vals[i] + nbsp);
+ }
+ println(tag("tr", tag("td", att("colspan", "" + colspan),
title)
+ + tag("td", opts)));
+ }
+
+ public void dropdown(String key, String title, String[] vals) {
+ String opts = "";
+ for (int i = 0; i < vals.length; i++)
+ opts += tag("option", att("value", vals[i]), vals[i]);
+ println(tag("tr", tag("td", att("colspan", "" + colspan),
title)
+ + tag("td", att("align", "left"),
tag("select",
+ att("name", key), opts))));
+ }
+
+ public void form_begin(String key, String val, String url, int
spacing)
+ throws IOException {
+ println("<div "
+ + att("class", "properties")
+ + " > "
+ +
+ // "<center>" +
+ "<form action=\"" + url + "\"
method=\"POST\">\n"
+ + "<input type=\"hidden\" name=\"" + key +
"\" value=\"" + val
+ + "\">\n" + "<table align=\"center\" "
+ + att("cellspacing", spacing + "%") + " >");
+ }
+
+ public void form_begin(String key, String val, String url)
+ throws IOException {
+ form_begin(key, val, url, 10);
+ }
+
+ public void form_end() throws IOException {
+ println(tag("tr", tag("td", nbsp)
+ + tag("td", att("align", "right") +
att("colspan", "" + colspan),
+ atag("input", att("type", "submit") +
att("class", "submit_button")
+ + att("name", "submit") +
att("value", "Submit"))))
+ + "</table><p/>\n" + "</form>" +
+ // "</center>"+
+ "</div>");
+ }
+
+ public void singlerow_begin(int spacing, int span) {
+
+ println("<tr><td " + att("colspan", "" + span) + " >");
+ table_begin(spacing);
+ }
+
+ public void singlerow_begin(int spacing) {
+ singlerow_begin(spacing, 1);
+ }
+
+ public void singlerow_end() {
+ table_end();
+ println("</td></tr>");
+ }
+
+ public void table_begin() {
+ // println("<center><table align=\"center\">");
+ table_begin(10);
+ }
+
+ public void table_begin(int spacing) {
+ println("<div " + att("class", "properties") + " > "
+ + "<center><table align=\"left\" "
+ + att("cellspacing", spacing + "%") + ">");
+ }
+
+ public void table_end() {
+ println("</table></center></div>");
+ }
+
+ public void lineoftext(String text, String colour, int fill) {
+ singlerow_begin(1, 2);
+ println(tag("tr", tag("td", colouredtext(text + times(fill),
colour))));
+ singlerow_end();
+ }
+
+ public void simplelineoftext(String text, String colour) { // +
+ // att("colspan",""+span)
+ println("<tr><td " + " >\n"
+ + tag("tr", tag("td", tag("p",
colouredtext(text, colour))))
+ + "</td></tr>");
+ }
+
+ public void simplelineoftext(String span, String text, String colour)
{ //
+ println("<tr><td " + att("colspan", "" + span) + " >\n"
+ + tag("tr", tag("td", tag("p",
colouredtext(text, colour))))
+ + "</td></tr>");
+ }
+
+};

Deleted:
trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-component/src/main/java/org/perfsonar/webadmin/base2/util/HTMLUtilStringBuffer.java
===================================================================
---
trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-component/src/main/java/org/perfsonar/webadmin/base2/util/HTMLUtilStringBuffer.java
2012-09-05 10:33:57 UTC (rev 5992)
+++
trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-component/src/main/java/org/perfsonar/webadmin/base2/util/HTMLUtilStringBuffer.java
2012-09-05 11:17:18 UTC (rev 5993)
@@ -1,372 +0,0 @@
-package org.perfsonar.webadmin.base2.util;
-
-import java.io.IOException;
-
-public class HTMLUtilStringBuffer {
- private int colspan = 3;
- private StringBuffer sb;
-
- public HTMLUtilStringBuffer(StringBuffer sb) {
- this.sb = sb;
- }
-
- public void println(String s) {
- sb.append(s);
- }
-
- public String getContent() {
- return sb.toString();
- }
-
- public static String tag(String name, String attr, String body) {
- return "<" + name + attr + ">" + body + "</" + name + ">\n";
- }
-
- public static String tag(String name, String body) {
- return "<" + name + ">" + body + "</" + name + ">\n";
- }
-
- public static String atag(String name, String attr) {
- return "<" + name + attr + "/>\n";
- }
-
- public static String tag(String name) {
- return "<" + name + "/>\n";
- }
-
- public static String btag(String name, String body, String... atts) {
- String ret = "<" + name + " ";
- if (atts != null && atts.length > 0) {
- for (String s : atts)
- ret += s + " ";
- }
- return ret + ">" + body + "</" + name + ">\n";
- }
-
- public static String att(String attr, String val) {
- if (val == null)
- return "";
- else
- return " " + attr + " = \"" + val + "\" ";
- }
-
- public static String table(boolean b, String body) {
- return btag("table", body, att("center", (b ? "center" :
null)));
- }
-
- public static String div(String cls, String id, String align, String
style,
- String body) {
- return btag("div", body, att("class", cls), att("id", id),
att("align",
- align), att("style", style));
- }
-
- public static String form(String action, String name, String method,
- String onsubmit, String body) {
- return btag("form", body, att("action", action), att("name",
name),
- att("method", method), att("onsubmit",
onsubmit));
- }
-
- public static String p(String cls, String body) {
- return btag("p", body, att("class", cls));
- }
-
- public static String input(String type, String name, String value,
- String onClick, String body) {
- return btag("input", body, att("type", type), att("name",
name), att(
- "value", value), att("onClick", onClick));
- }
-
- public static String radio_chk(String type, String name, String value,
- String onClick, String body) {
- return btag("input", body, att("type", type), att("name",
name), att(
- "value", value), att("onClick", onClick),
- att("checked", "true"));
- }
-
- public static String input_id(String type, String id, String value,
- String onClick, String body) {
- return btag("input", body, att("type", type), att("id", id),
att(
- "value", value), att("onClick", onClick));
- }
-
- public static String html(String body) {
- return btag("html", body);
- }
-
- public static String body(String bd) {
- return btag("body", bd);
- }
-
- public static String head(String bd) {
- return btag("head", bd);
- }
-
- public static String title(String bd) {
- return btag("title", bd);
- }
-
- public static String ul(String bd) {
- return btag("ul", bd);
- }
-
- public static String li(String bd) {
- return btag("li", bd);
- }
-
- public static String h1(String bd) {
- return btag("h1", bd);
- }
-
- public static String a(String href, String bd) {
- return btag("a", bd, att("href", href));
- }
-
- public static String br(String body) {
- return btag("br", body);
- }
-
- public static String tr(String body) {
- return btag("tr", body);
- }
-
- public static String td(String body) {
- return btag("td", body);
- }
-
- public static String td_col(String body) {
- return btag("td", body, att("colspan", "2"));
- }
-
- public static String span(String cls, String body) {
- return btag("span", body, att("class", cls));
- }
-
- public static String colouredtext(String text, String colour) {
- return tag("font", att("color", colour), text);
- }
-
- public static String greenasterisk() {
- return "<span class=\"greenasterisk\" >*</span>";
- }
-
- private static final String doctype = "<!DOCTYPE HTML PUBLIC
\"-//W3C//DTD HTML 4.01"
- + " Transitional//EN\"
\"http://www.w3.org/TR/html4/loose.dtd\";> ";
- private static final String cssFile = "default.css";
- private static final String onClickAttribute = "
onclick=\"checkIt(this);\" ";
- private static final String nbsp = "&nbsp;";
- private static final String checkedAttribute = " checked =\"true\" ";
//
- private static final String blockedAttribute = "
style=\"display:block;\" ";
- private static final String unblockedAttribute = "
style=\"display:none;\" ";
-
- private static String times(int i) {
- String ret = "";
- for (int j = 0; j < i; j++)
- ret += nbsp;
- return ret;
- }
-
- private String getScript() // FIXME Vl_ stuff
- {
- return "<script src=\"Service_Admin.js\">"
- + "</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"
- // el = clicked element
- // el.value = value attribute of clicked
element el
- // el.name = name attribute of clicked
element el
- // if the clicked element's value is the same
- // as the hidden tag's (whose id=Vl_ + name
clicked elt)
- // default value then
- // disable all elements whose id is the same
as the
- // clicked element's name
- // +
- // "document.write(el.value
+\"\\n\"+document.getElementById(\"Vl_\"+el.name).value+\"\\n\"+document.getElementById(el.name).style.display)\n"
- + "if (el.value == "
- +
"document.getElementById(\"Vl_\"+el.name).value) {\n"
- +
"document.getElementById(el.name).style.display = "
- + "\"block\";\n" + "}\n" + "else {\n"
- +
"document.getElementById(el.name).style.display ="
- + " \"none\";\n" + "}\n" + "}\n" +
"</script>\n";
- }
-
- public void preamble() throws IOException {
- println(getScript());
- println("<div class=\"main\">");
- }
-
- public void postscript() throws IOException {
- println("</div>");
- }
-
- // Specification:
- // for each grouped radio elt
- // there exists a hidden tag
- // whose
- // id = Vl_+name attr of radio elt
- // and
- // name denotes the disabled value
- // there exist other elements
- // whose
- // id = name attr of radio elt
-
- public void radiogroup_begin(String id, String title, String yesval,
- String noval, boolean enabled) throws IOException {
- println(
- // att("align","center"),
- tag("tr", tag("td", title)
- + // ,att("colspan",""+3)
- times(13)
- + tag("td", atag("input", att("type",
"hidden")
- + att("value", yesval) +
att("id", "Vl_" + id))
- + tag("input", att("type",
"radio") + att("name", id)
- +
att("value", yesval) + onClickAttribute
- + (enabled ?
checkedAttribute : ""), times(2)
- + yesval +
nbsp)
- + tag("input", att("type",
"radio") + att("name", id)
- +
att("value", noval) + onClickAttribute
- + (!enabled ?
checkedAttribute : ""), times(2)
- + noval +
times(14)))));
- println("<tr><td>" + "<div " + att("id", id)
- + att("class", "inner_properties")
- + (!enabled ? unblockedAttribute :
blockedAttribute) + " > ");// +
- // "<div "+
- // att("class","properties")
- // +
- // " >");
- table_begin();
- }
-
- public void radiogroup_end() {
- table_end();
-
- println("</div></td></tr>");
- }
-
- private void generictextbox(String type, String key, String title,
- String val) throws IOException {
-
- final int size = 30;
- println(tag("tr", tag("td", att("colspan", "" + colspan),
title)
- + tag("td", att("align", "left"),
atag("input", att("class",
- "input_style")
- + att("type", type)
- + att("name", key)
- + att("size", "" + size) +
att("value", val))))
-
- );
- }
-
- public void textbox(String key, String title, String val)
- throws IOException {
- generictextbox("text", key, title, val);
- }
-
- public void passtextbox(String key, String title, String val)
- throws IOException {
- generictextbox("password", key, title, val);
- }
-
- // assumes keys.length = vals.length
- public void radio(String key, String title, String[] vals)
- throws IOException {
- String opts = "";
- for (int i = 0; i < vals.length; i++) {
- opts += tag("input", att("type", "radio") +
att("name", key)
- + att("value", vals[i]) + (i == 0 ?
checkedAttribute : ""),
- times(2) + vals[i] + nbsp);
- }
- println(tag("tr", tag("td", att("colspan", "" + colspan),
title)
- + tag("td", opts)));
- }
-
- public void dropdown(String key, String title, String[] vals) {
- String opts = "";
- for (int i = 0; i < vals.length; i++)
- opts += tag("option", att("value", vals[i]), vals[i]);
- println(tag("tr", tag("td", att("colspan", "" + colspan),
title)
- + tag("td", att("align", "left"),
tag("select",
- att("name", key), opts))));
- }
-
- public void form_begin(String key, String val, String url, int
spacing)
- throws IOException {
- println("<div "
- + att("class", "properties")
- + " > "
- +
- // "<center>" +
- "<form action=\"" + url + "\"
method=\"POST\">\n"
- + "<input type=\"hidden\" name=\"" + key +
"\" value=\"" + val
- + "\">\n" + "<table align=\"center\" "
- + att("cellspacing", spacing + "%") + " >");
- }
-
- public void form_begin(String key, String val, String url)
- throws IOException {
- form_begin(key, val, url, 10);
- }
-
- public void form_end() throws IOException {
- println(tag("tr", tag("td", nbsp)
- + tag("td", att("align", "right") +
att("colspan", "" + colspan),
- atag("input", att("type", "submit") +
att("class", "submit_button")
- + att("name", "submit") +
att("value", "Submit"))))
- + "</table><p/>\n" + "</form>" +
- // "</center>"+
- "</div>");
- }
-
- public void singlerow_begin(int spacing, int span) {
-
- println("<tr><td " + att("colspan", "" + span) + " >");
- table_begin(spacing);
- }
-
- public void singlerow_begin(int spacing) {
- singlerow_begin(spacing, 1);
- }
-
- public void singlerow_end() {
- table_end();
- println("</td></tr>");
- }
-
- public void table_begin() {
- // println("<center><table align=\"center\">");
- table_begin(10);
- }
-
- public void table_begin(int spacing) {
- println("<div " + att("class", "properties") + " > "
- + "<center><table align=\"left\" "
- + att("cellspacing", spacing + "%") + ">");
- }
-
- public void table_end() {
- println("</table></center></div>");
- }
-
- public void lineoftext(String text, String colour, int fill) {
- singlerow_begin(1, 2);
- println(tag("tr", tag("td", colouredtext(text + times(fill),
colour))));
- singlerow_end();
- }
-
- public void simplelineoftext(String text, String colour) { // +
- // att("colspan",""+span)
- println("<tr><td " + " >\n"
- + tag("tr", tag("td", tag("p",
colouredtext(text, colour))))
- + "</td></tr>");
- }
-
- public void simplelineoftext(String span, String text, String colour)
{ //
- println("<tr><td " + att("colspan", "" + span) + " >\n"
- + tag("tr", tag("td", tag("p",
colouredtext(text, colour))))
- + "</td></tr>");
- }
-
-};

Modified:
trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-component/src/main/java/org/perfsonar/webadmin/base2/util/NSContext.java
===================================================================
---
trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-component/src/main/java/org/perfsonar/webadmin/base2/util/NSContext.java
2012-09-05 10:33:57 UTC (rev 5992)
+++
trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-component/src/main/java/org/perfsonar/webadmin/base2/util/NSContext.java
2012-09-05 11:17:18 UTC (rev 5993)
@@ -5,9 +5,9 @@
import javax.xml.*;
import java.util.Iterator;

-public class NSContext extends HashMap<String, String> implements
- NamespaceContext {
- // private myurl = "";
+@SuppressWarnings("serial")
+public class NSContext extends HashMap<String, String> implements
NamespaceContext {
+
public NSContext() {
put("xml", XMLConstants.XML_NS_URI);
}
@@ -19,13 +19,12 @@
return (s == null) ? XMLConstants.NULL_NS_URI : s;
}

- // This method isn't necessary for XPath processing.
+ // FIXME: This method isn't necessary for XPath processing.
public String getPrefix(String uri) {
throw new UnsupportedOperationException();
}

- // This method isn't necessary for XPath processing either.
- //
+ // FIXME: This method isn't necessary for XPath processing either.
public Iterator getPrefixes(String uri) {
throw new UnsupportedOperationException();
}

Deleted:
trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-component/src/main/java/org/perfsonar/webadmin/base2/util/StringOutputStream.java
===================================================================
---
trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-component/src/main/java/org/perfsonar/webadmin/base2/util/StringOutputStream.java
2012-09-05 10:33:57 UTC (rev 5992)
+++
trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-component/src/main/java/org/perfsonar/webadmin/base2/util/StringOutputStream.java
2012-09-05 11:17:18 UTC (rev 5993)
@@ -1,47 +0,0 @@
-package org.perfsonar.webadmin.base2.util;
-
-import java.io.OutputStream;
-import java.io.Serializable;
-
-public class StringOutputStream extends OutputStream implements Serializable
{
- protected StringBuffer buf = null;
-
- public StringOutputStream() {
- super();
- buf = new StringBuffer();
- }
-
- public String toString() {
- return buf.toString();
- }
-
- public void close() {
- buf = null;
- }
-
- public void write(byte[] bytes) {
- char[] carr = new char[bytes.length];
- for (int i = 0; i < bytes.length; i++)
- carr[i] = (char) bytes[i];
- buf.append(carr);
- }
-
- public void write(byte[] b, int off, int len) {
- if ((off < 0) || (len < 0) || (off + len) > b.length) {
- throw new IndexOutOfBoundsException("Out of bounds");
- }
- byte[] bytes = new byte[len];
- for (int i = 0; i < len; i++) {
- bytes[i] = b[off];
- off++;
- }
- char[] carr = new char[bytes.length];
- for (int i = 0; i < bytes.length; i++)
- carr[i] = (char) bytes[i];
- buf.append(carr);
- }
-
- public void write(int b) {
- buf.append((char) b);
- }
-}

Modified:
trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-component/src/main/webapp/views/error.jsp
===================================================================
---
trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-component/src/main/webapp/views/error.jsp
2012-09-05 10:33:57 UTC (rev 5992)
+++
trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-component/src/main/webapp/views/error.jsp
2012-09-05 11:17:18 UTC (rev 5993)
@@ -1,10 +1,14 @@
-<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
+<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>

+<div class="centerWindow">

-<center>
- <h2>
- We failed to load web admin configuration file(s). <br />
- Please check Tomcat log files for further information. <br />
- Restart Tomcat after saving web admin configuration files and click
- <a href="index.jsp" target="_self"> here</a>.</h2>
-</center>
\ No newline at end of file
+<p class="heading1">Trying to load WebAdmin configuration file.</p>
+
+<div class="failed">
+ <p>We failed loading the WebAdmin configuration file(s).</p>
+ <p>Hopefully you'll find further information in the Tomcat log files.</p>
+ <p>After correcting the configuration, you'll probably need to restart
Tomcat and reload this page.</p>
+</div>
+
+<p class="properties">The perfSONAR logs may contain more information
explaining the cause of this error.</p>
+</div>

Modified:
trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-component/src/main/webapp/views/savedFailed.jsp
===================================================================
---
trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-component/src/main/webapp/views/savedFailed.jsp
2012-09-05 10:33:57 UTC (rev 5992)
+++
trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-component/src/main/webapp/views/savedFailed.jsp
2012-09-05 11:17:18 UTC (rev 5993)
@@ -1,6 +1,12 @@
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>

+<div class="centerWindow">

-<p class="heading1">
- The configuration file has <b>NOT</b> been saved.
-</p>
\ No newline at end of file
+<p class="heading1">Trying to save configuration file to disk.</p>
+
+<div class="failed">
+ <p>The configuration file has <b>NOT</b> been saved.</p>
+</div>
+
+<p class="properties">The perfSONAR logs may contain more information
explaining the cause of this error.</p>
+</div>
\ No newline at end of file


Property changes on:
trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-exampleservice
___________________________________________________________________
Modified: svn:ignore
- .classpath

.project

.settings

target

+ .classpath

.project

.settings

target

logs


Modified:
trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-exampleservice/pom.xml
===================================================================
---
trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-exampleservice/pom.xml
2012-09-05 10:33:57 UTC (rev 5992)
+++
trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-exampleservice/pom.xml
2012-09-05 11:17:18 UTC (rev 5993)
@@ -12,17 +12,31 @@
<relativePath>..</relativePath>
</parent>

- <description>This is a example of how a perfSONAR service project can
add the WebAdmin WAR as an overlay.
+ <description>This is a example of how a perfSONAR service project can
add the WebAdmin WAR as an overlay. New servlet and JSP pages can be added
in the service itself.

-New servlet and JSP pages can be added in the service itself.</description>
+Servlet can extend the BasicServlet and then have the WebAdmin object map at
finger tips.

+JSP pages can be added at the root of the webapp/ directory (and a
corresponding entry in the web.xml) or inside de webapp/views/ directory and
be included in the WebAdmin index.jsp page (using the page parameter). This
last solution make it possible to re-use the same page layout easily (only
providing the JSP code needed to fill the main area of the page).
+</description>
+
<dependencies>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </dependency>
<dependency>
<groupId>net.geant.perfsonar</groupId>
<artifactId>web-admin-component</artifactId>
<version>${project.version}</version>
<type>war</type>
</dependency>
+ <dependency>
+ <!-- You need to include the web-admin-component jar (classes)
if you want to extend the BasicServlet class -->
+ <groupId>net.geant.perfsonar</groupId>
+ <artifactId>web-admin-component</artifactId>
+ <version>${project.version}</version>
+ <classifier>classes</classifier>
+ </dependency>
</dependencies>

<build>
@@ -35,12 +49,18 @@
<configuration>
<overlays>
<overlay>
+ <!-- The web-admin-component needs to be used
as a WAR overlay -->

<groupId>net.geant.perfsonar</groupId>

<artifactId>web-admin-component</artifactId>
</overlay>
</overlays>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.apache.tomcat.maven</groupId>
+ <artifactId>tomcat6-maven-plugin</artifactId>
+ <!-- This plugin can be called with a simple
'mvn clean tomcat6:run-war' -->
+ </plugin>
</plugins>

</build>

Added:
trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-exampleservice/src/main/java/org/perfsonar/webadmin/example/servlet/ExampleServlet.java
===================================================================
---
trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-exampleservice/src/main/java/org/perfsonar/webadmin/example/servlet/ExampleServlet.java
(rev 0)
+++
trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-exampleservice/src/main/java/org/perfsonar/webadmin/example/servlet/ExampleServlet.java
2012-09-05 11:17:18 UTC (rev 5993)
@@ -0,0 +1,37 @@
+/**
+ *
+ */
+package org.perfsonar.webadmin.example.servlet;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.perfsonar.webadmin.base2.servlet.BasicServlet;
+
+/**
+ * @author Antoine Delvaux - DANTE
+ *
+ */
+@SuppressWarnings("serial")
+public class ExampleServlet extends BasicServlet {
+
+ /**
+ * You override the doGet or doPost method to define your Servlet
behavior
+ */
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse
resp) throws ServletException, IOException {
+
+ req.setAttribute("exampleAttribute", "Hello from the
servlet!");
+
+ // If you want to have the same look and feel as the rest of
the WebAdmin
+ // You can just forward the request to the index.jsp page and
give
+ // your new views/example.jsp age as parameter.
+ getServletConfig().getServletContext().getRequestDispatcher(
+ "/index.jsp?page=example").forward(req, resp);
+
+ }
+
+}


Property changes on:
trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-exampleservice/src/main/java/org/perfsonar/webadmin/example/servlet/ExampleServlet.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain

Modified:
trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-exampleservice/src/main/webapp/WEB-INF/classes/perfsonar/conf/configuration.xml
===================================================================
---
trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-exampleservice/src/main/webapp/WEB-INF/classes/perfsonar/conf/configuration.xml
2012-09-05 10:33:57 UTC (rev 5992)
+++
trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-exampleservice/src/main/webapp/WEB-INF/classes/perfsonar/conf/configuration.xml
2012-09-05 11:17:18 UTC (rev 5993)
@@ -1,26 +1,27 @@
<?xml version='1.0' encoding='UTF-8'?>

-
<configuration xmlns="http://service.perfsonar.org/ns/config/base/0.9/";>

-<!-- This is a configuration file example for a perfSONAR service, in this
case the XML LS -->
+<!-- This is a configuration file example for a perfSONAR service -->
<!-- This file should be replaced by the real configuration file of the
service you integrate the Web Admin with -->
+<!-- The properties of this file will then be displayed by the WebAdmin
where you'll be able to edit it -->

- <service name="xmlls">
+<!-- The structure of this file is governed by the configuration-rules.xml
file which "digest" it -->

+ <service name="exampleService">
+
<!--
....................................................................................
-->

- <!-- Lookup Info of the LS instance -->
-
<lookupInformation>
- <option name="accessPoint"
value="http://localhost:8080/perfsonar-java-xml-ls/services/LookupService"/>
- <option name="serviceName" value="Example perfSONAR JAVA - XML LS"/>
- <option name="serviceType" value="LS"/>
+ <option name="accessPoint"
value="http://localhost:8080/perfsonar-java-web-admin-example-service/services/NoService"/>
+ <option name="serviceName" value="Example perfSONAR JAVA Service"/>
+ <option name="serviceType" value="Example"/>
</lookupInformation>

+
<!--
....................................................................................
-->

- <!-- Message Handlers - message types and service engines -->
+ <!-- Here are some sample definitions of properties you can edit with
the WebAdmin -->

<messageHandler>

@@ -68,9 +69,10 @@

</messageHandler>

+
<!--
....................................................................................
-->

- <!-- Additional auxiliary components -->
+ <!-- Some more properties, depending on your service (here comes from a
LS configuration file) -->

<auxiliaryComponents>

@@ -182,14 +184,12 @@

<!--
....................................................................................
-->

- <!-- Protocol mappings, XML elements and their bindings -->
+ <!-- Some more properties examples -->

<protocolMappings>

-
<!-- default mapping -->

-
<!-- general mappings -->
<element name="{*}message"
mapping="org.perfsonar.base2.xml.nmwg.Message"/>
@@ -209,12 +209,9 @@
mapping="org.perfsonar.base2.xml.Element"/>
<element
name="{http://ggf.org/ns/nmwg/tools/org/perfsonar/service/lookup/xquery/1.0/}subject";

mapping="org.perfsonar.base2.xml.TextElement"/>
-

</protocolMappings>

-
</service>

-
</configuration>

Modified:
trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-exampleservice/src/main/webapp/WEB-INF/classes/perfsonar/conf/webAdminConfig.xml
===================================================================
---
trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-exampleservice/src/main/webapp/WEB-INF/classes/perfsonar/conf/webAdminConfig.xml
2012-09-05 10:33:57 UTC (rev 5992)
+++
trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-exampleservice/src/main/webapp/WEB-INF/classes/perfsonar/conf/webAdminConfig.xml
2012-09-05 11:17:18 UTC (rev 5993)
@@ -26,6 +26,16 @@
<wa:title>WebAdmin Settings</wa:title>
</wa:basiclink>

+ <wa:basiclink>
+ <wa:redirectTo>externalLink</wa:redirectTo> <!-- link with
target="_blank" -->
+ <wa:title>Link in new window</wa:title>
+ </wa:basiclink>
+
+ <wa:basiclink>
+ <wa:servletId>internalLink</wa:servletId> <!-- link to a service
provided servlet -->
+ <wa:title>Internal link</wa:title>
+ </wa:basiclink>
+
<wa:advancedlink>
<wa:pageId>advanced</wa:pageId> <!-- page identifier -->
<wa:title>Detailed Settings</wa:title>
@@ -86,11 +96,11 @@
<wa:title>
<wa:text>Title of this page</wa:text>
</wa:title>
- <wa:plain>
+ <wa:plain>
<wa:textbox>
<wa:default>
<wa:xpath>
-
doc("classes/perfsonar/conf/configuration.xml")//ns1:configuration/ns1:service[@name="xmlls"]/ns1:lookupInformation/ns1:option[@name="accessPoint"]/@value
+
doc("classes/perfsonar/conf/configuration.xml")//ns1:configuration/ns1:service[@name="exampleService"]/ns1:lookupInformation/ns1:option[@name="accessPoint"]/@value
</wa:xpath>
</wa:default>
<wa:title>
@@ -102,7 +112,7 @@
<wa:textbox>
<wa:default>
<wa:xpath>
-
doc("classes/perfsonar/conf/configuration.xml")//ns1:configuration/ns1:service[@name="xmlls"]/ns1:lookupInformation/ns1:option[@name="serviceName"]/@value
+
doc("classes/perfsonar/conf/configuration.xml")//ns1:configuration/ns1:service[@name="exampleService"]/ns1:lookupInformation/ns1:option[@name="serviceName"]/@value
</wa:xpath>
</wa:default>
<wa:title>
@@ -114,7 +124,7 @@
<wa:textbox>
<wa:default>
<wa:xpath>
-
doc("classes/perfsonar/conf/configuration.xml")//ns1:configuration/ns1:service[@name="xmlls"]/ns1:lookupInformation/ns1:option[@name="serviceType"]/@value
+
doc("classes/perfsonar/conf/configuration.xml")//ns1:configuration/ns1:service[@name="exampleService"]/ns1:lookupInformation/ns1:option[@name="serviceType"]/@value
</wa:xpath>
</wa:default>
<wa:title>
@@ -127,7 +137,7 @@
<wa:textbox>
<wa:default>
<wa:xpath>
-
doc("classes/perfsonar/conf/configuration.xml")//ns1:configuration/ns1:service[@name="xmlls"]/ns1:auxiliaryComponents/ns1:component[@name="scheduling"]/ns1:actions/ns1:action[@name="LSCleanup_1"]/ns1:option[@name="interval"]/@value
+
doc("classes/perfsonar/conf/configuration.xml")//ns1:configuration/ns1:service[@name="exampleService"]/ns1:auxiliaryComponents/ns1:component[@name="scheduling"]/ns1:actions/ns1:action[@name="LSCleanup_1"]/ns1:option[@name="interval"]/@value
</wa:xpath>
</wa:default>
<wa:title>
@@ -140,7 +150,7 @@
<wa:textbox>
<wa:default>
<wa:xpath>
-
doc("classes/perfsonar/conf/configuration.xml")//ns1:configuration/ns1:service[@name="xmlls"]/ns1:auxiliaryComponents/ns1:component[@name="scheduling"]/ns1:actions/ns1:action[@name="LSCleanup_1"]/ns1:option[@name="lsTTL"]/@value
+
doc("classes/perfsonar/conf/configuration.xml")//ns1:configuration/ns1:service[@name="exampleService"]/ns1:auxiliaryComponents/ns1:component[@name="scheduling"]/ns1:actions/ns1:action[@name="LSCleanup_1"]/ns1:option[@name="lsTTL"]/@value
</wa:xpath>
</wa:default>
<wa:title>
@@ -163,7 +173,7 @@
<wa:textbox>
<wa:default>
<wa:xpath>
-
doc("classes/perfsonar/conf/configuration.xml")//ns1:configuration/ns1:service[@name="xmlls"]/ns1:lookupInformation/ns1:option[@name="accessPoint"]/@value
+
doc("classes/perfsonar/conf/configuration.xml")//ns1:configuration/ns1:service[@name="exampleService"]/ns1:lookupInformation/ns1:option[@name="accessPoint"]/@value
</wa:xpath>
</wa:default>
<wa:title>
@@ -189,7 +199,7 @@
<wa:dropdown>
<wa:default>
<wa:xpath>
-
doc("classes/perfsonar/conf/configuration.xml")//ns1:configuration/ns1:service[@name="xmlls"]/ns1:lookupInformation/ns1:option[@name="serviceName"]/@value
+
doc("classes/perfsonar/conf/configuration.xml")//ns1:configuration/ns1:service[@name="exampleService"]/ns1:lookupInformation/ns1:option[@name="serviceName"]/@value
</wa:xpath>
</wa:default>
<wa:title>
@@ -205,7 +215,7 @@
<wa:radio>
<wa:default>
<wa:xpath>
-
doc("classes/perfsonar/conf/configuration.xml")//ns1:configuration/ns1:service[@name="xmlls"]/ns1:messageHandler/ns1:message[@type="EchoRequest"]/ns1:option[@name="authN"]/@value</wa:xpath>
+
doc("classes/perfsonar/conf/configuration.xml")//ns1:configuration/ns1:service[@name="exampleService"]/ns1:messageHandler/ns1:message[@type="EchoRequest"]/ns1:option[@name="authN"]/@value</wa:xpath>
</wa:default>
<wa:title>
<wa:text>Radio Box Item</wa:text>
@@ -232,7 +242,7 @@
<wa:textbox>
<wa:default>
<wa:xpath>
-
doc("classes/perfsonar/conf/configuration.xml")//ns1:configuration/ns1:service[@name="xmlls"]/ns1:lookupInformation/ns1:option[@name="accessPoint"]/@value
+
doc("classes/perfsonar/conf/configuration.xml")//ns1:configuration/ns1:service[@name="exampleService"]/ns1:lookupInformation/ns1:option[@name="accessPoint"]/@value
</wa:xpath>
</wa:default>
<wa:title>
@@ -244,7 +254,7 @@
<wa:textbox>
<wa:default>
<wa:xpath>
-
doc("classes/perfsonar/conf/configuration.xml")//ns1:configuration/ns1:service[@name="xmlls"]/ns1:lookupInformation/ns1:option[@name="serviceName"]/@value
+
doc("classes/perfsonar/conf/configuration.xml")//ns1:configuration/ns1:service[@name="exampleService"]/ns1:lookupInformation/ns1:option[@name="serviceName"]/@value
</wa:xpath>
</wa:default>
<wa:title>
@@ -256,7 +266,7 @@
<wa:textbox>
<wa:default>
<wa:xpath>
-
doc("classes/perfsonar/conf/configuration.xml")//ns1:configuration/ns1:service[@name="xmlls"]/ns1:lookupInformation/ns1:option[@name="serviceType"]/@value
+
doc("classes/perfsonar/conf/configuration.xml")//ns1:configuration/ns1:service[@name="exampleService"]/ns1:lookupInformation/ns1:option[@name="serviceType"]/@value
</wa:xpath>
</wa:default>
<wa:title>
@@ -272,7 +282,7 @@
<wa:textbox>
<wa:default>
<wa:xpath>
-
doc("classes/perfsonar/conf/configuration.xml")//ns1:configuration/ns1:service[@name="xmlls"]/ns1:auxiliaryComponents/ns1:component[@name="scheduling"]/ns1:actions/ns1:action[@name="LSCleanup_1"]/ns1:option[@name="interval"]/@value
+
doc("classes/perfsonar/conf/configuration.xml")//ns1:configuration/ns1:service[@name="exampleService"]/ns1:auxiliaryComponents/ns1:component[@name="scheduling"]/ns1:actions/ns1:action[@name="LSCleanup_1"]/ns1:option[@name="interval"]/@value
</wa:xpath>
</wa:default>
<wa:title>
@@ -285,7 +295,7 @@
<wa:textbox>
<wa:default>
<wa:xpath>
-
doc("classes/perfsonar/conf/configuration.xml")//ns1:configuration/ns1:service[@name="xmlls"]/ns1:auxiliaryComponents/ns1:component[@name="scheduling"]/ns1:actions/ns1:action[@name="LSCleanup_1"]/ns1:option[@name="lsTTL"]/@value
+
doc("classes/perfsonar/conf/configuration.xml")//ns1:configuration/ns1:service[@name="exampleService"]/ns1:auxiliaryComponents/ns1:component[@name="scheduling"]/ns1:actions/ns1:action[@name="LSCleanup_1"]/ns1:option[@name="lsTTL"]/@value
</wa:xpath>
</wa:default>
<wa:title>

Modified:
trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-exampleservice/src/main/webapp/WEB-INF/web.xml
===================================================================
---
trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-exampleservice/src/main/webapp/WEB-INF/web.xml
2012-09-05 10:33:57 UTC (rev 5992)
+++
trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-exampleservice/src/main/webapp/WEB-INF/web.xml
2012-09-05 11:17:18 UTC (rev 5993)
@@ -1,29 +1,59 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app xmlns="http://java.sun.com/xml/ns/j2ee";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd";
+ version="2.5">

-<web-app xmlns="http://java.sun.com/xml/ns/j2ee";
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
- xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd";
- version="2.5">
-
<display-name>perfSONAR Web Admin</display-name>

- <session-config>
- <!-- Default to 5 minute session timeouts -->
- <session-timeout>5</session-timeout>
- </session-config>
+ <!-- Authentication checks are done through a filter -->
+ <filter>
+ <filter-name>authFilter</filter-name>
+
<filter-class>org.perfsonar.webadmin.base2.filters.AuthFilter</filter-class>
+ </filter>
+ <filter-mapping>
+ <filter-name>authFilter</filter-name>
+ <!-- We only protect /config as a basic setting, but you can
add other
+ URL to protect under the same login credentials -->
+ <url-pattern>/config</url-pattern>
+ <url-pattern>/internalLink</url-pattern>
+ </filter-mapping>

- <!-- pS Config Servlet Admin -->
+ <!-- Login Servlet -->
<servlet>
+ <servlet-name>Authentification</servlet-name>
+
<servlet-class>org.perfsonar.webadmin.base2.servlet.LoginServlet</servlet-class>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>Authentification</servlet-name>
+ <url-pattern>/login</url-pattern>
+ <url-pattern>/myplace</url-pattern>
+ </servlet-mapping>
+
+ <!-- Example Servlet with 2 menu links -->
+ <servlet>
+ <servlet-name>ExampleServlet</servlet-name>
+ <servlet-class>
+ org.perfsonar.webadmin.example.servlet.ExampleServlet
+ </servlet-class>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>ExampleServlet</servlet-name>
+ <url-pattern>/internalLink</url-pattern>
+ <url-pattern>/externalLink</url-pattern>
+ </servlet-mapping>
+
+ <!-- pS Config Servlet Admin -->
+ <servlet>
<servlet-name>BasicConfiguration</servlet-name>
<servlet-class>

org.perfsonar.webadmin.base2.servlet.ConfigurationServlet
- </servlet-class>
+ </servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>BasicConfiguration</servlet-name>
<url-pattern>
/config
- </url-pattern>
+ </url-pattern>
</servlet-mapping>

<!-- SelfTest servlet -->
@@ -31,17 +61,18 @@
<servlet-name>SelfTestServlet</servlet-name>
<servlet-class>
org.perfsonar.webadmin.base2.servlet.SelfTestServlet
- </servlet-class>
+ </servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>SelfTestServlet</servlet-name>
<url-pattern>
/selfTest
- </url-pattern>
+ </url-pattern>
</servlet-mapping>

+ <!-- Welcome page -->
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>

-</web-app>
+</web-app>
\ No newline at end of file

Added:
trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-exampleservice/src/main/webapp/views/example.jsp
===================================================================
---
trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-exampleservice/src/main/webapp/views/example.jsp
(rev 0)
+++
trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-exampleservice/src/main/webapp/views/example.jsp
2012-09-05 11:17:18 UTC (rev 5993)
@@ -0,0 +1,13 @@
+<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
+
+<div class="centerWindow">
+
+<p class="heading1">Example Service example servlet page</p>
+
+<div class="succeed">
+ <p>The example service example servlet is working properly. And it has
something to say:</p>
+ <br/>
+ <br/>
+ <h3><%= request.getAttribute("exampleAttribute") %></h3>
+ <br/>
+</div>


Property changes on:
trunk/perfsonar-java-web-admin/perfsonar-java-web-admin-exampleservice/src/main/webapp/views/example.jsp
___________________________________________________________________
Added: svn:mime-type
+ text/plain



  • [pS-dev] [GEANT/SA2/ps-java-services] r5993 - in trunk/perfsonar-java-web-admin: perfsonar-java-web-ad min-component perfsonar-java-web-admin-component/src/main/ java/org/perfsonar/webadmin/base2/config perfsonar-java-we b-admin-component/src/main/java/org/perfsonar/webadmin/bas e2/servlet perfsonar-java-web-admin-component/src/main/jav a/org/perfsonar/webadmin/base2/servlet/util perfsonar-java -web-admin-component/src/main/java/org/perfsonar/webadmin/ base2/test perfsonar-java-web-admin-component/src/main/jav a/org/perfsonar/webadmin/base2/util perfsonar-java-web-adm in-component/src/main/webapp/views perfsonar-java-web-admi n-exampleservice perfsonar-java-web-admin-exampleservice/s rc/main perfsonar-java-web-admin-exampleservice/src/main/j ava perfsonar-java-web-admin-exampleservice/src/main/java/ org perfsonar-java-web-admin-exampleservice/src/main/java/ org/perfsonar perfsonar-java-web-admin-exampleservice/src/ main/java/org/perfsonar/webadmin perfsonar-java-web-admin- exampleservice/src /main/java/org/perfsonar/webadmin/examp le perfsonar-java-web-admin-exampleservice/src/main/java/o rg/perfsonar/webadmin/example/servlet perfsonar-java-web-a dmin-exampleservice/src/main/webapp perfsonar-java-web-adm in-exampleservice/src/main/webapp/WEB-INF perfsonar-java-w eb-admin-exampleservice/src/main/webapp/WEB-INF/classes/pe rfsonar/conf perfsonar-java-web-admin-exampleservice/src/m ain/webapp/views, svn-noreply, 09/05/2012

Archive powered by MHonArc 2.6.16.

Top of Page