This commit is contained in:
commit
58ba058041
|
@ -28,7 +28,7 @@ public interface ParamConstants {
|
||||||
}
|
}
|
||||||
|
|
||||||
enum Classify implements ParamConstants {
|
enum Classify implements ParamConstants {
|
||||||
MAIL("meter"),
|
MAIL("smtp"),
|
||||||
REGISTRY("registry");
|
REGISTRY("registry");
|
||||||
|
|
||||||
private String value;
|
private String value;
|
||||||
|
@ -86,14 +86,15 @@ public interface ParamConstants {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static enum MAIL {
|
enum MAIL {
|
||||||
HOST("meter.host", 1),
|
SERVER("smtp.server", 1),
|
||||||
PORT("meter.port", 2),
|
PORT("smtp.port", 2),
|
||||||
ACCOUNT("meter.account", 3),
|
ACCOUNT("smtp.account", 3),
|
||||||
PASSWORD("meter.password", 4),
|
PASSWORD("smtp.password", 4),
|
||||||
SSL("meter.ssl", 5),
|
SSL("smtp.ssl", 5),
|
||||||
TLS("meter.tls", 6),
|
TLS("smtp.tls", 6),
|
||||||
ANON("meter.anon", 7);
|
SMTP("smtp.smtp", 7);
|
||||||
|
/* ANON("smtp.anon", 7);*/
|
||||||
|
|
||||||
private String key;
|
private String key;
|
||||||
private Integer value;
|
private Integer value;
|
||||||
|
|
|
@ -4,21 +4,21 @@ import io.metersphere.base.domain.SystemParameter;
|
||||||
import io.metersphere.base.domain.SystemParameterExample;
|
import io.metersphere.base.domain.SystemParameterExample;
|
||||||
import io.metersphere.base.mapper.SystemParameterMapper;
|
import io.metersphere.base.mapper.SystemParameterMapper;
|
||||||
import io.metersphere.commons.constants.ParamConstants;
|
import io.metersphere.commons.constants.ParamConstants;
|
||||||
|
import io.metersphere.commons.exception.MSException;
|
||||||
import io.metersphere.commons.utils.EncryptUtils;
|
import io.metersphere.commons.utils.EncryptUtils;
|
||||||
|
import io.metersphere.i18n.Translator;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.apache.commons.lang3.BooleanUtils;
|
import org.apache.commons.lang3.BooleanUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.mail.javamail.JavaMailSenderImpl;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.mail.MessagingException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.springframework.mail.javamail.JavaMailSenderImpl;
|
|
||||||
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class SystemParameterService {
|
public class SystemParameterService {
|
||||||
|
@ -65,7 +65,7 @@ public class SystemParameterService {
|
||||||
public void testConnection(HashMap<String, String> hashMap) {
|
public void testConnection(HashMap<String, String> hashMap) {
|
||||||
JavaMailSenderImpl javaMailSender = new JavaMailSenderImpl();
|
JavaMailSenderImpl javaMailSender = new JavaMailSenderImpl();
|
||||||
javaMailSender.setDefaultEncoding("UTF-8");
|
javaMailSender.setDefaultEncoding("UTF-8");
|
||||||
javaMailSender.setHost(hashMap.get(ParamConstants.MAIL.PORT.getKey()));
|
javaMailSender.setHost(hashMap.get(ParamConstants.MAIL.SERVER.getKey()));
|
||||||
javaMailSender.setPort(Integer.valueOf(hashMap.get(ParamConstants.MAIL.PORT.getKey())));
|
javaMailSender.setPort(Integer.valueOf(hashMap.get(ParamConstants.MAIL.PORT.getKey())));
|
||||||
javaMailSender.setUsername(hashMap.get(ParamConstants.MAIL.ACCOUNT.getKey()));
|
javaMailSender.setUsername(hashMap.get(ParamConstants.MAIL.ACCOUNT.getKey()));
|
||||||
javaMailSender.setPassword(hashMap.get(ParamConstants.MAIL.PASSWORD.getKey()));
|
javaMailSender.setPassword(hashMap.get(ParamConstants.MAIL.PASSWORD.getKey()));
|
||||||
|
@ -78,6 +78,12 @@ public class SystemParameterService {
|
||||||
props.put("mail.smtp.starttls.enable", "true");
|
props.put("mail.smtp.starttls.enable", "true");
|
||||||
}
|
}
|
||||||
javaMailSender.setJavaMailProperties(props);
|
javaMailSender.setJavaMailProperties(props);
|
||||||
|
try {
|
||||||
|
javaMailSender.testConnection();
|
||||||
|
} catch (MessagingException e) {
|
||||||
|
MSException.throwException(Translator.get("connection_failed"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ cannot_be_null=\tCannot be empty
|
||||||
number=Number
|
number=Number
|
||||||
row=row
|
row=row
|
||||||
error=error
|
error=error
|
||||||
|
connection_failed=Connection failed
|
||||||
#user related
|
#user related
|
||||||
user_email_already_exists=User email already exists
|
user_email_already_exists=User email already exists
|
||||||
user_name_is_null=User name cannot be null
|
user_name_is_null=User name cannot be null
|
||||||
|
|
|
@ -13,6 +13,7 @@ password_is_null=密码不能为空
|
||||||
user_id_already_exists=用户id已存在
|
user_id_already_exists=用户id已存在
|
||||||
password_modification_failed=密码修改失败
|
password_modification_failed=密码修改失败
|
||||||
cannot_delete_current_user=无法删除当前登录用户
|
cannot_delete_current_user=无法删除当前登录用户
|
||||||
|
connection_failed=连接失败
|
||||||
#load test
|
#load test
|
||||||
edit_load_test_not_found=无法编辑测试,未找到测试:
|
edit_load_test_not_found=无法编辑测试,未找到测试:
|
||||||
run_load_test_not_found=无法运行测试,未找到测试:
|
run_load_test_not_found=无法运行测试,未找到测试:
|
||||||
|
@ -89,4 +90,3 @@ options=选项
|
||||||
please_input_workspace_member=请填写该工作空间相关人员
|
please_input_workspace_member=请填写该工作空间相关人员
|
||||||
test_case_report_template_repeat=同一工作空间下不能存在同名模版
|
test_case_report_template_repeat=同一工作空间下不能存在同名模版
|
||||||
plan_name_already_exists=测试计划名称已存在
|
plan_name_already_exists=测试计划名称已存在
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ cannot_be_null=不能為空
|
||||||
number=第
|
number=第
|
||||||
row=行
|
row=行
|
||||||
error=出錯
|
error=出錯
|
||||||
|
connection_failed=連接失敗
|
||||||
#user related
|
#user related
|
||||||
user_email_already_exists=用戶郵箱已存在
|
user_email_already_exists=用戶郵箱已存在
|
||||||
user_name_is_null=用戶名不能為空
|
user_name_is_null=用戶名不能為空
|
||||||
|
|
|
@ -125,13 +125,13 @@
|
||||||
},
|
},
|
||||||
testConnection(formInline) {
|
testConnection(formInline) {
|
||||||
let param = {
|
let param = {
|
||||||
"meter.host": this.formInline.host,
|
"smtp.server": this.formInline.host,
|
||||||
"meter.port": this.formInline.port,
|
"smtp.port": this.formInline.port,
|
||||||
"meter.account": this.formInline.account,
|
"smtp.account": this.formInline.account,
|
||||||
"meter.password": this.formInline.password,
|
"smtp.password": this.formInline.password,
|
||||||
"meter.ssl": this.SSL,
|
"smtp.ssl": this.SSL,
|
||||||
"meter.tls": this.TLS,
|
"smtp.tls": this.TLS,
|
||||||
"meter.smtp": this.SMTP,
|
"smtp.smtp": this.SMTP,
|
||||||
};
|
};
|
||||||
this.$refs[formInline].validate((valid) => {
|
this.$refs[formInline].validate((valid) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
|
@ -140,8 +140,10 @@
|
||||||
if (flag) {
|
if (flag) {
|
||||||
this.$success(this.$t('commons.connection_successful'));
|
this.$success(this.$t('commons.connection_successful'));
|
||||||
} else {
|
} else {
|
||||||
this.$message.error(this.$t('commons.connection_failed'));
|
this.$error(this.$t('commons.connection_failed'));
|
||||||
}
|
}
|
||||||
|
}).catch(() => {
|
||||||
|
this.$info(this.$t('commons.connection_failed'));
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
@ -160,13 +162,13 @@
|
||||||
this.showSave = false;
|
this.showSave = false;
|
||||||
this.show = true;
|
this.show = true;
|
||||||
let param = [
|
let param = [
|
||||||
{paramKey: "meter.host", paramValue: this.formInline.host, type: "text", sort: 1},
|
{paramKey: "smtp.host", paramValue: this.formInline.host, type: "text", sort: 1},
|
||||||
{paramKey: "meter.port", paramValue: this.formInline.port, type: "text", sort: 2},
|
{paramKey: "smtp.port", paramValue: this.formInline.port, type: "text", sort: 2},
|
||||||
{paramKey: "meter.account", paramValue: this.formInline.account, type: "text", sort: 3},
|
{paramKey: "smtp.account", paramValue: this.formInline.account, type: "text", sort: 3},
|
||||||
{paramKey: "meter.password", paramValue: this.formInline.password, type: "password", sort: 4},
|
{paramKey: "smtp.password", paramValue: this.formInline.password, type: "password", sort: 4},
|
||||||
{paramKey: "meter.ssl", paramValue: this.SSL, type: "text", sort: 5},
|
{paramKey: "smtp.ssl", paramValue: this.SSL, type: "text", sort: 5},
|
||||||
{paramKey: "meter.tls", paramValue: this.TLS, type: "text", sort: 6},
|
{paramKey: "smtp.tls", paramValue: this.TLS, type: "text", sort: 6},
|
||||||
{paramKey: "meter.smtp", paramValue: this.SMTP, type: "text", sort: 7}
|
{paramKey: "smtp.smtp", paramValue: this.SMTP, type: "text", sort: 7}
|
||||||
]
|
]
|
||||||
|
|
||||||
this.$refs[formInline].validate(valid => {
|
this.$refs[formInline].validate(valid => {
|
||||||
|
|
Loading…
Reference in New Issue