[wsas-java-dev] svn commit r1979 - in trunk/wsas/java/modules: core/src/org/wso2/wsas core/src/org/wso2/wsas/transport core/src/org/wso2/wsas/transport/fileupload core/src/org/wso2/wsas/transport/util servlet-edition/conf standalone-edition/conf

svn at wso2.org svn at wso2.org
Mon Apr 23 22:13:40 PDT 2007


Author: azeez
Date: Mon Apr 23 22:12:45 2007
New Revision: 1979

Added:
   trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/HttpGetRequestProcessor.java
   trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/util/AbstractWsdlProcessor.java
   trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/util/AtomProcessor.java
   trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/util/CertProcessor.java
   trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/util/InfoProcessor.java
   trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/util/PolicyProcessor.java
   trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/util/RequestProcessorUtil.java
      - copied, changed from r1964, trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/util/HttpGetRequestProcessor.java
   trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/util/RssProcessor.java
   trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/util/Wsdl11Processor.java
   trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/util/Wsdl20Processor.java
   trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/util/XsdProcessor.java
Removed:
   trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/util/HttpGetRequestProcessor.java
Modified:
   trunk/wsas/java/modules/core/src/org/wso2/wsas/MainServlet.java
   trunk/wsas/java/modules/core/src/org/wso2/wsas/ServerConstants.java
   trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/WSASServlet.java
   trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/fileupload/FileUploadExecutor.java
   trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/fileupload/FileUploadExecutorManager.java
   trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/util/ServiceHTMLProcessor.java
   trunk/wsas/java/modules/servlet-edition/conf/server.xml
   trunk/wsas/java/modules/standalone-edition/conf/server.xml
Log:
Added HTTP Request Processing functionality for special query parameters



Modified: trunk/wsas/java/modules/core/src/org/wso2/wsas/MainServlet.java
==============================================================================
--- trunk/wsas/java/modules/core/src/org/wso2/wsas/MainServlet.java	(original)
+++ trunk/wsas/java/modules/core/src/org/wso2/wsas/MainServlet.java	Mon Apr 23 22:12:45 2007
@@ -113,8 +113,6 @@
 
             System.setProperty(ServerConstants.AXIS2_HOME, wso2wsasHome);
             System.setProperty(ServerConstants.WSO2WSAS_HOME, wso2wsasHome);
-            ServerConfiguration.configurationXMLLocation =
-                    wso2wsasHome + File.separator + "conf" + File.separator + "server.xml";
             serverConfig = ServerConfiguration.getInstance();
             serverManager = ServerManager.getInstance();
             log.info("Using WSO2 WSAS Home = " + wso2wsasHome);
@@ -131,18 +129,8 @@
                 log.info("WSO2 WSAS startup failed.");
                 return;
             }
-
-            // -------------------------------------------------------------------------------------
-            String serverXML = System.getProperty(ServerConstants.WSO2WSAS_SERVER_XML);
-            if (serverXML == null) {
-                ServerConfiguration.configurationXMLLocation =
-                        wso2wsasHome + File.separator + "conf" + File.separator + "server.xml";
-            } else {
-                ServerConfiguration.configurationXMLLocation = serverXML;
-            }
-            // -------------------------------------------------------------------------------------
-
             is.close();
+            ServerConfiguration.configurationXMLLocation = Utils.getWsasServerXml();
 
             // ServerInfo class
             String serverInfoImplClass = props.getProperty(ServerPropertyKeys.APPSERVER_INFO_IMPL);

Modified: trunk/wsas/java/modules/core/src/org/wso2/wsas/ServerConstants.java
==============================================================================
--- trunk/wsas/java/modules/core/src/org/wso2/wsas/ServerConstants.java	(original)
+++ trunk/wsas/java/modules/core/src/org/wso2/wsas/ServerConstants.java	Mon Apr 23 22:12:45 2007
@@ -26,7 +26,7 @@
     }
 
     public static final String WSO2WSAS_HOME = "wso2wsas.home";
-    public static final String WSO2WSAS_SERVER_XML = "server.xml";
+    public static final String WSO2WSAS_SERVER_XML = "wso2wsas.server.xml";
     public static final String WSO2WSAS_START_TIME = "wso2wsas.start.time";
     public static final String WSO2WSAS_ADMIN_PASSWORD = "wso2wsas.admin.password";
     public static final String AXIS2_HOME = "axis2.home";
@@ -139,7 +139,5 @@
         public static final QName TYPE = new QName(WSO2WSAS_XML_NAMESPACE, "Type");
         public static final QName PASSWORD = new QName(WSO2WSAS_XML_NAMESPACE, "Password");
         public static final QName LOCATION = new QName(WSO2WSAS_XML_NAMESPACE, "Location");
-
-
     }
 }

Added: trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/HttpGetRequestProcessor.java
==============================================================================
--- (empty file)
+++ trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/HttpGetRequestProcessor.java	Mon Apr 23 22:12:45 2007
@@ -0,0 +1,30 @@
+/*                                                                             
+ * Copyright 2004,2005 The Apache Software Foundation.                         
+ *                                                                             
+ * Licensed under the Apache License, Version 2.0 (the "License");             
+ * you may not use this file except in compliance with the License.            
+ * You may obtain a copy of the License at                                     
+ *                                                                             
+ *      http://www.apache.org/licenses/LICENSE-2.0                             
+ *                                                                             
+ * Unless required by applicable law or agreed to in writing, software         
+ * distributed under the License is distributed on an "AS IS" BASIS,           
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.    
+ * See the License for the specific language governing permissions and         
+ * limitations under the License.                                              
+ */
+package org.wso2.wsas.transport;
+
+import org.apache.axis2.context.ConfigurationContext;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * 
+ */
+public interface HttpGetRequestProcessor {
+    void process(HttpServletRequest request,
+                 HttpServletResponse response,
+                 ConfigurationContext configurationContext) throws Exception;
+}

Modified: trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/WSASServlet.java
==============================================================================
--- trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/WSASServlet.java	(original)
+++ trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/WSASServlet.java	Mon Apr 23 22:12:45 2007
@@ -15,24 +15,42 @@
  */
 package org.wso2.wsas.transport;
 
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.xpath.AXIOMXPath;
 import org.apache.axis2.AxisFault;
-import org.apache.axis2.Constants;
 import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.transport.http.AxisServlet;
