Author: klape
Date: 2012-07-20 13:00:44 -0400 (Fri, 20 Jul 2012)
New Revision: 16510
Modified:
stack/native/branches/jbossws-native-3.1.2.SP11_JBPAPP-9542/
stack/native/branches/jbossws-native-3.1.2.SP11_JBPAPP-9542/modules/core/
stack/native/branches/jbossws-native-3.1.2.SP11_JBPAPP-9542/modules/core/src/main/java/org/jboss/ws/metadata/builder/jaxws/JAXWSWebServiceMetaDataBuilder.java
stack/native/branches/jbossws-native-3.1.2.SP11_JBPAPP-9542/modules/core/src/main/java/org/jboss/ws/metadata/wsdl/xsd/SchemaUtils.java
stack/native/branches/jbossws-native-3.1.2.SP11_JBPAPP-9542/modules/core/src/main/java/org/jboss/ws/tools/wsdl/WSDL11Reader.java
stack/native/branches/jbossws-native-3.1.2.SP11_JBPAPP-9542/modules/testsuite/native-tests/
Log:
[JBPAPP-9542] Change temporary WSDL and XSD file names in JBossWS
Property changes on: stack/native/branches/jbossws-native-3.1.2.SP11_JBPAPP-9542
___________________________________________________________________
Modified: svn:mergeinfo
- /stack/native/branches/jbossws-native-3.1.2.SP3-patch-02_JBPAPP-6365:14192
/stack/native/branches/jbossws-native-3.4.0.SP1:13928,13933,13936,13946
/stack/native/trunk:12502,13992,14157,14160,14181,14183,14842
+ /stack/native/branches/jbossws-native-3.1.2:16504
/stack/native/branches/jbossws-native-3.1.2.SP3-patch-02_JBPAPP-6365:14192
/stack/native/branches/jbossws-native-3.4.0.SP1:13928,13933,13936,13946
/stack/native/trunk:12502,13992,14157,14160,14181,14183,14842
Property changes on:
stack/native/branches/jbossws-native-3.1.2.SP11_JBPAPP-9542/modules/core
___________________________________________________________________
Modified: svn:mergeinfo
-
/stack/native/branches/jbossws-native-3.1.2.SP3-patch-02_JBPAPP-6365/modules/core:14192
/stack/native/branches/jbossws-native-3.4.0.SP1/modules/core:13928,13933,13936,13946
/stack/native/trunk/modules/core:12502,13992,14011,14157,14160,14181,14183,14842
+ /stack/native/branches/jbossws-native-3.1.2/modules/core:16504
/stack/native/branches/jbossws-native-3.1.2.SP3-patch-02_JBPAPP-6365/modules/core:14192
/stack/native/branches/jbossws-native-3.4.0.SP1/modules/core:13928,13933,13936,13946
/stack/native/trunk/modules/core:12502,13992,14011,14157,14160,14181,14183,14842
Modified:
stack/native/branches/jbossws-native-3.1.2.SP11_JBPAPP-9542/modules/core/src/main/java/org/jboss/ws/metadata/builder/jaxws/JAXWSWebServiceMetaDataBuilder.java
===================================================================
---
stack/native/branches/jbossws-native-3.1.2.SP11_JBPAPP-9542/modules/core/src/main/java/org/jboss/ws/metadata/builder/jaxws/JAXWSWebServiceMetaDataBuilder.java 2012-07-20
16:38:34 UTC (rev 16509)
+++
stack/native/branches/jbossws-native-3.1.2.SP11_JBPAPP-9542/modules/core/src/main/java/org/jboss/ws/metadata/builder/jaxws/JAXWSWebServiceMetaDataBuilder.java 2012-07-20
17:00:44 UTC (rev 16510)
@@ -26,6 +26,9 @@
import java.io.PrintStream;
import java.io.Writer;
import java.net.URL;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.math.BigInteger;
import javax.jws.HandlerChain;
import javax.jws.WebService;
@@ -398,10 +401,11 @@
}
}
- private void writeWsdl(ServiceMetaData serviceMetaData, WSDLDefinitions
wsdlDefinitions, EndpointMetaData epMetaData) throws IOException
+ private void writeWsdl(final ServiceMetaData serviceMetaData, WSDLDefinitions
wsdlDefinitions, EndpointMetaData epMetaData) throws IOException
{
// The RI uses upper case, and the TCK expects it, so we just mimic this even
though we don't really have to
String wsdlName =
ToolsUtils.firstLetterUpperCase(serviceMetaData.getServiceName().getLocalPart());
+
// Ensure that types are only in the interface qname
wsdlDefinitions.getWsdlTypes().setNamespace(epMetaData.getPortTypeName().getNamespaceURI());
@@ -415,8 +419,7 @@
else
{
dir = IOUtils.createTempDirectory();
- wsdlFile = File.createTempFile(wsdlName, ".wsdl", dir);
- wsdlFile.deleteOnExit();
+ wsdlFile = computeTempWsdlFile(serviceMetaData, dir, wsdlName);
}
message(wsdlFile.getName());
@@ -431,8 +434,7 @@
}
else
{
- file = File.createTempFile(suggestedFile, ".wsdl", dir);
- file.deleteOnExit();
+ file = computeTempWsdlFile(serviceMetaData, dir, suggestedFile);
}
actualFile = file.getName();
message(actualFile);
@@ -446,6 +448,35 @@
serviceMetaData.setWsdlLocation(wsdlFile.toURL());
}
+ private File computeTempWsdlFile(ServiceMetaData serviceMetaData, File dir, String
wsdlName) throws IOException
+ {
+ File wsdlFile = null;
+ try
+ {
+ byte[] deploymentName =
serviceMetaData.getUnifiedMetaData().getDeploymentName().getBytes("UTF-8");
+ String deploymentNameHash =
toHexString(MessageDigest.getInstance("MD5").digest(deploymentName));
+ wsdlFile = new File(dir + File.separator + wsdlName + "_" +
deploymentNameHash + ".wsdl");
+ }
+ catch(NoSuchAlgorithmException ex)
+ {
+ if(log.isTraceEnabled())
+ log.trace("MD5 has of deployment name failed for WSDL file name.
Falling back to File.createTempFile()", ex);
+ else
+ log.debug("MD5 has of deployment name failed for WSDL file name.
Falling back to File.createTempFile()");
+
+ wsdlFile = File.createTempFile(wsdlName, ".wsdl", dir);
+ }
+
+ wsdlFile.deleteOnExit();
+ return wsdlFile;
+ }
+
+ private String toHexString(byte[] hash)
+ {
+ BigInteger bi = new BigInteger(1, hash);
+ return String.format("%0" + (hash.length << 1) + "x",
bi);
+ }
+
private void message(String msg)
{
if (messageStream != null)
Modified:
stack/native/branches/jbossws-native-3.1.2.SP11_JBPAPP-9542/modules/core/src/main/java/org/jboss/ws/metadata/wsdl/xsd/SchemaUtils.java
===================================================================
---
stack/native/branches/jbossws-native-3.1.2.SP11_JBPAPP-9542/modules/core/src/main/java/org/jboss/ws/metadata/wsdl/xsd/SchemaUtils.java 2012-07-20
16:38:34 UTC (rev 16509)
+++
stack/native/branches/jbossws-native-3.1.2.SP11_JBPAPP-9542/modules/core/src/main/java/org/jboss/ws/metadata/wsdl/xsd/SchemaUtils.java 2012-07-20
17:00:44 UTC (rev 16510)
@@ -27,6 +27,11 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.math.BigInteger;
import javax.xml.namespace.QName;
@@ -508,7 +513,7 @@
/** Get the temp file for a given namespace
*/
- public static File getSchemaTempFile(String targetNS) throws IOException
+ public static File getSchemaTempFile(String targetNS, String fileName) throws
IOException
{
if (targetNS.length() == 0)
throw new IllegalArgumentException("Invalid null target namespace");
@@ -521,7 +526,8 @@
try
{
SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
- ServerConfig serverConfig =
spiProvider.getSPI(ServerConfigFactory.class).getServerConfig();File tmpDir =
serverConfig.getServerTempDir();
+ ServerConfig serverConfig =
spiProvider.getSPI(ServerConfigFactory.class).getServerConfig();
+ File tmpDir = serverConfig.getServerTempDir();
tmpdir = serverConfig.getServerTempDir();
tmpdir = new File(tmpdir.getCanonicalPath() + "/jbossws");
tmpdir.mkdirs();
@@ -537,9 +543,35 @@
fname = fname.replace('?', '_');
fname = fname.replace('#', '_');
- return File.createTempFile("JBossWS_" + fname, ".xsd",
tmpdir);
+ File file = null;
+ try
+ {
+ String fileNameHash =
toHexString(MessageDigest.getInstance("MD5").digest(fileName.getBytes("UTF-8")));
+ if(tmpdir == null)
+ {
+ tmpdir = (File) AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run()
+ {
+ return new File(System.getProperty("java.io.tmpdir"));
+ }
+ });
+ }
+ file = new File(tmpdir + File.separator + "JBossWS_" + fname +
"_" + fileNameHash + ".xsd");
+ }
+ catch(NoSuchAlgorithmException noAlgEx)
+ {
+ file = File.createTempFile("JBossWS_" + fname, ".xsd",
tmpdir);
+ }
+
+ return file;
}
+ private static String toHexString(byte[] hash)
+ {
+ BigInteger bi = new BigInteger(1, hash);
+ return String.format("%0" + (hash.length << 1) + "x",
bi);
+ }
+
/**
* Get the TargetNamespace from the schema model
*/
Modified:
stack/native/branches/jbossws-native-3.1.2.SP11_JBPAPP-9542/modules/core/src/main/java/org/jboss/ws/tools/wsdl/WSDL11Reader.java
===================================================================
---
stack/native/branches/jbossws-native-3.1.2.SP11_JBPAPP-9542/modules/core/src/main/java/org/jboss/ws/tools/wsdl/WSDL11Reader.java 2012-07-20
16:38:34 UTC (rev 16509)
+++
stack/native/branches/jbossws-native-3.1.2.SP11_JBPAPP-9542/modules/core/src/main/java/org/jboss/ws/tools/wsdl/WSDL11Reader.java 2012-07-20
17:00:44 UTC (rev 16510)
@@ -544,14 +544,14 @@
{
log.trace("processSchemaInclude: [targetNS=" + targetNS +
",parentURL=" + wsdlLoc + "]");
- tmpFile = SchemaUtils.getSchemaTempFile(targetNS);
+ tmpFile = SchemaUtils.getSchemaTempFile(targetNS, getFileName(wsdlLoc));
tempFiles.add(tmpFile);
publishedLocations.put(wsdlLoc, tmpFile.toURL());
}
else
{
- tmpFile = SchemaUtils.getSchemaTempFile("no_namespace");
+ tmpFile = SchemaUtils.getSchemaTempFile("no_namespace",
getFileName(wsdlLoc));
tempFiles.add(tmpFile);
publishedLocations.put(wsdlLoc, tmpFile.toURL());
@@ -600,6 +600,22 @@
handleSchemaImports(schemaEl, wsdlLoc);
}
+ private String getFileName(URL url)
+ {
+ String query = url.getQuery();
+ if(query != null)
+ {
+ if(query.contains("="))
+ {
+ return query.split("=")[1];
+ }
+ }
+
+ String exUrl = url.toExternalForm();
+ String[] paths = exUrl.split("/");
+ return paths[paths.length-1];
+ }
+
private void handleSchemaImports(Element schemaEl, URL parentURL) throws
WSDLException, IOException
{
if (parentURL == null)
Property changes on:
stack/native/branches/jbossws-native-3.1.2.SP11_JBPAPP-9542/modules/testsuite/native-tests
___________________________________________________________________
Modified: svn:mergeinfo
-
/stack/native/branches/jbossws-native-3.1.2.SP3-patch-02_JBPAPP-6365/modules/testsuite/native-tests:14192
/stack/native/branches/jbossws-native-3.4.0.SP1/modules/testsuite/native-tests:13928,13933,13936,13946
/stack/native/trunk/modules/testsuite/native-tests:12502,13992,14013,14157,14160,14181,14183,14842
+ /stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests:16504
/stack/native/branches/jbossws-native-3.1.2.SP3-patch-02_JBPAPP-6365/modules/testsuite/native-tests:14192
/stack/native/branches/jbossws-native-3.4.0.SP1/modules/testsuite/native-tests:13928,13933,13936,13946
/stack/native/trunk/modules/testsuite/native-tests:12502,13992,14013,14157,14160,14181,14183,14842