[jboss-svn-commits] JBL Code SVN: r8918 - in labs/jbossesb/trunk/product/core: rosetta/src/org/jboss/internal/soa/esb and 7 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Fri Jan 19 07:32:19 EST 2007


Author: tfennelly
Date: 2007-01-19 07:32:19 -0500 (Fri, 19 Jan 2007)
New Revision: 8918

Added:
   labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/assertion/
   labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/assertion/AssertArgument.java
Modified:
   labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/message/ActionProcessingPipeline.java
   labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/message/CbrListener.java
   labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/addressing/helpers/CallHelper.java
   labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/addressing/helpers/EPRHelper.java
   labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/FileCourier.java
   labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/TwoWayCourierImpl.java
   labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/MarshalException.java
   labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/UnmarshalException.java
   labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/addressing/Call.java
   labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/addressing/EPR.java
   labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/addressing/eprs/JMSEpr.java
   labs/jbossesb/trunk/product/core/rosetta/tests/src/org/jboss/soa/esb/addressing/util/tests/EPRHelperUnitTest.java
Log:
Some exception cleanups

Modified: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/message/ActionProcessingPipeline.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/message/ActionProcessingPipeline.java	2007-01-19 10:45:30 UTC (rev 8917)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/message/ActionProcessingPipeline.java	2007-01-19 12:32:19 UTC (rev 8918)
@@ -126,6 +126,7 @@
         catch(IllegalAccessException e)
     	{	_logger.error(prematureTermination("unable to access method"),e); } 
         catch (IllegalArgumentException e) {
+        	_logger.error(prematureTermination(e.getMessage()),e);
         } 
         finally 
         {

Modified: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/message/CbrListener.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/message/CbrListener.java	2007-01-19 10:45:30 UTC (rev 8917)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/message/CbrListener.java	2007-01-19 12:32:19 UTC (rev 8918)
@@ -126,8 +126,6 @@
         					} else {
         						_logger.log(Priority.ERROR, "Unable to reply to caller. Could not optain replyTo EPR.");
         					}
-        				} catch (URISyntaxException use) {
-        					_logger.log(Priority.ERROR, "Unable to reply to caller. "+ use.getLocalizedMessage(), use);
         				} catch (CourierException ce) {
         					_logger.log(Priority.ERROR, "Unable to reply to caller. "+ ce.getLocalizedMessage(), ce);
         				}

Modified: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/addressing/helpers/CallHelper.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/addressing/helpers/CallHelper.java	2007-01-19 10:45:30 UTC (rev 8917)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/addressing/helpers/CallHelper.java	2007-01-19 12:32:19 UTC (rev 8918)
@@ -22,8 +22,9 @@
  */
 
 import java.net.URI;
-import java.security.InvalidParameterException;
+import java.net.URISyntaxException;
 
+import org.jboss.internal.soa.esb.assertion.AssertArgument;
 import org.jboss.soa.esb.MarshalException;
 import org.jboss.soa.esb.UnmarshalException;
 import org.jboss.soa.esb.addressing.Call;