-import org.wso2.wsas.transport.util.HttpGetRequestProcessor;
+import org.apache.axis2.transport.http.HTTPConstants;
+import org.jaxen.SimpleNamespaceContext;
+import org.jaxen.XPath;
+import org.wso2.utils.ServerConfiguration;
+import org.wso2.wsas.ServerConstants;
+import org.wso2.wsas.transport.util.AtomProcessor;
+import org.wso2.wsas.transport.util.RssProcessor;
 
 import javax.servlet.ServletConfig;
 import javax.servlet.ServletContext;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import javax.xml.namespace.QName;
 import java.io.IOException;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
 /*
  * 
  */
 
 public class WSASServlet extends AxisServlet {
 
+    private Map getRequestProcessors = new LinkedHashMap();
+    private static final QName ITEM_QN = new QName(ServerConstants.WSO2WSAS_XML_NAMESPACE, "Item");
+    private static final QName CLASS_QN = new QName(ServerConstants.WSO2WSAS_XML_NAMESPACE, "Class");
+    private RssProcessor rssProcessor = new RssProcessor();
+    private AtomProcessor atomProcessor = new AtomProcessor();
+
     public void init(ServletConfig config) throws ServletException {
         ServletContext servletContext = config.getServletContext();
         this.configContext =
@@ -40,10 +58,43 @@
         this.axisConfiguration = this.configContext.getAxisConfiguration();
         servletContext.setAttribute(this.getClass().getName(), this);
         this.servletConfig = config;
-
+        populateGetRequestProcessors();
         initParams();
     }
 
+    private void populateGetRequestProcessors() throws ServletException {
+        try {
+            OMElement docEle = ServerConfiguration.getInstance().getDocumentElement();
+            if (docEle != null) {
+                SimpleNamespaceContext nsCtx = new SimpleNamespaceContext();
+                nsCtx.addNamespace("wsas", ServerConstants.WSO2WSAS_XML_NAMESPACE);
+                XPath xp = new AXIOMXPath("//wsas:HttpGetRequestProcessors/wsas:Processor");
+                xp.setNamespaceContext(nsCtx);
+                List nodeList = xp.selectNodes(docEle);
+                for (Iterator iter = nodeList.iterator(); iter.hasNext();) {
+                    OMElement processorEle = (OMElement) iter.next();
+                    OMElement itemEle = processorEle.getFirstChildWithName(ITEM_QN);
+                    if (itemEle == null) {
+                        throw new ServletException("Required element, 'Item' not found!");
+                    }
+                    OMElement classEle = processorEle.getFirstChildWithName(CLASS_QN);
+                    HttpGetRequestProcessor processor;
+                    if (classEle == null) {
+                        throw new ServletException("Required element, 'Class' not found!");
+                    } else {
+                        processor =
+                                (HttpGetRequestProcessor)
+                                        Class.forName(classEle.getText().trim()).newInstance();
+                    }
+                    getRequestProcessors.put(itemEle.getText().trim(),
+                                             processor);
+                }
+            }
+        } catch (Exception e) {
+            throw new ServletException(e);
+        }
+    }
+
     /**
      * WSAS specific GET implementation
      */
@@ -56,60 +107,45 @@
             String requestURI = request.getRequestURI();
             int indexOfServletPath =
                     request.getContextPath().indexOf(configContext.getServiceContextPath());
-            String contextRoot;
-            if (indexOfServletPath == -1) {
-                contextRoot = request.getContextPath();
-            } else {
-                contextRoot = requestURI.substring(0, indexOfServletPath);
-            }
 
             if (requestURI.indexOf("rss") >= 0) {
-                HttpGetRequestProcessor.processRssFeed(response, contextRoot);
+                rssProcessor.process(request, response, configContext);
             }
             if (requestURI.indexOf("atom") >= 0) {
-                HttpGetRequestProcessor.processAtomFeed(response, contextRoot);
+                atomProcessor.process(request, response, configContext);
             }
+
             String queryString = request.getQueryString();
+            boolean isRequestHandled = false;
             if (queryString != null) {
-                if (queryString.toLowerCase().indexOf("info") == 0) {
-                    HttpGetRequestProcessor.processInfo(configContext, requestURI, response);
-                } else if (queryString.toLowerCase().indexOf("xsd") == 0) {
-                    HttpGetRequestProcessor.processXsd(configContext, requestURI,
-                                                       response, request);
-                } else if (queryString.toLowerCase().indexOf("policy") == 0) {
-                    HttpGetRequestProcessor.processPolicy(configContext, requestURI,
-                                                          response, request);
-                } else if (queryString.toLowerCase().indexOf("wsdl2") == 0) {
-                    HttpGetRequestProcessor.printWSDL20(configContext, request, response);
-                } else if (queryString.toLowerCase().indexOf("wsdl") == 0) {
-                    HttpGetRequestProcessor.printWSDL11(configContext, request, response);
-                } else if (queryString.toLowerCase().indexOf("cert") == 0) {
-                    HttpGetRequestProcessor.processCert(configContext, response, request);
-                } else {
-                    handleRestRequest(request, response);
+                for (Iterator iter = getRequestProcessors.keySet().iterator(); iter.hasNext();) {
+                    String item = (String) iter.next();
+                    if (queryString.indexOf(item) == 0) {
+                        ((HttpGetRequestProcessor) getRequestProcessors.get(item)).process(request,
+                                                                                           response,
+                                                                                           configContext);
+                        isRequestHandled = true;
+                        break;
+                    }
                 }
-            } else {
+            }
+            if (!isRequestHandled) {
                 handleRestRequest(request, response);
             }
-        } catch (AxisFault axisFault) {
-            throw AxisFault.makeFault(axisFault);
-        } catch (IOException ioException) {
-            throw AxisFault.makeFault(ioException);
+        } catch (Exception e) {
+            throw AxisFault.makeFault(e);
         }
-
-
     }
 
-    private void handleRestRequest(HttpServletRequest request, HttpServletResponse response) throws
-                                                                                             IOException,
-                                                                                             ServletException {
+    private void handleRestRequest(HttpServletRequest request,
+                                   HttpServletResponse response) throws IOException,
+                                                                        ServletException {
         if (!disableREST) {
-            new ProcessRESTRequest(Constants.Configuration.HTTP_METHOD_GET, request,
-                                               response).processURLRequest();
+            new ProcessRESTRequest(HTTPConstants.HTTP_METHOD_GET,
+                                   request,
+                                   response).processURLRequest();
         } else {
             disableRESTErrorMessage(response);
         }
     }
-
-
 }

Modified: trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/fileupload/FileUploadExecutor.java
==============================================================================
--- trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/fileupload/FileUploadExecutor.java	(original)
+++ trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/fileupload/FileUploadExecutor.java	Mon Apr 23 22:12:45 2007
@@ -26,6 +26,5 @@
 
 public interface FileUploadExecutor {
     public boolean execute(HttpServletRequest request,
-                           HttpServletResponse response)
-            throws ServerException, IOException;
+                           HttpServletResponse response) throws ServerException, IOException;
 }

Modified: trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/fileupload/FileUploadExecutorManager.java
==============================================================================
--- trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/fileupload/FileUploadExecutorManager.java	(original)
+++ trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/fileupload/FileUploadExecutorManager.java	Mon Apr 23 22:12:45 2007
@@ -120,9 +120,8 @@
                     Class clazz = Class.forName(classElement.getText().trim());
                     Constructor constructor =
                             clazz.getConstructor(new Class[]{ConfigurationContext.class});
-                    object =
-                            (FileUploadExecutor) constructor
-                                    .newInstance(new Object[]{configurationContext});
+                    object = (FileUploadExecutor) constructor
+                            .newInstance(new Object[]{configurationContext});
 
                 } catch (Exception e) {
                     log.fatal(e);
@@ -137,11 +136,8 @@
                         log.fatal(msg);
                         throw new ServerException(msg);
                     }
-
-                    executorMap.put(actionElement.getText(), object);
-
+                    executorMap.put(actionElement.getText().trim(), object);
                 }
-
             }
         }
     }

Added: trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/util/AbstractWsdlProcessor.java
==============================================================================
--- (empty file)
+++ trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/util/AbstractWsdlProcessor.java	Mon Apr 23 22:12:45 2007
@@ -0,0 +1,63 @@
+/*                                                                             
+ * Copyright 2004,2005 The Apache Software Foundation.                         
+ *                                                                             
+ * Licensed under the Apache License, Version 2.0 (the "License");             
+ * you may not use this file except in compliance with the License.            
+ * You may obtain a copy of the License at                                     
+ *                                                                             
+ *      http://www.apache.org/licenses/LICENSE-2.0                             
+ *                                                                             
+ * Unless required by applicable law or agreed to in writing, software         
+ * distributed under the License is distributed on an "AS IS" BASIS,           
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.    
+ * See the License for the specific language governing permissions and         
+ * limitations under the License.                                              
+ */
+package org.wso2.wsas.transport.util;
+
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.description.AxisService;
+import org.wso2.wsas.transport.HttpGetRequestProcessor;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * 
+ */
+public abstract class AbstractWsdlProcessor implements HttpGetRequestProcessor {
+
+    protected void printWSDL(ConfigurationContext configurationContext,
+                             HttpServletRequest request,
+                             HttpServletResponse response,
+                             WSDLPrinter wsdlPrinter) throws IOException {
+        String requestURI = request.getRequestURI();
+        String serviceName = requestURI.substring(requestURI.lastIndexOf("/") + 1);
+        AxisService axisService =
+                configurationContext.getAxisConfiguration().getServiceForActivation(serviceName);
+
+        OutputStream outputStream = response.getOutputStream();
+        if (axisService != null) {
+            if (!axisService.isActive()) {
+                response.setContentType("text/html");
+                outputStream.write(("<h4>Service " +
+                                    serviceName +
+                                    " is inactive. Cannot display WSDL document.</h4>").getBytes());
+                outputStream.flush();
+            }
+            response.setContentType("text/xml");
+            wsdlPrinter.printWSDL(axisService);
+        } else {
+            response.setContentType("text/html");
+            outputStream.write(("<h4>Service " + serviceName +
+                                " not found. Cannot display WSDL document.</h4>").getBytes());
+            outputStream.flush();
+        }
+    }
+
+    interface WSDLPrinter {
+        void printWSDL(AxisService axisService) throws IOException;
+    }
+}

