Author: doogie
Date: Thu Apr 30 03:27:29 2009 New Revision: 770049 URL: http://svn.apache.org/viewvc?rev=770049&view=rev Log: Generics fixes. Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/FindServices.java ofbiz/trunk/framework/common/src/org/ofbiz/common/email/EmailServices.java ofbiz/trunk/framework/common/src/org/ofbiz/common/email/NotificationServices.java ofbiz/trunk/framework/common/src/org/ofbiz/common/image/ImageTransform.java Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/FindServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/FindServices.java?rev=770049&r1=770048&r2=770049&view=diff ============================================================================== --- ofbiz/trunk/framework/common/src/org/ofbiz/common/FindServices.java (original) +++ ofbiz/trunk/framework/common/src/org/ofbiz/common/FindServices.java Thu Apr 30 03:27:29 2009 @@ -33,6 +33,7 @@ import org.ofbiz.base.util.ObjectType; import org.ofbiz.base.util.StringUtil; import org.ofbiz.base.util.UtilDateTime; +import org.ofbiz.base.util.UtilGenerics; import org.ofbiz.base.util.UtilHttp; import static org.ofbiz.base.util.UtilGenerics.checkList; import static org.ofbiz.base.util.UtilGenerics.checkMap; @@ -543,10 +544,10 @@ List<String> orderByList = checkList(context.get("orderByList"), String.class); boolean noConditionFind = "Y".equals((String) context.get("noConditionFind")); boolean distinct = "Y".equals((String) context.get("distinct")); - List fieldList = (List) context.get("fieldList"); - Set fieldSet = null; + List<String> fieldList = UtilGenerics.checkList(context.get("fieldList")); + Set<String> fieldSet = null; if (fieldList != null) { - fieldSet = new HashSet(fieldList); + fieldSet = UtilMisc.makeSetWritable(fieldList); } GenericDelegator delegator = dctx.getDelegator(); // Retrieve entities - an iterator over all the values Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/email/EmailServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/email/EmailServices.java?rev=770049&r1=770048&r2=770049&view=diff ============================================================================== --- ofbiz/trunk/framework/common/src/org/ofbiz/common/email/EmailServices.java (original) +++ ofbiz/trunk/framework/common/src/org/ofbiz/common/email/EmailServices.java Thu Apr 30 03:27:29 2009 @@ -60,6 +60,7 @@ import org.ofbiz.base.util.GeneralException; import org.ofbiz.base.util.HttpClient; import org.ofbiz.base.util.HttpClientException; +import org.ofbiz.base.util.UtilGenerics; import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.UtilProperties; import org.ofbiz.base.util.UtilValidate; @@ -92,7 +93,7 @@ *@return Map with the result of the service, the output parameters */ public static Map<String, Object> sendMail(DispatchContext ctx, Map<String, ? extends Object> context) { - Map results = ServiceUtil.returnSuccess(); + Map<String, Object> results = ServiceUtil.returnSuccess(); String subject = (String) context.get("subject"); String partyId = (String) context.get("partyId"); String body = (String) context.get("body"); @@ -315,7 +316,7 @@ Map<String, Object> context = UtilMisc.makeMapWritable(rcontext); // pretty simple, get the content and then call the sendMail method below String bodyUrl = (String) context.remove("bodyUrl"); - Map bodyUrlParameters = (Map) context.remove("bodyUrlParameters"); + Map<String, Object> bodyUrlParameters = UtilGenerics.checkMap(context.remove("bodyUrlParameters")); URL url = null; @@ -337,7 +338,7 @@ } context.put("body", body); - Map result = sendMail(ctx, context); + Map<String, Object> result = sendMail(ctx, context); result.put("body", body); return result; @@ -359,7 +360,7 @@ String xslfoAttachScreenLocation = (String) serviceContext.remove("xslfoAttachScreenLocation"); String attachmentName = (String) serviceContext.remove("attachmentName"); Locale locale = (Locale) serviceContext.get("locale"); - Map bodyParameters = (Map) serviceContext.remove("bodyParameters"); + Map<String, Object> bodyParameters = UtilGenerics.checkMap(serviceContext.remove("bodyParameters")); if (bodyParameters == null) { bodyParameters = MapStack.create(); } @@ -379,7 +380,7 @@ } StringWriter bodyWriter = new StringWriter(); - MapStack screenContext = MapStack.create(); + MapStack<String> screenContext = MapStack.create(); screenContext.put("locale", locale); ScreenRenderer screens = new ScreenRenderer(bodyWriter, screenContext, htmlScreenRenderer); screens.populateContextForService(dctx, bodyParameters); @@ -415,7 +416,7 @@ // start processing fo pdf attachment try { Writer writer = new StringWriter(); - MapStack screenContextAtt = MapStack.create(); + MapStack<String> screenContextAtt = MapStack.create(); // substitute the freemarker variables... ScreenRenderer screensAtt = new ScreenRenderer(writer, screenContext, foScreenRenderer); screensAtt.populateContextForService(dctx, bodyParameters); @@ -447,7 +448,7 @@ baos.close(); // store in the list of maps for sendmail.... - List bodyParts = FastList.newInstance(); + List<Map<String, ? extends Object>> bodyParts = FastList.newInstance(); if (bodyText != null) { bodyText = FlexibleStringExpander.expandString(bodyText, screenContext, locale); bodyParts.add(UtilMisc.toMap("content", bodyText, "type", "text/html")); @@ -504,7 +505,7 @@ if (Debug.verboseOn()) Debug.logVerbose("sendMailFromScreen sendMail context: " + serviceContext, module); - Map result = ServiceUtil.returnSuccess(); + Map<String, Object> result = ServiceUtil.returnSuccess(); try { if (isMultiPart) { dispatcher.runSync("sendMailMultiPart", serviceContext); Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/email/NotificationServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/email/NotificationServices.java?rev=770049&r1=770048&r2=770049&view=diff ============================================================================== --- ofbiz/trunk/framework/common/src/org/ofbiz/common/email/NotificationServices.java (original) +++ ofbiz/trunk/framework/common/src/org/ofbiz/common/email/NotificationServices.java Thu Apr 30 03:27:29 2009 @@ -29,6 +29,7 @@ import javolution.util.FastMap; import org.ofbiz.base.util.Debug; +import org.ofbiz.base.util.UtilGenerics; import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.UtilProperties; import org.ofbiz.base.util.UtilURL; @@ -118,7 +119,7 @@ */ public static Map<String, Object> sendNotification(DispatchContext ctx, Map<String, ? extends Object> context) { LocalDispatcher dispatcher = ctx.getDispatcher(); - Map result = null; + Map<String, Object> result = null; try { // see whether the optional 'body' attribute was specified or needs to be processed @@ -142,7 +143,7 @@ // make sure we have a valid body before sending if (body != null) { // retain only the required attributes for the sendMail service - Map emailContext = FastMap.newInstance(); + Map<String, Object> emailContext = FastMap.newInstance(); emailContext.put("sendTo", context.get("sendTo")); emailContext.put("body", body); emailContext.put("sendCc", context.get("sendCc")); @@ -185,10 +186,10 @@ public static Map<String, Object> prepareNotification(DispatchContext ctx, Map<String, ? extends Object> context) { GenericDelegator delegator = ctx.getDelegator(); String templateName = (String) context.get("templateName"); - Map templateData = (Map) context.get("templateData"); + Map<String, Object> templateData = UtilGenerics.checkMap(context.get("templateData")); String webSiteId = (String) context.get("webSiteId"); - Map result = null; + Map<String, Object> result = null; if (templateData == null) { templateData = FastMap.newInstance(); } @@ -248,7 +249,7 @@ * @param context The context to check and, if necessary, set the * <code>baseUrl</code>. */ - public static void setBaseUrl(GenericDelegator delegator, String webSiteId, Map context) { + public static void setBaseUrl(GenericDelegator delegator, String webSiteId, Map<String, Object> context) { // If the baseUrl was not specified we can do a best effort instead if (!context.containsKey("baseUrl")) { StringBuilder httpBase = null; Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/image/ImageTransform.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/image/ImageTransform.java?rev=770049&r1=770048&r2=770049&view=diff ============================================================================== --- ofbiz/trunk/framework/common/src/org/ofbiz/common/image/ImageTransform.java (original) +++ ofbiz/trunk/framework/common/src/org/ofbiz/common/image/ImageTransform.java Thu Apr 30 03:27:29 2009 @@ -20,21 +20,26 @@ import java.awt.image.BufferedImage; import java.io.File; +import java.io.FileInputStream; import java.io.IOException; import java.util.List; import java.util.Locale; import java.util.Map; import javax.imageio.ImageIO; +import javax.xml.parsers.ParserConfigurationException; import javolution.util.FastMap; -import org.jdom.Document; -import org.jdom.Element; -import org.jdom.JDOMException; -import org.jdom.input.SAXBuilder; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilProperties; +import org.ofbiz.base.util.UtilXml; + +import org.xml.sax.SAXException; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; + /** @@ -180,7 +185,7 @@ * @return Map contains asked attribute values by attribute name */ public static Map<String, Object> getXMLValue(String fileFullPath, Locale locale) - throws IllegalStateException, IOException, JDOMException { + throws IllegalStateException, IOException { /* VARIABLES */ Document document; @@ -189,11 +194,14 @@ Map<String, Object> result = FastMap.newInstance(); /* PARSING */ - SAXBuilder sxb = new SAXBuilder(); try { - // JDOM - document = sxb.build(new File(fileFullPath)); - } catch (JDOMException e) { + document = UtilXml.readXmlDocument(new FileInputStream(fileFullPath), fileFullPath); + } catch (ParserConfigurationException e) { + String errMsg = UtilProperties.getMessage(resource, "ImageTransform.errors_occured_during_parsing", locale) + " ImageProperties.xml " + e.toString(); + Debug.logError(errMsg, module); + result.put("errorMessage", "error"); + return result; + } catch (SAXException e) { String errMsg = UtilProperties.getMessage(resource, "ImageTransform.errors_occured_during_parsing", locale) + " ImageProperties.xml " + e.toString(); Debug.logError(errMsg, module); result.put("errorMessage", "error"); @@ -206,7 +214,7 @@ } // set Root Element try { - rootElt = document.getRootElement(); + rootElt = document.getDocumentElement(); } catch (IllegalStateException e) { String errMsg = UtilProperties.getMessage(resource, "ImageTransform.root_element_has_not_been_set", locale) + e.toString(); Debug.logError(errMsg, module); @@ -215,20 +223,20 @@ } /* get NAME and VALUE */ - List<Element> children = rootElt.getChildren(); // FIXME : despite upgrading to jdom 1.1, it seems that getChildren is pre 1.5 java code (ie getChildren does not retun List<Element> but only List) + List<? extends Element> children = UtilXml.childElementList(rootElt); // FIXME : despite upgrading to jdom 1.1, it seems that getChildren is pre 1.5 java code (ie getChildren does not retun List<Element> but only List) for (Element currentElt : children) { Map<String, String> eltMap = FastMap.newInstance(); - if (currentElt.getContentSize() > 0) { + List<? extends Element> children2 = UtilXml.childElementList(currentElt); + if (children2.size() > 0) { Map<String, String> childMap = FastMap.newInstance(); // loop over Children 1st level - List<Element> children2 = currentElt.getChildren(); for (Element currentChild : children2) { - childMap.put(currentChild.getAttributeValue("name"), currentChild.getAttributeValue("value")); + childMap.put(currentChild.getAttribute("name"), currentChild.getAttribute("value")); } - valueMap.put(currentElt.getAttributeValue("name"), childMap); + valueMap.put(currentElt.getAttribute("name"), childMap); } else { - eltMap.put(currentElt.getAttributeValue("name"), currentElt.getAttributeValue("value")); - valueMap.put(currentElt.getName(), eltMap); + eltMap.put(currentElt.getAttribute("name"), currentElt.getAttribute("value")); + valueMap.put(currentElt.getNodeName(), eltMap); } } |
Free forum by Nabble | Edit this page |