svn commit: r1818500 - in /ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/mail: JavaMailContainer.java MimeMessageWrapper.java ServiceMcaAction.java ServiceMcaCondition.java ServiceMcaUtil.java

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

svn commit: r1818500 - in /ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/mail: JavaMailContainer.java MimeMessageWrapper.java ServiceMcaAction.java ServiceMcaCondition.java ServiceMcaUtil.java

mbrohl
Author: mbrohl
Date: Sun Dec 17 18:47:18 2017
New Revision: 1818500

URL: http://svn.apache.org/viewvc?rev=1818500&view=rev
Log:
Improved: General refactoring and code improvements, package
org.apache.ofbiz.service.mail.
(OFBIZ-9943)

Thanks Dennis Balkir for reporting and providing the patches.

Modified:
    ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/mail/JavaMailContainer.java
    ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/mail/MimeMessageWrapper.java
    ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/mail/ServiceMcaAction.java
    ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/mail/ServiceMcaCondition.java
    ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/mail/ServiceMcaUtil.java

Modified: ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/mail/JavaMailContainer.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/mail/JavaMailContainer.java?rev=1818500&r1=1818499&r2=1818500&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/mail/JavaMailContainer.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/mail/JavaMailContainer.java Sun Dec 17 18:47:18 2017
@@ -181,7 +181,9 @@ public class JavaMailContainer implement
         // re-write the URLName including the password for this store
         if (store != null && store.getURLName() != null) {
             URLName urlName = this.updateUrlName(store.getURLName(), session.getProperties());
-            if (Debug.verboseOn()) Debug.logVerbose("URLName - " + urlName.toString(), module);
+            if (Debug.verboseOn()) {
+                Debug.logVerbose("URLName - " + urlName.toString(), module);
+            }
             try {
                 store = session.getStore(urlName);
             } catch (NoSuchProviderException e) {
@@ -235,7 +237,7 @@ public class JavaMailContainer implement
                 host = props.getProperty("mail.host");
             }
         }
-        
+
         // check the port
         int portProps = 0;
         String portStr = props.getProperty("mail." + protocol + ".port");
@@ -260,8 +262,10 @@ public class JavaMailContainer implement
         if (portProps != 0) {
             port = portProps;
         }
-
-        if (Debug.verboseOn()) Debug.logVerbose("Update URL - " + protocol + "://" + userName + "@" + host + ":" + port + "!" + password + ";" + file, module);
+
+        if (Debug.verboseOn()) {
+            Debug.logVerbose("Update URL - " + protocol + "://" + userName + "@" + host + ":" + port + "!" + password + ";" + file, module);
+        }
         return new URLName(protocol, host, port, file, userName, password);
     }
 
@@ -281,7 +285,9 @@ public class JavaMailContainer implement
                     Debug.logWarning("There was a case error in LoggingStoreListener.notification", module);
             }
 
-            if (Debug.verboseOn()) Debug.logVerbose("JavaMail " + typeString + event.getMessage(), module);
+            if (Debug.verboseOn()) {
+                Debug.logVerbose("JavaMail " + typeString + event.getMessage(), module);
+            }
         }
     }
 
@@ -361,13 +367,19 @@ public class JavaMailContainer implement
                         message.setFlag(Flags.Flag.SEEN, true);
                     } else {
                         this.processMessage(message, session);
-                        if (Debug.verboseOn()) Debug.logVerbose("Message from " + UtilMisc.toListArray(message.getFrom()) + " with subject [" + message.getSubject() + "]  has been processed." , module);
+                        if (Debug.verboseOn()) {
+                            Debug.logVerbose("Message from " + UtilMisc.toListArray(message.getFrom()) + " with subject [" + message.getSubject() + "]  has been processed." , module);
+                        }
                         message.setFlag(Flags.Flag.SEEN, true);
-                        if (Debug.verboseOn()) Debug.logVerbose("Message [" + message.getSubject() + "] is marked seen", module);
+                        if (Debug.verboseOn()) {
+                            Debug.logVerbose("Message [" + message.getSubject() + "] is marked seen", module);
+                        }
 
                         // delete the message after processing
                         if (deleteMail) {
-                            if (Debug.verboseOn()) Debug.logVerbose("Message [" + message.getSubject() + "] is being deleted", module);
+                            if (Debug.verboseOn()) {
+                                Debug.logVerbose("Message [" + message.getSubject() + "] is being deleted", module);
+                            }
                             message.setFlag(Flags.Flag.DELETED, true);
                         }
                     }

