From 4067ee4e87d9d4ba097e84aba72ced12735bf70b Mon Sep 17 00:00:00 2001 From: Marco Risaliti Date: Thu, 20 Jan 2011 19:55:35 +0000 Subject: [PATCH] Remove java compilation warnings from OutputServices (OFBIZ-4102) git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1061483 13f79535-47bb-0310-9956-ffa450edef68 --- .../ofbiz/content/output/OutputServices.java | 43 +++++++------------ 1 file changed, 16 insertions(+), 27 deletions(-) diff --git a/applications/content/src/org/ofbiz/content/output/OutputServices.java b/applications/content/src/org/ofbiz/content/output/OutputServices.java index eba2d0b37c..49d5d0d214 100644 --- a/applications/content/src/org/ofbiz/content/output/OutputServices.java +++ b/applications/content/src/org/ofbiz/content/output/OutputServices.java @@ -47,8 +47,13 @@ import javax.print.attribute.PrintServiceAttributeSet; import javax.print.attribute.standard.PrinterName; import javax.xml.transform.stream.StreamSource; +import javolution.util.FastMap; + +import org.apache.fop.apps.Fop; +import org.apache.fop.apps.MimeConstants; 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; @@ -60,10 +65,6 @@ import org.ofbiz.widget.fo.FoFormRenderer; import org.ofbiz.widget.fo.FoScreenRenderer; import org.ofbiz.widget.screen.ScreenRenderer; -import javolution.util.FastMap; -import org.apache.fop.apps.Fop; -import org.apache.fop.apps.MimeConstants; - /** * Output Services @@ -77,10 +78,9 @@ public class OutputServices { public static final String resource = "ContentUiLabels"; public static Map sendPrintFromScreen(DispatchContext dctx, Map serviceContext) { - Locale locale = (Locale) serviceContext.get("locale"); String screenLocation = (String) serviceContext.remove("screenLocation"); - Map screenContext = (Map) serviceContext.remove("screenContext"); + Map screenContext = UtilGenerics.checkMap(serviceContext.remove("screenContext")); String contentType = (String) serviceContext.remove("contentType"); String printerContentType = (String) serviceContext.remove("printerContentType"); @@ -97,7 +97,7 @@ public class OutputServices { try { - MapStack screenContextTmp = MapStack.create(); + MapStack screenContextTmp = MapStack.create(); screenContextTmp.put("locale", locale); Writer writer = new StringWriter(); @@ -125,7 +125,7 @@ public class OutputServices { InputStream bais = new ByteArrayInputStream(baos.toByteArray()); DocAttributeSet docAttributeSet = new HashDocAttributeSet(); - List docAttributes = (List) serviceContext.remove("docAttributes"); + List docAttributes = UtilGenerics.checkList(serviceContext.remove("docAttributes")); if (UtilValidate.isNotEmpty(docAttributes)) { for (Object da : docAttributes) { Debug.logInfo("Adding DocAttribute: " + da, module); @@ -149,14 +149,11 @@ public class OutputServices { printer = printServices[0]; Debug.logInfo("Using printer: " + printer.getName(), module); if (!printer.isDocFlavorSupported(psInFormat)) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, - "ContentPrinterNotSupportDocFlavorFormat", - UtilMisc.toMap("psInFormat", psInFormat, "printerName", printer.getName()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ContentPrinterNotSupportDocFlavorFormat", UtilMisc.toMap("psInFormat", psInFormat, "printerName", printer.getName()), locale)); } } if (printer == null) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, - "ContentPrinterNotFound", UtilMisc.toMap("printerName", printerName), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ContentPrinterNotFound", UtilMisc.toMap("printerName", printerName), locale)); } } else { @@ -169,13 +166,12 @@ public class OutputServices { } if (printer == null) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, - "ContentPrinterNotAvailable", locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ContentPrinterNotAvailable", locale)); } PrintRequestAttributeSet praset = new HashPrintRequestAttributeSet(); - List printRequestAttributes = (List) serviceContext.remove("printRequestAttributes"); + List printRequestAttributes = UtilGenerics.checkList(serviceContext.remove("printRequestAttributes")); if (UtilValidate.isNotEmpty(printRequestAttributes)) { for (Object pra : printRequestAttributes) { Debug.logInfo("Adding PrintRequestAttribute: " + pra, module); @@ -184,23 +180,18 @@ public class OutputServices { } DocPrintJob job = printer.createPrintJob(); job.print(myDoc, praset); - - } catch (Exception e) { Debug.logError(e, "Error rendering [" + contentType + "]: " + e.toString(), module); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, - "ContentRenderingError", - UtilMisc.toMap("contentType", contentType, "errorString", e.toString()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ContentRenderingError", UtilMisc.toMap("contentType", contentType, "errorString", e.toString()), locale)); } return ServiceUtil.returnSuccess(); } public static Map createFileFromScreen(DispatchContext dctx, Map serviceContext) { - Locale locale = (Locale) serviceContext.get("locale"); String screenLocation = (String) serviceContext.remove("screenLocation"); - Map screenContext = (Map) serviceContext.remove("screenContext"); + Map screenContext = UtilGenerics.checkMap(serviceContext.remove("screenContext")); String contentType = (String) serviceContext.remove("contentType"); String filePath = (String) serviceContext.remove("filePath"); String fileName = (String) serviceContext.remove("fileName"); @@ -214,7 +205,7 @@ public class OutputServices { } try { - MapStack screenContextTmp = MapStack.create(); + MapStack screenContextTmp = MapStack.create(); screenContextTmp.put("locale", locale); Writer writer = new StringWriter(); @@ -256,9 +247,7 @@ public class OutputServices { } catch (Exception e) { Debug.logError(e, "Error rendering [" + contentType + "]: " + e.toString(), module); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, - "ContentRenderingError", - UtilMisc.toMap("contentType", contentType, "errorString", e.toString()), locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ContentRenderingError", UtilMisc.toMap("contentType", contentType, "errorString", e.toString()), locale)); } return ServiceUtil.returnSuccess();