axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dee...@apache.org
Subject svn commit: r439266 - in /webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2: deployment/repository/util/ deployment/resolver/ deployment/util/ description/
Date Fri, 01 Sep 2006 10:44:12 GMT
Author: deepal
Date: Fri Sep  1 03:44:11 2006
New Revision: 439266

URL: http://svn.apache.org/viewvc?rev=439266&view=rev
Log:
fixing AXIS2-1087

Modified:
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/repository/util/ArchiveReader.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/resolver/AARBasedWSDLLocator.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/resolver/AARFileBasedURIResolver.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/repository/util/ArchiveReader.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/repository/util/ArchiveReader.java?rev=439266&r1=439265&r2=439266&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/repository/util/ArchiveReader.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/repository/util/ArchiveReader.java
Fri Sep  1 03:44:11 2006
@@ -21,21 +21,10 @@
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.impl.builder.StAXOMBuilder;
 import org.apache.axis2.AxisFault;
-import org.apache.axis2.deployment.DeploymentConstants;
-import org.apache.axis2.deployment.DeploymentErrorMsgs;
-import org.apache.axis2.deployment.DeploymentException;
-import org.apache.axis2.deployment.DescriptionBuilder;
-import org.apache.axis2.deployment.ModuleBuilder;
-import org.apache.axis2.deployment.ServiceBuilder;
-import org.apache.axis2.deployment.ServiceGroupBuilder;
+import org.apache.axis2.deployment.*;
 import org.apache.axis2.deployment.resolver.AARBasedWSDLLocator;
 import org.apache.axis2.deployment.resolver.AARFileBasedURIResolver;
-import org.apache.axis2.description.AxisModule;
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.description.AxisServiceGroup;
-import org.apache.axis2.description.WSDL11ToAxisServiceBuilder;
-import org.apache.axis2.description.WSDL20ToAxisServiceBuilder;
-import org.apache.axis2.description.WSDLToAxisServiceBuilder;
+import org.apache.axis2.description.*;
 import org.apache.axis2.engine.AxisConfiguration;
 import org.apache.axis2.i18n.Messages;
 import org.apache.axis2.namespace.Constants;
@@ -45,13 +34,7 @@
 
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamException;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
+import java.io.*;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.zip.ZipEntry;
@@ -290,6 +273,11 @@
                             && entryName.endsWith(SUFFIX_WSDL)) {
                         out = new ByteArrayOutputStream();
 
+                        if (entryName.indexOf("/") != entryName.lastIndexOf("/")) {
+                            //only care abt the toplevel wsdl
+                            continue;
+                        }
+
                         while ((read = zin.read(buf)) > 0) {
                             out.write(buf, 0, read);
                         }
@@ -313,7 +301,6 @@
                             } else {
                                 new DeploymentException(Messages.getMessage("invalidWSDLFound"));
                             }
-
                             AxisService service = processWSDLFile(wsdlToAxisServiceBuilder,
serviceFile, true, new ByteArrayInputStream(out.toByteArray()));
                             servicesMap.put(service.getName(), service);
                         }

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/resolver/AARBasedWSDLLocator.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/resolver/AARBasedWSDLLocator.java?rev=439266&r1=439265&r2=439266&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/resolver/AARBasedWSDLLocator.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/resolver/AARBasedWSDLLocator.java
Fri Sep  1 03:44:11 2006
@@ -1,6 +1,7 @@
 package org.apache.axis2.deployment.resolver;
 
 import org.apache.axis2.deployment.DeploymentConstants;
+import org.apache.axis2.deployment.util.Utils;
 import org.apache.ws.commons.schema.resolver.DefaultURIResolver;
 import org.xml.sax.InputSource;
 
@@ -36,6 +37,7 @@
 
     private File aarFile;
     private InputStream baseInputStream;
