You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by le...@apache.org on 2009/05/01 08:08:20 UTC

svn commit: r770544 - /ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/usps/UspsServices.java

Author: lektran
Date: Fri May  1 06:08:19 2009
New Revision: 770544

URL: http://svn.apache.org/viewvc?rev=770544&view=rev
Log:
Fix an index out of bounds exception I stumbled across

Modified:
    ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/usps/UspsServices.java

Modified: ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/usps/UspsServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/usps/UspsServices.java?rev=770544&r1=770543&r2=770544&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/usps/UspsServices.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/usps/UspsServices.java Fri May  1 06:08:19 2009
@@ -37,6 +37,7 @@
 import javolution.util.FastList;
 import javolution.util.FastMap;
 
+import org.apache.commons.lang.StringUtils;
 import org.apache.xml.serialize.OutputFormat;
 import org.apache.xml.serialize.XMLSerializer;
 import org.ofbiz.base.util.Base64;
@@ -168,8 +169,8 @@
             packageElement.setAttribute("ID", String.valueOf(li.nextIndex() - 1)); // use zero-based index (see examples)
 
             UtilXml.addChildElementValue(packageElement, "Service", serviceCode, requestDocument);
-            UtilXml.addChildElementValue(packageElement, "ZipOrigination", originationZip.substring(0,5), requestDocument);
-            UtilXml.addChildElementValue(packageElement, "ZipDestination", destinationZip.substring(0,5), requestDocument);
+            UtilXml.addChildElementValue(packageElement, "ZipOrigination", StringUtils.substring(originationZip, 0, 5), requestDocument);
+            UtilXml.addChildElementValue(packageElement, "ZipDestination", StringUtils.substring(destinationZip, 0, 5), requestDocument);
 
             BigDecimal weightPounds = packageWeight.setScale(0, BigDecimal.ROUND_FLOOR);
             // for Parcel post, the weight must be at least 1 lb