I see some ugly formatting and variable names in this commit. Jacopo
On Jul 16, 2014, at 3:29 PM, [email protected] wrote: > Author: jleroux > Date: Wed Jul 16 13:29:19 2014 > New Revision: 1611002 > > URL: http://svn.apache.org/r1611002 > Log: > An updated ands slightly modified patch from BJ Freeman for "allow assignment > of port for the Javamail container." > https://issues.apache.org/jira/browse/1967 > > currently no property for setting the port to read email from in the javamail > container. > > Modified: > ofbiz/trunk/framework/service/ofbiz-component.xml > > ofbiz/trunk/framework/service/src/org/ofbiz/service/mail/JavaMailContainer.java > > Modified: ofbiz/trunk/framework/service/ofbiz-component.xml > URL: > http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/ofbiz-component.xml?rev=1611002&r1=1611001&r2=1611002&view=diff > ============================================================================== > --- ofbiz/trunk/framework/service/ofbiz-component.xml (original) > +++ ofbiz/trunk/framework/service/ofbiz-component.xml Wed Jul 16 13:29:19 2014 > @@ -77,6 +77,7 @@ under the License. > <property name="default-listener" value="store-listener"> > <property name="mail.store.protocol" value="imap"/> > <property name="mail.host" value="[host]"/> > + <property name="mail.port" value="110"/> > <property name="mail.user" value="[user]"/> > <property name="mail.pass" value="[pass]"/> > <property name="mail.debug" value="false"/> > > 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=1611002&r1=1611001&r2=1611002&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 > Wed Jul 16 13:29:19 2014 > @@ -25,6 +25,7 @@ import java.util.Properties; > import java.util.concurrent.Executors; > import java.util.concurrent.ScheduledExecutorService; > import java.util.concurrent.TimeUnit; > + > import javax.mail.FetchProfile; > import javax.mail.Flags; > import javax.mail.Folder; > @@ -34,23 +35,23 @@ import javax.mail.NoSuchProviderExceptio > import javax.mail.Session; > import javax.mail.Store; > import javax.mail.URLName; > -import javax.mail.internet.MimeMessage; > -import javax.mail.search.FlagTerm; > import javax.mail.event.StoreEvent; > import javax.mail.event.StoreListener; > +import javax.mail.internet.MimeMessage; > +import javax.mail.search.FlagTerm; > > import org.ofbiz.base.container.Container; > import org.ofbiz.base.container.ContainerConfig; > import org.ofbiz.base.container.ContainerException; > import org.ofbiz.base.util.Debug; > -import org.ofbiz.base.util.UtilValidate; > import org.ofbiz.base.util.UtilMisc; > +import org.ofbiz.base.util.UtilValidate; > import org.ofbiz.entity.Delegator; > import org.ofbiz.entity.DelegatorFactory; > -import org.ofbiz.entity.GenericValue; > import org.ofbiz.entity.GenericEntityException; > -import org.ofbiz.service.LocalDispatcher; > +import org.ofbiz.entity.GenericValue; > import org.ofbiz.service.GenericServiceException; > +import org.ofbiz.service.LocalDispatcher; > import org.ofbiz.service.ServiceContainer; > > public class JavaMailContainer implements Container { > @@ -77,6 +78,7 @@ public class JavaMailContainer implement > * @throws org.ofbiz.base.container.ContainerException > * > */ > + @Override > public void init(String[] args, String name, String configFile) throws > ContainerException { > this.name = name; > this.configFile = configFile; > @@ -91,6 +93,7 @@ public class JavaMailContainer implement > * @throws org.ofbiz.base.container.ContainerException > * > */ > + @Override > public boolean start() throws ContainerException { > ContainerConfig.Container cfg = ContainerConfig.getContainer(name, > configFile); > String dispatcherName = ContainerConfig.getPropertyValue(cfg, > "dispatcher-name", "JavaMailDispatcher"); > @@ -141,12 +144,14 @@ public class JavaMailContainer implement > * @throws org.ofbiz.base.container.ContainerException > * > */ > + @Override > public void stop() throws ContainerException { > // stop the poller > this.pollTimer.shutdown(); > Debug.logWarning("stop JavaMail poller", module); > } > > + @Override > public String getName() { > return name; > } > @@ -229,13 +234,32 @@ public class JavaMailContainer implement > host = props.getProperty("mail.host"); > } > } > - > + > + // check the port > + int port1 = 0; > + String strport = props.getProperty("mail." + protocol + ".port"); > + if (!UtilValidate.isEmpty(strport)) { > + port1 = Integer.valueOf(strport).intValue(); > + } > + if (port1==0) { > + strport = props.getProperty("mail.port"); > + if (!UtilValidate.isEmpty(strport)) { > + port1 = Integer.valueOf(props.getProperty("mail.port")) > + .intValue(); > + } > + } > + // override the port if have found one. > + if (port1!=0) { > + port = port1; > + } > + > if (Debug.verboseOn()) Debug.logVerbose("Update URL - " + protocol + > "://" + userName + "@" + host + ":" + port + "!" + password + ";" + file, > module); > return new URLName(protocol, host, port, file, userName, password); > } > > class LoggingStoreListener implements StoreListener { > > + @Override > public void notification(StoreEvent event) { > String typeString = ""; > switch (event.getMessageType()) { > @@ -261,6 +285,7 @@ public class JavaMailContainer implement > this.userLogin = userLogin; > } > > + @Override > public void run() { > if (UtilValidate.isNotEmpty(stores)) { > for (Map.Entry<Store, Session> entry: stores.entrySet()) { > >