Added: trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/util/AtomProcessor.java
==============================================================================
--- (empty file)
+++ trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/util/AtomProcessor.java	Mon Apr 23 22:12:45 2007
@@ -0,0 +1,62 @@
+/*                                                                             
+ * Copyright 2004,2005 The Apache Software Foundation.                         
+ *                                                                             
+ * Licensed under the Apache License, Version 2.0 (the "License");             
+ * you may not use this file except in compliance with the License.            
+ * You may obtain a copy of the License at                                     
+ *                                                                             
+ *      http://www.apache.org/licenses/LICENSE-2.0                             
+ *                                                                             
+ * Unless required by applicable law or agreed to in writing, software         
+ * distributed under the License is distributed on an "AS IS" BASIS,           
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.    
+ * See the License for the specific language governing permissions and         
+ * limitations under the License.                                              
+ */
+package org.wso2.wsas.transport.util;
+
+import org.apache.axiom.om.OMException;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.wsas.feed.FeedConstants;
+import org.wso2.wsas.feed.atom.AtomFeed;
+import org.wso2.wsas.feed.atom.AtomFeedFactory;
+import org.wso2.wsas.transport.HttpGetRequestProcessor;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamWriter;
+
+/**
+ * 
+ */
+
+public class AtomProcessor implements HttpGetRequestProcessor {
+    private static Log log = LogFactory.getLog(AtomProcessor.class);
+
+    public void process(HttpServletRequest request,
+                        HttpServletResponse response,
+                        ConfigurationContext configurationContext) throws Exception {
+        try {
+            response.setContentType("text/xml; charset=utf-8");
+            AtomFeed atomFeed = AtomFeedFactory.getAtomFeed(FeedConstants.WSO2WSAS_ATOM_FEED);
+            if (atomFeed != null) {
+                XMLStreamWriter writer =
+                        XMLOutputFactory.newInstance().
+                                createXMLStreamWriter(response.getOutputStream());
+                writer.writeProcessingInstruction("xml-stylesheet",
+                                                  "  type=\"text/xsl\" href=\"" +
+                                                  configurationContext.getContextRoot() +
+                                                  "/styles/atom.xsl\"");
+                atomFeed.getFeedElement().serialize(writer);
+                writer.flush();
+            }
+        } catch (OMException e) {
+            log.debug(e);
+        } catch (Exception e) {
+            log.error(e);
+        }
+    }
+}
\ No newline at end of file

Added: trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/util/CertProcessor.java
==============================================================================
--- (empty file)
+++ trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/util/CertProcessor.java	Mon Apr 23 22:12:45 2007
@@ -0,0 +1,83 @@
+/*                                                                             
+ * Copyright 2004,2005 The Apache Software Foundation.                         
+ *                                                                             
+ * Licensed under the Apache License, Version 2.0 (the "License");             
+ * you may not use this file except in compliance with the License.            
+ * You may obtain a copy of the License at                                     
+ *                                                                             
+ *      http://www.apache.org/licenses/LICENSE-2.0                             
+ *                                                                             
+ * Unless required by applicable law or agreed to in writing, software         
+ * distributed under the License is distributed on an "AS IS" BASIS,           
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.    
+ * See the License for the specific language governing permissions and         
+ * limitations under the License.                                              
+ */
+package org.wso2.wsas.transport.util;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.description.AxisService;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.wsas.persistence.PersistenceManager;
+import org.wso2.wsas.persistence.dataobject.KeyStoreDO;
+import org.wso2.wsas.persistence.dataobject.ServiceDO;
+import org.wso2.wsas.transport.HttpGetRequestProcessor;
+import org.wso2.wsas.util.KeyStoreUtil;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.OutputStream;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateEncodingException;
+
+/**
+ * 
+ */
+public class CertProcessor implements HttpGetRequestProcessor {
+    private static Log log = LogFactory.getLog(CertProcessor.class);
+    private static PersistenceManager pm = new PersistenceManager();
+
+    public void process(HttpServletRequest request,
+                        HttpServletResponse response,
+                        ConfigurationContext configurationContext) throws Exception {
+        String requestURI = request.getRequestURI();
+        String serviceName = requestURI.substring(requestURI.lastIndexOf("/") + 1);
+
+        AxisService axisService =
+                configurationContext.getAxisConfiguration().getServiceForActivation(serviceName);
+        OutputStream outputStream = response.getOutputStream();
+        if (!axisService.isActive()) {
+            response.setContentType("text/html");
+            outputStream.write(("<h4>Service " + serviceName +
+                                " is inactive. Cannot retrieve certificate.</h4>").getBytes());
+            outputStream.flush();
+        } else {
+            ServiceDO serviceDO = pm.getService(serviceName, null);
+            KeyStoreDO privateKeyStore;
+            if ((privateKeyStore = serviceDO.getPrivateKeyStore()) == null) {
+                response.setContentType("text/html");
+                outputStream.write(("<h4>Service " + serviceName +
+                                    " does not have a private key.</h4>").getBytes());
+                outputStream.flush();
+            } else {
+
+                // pump out the certificate
+                Certificate certificate =
+                        KeyStoreUtil.getCertificate(privateKeyStore.getKeyStoreName(),
+                                                    privateKeyStore.getPrivateKeyAlias());
+                try {
+                    response.setContentType("application/octet-stream");
+                    response.setHeader("Content-Disposition", "filename=" + serviceName + ".cert");
+                    outputStream.write(certificate.getEncoded());
+                } catch (CertificateEncodingException e) {
+                    String msg = "Could not get encoded format of certificate";
+                    log.error(msg, e);
+                    throw new AxisFault(msg, e);
+                }
+                outputStream.flush();
+            }
+        }
+    }
+}

Added: trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/util/InfoProcessor.java
==============================================================================
--- (empty file)
+++ trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/util/InfoProcessor.java	Mon Apr 23 22:12:45 2007
@@ -0,0 +1,40 @@
+/*                                                                             
+ * Copyright 2004,2005 The Apache Software Foundation.                         
+ *                                                                             
+ * Licensed under the Apache License, Version 2.0 (the "License");             
+ * you may not use this file except in compliance with the License.            
+ * You may obtain a copy of the License at                                     
+ *                                                                             
+ *      http://www.apache.org/licenses/LICENSE-2.0                             
+ *                                                                             
+ * Unless required by applicable law or agreed to in writing, software         
+ * distributed under the License is distributed on an "AS IS" BASIS,           
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.    
+ * See the License for the specific language governing permissions and         
+ * limitations under the License.                                              
+ */
+package org.wso2.wsas.transport.util;
+
+import org.apache.axis2.context.ConfigurationContext;
+import org.wso2.wsas.transport.HttpGetRequestProcessor;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * 
+ */
+public class InfoProcessor implements HttpGetRequestProcessor {
+
+    public void process(HttpServletRequest request,
+                        HttpServletResponse response,
+                        ConfigurationContext configurationContext) throws Exception {
+        String requestURI = request.getRequestURI();
+        String serviceName = requestURI.substring(requestURI.lastIndexOf("/") + 1);
+        response.setStatus(200);
+        response.setContentType("text/html");
+        response.getOutputStream().
+                print(ServiceHTMLProcessor.printServiceHTML(serviceName, configurationContext));
+
+    }
+}

