Author: arunpatidar
Date: Mon Jun 27 14:42:20 2016 New Revision: 1750352 URL: http://svn.apache.org/viewvc?rev=1750352&view=rev Log: Applied patch from jira issue - OFBIZ-7410 - Enforce noninstantiability to BirtWorker Class. Thanks Pratik Kulshreshth for your contribution. Modified: ofbiz/trunk/specialpurpose/birt/src/org/ofbiz/birt/BirtWorker.java ofbiz/trunk/specialpurpose/birt/src/org/ofbiz/birt/email/BirtEmailServices.java ofbiz/trunk/specialpurpose/birt/src/org/ofbiz/birt/webapp/view/BirtViewHandler.java Modified: ofbiz/trunk/specialpurpose/birt/src/org/ofbiz/birt/BirtWorker.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/birt/src/org/ofbiz/birt/BirtWorker.java?rev=1750352&r1=1750351&r2=1750352&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/birt/src/org/ofbiz/birt/BirtWorker.java (original) +++ ofbiz/trunk/specialpurpose/birt/src/org/ofbiz/birt/BirtWorker.java Mon Jun 27 14:42:20 2016 @@ -46,18 +46,19 @@ import org.ofbiz.entity.Delegator; import org.ofbiz.security.Security; import org.ofbiz.service.LocalDispatcher; -public class BirtWorker { +public final class BirtWorker { public final static String module = BirtWorker.class.getName(); - public final static String BIRT_PARAMETERS = "birtParameters"; - public final static String REPORT_ENGINE = "reportEngine"; - public final static String BIRT_LOCALE = "birtLocale"; - public final static String BIRT_IMAGE_DIRECTORY = "birtImageDirectory"; - public final static String BIRT_CONTENT_TYPE = "birtContentType"; - public final static String BIRT_OUTPUT_FILE_NAME = "birtOutputFileName"; + private final static String BIRT_PARAMETERS = "birtParameters"; + private final static String BIRT_LOCALE = "birtLocale"; + private final static String BIRT_IMAGE_DIRECTORY = "birtImageDirectory"; + private final static String BIRT_CONTENT_TYPE = "birtContentType"; + private final static String BIRT_OUTPUT_FILE_NAME = "birtOutputFileName"; - private static HTMLServerImageHandler imageHandler = new HTMLServerImageHandler(); + private final static HTMLServerImageHandler imageHandler = new HTMLServerImageHandler(); + + private BirtWorker () {} /** * export report @@ -193,4 +194,24 @@ public class BirtWorker { appContext.put("security", security); } } + + public static String getBirtParameters () { + return BIRT_PARAMETERS; + } + + public static String getBirtLocale () { + return BIRT_LOCALE; + } + + public static String getBirtImageDirectory () { + return BIRT_IMAGE_DIRECTORY; + } + + public static String getBirtContentType () { + return BIRT_CONTENT_TYPE; + } + + public static String getBirtOutputFileName () { + return BIRT_OUTPUT_FILE_NAME; + } } Modified: ofbiz/trunk/specialpurpose/birt/src/org/ofbiz/birt/email/BirtEmailServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/birt/src/org/ofbiz/birt/email/BirtEmailServices.java?rev=1750352&r1=1750351&r2=1750352&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/birt/src/org/ofbiz/birt/email/BirtEmailServices.java (original) +++ ofbiz/trunk/specialpurpose/birt/src/org/ofbiz/birt/email/BirtEmailServices.java Mon Jun 27 14:42:20 2016 @@ -82,10 +82,10 @@ public class BirtEmailServices { String attachmentName = (String) serviceContext.remove("attachmentName"); Locale locale = (Locale) serviceContext.get("locale"); Map<String, Object> bodyParameters = UtilGenerics.cast(serviceContext.remove("bodyParameters")); - Locale birtLocale = (Locale) serviceContext.remove(BirtWorker.BIRT_LOCALE); - Map<String, Object> birtParameters = UtilGenerics.cast(serviceContext.remove(BirtWorker.BIRT_PARAMETERS)); - String birtImageDirectory = (String) serviceContext.remove(BirtWorker.BIRT_IMAGE_DIRECTORY); - String birtContentType = (String) serviceContext.remove(BirtWorker.BIRT_CONTENT_TYPE); + Locale birtLocale = (Locale) serviceContext.remove(BirtWorker.getBirtLocale()); + Map<String, Object> birtParameters = UtilGenerics.cast(serviceContext.remove(BirtWorker.getBirtParameters())); + String birtImageDirectory = (String) serviceContext.remove(BirtWorker.getBirtImageDirectory()); + String birtContentType = (String) serviceContext.remove(BirtWorker.getBirtContentType()); if (bodyParameters == null) { bodyParameters = MapStack.create(); } @@ -160,12 +160,12 @@ public class BirtEmailServices { if (birtLocale == null) { birtLocale = locale; } - birtContext.put(BirtWorker.BIRT_LOCALE, birtLocale); + birtContext.put(BirtWorker.getBirtLocale(), birtLocale); if (birtParameters != null) { - birtContext.put(BirtWorker.BIRT_PARAMETERS, birtParameters); + birtContext.put(BirtWorker.getBirtParameters(), birtParameters); } if (birtImageDirectory != null) { - birtContext.put(BirtWorker.BIRT_IMAGE_DIRECTORY, birtImageDirectory); + birtContext.put(BirtWorker.getBirtImageDirectory(), birtImageDirectory); } if (birtContentType == null) { birtContentType = "application/pdf"; Modified: ofbiz/trunk/specialpurpose/birt/src/org/ofbiz/birt/webapp/view/BirtViewHandler.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/birt/src/org/ofbiz/birt/webapp/view/BirtViewHandler.java?rev=1750352&r1=1750351&r2=1750352&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/birt/src/org/ofbiz/birt/webapp/view/BirtViewHandler.java (original) +++ ofbiz/trunk/specialpurpose/birt/src/org/ofbiz/birt/webapp/view/BirtViewHandler.java Mon Jun 27 14:42:20 2016 @@ -87,34 +87,34 @@ public class BirtViewHandler implements Map<String, Object> context = new HashMap<String, Object>(); // set parameters from request - Map<String, Object> parameters = UtilGenerics.cast(request.getAttribute(BirtWorker.BIRT_PARAMETERS)); + Map<String, Object> parameters = UtilGenerics.cast(request.getAttribute(BirtWorker.getBirtParameters())); if (parameters != null) { - context.put(BirtWorker.BIRT_PARAMETERS, parameters); + context.put(BirtWorker.getBirtParameters(), parameters); } else { - context.put(BirtWorker.BIRT_PARAMETERS, UtilHttp.getParameterMap(request)); + context.put(BirtWorker.getBirtParameters(), UtilHttp.getParameterMap(request)); } // set locale from request - Locale locale = (Locale)request.getAttribute(BirtWorker.BIRT_LOCALE); + Locale locale = (Locale)request.getAttribute(BirtWorker.getBirtLocale()); if (locale == null) { locale = UtilHttp.getLocale(request); } // set output file name - String outputFileName = (String) request.getAttribute(BirtWorker.BIRT_OUTPUT_FILE_NAME); + String outputFileName = (String) request.getAttribute(BirtWorker.getBirtOutputFileName()); if (UtilValidate.isNotEmpty(outputFileName)) { UtilHttp.setContentDisposition(response, outputFileName); } // set override content type - String overrideContentType = (String) request.getAttribute(BirtWorker.BIRT_CONTENT_TYPE); + String overrideContentType = (String) request.getAttribute(BirtWorker.getBirtContentType()); if (UtilValidate.isNotEmpty(overrideContentType)) { contentType = overrideContentType; } - context.put(BirtWorker.BIRT_LOCALE, locale); + context.put(BirtWorker.getBirtLocale(), locale); Delegator delegator = (Delegator) request.getAttribute("delegator"); String birtImageDirectory = EntityUtilProperties.getPropertyValue("birt", "birt.html.image.directory", delegator); - context.put(BirtWorker.BIRT_IMAGE_DIRECTORY, birtImageDirectory); + context.put(BirtWorker.getBirtImageDirectory(), birtImageDirectory); BirtWorker.exportReport(design, context, contentType, response.getOutputStream()); } catch (BirtException e) { throw new ViewHandlerException("Birt Error create engine: " + e.toString(), e); |
Free forum by Nabble | Edit this page |