You are viewing a plain text version of this content. The canonical link for it is here.
Posted to muse-commits@ws.apache.org by ae...@apache.org on 2007/03/13 19:10:36 UTC

svn commit: r517798 - in /webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator: Messages.properties WsdlMerge.java

Author: aeberbac
Date: Tue Mar 13 11:10:35 2007
New Revision: 517798

URL: http://svn.apache.org/viewvc?view=rev&rev=517798
Log:
Fixed up error handling and reporting and added appropriate messages.

Modified:
    webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/Messages.properties
    webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/WsdlMerge.java

Modified: webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/Messages.properties
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/Messages.properties?view=diff&rev=517798&r1=517797&r2=517798
==============================================================================
--- webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/Messages.properties (original)
+++ webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/Messages.properties Tue Mar 13 11:10:35 2007
@@ -62,6 +62,11 @@
 
 
 # WsdlMerge
+WsdlMergeFailed = wsdlmerge encountered an error. Use XXX to see more detailed information.
+FailedCopyingProperty = Failed copying property XXX. See the nested exception.
+FailedWritingWsdl = Failed writing to merged WSDL file XXX. See the nested exception.
+FailedWritingRmd = Failed writing to merged RMD file XXX. See the nested exception.
+WsdlFragmentParseFailed = Failed parsing WSDL document number XXX (in the order passed on the command line). See nested exception.
 NoURIFlag = No URI was specified using XXX. This URI is used as the target namespace URI for the generated WSDL document. Try running with XXX for more information.
 NoAddressFlag = No Address was specified using XXX. This Address is used as the value for the location attribute on the service created for the generated WSDL document. Try running with XXX for more information.
 NoOutputFlag = No output file was specified using XXX. This is the file to which the merged WSDL should be written. Try running with XXX for more information.

Modified: webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/WsdlMerge.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/WsdlMerge.java?view=diff&rev=517798&r1=517797&r2=517798
==============================================================================
--- webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/WsdlMerge.java (original)
+++ webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/WsdlMerge.java Tue Mar 13 11:10:35 2007
@@ -29,6 +29,7 @@
 import javax.wsdl.Operation;
 import javax.wsdl.PortType;
 import javax.wsdl.Types;
+import javax.wsdl.WSDLException;
 import javax.wsdl.extensions.schema.Schema;
 import javax.wsdl.factory.WSDLFactory;
 import javax.wsdl.xml.WSDLReader;
@@ -79,7 +80,7 @@
 
             _reader.setFeature(WsdlUtils.WSDL4J_VERBOSE_FLAG, false);
 		} catch (Exception e) {
-			handleErrorAndExit(_MESSAGES.get("NoFactory"), e);
+			throw new MuseRuntimeException("NoFactory", _MESSAGES.get("NoFactory"), e);
 		}
 	}
 		
@@ -107,7 +108,8 @@
 			
 			run(files, outputFileName, outputRMDFileName, overwrite, uri, address);
 		} catch (Exception e) {
-			handleErrorAndExit(e.getMessage(), e);
+			Object[] filler = { Wsdl2JavaConstants.VERBOSE_FLAG };
+			handleErrorAndExit(_MESSAGES.get("WsdlMergeFailed", filler), e);
 		}
 	}
 
@@ -200,8 +202,14 @@
 	public static Definition merge(String namespaceURI, Document[] wsdlFragments, String address) {
 		DefinitionInfo targetDefinition = new DefinitionInfo(namespaceURI);
 
-		for (int i = 0; i < wsdlFragments.length; i++) {			
-			DefinitionInfo definition = new DefinitionInfo(load(wsdlFragments[i]));
+		DefinitionInfo definition = null;
+		for (int i = 0; i < wsdlFragments.length; i++) {	
+			try {
+				definition = new DefinitionInfo(load(wsdlFragments[i]));
+			} catch (WSDLException e) {
+				Object[] filler = { Integer.valueOf(i) };
+				throw new MuseRuntimeException("WsdlFragmentParseFailed", _MESSAGES.get("WsdlFragmentParseFailed", filler), e);
+			}
 			copyOperations(definition, targetDefinition);
 			copyProperties(definition, targetDefinition);
 		}
@@ -225,8 +233,8 @@
 			try {
 				addProperty(nextProperty, sourceMetadata, targetMetadata);
 			} catch (Exception e) {
-				//TODO
-				throw new RuntimeException();
+				Object[] filler = { nextProperty };
+				throw new MuseRuntimeException("FailedCopyingProperty", _MESSAGES.get("FailedCopyingProperty", filler), e);
 			}
 		}
 	}    
