Author: jacopoc
Date: Thu May 31 23:45:10 2007 New Revision: 543404 URL: http://svn.apache.org/viewvc?view=rev&rev=543404 Log: Fixed warnings after upgrade of common* jars related to a deprecated class used to manage file upload. Added a new folder (runtime/tmp) to store temporary files during upload and added new properties to configure the file upload to the general.properties file. Issue OFBIZ-942. Added: ofbiz/trunk/runtime/tmp/ Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/content/UploadContentAndImage.java ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java ofbiz/trunk/applications/content/src/org/ofbiz/content/layout/LayoutWorker.java ofbiz/trunk/framework/common/config/general.properties ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ServiceEventHandler.java Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/content/UploadContentAndImage.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/content/UploadContentAndImage.java?view=diff&rev=543404&r1=543403&r2=543404 ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/content/UploadContentAndImage.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/content/UploadContentAndImage.java Thu May 31 23:45:10 2007 @@ -18,6 +18,7 @@ *******************************************************************************/ package org.ofbiz.content.content; +import java.io.File; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; @@ -50,9 +51,10 @@ import org.ofbiz.service.ServiceAuthException; import org.ofbiz.service.ServiceUtil; -import org.apache.commons.fileupload.DiskFileUpload; import org.apache.commons.fileupload.FileItem; import org.apache.commons.fileupload.FileUploadException; +import org.apache.commons.fileupload.disk.DiskFileItemFactory; +import org.apache.commons.fileupload.servlet.ServletFileUpload; /** @@ -78,8 +80,7 @@ HttpSession session = request.getSession(); GenericValue userLogin = (GenericValue)session.getAttribute("userLogin"); - DiskFileUpload dfu = new DiskFileUpload(); - //if (Debug.infoOn()) Debug.logInfo("[UploadContentAndImage]DiskFileUpload " + dfu, module); + ServletFileUpload dfu = new ServletFileUpload(new DiskFileItemFactory(10240, new File("runtime/tmp"))); java.util.List lst = null; try { lst = dfu.parseRequest(request); @@ -343,7 +344,7 @@ HttpSession session = request.getSession(); GenericValue userLogin = (GenericValue)session.getAttribute("userLogin"); - DiskFileUpload dfu = new DiskFileUpload(); + ServletFileUpload dfu = new ServletFileUpload(new DiskFileItemFactory(10240, new File("runtime/tmp"))); //if (Debug.infoOn()) Debug.logInfo("[UploadContentAndImage]DiskFileUpload " + dfu, module); java.util.List lst = null; try { Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java?view=diff&rev=543404&r1=543403&r2=543404 ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java Thu May 31 23:45:10 2007 @@ -33,9 +33,10 @@ import javax.servlet.http.HttpSession; import javax.xml.parsers.ParserConfigurationException; -import org.apache.commons.fileupload.DiskFileUpload; import org.apache.commons.fileupload.FileItem; import org.apache.commons.fileupload.FileUploadException; +import org.apache.commons.fileupload.disk.DiskFileItemFactory; +import org.apache.commons.fileupload.servlet.ServletFileUpload; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.GeneralException; import org.ofbiz.base.util.UtilHttp; @@ -176,7 +177,7 @@ //GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator"); //String idFieldValue = null; - DiskFileUpload fu = new DiskFileUpload(); + ServletFileUpload fu = new ServletFileUpload(new DiskFileItemFactory(10240, new File("runtime/tmp"))); List lst = null; Locale locale = UtilHttp.getLocale(request); Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/layout/LayoutWorker.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/layout/LayoutWorker.java?view=diff&rev=543404&r1=543403&r2=543404 ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/layout/LayoutWorker.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/layout/LayoutWorker.java Thu May 31 23:45:10 2007 @@ -18,6 +18,7 @@ *******************************************************************************/ package org.ofbiz.content.layout; +import java.io.File; import java.util.HashMap; import java.util.Locale; import java.util.Map; @@ -29,9 +30,10 @@ import org.ofbiz.entity.util.ByteWrapper; import org.ofbiz.service.ServiceUtil; -import org.apache.commons.fileupload.DiskFileUpload; import org.apache.commons.fileupload.FileItem; import org.apache.commons.fileupload.FileUploadException; +import org.apache.commons.fileupload.disk.DiskFileItemFactory; +import org.apache.commons.fileupload.servlet.ServletFileUpload; /** * LayoutWorker Class @@ -54,7 +56,7 @@ HashMap results = new HashMap(); HashMap formInput = new HashMap(); results.put("formInput", formInput); - DiskFileUpload fu = new DiskFileUpload(); + ServletFileUpload fu = new ServletFileUpload(new DiskFileItemFactory(10240, new File("runtime/tmp"))); java.util.List lst = null; try { lst = fu.parseRequest(request); Modified: ofbiz/trunk/framework/common/config/general.properties URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/config/general.properties?view=diff&rev=543404&r1=543403&r2=543404 ============================================================================== --- ofbiz/trunk/framework/common/config/general.properties (original) +++ ofbiz/trunk/framework/common/config/general.properties Thu May 31 23:45:10 2007 @@ -54,7 +54,12 @@ # -- debug SMTP mail option enabled (Y|N) mail.debug.on=N -# -- HTTP upload max size in bytes (-1 for unlimited) +# -- HTTP upload settings +# -- directory used to temporarily store files that are larger than the configured size threshold (10K) +http.upload.max.sizethreshold=10240 +# -- directory used to temporarily store files that are larger than the configured size threshold +http.upload.tmprepository=runtime/tmp +# -- max size in bytes (-1 for unlimited) http.upload.max.size=-1 # -- spam header name and value to block incoming spam detected by external spam checker, configured for spam assin Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ServiceEventHandler.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ServiceEventHandler.java?view=diff&rev=543404&r1=543403&r2=543404 ============================================================================== --- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ServiceEventHandler.java (original) +++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ServiceEventHandler.java Thu May 31 23:45:10 2007 @@ -18,6 +18,7 @@ *******************************************************************************/ package org.ofbiz.webapp.event; +import java.io.File; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -31,10 +32,11 @@ import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; -import org.apache.commons.fileupload.DiskFileUpload; import org.apache.commons.fileupload.FileItem; import org.apache.commons.fileupload.FileUpload; import org.apache.commons.fileupload.FileUploadException; +import org.apache.commons.fileupload.disk.DiskFileItemFactory; +import org.apache.commons.fileupload.servlet.ServletFileUpload; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilHttp; @@ -127,12 +129,24 @@ Debug.logError(e, "Unable to obtain the max upload size from general.properties; using default -1", module); maxUploadSize = -1; } + // get the http size threshold configuration - files bigger than this will be + // temporarly stored on disk during upload + String sizeThresholdStr = UtilProperties.getPropertyValue("general.properties", "http.upload.max.sizethreshold", "10240"); + int sizeThreshold = 10240; // 10K + try { + sizeThreshold = Integer.parseInt(sizeThresholdStr); + } catch (NumberFormatException e) { + Debug.logError(e, "Unable to obtain the threshold size from general.properties; using default 10K", module); + sizeThreshold = -1; + } + // directory used to temporarily store files that are larger than the configured size threshold + String tmpUploadRepository = UtilProperties.getPropertyValue("general.properties", "http.upload.tmprepository", "runtime/tmp"); // check for multipart content types which may have uploaded items - boolean isMultiPart = FileUpload.isMultipartContent(request); + boolean isMultiPart = ServletFileUpload.isMultipartContent(request); Map multiPartMap = new HashMap(); if (isMultiPart) { - DiskFileUpload upload = new DiskFileUpload(); + ServletFileUpload upload = new ServletFileUpload(new DiskFileItemFactory(sizeThreshold, new File(tmpUploadRepository))); upload.setSizeMax(maxUploadSize); List uploadedItems = null; |
Free forum by Nabble | Edit this page |