Added: trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/util/PolicyProcessor.java
==============================================================================
--- (empty file)
+++ trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/util/PolicyProcessor.java	Mon Apr 23 22:12:45 2007
@@ -0,0 +1,176 @@
+/*                                                                             
+ * Copyright 2004,2005 The Apache Software Foundation.                         
+ *                                                                             
+ * Licensed under the Apache License, Version 2.0 (the "License");             
+ * you may not use this file except in compliance with the License.            
+ * You may obtain a copy of the License at                                     
+ *                                                                             
+ *      http://www.apache.org/licenses/LICENSE-2.0                             
+ *                                                                             
+ * Unless required by applicable law or agreed to in writing, software         
+ * distributed under the License is distributed on an "AS IS" BASIS,           
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.    
+ * See the License for the specific language governing permissions and         
+ * limitations under the License.                                              
+ */
+package org.wso2.wsas.transport.util;
+
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.PolicyInclude;
+import org.apache.axis2.util.ExternalPolicySerializer;
+import org.apache.neethi.Policy;
+import org.apache.neethi.PolicyReference;
+import org.apache.neethi.PolicyRegistry;
+import org.wso2.utils.NetworkUtils;
+import org.wso2.utils.ServerConfiguration;
+import org.wso2.wsas.ServerManager;
+import org.wso2.wsas.transport.HttpGetRequestProcessor;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.OutputStream;
+import java.util.ArrayList;
+
+/**
+ * 
+ */
+public class PolicyProcessor implements HttpGetRequestProcessor {
+
+    public void process(HttpServletRequest request,
+                        HttpServletResponse response,
+                        ConfigurationContext configCtx) throws Exception {
+        String requestURI = request.getRequestURI();
+        String serviceName = requestURI.substring(requestURI.lastIndexOf("/") + 1);
+        AxisService axisService =
+                configCtx.getAxisConfiguration().getServiceForActivation(serviceName);
+        OutputStream outputStream = response.getOutputStream();
+
+        if (axisService != null) {
+            if (!axisService.isActive()) {
+                response.setContentType("text/html");
+                outputStream.write(("<h4>Service " +
+                                    serviceName +
+                                    " is inactive. Cannot display policies.</h4>").getBytes());
+                outputStream.flush();
+            }
+            PolicyInclude policyInclude = axisService.getPolicyInclude();
+            if (policyInclude == null) {
+                response.setContentType("text/html");
+                outputStream.write("<h4>Policy element is not found!</h4>".getBytes());
+                outputStream.flush();
+                return;
+
+            }
+            ArrayList policyElements = policyInclude.getPolicyElements();
+
+            if (policyElements == null) {
+                response.setContentType("text/html");
+                outputStream.write("<h4>Policy elements not found!</h4>".getBytes());
+                outputStream.flush();
+                return;
+            }
+
+            PolicyRegistry reg = policyInclude.getPolicyRegistry();
+
+            ExternalPolicySerializer serializer = new ExternalPolicySerializer();
+            if (configCtx.getAxisConfiguration()
+                    .getLocalPolicyAssertions() != null) {
+                serializer.setAssertionsToFilter(
+                        configCtx.getAxisConfiguration().getLocalPolicyAssertions());
+            }
+
+
+            if (policyElements.size() == 1) {
+                response.setContentType("text/xml");
+                if (policyElements.get(0) instanceof Policy) {
+                    Policy policy = (Policy) policyElements.get(0);
+                    serializer.serialize(policy, outputStream);
+                } else if (policyElements.get(0) instanceof PolicyReference) {
+                    String key = ((PolicyReference) policyElements.get(0)).getURI();
+                    if (key.startsWith("#")) {
+                        key = key.substring(key.indexOf("#") + 1);
+                    }
+
+                    Policy p = reg.lookup(key);
+                    if (p == null) {
+                        response.setContentType("text/html");
+                        outputStream.write("<h4>Policy element not found!</h4>".getBytes());
+                    } else {
+                        serializer.serialize(p, outputStream);
+                    }
+                }
+            } else {
+                // for many policies
+                String idParam = request.getParameter("id");
+                if (idParam != null) {
+                    Object policyObject = policyElements.get(Integer.parseInt(idParam));
+                    if (policyObject != null) {
+                        response.setContentType("text/xml");
+                        if (policyObject instanceof Policy) {
+                            Policy policy = (Policy) policyObject;
+                            serializer.serialize(policy, outputStream);
+                        } else if (policyObject instanceof PolicyReference) {
+                            String key = ((PolicyReference) policyObject).getURI();
+                            if (key.startsWith("#")) {
+                                key = key.substring(key.indexOf("#") + 1);
+                            }
+                            Policy p = reg.lookup(key);
+                            if (p == null) {
+                                response.setContentType("text/html");
+                                outputStream
+                                        .write("<h4>Policy element not found!</h4>".getBytes());
+                            } else {
+                                serializer.serialize(p, outputStream);
+                            }
+                        }
+                    } else {
+                        response.setContentType("text/html");
+                        outputStream.write("<h4>Policy not found!</h4>".getBytes());
+                    }
+                } else {
+                    if (policyElements.size() == 0) {
+                        response.setContentType("text/html");
+                        outputStream.write("<h4>Policy not found!</h4>".getBytes());
+                    } else {
+                        String ipAddress = "http://" + NetworkUtils.getLocalHostname() + ":" +
+                                           ServerManager.httpPort;
+                        ServerConfiguration serverCofig = ServerConfiguration.getInstance();
+                        outputStream.write(("<html><head>" +
+                                            "<title>WSO2 Web Services Application Server v" +
+                                            serverCofig.getFirstProperty("Version") +
+                                            " Management Console - " +
+                                            axisService.getName() +
+                                            " Service Policies</title>" +
+                                            "</head>" +
+                                            "<body>" +
+                                            "<b>Policies for " +
+                                            axisService.getName() +
+                                            " service</b><br/><br/>").getBytes());
+                        if (policyElements.size() != 0) {
+                            String serviceContextPath = RequestProcessorUtil.getServiceContextPath(configCtx);
+                            for (int i = 0; i < policyElements.size(); i++) {
+                                String st = "<a href=\"" + ipAddress +
+                                            serviceContextPath + "/" +
+                                            axisService.getName() + "?policy&id=" + i +
+                                            "\">Policy " + i +
+                                            "</a><br/>";
+                                outputStream.write(st.getBytes());
+                            }
+                        } else {
+                            outputStream.write("<h4>No policies found</h4>".getBytes());
+                        }
+                        outputStream.write("</body></html>".getBytes());
+                    }
+
+                }
+            }
+        } else { // Service is null
+            response.setContentType("text/html");
+            outputStream.write(("<h4>Service " + serviceName +
+                                " not found. Cannot display policies.</h4>").getBytes());
+            outputStream.flush();
+        }
+        outputStream.flush();
+    }
+}

Copied: trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/util/RequestProcessorUtil.java (from r1964, trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/util/HttpGetRequestProcessor.java)
==============================================================================
--- trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/util/HttpGetRequestProcessor.java	(original)
+++ trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/util/RequestProcessorUtil.java	Mon Apr 23 22:12:45 2007
@@ -16,390 +16,26 @@
 package org.wso2.wsas.transport.util;
 
 import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.OMException;
 import org.apache.axiom.om.impl.builder.StAXOMBuilder;
-import org.apache.axis2.AxisFault;
 import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.description.PolicyInclude;
-import org.apache.axis2.util.ExternalPolicySerializer;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.neethi.Policy;
-import org.apache.neethi.PolicyReference;
-import org.apache.neethi.PolicyRegistry;
-import org.apache.ws.commons.schema.XmlSchema;
-import org.wso2.utils.NetworkUtils;
-import org.wso2.utils.ServerConfiguration;
-import org.wso2.wsas.ServerManager;
-import org.wso2.wsas.feed.FeedConstants;
-import org.wso2.wsas.feed.atom.AtomFeed;
-import org.wso2.wsas.feed.atom.AtomFeedFactory;
-import org.wso2.wsas.feed.rss.RSSFeed;
-import org.wso2.wsas.feed.rss.RSSFeedFactory;
-import org.wso2.wsas.persistence.PersistenceManager;
-import org.wso2.wsas.persistence.dataobject.KeyStoreDO;
-import org.wso2.wsas.persistence.dataobject.ServiceDO;
-import org.wso2.wsas.util.KeyStoreUtil;
 
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
 import javax.xml.stream.*;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
