Remove most of the java compilation warning (generics markup, unused code/import) (OFBIZ-4102)

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1057343 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Marco Risaliti
2011-01-10 20:14:36 +00:00
parent aa349357f3
commit ceafd4dae2
2 changed files with 22 additions and 20 deletions
@@ -20,21 +20,23 @@ package org.ofbiz.content.layout;
import java.io.File;
import java.nio.ByteBuffer;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javolution.util.FastMap;
import org.ofbiz.base.util.UtilHttp;
import org.ofbiz.base.util.UtilMisc;
import org.ofbiz.base.util.UtilProperties;
import org.ofbiz.service.ServiceUtil;
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.UtilGenerics;
import org.ofbiz.base.util.UtilHttp;
import org.ofbiz.base.util.UtilMisc;
import org.ofbiz.base.util.UtilProperties;
import org.ofbiz.service.ServiceUtil;
/**
* LayoutWorker Class
@@ -49,18 +51,18 @@ public class LayoutWorker {
* Expects key data in a field identitified by the "idField" value
* and the binary data to be in a field id'd by uploadField.
*/
public static Map uploadImageAndParameters(HttpServletRequest request, String uploadField) {
public static Map<String, Object> uploadImageAndParameters(HttpServletRequest request, String uploadField) {
//Debug.logVerbose("in uploadAndStoreImage", "");
Locale locale = UtilHttp.getLocale(request);
Map results = FastMap.newInstance();
Map formInput = FastMap.newInstance();
Map<String, Object> results = FastMap.newInstance();
Map<String, String> formInput = FastMap.newInstance();
results.put("formInput", formInput);
ServletFileUpload fu = new ServletFileUpload(new DiskFileItemFactory(10240, new File(new File("runtime"), "tmp")));
java.util.List lst = null;
List<FileItem> lst = null;
try {
lst = fu.parseRequest(request);
lst = UtilGenerics.checkList(fu.parseRequest(request));
} catch (FileUploadException e4) {
return ServiceUtil.returnError(e4.getMessage());
}
@@ -78,7 +80,6 @@ public class LayoutWorker {
FileItem imageFi = null;
for (int i=0; i < lst.size(); i++) {
fi = (FileItem)lst.get(i);
String fn = fi.getName();
String fieldName = fi.getFieldName();
String fieldStr = fi.getString();
if (fi.isFormField()) {
@@ -93,8 +94,8 @@ public class LayoutWorker {
}
if (imageFi == null) {
Map messageMap = UtilMisc.toMap("imageFi", imageFi);
String errMsg = UtilProperties.getMessage(LayoutWorker.err_resource, "layoutEvents.image_null", messageMap, locale);
String errMsg = UtilProperties.getMessage(LayoutWorker.err_resource,
"layoutEvents.image_null", UtilMisc.toMap("imageFi", imageFi), locale);
request.setAttribute("_ERROR_MESSAGE_", errMsg);
//Debug.logWarning("[DataEvents.uploadImage] imageFi(" + imageFi + ") is null", module);
return null;
@@ -109,7 +110,7 @@ public class LayoutWorker {
return results;
}
public static ByteBuffer returnByteBuffer(Map map) {
public static ByteBuffer returnByteBuffer(Map<String, ByteBuffer> map) {
ByteBuffer byteBuff = (ByteBuffer)map.get("imageData");
return byteBuff;
}
@@ -46,6 +46,7 @@ import javolution.util.FastMap;
import org.jdom.JDOMException;
import org.ofbiz.base.util.Debug;
import org.ofbiz.base.util.UtilDateTime;
import org.ofbiz.base.util.UtilGenerics;
import org.ofbiz.base.util.UtilMisc;
import org.ofbiz.base.util.UtilProperties;
import org.ofbiz.base.util.UtilValidate;
@@ -79,12 +80,12 @@ public class FrameImage {
Locale locale = (Locale) context.get("locale");
if (UtilValidate.isEmpty(context.get("frameContentId")) || UtilValidate.isEmpty(context.get("frameDataResourceId"))) {
result = ServiceUtil.returnError(UtilProperties.getMessage(resource,
result = ServiceUtil.returnError(UtilProperties.getMessage(resource,
"ProductImageFrameContentIdRequired", locale));
result.putAll(context);
}
if (UtilValidate.isEmpty(context.get("imageWidth")) || UtilValidate.isEmpty(context.get("imageHeight"))) {
result = ServiceUtil.returnError(UtilProperties.getMessage(resource,
result = ServiceUtil.returnError(UtilProperties.getMessage(resource,
"ProductImageWidthAndHeightRequired", locale));
result.putAll(context);
}
@@ -98,7 +99,7 @@ public class FrameImage {
frameImageName = contentDataResourceView.getString("contentName");
} catch (Exception e) {
Debug.logError(e, module);
result = ServiceUtil.returnError(e.getMessage());
result = ServiceUtil.returnError(e.getMessage());
result.putAll(context);
}
@@ -246,7 +247,7 @@ public class FrameImage {
HttpSession session = request.getSession();
GenericValue userLogin = (GenericValue)session.getAttribute("userLogin");
Map<String, ? extends Object> context = request.getParameterMap();
Map<String, ? extends Object> context = UtilGenerics.checkMap(request.getParameterMap());
String imageServerPath = FlexibleStringExpander.expandString(UtilProperties.getPropertyValue("catalog", "image.server.path"), context);
Map<String, Object> tempFile = LayoutWorker.uploadImageAndParameters(request, "uploadedFile");
String imageName = tempFile.get("imageFileName").toString();
@@ -317,7 +318,7 @@ public class FrameImage {
}
public static String previewFrameImage(HttpServletRequest request, HttpServletResponse response) throws IOException, JDOMException {
Delegator delegator = (Delegator) request.getAttribute("delegator");
Map<String, ? extends Object> context = request.getParameterMap();
Map<String, ? extends Object> context = UtilGenerics.checkMap(request.getParameterMap());
HttpSession session = request.getSession();
String imageServerPath = FlexibleStringExpander.expandString(UtilProperties.getPropertyValue("catalog", "image.server.path"), context);
@@ -406,7 +407,7 @@ public class FrameImage {
return "success";
}
public static String deleteFrameImage(HttpServletRequest request, HttpServletResponse response) {
Map<String, ? extends Object> context = request.getParameterMap();
Map<String, ? extends Object> context = UtilGenerics.checkMap(request.getParameterMap());
String imageServerPath = FlexibleStringExpander.expandString(UtilProperties.getPropertyValue("catalog", "image.server.path"), context);
File file = new File(imageServerPath + "/products/management/previewImage.jpg");
if (file.exists()) {