The Unified and Autonomous Development Platform
Merge branch 'stable' into buildspec-yaml
Robin Shen84450aa3cbc4
diff --cc server-core/pom.xmlindex 4a8cff7a7a,a925a400a2..565ba31c77--- a/server-core/pom.xml+++ b/server-core/pom.xml@@@ -1,330 -1,330 +1,330 @@@--<?xml version="1.0" encoding="UTF-8"?>--<project xmlns="http://maven.apache.org/POM/4.0.0"-- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"-- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">-- <modelVersion>4.0.0</modelVersion>-- <artifactId>server-core</artifactId>-- <parent>-- <groupId>io.onedev</groupId>-- <artifactId>server</artifactId>- <version>3.1.0</version>- <version>3.0.11</version>-- </parent>-- <build>-- <plugins>-- <plugin>-- <groupId>org.antlr</groupId>-- <artifactId>antlr4-maven-plugin</artifactId>-- </plugin>-- </plugins>-- </build>-- <dependencies>-- <dependency>-- <groupId>io.onedev</groupId>-- <artifactId>commons-launcher-loader</artifactId>-- </dependency>-- <dependency>-- <groupId>io.onedev</groupId>-- <artifactId>commons-launcher-loader</artifactId>-- <type>test-jar</type>-- <scope>test</scope>-- </dependency>-- <dependency>-- <groupId>io.onedev</groupId>-- <artifactId>commons-codeassist</artifactId>-- </dependency>-- <dependency>-- <groupId>io.onedev</groupId>-- <artifactId>commons-jsymbol</artifactId>-- </dependency>-- <dependency>-- <groupId>io.onedev</groupId>-- <artifactId>commons-jsyntax</artifactId>-- </dependency>-- <dependency>-- <groupId>commons-codec</groupId>-- <artifactId>commons-codec</artifactId>-- </dependency>-- <dependency>-- <groupId>org.apache.commons</groupId>-- <artifactId>commons-compress</artifactId>-- </dependency>-- <dependency>-- <groupId>com.google.guava</groupId>-- <artifactId>guava</artifactId>-- </dependency>-- <dependency>-- <groupId>org.jetbrains.xodus</groupId>-- <artifactId>xodus-entity-store</artifactId>-- </dependency>-- <dependency>-- <groupId>org.apache.tika</groupId>-- <artifactId>tika-core</artifactId>-- </dependency>-- <dependency>-- <groupId>org.apache.commons</groupId>-- <artifactId>commons-email</artifactId>-- </dependency>-- <dependency>-- <groupId>org.apache.velocity</groupId>-- <artifactId>velocity</artifactId>-- </dependency>-- <dependency>-- <groupId>commons-httpclient</groupId>-- <artifactId>commons-httpclient</artifactId>-- </dependency>-- <dependency>-- <groupId>joda-time</groupId>-- <artifactId>joda-time</artifactId>-- </dependency>-- <dependency>-- <groupId>org.yaml</groupId>-- <artifactId>snakeyaml</artifactId>-- </dependency>-- <dependency>-- <groupId>org.bouncycastle</groupId>-- <artifactId>bcprov-jdk15on</artifactId>-- </dependency>-- <dependency>-- <groupId>org.unbescape</groupId>-- <artifactId>unbescape</artifactId>-- </dependency>-- <dependency>-- <groupId>org.quartz-scheduler</groupId>-- <artifactId>quartz</artifactId>-- <exclusions>-- <exclusion>-- <groupId>c3p0</groupId>-- <artifactId>c3p0</artifactId>-- </exclusion>-- </exclusions>-- </dependency>-- <dependency>-- <groupId>org.webjars</groupId>-- <artifactId>font-awesome</artifactId>-- <exclusions>-- <exclusion>-- <groupId>org.webjars</groupId>-- <artifactId>bootstrap</artifactId>-- </exclusion>-- </exclusions>-- </dependency>-- <dependency>-- <groupId>org.webjars.npm</groupId>-- <artifactId>codemirror</artifactId>-- </dependency>-- <dependency>-- <groupId>org.apache.shiro</groupId>-- <artifactId>shiro-core</artifactId>-- <exclusions>-- <exclusion>-- <groupId>org.slf4j</groupId>-- <artifactId>slf4j-api</artifactId>-- </exclusion>-- </exclusions>-- </dependency>-- <dependency>-- <artifactId>lucene-core</artifactId>-- <groupId>org.apache.lucene</groupId>-- </dependency>-- <dependency>-- <artifactId>lucene-queries</artifactId>-- <groupId>org.apache.lucene</groupId>-- </dependency>-- <dependency>-- <artifactId>lucene-analyzers-common</artifactId>-- <groupId>org.apache.lucene</groupId>-- </dependency>-- <dependency>-- <groupId>org.apache.shiro</groupId>-- <artifactId>shiro-web</artifactId>-- </dependency>-- <dependency>-- <groupId>org.apache.shiro</groupId>-- <artifactId>shiro-guice</artifactId>-- </dependency>-- <dependency>-- <groupId>javax.xml.bind</groupId>-- <artifactId>jaxb-api</artifactId>-- </dependency>-- <dependency>-- <groupId>org.glassfish</groupId>-- <artifactId>javax.el</artifactId>-- </dependency>-- <dependency>-- <groupId>org.hsqldb</groupId>-- <artifactId>hsqldb</artifactId>-- </dependency>-- <dependency>-- <groupId>jaxen</groupId>-- <artifactId>jaxen</artifactId>-- </dependency>-- <dependency>-- <groupId>com.thoughtworks.xstream</groupId>-- <artifactId>xstream</artifactId>-- </dependency>-- <dependency>-- <groupId>com.joestelmach</groupId>-- <artifactId>natty</artifactId>-- </dependency>-- <dependency>-- <groupId>org.codehaus.groovy</groupId>-- <artifactId>groovy</artifactId>-- </dependency>-- <dependency>-- <groupId>com.googlecode.juniversalchardet</groupId>-- <artifactId>juniversalchardet</artifactId>-- </dependency>-- <dependency>-- <groupId>com.vladsch.flexmark</groupId>-- <artifactId>flexmark</artifactId>-- </dependency>-- <dependency>-- <groupId>com.vladsch.flexmark</groupId>-- <artifactId>flexmark-ext-autolink</artifactId>-- </dependency>-- <dependency>-- <groupId>com.vladsch.flexmark</groupId>-- <artifactId>flexmark-ext-anchorlink</artifactId>-- </dependency>-- <dependency>-- <groupId>com.vladsch.flexmark</groupId>-- <artifactId>flexmark-ext-definition</artifactId>-- </dependency>-- <dependency>-- <groupId>com.vladsch.flexmark</groupId>-- <artifactId>flexmark-ext-tables</artifactId>-- </dependency>-- <dependency>-- <groupId>com.vladsch.flexmark</groupId>-- <artifactId>flexmark-ext-gfm-tasklist</artifactId>-- </dependency>-- <dependency>-- <groupId>com.vladsch.flexmark</groupId>-- <artifactId>flexmark-ext-toc</artifactId>-- </dependency>-- <dependency>-- <groupId>org.eclipse.jgit</groupId>-- <artifactId>org.eclipse.jgit.http.server</artifactId>-- </dependency>-- <dependency>-- <groupId>org.eclipse.jgit</groupId>-- <artifactId>org.eclipse.jgit.archive</artifactId>-- </dependency>-- <dependency>-- <groupId>org.eclipse.jetty</groupId>-- <artifactId>jetty-server</artifactId>-- </dependency>-- <dependency>-- <groupId>org.eclipse.jetty</groupId>-- <artifactId>jetty-servlets</artifactId>-- </dependency>-- <dependency>-- <groupId>org.eclipse.jetty</groupId>-- <artifactId>jetty-servlet</artifactId>-- </dependency>-- <dependency>-- <groupId>org.eclipse.jetty.websocket</groupId>-- <artifactId>websocket-server</artifactId>-- </dependency>-- <dependency>-- <groupId>org.glassfish.jersey.containers</groupId>-- <artifactId>jersey-container-servlet</artifactId>-- </dependency>-- <dependency>-- <groupId>org.glassfish.jersey.ext</groupId>-- <artifactId>jersey-bean-validation</artifactId>-- </dependency>-- <dependency>-- <groupId>org.hibernate</groupId>-- <artifactId>hibernate-validator</artifactId>-- </dependency>-- <dependency>-- <groupId>org.apache.wicket</groupId>-- <artifactId>wicket-core</artifactId>-- </dependency>-- <dependency>-- <groupId>org.apache.wicket</groupId>-- <artifactId>wicket-extensions</artifactId>-- </dependency>-- <dependency>-- <groupId>org.apache.wicket</groupId>-- <artifactId>wicket-request</artifactId>-- </dependency>-- <dependency>-- <groupId>org.apache.wicket</groupId>-- <artifactId>wicket-util</artifactId>-- </dependency>-- <dependency>-- <groupId>org.apache.wicket</groupId>-- <artifactId>wicket-devutils</artifactId>-- </dependency>-- <dependency>-- <groupId>org.apache.wicket</groupId>-- <artifactId>wicket-native-websocket-core</artifactId>-- </dependency>-- <dependency>-- <groupId>de.agilecoders.wicket</groupId>-- <artifactId>wicket-bootstrap-core</artifactId>-- </dependency>-- <dependency>-- <groupId>de.agilecoders.wicket</groupId>-- <artifactId>wicket-bootstrap-extensions</artifactId>-- </dependency>-- <dependency>-- <groupId>commons-fileupload</groupId>-- <artifactId>commons-fileupload</artifactId>-- </dependency>-- <dependency>-- <groupId>commons-validator</groupId>-- <artifactId>commons-validator</artifactId>-- </dependency>-- <dependency>-- <groupId>org.ocpsoft.prettytime</groupId>-- <artifactId>prettytime</artifactId>-- </dependency>-- <dependency>-- <groupId>org.apache.httpcomponents</groupId>-- <artifactId>httpclient</artifactId>-- </dependency>-- <dependency>-- <groupId>org.glassfish.hk2</groupId>-- <artifactId>guice-bridge</artifactId>-- </dependency>-- <dependency>-- <groupId>org.hibernate</groupId>-- <artifactId>hibernate-core</artifactId>-- </dependency>-- <dependency>-- <groupId>org.hibernate</groupId>-- <artifactId>hibernate-jcache</artifactId>-- </dependency>-- <dependency>-- <groupId>org.ehcache</groupId>-- <artifactId>ehcache</artifactId>-- </dependency>-- <dependency>-- <groupId>org.hibernate</groupId>-- <artifactId>hibernate-entitymanager</artifactId>-- </dependency>-- <dependency>-- <groupId>org.hibernate</groupId>-- <artifactId>hibernate-hikaricp</artifactId>-- </dependency>-- <dependency>-- <groupId>com.zaxxer</groupId>-- <artifactId>HikariCP</artifactId>-- </dependency>-- <dependency>-- <groupId>org.dom4j</groupId>-- <artifactId>dom4j</artifactId>-- </dependency>-- <dependency>-- <groupId>io.onedev</groupId>-- <artifactId>k8s-helper</artifactId>-- <version>1.0.12</version>-- </dependency>-- </dependencies>-- <properties>-- <moduleClass>io.onedev.server.CoreModule</moduleClass>-- </properties>--</project>++<?xml version="1.0" encoding="UTF-8"?>++<project xmlns="http://maven.apache.org/POM/4.0.0"++ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"++ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">++ <modelVersion>4.0.0</modelVersion>++ <artifactId>server-core</artifactId>++ <parent>++ <groupId>io.onedev</groupId>++ <artifactId>server</artifactId>++ <version>3.0.11</version>++ </parent>++ <build>++ <plugins>++ <plugin>++ <groupId>org.antlr</groupId>++ <artifactId>antlr4-maven-plugin</artifactId>++ </plugin>++ </plugins>++ </build>++ <dependencies>++ <dependency>++ <groupId>io.onedev</groupId>++ <artifactId>commons-launcher-loader</artifactId>++ </dependency>++ <dependency>++ <groupId>io.onedev</groupId>++ <artifactId>commons-launcher-loader</artifactId>++ <type>test-jar</type>++ <scope>test</scope>++ </dependency>++ <dependency>++ <groupId>io.onedev</groupId>++ <artifactId>commons-codeassist</artifactId>++ </dependency>++ <dependency>++ <groupId>io.onedev</groupId>++ <artifactId>commons-jsymbol</artifactId>++ </dependency>++ <dependency>++ <groupId>io.onedev</groupId>++ <artifactId>commons-jsyntax</artifactId>++ </dependency>++ <dependency>++ <groupId>commons-codec</groupId>++ <artifactId>commons-codec</artifactId>++ </dependency>++ <dependency>++ <groupId>org.apache.commons</groupId>++ <artifactId>commons-compress</artifactId>++ </dependency>++ <dependency>++ <groupId>com.google.guava</groupId>++ <artifactId>guava</artifactId>++ </dependency>++ <dependency>++ <groupId>org.jetbrains.xodus</groupId>++ <artifactId>xodus-entity-store</artifactId>++ </dependency>++ <dependency>++ <groupId>org.apache.tika</groupId>++ <artifactId>tika-core</artifactId>++ </dependency>++ <dependency>++ <groupId>org.apache.commons</groupId>++ <artifactId>commons-email</artifactId>++ </dependency>++ <dependency>++ <groupId>org.apache.velocity</groupId>++ <artifactId>velocity</artifactId>++ </dependency>++ <dependency>++ <groupId>commons-httpclient</groupId>++ <artifactId>commons-httpclient</artifactId>++ </dependency>++ <dependency>++ <groupId>joda-time</groupId>++ <artifactId>joda-time</artifactId>++ </dependency>++ <dependency>++ <groupId>org.yaml</groupId>++ <artifactId>snakeyaml</artifactId>++ </dependency>++ <dependency>++ <groupId>org.bouncycastle</groupId>++ <artifactId>bcprov-jdk15on</artifactId>++ </dependency>++ <dependency>++ <groupId>org.unbescape</groupId>++ <artifactId>unbescape</artifactId>++ </dependency>++ <dependency>++ <groupId>org.quartz-scheduler</groupId>++ <artifactId>quartz</artifactId>++ <exclusions>++ <exclusion>++ <groupId>c3p0</groupId>++ <artifactId>c3p0</artifactId>++ </exclusion>++ </exclusions>++ </dependency>++ <dependency>++ <groupId>org.webjars</groupId>++ <artifactId>font-awesome</artifactId>++ <exclusions>++ <exclusion>++ <groupId>org.webjars</groupId>++ <artifactId>bootstrap</artifactId>++ </exclusion>++ </exclusions>++ </dependency>++ <dependency>++ <groupId>org.webjars.npm</groupId>++ <artifactId>codemirror</artifactId>++ </dependency>++ <dependency>++ <groupId>org.apache.shiro</groupId>++ <artifactId>shiro-core</artifactId>++ <exclusions>++ <exclusion>++ <groupId>org.slf4j</groupId>++ <artifactId>slf4j-api</artifactId>++ </exclusion>++ </exclusions>++ </dependency>++ <dependency>++ <artifactId>lucene-core</artifactId>++ <groupId>org.apache.lucene</groupId>++ </dependency>++ <dependency>++ <artifactId>lucene-queries</artifactId>++ <groupId>org.apache.lucene</groupId>++ </dependency>++ <dependency>++ <artifactId>lucene-analyzers-common</artifactId>++ <groupId>org.apache.lucene</groupId>++ </dependency>++ <dependency>++ <groupId>org.apache.shiro</groupId>++ <artifactId>shiro-web</artifactId>++ </dependency>++ <dependency>++ <groupId>org.apache.shiro</groupId>++ <artifactId>shiro-guice</artifactId>++ </dependency>++ <dependency>++ <groupId>javax.xml.bind</groupId>++ <artifactId>jaxb-api</artifactId>++ </dependency>++ <dependency>++ <groupId>org.glassfish</groupId>++ <artifactId>javax.el</artifactId>++ </dependency>++ <dependency>++ <groupId>org.hsqldb</groupId>++ <artifactId>hsqldb</artifactId>++ </dependency>++ <dependency>++ <groupId>jaxen</groupId>++ <artifactId>jaxen</artifactId>++ </dependency>++ <dependency>++ <groupId>com.thoughtworks.xstream</groupId>++ <artifactId>xstream</artifactId>++ </dependency>++ <dependency>++ <groupId>com.joestelmach</groupId>++ <artifactId>natty</artifactId>++ </dependency>++ <dependency>++ <groupId>org.codehaus.groovy</groupId>++ <artifactId>groovy</artifactId>++ </dependency>++ <dependency>++ <groupId>com.googlecode.juniversalchardet</groupId>++ <artifactId>juniversalchardet</artifactId>++ </dependency>++ <dependency>++ <groupId>com.vladsch.flexmark</groupId>++ <artifactId>flexmark</artifactId>++ </dependency>++ <dependency>++ <groupId>com.vladsch.flexmark</groupId>++ <artifactId>flexmark-ext-autolink</artifactId>++ </dependency>++ <dependency>++ <groupId>com.vladsch.flexmark</groupId>++ <artifactId>flexmark-ext-anchorlink</artifactId>++ </dependency>++ <dependency>++ <groupId>com.vladsch.flexmark</groupId>++ <artifactId>flexmark-ext-definition</artifactId>++ </dependency>++ <dependency>++ <groupId>com.vladsch.flexmark</groupId>++ <artifactId>flexmark-ext-tables</artifactId>++ </dependency>++ <dependency>++ <groupId>com.vladsch.flexmark</groupId>++ <artifactId>flexmark-ext-gfm-tasklist</artifactId>++ </dependency>++ <dependency>++ <groupId>com.vladsch.flexmark</groupId>++ <artifactId>flexmark-ext-toc</artifactId>++ </dependency>++ <dependency>++ <groupId>org.eclipse.jgit</groupId>++ <artifactId>org.eclipse.jgit.http.server</artifactId>++ </dependency>++ <dependency>++ <groupId>org.eclipse.jgit</groupId>++ <artifactId>org.eclipse.jgit.archive</artifactId>++ </dependency>++ <dependency>++ <groupId>org.eclipse.jetty</groupId>++ <artifactId>jetty-server</artifactId>++ </dependency>++ <dependency>++ <groupId>org.eclipse.jetty</groupId>++ <artifactId>jetty-servlets</artifactId>++ </dependency>++ <dependency>++ <groupId>org.eclipse.jetty</groupId>++ <artifactId>jetty-servlet</artifactId>++ </dependency>++ <dependency>++ <groupId>org.eclipse.jetty.websocket</groupId>++ <artifactId>websocket-server</artifactId>++ </dependency>++ <dependency>++ <groupId>org.glassfish.jersey.containers</groupId>++ <artifactId>jersey-container-servlet</artifactId>++ </dependency>++ <dependency>++ <groupId>org.glassfish.jersey.ext</groupId>++ <artifactId>jersey-bean-validation</artifactId>++ </dependency>++ <dependency>++ <groupId>org.hibernate</groupId>++ <artifactId>hibernate-validator</artifactId>++ </dependency>++ <dependency>++ <groupId>org.apache.wicket</groupId>++ <artifactId>wicket-core</artifactId>++ </dependency>++ <dependency>++ <groupId>org.apache.wicket</groupId>++ <artifactId>wicket-extensions</artifactId>++ </dependency>++ <dependency>++ <groupId>org.apache.wicket</groupId>++ <artifactId>wicket-request</artifactId>++ </dependency>++ <dependency>++ <groupId>org.apache.wicket</groupId>++ <artifactId>wicket-util</artifactId>++ </dependency>++ <dependency>++ <groupId>org.apache.wicket</groupId>++ <artifactId>wicket-devutils</artifactId>++ </dependency>++ <dependency>++ <groupId>org.apache.wicket</groupId>++ <artifactId>wicket-native-websocket-core</artifactId>++ </dependency>++ <dependency>++ <groupId>de.agilecoders.wicket</groupId>++ <artifactId>wicket-bootstrap-core</artifactId>++ </dependency>++ <dependency>++ <groupId>de.agilecoders.wicket</groupId>++ <artifactId>wicket-bootstrap-extensions</artifactId>++ </dependency>++ <dependency>++ <groupId>commons-fileupload</groupId>++ <artifactId>commons-fileupload</artifactId>++ </dependency>++ <dependency>++ <groupId>commons-validator</groupId>++ <artifactId>commons-validator</artifactId>++ </dependency>++ <dependency>++ <groupId>org.ocpsoft.prettytime</groupId>++ <artifactId>prettytime</artifactId>++ </dependency>++ <dependency>++ <groupId>org.apache.httpcomponents</groupId>++ <artifactId>httpclient</artifactId>++ </dependency>++ <dependency>++ <groupId>org.glassfish.hk2</groupId>++ <artifactId>guice-bridge</artifactId>++ </dependency>++ <dependency>++ <groupId>org.hibernate</groupId>++ <artifactId>hibernate-core</artifactId>++ </dependency>++ <dependency>++ <groupId>org.hibernate</groupId>++ <artifactId>hibernate-jcache</artifactId>++ </dependency>++ <dependency>++ <groupId>org.ehcache</groupId>++ <artifactId>ehcache</artifactId>++ </dependency>++ <dependency>++ <groupId>org.hibernate</groupId>++ <artifactId>hibernate-entitymanager</artifactId>++ </dependency>++ <dependency>++ <groupId>org.hibernate</groupId>++ <artifactId>hibernate-hikaricp</artifactId>++ </dependency>++ <dependency>++ <groupId>com.zaxxer</groupId>++ <artifactId>HikariCP</artifactId>++ </dependency>++ <dependency>++ <groupId>org.dom4j</groupId>++ <artifactId>dom4j</artifactId>++ </dependency>++ <dependency>++ <groupId>io.onedev</groupId>++ <artifactId>k8s-helper</artifactId>++ <version>1.0.12</version>++ </dependency>++ </dependencies>++ <properties>++ <moduleClass>io.onedev.server.CoreModule</moduleClass>++ </properties>++</project>diff --cc server-core/src/main/java/io/onedev/server/migration/DataMigrator.javaindex 900f59a87b,e4f1dbb1fe..1395191585--- a/server-core/src/main/java/io/onedev/server/migration/DataMigrator.java+++ b/server-core/src/main/java/io/onedev/server/migration/DataMigrator.java@@@ -1662,7 -1672,19 +1672,19 @@@ public class DataMigratorelseforkedFroms.put(projectId, null);}- }+ } else if (file.getName().startsWith("Settings.xml")) {- VersionedDocument dom = VersionedDocument.fromFile(file);++ VersionedXmlDoc dom = VersionedXmlDoc.fromFile(file);+ for (Element element: dom.getRootElement().elements()) {+ if (element.elementTextTrim("key").equals("MAIL")) {+ Element valueElement = element.element("value");+ if (valueElement != null) {+ valueElement.addElement("enableStartTLS").setText("true");+ valueElement.element("enableSSL").detach();+ }+ }+ }+ dom.writeToFile(file, false);+ }}Map<Long, Long> forkedRoots = new HashMap<>();diff --cc server-core/src/main/java/io/onedev/server/notification/DefaultMailManager.javaindex c56072246a,bd452657d0..8f84a94eca--- a/server-core/src/main/java/io/onedev/server/notification/DefaultMailManager.java+++ b/server-core/src/main/java/io/onedev/server/notification/DefaultMailManager.java@@@ -1,126 -1,126 +1,126 @@@--package io.onedev.server.notification;----import java.net.InetAddress;--import java.net.UnknownHostException;--import java.util.Collection;--import java.util.concurrent.ExecutorService;----import javax.inject.Inject;--import javax.inject.Singleton;----import org.apache.commons.codec.CharEncoding;--import org.apache.commons.mail.EmailException;--import org.apache.commons.mail.HtmlEmail;--import org.slf4j.Logger;--import org.slf4j.LoggerFactory;----import io.onedev.commons.launcher.bootstrap.Bootstrap;--import io.onedev.server.entitymanager.SettingManager;--import io.onedev.server.model.support.administration.MailSetting;--import io.onedev.server.persistence.TransactionManager;--import io.onedev.server.persistence.annotation.Sessional;----@Singleton--public class DefaultMailManager implements MailManager {---- private static final Logger logger = LoggerFactory.getLogger(DefaultMailManager.class);---- private final SettingManager settingManager;---- private final TransactionManager transactionManager;---- private final ExecutorService executorService;---- @Inject-- public DefaultMailManager(TransactionManager transactionManager, SettingManager setingManager,-- ExecutorService executorService) {-- this.transactionManager = transactionManager;-- this.settingManager = setingManager;-- this.executorService = executorService;-- }---- @Sessional-- @Override-- public void sendMailAsync(Collection<String> toList, String subject, String body) {-- transactionManager.runAfterCommit(new Runnable() {---- @Override-- public void run() {-- executorService.execute(new Runnable() {---- @Override-- public void run() {-- try {-- sendMail(toList, subject, body);-- } catch (Exception e) {-- logger.error("Error sending email (to: " + toList + ", subject: " + subject + ")", e);-- }-- }---- });-- }---- });-- }---- @Override-- public void sendMail(MailSetting mailSetting, Collection<String> toList, String subject, String body) {-- if (toList.isEmpty())-- return;---- if (mailSetting == null)-- mailSetting = settingManager.getMailSetting();---- if (mailSetting != null) {-- HtmlEmail email = new HtmlEmail();-- email.setSocketConnectionTimeout(Bootstrap.SOCKET_CONNECT_TIMEOUT);---- if (mailSetting.getTimeout() != 0)-- email.setSocketTimeout(mailSetting.getTimeout()*1000);--- email.setStartTLSEnabled(true);- email.setSSLOnConnect(mailSetting.isEnableSSL());- email.setStartTLSEnabled(mailSetting.isEnableStartTLS());- email.setSSLOnConnect(false);-- email.setSSLCheckServerIdentity(false);---- String senderEmail = mailSetting.getSenderAddress();-- if (senderEmail == null) {-- String hostName;-- try {-- hostName = InetAddress.getLocalHost().getHostName();-- } catch (UnknownHostException e) {-- throw new RuntimeException(e);-- }-- senderEmail = "onedev@" + hostName;-- }-- try {-- email.setFrom(senderEmail);-- for (String address: toList)-- email.addTo(address);---- email.setHostName(mailSetting.getSmtpHost());-- email.setSmtpPort(mailSetting.getSmtpPort());-- email.setSslSmtpPort(String.valueOf(mailSetting.getSmtpPort()));-- String smtpUser = mailSetting.getSmtpUser();-- if (smtpUser != null)-- email.setAuthentication(smtpUser, mailSetting.getSmtpPassword());-- email.setCharset(CharEncoding.UTF_8);---- email.setSubject(subject);-- email.setHtmlMsg(body);---- logger.debug("Sending email (to: {}, subject: {})... ", toList, subject);-- email.send();-- } catch (EmailException e) {-- throw new RuntimeException(e);-- }-- } else {-- logger.warn("Unable to send mail as mail setting is not specified");-- }-- }---- @Override-- public void sendMail(Collection<String> toList, String subject, String body) {-- sendMail(settingManager.getMailSetting(), toList, subject, body);-- }----}++package io.onedev.server.notification;++++import java.net.InetAddress;++import java.net.UnknownHostException;++import java.util.Collection;++import java.util.concurrent.ExecutorService;++++import javax.inject.Inject;++import javax.inject.Singleton;++++import org.apache.commons.codec.CharEncoding;++import org.apache.commons.mail.EmailException;++import org.apache.commons.mail.HtmlEmail;++import org.slf4j.Logger;++import org.slf4j.LoggerFactory;++++import io.onedev.commons.launcher.bootstrap.Bootstrap;++import io.onedev.server.entitymanager.SettingManager;++import io.onedev.server.model.support.administration.MailSetting;++import io.onedev.server.persistence.TransactionManager;++import io.onedev.server.persistence.annotation.Sessional;++++@Singleton++public class DefaultMailManager implements MailManager {++++ private static final Logger logger = LoggerFactory.getLogger(DefaultMailManager.class);++++ private final SettingManager settingManager;++++ private final TransactionManager transactionManager;++++ private final ExecutorService executorService;++++ @Inject++ public DefaultMailManager(TransactionManager transactionManager, SettingManager setingManager,++ ExecutorService executorService) {++ this.transactionManager = transactionManager;++ this.settingManager = setingManager;++ this.executorService = executorService;++ }++++ @Sessional++ @Override++ public void sendMailAsync(Collection<String> toList, String subject, String body) {++ transactionManager.runAfterCommit(new Runnable() {++++ @Override++ public void run() {++ executorService.execute(new Runnable() {++++ @Override++ public void run() {++ try {++ sendMail(toList, subject, body);++ } catch (Exception e) {++ logger.error("Error sending email (to: " + toList + ", subject: " + subject + ")", e);++ }++ }++++ });++ }++++ });++ }++++ @Override++ public void sendMail(MailSetting mailSetting, Collection<String> toList, String subject, String body) {++ if (toList.isEmpty())++ return;++++ if (mailSetting == null)++ mailSetting = settingManager.getMailSetting();++++ if (mailSetting != null) {++ HtmlEmail email = new HtmlEmail();++ email.setSocketConnectionTimeout(Bootstrap.SOCKET_CONNECT_TIMEOUT);++++ if (mailSetting.getTimeout() != 0)++ email.setSocketTimeout(mailSetting.getTimeout()*1000);++++ email.setStartTLSEnabled(mailSetting.isEnableStartTLS());++ email.setSSLOnConnect(false);++ email.setSSLCheckServerIdentity(false);++++ String senderEmail = mailSetting.getSenderAddress();++ if (senderEmail == null) {++ String hostName;++ try {++ hostName = InetAddress.getLocalHost().getHostName();++ } catch (UnknownHostException e) {++ throw new RuntimeException(e);++ }++ senderEmail = "onedev@" + hostName;++ }++ try {++ email.setFrom(senderEmail);++ for (String address: toList)++ email.addTo(address);++++ email.setHostName(mailSetting.getSmtpHost());++ email.setSmtpPort(mailSetting.getSmtpPort());++ email.setSslSmtpPort(String.valueOf(mailSetting.getSmtpPort()));++ String smtpUser = mailSetting.getSmtpUser();++ if (smtpUser != null)++ email.setAuthentication(smtpUser, mailSetting.getSmtpPassword());++ email.setCharset(CharEncoding.UTF_8);++++ email.setSubject(subject);++ email.setHtmlMsg(body);++++ logger.debug("Sending email (to: {}, subject: {})... ", toList, subject);++ email.send();++ } catch (EmailException e) {++ throw new RuntimeException(e);++ }++ } else {++ logger.warn("Unable to send mail as mail setting is not specified");++ }++ }++++ @Override++ public void sendMail(Collection<String> toList, String subject, String body) {++ sendMail(settingManager.getMailSetting(), toList, subject, body);++ }++++}