@@ -33,185 +34,125 @@
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
-public class CallHelper
+public abstract class CallHelper
 {
 
 	public static Element toXML (Call call, Document doc, Element header) throws MarshalException
 	{
-		if (call == null)
-			throw new InvalidParameterException();
+		AssertArgument.isNotNull(call, "call");
+		AssertArgument.isNotNull(doc, "doc");
+		AssertArgument.isNotNull(header, "header");
 		
-		try
+		if (call.getTo() != null)
 		{
-			if (call.getTo() != null)
-			{
-				Element toElement = doc.createElementNS(XMLUtil.WSA_NAMESPACE_URI, XMLUtil.WSA_PREFIX+":"+XMLUtil.TO_TAG);
-				EPRHelper.toXML(call.getTo(), doc, header, toElement, true);
-				header.appendChild(toElement);
-			}
-			
-			if (call.getFrom() != null)
-			{
-				Element fromElement = doc.createElementNS(XMLUtil.WSA_NAMESPACE_URI, XMLUtil.WSA_PREFIX+":"+XMLUtil.FROM_TAG);
-				EPRHelper.toXML(call.getFrom(), doc, header, fromElement, false);
-				header.appendChild(fromElement);
-			}
-			
-			if (call.getReplyTo() != null)
-			{
-				Element replyToElement = doc.createElementNS(XMLUtil.WSA_NAMESPACE_URI, XMLUtil.WSA_PREFIX+":"+XMLUtil.REPLY_TO_TAG);
-				EPRHelper.toXML(call.getReplyTo(), doc, header, replyToElement, false);
-				header.appendChild(replyToElement);
-			}
-			
-			if (call.getRelatesTo() != null)
-			{
-				Element relatesToElement = doc.createElementNS(XMLUtil.WSA_NAMESPACE_URI, XMLUtil.WSA_PREFIX+":"+XMLUtil.RELATES_TO_TAG);
-				relatesToElement.setNodeValue(call.getRelatesTo().toString());
-				header.appendChild(relatesToElement);
-			}
-			
-			if (call.getFaultTo() != null)
-			{
-				Element faultToElement = doc.createElementNS(XMLUtil.WSA_NAMESPACE_URI, XMLUtil.WSA_PREFIX+":"+XMLUtil.FAULT_TO_TAG);
-				EPRHelper.toXML(call.getFaultTo(), doc, header, faultToElement, false);
-				header.appendChild(faultToElement);
-			}
-			
-			if (call.getAction() != null)
-			{
-				Element actionElement = doc.createElementNS(XMLUtil.WSA_NAMESPACE_URI, XMLUtil.WSA_PREFIX+":"+XMLUtil.ACTION_TAG);
-				actionElement.setTextContent(call.getAction().toString());
-				header.appendChild(actionElement);
-			}
-			
-			if (call.getMessageID() != null)
-			{
-				Element messageIDElement = doc.createElementNS(XMLUtil.WSA_NAMESPACE_URI, XMLUtil.WSA_PREFIX+":"+XMLUtil.MESSAGE_IDENTIFIER_TAG);
-				messageIDElement.setTextContent(call.getMessageID().toString());
-				header.appendChild(messageIDElement);
-			}
-				
-			return header;
+			Element toElement = doc.createElementNS(XMLUtil.WSA_NAMESPACE_URI, XMLUtil.WSA_PREFIX+":"+XMLUtil.TO_TAG);
+			EPRHelper.toXML(call.getTo(), doc, header, toElement, true);
+			header.appendChild(toElement);
 		}
-		catch (Exception ex)
+		
+		if (call.getFrom() != null)
 		{
-			ex.printStackTrace();
-			
-			throw new MarshalException(ex);
+			Element fromElement = doc.createElementNS(XMLUtil.WSA_NAMESPACE_URI, XMLUtil.WSA_PREFIX+":"+XMLUtil.FROM_TAG);
+			EPRHelper.toXML(call.getFrom(), doc, header, fromElement, false);
+			header.appendChild(fromElement);
 		}
+		
+		if (call.getReplyTo() != null)
+		{
+			Element replyToElement = doc.createElementNS(XMLUtil.WSA_NAMESPACE_URI, XMLUtil.WSA_PREFIX+":"+XMLUtil.REPLY_TO_TAG);
+			EPRHelper.toXML(call.getReplyTo(), doc, header, replyToElement, false);
+			header.appendChild(replyToElement);
+		}
+		
+		if (call.getRelatesTo() != null)
+		{
+			Element relatesToElement = doc.createElementNS(XMLUtil.WSA_NAMESPACE_URI, XMLUtil.WSA_PREFIX+":"+XMLUtil.RELATES_TO_TAG);
+			relatesToElement.setNodeValue(call.getRelatesTo().toString());
+			header.appendChild(relatesToElement);
+		}
+		
+		if (call.getFaultTo() != null)
+		{
+			Element faultToElement = doc.createElementNS(XMLUtil.WSA_NAMESPACE_URI, XMLUtil.WSA_PREFIX+":"+XMLUtil.FAULT_TO_TAG);
+			EPRHelper.toXML(call.getFaultTo(), doc, header, faultToElement, false);
+			header.appendChild(faultToElement);
+		}
+		
+		if (call.getAction() != null)
+		{
+			Element actionElement = doc.createElementNS(XMLUtil.WSA_NAMESPACE_URI, XMLUtil.WSA_PREFIX+":"+XMLUtil.ACTION_TAG);
+			actionElement.setTextContent(call.getAction().toString());
+			header.appendChild(actionElement);
+		}
+		
+		if (call.getMessageID() != null)
+		{
+			Element messageIDElement = doc.createElementNS(XMLUtil.WSA_NAMESPACE_URI, XMLUtil.WSA_PREFIX+":"+XMLUtil.MESSAGE_IDENTIFIER_TAG);
+			messageIDElement.setTextContent(call.getMessageID().toString());
+			header.appendChild(messageIDElement);
+		}
+			
+		return header;
 	}
 	
 	public static Call fromXML (Element header) throws UnmarshalException
 	{
-		if (header == null)
-			throw new IllegalArgumentException();
+		AssertArgument.isNotNull(header, "header");
 		
-		Call call = null;
+		Call call = new Call();
+		NodeList nl = header.getChildNodes();
 		
-		try
+		for (int i = 0; i < nl.getLength(); i++)
 		{
-			call = new Call();
+			Node n = nl.item(i);
 			
-			NodeList nl = header.getChildNodes();
+			if (n.getNodeName().equals(XMLUtil.WSA_PREFIX+":"+XMLUtil.TO_TAG))
+			{
+				call.setTo(EPRHelper.fromXML((Element) header, true));
+			}
 			
-			for (int i = 0; i < nl.getLength(); i++)
+			if (n.getNodeName().equals(XMLUtil.WSA_PREFIX+":"+XMLUtil.FROM_TAG))
 			{
-				Node n = nl.item(i);
-				
-				if (n.getNodeName().equals(XMLUtil.WSA_PREFIX+":"+XMLUtil.TO_TAG))
-				{
-					try
-					{
-						call.setTo(EPRHelper.fromXML((Element) header, true));
-					}
-					catch (Exception ex)
-					{
-						throw new UnmarshalException(ex);
-					}
-				}
-				
-				if (n.getNodeName().equals(XMLUtil.WSA_PREFIX+":"+XMLUtil.FROM_TAG))
-				{
-					try
-					{
-						call.setFrom(EPRHelper.fromXML((Element) n, false));
-					}
-					catch (Exception ex)
-					{
-						throw new UnmarshalException(ex);
-					}
-				}
-				
-				if (n.getNodeName().equals(XMLUtil.WSA_PREFIX+":"+XMLUtil.REPLY_TO_TAG))
-				{
-					try
-					{
-						call.setReplyTo(EPRHelper.fromXML((Element) n, false));
-					}
-					catch (Exception ex)
-					{
-						throw new UnmarshalException(ex);
-					}
-				}
+				call.setFrom(EPRHelper.fromXML((Element) n, false));
+			}
+			
+			if (n.getNodeName().equals(XMLUtil.WSA_PREFIX+":"+XMLUtil.REPLY_TO_TAG))
+			{
+				call.setReplyTo(EPRHelper.fromXML((Element) n, false));
+			}
 
-				if (n.getNodeName().equals(XMLUtil.WSA_PREFIX+":"+XMLUtil.RELATES_TO_TAG))
-				{
-					try
-					{
-						call.setRelatesTo(new URI(n.getNodeValue()));
-					}
-					catch (Exception ex)
-					{
-						throw new UnmarshalException(ex);
-					}
+			if (n.getNodeName().equals(XMLUtil.WSA_PREFIX+":"+XMLUtil.RELATES_TO_TAG))
+			{
+				try {
+					call.setRelatesTo(new URI(n.getNodeValue()));
+				} catch (URISyntaxException e) {
+					throw new UnmarshalException("'" + XMLUtil.RELATES_TO_TAG + "' must be a valid URI", e);
 				}
+			}
 
-				if (n.getNodeName().equals(XMLUtil.WSA_PREFIX+":"+XMLUtil.FAULT_TO_TAG))
-				{
-					try
-					{
-						call.setFaultTo(EPRHelper.fromXML((Element) n, false));
-					}
-					catch (Exception ex)
-					{
-						throw new UnmarshalException(ex);
-					}
-				}
+			if (n.getNodeName().equals(XMLUtil.WSA_PREFIX+":"+XMLUtil.FAULT_TO_TAG))
+			{
+				call.setFaultTo(EPRHelper.fromXML((Element) n, false));
+			}
 
-				if (n.getNodeName().equals(XMLUtil.WSA_PREFIX+":"+XMLUtil.ACTION_TAG))
-				{			
-					try
-					{
-						call.setAction(new URI(n.getTextContent()));
-					}
-					catch (Exception ex)
-					{
-						throw new UnmarshalException(ex);
-					}
+			if (n.getNodeName().equals(XMLUtil.WSA_PREFIX+":"+XMLUtil.ACTION_TAG))
+			{			
+				try {
+					call.setAction(new URI(n.getTextContent()));
+				} catch (URISyntaxException e) {
+					throw new UnmarshalException("'" + XMLUtil.ACTION_TAG + "' must be a valid URI", e);
 				}
-				
-				if (n.getNodeName().equals(XMLUtil.WSA_PREFIX+":"+XMLUtil.MESSAGE_IDENTIFIER_TAG))
-				{
-					try
-					{
-						call.setMessageID(new URI(n.getTextContent()));
-					}
-					catch (Exception ex)
-					{
-						throw new UnmarshalException(ex);
-					}
+			}
+			
+			if (n.getNodeName().equals(XMLUtil.WSA_PREFIX+":"+XMLUtil.MESSAGE_IDENTIFIER_TAG))
+			{
+				try {
+					call.setMessageID(new URI(n.getTextContent()));
+				} catch (URISyntaxException e) {
+					throw new UnmarshalException("'" + XMLUtil.MESSAGE_IDENTIFIER_TAG + "' must be a valid URI", e);
 				}
 			}
 		}
-		catch (Exception ex)
-		{
-			// TODO error checking!!
-			
-			ex.printStackTrace();
-			
-			throw new UnmarshalException(ex);
-		}
 		
 		return call;
 	}

Modified: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/addressing/helpers/EPRHelper.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/addressing/helpers/EPRHelper.java	2007-01-19 10:45:30 UTC (rev 8917)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/addressing/helpers/EPRHelper.java	2007-01-19 12:32:19 UTC (rev 8918)
@@ -24,13 +24,12 @@
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.StringWriter;
-import java.net.URISyntaxException;
-import java.security.InvalidParameterException;
 
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
 
+import org.jboss.internal.soa.esb.assertion.AssertArgument;
 import org.jboss.soa.esb.MarshalException;
 import org.jboss.soa.esb.UnmarshalException;
 import org.jboss.soa.esb.addressing.EPR;
@@ -83,25 +82,15 @@
 	public static final Element toXML(EPR epr, Document doc, Element header,
 			Element packElement, boolean to) throws MarshalException
 	{
-		if (epr == null)
-			throw new InvalidParameterException();
+		AssertArgument.isNotNull(epr, "epr");
 
-		try
-		{
-			// TODO
-			// The EPR type really should be doing this itself.
+		// TODO
+		// The EPR type really should be doing this itself.
 
-			setSpecificEPR(epr);
+		setSpecificEPR(epr);
+		PortReferenceHelper.toXML(header, doc, packElement, epr.getAddr(), to);
 
-			PortReferenceHelper.toXML(header, doc, packElement, epr.getAddr(),
-					to);
-
-			return header;
-		}
-		catch (URISyntaxException ex)
-		{
-			throw new MarshalException(ex);
-		}
+		return header;
 	}
 
 	/**
@@ -127,8 +116,7 @@
 	public static final EPR fromXML(Element header, boolean to)
 			throws UnmarshalException
 	{
-		if (header == null)
-			throw new InvalidParameterException();
+		AssertArgument.isNotNull(header, "header");
 
 		if (to)
 		{
@@ -160,9 +148,10 @@
 	 * 
 	 * @param epr
 	 * @return
+	 * @throws MarshalException 
 	 */
 
-	public static final String toXMLString(EPR epr)
+	public static final String toXMLString(EPR epr) throws MarshalException
 	{
 		return toXMLString(epr, false, XMLUtil.FROM_TAG);
 	}
@@ -174,12 +163,13 @@
 	 * 
 	 * @param epr
 	 * @return
+	 * @throws MarshalException 
 	 */
 
-	public static final String toXMLString(EPR epr, boolean to, String tag)
+	public static final String toXMLString(EPR epr, boolean to, String tag) throws MarshalException
 	{
-		if (epr == null)
-			throw new InvalidParameterException();
+		AssertArgument.isNotNull(epr, "epr");
+		AssertArgument.isNotNull(tag, "tag");
 
 		try
 		{
@@ -216,24 +206,14 @@
 
 			return sWriter.toString();
 		}
-		catch (MarshalException ex)
+		catch (ParserConfigurationException ex)
 		{
-			ex.printStackTrace();
-			
-			return null;
+			throw new MarshalException("Failed to construct DOM Document Builder.", ex);
 		}
 		catch (IOException ex)
 		{
-			ex.printStackTrace();
-
-			return null;
+			throw new MarshalException("Error during DOM to String serialisation.", ex);
 		}
-		catch (ParserConfigurationException ex)
-		{
-			ex.printStackTrace();
-
-			return null;
-		}
 	}
 
 	/**
@@ -243,9 +223,10 @@
 	 * 
 	 * @param xml
 	 * @return
+	 * @throws UnmarshalException 
 	 */
 
-	public static final EPR fromXMLString(String xml)
+	public static final EPR fromXMLString(String xml) throws UnmarshalException
 	{
 		return fromXMLString(xml, false);
 	}
@@ -257,12 +238,12 @@
 	 * 
 	 * @param xml
 	 * @return
+	 * @throws UnmarshalException 
 	 */
 
-	public static final EPR fromXMLString(String xml, boolean to)
+	public static final EPR fromXMLString(String xml, boolean to) throws UnmarshalException
 	{
-		if (xml == null)
-			throw new InvalidParameterException();
+		AssertArgument.isNotNull(xml, "xml");
 
 		try
 		{
@@ -275,105 +256,78 @@
 
 			return fromXML(rootElement, to);
 		}
-		catch (UnmarshalException ex)
-		{
-			ex.printStackTrace();
-			
-			return null;
-		}
 		catch (SAXException ex)
 		{
-			ex.printStackTrace();
-
-			return null;
+			throw new UnmarshalException("Unable to parse EPR XML.", ex);
 		}
 		catch (IOException ex)
 		{
-			ex.printStackTrace();
-
-			return null;
+			throw new UnmarshalException("Unable to read EPR XML stream.", ex);
 		}
 		catch (ParserConfigurationException ex)
 		{
-			ex.printStackTrace();
-
-			return null;
+			throw new UnmarshalException("Failed to construct DOM Document Builder.", ex);
 		}
 	}
 
 	private final static void setSpecificEPR(EPR epr)
 	{
-		try
-		{
-			String eprType = null;
+		String eprType = null;
 
-			/*
-			 * Do not re-order.
-			 */
+		/*
+		 * Do not re-order.
+		 */
 
-			if (epr instanceof EmailEpr)
-				eprType = EmailEpr.type().toString();
-			else if (epr instanceof SFTPEpr)
-				eprType = SFTPEpr.type().toString();
-			else if (epr instanceof HTTPEpr)
-				eprType = HTTPEpr.type().toString();
-			else if (epr instanceof JDBCEpr)
-				eprType = JDBCEpr.type().toString();
-			else if (epr instanceof JMSEpr)
-				eprType = JMSEpr.type().toString();
-			else if (epr instanceof FTPEpr)
-				eprType = FTPEpr.type().toString();
-			else if (epr instanceof FileEpr)
-				eprType = FileEpr.type().toString();
+		if (epr instanceof EmailEpr)
+			eprType = EmailEpr.type().toString();
+		else if (epr instanceof SFTPEpr)
+			eprType = SFTPEpr.type().toString();
+		else if (epr instanceof HTTPEpr)
+			eprType = HTTPEpr.type().toString();
+		else if (epr instanceof JDBCEpr)
+			eprType = JDBCEpr.type().toString();
+		else if (epr instanceof JMSEpr)
+			eprType = JMSEpr.type().toString();
+		else if (epr instanceof FTPEpr)
+			eprType = FTPEpr.type().toString();
+		else if (epr instanceof FileEpr)
+			eprType = FileEpr.type().toString();
 
-			if (eprType != null)
-			{
-				if (epr.getAddr().getExtensionValue(EPR_TYPE) == null)
-					epr.getAddr().addExtension(EPR_TYPE, eprType);
+		if (eprType != null)
+		{
+			if (epr.getAddr().getExtensionValue(EPR_TYPE) == null) {
+				epr.getAddr().addExtension(EPR_TYPE, eprType);
 			}
 		}
-		catch (Exception ex)
-		{
-			ex.printStackTrace();
-		}
 	}
 
 	private final static EPR getSpecificEPR(EPR epr)
 	{
-		try
+		String eprType = epr.getAddr().getExtensionValue(EPR_TYPE);
+
+		if (eprType != null)
 		{
-			String eprType = epr.getAddr().getExtensionValue(EPR_TYPE);
+			/*
+			 * Do not re-order.
+			 */
 
-			if (eprType != null)
-			{
-				/*
-				 * Do not re-order.
-				 */
-
-				if (eprType.equals(EmailEpr.type().toString()))
-					return new EmailEpr(epr);
-				else if (eprType.equals(SFTPEpr.type().toString()))
-					return new SFTPEpr(epr);
-				else if (eprType.equals(HTTPEpr.type().toString()))
-					return new HTTPEpr(epr);
-				else if (eprType.equals(JDBCEpr.type().toString()))
-					return new JDBCEpr(epr);
-				else if (eprType.equals(JMSEpr.type().toString()))
-					return new JMSEpr(epr);
-				else if (eprType.equals(FTPEpr.type().toString()))
-					return new FTPEpr(epr);
-				else if (eprType.equals(FileEpr.type().toString()))
-					return new FileEpr(epr);
-				else
-					return epr;
-			}
+			if (eprType.equals(EmailEpr.type().toString()))
+				return new EmailEpr(epr);
+			else if (eprType.equals(SFTPEpr.type().toString()))
+				return new SFTPEpr(epr);
+			else if (eprType.equals(HTTPEpr.type().toString()))
+				return new HTTPEpr(epr);
+			else if (eprType.equals(JDBCEpr.type().toString()))
+				return new JDBCEpr(epr);
+			else if (eprType.equals(JMSEpr.type().toString()))
+				return new JMSEpr(epr);
+			else if (eprType.equals(FTPEpr.type().toString()))
+				return new FTPEpr(epr);
+			else if (eprType.equals(FileEpr.type().toString()))
+				return new FileEpr(epr);
 			else
 				return epr;
-		}
-		catch (Exception ex)
-		{
-			ex.printStackTrace();
-
+		} else {
 			return epr;
 		}
 	}
@@ -390,48 +344,39 @@
 
 	private final static EPR getSpecificEPR(EPR epr, Element header)
 	{
-		try
+		NodeList children = header.getChildNodes();
+		String eprType = null;
+
+		for (int i = 0; i < children.getLength(); i++)
 		{
-			NodeList children = header.getChildNodes();
-			String eprType = null;
+			if (children.item(i).getNodeName().equals(
+					XMLUtil.JBOSSESB_PREFIX + ":" + EPR_TYPE))
+				eprType = children.item(i).getTextContent();
+		}
 
-			for (int i = 0; i < children.getLength(); i++)
-			{
-				if (children.item(i).getNodeName().equals(
-						XMLUtil.JBOSSESB_PREFIX + ":" + EPR_TYPE))
-					eprType = children.item(i).getTextContent();
-			}
+		if (eprType != null)
+		{
+			/*
+			 * Do not re-order.
+			 */
 
-			if (eprType != null)
-			{
-				/*
-				 * Do not re-order.
-				 */
-
-				if (eprType.equals(EmailEpr.type().toString()))
-					return new EmailEpr(epr, header);
-				else if (eprType.equals(SFTPEpr.type().toString()))
-					return new SFTPEpr(epr, header);
-				else if (eprType.equals(HTTPEpr.type().toString()))
-					return new HTTPEpr(epr, header);
-				else if (eprType.equals(JDBCEpr.type().toString()))
-					return new JDBCEpr(epr, header);
-				else if (eprType.equals(JMSEpr.type().toString()))
-					return new JMSEpr(epr, header);
-				else if (eprType.equals(FTPEpr.type().toString()))
-					return new FTPEpr(epr, header);
-				else if (eprType.equals(FileEpr.type().toString()))
-					return new FileEpr(epr, header);
-				else
-					return epr;
-			}
+			if (eprType.equals(EmailEpr.type().toString()))
+				return new EmailEpr(epr, header);
+			else if (eprType.equals(SFTPEpr.type().toString()))
+				return new SFTPEpr(epr, header);
+			else if (eprType.equals(HTTPEpr.type().toString()))
+				return new HTTPEpr(epr, header);
+			else if (eprType.equals(JDBCEpr.type().toString()))
+				return new JDBCEpr(epr, header);
+			else if (eprType.equals(JMSEpr.type().toString()))
+				return new JMSEpr(epr, header);
+			else if (eprType.equals(FTPEpr.type().toString()))
+				return new FTPEpr(epr, header);
+			else if (eprType.equals(FileEpr.type().toString()))
+				return new FileEpr(epr, header);
 			else
 				return epr;
-		}
-		catch (Exception ex)
-		{
-			ex.printStackTrace();
-
+		} else {
 			return epr;
 		}
 	}

Added: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/assertion/AssertArgument.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/assertion/AssertArgument.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/assertion/AssertArgument.java	2007-01-19 12:32:19 UTC (rev 8918)
@@ -0,0 +1,70 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated 
+ * by the @authors tag. All rights reserved. 
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors. 
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A 
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+ * MA  02110-1301, USA.
+ * 
+ * (C) 2005-2006
+ */
+
+package org.jboss.internal.soa.esb.assertion;
+
+/**
+ * Argument assertion utilities.
+ * <p/>
+ * <b>Copied from <a href="http://www.milyn.org">milyn.org</a></b>.
+ *  
+ * @author tfennelly
+ */
+public abstract class AssertArgument {
+
+	/**
+	 * Assert that the argument is not null.
+	 * @param arg Argument.
+	 * @param argName Argument name.
+	 * @throws IllegalArgumentException Argument is null.
+	 */
+	public static void isNotNull(Object arg, String argName) throws IllegalArgumentException {
+		if (arg == null) {
+			throw new IllegalArgumentException("null '" + argName
+					+ "' arg in method call.");
+		}
+	}
+
+	/**
+	 * Assert that the argument is not empty.
+	 * @param arg Argument.
+	 * @param argName Argument name.
+	 * @throws IllegalArgumentException Argument is not null, but is empty.
+	 */
+	public static void isNotEmpty(String arg, String argName) throws IllegalArgumentException {
+		if (arg != null && arg.trim().equals("")) {
+			throw new IllegalArgumentException("Not null, but empty '"
+					+ argName + "' arg in method call.");
+		}
+	}
+
+	/**
+	 * Assert that the argument is neither null nor empty.
+	 * @param arg Argument.
+	 * @param argName Argument name.
+	 * @throws IllegalArgumentException Argument is null or empty.
+	 */
+	public static void isNotNullAndNotEmpty(String arg, String argName) throws IllegalArgumentException {
+		if (arg == null || arg.trim().equals("")) {
+			throw new IllegalArgumentException("null or empty '" + argName
+					+ "' arg in method call.");
+		}
+	}
+}

Modified: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/FileCourier.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/FileCourier.java	2007-01-19 10:45:30 UTC (rev 8917)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/FileCourier.java	2007-01-19 12:32:19 UTC (rev 8918)
@@ -221,10 +221,6 @@
 			{
 				throw new CourierException(e);
 			}
-			catch (URISyntaxException e)
-			{
-				throw new MalformedEPRException(e);
-			}
 		}
 
 		try

Modified: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/TwoWayCourierImpl.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/TwoWayCourierImpl.java	2007-01-19 10:45:30 UTC (rev 8917)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/TwoWayCourierImpl.java	2007-01-19 12:32:19 UTC (rev 8918)
@@ -127,22 +127,17 @@
 			throws CourierException, MalformedEPRException
 	{
 		String addr = null;
-		try
-		{
-			addr = epr.getAddr().getAddress();
-			if (addr.startsWith(JMSEpr.JMS_PROTOCOL))
-				return new JmsCourier(new JMSEpr(epr), pickUpOnly);
-			if (addr.startsWith(JDBCEpr.JDBC_PROTOCOL))
-				return new SqlTableCourier(new JDBCEpr(epr), pickUpOnly);
-			// TODO magic strings
-			if (addr.startsWith("file://") || addr.startsWith("ftp://")
-					|| addr.startsWith("sftp://") || addr.startsWith("ftps://"))
-				return new FileCourier(new FileEpr(epr), pickUpOnly);
-		}
-		catch (URISyntaxException e)
-		{ /* OK just fall through */
-			_logger.error(e);
-		}
+
+		addr = epr.getAddr().getAddress();
+		if (addr.startsWith(JMSEpr.JMS_PROTOCOL))
+			return new JmsCourier(new JMSEpr(epr), pickUpOnly);
+		if (addr.startsWith(JDBCEpr.JDBC_PROTOCOL))
+			return new SqlTableCourier(new JDBCEpr(epr), pickUpOnly);
+		// TODO magic strings
+		if (addr.startsWith("file://") || addr.startsWith("ftp://")
+				|| addr.startsWith("sftp://") || addr.startsWith("ftps://"))
+			return new FileCourier(new FileEpr(epr), pickUpOnly);
+
 		throw new CourierException("Courier for "
 				+ epr.getClass().getSimpleName() + " not supported yet");
 	}

Modified: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/MarshalException.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/MarshalException.java	2007-01-19 10:45:30 UTC (rev 8917)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/MarshalException.java	2007-01-19 12:32:19 UTC (rev 8918)
@@ -28,7 +28,7 @@
 
 public class MarshalException extends Exception
 {
-	public static final long serialVersionUID = 0xE;
+	private static final long serialVersionUID = 0xE;
 	
 	public MarshalException()
 	{
@@ -44,5 +44,10 @@
 	{
 		super(ex);
 	}
+
+	public MarshalException (String message, Exception ex)
+	{
+		super(message, ex);
+	}
 	
 }

Modified: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/UnmarshalException.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/UnmarshalException.java	2007-01-19 10:45:30 UTC (rev 8917)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/UnmarshalException.java	2007-01-19 12:32:19 UTC (rev 8918)
@@ -28,7 +28,7 @@
 
 public class UnmarshalException extends Exception
 {
-	public static final long serialVersionUID = 0xE;
+	private static final long serialVersionUID = 0xE;
 	
 	public UnmarshalException()
 	{
@@ -44,4 +44,9 @@
 	{
 		super(ex);
 	}
+
+	public UnmarshalException (String message, Exception ex)
+	{
+		super(ex);
+	}
 }

Modified: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/addressing/Call.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/addressing/Call.java	2007-01-19 10:45:30 UTC (rev 8917)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/addressing/Call.java	2007-01-19 12:32:19 UTC (rev 8918)
@@ -85,10 +85,9 @@
 	
 	/**
 	 * @return the To field.
-	 * @throws URISyntaxException thrown if the address is invalid.
 	 */
 	
-	public EPR getTo () throws URISyntaxException
+	public EPR getTo ()
 	{
 		return _to;
 	}
@@ -109,7 +108,7 @@
 	 * @throws URISyntaxException thrown if the address is invalid.
 	 */
 	
-	public EPR getFrom () throws URISyntaxException
+	public EPR getFrom ()
 	{
 		return _from;
 	}
@@ -130,7 +129,7 @@
 	 * @throws URISyntaxException thrown if the address is invalid.
 	 */
 	
-	public EPR getReplyTo () throws URISyntaxException
+	public EPR getReplyTo ()
 	{
 		return _replyTo;
 	}
@@ -148,10 +147,9 @@
 	
 	/**
 	 * @return the FaultTo field.
-	 * @throws URISyntaxException thrown if the address is invalid.
 	 */
 	
-	public EPR getFaultTo () throws URISyntaxException
+	public EPR getFaultTo ()
 	{
 		return _faultTo;
 	}
@@ -169,10 +167,9 @@
 	
 	/**
 	 * @return the RelatesTo field.
-	 * @throws URISyntaxException thrown if the field is invalid.
 	 */
 	
-	public URI getRelatesTo () throws URISyntaxException
+	public URI getRelatesTo ()
 	{
 		return _relatesTo;
 	}
@@ -189,10 +186,8 @@
 
 	/**
 	 * @return the Action field.
-	 * @throws URISyntaxException thrown if the field is invalid.
 	 */
-	
-	public URI getAction () throws URISyntaxException
+	public URI getAction ()
 	{
 		return _action;
 	}
@@ -210,10 +205,9 @@
 	
 	/**
 	 * @return the MessageID field.
-	 * @throws URISyntaxException thrown if the value is invalid.
 	 */
 	
-	public URI getMessageID () throws URISyntaxException
+	public URI getMessageID ()
 	{
 		return _messageID;
 	}

Modified: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/addressing/EPR.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/addressing/EPR.java	2007-01-19 10:45:30 UTC (rev 8917)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/addressing/EPR.java	2007-01-19 12:32:19 UTC (rev 8918)
@@ -87,10 +87,9 @@
 	 * Get the EPR address.
 	 * 
 	 * @return the address.
-	 * @throws URISyntaxException thrown if the address is invalid.
 	 */
 	
-	public PortReference getAddr () throws URISyntaxException
+	public PortReference getAddr ()
 	{
 		return _addr;
 	}

Modified: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/addressing/eprs/JMSEpr.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/addressing/eprs/JMSEpr.java	2007-01-19 10:45:30 UTC (rev 8917)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/addressing/eprs/JMSEpr.java	2007-01-19 12:32:19 UTC (rev 8918)
@@ -88,47 +88,40 @@
 		{
 			String nodeName = nl.item(i).getNodeName();
 			
-			try
+			if (nodeName.equals(XMLUtil.JBOSSESB_PREFIX+":"+SPECIFICATION_VERSION_TAG))
 			{
-				if (nodeName.equals(XMLUtil.JBOSSESB_PREFIX+":"+SPECIFICATION_VERSION_TAG))
-				{
-					getAddr().addExtension(SPECIFICATION_VERSION_TAG, nl.item(i).getTextContent());
-				}
-				else
-				if (nodeName.equals(XMLUtil.JBOSSESB_PREFIX+":"+DESTINATION_NAME_TAG))
-				{
-					getAddr().addExtension(DESTINATION_NAME_TAG, nl.item(i).getTextContent());
-				}
-				else
-				if (nodeName.equals(XMLUtil.JBOSSESB_PREFIX+":"+CONNECTION_FACTORY_TAG))
-				{
-					getAddr().addExtension(CONNECTION_FACTORY_TAG, nl.item(i).getTextContent());
-				}
-				else
-				if (nodeName.equals(XMLUtil.JBOSSESB_PREFIX+":"+JNDI_CONTEXT_FACTORY_TAG))
-				{
-					getAddr().addExtension(JNDI_CONTEXT_FACTORY_TAG, nl.item(i).getTextContent());
-				}
-				else
-				if (nodeName.equals(XMLUtil.JBOSSESB_PREFIX+":"+JNDI_PKG_PREFIX_TAG))
-				{
-					getAddr().addExtension(JNDI_PKG_PREFIX_TAG, nl.item(i).getTextContent());
-				}
-				else
-				if (nodeName.equals(XMLUtil.JBOSSESB_PREFIX+":"+JNDI_URL_TAG))
-				{
-					getAddr().addExtension(JNDI_URL_TAG, nl.item(i).getTextContent());
-				}
-				else
-				if (nodeName.equals(XMLUtil.JBOSSESB_PREFIX+":"+MESSAGE_SELECTOR_TAG))
-				{
-					getAddr().addExtension(MESSAGE_SELECTOR_TAG, nl.item(i).getTextContent());
-				}
+				getAddr().addExtension(SPECIFICATION_VERSION_TAG, nl.item(i).getTextContent());
 			}
-			catch (URISyntaxException ex)
+			else
+			if (nodeName.equals(XMLUtil.JBOSSESB_PREFIX+":"+DESTINATION_NAME_TAG))
 			{
-				ex.printStackTrace();
+				getAddr().addExtension(DESTINATION_NAME_TAG, nl.item(i).getTextContent());
 			}
+			else
+			if (nodeName.equals(XMLUtil.JBOSSESB_PREFIX+":"+CONNECTION_FACTORY_TAG))
+			{
+				getAddr().addExtension(CONNECTION_FACTORY_TAG, nl.item(i).getTextContent());
+			}
+			else
+			if (nodeName.equals(XMLUtil.JBOSSESB_PREFIX+":"+JNDI_CONTEXT_FACTORY_TAG))
+			{
+				getAddr().addExtension(JNDI_CONTEXT_FACTORY_TAG, nl.item(i).getTextContent());
+			}
+			else
+			if (nodeName.equals(XMLUtil.JBOSSESB_PREFIX+":"+JNDI_PKG_PREFIX_TAG))
+			{
+				getAddr().addExtension(JNDI_PKG_PREFIX_TAG, nl.item(i).getTextContent());
+			}
+			else
+			if (nodeName.equals(XMLUtil.JBOSSESB_PREFIX+":"+JNDI_URL_TAG))
+			{
+				getAddr().addExtension(JNDI_URL_TAG, nl.item(i).getTextContent());
+			}
+			else
+			if (nodeName.equals(XMLUtil.JBOSSESB_PREFIX+":"+MESSAGE_SELECTOR_TAG))
+			{
+				getAddr().addExtension(MESSAGE_SELECTOR_TAG, nl.item(i).getTextContent());
+			}
 		}
 	}
 

Modified: labs/jbossesb/trunk/product/core/rosetta/tests/src/org/jboss/soa/esb/addressing/util/tests/EPRHelperUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/tests/src/org/jboss/soa/esb/addressing/util/tests/EPRHelperUnitTest.java	2007-01-19 10:45:30 UTC (rev 8917)
+++ labs/jbossesb/trunk/product/core/rosetta/tests/src/org/jboss/soa/esb/addressing/util/tests/EPRHelperUnitTest.java	2007-01-19 12:32:19 UTC (rev 8918)
@@ -25,6 +25,8 @@
 import junit.framework.TestCase;
 
 import org.jboss.internal.soa.esb.addressing.helpers.EPRHelper;
+import org.jboss.soa.esb.MarshalException;
+import org.jboss.soa.esb.UnmarshalException;
 import org.jboss.soa.esb.addressing.EPR;
 import org.jboss.soa.esb.addressing.eprs.EmailEpr;
 
@@ -37,7 +39,7 @@
 public class EPRHelperUnitTest extends TestCase
 {
 	
-	public void testToFromXMLString ()
+	public void testToFromXMLString () throws MarshalException, UnmarshalException
 	{
 		EmailEpr email = new EmailEpr(EmailEpr.SMTP_PROTOCOL, "foobar", "25", "me", "letmein");
 		




More information about the jboss-svn-commits mailing list