svn commit: r571262 - /ofbiz/trunk/framework/service/src/org/ofbiz/service/mail/JavaMailContainer.java

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

svn commit: r571262 - /ofbiz/trunk/framework/service/src/org/ofbiz/service/mail/JavaMailContainer.java

jaz-3
Author: jaz
Date: Thu Aug 30 11:12:02 2007
New Revision: 571262

URL: http://svn.apache.org/viewvc?rev=571262&view=rev
Log:
few small moficiations (better error checking) to the javamail container

Modified:
    ofbiz/trunk/framework/service/src/org/ofbiz/service/mail/JavaMailContainer.java

Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/mail/JavaMailContainer.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/mail/JavaMailContainer.java?rev=571262&r1=571261&r2=571262&view=diff
==============================================================================
--- ofbiz/trunk/framework/service/src/org/ofbiz/service/mail/JavaMailContainer.java (original)
+++ ofbiz/trunk/framework/service/src/org/ofbiz/service/mail/JavaMailContainer.java Thu Aug 30 11:12:02 2007
@@ -86,11 +86,7 @@
         ContainerConfig.Container cfg = ContainerConfig.getContainer("javamail-container", configFile);
         String dispatcherName = ContainerConfig.getPropertyValue(cfg, "dispatcher-name", "JavaMailDispatcher");
         String delegatorName = ContainerConfig.getPropertyValue(cfg, "delegator-name", "default");
-        if ("true".equals(ContainerConfig.getPropertyValue(cfg, "delete-mail", "false"))) {
-            this.deleteMail = true;
-        } else {
-            this.deleteMail = false;
-        }
+        this.deleteMail = "true".equals(ContainerConfig.getPropertyValue(cfg, "delete-mail", "false"));
         
         this.delegator = GenericDelegator.getGenericDelegator(delegatorName);
         this.dispatcher = GenericDispatcher.getLocalDispatcher(dispatcherName, delegator);
@@ -161,7 +157,7 @@
 
     protected Store getStore(Session session) throws ContainerException {
         // create the store object
-        Store store = null;
+        Store store;
         try {
             store = session.getStore();
         } catch (NoSuchProviderException e) {
@@ -179,6 +175,10 @@
             }
         }
 
+        if (store == null) {
+            throw new ContainerException("No store configured!");
+        }
+
         // test the store
         try {
             store.connect();
@@ -306,9 +306,9 @@
             for (int i = 0; i < messages.length; i++) {
                 // process each un-read message
              if (!messages[i].isSet(Flags.Flag.SEEN)) {
-             long messageSize = ((MimeMessage) messages[i]).getSize();
+             long messageSize = messages[i].getSize();
              if (messages[i] instanceof MimeMessage && messageSize >= maxSize) {
-             Debug.logWarning("Message from: " + ((MimeMessage)messages[i]).getFrom()[0] + "not received, to big, size:" + messageSize + " cannot be more than " + maxSize + " bytes", module);
+             Debug.logWarning("Message from: " + messages[i].getFrom()[0] + "not received, to big, size:" + messageSize + " cannot be more than " + maxSize + " bytes", module);
              } else {
              this.processMessage(messages[i], session);
              if (Debug.verboseOn()) Debug.logVerbose("Message from " + UtilMisc.toListArray(messages[i].getFrom()) + " with subject [" + messages[i].getSubject() + "]  has been processed." , module);