juddi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ks...@apache.org
Subject svn commit: r1130586 - in /juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client: UDDIServiceWSDL.java config/Property.java
Date Thu, 02 Jun 2011 14:48:06 GMT
Author: kstam
Date: Thu Jun  2 14:48:05 2011
New Revision: 1130586

URL: http://svn.apache.org/viewvc?rev=1130586&view=rev
Log:
JUDDI-489, using the jboss.server.temp.dir on jboss 

Modified:
    juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/UDDIServiceWSDL.java
    juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/Property.java

Modified: juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/UDDIServiceWSDL.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/UDDIServiceWSDL.java?rev=1130586&r1=1130585&r2=1130586&view=diff
==============================================================================
--- juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/UDDIServiceWSDL.java
(original)
+++ juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/UDDIServiceWSDL.java
Thu Jun  2 14:48:05 2011
@@ -6,10 +6,18 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStreamWriter;
 import java.io.Writer;
+import java.net.URISyntaxException;
 import java.net.URL;
+import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
+import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamSource;
+
+import org.apache.juddi.v3.client.config.Property;
+
 public class UDDIServiceWSDL {
 	
 	/** The WSDLEnpoint Types as defined in the UDDI v3 specification. */
@@ -61,6 +69,17 @@ public class UDDIServiceWSDL {
 		specEndPoints.put(WSDLEndPointType.VALUESETCACHING      , "http://localhost/uddi/valuesetcaching/");
 	}
 	
+	public List<Source> getWSDLFilePaths(String destDir) throws IOException {
+		File tmpDir = new File(destDir);
+		if (!tmpDir.exists()) copyImportFiles(destDir);
+		List<Source> metadata = new ArrayList<Source>();
+		for (String importFileName : imports) {
+			File file = new File(destDir + File.separator + importFileName);
+			Source source = new StreamSource(file);
+			metadata.add(source);
+		}
+	    return metadata;
+	}
 	/**
 	 * Returns the path to a temporary uddi_v3_service.wsdl file, where the soap:address location
 	 * of the given endPointType has been updated with the value specified in the soapAddressLocation.
@@ -69,26 +88,30 @@ public class UDDIServiceWSDL {
 	 * @param soapAddressLocation
 	 * @return WSDL File Path
 	 * @throws IOException
+	 * @throws URISyntaxException 
 	 */
-	public URL getWSDLFilePath(WSDLEndPointType endpointType, String soapAddressLocation) throws
IOException 
+	public URL getWSDLFilePath(WSDLEndPointType endpointType, String soapAddressLocation) throws
IOException
 	{
 		String wsdlString = getServiceWSDLContent();
 	    String specEndPoint = specEndPoints.get(endpointType);
-	    wsdlString = wsdlString.replace(specEndPoint, soapAddressLocation);
-	    String destDir = System.getProperty("java.io.tmpdir");
+	    if (soapAddressLocation!=null) {
+	    	wsdlString = wsdlString.replace(specEndPoint, soapAddressLocation);
+	    }
+	    String destDir = Property.getTempDir();
 	    File tmpDir = new File(destDir);
 	    if (!tmpDir.exists()) {
 	    	tmpDir.mkdirs();
 	    }
-	    File tmpWSDLFile = File.createTempFile("uddi_v3_service", "wsdl", tmpDir);
+	    copyImportFiles(destDir);
+	    
+	    File tmpWSDLFile = File.createTempFile( "uddi_v3_service.wsdl", ".wsdl", tmpDir);
 	    Writer out = new OutputStreamWriter(new FileOutputStream(tmpWSDLFile));
 	    try {
 	      out.write(wsdlString);
 	    } finally {
 	      out.close();
 	    }
-	    copyImportFiles();
-	    URL url = new URL("file:" + tmpWSDLFile.getAbsolutePath());
+	    URL url = tmpWSDLFile.toURI().toURL();
 	    return url;
 	}
 	
@@ -104,7 +127,7 @@ public class UDDIServiceWSDL {
 	    return read(serviceWSDLURL);
 	}
 	
-	private void copyImportFiles() throws IOException
+	private void copyImportFiles(String destDir) throws IOException
 	{
 		URL serviceWSDLURL = ClassUtil.getResource(getUddiV3ServiceWSDL(),this.getClass());
 		if (serviceWSDLURL==null) throw new IOException("Could not locate resource " + getUddiV3ServiceWSDL());
@@ -113,7 +136,6 @@ public class UDDIServiceWSDL {
     		endIndex = getUddiV3ServiceWSDL().lastIndexOf(File.separator);
     	}
 		String srcDir  = getUddiV3ServiceWSDL().substring(0,endIndex);
-		String destDir = System.getProperty("java.io.tmpdir");
 		for (String importFileName : imports) {
 			URL url = ClassUtil.getResource(srcDir + importFileName, this.getClass());
 			String content = read(url);

Modified: juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/Property.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/Property.java?rev=1130586&r1=1130585&r2=1130586&view=diff
==============================================================================
--- juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/Property.java
(original)
+++ juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/Property.java
Thu Jun  2 14:48:05 2011
@@ -16,6 +16,8 @@
  */
 package org.apache.juddi.v3.client.config;
 
+import java.net.URI;
+import java.net.URISyntaxException;
 import java.net.URL;
 import java.util.Properties;
 
@@ -52,6 +54,14 @@ public class Property 
 	public static final String DEFAULT_BINDING_KEY_FORMAT       = "uddi:${keyDomain}:binding_${nodeName}_${serviceName}_${portName}_${port}";
 	public static final String DEFAULT_SERVICE_DESCRIPTION      = "Default service description
when no <wsdl:document> element is defined inside the <wsdl:service> element.";
 	public static final String DEFAULT_BINDING_DESCRIPTION      = "Default binding description
when no <wsdl:document> element is defined inside the <wsdl:binding> element.";
+	
+	public static String getTempDir() {
+		String tmpDir = System.getProperty("jboss.server.temp.dir");
+		if (tmpDir == null) {
+			tmpDir = System.getProperty("java.io.tmpdir");
+		}
+		return tmpDir;
+	}
 	/**
 	 * Constructs the serviceKey based on the bindingKeyFormat specified in the properties.
When no
 	 * businessKeyFormat is specific the default format of uddi:${keyDomain}:${businessName}
is used. The businessName
@@ -88,6 +98,19 @@ public class Property 
 		String serviceKey = TokenResolver.replaceTokens(keyFormat, tempProperties).toLowerCase();
 		return serviceKey;
 	}
+	
+	public static String getBindingKey(Properties properties, QName serviceName, String portName,
URL bindingUrl) {
+		
+		String bindingKey = null;
+		try {
+			URI bindingURI = bindingUrl.toURI();
+			bindingKey =  getBindingKey(properties, serviceName, portName, bindingURI);
+		} catch (URISyntaxException e) {
+			
+		}
+		return bindingKey;
+		
+	}
 	/**
 	 * Constructs the bindingKey based on the bindingKeyFormat specified in the properties.
When no
 	 * bindingKeyFormat is specific the default format of uddi:${keyDomain}:${nodeName}-${serviceName}-{portName}
is used.
@@ -97,20 +120,20 @@ public class Property 
 	 * @param portName
 	 * @return the bindingKey
 	 */
-	public static String getBindingKey(Properties properties, QName serviceName, String portName,
URL bindingUrl) {
+	public static String getBindingKey(Properties properties, QName serviceName, String portName,
URI bindingUrl) {
 		Properties tempProperties = new Properties();
 		tempProperties.putAll(properties);
 		tempProperties.put("serviceName", serviceName.getLocalPart());
 		tempProperties.put("portName", portName);
 		int port = bindingUrl.getPort();
 		if (port==-1) {
-			if ("http".equals(bindingUrl.getProtocol())) {
+			if ("http".equals(bindingUrl.getScheme())) {
 				port = 80;
-			} else if ("https".equals(bindingUrl.getProtocol())) {
+			} else if ("https".equals(bindingUrl.getScheme())) {
 				port = 443;
 			}
 		}
-		tempProperties.put("port", port);
+		tempProperties.put("port", String.valueOf(port));
 		//Constructing the binding Key
 		String keyFormat = properties.getProperty(BINDING_KEY_FORMAT, DEFAULT_BINDING_KEY_FORMAT);
 		String bindingKey = TokenResolver.replaceTokens(keyFormat, tempProperties).toLowerCase();



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@juddi.apache.org
For additional commands, e-mail: commits-help@juddi.apache.org


Mime
View raw message