-import java.io.IOException;
 import java.io.OutputStream;
-import java.security.cert.Certificate;
-import java.security.cert.CertificateEncodingException;
-import java.util.ArrayList;
 
 /**
  *
  */
-public class HttpGetRequestProcessor {
-    private static Log log = LogFactory.getLog(HttpGetRequestProcessor.class);
-    private static PersistenceManager pm = new PersistenceManager();
+public class RequestProcessorUtil {
+    private static Log log = LogFactory.getLog(RequestProcessorUtil.class);
 
-    public static void processCert(ConfigurationContext configurationContext,
-                                   HttpServletResponse response,
-                                   HttpServletRequest request) throws IOException {
-
-        String requestURI = request.getRequestURI();
-        String serviceName = requestURI.substring(requestURI.lastIndexOf("/") + 1);
-
-        AxisService axisService =
-                configurationContext.getAxisConfiguration().getServiceForActivation(serviceName);
-        OutputStream outputStream = response.getOutputStream();
-        if (!axisService.isActive()) {
-            response.setContentType("text/html");
-            outputStream.write(("<h4>Service " + serviceName +
-                                " is inactive. Cannot retrieve certificate.</h4>").getBytes());
-            outputStream.flush();
-        } else {
-            ServiceDO serviceDO = pm.getService(serviceName, null);
-            KeyStoreDO privateKeyStore;
-            if ((privateKeyStore = serviceDO.getPrivateKeyStore()) == null) {
-                response.setContentType("text/html");
-                outputStream.write(("<h4>Service " + serviceName +
-                                    " does not have a private key.</h4>").getBytes());
-                outputStream.flush();
-            } else {
-
-                // pump out the certificate
-                Certificate certificate =
-                        KeyStoreUtil.getCertificate(privateKeyStore.getKeyStoreName(),
-                                                    privateKeyStore.getPrivateKeyAlias());
-                try {
-                    response.setContentType("application/octet-stream");
-                    response.setHeader("Content-Disposition", "filename=" + serviceName + ".cert");
-                    outputStream.write(certificate.getEncoded());
-                } catch (CertificateEncodingException e) {
-                    String msg = "Could not get encoded format of certificate";
-                    log.error(msg, e);
-                    throw new AxisFault(msg, e);
-                }
-                outputStream.flush();
-            }
-        }
-
-    }
-
-    public static void printWSDL11(final ConfigurationContext configurationContext,
-                                   final HttpServletRequest request,
-                                   final HttpServletResponse response) throws IOException {
-        WSDLPrinter wsdlPrinter = new WSDLPrinter() {
-            public void printWSDL(AxisService axisService) throws IOException {
-                ByteArrayOutputStream baos = new ByteArrayOutputStream();
-                axisService.printWSDL(baos,
-                                      NetworkUtils.getLocalHostname(),
-                                      getServiceContextPath(configurationContext));
-                writeDocument(baos,
-                              response.getOutputStream(),
-                              "annotated-wsdl.xsl",
-                              configurationContext.getContextRoot());
-            }
-        };
-        printWSDL(configurationContext, request, response, wsdlPrinter);
-    }
-
-    public static void printWSDL20(final ConfigurationContext configurationContext,
-                                   final HttpServletRequest request,
-                                   final HttpServletResponse response) throws IOException {
-        WSDLPrinter wsdlPrinter = new WSDLPrinter() {
-            public void printWSDL(AxisService axisService) throws IOException {
-                ByteArrayOutputStream baos = new ByteArrayOutputStream();
-                axisService.printWSDL2(baos,
-                                       NetworkUtils.getLocalHostname(),
-                                       getServiceContextPath(configurationContext));
-                writeDocument(baos,
-                              response.getOutputStream(),
-                              "annotated-wsdl2.xsl",
-                              configurationContext.getContextRoot());
-            }
-        };
-        printWSDL(configurationContext, request, response, wsdlPrinter);
-    }
-
-    /**
-     * @param request
-     * @param response
-     * @param wsdlPrinter
-     */
-    private static void printWSDL(ConfigurationContext configurationContext,
-                                  HttpServletRequest request,
-                                  HttpServletResponse response,
-                                  WSDLPrinter wsdlPrinter) throws IOException {
-        String requestURI = request.getRequestURI();
-        String serviceName = requestURI.substring(requestURI.lastIndexOf("/") + 1);
-        AxisService axisService =
-                configurationContext.getAxisConfiguration().getServiceForActivation(serviceName);
-
-        OutputStream outputStream = response.getOutputStream();
-        if (axisService != null) {
-            if (!axisService.isActive()) {
-                response.setContentType("text/html");
-                outputStream.write(("<h4>Service " +
-                                    serviceName +
-                                    " is inactive. Cannot display WSDL document.</h4>").getBytes());
-                outputStream.flush();
-            }
-            response.setContentType("text/xml");
-            wsdlPrinter.printWSDL(axisService);
-        } else {
-            response.setContentType("text/html");
-            outputStream.write(("<h4>Service " + serviceName +
-                                " not found. Cannot display WSDL document.</h4>").getBytes());
-            outputStream.flush();
-        }
-    }
-
-    public static void processPolicy(ConfigurationContext configCtx,
-                                     String requestURI,
-                                     HttpServletResponse response,
-                                     HttpServletRequest request) throws IOException {
-
-        String serviceName = requestURI.substring(requestURI.lastIndexOf("/") + 1);
-        AxisService axisService =
-                configCtx.getAxisConfiguration().getServiceForActivation(serviceName);
-        OutputStream outputStream = response.getOutputStream();
-
-        if (axisService != null) {
-            if (!axisService.isActive()) {
-                response.setContentType("text/html");
-                outputStream.write(("<h4>Service " +
-                                    serviceName +
-                                    " is inactive. Cannot display policies.</h4>").getBytes());
-                outputStream.flush();
-            }
-            PolicyInclude policyInclude = axisService.getPolicyInclude();
-            if (policyInclude == null) {
-                response.setContentType("text/html");
-                outputStream.write("<h4>Policy element is not found!</h4>".getBytes());
-                outputStream.flush();
-                return;
-
-            }
-            ArrayList policyElements = policyInclude.getPolicyElements();
-
-            if (policyElements == null) {
-                response.setContentType("text/html");
-                outputStream.write("<h4>Policy elements not found!</h4>".getBytes());
-                outputStream.flush();
-                return;
-            }
-
-            PolicyRegistry reg = policyInclude.getPolicyRegistry();
-
-            ExternalPolicySerializer serializer = new ExternalPolicySerializer();
-            if (configCtx.getAxisConfiguration()
-                    .getLocalPolicyAssertions() != null) {
-                serializer.setAssertionsToFilter(
-                        configCtx.getAxisConfiguration().getLocalPolicyAssertions());
-            }
-
-
-            if (policyElements.size() == 1) {
-                response.setContentType("text/xml");
-                if (policyElements.get(0) instanceof Policy) {
-                    Policy policy = (Policy) policyElements.get(0);
-                    serializer.serialize(policy, outputStream);
-                } else if (policyElements.get(0) instanceof PolicyReference) {
-                    String key = ((PolicyReference) policyElements.get(0)).getURI();
-                    if (key.startsWith("#")) {
-                        key = key.substring(key.indexOf("#") + 1);
-                    }
-
-                    Policy p = reg.lookup(key);
-                    if (p == null) {
-                        response.setContentType("text/html");
-                        outputStream.write("<h4>Policy element not found!</h4>".getBytes());
-                    } else {
-                        serializer.serialize(p, outputStream);
-                    }
-                }
-            } else {
-                // for many policies
-                String idParam = request.getParameter("id");
-                if (idParam != null) {
-                    Object policyObject = policyElements.get(Integer.parseInt(idParam));
-                    if (policyObject != null) {
-                        response.setContentType("text/xml");
-                        if (policyObject instanceof Policy) {
-                            Policy policy = (Policy) policyObject;
-                            serializer.serialize(policy, outputStream);
-                        } else if (policyObject instanceof PolicyReference) {
-                            String key = ((PolicyReference) policyObject).getURI();
-                            if (key.startsWith("#")) {
-                                key = key.substring(key.indexOf("#") + 1);
-                            }
-                            Policy p = reg.lookup(key);
-                            if (p == null) {
-                                response.setContentType("text/html");
-                                outputStream
-                                        .write("<h4>Policy element not found!</h4>".getBytes());
-                            } else {
-                                serializer.serialize(p, outputStream);
-                            }
-                        }
-                    } else {
-                        response.setContentType("text/html");
-                        outputStream.write("<h4>Policy not found!</h4>".getBytes());
-                    }
-                } else {
-                    if (policyElements.size() == 0) {
-                        response.setContentType("text/html");
-                        outputStream.write("<h4>Policy not found!</h4>".getBytes());
-                    } else {
-                        String ipAddress = "http://" + NetworkUtils.getLocalHostname() + ":" +
-                                           ServerManager.httpPort;
-                        ServerConfiguration serverCofig = ServerConfiguration.getInstance();
-                        outputStream.write(("<html><head>" +
-                                            "<title>WSO2 Web Services Application Server v" +
-                                            serverCofig.getFirstProperty("Version") +
-                                            " Management Console - " +
-                                            axisService.getName() +
-                                            " Service Policies</title>" +
-                                            "</head>" +
-                                            "<body>" +
-                                            "<b>Policies for " +
-                                            axisService.getName() +
-                                            " service</b><br/><br/>").getBytes());
-                        if (policyElements.size() != 0) {
-                            String serviceContextPath = getServiceContextPath(configCtx);
-                            for (int i = 0; i < policyElements.size(); i++) {
-                                String st = "<a href=\"" + ipAddress +
-                                            serviceContextPath + "/" +
-                                            axisService.getName() + "?policy&id=" + i +
-                                            "\">Policy " + i +
-                                            "</a><br/>";
-                                outputStream.write(st.getBytes());
-                            }
-                        } else {
-                            outputStream.write("<h4>No policies found</h4>".getBytes());
-                        }
-                        outputStream.write("</body></html>".getBytes());
-                    }
-
-                }
-            }
-        } else { // Service is null
-            response.setContentType("text/html");
-            outputStream.write(("<h4>Service " + serviceName +
-                                " not found. Cannot display policies.</h4>").getBytes());
-            outputStream.flush();
-        }
-        outputStream.flush();
-    }
-
-    public static void processXsd(ConfigurationContext configCtx,
-                                  String requestURI,
-                                  HttpServletResponse response,
-                                  HttpServletRequest request) throws IOException {
-        String serviceName = requestURI.substring(requestURI.lastIndexOf("/") + 1);
-        AxisService axisService =
-                configCtx.getAxisConfiguration().getServiceForActivation(serviceName);
-        OutputStream outputStream = response.getOutputStream();
-        String contextRoot = request.getContextPath();
-        if (axisService != null) {
-            if (!axisService.isActive()) {
-                response.setContentType("text/html");
-                outputStream.write(("<h4>Service " +
-                                    serviceName +
-                                    " is inactive. Cannot display Schema.</h4>").getBytes());
-                outputStream.flush();
-            }
-
-            ArrayList schemas = axisService.getSchema();
-            if (schemas.size() == 1) {
-
-                response.setContentType("text/xml");
-
-                // Write to the output stream
-                processSchema((XmlSchema) schemas.get(0), outputStream, contextRoot);
-
-            } else {
-                String idParam = request.getParameter("id");
-                if (idParam != null) {
-                    XmlSchema schema = axisService.getSchema(Integer.parseInt(idParam));
-                    if (schema != null) {
-                        response.setContentType("text/xml");
-                        processSchema(schema, outputStream, contextRoot);
-                    } else {
-                        response.setContentType("text/html");
-                        outputStream.write("<h4>Schema not found!</h4>".getBytes());
-                    }
-                } else {
-                    String ipAddress = "http://" + NetworkUtils.getLocalHostname() + ":" +
-                                       ServerManager.httpPort;
-                    String version =
-                            ServerConfiguration.getInstance().getFirstProperty("Version");
-                    outputStream.write(("<html><head>" +
-                                        "<title>WSO2 Web Services Application Server v" +
-                                        version +
-                                        "Management Console" +
-                                        " - " +
-                                        axisService.getName() +
-                                        " Service Schema</title>" +
-                                        "</head>" +
-                                        "<body>" +
-                                        "<b>Schemas for " +
-                                        axisService.getName() +
-                                        " service</b><br/><br/>").getBytes());
-                    if (schemas.size() != 0) {
-                        for (int i = 0; i < schemas.size(); i++) {
-                            String st = "<a href=\"" + ipAddress +
-                                        getServiceContextPath(configCtx) + "/" +
-                                        axisService.getName() + "?xsd&id=" + i + "\">Schema " + i +
-                                        "</a><br/>";
-                            outputStream.write(st.getBytes());
-                        }
-                    } else {
-                        outputStream.write("<p>No schemas found</p>".getBytes());
-                    }
-                    outputStream.write("</body></html>".getBytes());
-                }
-            }
-        } else {  // service is null
-            response.setContentType("text/html");
-            outputStream.write(("<h4>Service " +
-                                serviceName +
-                                " is not found. Cannot display Schema.</h4>").getBytes());
-            outputStream.flush();
-        }
-    }
-
-
-    private static void processSchema(XmlSchema schema, OutputStream outputStream,
-                                      String contextRoot) {
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        schema.write(baos);
-        writeDocument(baos, outputStream, "annotated-xsd.xsl", contextRoot);
-    }
-
-    private static void writeDocument(ByteArrayOutputStream byteArrayOutStream,
-                                      OutputStream out,
-                                      String annotatedXsl,
-                                      String contextRoot) {
+    static void writeDocument(ByteArrayOutputStream byteArrayOutStream,
+                              OutputStream out,
+                              String annotatedXsl,
+                              String contextRoot) {
         XMLStreamWriter writer;
         try {
             ByteArrayInputStream bais =
@@ -423,62 +59,7 @@
         }
     }
 
-    public static void processInfo(ConfigurationContext configurationContext, String requestURI,
-                                   HttpServletResponse response) throws IOException {
-        String serviceName = requestURI
-                .substring(requestURI.lastIndexOf("/") + 1);
-        response.setStatus(200);
-        response.setContentType("text/html");
-
-        response.getOutputStream().
-                print(ServiceHTMLProcessor.printServiceHTML(serviceName, configurationContext));
-    }
-
-    public static void processAtomFeed(HttpServletResponse response, String contextRoot) {
-        try {
-            response.setContentType("text/xml; charset=utf-8");
-            AtomFeed atomFeed = AtomFeedFactory.getAtomFeed(FeedConstants.WSO2WSAS_ATOM_FEED);
-            if (atomFeed != null) {
-                XMLStreamWriter writer =
-                        XMLOutputFactory.newInstance().
-                                createXMLStreamWriter(response.getOutputStream());
-                writer.writeProcessingInstruction("xml-stylesheet",
-                                                  "  type=\"text/xsl\" href=\"" +
-                                                  contextRoot +
-                                                  "/styles/atom.xsl\"");
-                atomFeed.getFeedElement().serialize(writer);
-                writer.flush();
-            }
-        } catch (OMException e) {
-            log.debug(e);
-        } catch (Exception e) {
-            log.error(e);
-        }
-    }
-
-    public static void processRssFeed(HttpServletResponse response, String contextRoot) {
-        try {
-            response.setContentType("text/xml; charset=utf-8");
-            RSSFeed rssFeed = RSSFeedFactory.getRSSFeed(FeedConstants.WSO2WSAS_RSS_FEED);
-            if (rssFeed != null) {
-                XMLStreamWriter writer =
-                        XMLOutputFactory.newInstance()
-                                .createXMLStreamWriter(response.getOutputStream());
-                writer.writeProcessingInstruction("xml-stylesheet",
-                                                  "  type=\"text/xsl\" href=\"" +
-                                                  contextRoot +
-                                                  "/styles/rss.xsl\"");
-                rssFeed.getFeedElement().serialize(writer);
-                writer.flush();
-            }
-        } catch (OMException e) {
-            log.debug(e);
-        } catch (Exception e) {
-            log.error(e);
-        }
-    }
-
-    private static String getServiceContextPath(ConfigurationContext configCtx) {
+    static String getServiceContextPath(ConfigurationContext configCtx) {
         String serviceContextPath = configCtx.getServiceContextPath();
         if (!configCtx.getContextRoot().equals("/")
             && !serviceContextPath.startsWith("/")) {
@@ -486,8 +67,4 @@
         }
         return serviceContextPath;
     }
-
-    private interface WSDLPrinter {
-        void printWSDL(AxisService axisService) throws IOException;
-    }
 }

Added: trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/util/RssProcessor.java
==============================================================================
--- (empty file)
+++ trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/util/RssProcessor.java	Mon Apr 23 22:12:45 2007
@@ -0,0 +1,60 @@
+/*                                                                             
+ * Copyright 2004,2005 The Apache Software Foundation.                         
+ *                                                                             
+ * Licensed under the Apache License, Version 2.0 (the "License");             
+ * you may not use this file except in compliance with the License.            
+ * You may obtain a copy of the License at                                     
+ *                                                                             
+ *      http://www.apache.org/licenses/LICENSE-2.0                             
+ *                                                                             
+ * Unless required by applicable law or agreed to in writing, software         
+ * distributed under the License is distributed on an "AS IS" BASIS,           
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.    
+ * See the License for the specific language governing permissions and         
+ * limitations under the License.                                              
+ */
+package org.wso2.wsas.transport.util;
+
+import org.apache.axiom.om.OMException;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.wsas.feed.FeedConstants;
+import org.wso2.wsas.feed.rss.RSSFeed;
+import org.wso2.wsas.feed.rss.RSSFeedFactory;
+import org.wso2.wsas.transport.HttpGetRequestProcessor;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamWriter;
+
+/**
+ * 
+ */
+public class RssProcessor implements HttpGetRequestProcessor {
+    private static Log log = LogFactory.getLog(RequestProcessorUtil.class);
+
+    public void process(HttpServletRequest request, HttpServletResponse response,
+                        ConfigurationContext configurationContext) throws Exception {
+        try {
+            response.setContentType("text/xml; charset=utf-8");
+            RSSFeed rssFeed = RSSFeedFactory.getRSSFeed(FeedConstants.WSO2WSAS_RSS_FEED);
+            if (rssFeed != null) {
+                XMLStreamWriter writer =
+                        XMLOutputFactory.newInstance()
+                                .createXMLStreamWriter(response.getOutputStream());
+                writer.writeProcessingInstruction("xml-stylesheet",
+                                                  "  type=\"text/xsl\" href=\"" +
+                                                  configurationContext.getContextRoot() +
+                                                  "/styles/rss.xsl\"");
+                rssFeed.getFeedElement().serialize(writer);
+                writer.flush();
+            }
+        } catch (OMException e) {
+            log.debug(e);
+        } catch (Exception e) {
+            log.error(e);
+        }
+    }
+}

Modified: trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/util/ServiceHTMLProcessor.java
==============================================================================
--- trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/util/ServiceHTMLProcessor.java	(original)
+++ trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/util/ServiceHTMLProcessor.java	Mon Apr 23 22:12:45 2007
@@ -16,20 +16,20 @@
 */
 package org.wso2.wsas.transport.util;
 
-import org.wso2.wsas.ServerConstants;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.description.AxisOperation;
 import org.apache.axis2.description.AxisService;
 import org.apache.axis2.description.AxisServiceGroup;
 import org.apache.axis2.engine.AxisConfiguration;
+import org.wso2.wsas.ServerConstants;
 
 import java.util.Enumeration;
 import java.util.Hashtable;
 import java.util.Iterator;
 
 public class ServiceHTMLProcessor {
-    
+
     /**
      * Returns the HTML text for the list of services deployed.
      * This can be delegated to another Class as well

Added: trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/util/Wsdl11Processor.java
==============================================================================
--- (empty file)
+++ trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/util/Wsdl11Processor.java	Mon Apr 23 22:12:45 2007
@@ -0,0 +1,49 @@
+/*                                                                             
+ * Copyright 2004,2005 The Apache Software Foundation.                         
+ *                                                                             
+ * Licensed under the Apache License, Version 2.0 (the "License");             
+ * you may not use this file except in compliance with the License.            
+ * You may obtain a copy of the License at                                     
+ *                                                                             
+ *      http://www.apache.org/licenses/LICENSE-2.0                             
+ *                                                                             
+ * Unless required by applicable law or agreed to in writing, software         
+ * distributed under the License is distributed on an "AS IS" BASIS,           
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.    
+ * See the License for the specific language governing permissions and         
+ * limitations under the License.                                              
+ */
+package org.wso2.wsas.transport.util;
+
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.description.AxisService;
+import org.wso2.utils.NetworkUtils;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+
+/**
+ * 
+ */
+public class Wsdl11Processor extends AbstractWsdlProcessor {
+
+    public void process(final HttpServletRequest request,
+                        final HttpServletResponse response,
+                        final ConfigurationContext configurationContext) throws Exception {
+        WSDLPrinter wsdlPrinter = new WSDLPrinter() {
+            public void printWSDL(AxisService axisService) throws IOException {
+                ByteArrayOutputStream baos = new ByteArrayOutputStream();
+                axisService.printWSDL(baos,
+                                      NetworkUtils.getLocalHostname(),
+                                      RequestProcessorUtil.getServiceContextPath(configurationContext));
+                RequestProcessorUtil.writeDocument(baos,
+                                                   response.getOutputStream(),
+                                                   "annotated-wsdl.xsl",
+                                                   configurationContext.getContextRoot());
+            }
+        };
+        printWSDL(configurationContext, request, response, wsdlPrinter);
+    }
+}

Added: trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/util/Wsdl20Processor.java
==============================================================================
--- (empty file)
+++ trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/util/Wsdl20Processor.java	Mon Apr 23 22:12:45 2007
@@ -0,0 +1,50 @@
+/*                                                                             
+ * Copyright 2004,2005 The Apache Software Foundation.                         
+ *                                                                             
+ * Licensed under the Apache License, Version 2.0 (the "License");             
+ * you may not use this file except in compliance with the License.            
+ * You may obtain a copy of the License at                                     
+ *                                                                             
+ *      http://www.apache.org/licenses/LICENSE-2.0                             
+ *                                                                             
+ * Unless required by applicable law or agreed to in writing, software         
+ * distributed under the License is distributed on an "AS IS" BASIS,           
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.    
+ * See the License for the specific language governing permissions and         
+ * limitations under the License.                                              
+ */
+package org.wso2.wsas.transport.util;
+
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.description.AxisService;
+import org.wso2.utils.NetworkUtils;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+
+/**
+ * 
+ */
+
+public class Wsdl20Processor extends AbstractWsdlProcessor {
+
+    public void process(final HttpServletRequest request,
+                        final HttpServletResponse response,
+                        final ConfigurationContext configurationContext) throws Exception {
+        WSDLPrinter wsdlPrinter = new WSDLPrinter() {
+            public void printWSDL(AxisService axisService) throws IOException {
+                ByteArrayOutputStream baos = new ByteArrayOutputStream();
+                axisService.printWSDL2(baos,
+                                       NetworkUtils.getLocalHostname(),
+                                       RequestProcessorUtil.getServiceContextPath(configurationContext));
+                RequestProcessorUtil.writeDocument(baos,
+                                                   response.getOutputStream(),
+                                                   "annotated-wsdl2.xsl",
+                                                   configurationContext.getContextRoot());
+            }
+        };
+        printWSDL(configurationContext, request, response, wsdlPrinter);
+    }
+}

Added: trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/util/XsdProcessor.java
==============================================================================
--- (empty file)
+++ trunk/wsas/java/modules/core/src/org/wso2/wsas/transport/util/XsdProcessor.java	Mon Apr 23 22:12:45 2007
@@ -0,0 +1,120 @@
+/*                                                                             
+ * Copyright 2004,2005 The Apache Software Foundation.                         
+ *                                                                             
+ * Licensed under the Apache License, Version 2.0 (the "License");             
+ * you may not use this file except in compliance with the License.            
+ * You may obtain a copy of the License at                                     
+ *                                                                             
+ *      http://www.apache.org/licenses/LICENSE-2.0                             
+ *                                                                             
+ * Unless required by applicable law or agreed to in writing, software         
+ * distributed under the License is distributed on an "AS IS" BASIS,           
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.    
+ * See the License for the specific language governing permissions and         
+ * limitations under the License.                                              
+ */
+package org.wso2.wsas.transport.util;
+
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.description.AxisService;
+import org.apache.ws.commons.schema.XmlSchema;
+import org.wso2.utils.NetworkUtils;
+import org.wso2.utils.ServerConfiguration;
+import org.wso2.wsas.ServerManager;
+import org.wso2.wsas.transport.HttpGetRequestProcessor;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.ByteArrayOutputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+
+/**
+ * 
+ */
+public class XsdProcessor implements HttpGetRequestProcessor {
+
+    public void process(HttpServletRequest request,
+                        HttpServletResponse response,
+                        ConfigurationContext configCtx) throws Exception {
+        String requestURI = request.getRequestURI();
+        String serviceName = requestURI.substring(requestURI.lastIndexOf("/") + 1);
+        AxisService axisService =
+                configCtx.getAxisConfiguration().getServiceForActivation(serviceName);
+        OutputStream outputStream = response.getOutputStream();
+        String contextRoot = request.getContextPath();
+        if (axisService != null) {
+            if (!axisService.isActive()) {
+                response.setContentType("text/html");
+                outputStream.write(("<h4>Service " +
+                                    serviceName +
+                                    " is inactive. Cannot display Schema.</h4>").getBytes());
+                outputStream.flush();
+            }
+
+            ArrayList schemas = axisService.getSchema();
+            if (schemas.size() == 1) {
+
+                response.setContentType("text/xml");
+
+                // Write to the output stream
+                processSchema((XmlSchema) schemas.get(0), outputStream, contextRoot);
+
+            } else {
+                String idParam = request.getParameter("id");
+                if (idParam != null) {
+                    XmlSchema schema = axisService.getSchema(Integer.parseInt(idParam));
+                    if (schema != null) {
+                        response.setContentType("text/xml");
+                        processSchema(schema, outputStream, contextRoot);
+                    } else {
+                        response.setContentType("text/html");
+                        outputStream.write("<h4>Schema not found!</h4>".getBytes());
+                    }
+                } else {
+                    String ipAddress = "http://" + NetworkUtils.getLocalHostname() + ":" +
+                                       ServerManager.httpPort;
+                    String version =
+                            ServerConfiguration.getInstance().getFirstProperty("Version");
+                    outputStream.write(("<html><head>" +
+                                        "<title>WSO2 Web Services Application Server v" +
+                                        version +
+                                        "Management Console" +
+                                        " - " +
+                                        axisService.getName() +
+                                        " Service Schema</title>" +
+                                        "</head>" +
+                                        "<body>" +
+                                        "<b>Schemas for " +
+                                        axisService.getName() +
+                                        " service</b><br/><br/>").getBytes());
+                    if (schemas.size() != 0) {
+                        for (int i = 0; i < schemas.size(); i++) {
+                            String st = "<a href=\"" + ipAddress +
+                                        RequestProcessorUtil.getServiceContextPath(configCtx) + "/" +
+                                        axisService.getName() + "?xsd&id=" + i + "\">Schema " + i +
+                                        "</a><br/>";
+                            outputStream.write(st.getBytes());
+                        }
+                    } else {
+                        outputStream.write("<p>No schemas found</p>".getBytes());
+                    }
+                    outputStream.write("</body></html>".getBytes());
+                }
+            }
+        } else {  // service is null
+            response.setContentType("text/html");
+            outputStream.write(("<h4>Service " +
+                                serviceName +
+                                " is not found. Cannot display Schema.</h4>").getBytes());
+            outputStream.flush();
+        }
+    }
+
+    private void processSchema(XmlSchema schema, OutputStream outputStream,
+                               String contextRoot) {
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        schema.write(baos);
+        RequestProcessorUtil.writeDocument(baos, outputStream, "annotated-xsd.xsl", contextRoot);
+    }
+}

Modified: trunk/wsas/java/modules/servlet-edition/conf/server.xml
==============================================================================
--- trunk/wsas/java/modules/servlet-edition/conf/server.xml	(original)
+++ trunk/wsas/java/modules/servlet-edition/conf/server.xml	Mon Apr 23 22:12:45 2007
@@ -232,4 +232,43 @@
             <Class>org.wso2.wsas.transport.fileupload.SpringFileUploadExecutor</Class>
         </Mapping>
     </FileUploadConfig>
+
+    <!--
+       Processors which process special HTTP GET requests such as ?wsdl, ?policy etc.
+
+       In order to plug in a processor to handle a special request, simply add an entry to this
+       section.
+
+       The value of the Item element is the first parameter in the query string(e.g. ?wsdl)
+       which needs special processing
+
+       The value of the Class element is a class which implements
+       org.wso2.wsas.transport.HttpGetRequestProcessor
+    -->
+    <HttpGetRequestProcessors>
+        <Processor>
+            <Item>info</Item>
+            <Class>org.wso2.wsas.transport.util.InfoProcessor</Class>
+        </Processor>
+        <Processor>
+            <Item>wsdl</Item>
+            <Class>org.wso2.wsas.transport.util.Wsdl11Processor</Class>
+        </Processor>
+        <Processor>
+            <Item>wsdl2</Item>
+            <Class>org.wso2.wsas.transport.util.Wsdl20Processor</Class>
+        </Processor>
+        <Processor>
+            <Item>xsd</Item>
+            <Class>org.wso2.wsas.transport.util.XsdProcessor</Class>
+        </Processor>
+        <Processor>
+            <Item>policy</Item>
+            <Class>org.wso2.wsas.transport.util.PolicyProcessor</Class>
+        </Processor>
+        <Processor>
+            <Item>cert</Item>
+            <Class>org.wso2.wsas.transport.util.CertProcessor</Class>
+        </Processor>
+    </HttpGetRequestProcessors>
 </Server>

Modified: trunk/wsas/java/modules/standalone-edition/conf/server.xml
==============================================================================
--- trunk/wsas/java/modules/standalone-edition/conf/server.xml	(original)
+++ trunk/wsas/java/modules/standalone-edition/conf/server.xml	Mon Apr 23 22:12:45 2007
@@ -212,4 +212,43 @@
             <Class>org.wso2.wsas.transport.fileupload.SpringFileUploadExecutor</Class>
         </Mapping>
     </FileUploadConfig>
+
+    <!--
+       Processors which process special HTTP GET requests such as ?wsdl, ?policy etc.
+
+       In order to plug in a processor to handle a special request, simply add an entry to this
+       section.
+
+       The value of the Item element is the first parameter in the query string(e.g. ?wsdl)
+       which needs special processing
+       
+       The value of the Class element is a class which implements
+       org.wso2.wsas.transport.HttpGetRequestProcessor
+    -->
+    <HttpGetRequestProcessors>
+        <Processor>
+            <Item>info</Item>
+            <Class>org.wso2.wsas.transport.util.InfoProcessor</Class>
+        </Processor>
+        <Processor>
+            <Item>wsdl</Item>
+            <Class>org.wso2.wsas.transport.util.Wsdl11Processor</Class>
+        </Processor>
+        <Processor>
+            <Item>wsdl2</Item>
+            <Class>org.wso2.wsas.transport.util.Wsdl20Processor</Class>
+        </Processor>
+        <Processor>
+            <Item>xsd</Item>
+            <Class>org.wso2.wsas.transport.util.XsdProcessor</Class>
+        </Processor>
+        <Processor>
+            <Item>policy</Item>
+            <Class>org.wso2.wsas.transport.util.PolicyProcessor</Class>
+        </Processor>
+        <Processor>
+            <Item>cert</Item>
+            <Class>org.wso2.wsas.transport.util.CertProcessor</Class>
+        </Processor>
+    </HttpGetRequestProcessors>
 </Server>




More information about the Wsas-java-dev mailing list