diff --git a/src/main/java/com/nis/domain/restful/CommonSourceFieldCfg.java b/src/main/java/com/nis/domain/restful/CommonSourceFieldCfg.java index fce27bd..b3d2336 100644 --- a/src/main/java/com/nis/domain/restful/CommonSourceFieldCfg.java +++ b/src/main/java/com/nis/domain/restful/CommonSourceFieldCfg.java @@ -20,6 +20,7 @@ public class CommonSourceFieldCfg { private String defaultVal; private String regexp; private Boolean isSrcInfo=false; + private Boolean isCfgId=false; public CommonSourceFieldCfg() { super(); @@ -37,7 +38,7 @@ public class CommonSourceFieldCfg { */ public CommonSourceFieldCfg(String fieldType, String srcName, String dstName, String range, Boolean isRequired, - String defaultVal, String regexp,Boolean isSrcInfo) { + String defaultVal, String regexp,Boolean isSrcInfo,Boolean isCfgId) { super(); this.fieldType = fieldType; this.srcName = srcName; @@ -47,6 +48,7 @@ public class CommonSourceFieldCfg { this.defaultVal = defaultVal; this.regexp = regexp; this.isSrcInfo = isSrcInfo; + this.isCfgId = isCfgId; } public String getSrcName() { @@ -117,4 +119,19 @@ public class CommonSourceFieldCfg { public void setIsSrcInfo(Boolean isSrcInfo) { this.isSrcInfo = isSrcInfo; } + + /** + * @return the isCfgId + */ + public Boolean getIsCfgId() { + return isCfgId; + } + + /** + * @param isCfgId the isCfgId to set + */ + public void setIsCfgId(Boolean isCfgId) { + this.isCfgId = isCfgId; + } + } diff --git a/src/main/java/com/nis/util/ReadCommSourceXmlUtil.java b/src/main/java/com/nis/util/ReadCommSourceXmlUtil.java index 7a7ed82..227e70b 100644 --- a/src/main/java/com/nis/util/ReadCommSourceXmlUtil.java +++ b/src/main/java/com/nis/util/ReadCommSourceXmlUtil.java @@ -94,6 +94,9 @@ public class ReadCommSourceXmlUtil { if (!StringUtil.isEmpty(field.attribute("isSrcInfo"))) { fieldCfg.setIsSrcInfo(Boolean.valueOf(field.attribute("isSrcInfo").getValue())); } + if (!StringUtil.isEmpty(field.attribute("isCfgId"))) { + fieldCfg.setIsCfgId(Boolean.valueOf(field.attribute("isCfgId").getValue())); + } cfgList.add(fieldCfg); } commonSourceCfgMap.put(serviceId.trim(), cfgList); diff --git a/src/main/java/com/nis/web/service/restful/ConfigJedisServiceimpl.java b/src/main/java/com/nis/web/service/restful/ConfigJedisServiceimpl.java index 3992aa0..4c58145 100644 --- a/src/main/java/com/nis/web/service/restful/ConfigJedisServiceimpl.java +++ b/src/main/java/com/nis/web/service/restful/ConfigJedisServiceimpl.java @@ -179,9 +179,15 @@ public class ConfigJedisServiceimpl implements ConfigRedisService { } catch (Exception e) { transaction.discard(); - String error = "保存非maat类配置发生了异常," + e.getMessage(); -// logger.error(error); - throw new ServiceRuntimeException(error, RestBusinessCode.SaveDataInError.getValue()); + + if (e instanceof ServiceRuntimeException) { + throw e; + }else { + String error = "保存非maat类配置发生了异常," + e.getMessage(); +// logger.error(error); + throw new ServiceRuntimeException(error, RestBusinessCode.SaveDataInError.getValue()); + } + } finally { // 释放连接到连接池 JedisUtils.returnResource(resource); @@ -525,9 +531,13 @@ public class ConfigJedisServiceimpl implements ConfigRedisService { throw new ServiceRuntimeException(error, RestBusinessCode.CannotConnectionRedis.getValue()); } catch (Exception e) { transaction.discard(); - String error = "保存maat类配置发生了异常" + e.getMessage(); - logger.error(error); - throw new ServiceRuntimeException(error, RestBusinessCode.SaveDataInError.getValue()); + if (e instanceof ServiceRuntimeException) { + throw e; + }else { + String error = "保存maat类配置发生了异常" + e.getMessage(); + logger.error(error); + throw new ServiceRuntimeException(error, RestBusinessCode.SaveDataInError.getValue()); + } } finally { // 释放连接到连接池 JedisUtils.returnResource(resource); @@ -942,7 +952,13 @@ public class ConfigJedisServiceimpl implements ConfigRedisService { transaction.discard(); String error = "删除非maat类配置发生了异常," + e.getMessage(); // logger.error(error); - throw new ServiceRuntimeException(error, RestBusinessCode.DeleteDataInError.getValue()); + if (e instanceof ServiceRuntimeException) { + throw e; + }else { + throw new ServiceRuntimeException(error, RestBusinessCode.DeleteDataInError.getValue()); + } + + } finally { // 释放连接到连接池 JedisUtils.returnResource(resource); diff --git a/src/main/java/com/nis/web/service/restful/ConfigSourcesService.java b/src/main/java/com/nis/web/service/restful/ConfigSourcesService.java index 9a3abcb..ffbd431 100644 --- a/src/main/java/com/nis/web/service/restful/ConfigSourcesService.java +++ b/src/main/java/com/nis/web/service/restful/ConfigSourcesService.java @@ -697,7 +697,15 @@ public class ConfigSourcesService extends BaseService { checkOptForUpdate(srcMap); validIdMap.put(srcMap.get("isValid").toString(), srcMap.get("isValid").toString()); Integer service = Integer.valueOf(srcMap.get("service").toString()); - Long cfgId = Long.valueOf(srcMap.get("cfgId").toString()); + + List list = ReadCommSourceXmlUtil.getCommonSourceCfgByService(service+""); + String srcName="cfgId"; + for (CommonSourceFieldCfg commonSourceFieldCfg : list) { + if (commonSourceFieldCfg.getIsCfgId()) { + srcName = commonSourceFieldCfg.getSrcName(); + } + } + Long cfgId = Long.valueOf(srcMap.get(srcName).toString()); if (cfgMap.containsKey(service)) { cfgMap.get(service).add(cfgId); } else { @@ -736,7 +744,8 @@ public class ConfigSourcesService extends BaseService { configRedisService.delUnMaatConfig(restMap,validIdMap.containsKey("0")?true:false); } catch (Exception e) { // TODO: handle exception - throw new ServiceRuntimeException(RestBusinessCode.service_runtime_error.getErrorReason(),RestBusinessCode.service_runtime_error.getValue()); + throw e; + //throw new ServiceRuntimeException(RestBusinessCode.service_runtime_error.getErrorReason(),RestBusinessCode.service_runtime_error.getValue()); } } @@ -749,25 +758,31 @@ public class ConfigSourcesService extends BaseService { * @throws Exception */ private void checkOptForUpdate(Map srcMap) throws Exception{ - String cfgId = srcMap.get("cfgId").toString(); - String service = srcMap.get("service").toString(); - String isValid = srcMap.get("isValid").toString(); - if (StringUtil.isEmpty(cfgId)) { - throw new RestServiceException(RestBusinessCode.CfgIdIsNull.getErrorReason(),RestBusinessCode.CfgIdIsNull.getValue()); - } else if (!StringUtil.isNumeric(cfgId)) { - throw new RestServiceException("cfgId字段格式不正确,"+RestBusinessCode.MastNumberic.getErrorReason(),RestBusinessCode.MastNumberic.getValue()); - } + Object service = srcMap.get("service"); + Object isValid = srcMap.get("isValid"); if (StringUtil.isEmpty(service)) { throw new RestServiceException(RestBusinessCode.ServiceIsNull.getErrorReason(),RestBusinessCode.ServiceIsNull.getValue()); - } else if (!StringUtil.isNumeric(service)) { + } else if (!StringUtil.isNumeric(service.toString())) { throw new RestServiceException("service字段格式不正确,"+RestBusinessCode.MastNumberic.getErrorReason(),RestBusinessCode.MastNumberic.getValue()); } - + List list = ReadCommSourceXmlUtil.getCommonSourceCfgByService(service+""); + String srcName="cfgId"; + for (CommonSourceFieldCfg commonSourceFieldCfg : list) { + if (commonSourceFieldCfg.getIsCfgId()) { + srcName = commonSourceFieldCfg.getSrcName(); + } + } + Object cfgId = srcMap.get(srcName); + if (StringUtil.isEmpty(cfgId)) { + throw new RestServiceException(RestBusinessCode.CfgIdIsNull.getErrorReason(),RestBusinessCode.CfgIdIsNull.getValue()); + } else if (!StringUtil.isNumeric(cfgId.toString())) { + throw new RestServiceException("cfgId字段格式不正确,"+RestBusinessCode.MastNumberic.getErrorReason(),RestBusinessCode.MastNumberic.getValue()); + } if (StringUtil.isEmpty(isValid)) { throw new RestServiceException("配置id为" + srcMap.get("cfgId") + "的isValid字段不能为空",RestBusinessCode.IsValidIsNull.getValue()); } else { - if (!StringUtil.isNumeric(service)) { + if (!StringUtil.isNumeric(service.toString())) { throw new RestServiceException(RestBusinessCode.IsValidInWrongRange.getErrorReason(),RestBusinessCode.IsValidInWrongRange.getValue()); } //配置取消改为状态更新(停/启用) diff --git a/src/main/resources/commonSources/applicationConfig-parser.schema.xsd b/src/main/resources/commonSources/applicationConfig-parser.schema.xsd index f8a376e..4f10c1b 100644 --- a/src/main/resources/commonSources/applicationConfig-parser.schema.xsd +++ b/src/main/resources/commonSources/applicationConfig-parser.schema.xsd @@ -15,6 +15,12 @@ + + + + + + diff --git a/src/main/resources/commonSources/applicationConfig-parser.xml b/src/main/resources/commonSources/applicationConfig-parser.xml index da65579..cd675ea 100644 --- a/src/main/resources/commonSources/applicationConfig-parser.xml +++ b/src/main/resources/commonSources/applicationConfig-parser.xml @@ -14,7 +14,7 @@ - + @@ -42,7 +42,7 @@ - + @@ -59,7 +59,7 @@ - + @@ -70,7 +70,7 @@ - + @@ -88,7 +88,7 @@ - + @@ -110,7 +110,7 @@ - + @@ -132,14 +132,14 @@ - + - + - + @@ -147,7 +147,7 @@ - + diff --git a/src/main/resources/maatXml/applicationConfig-maatRedis.xml b/src/main/resources/maatXml/applicationConfig-maatRedis.xml index 580fd68..f4d233c 100644 --- a/src/main/resources/maatXml/applicationConfig-maatRedis.xml +++ b/src/main/resources/maatXml/applicationConfig-maatRedis.xml @@ -138,8 +138,8 @@ - EFFECTIVE_RULE;:;{un_maat_table_name};,;[cfg_id] - [keyring_id];\t;[service];\t;[keyring_name];\t;[keyring_type];\t;[private_key_file];\t;[publici_key_file];\t;[expire_after];\t;[kublic_key_algo];\t;[crl];\t;[is_valid];\t;[op_time]; 0;\n + EFFECTIVE_RULE;:;{un_maat_table_name};,;[keyring_id] + [keyring_id];\t;[service];\t;[keyring_name];\t;[keyring_type];\t;[private_key_file];\t;[public_key_file];\t;[expire_after];\t;[public_key_algo];\t;[crl];\t;[is_valid];\t;[op_time]; 0;\n 1 @@ -158,7 +158,7 @@ - EFFECTIVE_RULE;:;{un_maat_table_name};,;[cfg_id] + EFFECTIVE_RULE;:;{un_maat_table_name};,;[file_id] [file_id];\t;[service];\t;[file_desc];\t;[content_type];\t;[content_length];\t;[file_path];\t;[is_valid];\t;[op_time]; 0;\n