svn commit: r1750534 - in /ofbiz/trunk/framework: webapp/src/org/ofbiz/webapp/view/ApacheFopWorker.java widget/src/org/ofbiz/widget/renderer/fo/ScreenFopViewHandler.java

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

svn commit: r1750534 - in /ofbiz/trunk/framework: webapp/src/org/ofbiz/webapp/view/ApacheFopWorker.java widget/src/org/ofbiz/widget/renderer/fo/ScreenFopViewHandler.java

Arun Patidar-4
Author: arunpatidar
Date: Tue Jun 28 15:10:51 2016
New Revision: 1750534

URL: http://svn.apache.org/viewvc?rev=1750534&view=rev
Log:
Applied patch from jira issue - OFBIZ-7459 - Enforce noninstantiability to ApacheFopWorker Class. Thanks Rishi Solanki and Rohit Koushal for your contribution.

Modified:
    ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/view/ApacheFopWorker.java
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/renderer/fo/ScreenFopViewHandler.java

Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/view/ApacheFopWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/view/ApacheFopWorker.java?rev=1750534&r1=1750533&r2=1750534&view=diff
==============================================================================
--- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/view/ApacheFopWorker.java (original)
+++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/view/ApacheFopWorker.java Tue Jun 28 15:10:51 2016
@@ -51,46 +51,47 @@ import org.ofbiz.base.util.UtilValidate;
  * Apache FOP worker class.
  */
 
