Author: hansbak Date: Tue May 14 02:53:33 2013 New Revision: 1482177 URL: http://svn.apache.org/r1482177 Log: add an optional timeout parameter to the ftp service
Modified: ofbiz/trunk/framework/common/servicedef/services.xml ofbiz/trunk/framework/common/src/org/ofbiz/common/FtpServices.java Modified: ofbiz/trunk/framework/common/servicedef/services.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/servicedef/services.xml?rev=1482177&r1=1482176&r2=1482177&view=diff ============================================================================== --- ofbiz/trunk/framework/common/servicedef/services.xml (original) +++ ofbiz/trunk/framework/common/servicedef/services.xml Tue May 14 02:53:33 2013 @@ -354,6 +354,7 @@ under the License. <attribute name="remoteFilename" type="String" mode="IN" optional="false"/> <attribute name="binaryTransfer" type="Boolean" mode="IN" optional="true"/> <attribute name="passiveMode" type="Boolean" mode="IN" optional="true"/> + <attribute name="defaultTimeout" type="Integer" mode="IN" optional="true"/> </service> <service name="ftpPutFile" engine="java" use-transaction="false" location="org.ofbiz.common.FtpServices" invoke="putFile"> Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/FtpServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/FtpServices.java?rev=1482177&r1=1482176&r2=1482177&view=diff ============================================================================== --- ofbiz/trunk/framework/common/src/org/ofbiz/common/FtpServices.java (original) +++ ofbiz/trunk/framework/common/src/org/ofbiz/common/FtpServices.java Tue May 14 02:53:33 2013 @@ -37,6 +37,7 @@ import org.apache.commons.net.ftp.FTPRep import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.UtilProperties; +import org.ofbiz.base.util.UtilValidate; import org.ofbiz.service.DispatchContext; import org.ofbiz.service.ServiceUtil; @@ -62,6 +63,11 @@ public class FtpServices { List<String> errorList = FastList.newInstance(); FTPClient ftp = new FTPClient(); try { + Integer defaultTimeout = (Integer) context.get("defaultTimeout"); + if (UtilValidate.isNotEmpty(defaultTimeout)) { + Debug.logInfo("[putFile] set default timeout to: " + defaultTimeout.intValue() + " milliseconds", module); + ftp.setDefaultTimeout(defaultTimeout.intValue()); + } Debug.logInfo("[putFile] connecting to: " + (String) context.get("hostname"), module); ftp.connect((String) context.get("hostname")); if (!FTPReply.isPositiveCompletion(ftp.getReplyCode())) { @@ -142,6 +148,11 @@ public class FtpServices { List<String> errorList = FastList.newInstance(); FTPClient ftp = new FTPClient(); try { + Integer defaultTimeout = (Integer) context.get("defaultTimeout"); + if (UtilValidate.isNotEmpty(defaultTimeout)) { + Debug.logInfo("[getFile] Set default timeout to: " + defaultTimeout.intValue() + " milliseconds", module); + ftp.setDefaultTimeout(defaultTimeout.intValue()); + } ftp.connect((String) context.get("hostname")); if (!FTPReply.isPositiveCompletion(ftp.getReplyCode())) { errorList.add(UtilProperties.getMessage(resource, "CommonFtpConnectionRefused", locale));