svn commit: r1061483 - /ofbiz/trunk/applications/content/src/org/ofbiz/content/output/OutputServices.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1061483 - /ofbiz/trunk/applications/content/src/org/ofbiz/content/output/OutputServices.java

mrisaliti
Author: mrisaliti
Date: Thu Jan 20 19:55:35 2011
New Revision: 1061483

URL: http://svn.apache.org/viewvc?rev=1061483&view=rev
Log:
Remove java compilation warnings from OutputServices (OFBIZ-4102)

Modified:
    ofbiz/trunk/applications/content/src/org/ofbiz/content/output/OutputServices.java

Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/output/OutputServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/output/OutputServices.java?rev=1061483&r1=1061482&r2=1061483&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/src/org/ofbiz/content/output/OutputServices.java (original)
+++ ofbiz/trunk/applications/content/src/org/ofbiz/content/output/OutputServices.java Thu Jan 20 19:55:35 2011
@@ -47,8 +47,13 @@ import javax.print.attribute.PrintServic
 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.FoFormRendere
 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<String, Object> sendPrintFromScreen(DispatchContext dctx, Map<String, ? extends Object> serviceContext) {
-
         Locale locale = (Locale) serviceContext.get("locale");
         String screenLocation = (String) serviceContext.remove("screenLocation");
-        Map screenContext = (Map) serviceContext.remove("screenContext");
+        Map<String, Object> 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<String> 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<Object> 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<Object> 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<String, Object> createFileFromScreen(DispatchContext dctx, Map<String, ? extends Object> serviceContext) {
-
         Locale locale = (Locale) serviceContext.get("locale");
         String screenLocation = (String) serviceContext.remove("screenLocation");
-        Map screenContext = (Map) serviceContext.remove("screenContext");
+        Map<String, Object> 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<String> 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();