diff --git a/src/main/java/com/nis/web/service/configuration/IpCfgService.java b/src/main/java/com/nis/web/service/configuration/IpCfgService.java index e41e94697..734a653f9 100644 --- a/src/main/java/com/nis/web/service/configuration/IpCfgService.java +++ b/src/main/java/com/nis/web/service/configuration/IpCfgService.java @@ -4,15 +4,16 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Map; +import java.util.Properties; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.nis.domain.FunctionRegionDict; -import com.nis.domain.SysDataDictionaryItem; import com.nis.domain.callback.InlineIp; import com.nis.domain.configuration.AreaIpCfg; import com.nis.domain.configuration.BaseIpCfg; @@ -27,6 +28,7 @@ import com.nis.domain.maat.ToMaatBean; import com.nis.domain.maat.ToMaatResult; import com.nis.exceptions.MaatConvertException; import com.nis.util.ConfigServiceUtil; +import com.nis.util.Configurations; import com.nis.util.Constants; import com.nis.util.DictUtils; import com.nis.util.StringUtil; @@ -161,20 +163,16 @@ public class IpCfgService extends CrudService { List dictList = DictUtils.getFunctionRegionDictList(cfg.getFunctionId()); int maatType=0; //判断下发类型是走maat还是callback - - List maatServiceList = DictUtils.getDictList("MAAT_SERVICE"); - for(SysDataDictionaryItem maatService:maatServiceList){ - if(Integer.parseInt(maatService.getItemCode())==cfg.getServiceId().intValue()){ - for(FunctionRegionDict f:dictList){ - if(maatService.getItemValue().equals(f.getConfigRegionValue())){ - maatType=f.getIsMaat(); - break; - } + String regionValue=cfg.getCfgType(); + if(regionValue!=null) { + for(FunctionRegionDict region:dictList) { + if(regionValue.equals(region.getConfigRegionValue())) { + maatType=region.getIsMaat(); + break; } - break; } } - + Properties props=this.getMsgProp(); if(cfg.getIsAudit()==Constants.AUDIT_YES){ if(maatType==Constants.CALLBACK_TYPE){ List ipList=new ArrayList<>(); @@ -251,6 +249,8 @@ public class IpCfgService extends CrudService { logger.error("IP配置配置下发失败",e); throw e; } + }else { + throw new MaatConvertException(":"+props.getProperty("unknown_cfg_type")); } }else if(cfg.getIsAudit()==Constants.AUDIT_NOT_YES){ if(maatType==Constants.CALLBACK_TYPE){ @@ -291,6 +291,8 @@ public class IpCfgService extends CrudService { logger.info("IP管控取消配置失败"); throw e; } + }else { + throw new MaatConvertException(":"+props.getProperty("unknown_cfg_type")); } } } @@ -483,4 +485,26 @@ public class IpCfgService extends CrudService { // TODO Auto-generated method stub return ipCfgDao.getListByCfgIdWithName(tablename,functionId,ids); } + /** + * 获取国际化配置文件 + * @return + */ + public Properties getMsgProp(){ + Properties msgProp = new Properties(); + try { + String language = LocaleContextHolder.getLocale().getLanguage(); + if(language.equals("zh_cn")||language.equals("zh")){ + msgProp.load(Configurations.class.getResourceAsStream("/messages/message_zh_CN.properties")); + }else if(language.equals("ru")){ + msgProp.load(Configurations.class.getResourceAsStream("/messages/message_ru.properties")); + }else{ + msgProp.load(Configurations.class.getResourceAsStream("/messages/message_en.properties")); + } + + } catch (Exception e) { + msgProp = null; + logger.error("未知i18n消息配置文件,请确定文件是否存在!",e); + } + return msgProp; + } } diff --git a/src/main/resources/messages/message_en.properties b/src/main/resources/messages/message_en.properties index 38ab64b37..c8fbc0a8f 100644 --- a/src/main/resources/messages/message_en.properties +++ b/src/main/resources/messages/message_en.properties @@ -1056,4 +1056,5 @@ Maintenance=Advanced Proxy=Proxy selective=Selective ip_protocol=IP Protocol -max_shouldnot_less_than_min=The max item should not be less than the min item. \ No newline at end of file +max_shouldnot_less_than_min=The max item should not be less than the min item. +unknown_cfg_type=Unknown configuration type. \ No newline at end of file diff --git a/src/main/resources/messages/message_ru.properties b/src/main/resources/messages/message_ru.properties index 0cd1cce84..43a772f3f 100644 --- a/src/main/resources/messages/message_ru.properties +++ b/src/main/resources/messages/message_ru.properties @@ -860,4 +860,5 @@ isp_report=Isp Report show_more=Show More ratelimit_limit=Limit Rate must between 0 and 100 -max_shouldnot_less_than_min=The max item should not be less than the min item. \ No newline at end of file +max_shouldnot_less_than_min=The max item should not be less than the min item. +unknown_cfg_type=Unknown configuration type. \ No newline at end of file diff --git a/src/main/resources/messages/message_zh_CN.properties b/src/main/resources/messages/message_zh_CN.properties index 03d12d604..3546f45dc 100644 --- a/src/main/resources/messages/message_zh_CN.properties +++ b/src/main/resources/messages/message_zh_CN.properties @@ -1049,4 +1049,5 @@ traffic_website_type_chart=\u7F51\u7AD9\u5206\u7C7B\u6D41\u91CF\u7EDF\u8BA1\u56F website=\u7F51\u7AD9\u540D\u79F0 #===============dashboard end=================================== ratelimit_limit=\u9650\u901F\u6BD4\u4F8B\u5FC5\u987B\u4ECB\u4E8E0\u5230100\#\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=dashboard end\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\=\= -max_shouldnot_less_than_min=\u6700\u5927\u9879\u4E0D\u80FD\u5C0F\u4E8E\u6700\u5C0F\u9879 \ No newline at end of file +max_shouldnot_less_than_min=\u6700\u5927\u9879\u4E0D\u80FD\u5C0F\u4E8E\u6700\u5C0F\u9879 +unknown_cfg_type=\u672A\u77E5\u7684\u914D\u7F6E\u7C7B\u578B \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/views/cfg/common/domainList.jsp b/src/main/webapp/WEB-INF/views/cfg/common/domainList.jsp index f51f4f028..795b96f19 100644 --- a/src/main/webapp/WEB-INF/views/cfg/common/domainList.jsp +++ b/src/main/webapp/WEB-INF/views/cfg/common/domainList.jsp @@ -88,10 +88,9 @@
- - - - + + +
@@ -402,12 +401,12 @@ - - - - - - + + + + + + ${cfg.creatorName } diff --git a/src/main/webapp/WEB-INF/views/cfg/common/ipForm.jsp b/src/main/webapp/WEB-INF/views/cfg/common/ipForm.jsp index 4b271edf8..05bea4afc 100644 --- a/src/main/webapp/WEB-INF/views/cfg/common/ipForm.jsp +++ b/src/main/webapp/WEB-INF/views/cfg/common/ipForm.jsp @@ -51,7 +51,7 @@ $(function(){ $(element).parents(".form-group").find("div[for='"+element.attr("name")+"']").append(error); }, submitHandler: function(form){ - if($("#dnsStrategyId")){ + if($("#dnsStrategyId")&&$("#dnsStrategyId").val()){ $("#cfgRegionCode").val($("#cfgRegionCodeMaat").val()); $("#cfgType").val($("#cfgTypeMaat").val()); } @@ -106,7 +106,7 @@ $(function(){ - + diff --git a/src/main/webapp/WEB-INF/views/cfg/ipaddr/ipForm.jsp b/src/main/webapp/WEB-INF/views/cfg/ipaddr/ipForm.jsp index 470ef78d6..daee16f48 100644 --- a/src/main/webapp/WEB-INF/views/cfg/ipaddr/ipForm.jsp +++ b/src/main/webapp/WEB-INF/views/cfg/ipaddr/ipForm.jsp @@ -62,10 +62,6 @@ $(function(){ $(element).parents(".form-group").find("div[for='"+element.attr("name")+"']").append(error); }, submitHandler: function(form){ - if($("#dnsStrategyId")){ - $("#cfgRegionCode").val($("#cfgRegionCodeMaat").val()); - $("#cfgType").val($("#cfgTypeMaat").val()); - } loading(''); form.submit(); }, @@ -117,7 +113,7 @@ $(function(){ - + diff --git a/src/main/webapp/WEB-INF/views/cfg/ipsec/ipForm.jsp b/src/main/webapp/WEB-INF/views/cfg/ipsec/ipForm.jsp index 5e121147a..3b86fa109 100644 --- a/src/main/webapp/WEB-INF/views/cfg/ipsec/ipForm.jsp +++ b/src/main/webapp/WEB-INF/views/cfg/ipsec/ipForm.jsp @@ -55,10 +55,6 @@ $(function(){ $(element).parents(".form-group").find("div[for='"+element.attr("name")+"']").append(error); }, submitHandler: function(form){ - if($("#dnsStrategyId")){ - $("#cfgRegionCode").val($("#cfgRegionCodeMaat").val()); - $("#cfgType").val($("#cfgTypeMaat").val()); - } loading(''); form.submit(); }, @@ -111,7 +107,7 @@ $(function(){ - + diff --git a/src/main/webapp/WEB-INF/views/cfg/whitelist/domainList.jsp b/src/main/webapp/WEB-INF/views/cfg/whitelist/domainList.jsp index 72620c50f..889efea30 100644 --- a/src/main/webapp/WEB-INF/views/cfg/whitelist/domainList.jsp +++ b/src/main/webapp/WEB-INF/views/cfg/whitelist/domainList.jsp @@ -71,10 +71,9 @@
- - - - + + +
@@ -217,12 +216,12 @@ - - - - - - + + + + + + ${cfg.creatorName }