perfsonar-dev - perfsonar: r5442 - in branches/new-structure-with-base2/ps-mdm-web-admin: ant src/main/java/org/perfsonar/webadmin/base2/servlet src/main/java/org/perfsonar/webadmin/base2/servlet/util src/main/java/org/perfsonar/webadmin/base2/test tomcat tomcat/views
Subject: perfsonar development work
List archive
perfsonar: r5442 - in branches/new-structure-with-base2/ps-mdm-web-admin: ant src/main/java/org/perfsonar/webadmin/base2/servlet src/main/java/org/perfsonar/webadmin/base2/servlet/util src/main/java/org/perfsonar/webadmin/base2/test tomcat tomcat/views
Chronological Thread
- From:
- To:
- Subject: perfsonar: r5442 - in branches/new-structure-with-base2/ps-mdm-web-admin: ant src/main/java/org/perfsonar/webadmin/base2/servlet src/main/java/org/perfsonar/webadmin/base2/servlet/util src/main/java/org/perfsonar/webadmin/base2/test tomcat tomcat/views
- Date: Wed, 30 Dec 2009 07:48:28 -0500
Author: trzaszcz
Date: 2009-12-30 07:48:28 -0500 (Wed, 30 Dec 2009)
New Revision: 5442
Added:
branches/new-structure-with-base2/ps-mdm-web-admin/src/main/java/org/perfsonar/webadmin/base2/test/SOAPClientException.java
Modified:
branches/new-structure-with-base2/ps-mdm-web-admin/ant/build.xml
branches/new-structure-with-base2/ps-mdm-web-admin/src/main/java/org/perfsonar/webadmin/base2/servlet/SelfTestServlet.java
branches/new-structure-with-base2/ps-mdm-web-admin/src/main/java/org/perfsonar/webadmin/base2/servlet/util/ConfigurationServletHelper.java
branches/new-structure-with-base2/ps-mdm-web-admin/src/main/java/org/perfsonar/webadmin/base2/test/SOAPClient.java
branches/new-structure-with-base2/ps-mdm-web-admin/tomcat/index.jsp
branches/new-structure-with-base2/ps-mdm-web-admin/tomcat/views/sideBar.jsp
Log:
selfTest implementation
Modified: branches/new-structure-with-base2/ps-mdm-web-admin/ant/build.xml
===================================================================
--- branches/new-structure-with-base2/ps-mdm-web-admin/ant/build.xml
2009-12-30 11:06:43 UTC (rev 5441)
+++ branches/new-structure-with-base2/ps-mdm-web-admin/ant/build.xml
2009-12-30 12:48:28 UTC (rev 5442)
@@ -229,6 +229,9 @@
<exclude name="xalan" />
<exclude name="xmldb" />
</fileset>
+ <fileset dir="${basedir}/lib/repository">
+ <include
name="**/*.jar" />
+ </fileset>
</copy>
<war basedir="${basedir}/tomcat"
destfile="${build}/${warfilename}.war" webxml="${temp.dir.web-inf}/web.xml"
excludes="${lib}/servlet/*">
Modified:
branches/new-structure-with-base2/ps-mdm-web-admin/src/main/java/org/perfsonar/webadmin/base2/servlet/SelfTestServlet.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-web-admin/src/main/java/org/perfsonar/webadmin/base2/servlet/SelfTestServlet.java
2009-12-30 11:06:43 UTC (rev 5441)
+++
branches/new-structure-with-base2/ps-mdm-web-admin/src/main/java/org/perfsonar/webadmin/base2/servlet/SelfTestServlet.java
2009-12-30 12:48:28 UTC (rev 5442)
@@ -1,5 +1,8 @@
package org.perfsonar.webadmin.base2.servlet;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
import java.io.IOException;
import javax.servlet.ServletException;
@@ -7,17 +10,66 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.perfsonar.webadmin.base2.config.ObjectMap;
+import org.perfsonar.webadmin.base2.servlet.util.ConfigurationServletHelper;
+import org.perfsonar.webadmin.base2.test.SOAPClient;
+import org.perfsonar.webadmin.base2.test.SOAPClientException;
+
@SuppressWarnings("serial")
-public class SelfTestServlet extends HttpServlet{
-
-
-
+public class SelfTestServlet extends HttpServlet {
+
+ private final String SELF_TEST_FILE = "/soapMessages/selfTest.xml";
+
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
+ String path = getServletContext().getRealPath("/");
+ String basePath = path + "/WEB-INF";
+ ObjectMap objectMap = new ObjectMap(basePath,
+ ConfigurationServletHelper.WA_CONFIG_PATH,
+ ConfigurationServletHelper.WA_FILE_NAME);
+ String accessPoint = objectMap.getWA().getServiceInformation()
+ .getAccessPoint();
- resp.getWriter().append("DONE");
+ System.out.println("A:C - "+accessPoint);
+
+ SOAPClient soapClient = new SOAPClient(accessPoint);
+ String messageContent = getFileContent(path + SELF_TEST_FILE);
+
+ if (messageContent == null) {
+ getServletContext().setAttribute("errorMessage",
"Message is null");
+ }else{
+ String result;
+ try {
+ result =
soapClient.sendMessage(messageContent);
+ if (result != null) {
+
+ } else {
+
+ }
+ } catch (SOAPClientException e) {
+
getServletContext().setAttribute("errorMessage", e.getMessage());
+ }
+ }
+ getServletConfig().getServletContext().getRequestDispatcher(
+ "/index.jsp?page=selfTest&ok").forward(req,
resp);
}
-
-
+
+ private String getFileContent(String url) {
+
+ byte[] buffer = new byte[(int) new File(url).length()];
+ FileInputStream f;
+ try {
+ f = new FileInputStream(url);
+ f.read(buffer);
+ return new String(buffer);
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ return null;
+ }
+
}
Modified:
branches/new-structure-with-base2/ps-mdm-web-admin/src/main/java/org/perfsonar/webadmin/base2/servlet/util/ConfigurationServletHelper.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-web-admin/src/main/java/org/perfsonar/webadmin/base2/servlet/util/ConfigurationServletHelper.java
2009-12-30 11:06:43 UTC (rev 5441)
+++
branches/new-structure-with-base2/ps-mdm-web-admin/src/main/java/org/perfsonar/webadmin/base2/servlet/util/ConfigurationServletHelper.java
2009-12-30 12:48:28 UTC (rev 5442)
@@ -24,12 +24,12 @@
/**
* localization of the WA configuration file
*/
- static final String WA_CONFIG_PATH = "classes/perfsonar/conf";
+ public static final String WA_CONFIG_PATH = "classes/perfsonar/conf";
/**
* file name of the wa.xml file
*/
- static final String WA_FILE_NAME = "wa.xml";
+ public static final String WA_FILE_NAME = "wa.xml";
private HttpServletRequest request;
private HttpServletResponse response;
Modified:
branches/new-structure-with-base2/ps-mdm-web-admin/src/main/java/org/perfsonar/webadmin/base2/test/SOAPClient.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-web-admin/src/main/java/org/perfsonar/webadmin/base2/test/SOAPClient.java
2009-12-30 11:06:43 UTC (rev 5441)
+++
branches/new-structure-with-base2/ps-mdm-web-admin/src/main/java/org/perfsonar/webadmin/base2/test/SOAPClient.java
2009-12-30 12:48:28 UTC (rev 5442)
@@ -16,7 +16,7 @@
* Simple SOAP client
*
* @author Slawomir Trzaszczka
- *
+ *
*/
public class SOAPClient {
@@ -30,38 +30,44 @@
*
* sends request to webService and returns content of the response
*
- * @param content - content of the message (soap message)
+ * @param content
+ * - content of the message (soap message)
* @return
* @throws UnsupportedEncodingException
*/
- public String sendMessage(String content)
- throws UnsupportedEncodingException {
+ public String sendMessage(String content) throws SOAPClientException {
HttpClient httpclient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
-
+
// define required HTTP headers
httpPost.setHeader("Content-type", "text/xml;
charset=UTF-8;");
httpPost.setHeader("SOAPAction", "");
- StringEntity entity = new StringEntity(content);
+ StringEntity entity;
+ try {
+ entity = new StringEntity(content);
+ httpPost.setEntity(entity);
- httpPost.setEntity(entity);
+ ResponseHandler<String> responseHandler = new
BasicResponseHandler();
- ResponseHandler<String> responseHandler = new
BasicResponseHandler();
-
- try {
- return httpclient.execute(httpPost, responseHandler);
- } catch (ClientProtocolException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }finally{
- if(httpclient!=null){
- httpclient.getConnectionManager().shutdown();
+ try {
+ return httpclient.execute(httpPost,
responseHandler);
+ } catch (ClientProtocolException e) {
+ e.printStackTrace();
+ throw new SOAPClientException(e.getMessage());
+ } catch (IOException e) {
+ e.printStackTrace();
+ throw new SOAPClientException(e.getMessage());
+ } finally {
+ if (httpclient != null) {
+
httpclient.getConnectionManager().shutdown();
+ }
}
+ } catch (UnsupportedEncodingException e1) {
+ e1.printStackTrace();
+ throw new SOAPClientException(e1.getMessage());
}
- return null;
}
}
Added:
branches/new-structure-with-base2/ps-mdm-web-admin/src/main/java/org/perfsonar/webadmin/base2/test/SOAPClientException.java
Modified: branches/new-structure-with-base2/ps-mdm-web-admin/tomcat/index.jsp
===================================================================
--- branches/new-structure-with-base2/ps-mdm-web-admin/tomcat/index.jsp
2009-12-30 11:06:43 UTC (rev 5441)
+++ branches/new-structure-with-base2/ps-mdm-web-admin/tomcat/index.jsp
2009-12-30 12:48:28 UTC (rev 5442)
@@ -50,9 +50,12 @@
<%
}else if(pageParam != null &&
pageParam.equals("form")){
out.println(request.getAttribute("form"));
- %>
-
- <%
+ }else if(pageParam != null &&
pageParam.equals("selfTest")){
+ if(request.getParameter("ok")!=null){
+ out.println("OK");
+ }else{
+
out.println(application.getAttribute("errorMessage"));
+ }
}else{
%>
<%@include
file="views/welcome.jsp" %>
Modified:
branches/new-structure-with-base2/ps-mdm-web-admin/tomcat/views/sideBar.jsp
===================================================================
---
branches/new-structure-with-base2/ps-mdm-web-admin/tomcat/views/sideBar.jsp
2009-12-30 11:06:43 UTC (rev 5441)
+++
branches/new-structure-with-base2/ps-mdm-web-admin/tomcat/views/sideBar.jsp
2009-12-30 12:48:28 UTC (rev 5442)
@@ -19,6 +19,9 @@
out.println(basicLink);
}
%>
+ <span class="navtex">
+ <a href="selfTest">Test</a>
+ </span>
</td>
</tr>
<%
- perfsonar: r5442 - in branches/new-structure-with-base2/ps-mdm-web-admin: ant src/main/java/org/perfsonar/webadmin/base2/servlet src/main/java/org/perfsonar/webadmin/base2/servlet/util src/main/java/org/perfsonar/webadmin/base2/test tomcat tomcat/views, svnlog, 12/30/2009
Archive powered by MHonArc 2.6.16.