axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dee...@apache.org
Subject svn commit: r396601 - in /webservices/axis2/trunk/java/modules/core/src/org/apache/axis2: description/AxisService.java description/AxisService2OM.java transport/http/ListingAgent.java
Date Mon, 24 Apr 2006 16:29:52 GMT
Author: deepal
Date: Mon Apr 24 09:29:48 2006
New Revision: 396601

URL: http://svn.apache.org/viewcvs?rev=396601&view=rev
Log:
-improving ?xsd
when there are multiple schema element they can be view using
  ?xsd=xsd0

Modified:
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService2OM.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/ListingAgent.java

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService.java?rev=396601&r1=396600&r2=396601&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService.java
(original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService.java
Mon Apr 24 09:29:48 2006
@@ -53,7 +53,6 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.io.Writer;
 import java.net.URL;
 import java.util.*;
 
@@ -383,11 +382,8 @@
         }
     }
 
-    public void printSchema(Writer writer) throws AxisFault {
-        for (int i = 0; i < schemaList.size(); i++) {
-            XmlSchema schema = addNameSpaces(i);
-            schema.write(writer);
-        }
+    public XmlSchema getSchema(int index) {
+        return addNameSpaces(index);
     }
 
     private XmlSchema addNameSpaces(int i) {
@@ -690,8 +686,8 @@
 
     public void addSchema(Collection schemas) {
         Iterator iterator = schemas.iterator();
-        while(iterator.hasNext()){
-            XmlSchema schema = (XmlSchema)iterator.next();
+        while (iterator.hasNext()) {
+            XmlSchema schema = (XmlSchema) iterator.next();
             schemaList.add(schema);
             addSchemaNameSpace(schema.getTargetNamespace());
         }

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService2OM.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService2OM.java?rev=396601&r1=396600&r2=396601&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService2OM.java
(original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService2OM.java
Mon Apr 24 09:29:48 2006
@@ -113,6 +113,7 @@
         for (int i = 0; i < schemas.size(); i++) {
             StringWriter writer = new StringWriter();
             XmlSchema schema = (XmlSchema) schemas.get(i);
+            
             schema.write(writer);
             if (!"".equals(writer.toString())) {
                 XMLInputFactory xmlInputFactory = XMLInputFactory.newInstance();

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/ListingAgent.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/ListingAgent.java?rev=396601&r1=396600&r2=396601&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/ListingAgent.java
(original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/ListingAgent.java
Mon Apr 24 09:29:48 2006
@@ -20,95 +20,137 @@
 import org.apache.axis2.Constants;
 import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.description.AxisService;
+import org.apache.ws.commons.schema.XmlSchema;
 
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
+import java.io.InputStream;
 import java.io.OutputStream;
+import java.util.ArrayList;
 import java.util.HashMap;
 
 public class ListingAgent extends AbstractAgent {
 
-  private static final String LIST_MULTIPLE_SERVICE_JSP_NAME = "listServices.jsp";
-  private static final String LIST_SINGLE_SERVICE_JSP_NAME = "listSingleService.jsp";
+    private static final String LIST_MULTIPLE_SERVICE_JSP_NAME = "listServices.jsp";
+    private static final String LIST_SINGLE_SERVICE_JSP_NAME = "listSingleService.jsp";
 
-  public static final String RUNNING_PORT = "RUNNING_PORT";
+    public static final String RUNNING_PORT = "RUNNING_PORT";
 
-  public ListingAgent(ConfigurationContext aConfigContext) {
-    super(aConfigContext);
-  }
-
-  public void handle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse)
-    throws IOException, ServletException {
-     if (httpServletRequest.getParameter("wsdl") != null || httpServletRequest.getParameter("xsd")
!= null) {
-       processListService(httpServletRequest, httpServletResponse);
-     } else {
-        super.handle(httpServletRequest, httpServletResponse);
-     }
-  }
-
-
-  protected void processIndex(HttpServletRequest httpServletRequest, HttpServletResponse
httpServletResponse) throws IOException, ServletException {
-    processListServices(httpServletRequest, httpServletResponse);
-  }
-
-  protected void processListService(HttpServletRequest req, HttpServletResponse res)
-    throws IOException, ServletException {
-
-    String filePart = req.getRequestURL().toString();
-    String serviceName = filePart.substring(filePart.lastIndexOf("/") + 1, filePart.length());
-    HashMap services = configContext.getAxisConfiguration().getServices();
-    String wsdl = req.getParameter("wsdl");
-    String xsd = req.getParameter("xsd");
-    if ((services != null) && !services.isEmpty()) {
-      Object serviceObj = services.get(serviceName);
-      if (serviceObj != null) {
-        if (wsdl != null) {
-          OutputStream out = res.getOutputStream();
-          res.setContentType("text/xml");
-          int ipindex = filePart.indexOf("//");
-          String ip = null;
-          if (ipindex >= 0) {
-            ip = filePart.substring(ipindex + 2, filePart.length());
-            int seperatorIndex = ip.indexOf(":");
-            int slashIndex = ip.indexOf("/");
-            String port = ip.substring(seperatorIndex + 1, slashIndex);
-            System.setProperty(RUNNING_PORT, port);
-            if (seperatorIndex > 0) {
-              ip = ip.substring(0, seperatorIndex);
-            }
-          }
-          ((AxisService) serviceObj).printWSDL(out, ip);
-          out.flush();
-          out.close();
-          return;
-        } else if (xsd != null) {
-          OutputStream out = res.getOutputStream();
-          res.setContentType("text/xml");
-          ((AxisService) serviceObj).printSchema(out);
-          out.flush();
-          out.close();
-          return;
+    public ListingAgent(ConfigurationContext aConfigContext) {
+        super(aConfigContext);
+    }
+
+    public void handle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse)
+            throws IOException, ServletException {
+        if (httpServletRequest.getParameter("wsdl") != null || httpServletRequest.getParameter("xsd")
!= null) {
+            processListService(httpServletRequest, httpServletResponse);
         } else {
-          req.getSession().setAttribute(Constants.SINGLE_SERVICE, serviceObj);
+            super.handle(httpServletRequest, httpServletResponse);
         }
-      } else {
-        req.getSession().setAttribute(Constants.SINGLE_SERVICE, null);
-      }
     }
 
-    renderView(LIST_SINGLE_SERVICE_JSP_NAME, req, res);
-  }
 
-  protected void processListServices(HttpServletRequest req, HttpServletResponse res) throws
IOException, ServletException {
-    HashMap services = configContext.getAxisConfiguration().getServices();
+    protected void processIndex(HttpServletRequest httpServletRequest, HttpServletResponse
httpServletResponse) throws IOException, ServletException {
+        processListServices(httpServletRequest, httpServletResponse);
+    }
+
+    protected void processListService(HttpServletRequest req, HttpServletResponse res)
+            throws IOException, ServletException {
+
+        String filePart = req.getRequestURL().toString();
+        String serviceName = filePart.substring(filePart.lastIndexOf("/") + 1, filePart.length());
+        HashMap services = configContext.getAxisConfiguration().getServices();
+        String wsdl = req.getParameter("wsdl");
+        String xsd = req.getParameter("xsd");
+        if ((services != null) && !services.isEmpty()) {
+            Object serviceObj = services.get(serviceName);
+            if (serviceObj != null) {
+                if (wsdl != null) {
+                    OutputStream out = res.getOutputStream();
+                    res.setContentType("text/xml");
+                    int ipindex = filePart.indexOf("//");
+                    String ip = null;
+                    if (ipindex >= 0) {
+                        ip = filePart.substring(ipindex + 2, filePart.length());
+                        int seperatorIndex = ip.indexOf(":");
+                        int slashIndex = ip.indexOf("/");
+                        String port = ip.substring(seperatorIndex + 1, slashIndex);
+                        System.setProperty(RUNNING_PORT, port);
+                        if (seperatorIndex > 0) {
+                            ip = ip.substring(0, seperatorIndex);
+                        }
+                    }
+                    ((AxisService) serviceObj).printWSDL(out, ip);
+                    out.flush();
+                    out.close();
+                    return;
+                } else if (xsd != null) {
+                    OutputStream out = res.getOutputStream();
+                    res.setContentType("text/xml");
+
+                    AxisService axisService = (AxisService) serviceObj;
+                    ArrayList scheams = axisService.getSchema();
+                    if (!"".equals(xsd)) {
+//                        if (xsd.endsWith(".xsd")) {
+//                            ClassLoader loader = axisService.getClassLoader();
+//                            InputStream in = loader.getResourceAsStream("META-INF/" + xsd);
+//                            if (in != null) {
+//                                byte[] buf = new byte[1024];
+//                                int read;
+//                                while ((read = in.read(buf)) > 0) {
+//                                    out.write(buf, 0, read);
+//                                }
+//                                out.flush();
+//                                out.close();
+//                            }
+//                            return;
+//                        }
+                        xsd = xsd.replaceAll("xsd", "").trim();
+                        try {
+                            int index = Integer.parseInt(xsd);
+                            XmlSchema scheam = axisService.getSchema(index);
+                            if (scheam != null) {
+                                scheam.write(out);
+                                out.flush();
+                                out.close();
+                            }
+                        } catch (Exception e) {
+
+                        }
+                        return;
+                    }
+                    if (scheams.size() > 1) {
+                        res.sendRedirect("");
+                    } else if ("".equals(xsd)) {
+                        XmlSchema scheam = axisService.getSchema(0);
+                        if (scheam != null) {
+                            scheam.write(out);
+                            out.flush();
+                            out.close();
+                        }
+                    }
+                    return;
+                } else {
+                    req.getSession().setAttribute(Constants.SINGLE_SERVICE, serviceObj);
+                }
+            } else {
+                req.getSession().setAttribute(Constants.SINGLE_SERVICE, null);
+            }
+        }
+
+        renderView(LIST_SINGLE_SERVICE_JSP_NAME, req, res);
+    }
+
+    protected void processListServices(HttpServletRequest req, HttpServletResponse res) throws
IOException, ServletException {
+        HashMap services = configContext.getAxisConfiguration().getServices();
 
-    req.getSession().setAttribute(Constants.SERVICE_MAP, services);
-    req.getSession().setAttribute(Constants.ERROR_SERVICE_MAP,
-      configContext.getAxisConfiguration().getFaultyServices());
+        req.getSession().setAttribute(Constants.SERVICE_MAP, services);
+        req.getSession().setAttribute(Constants.ERROR_SERVICE_MAP,
+                configContext.getAxisConfiguration().getFaultyServices());
 
-    renderView(LIST_MULTIPLE_SERVICE_JSP_NAME, req, res);
-  }
+        renderView(LIST_MULTIPLE_SERVICE_JSP_NAME, req, res);
+    }
 
 }



Mime
View raw message