-public class ApacheFopWorker {
+public final class ApacheFopWorker {
 
     public static final String module = ApacheFopWorker.class.getName();
     /** File name prefix used for temporary files. Currently set to
      * <code>org.ofbiz.webapp.view.ApacheFopWorker-</code>.
      */
-    public static final String tempFilePrefix = "org.ofbiz.webapp.view.ApacheFopWorker-";
+    private static final String tempFilePrefix = "org.ofbiz.webapp.view.ApacheFopWorker-";
 
-    protected static FopFactory fopFactory = null;
+    private static FopFactory fopFactory = null;
     
-    public static final int encryptionLengthBitsDefault = 128;
+    private static final int encryptionLengthBitsDefault = 128;
     
-    public static final String encryptionLengthDefault = UtilProperties.getPropertyValue("fop", "fop.encryption-length.default", String.valueOf(encryptionLengthBitsDefault));
+    private static final String encryptionLengthDefault = UtilProperties.getPropertyValue("fop", "fop.encryption-length.default", String.valueOf(encryptionLengthBitsDefault));
 
-    public static final String userPasswordDefault = UtilProperties.getPropertyValue("fop", "fop.userPassword.default");
+    private static final String userPasswordDefault = UtilProperties.getPropertyValue("fop", "fop.userPassword.default");
 
-    public static final String ownerPasswordDefault = UtilProperties.getPropertyValue("fop", "fop.ownerPassword.default");
+    private static final String ownerPasswordDefault = UtilProperties.getPropertyValue("fop", "fop.ownerPassword.default");
 
-    public static final String allowPrintDefault = UtilProperties.getPropertyValue("fop", "fop.allowPrint.default", "true");
+    private static final String allowPrintDefault = UtilProperties.getPropertyValue("fop", "fop.allowPrint.default", "true");
 
-    public static final String allowCopyContentDefault = UtilProperties.getPropertyValue("fop", "fop.allowCopyContent.default", "true");
+    private static final String allowCopyContentDefault = UtilProperties.getPropertyValue("fop", "fop.allowCopyContent.default", "true");
 
-    public static final String allowEditContentDefault = UtilProperties.getPropertyValue("fop", "fop.allowEditContent.default", "true");
+    private static final String allowEditContentDefault = UtilProperties.getPropertyValue("fop", "fop.allowEditContent.default", "true");
 
-    public static final String allowEditAnnotationsDefault = UtilProperties.getPropertyValue("fop", "fop.allowEditAnnotations.default", "true");
+    private static final String allowEditAnnotationsDefault = UtilProperties.getPropertyValue("fop", "fop.allowEditAnnotations.default", "true");
 
-    public static final String allowFillInFormsDefault = UtilProperties.getPropertyValue("fop", "fop.allowFillInForms.default", "true");
+    private static final String allowFillInFormsDefault = UtilProperties.getPropertyValue("fop", "fop.allowFillInForms.default", "true");
 
-    public static final String allowAccessContentDefault = UtilProperties.getPropertyValue("fop", "fop.allowAccessContent.default", "true");
+    private static final String allowAccessContentDefault = UtilProperties.getPropertyValue("fop", "fop.allowAccessContent.default", "true");
 
-    public static final String allowAssembleDocumentDefault = UtilProperties.getPropertyValue("fop", "fop.allowAssembleDocument.default", "true");
+    private static final String allowAssembleDocumentDefault = UtilProperties.getPropertyValue("fop", "fop.allowAssembleDocument.default", "true");
 
-    public static final String allowPrintHqDefault = UtilProperties.getPropertyValue("fop", "fop.allowPrintHq.default", "true");
+    private static final String allowPrintHqDefault = UtilProperties.getPropertyValue("fop", "fop.allowPrintHq.default", "true");
 
-    public static final String encryptMetadataDefault = UtilProperties.getPropertyValue("fop", "fop.encrypt-metadata.default", "true");
+    private static final String encryptMetadataDefault = UtilProperties.getPropertyValue("fop", "fop.encrypt-metadata.default", "true");
     
-    public static final String fopPath = UtilProperties.getPropertyValue("fop", "fop.path", "/framework/webapp/config");
+    private static final String fopPath = UtilProperties.getPropertyValue("fop", "fop.path", "/framework/webapp/config");
     
-    public static final String fopFontBaseProperty = UtilProperties.getPropertyValue("fop", "fop.font.base.url", "/framework/webapp/config/");
+    private static final String fopFontBaseProperty = UtilProperties.getPropertyValue("fop", "fop.font.base.url", "/framework/webapp/config/");
 
+    private ApacheFopWorker() {}
 
     /** Returns an instance of the FopFactory class. FOP documentation recommends
      * the reuse of the factory instance because of the startup time.
@@ -240,13 +241,13 @@ public class ApacheFopWorker {
 
     /** Local URI resolver for the Transformer class.
      */
-    public static class LocalResolver implements URIResolver {
+    private static class LocalResolver implements URIResolver {
 
         private URIResolver defaultResolver;
 
-        protected LocalResolver() {}
+        private LocalResolver() {}
 
-        public LocalResolver(URIResolver defaultResolver) {
+        private LocalResolver(URIResolver defaultResolver) {
             this.defaultResolver = defaultResolver;
         }
 
@@ -263,4 +264,52 @@ public class ApacheFopWorker {
             return defaultResolver.resolve(href, base);
         }
     }
+
+    public static String getEncryptionLengthDefault() {
+        return encryptionLengthDefault;
+    }
+
+    public static String getUserPasswordDefault() {
+        return userPasswordDefault;
+    }
+
+    public static String getOwnerPasswordDefault() {
+        return ownerPasswordDefault;
+    }
+
+    public static String getAllowPrintDefault() {
+        return allowPrintDefault;
+    }
+
+    public static String getAllowCopyContentDefault() {
+        return allowCopyContentDefault;
+    }
+
+    public static String getAllowEditContentDefault() {
+        return allowEditContentDefault;
+    }
+
+    public static String getAllowEditAnnotationsDefault() {
+        return allowEditAnnotationsDefault;
+    }
+
+    public static String getAllowAccessContentDefault() {
+        return allowAccessContentDefault;
+    }
+
+    public static String getAllowFillInFormsDefault() {
+        return allowFillInFormsDefault;
+    }
+
+    public static String getAllowAssembleDocumentDefault() {
+        return allowAssembleDocumentDefault;
+    }
+
+    public static String getAllowPrintHqDefault() {
+        return allowPrintHqDefault;
+    }
+
+    public static String getEncryptMetadataDefault() {
+        return encryptMetadataDefault;
+    }
 }

Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/renderer/fo/ScreenFopViewHandler.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/renderer/fo/ScreenFopViewHandler.java?rev=1750534&r1=1750533&r2=1750534&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/renderer/fo/ScreenFopViewHandler.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/renderer/fo/ScreenFopViewHandler.java Tue Jun 28 15:10:51 2016
@@ -110,27 +110,27 @@ public class ScreenFopViewHandler extend
         FOUserAgent foUserAgent = null;
         String userPassword = request.getParameter("userPassword");
         String ownerPassword = request.getParameter("ownerPassword");
-        boolean allowPrint = Boolean.parseBoolean(UtilValidate.isEmpty(request.getParameter("allowPrint")) ? ApacheFopWorker.allowPrintDefault : request.getParameter("allowPrint"));
-        boolean allowCopyContent = Boolean.parseBoolean(UtilValidate.isEmpty(request.getParameter("allowCopyContent")) ? ApacheFopWorker.allowCopyContentDefault : request.getParameter("allowCopyContent"));
-        boolean allowEditContent = Boolean.parseBoolean(UtilValidate.isEmpty(request.getParameter("allowEditContent")) ? ApacheFopWorker.allowEditContentDefault : request.getParameter("allowEditContent"));
-        boolean allowEditAnnotations = Boolean.parseBoolean(UtilValidate.isEmpty(request.getParameter("allowEditAnnotations")) ? ApacheFopWorker.allowEditAnnotationsDefault : request.getParameter("allowEditAnnotations"));
+        boolean allowPrint = Boolean.parseBoolean(UtilValidate.isEmpty(request.getParameter("allowPrint")) ? ApacheFopWorker.getAllowPrintDefault() : request.getParameter("allowPrint"));
+        boolean allowCopyContent = Boolean.parseBoolean(UtilValidate.isEmpty(request.getParameter("allowCopyContent")) ? ApacheFopWorker.getAllowCopyContentDefault() : request.getParameter("allowCopyContent"));
+        boolean allowEditContent = Boolean.parseBoolean(UtilValidate.isEmpty(request.getParameter("allowEditContent")) ? ApacheFopWorker.getAllowEditContentDefault() : request.getParameter("allowEditContent"));
+        boolean allowEditAnnotations = Boolean.parseBoolean(UtilValidate.isEmpty(request.getParameter("allowEditAnnotations")) ? ApacheFopWorker.getAllowEditAnnotationsDefault() : request.getParameter("allowEditAnnotations"));
         if (UtilValidate.isNotEmpty(userPassword) || UtilValidate.isNotEmpty(ownerPassword) || !allowPrint || !allowCopyContent || allowEditContent || !allowEditAnnotations) {
             int encryptionLength = 128;
             try {
                 encryptionLength = Integer.parseInt(request.getParameter("encryption-length"));
             } catch (NumberFormatException e) {
                 try {
-                    encryptionLength = Integer.parseInt(ApacheFopWorker.encryptionLengthDefault);
+                    encryptionLength = Integer.parseInt(ApacheFopWorker.getEncryptionLengthDefault());
                 } catch (NumberFormatException e1) {
                     // ignore
                 }
             }
             
-            boolean encryptMetadata = Boolean.parseBoolean(UtilValidate.isEmpty(request.getParameter("encrypt-metadata")) ? ApacheFopWorker.encryptMetadataDefault : request.getParameter("encrypt-metadata"));
-            boolean allowFillInForms = Boolean.parseBoolean(UtilValidate.isEmpty(request.getParameter("allowFillInForms")) ? ApacheFopWorker.allowFillInFormsDefault : request.getParameter("allowFillInForms"));
-            boolean allowAccessContent = Boolean.parseBoolean(UtilValidate.isEmpty(request.getParameter("allowAccessContent")) ? ApacheFopWorker.allowAccessContentDefault : request.getParameter("allowAccessContent"));
-            boolean allowAssembleDocument = Boolean.parseBoolean(UtilValidate.isEmpty(request.getParameter("allowAssembleDocument")) ? ApacheFopWorker.allowAssembleDocumentDefault : request.getParameter("allowAssembleDocument"));
-            boolean allowPrintHq = Boolean.parseBoolean(UtilValidate.isEmpty(request.getParameter("allowPrintHq")) ? ApacheFopWorker.allowPrintHqDefault : request.getParameter("allowPrintHq"));
+            boolean encryptMetadata = Boolean.parseBoolean(UtilValidate.isEmpty(request.getParameter("encrypt-metadata")) ? ApacheFopWorker.getEncryptMetadataDefault() : request.getParameter("encrypt-metadata"));
+            boolean allowFillInForms = Boolean.parseBoolean(UtilValidate.isEmpty(request.getParameter("allowFillInForms")) ? ApacheFopWorker.getAllowFillInFormsDefault() : request.getParameter("allowFillInForms"));
+            boolean allowAccessContent = Boolean.parseBoolean(UtilValidate.isEmpty(request.getParameter("allowAccessContent")) ? ApacheFopWorker.getAllowAccessContentDefault() : request.getParameter("allowAccessContent"));
+            boolean allowAssembleDocument = Boolean.parseBoolean(UtilValidate.isEmpty(request.getParameter("allowAssembleDocument")) ? ApacheFopWorker.getAllowAssembleDocumentDefault() : request.getParameter("allowAssembleDocument"));
+            boolean allowPrintHq = Boolean.parseBoolean(UtilValidate.isEmpty(request.getParameter("allowPrintHq")) ? ApacheFopWorker.getAllowPrintHqDefault() : request.getParameter("allowPrintHq"));
             
             FopFactory fopFactory = ApacheFopWorker.getFactoryInstance();
             foUserAgent = fopFactory.newFOUserAgent();