+    private String lastImportLocation = "";
 
     public AARBasedWSDLLocator(File zipFile, InputStream baseInputStream) {
         this.baseInputStream = baseInputStream;
@@ -51,6 +53,14 @@
      * @param importLocation
      */
     public InputSource getImportInputSource(String parentLocation, String importLocation)
{
+        //setting current import location.
+        if (importLocation != null && importLocation.length() > 0) {
+            int speindex = importLocation.lastIndexOf("/");
+            if (speindex > 0) {
+                lastImportLocation = importLocation.substring(0, speindex);
+            }
+
+        }
         if (isAbsolute(importLocation)) {
             return super.resolveEntity(
                     null, importLocation, parentLocation);
@@ -65,10 +75,13 @@
                 int read;
                 ByteArrayOutputStream out;
                 String searchingStr;
+                if (parentLocation != null && parentLocation.length() > 0) {
+                    importLocation = Utils.getPath(parentLocation, importLocation);
+                }
                 while ((entry = zin.getNextEntry()) != null) {
                     String entryName = entry.getName().toLowerCase();
                     searchingStr = (DeploymentConstants.META_INF + "/" + importLocation).toLowerCase();
-                    if (entryName.equals(searchingStr)) {
+                    if (entryName.equalsIgnoreCase(searchingStr)) {
                         out = new ByteArrayOutputStream();
                         while ((read = zin.read(buf)) > 0) {
                             out.write(buf, 0, read);
@@ -107,6 +120,8 @@
      */
     public String getLatestImportURI() {
         //we don't care about this either
-        return "";
+        return lastImportLocation;
     }
+
+
 }

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/resolver/AARFileBasedURIResolver.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/resolver/AARFileBasedURIResolver.java?rev=439266&r1=439265&r2=439266&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/resolver/AARFileBasedURIResolver.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/resolver/AARFileBasedURIResolver.java
Fri Sep  1 03:44:11 2006
@@ -1,16 +1,13 @@
 package org.apache.axis2.deployment.resolver;
 
-import org.apache.ws.commons.schema.resolver.DefaultURIResolver;
 import org.apache.axis2.deployment.DeploymentConstants;
+import org.apache.axis2.deployment.util.Utils;
+import org.apache.ws.commons.schema.resolver.DefaultURIResolver;
 import org.xml.sax.InputSource;
 
-import java.util.zip.ZipInputStream;
+import java.io.*;
 import java.util.zip.ZipEntry;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.ByteArrayOutputStream;
-import java.io.ByteArrayInputStream;
-import java.io.File;
+import java.util.zip.ZipInputStream;
 /*
  * Copyright 2004,2005 The Apache Software Foundation.
  *
@@ -30,7 +27,7 @@
 /**
  * A custom URI resolver that can
  */
-public class AARFileBasedURIResolver extends DefaultURIResolver{
+public class AARFileBasedURIResolver extends DefaultURIResolver {
 
     private String aarFileName;
     private File aarFile;
@@ -42,7 +39,7 @@
     public AARFileBasedURIResolver(File aarFile) {
         this.aarFile = aarFile;
     }
-    
+
     public AARFileBasedURIResolver() {
     }
 
@@ -53,26 +50,27 @@
     public void setAarFileName(File aarFile) {
         this.aarFile = aarFile;
     }
+
     public InputSource resolveEntity(
             String targetNamespace,
             String schemaLocation,
             String baseUri) {
         //no issue with
-        if (isAbsolute(schemaLocation)){
+        if (isAbsolute(schemaLocation)) {
             return super.resolveEntity(
-                    targetNamespace,schemaLocation,baseUri);
-        }else{
+                    targetNamespace, schemaLocation, baseUri);
+        } else {
             //validate
-            if (schemaLocation.startsWith("..")){
+            if ((baseUri == null || "".equals(baseUri)) && schemaLocation.startsWith(".."))
{
                 throw new RuntimeException(
-                        "Unsupported schema location "+ schemaLocation);
+                        "Unsupported schema location " + schemaLocation);
             }
 
             ZipInputStream zin = null;
             try {
-                if (aarFile!=null){
+                if (aarFile != null) {
                     zin = new ZipInputStream(new FileInputStream(aarFile));
-                } else{
+                } else {
                     zin = new ZipInputStream(new FileInputStream(aarFileName));
                 }
 
@@ -81,10 +79,13 @@
                 int read;
                 ByteArrayOutputStream out;
                 String searchingStr;
+                if (baseUri != null && baseUri.length() > 0) {
+                    schemaLocation = Utils.getPath(baseUri, schemaLocation);
+                }
                 while ((entry = zin.getNextEntry()) != null) {
                     String entryName = entry.getName().toLowerCase();
                     searchingStr = (DeploymentConstants.META_INF + "/" + schemaLocation).toLowerCase();
-                    if (entryName.equals(searchingStr)) {
+                    if (entryName.equalsIgnoreCase(searchingStr)) {
                         out = new ByteArrayOutputStream();
                         while ((read = zin.read(buf)) > 0) {
                             out.write(buf, 0, read);
@@ -95,12 +96,11 @@
                 }
 
 
-
             } catch (IOException e) {
                 throw new RuntimeException(e);
-            } finally{
+            } finally {
                 try {
-                    if (zin!=null) zin.close();
+                    if (zin != null) zin.close();
                 } catch (IOException e) {
                     //log this error
                 }

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java?rev=439266&r1=439265&r2=439266&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java
Fri Sep  1 03:44:11 2006
@@ -6,8 +6,8 @@
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.Constants;
 import org.apache.axis2.deployment.DeploymentConstants;
-import org.apache.axis2.deployment.DeploymentException;
 import org.apache.axis2.deployment.DeploymentEngine;
+import org.apache.axis2.deployment.DeploymentException;
 import org.apache.axis2.deployment.ServiceBuilder;
 import org.apache.axis2.deployment.repository.util.ArchiveFileData;
 import org.apache.axis2.deployment.repository.util.ArchiveReader;
@@ -95,7 +95,7 @@
             ArrayList array = new ArrayList();
             String urlString = url.toString();
             InputStream in = url.openStream();
-            ZipInputStream zin ;
+            ZipInputStream zin;
             if (antiJARLocking) {
                 File inputFile = createTempFile(urlString.substring(urlString.length() -
4), in);
                 in.close();
@@ -409,6 +409,7 @@
      * @param config        : AxisConfiguration : for get classs loders etc..
      * @return
      * @throws org.apache.axis2.deployment.DeploymentException
+     *
      */
     public static AxisModule buildModule(File modulearchive, DeploymentEngine engine, AxisConfiguration
config)
             throws DeploymentException {
@@ -483,5 +484,46 @@
         }
 
         return axisService;
+    }
+
+    public static String getPath(String parent, String childPath) {
+        Stack parentStack = new Stack();
+        Stack childStack = new Stack();
+        if (parent != null) {
+            String [] values = parent.split("/");
+            if (values.length > 0) {
+                for (int i = 0; i < values.length; i++) {
+                    String value = values[i];
+                    parentStack.push(value);
+                }
+            }
+        }
+        String [] values = childPath.split("/");
+        if (values.length > 0) {
+            for (int i = 0; i < values.length; i++) {
+                String value = values[i];
+                childStack.push(value);
+            }
+        }
+        String filepath = "";
+        while (!childStack.isEmpty()) {
+            String value = (String) childStack.pop();
+            if ("..".equals(value)) {
+                parentStack.pop();
+            } else if (!"".equals(value)) {
+                if ("".equals(filepath)) {
+                    filepath = value;
+                } else {
+                    filepath = value + "/" + filepath;
+                }
+            }
+        }
+        while (!parentStack.isEmpty()) {
+            String value = (String) parentStack.pop();
+            if (!"".equals(value)) {
+                filepath = value + "/" + filepath;
+            }
+        }
+        return filepath;
     }
 }

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java?rev=439266&r1=439265&r2=439266&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java
Fri Sep  1 03:44:11 2006
@@ -1568,7 +1568,8 @@
                 // just add this schema - no need to worry about the imported
                 // ones
                 axisService.addSchema(getXMLSchema(schema.getElement(),
-                        wsdl4jDefinition.getDocumentBaseURI()));
+                        schema.getDocumentBaseURI()));
+//                        wsdl4jDefinition.getDocumentBaseURI()));
 
             } else if (SOAPConstants.Q_ELEM_SOAP_OPERATION.equals(wsdl4jElement
                     .getElementType())) {



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message