@@ -337,7 +345,7 @@
 					ADDRESS_FLAG,
 					HELP_FLAG
 				};
-			handleErrorAndExit(_MESSAGES.get("NoAddressFlag",filler));
+			throw new MuseRuntimeException("NoAddressFlag", _MESSAGES.get("NoAddressFlag",filler));
 		}
 		
 		return addressArg;
@@ -357,7 +365,7 @@
 				URI_FLAG,
 				HELP_FLAG
 			};
-			handleErrorAndExit(_MESSAGES.get("NoURIFlag",filler));
+			throw new MuseRuntimeException("NoURIFlag", _MESSAGES.get("NoURIFlag",filler));
 		}
 		
 		return uriArg;
@@ -377,7 +385,7 @@
 					OUTPUT_FLAG,
 					HELP_FLAG
 				};
-			handleErrorAndExit(_MESSAGES.get("NoOutputFlag",filler));
+			throw new MuseRuntimeException("NoOutputFlag", _MESSAGES.get("NoOutputFlag",filler));
 		}
 		
 		return outputArg;
@@ -398,13 +406,13 @@
 			files[i] = new File(argFiles[i]);	
 			if(!files[i].exists()) {
 				Object[] filler = { files[i] };
-				handleErrorAndExit(_MESSAGES.get("NonExistant", filler));
+				throw new MuseRuntimeException("NonExistant", _MESSAGES.get("NonExistant", filler));
 			}
 		}
 		
 		if(files.length  == 0) {
 			Object filler[] = { HELP_FLAG };
-			handleErrorAndExit(_MESSAGES.get("NoWSDLs", filler));
+			throw new MuseRuntimeException("NoWSDLs", _MESSAGES.get("NoWSDLs", filler));
 		}
 		
 		return files;
@@ -420,18 +428,11 @@
 	 * 
 	 * @return
 	 * 			A <code>Defintion</code> if parsing was successful
+	 * @throws WSDLException 
 	 */
-	private static Definition load(Document document) {
-		Definition definition = null;
+	private static Definition load(Document document) throws WSDLException {
 		String parent = null;
-		try {	
-			definition = _reader.readWSDL(parent, document);							
-		} catch (Exception e) {
-			//TODO fix
-			handleErrorAndExit(_MESSAGES.get("FailedWSDLParse"),e);
-		}
-		
-		return definition;
+		return _reader.readWSDL(parent, document);									
 	}
 	
 	private static void writeRmd(String fileName, MetadataDescriptor metadata, boolean overwrite) {
@@ -445,7 +446,8 @@
 				fileWriter.write(XmlUtils.toString(rmdDoc));
 				fileWriter.close();			
 			} catch (Exception e) {
-				throw new RuntimeException(e);
+				Object[] filler = {metadataDestination.getAbsolutePath()};
+				throw new MuseRuntimeException("FailedWritingRmd", _MESSAGES.get("FailedWritingRmd", filler), e);
 			}
 		} else {
 			handleMessage(_MESSAGES.get("NotOverwriting", new String[] {metadataDestination.getPath()}));
@@ -464,8 +466,8 @@
 				fileWriter.write(XmlUtils.toString(wsdlDoc));
 				fileWriter.close();			
 			} catch (Exception e) {
-				//TODO
-				handleErrorAndExit("failed writing wsdl");
+				Object[] filler = {wsdlDestination.getAbsolutePath()};
+				throw new MuseRuntimeException("FailedWritingWsdl", _MESSAGES.get("FailedWritingWsdl", filler), e);
 			}
 		} else {
 			handleMessage(_MESSAGES.get("NotOverwriting", new String[] {wsdlDestination.getPath()}));



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