Modified: ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/mail/MimeMessageWrapper.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/mail/MimeMessageWrapper.java?rev=1818500&r1=1818499&r2=1818500&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/mail/MimeMessageWrapper.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/mail/MimeMessageWrapper.java Sun Dec 17 18:47:18 2017
@@ -465,10 +465,7 @@ public class MimeMessageWrapper implemen
                 Debug.logWarning("Requested a subpart [" + subIndex + "] which deos not exist; only [" + getSubPartCount(mainIndex) + "] parts", module);
                 // there is no sub part to find
                 return part;
-            } catch (MessagingException e) {
-                Debug.logError(e, module);
-                return null;
-            } catch (IOException e) {
+            } catch (MessagingException | IOException e) {
                 Debug.logError(e, module);
                 return null;
             }
@@ -478,7 +475,9 @@ public class MimeMessageWrapper implemen
     }
 
     protected String getContentText(Object content) {
-        if (content == null) return null;
+        if (content == null) {
+            return null;
+        }
         if (content instanceof String) {
             return (String) content;
         } else if (content instanceof InputStream) {
@@ -531,7 +530,7 @@ public class MimeMessageWrapper implemen
 
     /**
      * Convert MimeMessageWrapper to String. This is used when sending emails.
-     *
+     *
      */
     private static class MimeMessageToString<E> extends AbstractConverter<MimeMessageWrapper, String> {
         public MimeMessageToString() {

Modified: ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/mail/ServiceMcaAction.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/mail/ServiceMcaAction.java?rev=1818500&r1=1818499&r2=1818500&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/mail/ServiceMcaAction.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/mail/ServiceMcaAction.java Sun Dec 17 18:47:18 2017
@@ -47,7 +47,9 @@ public class ServiceMcaAction implements
         this.serviceMode = action.getAttribute("mode");
         this.runAsUser = action.getAttribute("run-as-user");
         // support the old, inconsistent attribute name
-        if (UtilValidate.isEmail(this.runAsUser)) this.runAsUser = action.getAttribute("runAsUser");
+        if (UtilValidate.isEmail(this.runAsUser)) {
+            this.runAsUser = action.getAttribute("runAsUser");
+        }
         this.persist = "true".equals(action.getAttribute("persist"));
     }
 

Modified: ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/mail/ServiceMcaCondition.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/mail/ServiceMcaCondition.java?rev=1818500&r1=1818499&r2=1818500&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/mail/ServiceMcaCondition.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/mail/ServiceMcaCondition.java Sun Dec 17 18:47:18 2017
@@ -148,9 +148,7 @@ public class ServiceMcaCondition impleme
             String[] fieldValues = null;
             try {
                 fieldValues = this.getFieldValue(message, fieldName);
-            } catch (MessagingException e) {
-                Debug.logError(e, module);
-            } catch (IOException e) {
+            } catch (MessagingException | IOException e) {
                 Debug.logError(e, module);
             }
 

Modified: ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/mail/ServiceMcaUtil.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/mail/ServiceMcaUtil.java?rev=1818500&r1=1818499&r2=1818500&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/mail/ServiceMcaUtil.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/mail/ServiceMcaUtil.java Sun Dec 17 18:47:18 2017
@@ -89,7 +89,7 @@ public final class ServiceMcaUtil {
     }
 
     public static void evalRules(LocalDispatcher dispatcher, MimeMessageWrapper wrapper, GenericValue userLogin) throws GenericServiceException {
-        Set<String> actionsRun = new TreeSet<String>();
+        Set<String> actionsRun = new TreeSet<>();
         for (ServiceMcaRule rule: getServiceMcaRules()) {
             rule.eval(dispatcher, wrapper, actionsRun, userLogin);
         }