Compare commits
340 Commits
demo_appse
...
develop_20
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3fde460cc1 | ||
|
|
f79e9220b2 | ||
|
|
af1bff0472 | ||
|
|
025873ce76 | ||
|
|
28771355cc | ||
|
|
0629e8b1de | ||
|
|
8d7a6c69b6 | ||
|
|
fe3f632046 | ||
|
|
9527b41592 | ||
|
|
6312a65351 | ||
|
|
f6c37c7bda | ||
|
|
c81dd92aca | ||
|
|
9f4264d878 | ||
|
|
d4e153533a | ||
|
|
35ca1636ef | ||
|
|
44486b98cb | ||
|
|
ea456f83d0 | ||
|
|
b4f9eac0d3 | ||
|
|
54333afe0b | ||
|
|
48806bd775 | ||
|
|
23ae0f08d3 | ||
|
|
21ca3bc804 | ||
|
|
d9110dfa14 | ||
|
|
fd2d285b92 | ||
|
|
8a27636007 | ||
|
|
89336a3677 | ||
|
|
144900d6df | ||
|
|
ba758cab58 | ||
|
|
10fb06f5bf | ||
|
|
dd37178cfc | ||
|
|
46fff54557 | ||
|
|
f1fc6ee9aa | ||
|
|
dde951fe4a | ||
|
|
33fd4df21d | ||
|
|
1882d011cb | ||
|
|
cd977ed81a | ||
|
|
e8a5c506e9 | ||
|
|
f8e1b8f093 | ||
|
|
c30ab53f00 | ||
|
|
ea33bae40f | ||
|
|
d1082f539e | ||
|
|
c1188539b5 | ||
|
|
269f4e0644 | ||
|
|
3f6d6a6d60 | ||
|
|
00ffdd863c | ||
|
|
1eaa2e668b | ||
|
|
86c2d86565 | ||
|
|
35e491e20c | ||
|
|
ce8c273aa4 | ||
|
|
d00a855666 | ||
|
|
2b57e33d12 | ||
|
|
fa9edae028 | ||
|
|
d4ee7c7a42 | ||
|
|
eac5552be2 | ||
|
|
18c5567f58 | ||
|
|
b0a9982d54 | ||
|
|
8e724393e1 | ||
|
|
494fb0669a | ||
|
|
36d1fee141 | ||
|
|
999406cbd1 | ||
|
|
4107e0fb92 | ||
|
|
efd965f4ca | ||
|
|
6eecad82aa | ||
|
|
ab8c4448ce | ||
|
|
9ade865187 | ||
|
|
2aa3524104 | ||
|
|
35a1b72fee | ||
|
|
724eeef0f5 | ||
|
|
65d3f5013f | ||
|
|
b50d324303 | ||
|
|
26097409d6 | ||
|
|
6223c66618 | ||
|
|
0499fb845d | ||
|
|
30007d50d0 | ||
|
|
1221ce6a18 | ||
|
|
b9246ddeeb | ||
|
|
eda0103068 | ||
|
|
589cf100ee | ||
|
|
3b838aa838 | ||
|
|
b3abe1f0e5 | ||
|
|
0b1a51aa47 | ||
|
|
40e166510c | ||
|
|
47771e57e7 | ||
|
|
94f0bc56b8 | ||
|
|
0cf19aeab9 | ||
|
|
078b1a0071 | ||
|
|
728201cfbe | ||
|
|
8719ed0527 | ||
|
|
77716a9517 | ||
|
|
5e9400e723 | ||
|
|
541aaf4640 | ||
|
|
f773c95c0b | ||
|
|
77c7649b6a | ||
|
|
e8dd565262 | ||
|
|
fe90fd9935 | ||
|
|
827a43d843 | ||
|
|
34a6cb5ed4 | ||
|
|
42724b94de | ||
|
|
97d1a52d3c | ||
|
|
28f07f00f2 | ||
|
|
c716cb1fc3 | ||
|
|
1191db5fbe | ||
|
|
5b63b0237e | ||
|
|
99c3c8c84f | ||
|
|
865811b9b2 | ||
|
|
5a5bdddba4 | ||
|
|
6bd04a92ce | ||
|
|
e69992d712 | ||
|
|
4725a3ff90 | ||
|
|
6ac930fd22 | ||
|
|
7b5c9092d1 | ||
|
|
1cf9594bd2 | ||
|
|
cc8cb48da1 | ||
|
|
b8d1bd9ab9 | ||
|
|
3acdae76d0 | ||
|
|
7b27b457a2 | ||
|
|
7c36ec0abc | ||
|
|
80b590b673 | ||
|
|
f52651b382 | ||
|
|
a1998f24f7 | ||
|
|
3bd9c15566 | ||
|
|
84eff37a0d | ||
|
|
233a02b7dc | ||
|
|
02bade2de0 | ||
|
|
bdcc2bb1b4 | ||
|
|
4c2872c5ea | ||
|
|
36e990a247 | ||
|
|
f06830ae23 | ||
|
|
e4effb7ab4 | ||
|
|
910072f66f | ||
|
|
359dd64696 | ||
|
|
96e8493509 | ||
|
|
faad92ed0d | ||
|
|
a2f8cf56d3 | ||
|
|
32804e2a9a | ||
|
|
c224080ef9 | ||
|
|
ecb1fed2d5 | ||
|
|
a769757728 | ||
|
|
8b36721749 | ||
|
|
451c114419 | ||
|
|
161c545fcd | ||
|
|
84f5646f86 | ||
|
|
47029f0eaf | ||
|
|
1f93d4f3b0 | ||
|
|
a478bee5f3 | ||
|
|
bca7de6990 | ||
|
|
268a0ae81b | ||
|
|
fc08261929 | ||
|
|
04a94458ed | ||
|
|
7f9a1c4f70 | ||
|
|
9b5792d748 | ||
|
|
002ad20be4 | ||
|
|
9f97dc2202 | ||
|
|
bcc0f7f220 | ||
|
|
add20445ad | ||
|
|
3be1c1a625 | ||
|
|
aa25c49a87 | ||
|
|
4ce7ebef05 | ||
|
|
f3ea596e5a | ||
|
|
da9ea20e8f | ||
|
|
7af6c7c203 | ||
|
|
c2faf2a2a3 | ||
|
|
af4491d739 | ||
|
|
ae0f91e36d | ||
|
|
4880832028 | ||
|
|
f6405c6f04 | ||
|
|
04db6bcb47 | ||
|
|
f2b5d7413c | ||
|
|
b372f4a9d8 | ||
|
|
851301c671 | ||
|
|
6eea9ee15b | ||
|
|
7189f2a671 | ||
|
|
85da9461e5 | ||
|
|
2809d1890d | ||
|
|
e4cf2aa1b4 | ||
|
|
91d93e7840 | ||
|
|
5e1095f2bb | ||
|
|
bea5312e9f | ||
|
|
09405e06e1 | ||
|
|
bf00ccd875 | ||
|
|
08dd0f3868 | ||
|
|
b7a64234f8 | ||
|
|
a1ad694260 | ||
|
|
253adc1396 | ||
|
|
fc302fe984 | ||
|
|
fcface8471 | ||
|
|
19b1d1b40c | ||
|
|
dc1a75c9c9 | ||
|
|
1896c51a87 | ||
|
|
f284491963 | ||
|
|
f309b8b79b | ||
|
|
805d444d01 | ||
|
|
36f09542da | ||
|
|
6017b7f454 | ||
|
|
f90d3dbf32 | ||
|
|
b588f12b0c | ||
|
|
9a9b050fc7 | ||
|
|
e977d00657 | ||
|
|
ef5c6cdfa6 | ||
|
|
62056ed718 | ||
|
|
e1966eb0c3 | ||
|
|
db00cafd84 | ||
|
|
785150f921 | ||
|
|
c8e43c81f1 | ||
|
|
b87f99c852 | ||
|
|
c348697e3b | ||
|
|
6b37a95ee2 | ||
|
|
d8b05f9431 | ||
|
|
8682124d04 | ||
|
|
b12f45a187 | ||
|
|
ba56de3336 | ||
|
|
518600da40 | ||
|
|
e98c8f2f2a | ||
|
|
322e5ba8a8 | ||
|
|
c87a465200 | ||
|
|
bf74483f77 | ||
|
|
c690c68aad | ||
|
|
9b2f41cd39 | ||
|
|
88199a222b | ||
|
|
7583c01432 | ||
|
|
6d9060bb49 | ||
|
|
2b452af4b3 | ||
|
|
c5aae2302c | ||
|
|
a8468064d6 | ||
|
|
ba3aeb199f | ||
|
|
d8a5ecf8ab | ||
|
|
043cb275dc | ||
|
|
60392b2493 | ||
|
|
a2f311f18c | ||
|
|
220b3be2b0 | ||
|
|
668c435862 | ||
|
|
47966248dc | ||
|
|
8b60648f3e | ||
|
|
745076678a | ||
|
|
22ed019dbd | ||
|
|
737833492b | ||
|
|
edb9f11b92 | ||
|
|
be3811688f | ||
|
|
851fb85ca1 | ||
|
|
2dadd96484 | ||
|
|
0ebee67507 | ||
|
|
85f09a60be | ||
|
|
fa20de4df1 | ||
|
|
2abffe2e34 | ||
|
|
32d4ad3cd7 | ||
|
|
453ed153bc | ||
|
|
c458bb0e6b | ||
|
|
b307bffb26 | ||
|
|
e940073eae | ||
|
|
07b7040df4 | ||
|
|
8d8a6dc97e | ||
|
|
4a627eacaa | ||
|
|
ecdaa47d8a | ||
|
|
98747b329b | ||
|
|
26078a9cd1 | ||
|
|
776dc47ad6 | ||
|
|
faf8f45585 | ||
|
|
e33e91cb46 | ||
|
|
90ffb5388f | ||
|
|
6931832c8c | ||
|
|
281ea2f2a9 | ||
|
|
a4c566089f | ||
|
|
049550dc1c | ||
|
|
ea13a037e8 | ||
|
|
b2bfd83e1f | ||
|
|
00f40e6394 | ||
|
|
40ad762853 | ||
|
|
e319a19135 | ||
|
|
de813e15d9 | ||
|
|
2febc9e5b7 | ||
|
|
a7914aafac | ||
|
|
10e0064556 | ||
|
|
18491f2644 | ||
|
|
2db43e69d9 | ||
|
|
c1c5c8f5bb | ||
|
|
1c2833ee8e | ||
|
|
8c70356e44 | ||
|
|
41e5202cbf | ||
|
|
9d6e3a3d4a | ||
|
|
63882ac75e | ||
|
|
0a76ce337a | ||
|
|
5c63f85483 | ||
|
|
2181a420b9 | ||
|
|
5d86fb0fd4 | ||
|
|
9b304e3c13 | ||
|
|
87e07376fa | ||
|
|
736c4cda04 | ||
|
|
a2dc1dd6f5 | ||
|
|
787484c721 | ||
|
|
5c8b81c67e | ||
|
|
56e9cebe26 | ||
|
|
469c753161 | ||
|
|
72b88b09c4 | ||
|
|
3e706f7027 | ||
|
|
498fee3727 | ||
|
|
1f4618ae7f | ||
|
|
1f024e6b81 | ||
|
|
839f06b495 | ||
|
|
e3bade38b9 | ||
|
|
1346fd1bfc | ||
|
|
da24fa3b84 | ||
|
|
ee20daadb3 | ||
|
|
a80c9267df | ||
|
|
b0a6fe7c86 | ||
|
|
493c5e7c63 | ||
|
|
ad310f6d48 | ||
|
|
86365ad7b1 | ||
|
|
372232d206 | ||
|
|
4dfd9b2d70 | ||
|
|
f105fca9a7 | ||
|
|
c4db370870 | ||
|
|
0756af0d6e | ||
|
|
daac82f77a | ||
|
|
f71711ed8f | ||
|
|
5b8a342625 | ||
|
|
d9f5398fc6 | ||
|
|
8d6d6da7f3 | ||
|
|
44ea7d6ca2 | ||
|
|
cca47e3823 | ||
|
|
f8a90c0c8f | ||
|
|
e412d22569 | ||
|
|
4ed438f8aa | ||
|
|
77f9d927be | ||
|
|
abbb76031b | ||
|
|
5ee58bc895 | ||
|
|
a437417da1 | ||
|
|
b41f0d8ad5 | ||
|
|
9ff1643e30 | ||
|
|
7e1875b384 | ||
|
|
aa5eccf995 | ||
|
|
9e6e2fbd37 | ||
|
|
104d06fd19 | ||
|
|
216c64b031 | ||
|
|
25ea439564 | ||
|
|
d225b81903 | ||
|
|
b1ee15772b | ||
|
|
84e691d03b | ||
|
|
0409a5f8c8 | ||
|
|
6a5b07f8ce | ||
|
|
de8496e003 |
10
.classpath
10
.classpath
@@ -28,11 +28,6 @@
|
||||
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.8.0_144">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="lib" path="lib/jersey-client-2.23.1.jar">
|
||||
<attributes>
|
||||
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
|
||||
@@ -158,5 +153,10 @@
|
||||
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||
<attributes>
|
||||
<attribute name="owner.project.facets" value="java"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.7
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.source=1.7
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
<faceted-project>
|
||||
<fixed facet="wst.jsdt.web"/>
|
||||
<installed facet="wst.jsdt.web" version="1.0"/>
|
||||
<installed facet="java" version="1.7"/>
|
||||
<installed facet="jst.web" version="3.0"/>
|
||||
<installed facet="jst.jaxrs" version="1.1"/>
|
||||
<installed facet="maven" version="1.0"/>
|
||||
<installed facet="java" version="1.8"/>
|
||||
</faceted-project>
|
||||
|
||||
@@ -1 +1,7 @@
|
||||
gk for web
|
||||
520上线功能:
|
||||
|
||||
|
||||
Source IP аddress / IP subnet / IP range 的配置 按 1月 29号的 demo实现
|
||||
|
||||
系统需要支持配置的批量删除功能,一次删除的配置条数可达 1万 条 ,也需要支持一次
|
||||
删除所有规则
|
||||
22
pom.xml
22
pom.xml
@@ -710,5 +710,27 @@
|
||||
<artifactId>jersey-apache-connector</artifactId>
|
||||
<version>2.23.1</version>
|
||||
</dependency>
|
||||
<!-- quartz -->
|
||||
<dependency>
|
||||
<groupId>org.quartz-scheduler</groupId>
|
||||
<artifactId>quartz</artifactId>
|
||||
<version>2.2.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.quartz-scheduler</groupId>
|
||||
<artifactId>quartz-jobs</artifactId>
|
||||
<version>2.2.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid</artifactId>
|
||||
<version>1.1.10</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.57</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
||||
31
src/main/java/com/nis/domain/Nets.java
Normal file
31
src/main/java/com/nis/domain/Nets.java
Normal file
@@ -0,0 +1,31 @@
|
||||
package com.nis.domain;
|
||||
|
||||
/**
|
||||
* Created by dell on 2018-8-30.
|
||||
*/
|
||||
public class Nets {
|
||||
|
||||
private String StartIP;
|
||||
private String EndIP;
|
||||
private String NetMask;
|
||||
public String getStartIP() {
|
||||
return StartIP;
|
||||
}
|
||||
public void setStartIP(String startIP) {
|
||||
StartIP = startIP;
|
||||
}
|
||||
public String getEndIP() {
|
||||
return EndIP;
|
||||
}
|
||||
public void setEndIP(String endIP) {
|
||||
EndIP = endIP;
|
||||
}
|
||||
public String getNetMask() {
|
||||
return NetMask;
|
||||
}
|
||||
public void setNetMask(String netMask) {
|
||||
NetMask = netMask;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
56
src/main/java/com/nis/domain/ScheduleCfg.java
Normal file
56
src/main/java/com/nis/domain/ScheduleCfg.java
Normal file
@@ -0,0 +1,56 @@
|
||||
package com.nis.domain;
|
||||
|
||||
import com.nis.domain.configuration.BaseCfg;
|
||||
|
||||
/**
|
||||
* 定时任务信息 schedule_info
|
||||
* @author ThinkPad
|
||||
*
|
||||
*/
|
||||
public class ScheduleCfg extends BaseCfg<ScheduleCfg>{
|
||||
private static final long serialVersionUID = 7151915080876949497L;
|
||||
|
||||
private String name;//定时任务名称,预留
|
||||
private String cronValid;//生效cron表达式
|
||||
private String cronInvalid;//失效cron表达式
|
||||
private String whereStr;//动态where 条件
|
||||
private int delFlag;
|
||||
private int type;
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public String getCronValid() {
|
||||
return cronValid;
|
||||
}
|
||||
public void setCronValid(String cronValid) {
|
||||
this.cronValid = cronValid;
|
||||
}
|
||||
public String getCronInvalid() {
|
||||
return cronInvalid;
|
||||
}
|
||||
public void setCronInvalid(String cronInvalid) {
|
||||
this.cronInvalid = cronInvalid;
|
||||
}
|
||||
public String getWhereStr() {
|
||||
return whereStr;
|
||||
}
|
||||
public void setWhereStr(String whereStr) {
|
||||
this.whereStr = whereStr;
|
||||
}
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
public int getDelFlag() {
|
||||
return delFlag;
|
||||
}
|
||||
public void setDelFlag(int delFlag) {
|
||||
this.delFlag = delFlag;
|
||||
}
|
||||
|
||||
}
|
||||
66
src/main/java/com/nis/domain/ScheduleExceInfo.java
Normal file
66
src/main/java/com/nis/domain/ScheduleExceInfo.java
Normal file
@@ -0,0 +1,66 @@
|
||||
package com.nis.domain;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.nis.domain.configuration.BaseCfg;
|
||||
|
||||
/**
|
||||
* 定时任务执行信息 schedule_exce_log/schedule_exce_new
|
||||
* `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键自增',
|
||||
`schedule_id` bigint(20) NOT NULL COMMENT 'schedule_info 表的主键',
|
||||
`exce_time` datetime DEFAULT NULL COMMENT '最新执行时间',
|
||||
`issue_status` int(255) DEFAULT NULL COMMENT '下发状态:1:生效,0:失效',
|
||||
`issue_result` int(255) DEFAULT NULL COMMENT '下发结果:1:成功,0:失败',
|
||||
`error_info` varchar(255) DEFAULT NULL COMMENT '下发失败原因',
|
||||
`compile_id` bigint(20) DEFAULT NULL COMMENT '编译id',
|
||||
* @author fang
|
||||
*
|
||||
*/
|
||||
public class ScheduleExceInfo extends BaseCfg<ScheduleExceInfo>{
|
||||
private static final long serialVersionUID = 7151915080876949497L;
|
||||
|
||||
private Long scheduleId;//定时器id
|
||||
private Date exceTime;//下发时间
|
||||
private Integer issueStatus;//下发 的状态
|
||||
private Integer issueResult;//下发结果
|
||||
private String errorInfo;//动态where 条件
|
||||
private Integer isIssue;//是否需要下发配置,1:需要,0:不需要
|
||||
|
||||
public Long getScheduleId() {
|
||||
return scheduleId;
|
||||
}
|
||||
public void setScheduleId(Long scheduleId) {
|
||||
this.scheduleId = scheduleId;
|
||||
}
|
||||
public Date getExceTime() {
|
||||
return exceTime;
|
||||
}
|
||||
public void setExceTime(Date exceTime) {
|
||||
this.exceTime = exceTime;
|
||||
}
|
||||
public Integer getIssueStatus() {
|
||||
return issueStatus;
|
||||
}
|
||||
public void setIssueStatus(Integer issueStatus) {
|
||||
this.issueStatus = issueStatus;
|
||||
}
|
||||
public Integer getIssueResult() {
|
||||
return issueResult;
|
||||
}
|
||||
public void setIssueResult(Integer issueResult) {
|
||||
this.issueResult = issueResult;
|
||||
}
|
||||
public String getErrorInfo() {
|
||||
return errorInfo;
|
||||
}
|
||||
public void setErrorInfo(String errorInfo) {
|
||||
this.errorInfo = errorInfo;
|
||||
}
|
||||
public Integer getIsIssue() {
|
||||
return isIssue;
|
||||
}
|
||||
public void setIsIssue(Integer isIssue) {
|
||||
this.isIssue = isIssue;
|
||||
}
|
||||
|
||||
}
|
||||
92
src/main/java/com/nis/domain/SysUserWarn.java
Normal file
92
src/main/java/com/nis/domain/SysUserWarn.java
Normal file
@@ -0,0 +1,92 @@
|
||||
package com.nis.domain;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.xml.bind.annotation.XmlTransient;
|
||||
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
public class SysUserWarn {
|
||||
|
||||
private String serviceId; //业务Id
|
||||
private String serviceDesc;//业务描述
|
||||
private Integer interfaceCfgTotal;//界面配置数量
|
||||
|
||||
private Integer systemCfgTotal;//服务端配置数量
|
||||
|
||||
private Date time;//时间
|
||||
private String remark;//备注
|
||||
|
||||
private Integer id;//serviceID
|
||||
private String tableName;//表名
|
||||
/**
|
||||
* 当前实体分页对象
|
||||
*/
|
||||
protected Page<SysUserWarn> page;
|
||||
|
||||
public String getServiceId() {
|
||||
return serviceId;
|
||||
}
|
||||
public void setServiceId(String serviceId) {
|
||||
this.serviceId = serviceId;
|
||||
}
|
||||
public String getServiceDesc() {
|
||||
return serviceDesc;
|
||||
}
|
||||
public void setServiceDesc(String serviceDesc) {
|
||||
this.serviceDesc = serviceDesc;
|
||||
}
|
||||
public Integer getInterfaceCfgTotal() {
|
||||
return interfaceCfgTotal;
|
||||
}
|
||||
public void setInterfaceCfgTotal(Integer interfaceCfgTotal) {
|
||||
this.interfaceCfgTotal = interfaceCfgTotal;
|
||||
}
|
||||
public Integer getSystemCfgTotal() {
|
||||
return systemCfgTotal;
|
||||
}
|
||||
public void setSystemCfgTotal(Integer systemCfgTotal) {
|
||||
this.systemCfgTotal = systemCfgTotal;
|
||||
}
|
||||
public Date getTime() {
|
||||
return time;
|
||||
}
|
||||
public void setTime(Date time) {
|
||||
this.time = time;
|
||||
}
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
public String getTableName() {
|
||||
return tableName;
|
||||
}
|
||||
public void setTableName(String tableName) {
|
||||
this.tableName = tableName;
|
||||
}
|
||||
@JsonIgnore
|
||||
@XmlTransient
|
||||
public Page<SysUserWarn> getPage() {
|
||||
if (page == null){
|
||||
page = new Page<SysUserWarn>();
|
||||
}
|
||||
return page;
|
||||
}
|
||||
|
||||
public Page<SysUserWarn> setPage(Page<SysUserWarn> page) {
|
||||
this.page = page;
|
||||
return page;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
46
src/main/java/com/nis/domain/SysUserWarnData.java
Normal file
46
src/main/java/com/nis/domain/SysUserWarnData.java
Normal file
@@ -0,0 +1,46 @@
|
||||
package com.nis.domain;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class SysUserWarnData {
|
||||
|
||||
private Map<String,List<String>> effective;
|
||||
private Integer effectiveCount;
|
||||
private Map<String,List<String>> obsolete;
|
||||
private Integer obsoleteCount;
|
||||
|
||||
|
||||
public Map<String, List<String>> getEffective() {
|
||||
return effective;
|
||||
}
|
||||
public void setEffective(Map<String, List<String>> effective) {
|
||||
this.effective = effective;
|
||||
}
|
||||
public Integer getEffectiveCount() {
|
||||
return effectiveCount;
|
||||
}
|
||||
public void setEffectiveCount(Integer effectiveCount) {
|
||||
this.effectiveCount = effectiveCount;
|
||||
}
|
||||
public Map<String, List<String>> getObsolete() {
|
||||
return obsolete;
|
||||
}
|
||||
public void setObsolete(Map<String, List<String>> obsolete) {
|
||||
this.obsolete = obsolete;
|
||||
}
|
||||
public Integer getObsoleteCount() {
|
||||
return obsoleteCount;
|
||||
}
|
||||
public void setObsoleteCount(Integer obsoleteCount) {
|
||||
this.obsoleteCount = obsoleteCount;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SysUserWarnData [effective=" + effective + ", effectiveCount=" + effectiveCount + ", obsolete="
|
||||
+ obsolete + ", obsoleteCount=" + obsoleteCount + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
67
src/main/java/com/nis/domain/SysUserWarnRecvData.java
Normal file
67
src/main/java/com/nis/domain/SysUserWarnRecvData.java
Normal file
@@ -0,0 +1,67 @@
|
||||
package com.nis.domain;
|
||||
|
||||
public class SysUserWarnRecvData {
|
||||
private Integer status;
|
||||
private Integer businessCode;
|
||||
private String reason;
|
||||
private String msg;
|
||||
private String fromuri;
|
||||
private String logSource;
|
||||
private String traceCode;
|
||||
private SysUserWarnData data;
|
||||
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
public Integer getBusinessCode() {
|
||||
return businessCode;
|
||||
}
|
||||
public void setBusinessCode(Integer businessCode) {
|
||||
this.businessCode = businessCode;
|
||||
}
|
||||
public String getReason() {
|
||||
return reason;
|
||||
}
|
||||
public void setReason(String reason) {
|
||||
this.reason = reason;
|
||||
}
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
public String getFromuri() {
|
||||
return fromuri;
|
||||
}
|
||||
public void setFromuri(String fromuri) {
|
||||
this.fromuri = fromuri;
|
||||
}
|
||||
public String getLogSource() {
|
||||
return logSource;
|
||||
}
|
||||
public void setLogSource(String logSource) {
|
||||
this.logSource = logSource;
|
||||
}
|
||||
public String getTraceCode() {
|
||||
return traceCode;
|
||||
}
|
||||
public void setTraceCode(String traceCode) {
|
||||
this.traceCode = traceCode;
|
||||
}
|
||||
public SysUserWarnData getData() {
|
||||
return data;
|
||||
}
|
||||
public void setData(SysUserWarnData data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -20,12 +20,14 @@ public class AsnIpCfg extends BaseCfg<AsnIpCfg> {
|
||||
@ExcelField(title="ip_type",dictType="IP_TYPE",sort=6)
|
||||
@SerializedName("ipType")
|
||||
private Integer ipType;
|
||||
@ExcelField(title="ip_pattern",dictType="IP_PATTERN",sort=8)
|
||||
private Integer ipPattern;
|
||||
private Integer srcIpPattern;
|
||||
@ExcelField(title="dest_ip_pattern",dictType="IP_PATTERN",sort=8)
|
||||
private Integer destIpPattern;
|
||||
private String srcIpAddress;
|
||||
@ExcelField(title="ip",sort=7)
|
||||
private String destIpAddress;
|
||||
private Integer portPattern;
|
||||
private Integer srcPortPattern;
|
||||
private Integer destPortPattern;
|
||||
private String srcPort;
|
||||
private String destPort;
|
||||
//@ExcelField(title="group",sort=2)
|
||||
@@ -117,11 +119,30 @@ public class AsnIpCfg extends BaseCfg<AsnIpCfg> {
|
||||
public void setIpType(Integer ipType) {
|
||||
this.ipType = ipType;
|
||||
}
|
||||
public Integer getIpPattern() {
|
||||
return ipPattern;
|
||||
|
||||
public Integer getSrcIpPattern() {
|
||||
return srcIpPattern;
|
||||
}
|
||||
public void setIpPattern(Integer ipPattern) {
|
||||
this.ipPattern = ipPattern;
|
||||
public void setSrcIpPattern(Integer srcIpPattern) {
|
||||
this.srcIpPattern = srcIpPattern;
|
||||
}
|
||||
public Integer getDestIpPattern() {
|
||||
return destIpPattern;
|
||||
}
|
||||
public void setDestIpPattern(Integer destIpPattern) {
|
||||
this.destIpPattern = destIpPattern;
|
||||
}
|
||||
public Integer getSrcPortPattern() {
|
||||
return srcPortPattern;
|
||||
}
|
||||
public void setSrcPortPattern(Integer srcPortPattern) {
|
||||
this.srcPortPattern = srcPortPattern;
|
||||
}
|
||||
public Integer getDestPortPattern() {
|
||||
return destPortPattern;
|
||||
}
|
||||
public void setDestPortPattern(Integer destPortPattern) {
|
||||
this.destPortPattern = destPortPattern;
|
||||
}
|
||||
public String getSrcIpAddress() {
|
||||
return srcIpAddress;
|
||||
@@ -135,12 +156,6 @@ public class AsnIpCfg extends BaseCfg<AsnIpCfg> {
|
||||
public void setDestIpAddress(String destIpAddress) {
|
||||
this.destIpAddress = destIpAddress;
|
||||
}
|
||||
public Integer getPortPattern() {
|
||||
return portPattern;
|
||||
}
|
||||
public void setPortPattern(Integer portPattern) {
|
||||
this.portPattern = portPattern;
|
||||
}
|
||||
public String getSrcPort() {
|
||||
return srcPort;
|
||||
}
|
||||
@@ -176,9 +191,10 @@ public class AsnIpCfg extends BaseCfg<AsnIpCfg> {
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AsnIpCfg [regionId=" + regionId + ", ratelimit=" + ratelimit + ", ipType=" + ipType + ", ipPattern="
|
||||
+ ipPattern + ", srcIpAddress=" + srcIpAddress + ", destIpAddress=" + destIpAddress + ", portPattern="
|
||||
+ portPattern + ", srcPort=" + srcPort + ", destPort=" + destPort + ", asnIpGroupName=" + asnIpGroupName
|
||||
return "AsnIpCfg [regionId=" + regionId + ", ratelimit=" + ratelimit + ", ipType=" + ipType + ", srcIpPattern="
|
||||
+ srcIpPattern + ", destIpPattern="+ destIpPattern+ ", srcIpAddress=" + srcIpAddress + ", destIpAddress="
|
||||
+ destIpAddress + ", srcPortPattern="+ srcPortPattern+", destPortPattern="+ destPortPattern + ", srcPort="
|
||||
+ srcPort + ", destPort=" + destPort + ", asnIpGroupName=" + asnIpGroupName
|
||||
+ ", asnIpGroup=" + asnIpGroup + ", direction=" + direction + ", protocol=" + protocol + ", protocolId="
|
||||
+ protocolId + ", compileId=" + compileId + ", isValid=" + isValid + ", userRegion1=" + userRegion1
|
||||
+ ", userRegion2=" + userRegion2 + ", userRegion3=" + userRegion3 + ", userRegion4=" + userRegion4
|
||||
|
||||
57
src/main/java/com/nis/domain/basics/ProtectionListInfo.java
Normal file
57
src/main/java/com/nis/domain/basics/ProtectionListInfo.java
Normal file
@@ -0,0 +1,57 @@
|
||||
package com.nis.domain.basics;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import com.nis.domain.configuration.BaseCfg;
|
||||
|
||||
public class ProtectionListInfo extends BaseCfg<ProtectionListInfo> implements Serializable{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -3781310894175345207L;
|
||||
private Integer proId;
|
||||
private String keyword;
|
||||
private String targetType;
|
||||
private String description;
|
||||
|
||||
|
||||
public Integer getProId() {
|
||||
return proId;
|
||||
}
|
||||
public void setProId(Integer proId) {
|
||||
this.proId = proId;
|
||||
}
|
||||
public String getKeyword() {
|
||||
return keyword;
|
||||
}
|
||||
public void setKeyword(String keyword) {
|
||||
this.keyword = keyword;
|
||||
}
|
||||
public String getTargetType() {
|
||||
return targetType;
|
||||
}
|
||||
public void setTargetType(String targetType) {
|
||||
this.targetType = targetType;
|
||||
}
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
public Date getEditTime() {
|
||||
return editTime;
|
||||
}
|
||||
public void setEditTime(Date editTime) {
|
||||
this.editTime = editTime;
|
||||
}
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,8 +1,6 @@
|
||||
|
||||
package com.nis.domain.configuration;
|
||||
|
||||
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.nis.util.excel.ExcelField;
|
||||
@@ -34,11 +32,13 @@ public class AppIpCfg extends BaseCfg<AppIpCfg> {
|
||||
@ExcelField(title="ip_type",dictType="IP_TYPE",sort=3)
|
||||
@SerializedName("ipType")
|
||||
protected Integer ipType;
|
||||
protected Integer ipPattern;
|
||||
protected Integer srcIpPattern;
|
||||
protected Integer destIpPattern;
|
||||
protected String srcIpAddress;
|
||||
@ExcelField(title="server_ip",sort=4)
|
||||
protected String destIpAddress;
|
||||
protected Integer portPattern;
|
||||
protected Integer srcPortPattern;
|
||||
protected Integer destPortPattern;
|
||||
protected String srcPort;
|
||||
@ExcelField(title="server_port",sort=5)
|
||||
protected String destPort;
|
||||
@@ -121,34 +121,7 @@ public class AppIpCfg extends BaseCfg<AppIpCfg> {
|
||||
// this.protocolId = protocolId;
|
||||
// }
|
||||
|
||||
/**
|
||||
* ipPattern
|
||||
* @return ipPattern
|
||||
*/
|
||||
|
||||
public Integer getIpPattern() {
|
||||
return ipPattern;
|
||||
}
|
||||
/**
|
||||
* @param ipPattern the ipPattern to set
|
||||
*/
|
||||
public void setIpPattern(Integer ipPattern) {
|
||||
this.ipPattern = ipPattern;
|
||||
}
|
||||
/**
|
||||
* portPattern
|
||||
* @return portPattern
|
||||
*/
|
||||
|
||||
public Integer getPortPattern() {
|
||||
return portPattern;
|
||||
}
|
||||
/**
|
||||
* @param portPattern the portPattern to set
|
||||
*/
|
||||
public void setPortPattern(Integer portPattern) {
|
||||
this.portPattern = portPattern;
|
||||
}
|
||||
|
||||
/**
|
||||
* srcIpAddress
|
||||
@@ -158,6 +131,30 @@ public class AppIpCfg extends BaseCfg<AppIpCfg> {
|
||||
public String getSrcIpAddress() {
|
||||
return srcIpAddress;
|
||||
}
|
||||
public Integer getSrcIpPattern() {
|
||||
return srcIpPattern;
|
||||
}
|
||||
public void setSrcIpPattern(Integer srcIpPattern) {
|
||||
this.srcIpPattern = srcIpPattern;
|
||||
}
|
||||
public Integer getDestIpPattern() {
|
||||
return destIpPattern;
|
||||
}
|
||||
public void setDestIpPattern(Integer destIpPattern) {
|
||||
this.destIpPattern = destIpPattern;
|
||||
}
|
||||
public Integer getSrcPortPattern() {
|
||||
return srcPortPattern;
|
||||
}
|
||||
public void setSrcPortPattern(Integer srcPortPattern) {
|
||||
this.srcPortPattern = srcPortPattern;
|
||||
}
|
||||
public Integer getDestPortPattern() {
|
||||
return destPortPattern;
|
||||
}
|
||||
public void setDestPortPattern(Integer destPortPattern) {
|
||||
this.destPortPattern = destPortPattern;
|
||||
}
|
||||
/**
|
||||
* @param srcIpAddress the srcIpAddress to set
|
||||
*/
|
||||
@@ -257,16 +254,10 @@ public class AppIpCfg extends BaseCfg<AppIpCfg> {
|
||||
public String toString() {
|
||||
return "AppIpCfg [compileId=" + compileId + ", ratelimit=" + ratelimit + ", appCode=" + appCode + ", behavCode="
|
||||
+ behavCode + ", specServiceId=" + specServiceId + ", appName=" + appName + ", ipType=" + ipType
|
||||
+ ", ipPattern=" + ipPattern + ", srcIpAddress=" + srcIpAddress + ", destIpAddress=" + destIpAddress
|
||||
+ ", portPattern=" + portPattern + ", srcPort=" + srcPort + ", destPort=" + destPort + ", direction="
|
||||
+ direction + ", protocol=" + protocol + ", userRegion1=" + userRegion1 + ", userRegion2=" + userRegion2
|
||||
+ ", userRegion3=" + userRegion3 + ", userRegion4=" + userRegion4 + ", userRegion5=" + userRegion5
|
||||
+ ", cfgId=" + cfgId + ", cfgDesc=" + cfgDesc + ", action=" + action + ", isValid=" + isValid
|
||||
+ ", isAudit=" + isAudit + ", creatorId=" + creatorId + ", createTime=" + createTime + ", editorId="
|
||||
+ editorId + ", editTime=" + editTime + ", auditorId=" + auditorId + ", auditTime=" + auditTime
|
||||
+ ", serviceId=" + serviceId + ", requestId=" + requestId + ", cancelRequestId=" + cancelRequestId
|
||||
+ ", isAreaEffective=" + isAreaEffective + ", classify=" + classify + ", attribute=" + attribute
|
||||
+ ", lable=" + lable + ", areaEffectiveIds=" + areaEffectiveIds + ", cfgRegionCode=" + cfgRegionCode
|
||||
+ ", cfgType=" + cfgType + ", functionId=" + functionId + ", doLog=" + doLog + "]";
|
||||
+ ", srcIpPattern=" + srcIpPattern + ", destIpPattern=" + destIpPattern + ", srcIpAddress="
|
||||
+ srcIpAddress + ", destIpAddress=" + destIpAddress + ", srcPortPattern=" + srcPortPattern
|
||||
+ ", destPortPattern=" + destPortPattern + ", srcPort=" + srcPort + ", destPort=" + destPort
|
||||
+ ", direction=" + direction + ", protocol=" + protocol + "]";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -39,6 +39,9 @@ public class AppTopicDomainCfg extends BaseCfg<AppTopicDomainCfg> {
|
||||
@ExcelField(title="topic",dictType="TOPIC",sort=2)
|
||||
private Long topicId;
|
||||
|
||||
private String topic;
|
||||
private String websiteService;
|
||||
|
||||
/**
|
||||
* 表达式类型
|
||||
*/
|
||||
@@ -180,4 +183,20 @@ public class AppTopicDomainCfg extends BaseCfg<AppTopicDomainCfg> {
|
||||
this.websiteServiceId = websiteServiceId;
|
||||
}
|
||||
|
||||
public String getTopic() {
|
||||
return topic;
|
||||
}
|
||||
|
||||
public void setTopic(String topic) {
|
||||
this.topic = topic;
|
||||
}
|
||||
|
||||
public String getWebsiteService() {
|
||||
return websiteService;
|
||||
}
|
||||
|
||||
public void setWebsiteService(String websiteService) {
|
||||
this.websiteService = websiteService;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -59,7 +59,8 @@ public class AreaIpCfg extends BaseIpCfg {
|
||||
this.cfgType=Constants.AREA_REGION;
|
||||
this.cfgRegionCode=1;
|
||||
this.protocol=0;
|
||||
this.portPattern=1;
|
||||
this.srcPortPattern=1;
|
||||
this.destPortPattern=1;
|
||||
this.srcPort="0";
|
||||
this.destPort="0";
|
||||
this.direction=0;
|
||||
|
||||
@@ -9,8 +9,18 @@ package com.nis.domain.configuration;
|
||||
* @version V1.0
|
||||
*/
|
||||
public class AvVoipAccountCfg extends BaseStringCfg<AvVoipAccountCfg>{
|
||||
|
||||
private static final String tableName="av_voip_account_cfg";
|
||||
|
||||
private static final long serialVersionUID = -7398698517584394431L;
|
||||
|
||||
@Override
|
||||
public void initDefaultValue() {
|
||||
super.initDefaultValue();
|
||||
this.exprType=0;
|
||||
this.matchMethod=0;
|
||||
}
|
||||
public static String getTablename() {
|
||||
return tableName;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.nis.domain.BaseEntity;
|
||||
import com.nis.domain.ScheduleCfg;
|
||||
import com.nis.domain.SysMenu;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.StringUtil;
|
||||
@@ -61,6 +62,21 @@ public class BaseCfg<T> extends BaseEntity<T> implements Cloneable{
|
||||
protected String exType;//导出类型
|
||||
protected String hColumns;//导出隐藏列
|
||||
|
||||
protected String compileIdNew;// 查询 配置ID 范围
|
||||
|
||||
//批量操作时,记录isAudit和isValid检索条件
|
||||
protected String batchAuditValue;
|
||||
protected String batchValidValue;
|
||||
|
||||
/**
|
||||
* 定时任务信息
|
||||
*/
|
||||
//protected List<ScheduleCfg> schedules;
|
||||
/**
|
||||
* 定时任务信息,2019年1月18日18:54:53 修改
|
||||
*/
|
||||
protected ScheduleCfg schedule;
|
||||
|
||||
private String commonGroupIds; //公共组织id(考虑一个compile存在多个asn组织的情况)
|
||||
public String getCommonGroupIds() {
|
||||
return commonGroupIds;
|
||||
@@ -98,6 +114,12 @@ public class BaseCfg<T> extends BaseEntity<T> implements Cloneable{
|
||||
public void setCompileGroupMap(Map<Integer, Integer> compileGroupMap) {
|
||||
this.compileGroupMap = compileGroupMap;
|
||||
}
|
||||
public String getCompileIdNew() {
|
||||
return compileIdNew;
|
||||
}
|
||||
public void setCompileIdNew(String compileIdNew) {
|
||||
this.compileIdNew = compileIdNew;
|
||||
}
|
||||
|
||||
/**
|
||||
* 编译id
|
||||
@@ -350,26 +372,24 @@ public class BaseCfg<T> extends BaseEntity<T> implements Cloneable{
|
||||
*/
|
||||
public void setFunctionId(Integer functionId) {
|
||||
this.functionId = functionId;
|
||||
if(!StringUtil.isEmpty(functionId) && StringUtil.isEmpty(this.menuNameCode)){
|
||||
List<SysMenu> list = UserUtils.getMenuList();
|
||||
}
|
||||
|
||||
public String getMenuNameCode() {
|
||||
if(!StringUtil.isEmpty(this.functionId) && StringUtil.isEmpty(menuNameCode)){
|
||||
List<SysMenu> list = UserUtils.getMenuCfgList();
|
||||
if(!StringUtil.isEmpty(list)) {
|
||||
for (SysMenu menu :list) {
|
||||
if (!StringUtil.isEmpty(menu.getCode())
|
||||
&&menu.getFunctionId()!=null
|
||||
&& menu.getFunctionId().equals(functionId)
|
||||
&& menu.getFunctionId().equals(this.functionId)
|
||||
//&& menu.getFunctionId().equals(functionId)
|
||||
) {
|
||||
this.setMenuNameCode(menu.getCode());
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public String getMenuNameCode() {
|
||||
return menuNameCode;
|
||||
}
|
||||
public void setMenuNameCode(String menuNameCode) {
|
||||
@@ -982,5 +1002,23 @@ public class BaseCfg<T> extends BaseEntity<T> implements Cloneable{
|
||||
public void setDoBlackList(Integer doBlackList) {
|
||||
this.doBlackList = doBlackList;
|
||||
}
|
||||
public ScheduleCfg getSchedule() {
|
||||
return schedule;
|
||||
}
|
||||
public void setSchedule(ScheduleCfg schedule) {
|
||||
this.schedule = schedule;
|
||||
}
|
||||
public String getBatchAuditValue() {
|
||||
return batchAuditValue;
|
||||
}
|
||||
public String getBatchValidValue() {
|
||||
return batchValidValue;
|
||||
}
|
||||
public void setBatchAuditValue(String batchAuditValue) {
|
||||
this.batchAuditValue = batchAuditValue;
|
||||
}
|
||||
public void setBatchValidValue(String batchValidValue) {
|
||||
this.batchValidValue = batchValidValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -45,14 +45,18 @@ public class BaseIpCfg extends BaseCfg<BaseIpCfg> {
|
||||
@SerializedName("ipType")
|
||||
@ExcelField(title="ip_type",dictType="IP_TYPE",sort=50)
|
||||
protected Integer ipType;
|
||||
@ExcelField(title="ip_pattern",dictType="IP_PATTERN",sort=51)
|
||||
protected Integer ipPattern;
|
||||
@ExcelField(title="client_ip",sort=53)
|
||||
@ExcelField(title="src_ip_pattern",dictType="IP_PATTERN",sort=51)
|
||||
protected Integer srcIpPattern;
|
||||
@ExcelField(title="client_ip",sort=52)
|
||||
protected String srcIpAddress;
|
||||
@ExcelField(title="server_ip",sort=52)
|
||||
@ExcelField(title="dest_ip_pattern",dictType="IP_PATTERN",sort=53)
|
||||
protected Integer destIpPattern;
|
||||
@ExcelField(title="server_ip",sort=54)
|
||||
protected String destIpAddress;
|
||||
@ExcelField(title="port_pattern",dictType="PORT_PATTERN",sort=54)
|
||||
protected Integer portPattern;
|
||||
@ExcelField(title="src_port_pattern",dictType="PORT_PATTERN",sort=54)
|
||||
protected Integer srcPortPattern;
|
||||
@ExcelField(title="dest_port_pattern",dictType="PORT_PATTERN",sort=54)
|
||||
protected Integer destPortPattern;
|
||||
@ExcelField(title="client_port",sort=55)
|
||||
protected String srcPort;
|
||||
@ExcelField(title="server_port",sort=56)
|
||||
@@ -75,7 +79,7 @@ public class BaseIpCfg extends BaseCfg<BaseIpCfg> {
|
||||
protected String organization; //仅用于copy属性使用
|
||||
protected String country; //仅用于copy属性使用
|
||||
protected String detail; //仅用于copy属性使用
|
||||
@ExcelField(title="log_total",sort=42)
|
||||
// @ExcelField(title="log_total",sort=42)
|
||||
private Long totalLogs;
|
||||
|
||||
public String getOrganization() {
|
||||
@@ -269,35 +273,31 @@ public class BaseIpCfg extends BaseCfg<BaseIpCfg> {
|
||||
this.protocolId = protocolId;
|
||||
}
|
||||
|
||||
/**
|
||||
* ipPattern
|
||||
* @return ipPattern
|
||||
*/
|
||||
|
||||
public Integer getIpPattern() {
|
||||
return ipPattern;
|
||||
public Integer getSrcIpPattern() {
|
||||
return srcIpPattern;
|
||||
}
|
||||
/**
|
||||
* @param ipPattern the ipPattern to set
|
||||
*/
|
||||
public void setIpPattern(Integer ipPattern) {
|
||||
this.ipPattern = ipPattern;
|
||||
public void setSrcIpPattern(Integer srcIpPattern) {
|
||||
this.srcIpPattern = srcIpPattern;
|
||||
}
|
||||
/**
|
||||
* portPattern
|
||||
* @return portPattern
|
||||
*/
|
||||
|
||||
public Integer getPortPattern() {
|
||||
return portPattern;
|
||||
public Integer getDestIpPattern() {
|
||||
return destIpPattern;
|
||||
}
|
||||
/**
|
||||
* @param portPattern the portPattern to set
|
||||
*/
|
||||
public void setPortPattern(Integer portPattern) {
|
||||
this.portPattern = portPattern;
|
||||
public void setDestIpPattern(Integer destIpPattern) {
|
||||
this.destIpPattern = destIpPattern;
|
||||
}
|
||||
public Integer getSrcPortPattern() {
|
||||
return srcPortPattern;
|
||||
}
|
||||
public void setSrcPortPattern(Integer srcPortPattern) {
|
||||
this.srcPortPattern = srcPortPattern;
|
||||
}
|
||||
public Integer getDestPortPattern() {
|
||||
return destPortPattern;
|
||||
}
|
||||
public void setDestPortPattern(Integer destPortPattern) {
|
||||
this.destPortPattern = destPortPattern;
|
||||
}
|
||||
|
||||
/**
|
||||
* srcIpAddress
|
||||
* @return srcIpAddress
|
||||
|
||||
@@ -238,7 +238,13 @@ public class BaseStringCfg<T> extends BaseCfg<T> {
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
BaseStringCfg base=(BaseStringCfg)list.get(i);
|
||||
base.setIsHex(base.getIsHexbin());
|
||||
base.setIsCaseInsenstive(base.getIsHexbin());
|
||||
// base.setIsCaseInsenstive(base.getIsHexbin());
|
||||
// '默认为0:大小写不敏感,且非HEX;1:HEX格式二进制;2:大小写敏感,且非HEX',
|
||||
if(base.getIsHexbin()==2){
|
||||
base.setIsCaseInsenstive(1);
|
||||
}else{
|
||||
base.setIsCaseInsenstive(0);
|
||||
}
|
||||
base.setCfgKeywords(Functions.replace(base.getCfgKeywords(), "***and***"," "));
|
||||
}
|
||||
return list;
|
||||
@@ -248,7 +254,13 @@ public class BaseStringCfg<T> extends BaseCfg<T> {
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
BaseStringCfg base=(BaseStringCfg)list.get(i);
|
||||
base.setIsHex(base.getIsHexbin());
|
||||
base.setIsCaseInsenstive(base.getIsHexbin());
|
||||
// base.setIsCaseInsenstive(base.getIsHexbin());
|
||||
// '默认为0:大小写不敏感,且非HEX;1:HEX格式二进制;2:大小写敏感,且非HEX',
|
||||
if(base.getIsHexbin()==2){
|
||||
base.setIsCaseInsenstive(1);
|
||||
}else{
|
||||
base.setIsCaseInsenstive(0);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@@ -211,7 +211,12 @@ public class ComplexkeywordCfg extends BaseCfg<ComplexkeywordCfg>{
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
ComplexkeywordCfg base=(ComplexkeywordCfg)list.get(i);
|
||||
base.setIsHex(base.getIsHexbin());
|
||||
base.setIsCaseInsenstive(base.getIsHexbin());
|
||||
// '默认为0:大小写不敏感,且非HEX;1:HEX格式二进制;2:大小写敏感,且非HEX',
|
||||
if(base.getIsHexbin()==2){
|
||||
base.setIsCaseInsenstive(1);
|
||||
}else{
|
||||
base.setIsCaseInsenstive(0);
|
||||
}
|
||||
base.setCfgKeywords(Functions.replace(base.getCfgKeywords(), "***and***"," "));
|
||||
}
|
||||
return list;
|
||||
|
||||
@@ -29,6 +29,8 @@ public class DdosIpCfg extends BaseIpCfg {
|
||||
private Long bpsThreadshold;// 即DDoS攻击保护动作触发阈值,每秒Bit数和每秒包数
|
||||
@ExcelField(title="pps_threadshold",sort=48)
|
||||
private Long ppsThreadshold;
|
||||
@ExcelField(title="log_total",sort=42)
|
||||
private Long totalLogs;
|
||||
|
||||
public String getAntiddosProtocol() {
|
||||
return antiddosProtocol;
|
||||
@@ -54,6 +56,12 @@ public class DdosIpCfg extends BaseIpCfg {
|
||||
public void setIndexTable(String indexTable) {
|
||||
this.indexTable = indexTable;
|
||||
}
|
||||
public Long getTotalLogs() {
|
||||
return totalLogs;
|
||||
}
|
||||
public void setTotalLogs(Long totalLogs) {
|
||||
this.totalLogs = totalLogs;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
34
src/main/java/com/nis/domain/configuration/HelpInfo.java
Normal file
34
src/main/java/com/nis/domain/configuration/HelpInfo.java
Normal file
@@ -0,0 +1,34 @@
|
||||
package com.nis.domain.configuration;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.nis.domain.BaseEntity;
|
||||
import com.nis.util.excel.ExcelField;
|
||||
|
||||
public class HelpInfo extends BaseEntity<HelpInfo>{
|
||||
|
||||
private static final long serialVersionUID = 2451757008384840494L;
|
||||
private String fileName;
|
||||
private String fileComment;
|
||||
private String backFileComment;
|
||||
public String getFileName() {
|
||||
return fileName;
|
||||
}
|
||||
public void setFileName(String fileName) {
|
||||
this.fileName = fileName;
|
||||
}
|
||||
public String getFileComment() {
|
||||
return fileComment;
|
||||
}
|
||||
public void setFileComment(String fileComment) {
|
||||
this.fileComment = fileComment;
|
||||
}
|
||||
public String getBackFileComment() {
|
||||
return backFileComment;
|
||||
}
|
||||
public void setBackFileComment(String backFileComment) {
|
||||
this.backFileComment = backFileComment;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -12,7 +12,7 @@ public class DomainInterceptMonitTemplate extends StringAllNotDoLogTemplate{
|
||||
private String userRegion5;
|
||||
private String cfgKeywords;
|
||||
|
||||
@ExcelField(title="intercept_intensity",dictType="INTERCEPT_DOMAIN_INTENSITY",align=2,sort=2)
|
||||
@ExcelField(title="intercept_intensity",dictType="INTERCEPT_DOMAIN_INTENSITY",align=2,sort=12)
|
||||
public String getUserRegion5() {
|
||||
return userRegion5;
|
||||
}
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
package com.nis.domain.configuration.template;
|
||||
|
||||
/**
|
||||
* wx 将部分字段的标题改变,或者不需要的字段隐藏
|
||||
* 隐藏方法,对于不需要的字段或者方法,Override该字段方法,但是@ExcelField注解不需要加上了
|
||||
* @author dell
|
||||
*
|
||||
*/
|
||||
@Deprecated
|
||||
public class IpAddrTemplate extends IpCfgTemplate {
|
||||
|
||||
|
||||
@Override
|
||||
public Integer getIrType() {
|
||||
// TODO Auto-generated method stub
|
||||
return super.getIrType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getDnsStrategyId() {
|
||||
// TODO Auto-generated method stub
|
||||
return super.getDnsStrategyId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRatelimit() {
|
||||
// TODO Auto-generated method stub
|
||||
return super.getRatelimit();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,7 +8,6 @@
|
||||
*/
|
||||
package com.nis.domain.configuration.template;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.nis.util.excel.ExcelField;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,310 +0,0 @@
|
||||
/**
|
||||
*@Title: BaseStringConfig.java
|
||||
*@Package com.nis.domain.restful
|
||||
*@Description TODO
|
||||
*@author dell
|
||||
*@date 2018年2月5日 下午5:26:02
|
||||
*@version 版本号
|
||||
*/
|
||||
package com.nis.domain.configuration.template;
|
||||
|
||||
import com.nis.util.excel.ExcelField;
|
||||
|
||||
/**
|
||||
* @Description: excel导入IP类配置
|
||||
*/
|
||||
@Deprecated
|
||||
public class IpCfgTemplate {
|
||||
|
||||
/**
|
||||
* @Fields serialVersionUID:TODO(用一句话描述这个变量表示什么)
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
|
||||
|
||||
private Long cfgId;
|
||||
private Integer ipType;//1
|
||||
private Integer ipPattern;//2
|
||||
private String srcIpAddress; //3
|
||||
private String destIpAddress; //4
|
||||
private Integer portPattern; //5
|
||||
private String srcPort; //6
|
||||
private String destPort;//7
|
||||
private Integer protocol;//8
|
||||
protected Integer direction;//9
|
||||
private String cfgDesc;//10
|
||||
private Integer requestId;//11
|
||||
private String requestName;//12
|
||||
private Integer isAreaEffective;//13
|
||||
private String classify;//14
|
||||
private String attribute;//15
|
||||
private String lable;//16
|
||||
private String classifyName;//17
|
||||
private String attributeName;//18
|
||||
private String lableName;//19
|
||||
private String areaEffectiveIds;//20
|
||||
private String ratelimit;//21
|
||||
private Integer dnsStrategyId;//22
|
||||
private Integer irType;//23
|
||||
private String userRegion1;//77
|
||||
private String userRegion2;//78
|
||||
private String userRegion3;//79
|
||||
private String userRegion4;//80
|
||||
private String userRegion5;//81
|
||||
|
||||
/**
|
||||
* userRegion1
|
||||
* @return userRegion1
|
||||
*/
|
||||
// @ExcelField(title="userregion1",align=2,sort=77)
|
||||
public String getUserRegion1() {
|
||||
return userRegion1;
|
||||
}
|
||||
/**
|
||||
* @param userRegion1 the userRegion1 to set
|
||||
*/
|
||||
public void setUserRegion1(String userRegion1) {
|
||||
this.userRegion1 = userRegion1;
|
||||
}
|
||||
/**
|
||||
* userRegion2
|
||||
* @return userRegion2
|
||||
*/
|
||||
// @ExcelField(title="userregion2",align=2,sort=78)
|
||||
public String getUserRegion2() {
|
||||
return userRegion2;
|
||||
}
|
||||
/**
|
||||
* @param userRegion2 the userRegion2 to set
|
||||
*/
|
||||
public void setUserRegion2(String userRegion2) {
|
||||
this.userRegion2 = userRegion2;
|
||||
}
|
||||
/**
|
||||
* userRegion3
|
||||
* @return userRegion3
|
||||
*/
|
||||
// @ExcelField(title="userregion3",align=2,sort=79)
|
||||
public String getUserRegion3() {
|
||||
return userRegion3;
|
||||
}
|
||||
/**
|
||||
* @param userRegion3 the userRegion3 to set
|
||||
*/
|
||||
public void setUserRegion3(String userRegion3) {
|
||||
this.userRegion3 = userRegion3;
|
||||
}
|
||||
/**
|
||||
* userRegion4
|
||||
* @return userRegion4
|
||||
*/
|
||||
// @ExcelField(title="userregion4",align=2,sort=80)
|
||||
public String getUserRegion4() {
|
||||
return userRegion4;
|
||||
}
|
||||
/**
|
||||
* @param userRegion4 the userRegion4 to set
|
||||
*/
|
||||
public void setUserRegion4(String userRegion4) {
|
||||
this.userRegion4 = userRegion4;
|
||||
}
|
||||
/**
|
||||
* userRegion5
|
||||
* @return userRegion5
|
||||
*/
|
||||
// @ExcelField(title="userregion5",align=2,sort=81)
|
||||
public String getUserRegion5() {
|
||||
return userRegion5;
|
||||
}
|
||||
/**
|
||||
* @param userRegion5 the userRegion5 to set
|
||||
*/
|
||||
public void setUserRegion5(String userRegion5) {
|
||||
this.userRegion5 = userRegion5;
|
||||
}
|
||||
/**
|
||||
* ratelimit
|
||||
* @return ratelimit
|
||||
*/
|
||||
@ExcelField(title="ratelimit",align=2,sort=74)
|
||||
public String getRatelimit() {
|
||||
return ratelimit;
|
||||
}
|
||||
/**
|
||||
* @param ratelimit the ratelimit to set
|
||||
*/
|
||||
public void setRatelimit(String ratelimit) {
|
||||
this.ratelimit = ratelimit;
|
||||
}
|
||||
/**
|
||||
* irType
|
||||
* @return irType
|
||||
*/
|
||||
@ExcelField(title="ir_type",align=2,sort=76)
|
||||
public Integer getIrType() {
|
||||
return irType;
|
||||
}
|
||||
/**
|
||||
* @param irType the irType to set
|
||||
*/
|
||||
public void setIrType(Integer irType) {
|
||||
this.irType = irType;
|
||||
}
|
||||
/**
|
||||
* dnsStrategyId
|
||||
* @return dnsStrategyId
|
||||
*/
|
||||
@ExcelField(title="dns_strategy_id",align=2,sort=75)
|
||||
public Integer getDnsStrategyId() {
|
||||
return dnsStrategyId;
|
||||
}
|
||||
/**
|
||||
* @param dnsStrategyId the dnsStrategyId to set
|
||||
*/
|
||||
public void setDnsStrategyId(Integer dnsStrategyId) {
|
||||
this.dnsStrategyId = dnsStrategyId;
|
||||
}
|
||||
@ExcelField(title="ip_type",align=2,sort=1)
|
||||
public Integer getIpType() {
|
||||
return ipType;
|
||||
}
|
||||
public void setIpType(Integer ipType) {
|
||||
this.ipType = ipType;
|
||||
}
|
||||
@ExcelField(title="ip_pattern",align=2,sort=2)
|
||||
public Integer getIpPattern() {
|
||||
return ipPattern;
|
||||
}
|
||||
public void setIpPattern(Integer ipPattern) {
|
||||
this.ipPattern = ipPattern;
|
||||
}
|
||||
@ExcelField(title="client_ip",align=2,sort=3)
|
||||
public String getSrcIpAddress() {
|
||||
return srcIpAddress;
|
||||
}
|
||||
public void setSrcIpAddress(String srcIpAddress) {
|
||||
this.srcIpAddress = srcIpAddress;
|
||||
}
|
||||
@ExcelField(title="server_ip",align=2,sort=4)
|
||||
public String getDestIpAddress() {
|
||||
return destIpAddress;
|
||||
}
|
||||
public void setDestIpAddress(String destIpAddress) {
|
||||
this.destIpAddress = destIpAddress;
|
||||
}
|
||||
@ExcelField(title="port_pattern",align=2,sort=5)
|
||||
public Integer getPortPattern() {
|
||||
return portPattern;
|
||||
}
|
||||
public void setPortPattern(Integer portPattern) {
|
||||
this.portPattern = portPattern;
|
||||
}
|
||||
@ExcelField(title="client_port",align=2,sort=6)
|
||||
public String getSrcPort() {
|
||||
return srcPort;
|
||||
}
|
||||
public void setSrcPort(String srcPort) {
|
||||
this.srcPort = srcPort;
|
||||
}
|
||||
@ExcelField(title="server_port",align=2,sort=7)
|
||||
public String getDestPort() {
|
||||
return destPort;
|
||||
}
|
||||
public void setDestPort(String destPort) {
|
||||
this.destPort = destPort;
|
||||
}
|
||||
public Long getCfgId() {
|
||||
return cfgId;
|
||||
}
|
||||
public void setCfgId(Long cfgId) {
|
||||
this.cfgId = cfgId;
|
||||
}
|
||||
@ExcelField(title="direction",align=2,sort=8)
|
||||
public Integer getDirection() {
|
||||
return direction;
|
||||
}
|
||||
public void setDirection(Integer direction) {
|
||||
this.direction = direction;
|
||||
}
|
||||
@ExcelField(title="config_describe",align=2,sort=11)
|
||||
public String getCfgDesc() {
|
||||
return cfgDesc;
|
||||
}
|
||||
public void setCfgDesc(String cfgDesc) {
|
||||
this.cfgDesc = cfgDesc;
|
||||
}
|
||||
@ExcelField(title="letter",align=2,sort=13)
|
||||
public Integer getRequestId() {
|
||||
return requestId;
|
||||
}
|
||||
public void setRequestId(Integer requestId) {
|
||||
this.requestId = requestId;
|
||||
}
|
||||
public String getRequestName() {
|
||||
return requestName;
|
||||
}
|
||||
public void setRequestName(String requestName) {
|
||||
this.requestName = requestName;
|
||||
}
|
||||
public Integer getIsAreaEffective() {
|
||||
return isAreaEffective;
|
||||
}
|
||||
public void setIsAreaEffective(Integer isAreaEffective) {
|
||||
this.isAreaEffective = isAreaEffective;
|
||||
}
|
||||
@ExcelField(title="classification",align=2,sort=71)
|
||||
public String getClassify() {
|
||||
return classify;
|
||||
}
|
||||
public void setClassify(String classify) {
|
||||
this.classify = classify;
|
||||
}
|
||||
@ExcelField(title="attribute",align=2,sort=72)
|
||||
public String getAttribute() {
|
||||
return attribute;
|
||||
}
|
||||
public void setAttribute(String attribute) {
|
||||
this.attribute = attribute;
|
||||
}
|
||||
@ExcelField(title="label",align=2,sort=73)
|
||||
public String getLable() {
|
||||
return lable;
|
||||
}
|
||||
public void setLable(String lable) {
|
||||
this.lable = lable;
|
||||
}
|
||||
public String getClassifyName() {
|
||||
return classifyName;
|
||||
}
|
||||
public void setClassifyName(String classifyName) {
|
||||
this.classifyName = classifyName;
|
||||
}
|
||||
public String getAttributeName() {
|
||||
return attributeName;
|
||||
}
|
||||
public void setAttributeName(String attributeName) {
|
||||
this.attributeName = attributeName;
|
||||
}
|
||||
public String getLableName() {
|
||||
return lableName;
|
||||
}
|
||||
public void setLableName(String lableName) {
|
||||
this.lableName = lableName;
|
||||
}
|
||||
// @ExcelField(title="area_effective",align=2,sort=70)
|
||||
public String getAreaEffectiveIds() {
|
||||
return areaEffectiveIds;
|
||||
}
|
||||
public void setAreaEffectiveIds(String areaEffectiveIds) {
|
||||
this.areaEffectiveIds = areaEffectiveIds;
|
||||
}
|
||||
@ExcelField(title="protocol",align=2,sort=9)
|
||||
public Integer getProtocol() {
|
||||
return protocol;
|
||||
}
|
||||
public void setProtocol(Integer protocol) {
|
||||
this.protocol = protocol;
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
package com.nis.domain.configuration.template;
|
||||
|
||||
import com.nis.util.excel.ExcelField;
|
||||
/**
|
||||
* wx 将部分字段的标题改变,或者不需要的字段隐藏
|
||||
* 隐藏方法,对于不需要的字段或者方法,Override该字段方法,但是@ExcelField注解不需要加上了
|
||||
* @author dell
|
||||
*
|
||||
*/
|
||||
@Deprecated
|
||||
public class IpMultiplexPolicyTemplate extends IpCfgTemplate {
|
||||
@Override
|
||||
@ExcelField(title="IP",align=2,sort=3)
|
||||
public String getSrcIpAddress() {
|
||||
return super.getSrcIpAddress();
|
||||
}
|
||||
@ExcelField(title="port",align=2,sort=6)
|
||||
@Override
|
||||
public String getSrcPort() {
|
||||
// TODO Auto-generated method stub
|
||||
return super.getSrcPort();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ExcelField(title="group_name",align=2,sort=75)
|
||||
public Integer getDnsStrategyId() {
|
||||
// TODO Auto-generated method stub
|
||||
return super.getDnsStrategyId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRatelimit() {
|
||||
// TODO Auto-generated method stub
|
||||
return super.getRatelimit();
|
||||
}
|
||||
@Override
|
||||
public String getDestPort() {
|
||||
// TODO Auto-generated method stub
|
||||
return super.getDestPort();
|
||||
}
|
||||
@Override
|
||||
public String getDestIpAddress() {
|
||||
// TODO Auto-generated method stub
|
||||
return super.getDestIpAddress();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
package com.nis.domain.configuration.template;
|
||||
|
||||
/**
|
||||
* wx 将部分字段的标题改变,或者不需要的字段隐藏
|
||||
* 隐藏方法,对于不需要的字段或者方法,Override该字段方法,但是@ExcelField注解不需要加上了
|
||||
* @author dell
|
||||
*
|
||||
*/
|
||||
@Deprecated
|
||||
public class IpsecTemplate extends IpCfgTemplate {
|
||||
|
||||
|
||||
@Override
|
||||
public Integer getIrType() {
|
||||
// TODO Auto-generated method stub
|
||||
return super.getIrType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getDnsStrategyId() {
|
||||
// TODO Auto-generated method stub
|
||||
return super.getDnsStrategyId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRatelimit() {
|
||||
// TODO Auto-generated method stub
|
||||
return super.getRatelimit();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,7 +10,7 @@ public class P2pIpTemplate extends IpAllTemplate {
|
||||
|
||||
private String userRegion2;
|
||||
|
||||
@ExcelField(title="p2p_ip_config_type",dictType="P2P_IP_TYPE",align=2,sort=2)
|
||||
@ExcelField(title="p2p_ip_config_type",dictType="P2P_IP_TYPE",align=2,sort=5)
|
||||
public String getUserRegion2() {
|
||||
return userRegion2;
|
||||
}
|
||||
|
||||
@@ -7,28 +7,12 @@ import com.nis.util.excel.ExcelField;
|
||||
* @author dell
|
||||
*
|
||||
*/
|
||||
public class TopicWebsiteTemplate extends StringAllTemplate{
|
||||
public class TopicWebsiteTemplate extends StringAllNotDoLogTemplate{
|
||||
|
||||
private Long topicId; // 主题
|
||||
private Long websiteServiceId; // 网站
|
||||
private String topic; // 主题
|
||||
private String websiteService; // 网站
|
||||
private String cfgKeywords; // 域名
|
||||
|
||||
@ExcelField(title="topic",dictType="TOPIC",sort=2)
|
||||
public Long getTopicId() {
|
||||
return topicId;
|
||||
}
|
||||
public void setTopicId(Long topicId) {
|
||||
this.topicId = topicId;
|
||||
}
|
||||
|
||||
@ExcelField(title="website_server",dictType="WEBSITE_SERVER",sort=3)
|
||||
public Long getWebsiteServiceId() {
|
||||
return websiteServiceId;
|
||||
}
|
||||
public void setWebsiteServiceId(Long websiteServiceId) {
|
||||
this.websiteServiceId = websiteServiceId;
|
||||
}
|
||||
|
||||
@ExcelField(title="domain_name",sort=4)
|
||||
public String getCfgKeywords() {
|
||||
return cfgKeywords;
|
||||
@@ -37,4 +21,20 @@ public class TopicWebsiteTemplate extends StringAllTemplate{
|
||||
this.cfgKeywords = cfgKeywords;
|
||||
}
|
||||
|
||||
@ExcelField(title="topic",sort=2)
|
||||
public String getTopic() {
|
||||
return topic;
|
||||
}
|
||||
public void setTopic(String topic) {
|
||||
this.topic = topic;
|
||||
}
|
||||
|
||||
@ExcelField(title="website_server",sort=3)
|
||||
public String getWebsiteService() {
|
||||
return websiteService;
|
||||
}
|
||||
public void setWebsiteService(String websiteService) {
|
||||
this.websiteService = websiteService;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
package com.nis.domain.configuration.template;
|
||||
|
||||
/**
|
||||
* wx 将部分字段的标题改变,或者不需要的字段隐藏
|
||||
* 隐藏方法,对于不需要的字段或者方法,Override该字段方法,但是@ExcelField注解不需要加上了
|
||||
* @author dell
|
||||
*
|
||||
*/
|
||||
@Deprecated
|
||||
public class TunnelIpTemplate extends IpCfgTemplate {
|
||||
|
||||
|
||||
@Override
|
||||
public Integer getIrType() {
|
||||
// TODO Auto-generated method stub
|
||||
return super.getIrType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getDnsStrategyId() {
|
||||
// TODO Auto-generated method stub
|
||||
return super.getDnsStrategyId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRatelimit() {
|
||||
// TODO Auto-generated method stub
|
||||
return super.getRatelimit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getProtocol() {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
package com.nis.domain.configuration.template;
|
||||
|
||||
/**
|
||||
* wx 将部分字段的标题改变,或者不需要的字段隐藏
|
||||
* 隐藏方法,对于不需要的字段或者方法,Override该字段方法,但是@ExcelField注解不需要加上了
|
||||
* @author dell
|
||||
*
|
||||
*/
|
||||
@Deprecated
|
||||
public class WhiteListIpTemplate extends IpCfgTemplate {
|
||||
|
||||
@Override
|
||||
public Integer getDirection() {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getProtocol() {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getIrType() {
|
||||
// TODO Auto-generated method stub
|
||||
return super.getIrType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getDnsStrategyId() {
|
||||
// TODO Auto-generated method stub
|
||||
return super.getDnsStrategyId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getRequestId() {
|
||||
// TODO Auto-generated method stub
|
||||
return super.getRequestId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClassify() {
|
||||
// TODO Auto-generated method stub
|
||||
return super.getClassify();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAttribute() {
|
||||
// TODO Auto-generated method stub
|
||||
return super.getAttribute();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLable() {
|
||||
// TODO Auto-generated method stub
|
||||
return super.getLable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRatelimit() {
|
||||
// TODO Auto-generated method stub
|
||||
return super.getRatelimit();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,6 +18,7 @@ public class SysIspInfo implements Serializable {
|
||||
private Integer ispKeyCode;// 运营商唯一标识编码,
|
||||
private Date createTime;
|
||||
|
||||
private String ispNum; // 出入口跟设备号拼接
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
@@ -67,6 +68,11 @@ public class SysIspInfo implements Serializable {
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public String getIspNum() {
|
||||
return ispNum;
|
||||
}
|
||||
public void setIspNum(String ispNum) {
|
||||
this.ispNum = ispNum;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.nis.domain.log;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.nis.util.excel.ExcelField;
|
||||
|
||||
public class NtcConnRecordLog extends BaseLogEntity<NtcConnRecordLog> {
|
||||
@@ -29,6 +30,8 @@ public class NtcConnRecordLog extends BaseLogEntity<NtcConnRecordLog> {
|
||||
protected String totalByte;
|
||||
|
||||
protected String ispCode;//运营商
|
||||
protected String ispNum;//运营商 (entrance_id+device_id)
|
||||
protected String ispName;//运营商
|
||||
|
||||
|
||||
|
||||
@@ -120,4 +123,20 @@ public class NtcConnRecordLog extends BaseLogEntity<NtcConnRecordLog> {
|
||||
this.s2cByteNum = s2cByteNum;
|
||||
}
|
||||
|
||||
public String getIspName() {
|
||||
return ispName;
|
||||
}
|
||||
|
||||
public void setIspName(String ispName) {
|
||||
this.ispName = ispName;
|
||||
}
|
||||
|
||||
public String getIspNum() {
|
||||
return ispNum;
|
||||
}
|
||||
|
||||
public void setIspNum(String ispNum) {
|
||||
this.ispNum = ispNum;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ public class PxyHttpLog extends BaseLogEntity<NtcIpLog> {
|
||||
@ExcelField(title="req_body",sort=78)
|
||||
private String reqBody;
|
||||
@ExcelField(title="resp_body",sort=79)
|
||||
private String resBody;
|
||||
private String respBody;
|
||||
@ExcelField(title="website",sort=8)
|
||||
private String website;
|
||||
|
||||
@@ -115,23 +115,30 @@ public class PxyHttpLog extends BaseLogEntity<NtcIpLog> {
|
||||
public void setReqBody(String reqBody) {
|
||||
this.reqBody = reqBody;
|
||||
}
|
||||
public String getResBody() {
|
||||
return resBody;
|
||||
public String getRespBody() {
|
||||
return respBody;
|
||||
}
|
||||
public void setResBody(String resBody) {
|
||||
this.resBody = resBody;
|
||||
public void setRespBody(String respBody) {
|
||||
this.respBody = respBody;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "{\"url\"=\"" + url + "\", \"reqLine\"=\"" + reqLine
|
||||
+ "\", \"resLine\"=\"" + resLine + "\", \"cookie\"=\"" + cookie
|
||||
+ "\", \"referer\"=\"" + referer + "\", \"userAgent\"=\""
|
||||
+ userAgent + "\", \"contentLen\"=\"" + contentLen
|
||||
+ "\", \"contentType\"=\"" + contentType
|
||||
+ "\", \"setCookie\"=\"" + setCookie + "\", \"reqHeader\"=\""
|
||||
+ reqHeader + "\", \"respHeader\"=\"" + respHeader
|
||||
+ "\", \"reqBody\"=\"" + reqBody + "\", \"resBody\"=\""
|
||||
+ resBody + "\"}";
|
||||
return "PxyHttpLog [url=" + url + ", reqLine=" + reqLine + ", resLine=" + resLine + ", cookie=" + cookie
|
||||
+ ", referer=" + referer + ", userAgent=" + userAgent + ", contentLen=" + contentLen + ", contentType="
|
||||
+ contentType + ", setCookie=" + setCookie + ", reqHeader=" + reqHeader + ", respHeader=" + respHeader
|
||||
+ ", reqBody=" + reqBody + ", respBody=" + respBody + ", website=" + website + ", cfgId=" + cfgId
|
||||
+ ", foundTime=" + foundTime + ", recvTime=" + recvTime + ", transProto=" + transProto + ", addrType="
|
||||
+ addrType + ", dIp=" + dIp + ", sIp=" + sIp + ", dPort=" + dPort + ", sPort=" + sPort + ", service="
|
||||
+ service + ", entranceId=" + entranceId + ", deviceId=" + deviceId + ", direction=" + direction
|
||||
+ ", streamDir=" + streamDir + ", capIp=" + capIp + ", addrList=" + addrList + ", serverLocate="
|
||||
+ serverLocate + ", clientLocate=" + clientLocate + ", sAsn=" + sAsn + ", dAsn=" + dAsn
|
||||
+ ", sSubscribeId=" + sSubscribeId + ", dSubscribeId=" + dSubscribeId + ", sceneFile=" + sceneFile
|
||||
+ ", functionId=" + functionId + ", action=" + action + ", date=" + date + ", seltype=" + seltype
|
||||
+ ", searchFoundStartTime=" + searchFoundStartTime + ", searchFoundEndTime=" + searchFoundEndTime
|
||||
+ ", isLogTotalSearch=" + isLogTotalSearch + ", orderBy=" + orderBy + ", encapType=" + encapType
|
||||
+ ", linkId=" + linkId + ", innerSmac=" + innerSmac + ", innerDmac=" + innerDmac + ", id=" + id
|
||||
+ ", currentUser=" + currentUser + ", page=" + page + ", pageLog=" + pageLog + ", sqlMap=" + sqlMap
|
||||
+ ", isNewRecord=" + isNewRecord + ", isFilterAction=" + isFilterAction + "]";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public class GroupReuseAddBean implements Serializable{
|
||||
@Expose
|
||||
private Integer opAction;
|
||||
@Expose
|
||||
@SerializedName("commonGroupList")
|
||||
@SerializedName("groupReuseList")
|
||||
private List<GroupReuseCfg> groupReuseCfgList;
|
||||
|
||||
public String getVersion() {
|
||||
|
||||
@@ -14,7 +14,7 @@ import com.nis.domain.maat.MaatCfg.StringCfg;
|
||||
*
|
||||
*/
|
||||
public class GroupReuseCfg implements Serializable {
|
||||
/*@Expose
|
||||
@Expose
|
||||
@SerializedName("service")
|
||||
private Integer serviceId;
|
||||
public Integer getServiceId() {
|
||||
@@ -23,7 +23,7 @@ public class GroupReuseCfg implements Serializable {
|
||||
public void setServiceId(Integer serviceId) {
|
||||
this.serviceId = serviceId;
|
||||
}
|
||||
*/ /**
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1830956100866313836L;
|
||||
|
||||
@@ -95,8 +95,6 @@ public class MaatCfg implements Serializable {
|
||||
@Expose
|
||||
@SerializedName("ipClientRangeList")
|
||||
private List<IpCfg> areaIpRegionList;
|
||||
@Expose
|
||||
private List<GroupCfg> keepGroupList;
|
||||
|
||||
public static class GroupCfg{
|
||||
@Expose
|
||||
@@ -106,8 +104,6 @@ public class MaatCfg implements Serializable {
|
||||
@Expose
|
||||
private Integer isValid;
|
||||
@Expose
|
||||
private Integer isCommonGroup;
|
||||
@Expose
|
||||
@SerializedName("opTime")
|
||||
private Date auditTime;
|
||||
public Integer getGroupId() {
|
||||
@@ -134,12 +130,7 @@ public class MaatCfg implements Serializable {
|
||||
public void setAuditTime(Date auditTime) {
|
||||
this.auditTime = auditTime;
|
||||
}
|
||||
public Integer getIsCommonGroup() {
|
||||
return isCommonGroup;
|
||||
}
|
||||
public void setIsCommonGroup(Integer isCommonGroup) {
|
||||
this.isCommonGroup = isCommonGroup;
|
||||
}
|
||||
|
||||
}
|
||||
public static class StringCfg{
|
||||
@Expose
|
||||
@@ -688,13 +679,6 @@ public class MaatCfg implements Serializable {
|
||||
public void setRequestId(Integer requestId) {
|
||||
this.requestId = requestId;
|
||||
}
|
||||
|
||||
public List<GroupCfg> getKeepGroupList() {
|
||||
return keepGroupList;
|
||||
}
|
||||
public void setKeepGroupList(List<GroupCfg> keepGroupList) {
|
||||
this.keepGroupList = keepGroupList;
|
||||
}
|
||||
public void initDefaultValue() {
|
||||
this.doLog=Constants.MAAT_CFG_DOLOG_DEFAULT;
|
||||
// this.doBlackList=Constants.MAAT_CFG_DOLOG_DOBLACKLIST_DEFAULT;
|
||||
|
||||
@@ -54,6 +54,8 @@ public class ToUpdateMaatBeanStatus implements Serializable{
|
||||
@Expose
|
||||
private Integer isValid;
|
||||
@Expose
|
||||
private Integer service;
|
||||
@Expose
|
||||
@SerializedName("opTime")
|
||||
private Date auditTime;
|
||||
public Integer getCompileId() {
|
||||
@@ -74,6 +76,12 @@ public class ToUpdateMaatBeanStatus implements Serializable{
|
||||
public void setAuditTime(Date auditTime) {
|
||||
this.auditTime = auditTime;
|
||||
}
|
||||
public Integer getService() {
|
||||
return service;
|
||||
}
|
||||
public void setService(Integer service) {
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
}
|
||||
public String getVersion() {
|
||||
|
||||
@@ -6,9 +6,7 @@ import com.nis.util.excel.ExcelField;
|
||||
public class NtcAsnRecord extends BaseLogEntity<NtcAsnRecord>{
|
||||
|
||||
private static final long serialVersionUID = -4947912502754359817L;
|
||||
@ExcelField(title="GBps",sort=10)
|
||||
protected String GBps;
|
||||
//@ExcelField(title="bps",sort=10)
|
||||
@ExcelField(title="bps",sort=10)
|
||||
protected String bps;
|
||||
@ExcelField(title="pps",sort=9)
|
||||
protected String pps;
|
||||
@@ -28,12 +26,6 @@ public class NtcAsnRecord extends BaseLogEntity<NtcAsnRecord>{
|
||||
}
|
||||
protected String searchAsnType;//1:d_asn;2:s_asn
|
||||
|
||||
public String getGBps() {
|
||||
return bps;
|
||||
}
|
||||
public void setGBps(String gBps) {
|
||||
GBps = this.getBps();
|
||||
}
|
||||
public String getBps() {
|
||||
return bps;
|
||||
}
|
||||
|
||||
@@ -23,21 +23,6 @@ public class ConfigGroupInfo implements Serializable{
|
||||
@ExcelField(title="cfg_id",sort=301)
|
||||
private Integer compileId;
|
||||
private Long asnId;
|
||||
private Integer isAuditAll; //是否有策略选择了此公共组下发所有;
|
||||
private Integer isUsed; //是否有策略选择了此公共组;
|
||||
|
||||
public Integer getIsUsed() {
|
||||
return isUsed;
|
||||
}
|
||||
public void setIsUsed(Integer isUsed) {
|
||||
this.isUsed = isUsed;
|
||||
}
|
||||
public Integer getIsAuditAll() {
|
||||
return isAuditAll;
|
||||
}
|
||||
public void setIsAuditAll(Integer isAuditAll) {
|
||||
this.isAuditAll = isAuditAll;
|
||||
}
|
||||
|
||||
public Long getAsnId() {
|
||||
return asnId;
|
||||
|
||||
@@ -30,13 +30,15 @@ public class SpecificServiceHostCfg extends BaseEntity<SpecificServiceHostCfg>{
|
||||
@Expose
|
||||
private Integer protocol; //protocol 协议 int N 6表示tcp,17表示udp,0表示任意
|
||||
@Expose
|
||||
private Integer ipPattern; //ip格式
|
||||
private Integer srcIpPattern; //ip格式
|
||||
private Integer destIpPattern; //ip格式
|
||||
@Expose
|
||||
private String srcIpAddress; //源(客户端)IP地址
|
||||
@Expose
|
||||
private String destIpAddress; //目的(服务器)IP地址
|
||||
@Expose
|
||||
private Integer portPattern; //端口格式
|
||||
private Integer srcPortPattern; //端口格式
|
||||
private Integer destPortPattern; //端口格式
|
||||
@Expose
|
||||
private String srcPort; //源(客户端)端口
|
||||
@Expose
|
||||
@@ -114,19 +116,33 @@ public class SpecificServiceHostCfg extends BaseEntity<SpecificServiceHostCfg>{
|
||||
public void setDestPort(String destPort) {
|
||||
this.destPort = destPort;
|
||||
}
|
||||
@ExcelField(title="ip_pattern",align=2,sort=21,fieldType=Integer.class)
|
||||
public Integer getIpPattern() {
|
||||
return ipPattern;
|
||||
@ExcelField(title="src_ip_pattern",align=2,sort=21,fieldType=Integer.class)
|
||||
public Integer getSrcIpPattern() {
|
||||
return srcIpPattern;
|
||||
}
|
||||
public void setIpPattern(Integer ipPattern) {
|
||||
this.ipPattern = ipPattern;
|
||||
public void setSrcIpPattern(Integer srcIpPattern) {
|
||||
this.srcIpPattern = srcIpPattern;
|
||||
}
|
||||
@ExcelField(title="port_pattern",align=2,sort=40,fieldType=Integer.class)
|
||||
public Integer getPortPattern() {
|
||||
return portPattern;
|
||||
@ExcelField(title="dest_ip_pattern",align=2,sort=22,fieldType=Integer.class)
|
||||
public Integer getDestIpPattern() {
|
||||
return destIpPattern;
|
||||
}
|
||||
public void setPortPattern(Integer portPattern) {
|
||||
this.portPattern = portPattern;
|
||||
public void setDestIpPattern(Integer destIpPattern) {
|
||||
this.destIpPattern = destIpPattern;
|
||||
}
|
||||
@ExcelField(title="src_port_pattern",align=2,sort=40,fieldType=Integer.class)
|
||||
public Integer getSrcPortPattern() {
|
||||
return srcPortPattern;
|
||||
}
|
||||
public void setSrcPortPattern(Integer srcPortPattern) {
|
||||
this.srcPortPattern = srcPortPattern;
|
||||
}
|
||||
@ExcelField(title="dest_port_pattern",align=2,sort=41,fieldType=Integer.class)
|
||||
public Integer getDestPortPattern() {
|
||||
return destPortPattern;
|
||||
}
|
||||
public void setDestPortPattern(Integer destPortPattern) {
|
||||
this.destPortPattern = destPortPattern;
|
||||
}
|
||||
@ExcelField(title="direction",align=2,sort=110)
|
||||
public Integer getDirection() {
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.nis.persistence.interceptor;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.ibatis.executor.Executor;
|
||||
import org.apache.ibatis.mapping.MappedStatement;
|
||||
import org.apache.ibatis.plugin.Intercepts;
|
||||
import org.apache.ibatis.plugin.Invocation;
|
||||
import org.apache.ibatis.plugin.Plugin;
|
||||
import org.apache.ibatis.plugin.Signature;
|
||||
import org.apache.ibatis.session.Configuration;
|
||||
import org.apache.ibatis.session.ResultHandler;
|
||||
import org.apache.ibatis.session.RowBounds;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.nis.domain.ScheduleCfg;
|
||||
import com.nis.domain.configuration.BaseCfg;
|
||||
import com.nis.util.ServiceConfigTemplateUtil;
|
||||
/**
|
||||
* 定时任务 拦截器
|
||||
* 1、拦截 select 操作
|
||||
* 2、判断是否 form 查询配置主表
|
||||
* 3、如果是配置主表,查询对应的 scheduleCfg信息
|
||||
* @author fang
|
||||
*
|
||||
*/
|
||||
@Intercepts({@Signature(type = Executor.class,
|
||||
method = "query",
|
||||
args = {MappedStatement.class, Object.class, RowBounds.class, ResultHandler.class})})
|
||||
public class ScheduleSelectInterceptor extends BaseInterceptor{
|
||||
private static final long serialVersionUID = -265785145929843646L;
|
||||
private static final Logger logger = Logger.getLogger(ScheduleSelectInterceptor.class);
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("all")
|
||||
public Object intercept(Invocation invocation) throws Throwable {
|
||||
final MappedStatement mappedStatement = (MappedStatement) invocation.getArgs()[0];
|
||||
final Executor executor = (Executor)invocation.getTarget();
|
||||
// select sql 查询结果
|
||||
Object result = invocation.proceed();
|
||||
if(result != null ) {
|
||||
if(result instanceof Collection) {
|
||||
Collection c = (Collection)result;
|
||||
// if(c.size()==1) {//如果只查询一个 配置可以判定为是 form update 页面查询
|
||||
if(c.size() >0) {//配置列表需要查询是否为定时任务,所以需要遍历
|
||||
Iterator iterator = c.iterator();
|
||||
while(iterator.hasNext()){
|
||||
Object next = iterator.next();
|
||||
if(next instanceof BaseCfg<?>) {
|
||||
BaseCfg cfg = (BaseCfg)next;
|
||||
//结果集的类名
|
||||
String simpleName = next.getClass().getSimpleName();
|
||||
//根据类名查找对应的 表名
|
||||
String tableName = ServiceConfigTemplateUtil.getCfgTableNameByClassName(simpleName);
|
||||
if(tableName != null) {//是配置主表
|
||||
Configuration configuration = mappedStatement.getConfiguration();
|
||||
MappedStatement scheduleStmt = configuration.getMappedStatement("com.nis.web.dao.SchedulerDao.findScheduleList");
|
||||
ScheduleCfg sc = new ScheduleCfg();
|
||||
sc.setTableName(tableName);
|
||||
sc.setCfgId(cfg.getCfgId());
|
||||
sc.setCompileId(cfg.getCompileId());
|
||||
//executor.clearLocalCache();
|
||||
List<ScheduleCfg> schedules = executor.query(scheduleStmt, sc, RowBounds.DEFAULT, Executor.NO_RESULT_HANDLER);
|
||||
if(schedules != null&& schedules.size() > 0) {
|
||||
cfg.setSchedule(schedules.get(0));
|
||||
}
|
||||
logger.debug(String.format("配置bean中赋值scheduleCfg,表名:%s,类名:%s,cfgId:%s,compileId:%s,schedules num:%s", tableName,simpleName,sc.getCfgId(),sc.getCompileId(),schedules==null?0:schedules.size()));
|
||||
}
|
||||
}else{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object plugin(Object target) {
|
||||
return Plugin.wrap(target, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProperties(Properties properties) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,396 @@
|
||||
package com.nis.persistence.interceptor;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.sql.SQLException;
|
||||
import java.text.DateFormat;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.ibatis.executor.Executor;
|
||||
import org.apache.ibatis.mapping.BoundSql;
|
||||
import org.apache.ibatis.mapping.MappedStatement;
|
||||
import org.apache.ibatis.mapping.ParameterMapping;
|
||||
import org.apache.ibatis.plugin.Intercepts;
|
||||
import org.apache.ibatis.plugin.Invocation;
|
||||
import org.apache.ibatis.plugin.Plugin;
|
||||
import org.apache.ibatis.plugin.Signature;
|
||||
import org.apache.ibatis.reflection.MetaObject;
|
||||
import org.apache.ibatis.session.Configuration;
|
||||
import org.apache.ibatis.session.RowBounds;
|
||||
import org.apache.ibatis.type.TypeHandlerRegistry;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
|
||||
import com.alibaba.druid.sql.ast.statement.SQLUpdateSetItem;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlUpdateStatement;
|
||||
import com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.nis.domain.ScheduleCfg;
|
||||
import com.nis.domain.ScheduleExceInfo;
|
||||
import com.nis.domain.configuration.BaseCfg;
|
||||
import com.nis.util.ServiceConfigTemplateUtil;
|
||||
import com.nis.web.security.UserUtils;
|
||||
|
||||
import jersey.repackaged.com.google.common.collect.Sets;
|
||||
/**
|
||||
* 定时任务 拦截器
|
||||
* 1、拦截insert,update,delete操作
|
||||
* 2、判断是否是需要下发配置的表
|
||||
* 3、如果是需要下发配置的表,则同时将数据保存到schedule_cfg表中,并调用定时任务
|
||||
* @author fang
|
||||
*
|
||||
*/
|
||||
@Intercepts({@Signature(
|
||||
type= Executor.class,
|
||||
method = "update",
|
||||
args = {MappedStatement.class,Object.class})})
|
||||
public class ScheduleUpdateInterceptor extends BaseInterceptor{
|
||||
private static final long serialVersionUID = -265785145929843646L;
|
||||
private static final Logger logger = Logger.getLogger(ScheduleUpdateInterceptor.class);
|
||||
|
||||
private static final String TABLE_NAME_INSERT_REG = "^\\s*insert\\s+into\\s+([\\w_-]+)\\s*\\(";
|
||||
private static final Pattern TABLE_NAME_INSERT_PATTERN = Pattern.compile(TABLE_NAME_INSERT_REG, Pattern.CASE_INSENSITIVE);//大小写
|
||||
|
||||
private static final String TABLE_NAME_UPDATE_REG = "^\\s*update\\s+([\\w_-]+)";
|
||||
private static final Pattern TABLE_NAME_UPDATE_PATTERN = Pattern.compile(TABLE_NAME_UPDATE_REG, Pattern.CASE_INSENSITIVE);//大小写
|
||||
|
||||
private static final String TABLE_NAME_DELETE_REG = "^\\s*delete\\s+from\\s+([\\w_-]+)";
|
||||
private static final Pattern TABLE_NAME_DELETE_PATTERN = Pattern.compile(TABLE_NAME_DELETE_REG, Pattern.CASE_INSENSITIVE);//大小写
|
||||
/**
|
||||
* 排除拦截的id
|
||||
*/
|
||||
private static final Set<String> EXCLUDE_MAPPER_IDS = Sets.newHashSet();
|
||||
static {
|
||||
EXCLUDE_MAPPER_IDS.add("com.nis.web.dao.SchedulerDao.updateCfgTableStatus");
|
||||
EXCLUDE_MAPPER_IDS.add("com.nis.web.dao.basics.ServiceDictInfoDao");
|
||||
EXCLUDE_MAPPER_IDS.add("com.nis.web.dao.configuration.PxyObjKeyringDao.updatePxyObjTrustedCaCrl");
|
||||
EXCLUDE_MAPPER_IDS.add("com.nis.web.dao.configuration.CommonPolicyDao.auditCfgBatch");
|
||||
EXCLUDE_MAPPER_IDS.add("com.nis.web.dao.configuration.CommonPolicyDao.deleteCfgBatch");
|
||||
}
|
||||
/**
|
||||
* is_valid 字段名
|
||||
*/
|
||||
private static final String IS_VALID_COLUMN = "is_valid";
|
||||
/**
|
||||
* is_audit 字段名
|
||||
*/
|
||||
private static final String IS_AUDIT_COLUMN = "is_audit";
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("all")
|
||||
public Object intercept(Invocation invocation) throws Throwable {
|
||||
final MappedStatement mappedStatement = (MappedStatement) invocation.getArgs()[0];
|
||||
final Executor executor = (Executor)invocation.getTarget();
|
||||
Object parameter = invocation.getArgs()[1];//被拦截的 sql 参数
|
||||
BoundSql boundSql = mappedStatement.getBoundSql(parameter);
|
||||
Object result = invocation.proceed();//被拦截的 sql 操作 继续执行
|
||||
String curProceedId = mappedStatement.getId();
|
||||
//不需要拦截的操作直接返回结果
|
||||
if(EXCLUDE_MAPPER_IDS.contains(curProceedId)) {
|
||||
return result;
|
||||
}
|
||||
String tableName = null;//操作的表名
|
||||
//mybatis 整个mapper 信息
|
||||
Configuration configuration = mappedStatement.getConfiguration();
|
||||
//被拦截的 sql语句
|
||||
String sql = boundSql.getSql();
|
||||
//所有需要拦截的表名
|
||||
Set<String> tableNames = ServiceConfigTemplateUtil.getCompileTableName();
|
||||
|
||||
switch (mappedStatement.getSqlCommandType()) {
|
||||
case INSERT://新增配置
|
||||
Matcher insertMatcher = TABLE_NAME_INSERT_PATTERN.matcher(sql);
|
||||
tableName = insertMatcher.find()?insertMatcher.group(1):tableName;
|
||||
if(tableName != null && tableNames.contains(tableName.toLowerCase())) {
|
||||
insertCfg(executor,parameter, configuration,tableName);
|
||||
}
|
||||
break;
|
||||
case UPDATE://更新配置
|
||||
Matcher updateMatcher = TABLE_NAME_UPDATE_PATTERN.matcher(sql);
|
||||
tableName = updateMatcher.find()?updateMatcher.group(1):tableName;
|
||||
if(tableName != null && tableNames.contains(tableName.toLowerCase())) {
|
||||
updateCfg(executor,boundSql, configuration,tableName);
|
||||
}
|
||||
break;
|
||||
case DELETE://删除配置
|
||||
Matcher deleteMatcher = TABLE_NAME_DELETE_PATTERN.matcher(sql);
|
||||
tableName = deleteMatcher.find()?deleteMatcher.group(1):tableName;
|
||||
if(tableName != null && tableNames.contains(tableName.toLowerCase())) {
|
||||
deleteCfg(executor,parameter, configuration,tableName);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
logger.debug(sql);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object plugin(Object target) {
|
||||
return Plugin.wrap(target, this);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @throws SQLException
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("all")
|
||||
private void insertCfg(Executor executor,Object parameterObject,Configuration configuration,String tableName) throws SQLException {
|
||||
List<BaseCfg> cfgList = Lists.newArrayList();
|
||||
//确保 单个,批量都适用
|
||||
if(parameterObject instanceof BaseCfg<?>) {//单个添加
|
||||
BaseCfg<?> baseCfg = (BaseCfg<?>)parameterObject;
|
||||
cfgList.add(baseCfg);
|
||||
}else if(parameterObject instanceof Collection) {
|
||||
Collection<BaseCfg<?>> bcCollection = (Collection<BaseCfg<?>>)parameterObject;
|
||||
cfgList.addAll(bcCollection);
|
||||
}else if(parameterObject.getClass().isArray()) {
|
||||
int length = Array.getLength(parameterObject);
|
||||
for(int i = 0;i< length;i++) {
|
||||
BaseCfg<?> baseCfg = (BaseCfg<?>)Array.get(parameterObject, i);
|
||||
cfgList.add(baseCfg);
|
||||
}
|
||||
}
|
||||
//整理需要 insert 的 schedule_cfg 的数据
|
||||
List<ScheduleCfg> scheduleList = Lists.newArrayList();
|
||||
for(BaseCfg<?> baseCfg : cfgList) {
|
||||
ScheduleCfg scList = copyScheduleCfgFromBaseCfg(baseCfg, tableName);
|
||||
if(scList!=null){
|
||||
//TODO 定时任务设置默认为isValid=0 isAudit=0,需要考虑允许用户新增isValid=1 isAudit=1的配置下发
|
||||
scList.setIsValid(0);//设置默认值
|
||||
scList.setIsAudit(0);//设置默认值
|
||||
scheduleList.add(scList);
|
||||
}
|
||||
}
|
||||
|
||||
if(scheduleList.size() > 0) {
|
||||
for(ScheduleCfg sc : scheduleList) {
|
||||
MappedStatement statement = configuration.getMappedStatement("com.nis.web.dao.SchedulerDao.insert");
|
||||
executor.update(statement, sc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("all")
|
||||
private void updateCfg(Executor executor,BoundSql boundSql,Configuration configuration,String tableName) throws SQLException {
|
||||
/*
|
||||
* 条件1: is_valid=0,is_audit=0; 未生效之前修改,来自修改页面
|
||||
*1、首先将所有相关定时任务信息取消
|
||||
*2、 新增 定时任务信息
|
||||
*/
|
||||
Object parameterObject = boundSql.getParameterObject();
|
||||
if(parameterObject instanceof BaseCfg) {
|
||||
BaseCfg bc = (BaseCfg)parameterObject;
|
||||
Integer isValid = bc.getIsValid();
|
||||
Integer isAudit = bc.getIsAudit();
|
||||
Integer compileId = bc.getCompileId();
|
||||
Long cfgId = bc.getCfgId();
|
||||
if(isValid == 0 && isAudit == 0) {
|
||||
ScheduleCfg sc = new ScheduleCfg();
|
||||
sc.setCompileId(compileId);
|
||||
sc.setEditorId(bc.getEditorId());
|
||||
sc.setEditTime(bc.getEditTime());
|
||||
sc.setType(1);
|
||||
sc.setCfgId(cfgId);
|
||||
//根据 compileId 删除之前的
|
||||
MappedStatement statement = configuration.getMappedStatement("com.nis.web.dao.SchedulerDao.deleteByCompileId");
|
||||
executor.update(statement, sc);
|
||||
//新增 更改的
|
||||
ScheduleCfg schedule = copyScheduleCfgFromBaseCfg(bc, tableName);
|
||||
if(schedule != null ) {
|
||||
statement = configuration.getMappedStatement("com.nis.web.dao.SchedulerDao.insert");
|
||||
executor.update(statement, schedule);
|
||||
//配置信息新增,或取消之后重新修改,需要修改 exce_new表的状态
|
||||
statement = configuration.getMappedStatement("com.nis.web.dao.SchedulerDao.updateScheduleExceNew");
|
||||
ScheduleExceInfo exceNew = new ScheduleExceInfo();
|
||||
exceNew.setCompileId(compileId);
|
||||
exceNew.setIssueStatus(1);
|
||||
exceNew.setIsIssue(1);//定时任务执行时需要下发配置
|
||||
executor.update(statement, exceNew);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
//完整的sql语句,已经完成 ? 替换
|
||||
String sql = showSql(configuration, boundSql);
|
||||
log.debug(String.format("cfg update sql : " , sql));
|
||||
//其它剩余基本判定为 修改状态的 update
|
||||
MySqlStatementParser parser = new MySqlStatementParser(sql);
|
||||
MySqlUpdateStatement updateSqlStmt = (MySqlUpdateStatement)parser.parseStatement();
|
||||
List<SQLUpdateSetItem> items = updateSqlStmt.getItems();
|
||||
/* 分别获取 is_audit & is_valid 的值*/
|
||||
Integer isValid = null;
|
||||
Integer isAudit = null;
|
||||
for(SQLUpdateSetItem item : items) {
|
||||
if(IS_VALID_COLUMN.equalsIgnoreCase(item.getColumn().toString())) {
|
||||
isValid = Integer.valueOf(item.getValue().toString());
|
||||
continue;
|
||||
}
|
||||
if(IS_AUDIT_COLUMN.equalsIgnoreCase(item.getColumn().toString())) {
|
||||
isAudit = Integer.valueOf(item.getValue().toString());
|
||||
continue;
|
||||
}
|
||||
if(isValid != null && isAudit != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
//isValid 和 isAudit 同时为空,目前发现有 取消来函的 update 操作有此情况
|
||||
if(isValid == null && isAudit == null) {
|
||||
return;
|
||||
}
|
||||
//获取当前的update 条件
|
||||
String whereStr = updateSqlStmt.getWhere().toString();
|
||||
StringBuilder whereSb = new StringBuilder();
|
||||
whereSb.append(" and table_name = '");
|
||||
whereSb.append(tableName);
|
||||
whereSb.append("' and ( ");
|
||||
whereSb.append(whereStr);
|
||||
whereSb.append(" )");
|
||||
//根据当前的 update 条件 查出所有符合条件的 schedule_cfg 数据
|
||||
MappedStatement scheduleStmt = configuration.getMappedStatement("com.nis.web.dao.SchedulerDao.findScheduleList");
|
||||
ScheduleCfg sc = new ScheduleCfg();
|
||||
sc.setWhereStr(whereSb.toString());
|
||||
List<ScheduleCfg> schedules = executor.query(scheduleStmt, sc, RowBounds.DEFAULT, Executor.NO_RESULT_HANDLER);
|
||||
if(schedules != null && schedules.size() > 0) {//有符合条件的 定时任务
|
||||
Set<Integer> compileSet = Sets.newHashSet();//保存操作的所有 compileId
|
||||
Date now = new Date();//当前时间
|
||||
//1、将符合条件的是 ScheduleCfg update del_flag = 0
|
||||
for(ScheduleCfg scfg : schedules) {
|
||||
compileSet.add(scfg.getCompileId());
|
||||
scfg.setEditorId(UserUtils.getUser().getId());
|
||||
scfg.setEditTime(now);
|
||||
MappedStatement statement = configuration.getMappedStatement("com.nis.web.dao.SchedulerDao.deleteByCompileId");
|
||||
executor.update(statement, scfg);
|
||||
}
|
||||
//2、把原信息 重新保存,并修改 is_valid ,is_audit 状态
|
||||
for(ScheduleCfg scfg : schedules) {
|
||||
MappedStatement statement = configuration.getMappedStatement("com.nis.web.dao.SchedulerDao.insert");
|
||||
scfg.setIsValid(isValid);
|
||||
scfg.setIsAudit(isAudit);
|
||||
scfg.setType(1);
|
||||
executor.update(statement, scfg);
|
||||
}
|
||||
//手动 审核通过,立即生效时 已经下发,修改 exce_new 表的是否需要下发字段为 不需要 : 0
|
||||
if(isValid == 1 && isAudit == 1) {
|
||||
for(Integer ci : compileSet) {
|
||||
MappedStatement statement = configuration.getMappedStatement("com.nis.web.dao.SchedulerDao.findScheduleExceNew");
|
||||
ScheduleExceInfo se = new ScheduleExceInfo();
|
||||
se.setCompileId(ci);
|
||||
se.setIsValid(isValid);
|
||||
List<ScheduleExceInfo> seList = executor.query(statement, se, RowBounds.DEFAULT, Executor.NO_RESULT_HANDLER);
|
||||
if(seList == null || seList.size() < 1) {//没有执行记录,新增一条
|
||||
//配置信息新增,或取消之后重新修改,需要修改 exce_new表的状态
|
||||
statement = configuration.getMappedStatement("com.nis.web.dao.SchedulerDao.insertScheduleExceNew");
|
||||
ScheduleExceInfo exceNew = new ScheduleExceInfo();
|
||||
exceNew.setCompileId(ci);
|
||||
exceNew.setIssueStatus(1);
|
||||
exceNew.setIsIssue(0);//已经下发,定时任务不需要下发
|
||||
exceNew.setExceTime(new Date());
|
||||
executor.update(statement, exceNew);
|
||||
}else {
|
||||
//配置信息新增,或取消之后重新修改,需要修改 exce_new表的状态
|
||||
statement = configuration.getMappedStatement("com.nis.web.dao.SchedulerDao.updateScheduleExceNew");
|
||||
ScheduleExceInfo exceNew = new ScheduleExceInfo();
|
||||
exceNew.setCompileId(ci);
|
||||
exceNew.setIssueStatus(1);
|
||||
exceNew.setIsIssue(0);//已经下发,定时任务不需要下发
|
||||
executor.update(statement, exceNew);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 暂时没有发现有 删除操作
|
||||
*/
|
||||
@SuppressWarnings("all")
|
||||
private void deleteCfg(Executor executor,Object parameterObject,Configuration configuration,String tableName) throws SQLException {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 从 basecfg 实体类中获取 schedule cfg
|
||||
* @param baseCfg
|
||||
* @param tableName
|
||||
* @return
|
||||
*/
|
||||
private ScheduleCfg copyScheduleCfgFromBaseCfg(BaseCfg<?> baseCfg,String tableName){
|
||||
ScheduleCfg schedule = baseCfg.getSchedule();
|
||||
if(schedule != null ) {
|
||||
BeanUtils.copyProperties(baseCfg, schedule,new String[]{"userRegion1","userRegion2","userRegion3","userRegion4","userRegion5"});
|
||||
schedule.setTableName(tableName);
|
||||
schedule.setType(1);
|
||||
}
|
||||
return schedule;
|
||||
}
|
||||
|
||||
|
||||
/*如果参数是String,则添加单引号, 如果是日期,则转换为时间格式器并加单引号; 对参数是null和不是null的情况作了处理*/
|
||||
private static String getParameterValue(Object obj) {
|
||||
String value = null;
|
||||
if (obj instanceof String) {
|
||||
value = "'" + obj.toString() + "'";
|
||||
} else if (obj instanceof Date) {
|
||||
DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT, Locale.getDefault());
|
||||
value = "'" + formatter.format(new Date()) + "'";
|
||||
} else {
|
||||
if (obj != null) {
|
||||
value = obj.toString();
|
||||
} else {
|
||||
value = "null";
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
// 进行?的替换
|
||||
public static String showSql(Configuration configuration, BoundSql boundSql) {
|
||||
Object parameterObject = boundSql.getParameterObject(); // 获取参数
|
||||
List<ParameterMapping> parameterMappings = boundSql.getParameterMappings();
|
||||
String sql = boundSql.getSql().replaceAll("[\\s]+", " "); // sql语句中多个空格都用一个空格代替
|
||||
if (parameterMappings != null && parameterMappings.size() >0 && parameterObject != null) {
|
||||
TypeHandlerRegistry typeHandlerRegistry = configuration.getTypeHandlerRegistry(); // 获取类型处理器注册器,类型处理器的功能是进行java类型和数据库类型的转换<br> // 如果根据parameterObject.getClass()可以找到对应的类型,则替换
|
||||
if (typeHandlerRegistry.hasTypeHandler(parameterObject.getClass())) {
|
||||
sql = sql.replaceFirst("\\?", Matcher.quoteReplacement(getParameterValue(parameterObject)));
|
||||
|
||||
} else {
|
||||
MetaObject metaObject = configuration.newMetaObject(parameterObject);// MetaObject主要是封装了originalObject对象,提供了get和set的方法用于获取和设置originalObject的属性值,主要支持对JavaBean、Collection、Map三种类型对象的操作
|
||||
for (ParameterMapping parameterMapping : parameterMappings) {
|
||||
String propertyName = parameterMapping.getProperty();
|
||||
if (metaObject.hasGetter(propertyName)) {
|
||||
Object obj = metaObject.getValue(propertyName);
|
||||
sql = sql.replaceFirst("\\?", Matcher.quoteReplacement(getParameterValue(obj)));
|
||||
} else if (boundSql.hasAdditionalParameter(propertyName)) {
|
||||
Object obj = boundSql.getAdditionalParameter(propertyName); // 该分支是动态sql
|
||||
sql = sql.replaceFirst("\\?", Matcher.quoteReplacement(getParameterValue(obj)));
|
||||
}else{sql=sql.replaceFirst("\\?","缺失");}//打印出缺失,提醒该参数缺失并防止错位
|
||||
}
|
||||
}
|
||||
}
|
||||
return sql;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setProperties(Properties properties) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
578
src/main/java/com/nis/quartz/ScheduleCfgJob.java
Normal file
578
src/main/java/com/nis/quartz/ScheduleCfgJob.java
Normal file
@@ -0,0 +1,578 @@
|
||||
package com.nis.quartz;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.quartz.CalendarIntervalScheduleBuilder;
|
||||
import org.quartz.CalendarIntervalTrigger;
|
||||
import org.quartz.CronScheduleBuilder;
|
||||
import org.quartz.DateBuilder;
|
||||
import org.quartz.DisallowConcurrentExecution;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobBuilder;
|
||||
import org.quartz.JobDataMap;
|
||||
import org.quartz.JobDetail;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
import org.quartz.JobKey;
|
||||
import org.quartz.PersistJobDataAfterExecution;
|
||||
import org.quartz.ScheduleBuilder;
|
||||
import org.quartz.Scheduler;
|
||||
import org.quartz.SchedulerException;
|
||||
import org.quartz.SimpleScheduleBuilder;
|
||||
import org.quartz.SimpleTrigger;
|
||||
import org.quartz.Trigger;
|
||||
import org.quartz.TriggerBuilder;
|
||||
import org.quartz.TriggerKey;
|
||||
import org.quartz.impl.matchers.GroupMatcher;
|
||||
import org.quartz.impl.triggers.CalendarIntervalTriggerImpl;
|
||||
import org.quartz.impl.triggers.CronTriggerImpl;
|
||||
import org.quartz.spi.MutableTrigger;
|
||||
|
||||
import com.nis.domain.ScheduleCfg;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.DateUtil;
|
||||
import com.nis.util.DateUtils;
|
||||
import com.nis.util.StringUtils;
|
||||
import com.nis.web.dao.SchedulerDao;
|
||||
import com.nis.web.service.SpringContextHolder;
|
||||
|
||||
/**
|
||||
* 定时任务 配置定时任务加载
|
||||
* 1、每 n s 执行一次,每次读取 schedule_cfg 最新的数据
|
||||
* 2、删除或新增 定时任务
|
||||
* 3、单线程执行
|
||||
* @author fang
|
||||
*
|
||||
*/
|
||||
@DisallowConcurrentExecution
|
||||
@PersistJobDataAfterExecution
|
||||
public class ScheduleCfgJob implements Job {
|
||||
private static final Logger log = Logger.getLogger(ScheduleCfgJob.class);
|
||||
|
||||
/**
|
||||
* 状态组,格式:statusGroup-compileId
|
||||
*/
|
||||
private static final String STATUS_GROUP = "statusGroup-";
|
||||
private static final String STATUS_JOB = "STATUS-JOB";
|
||||
/**
|
||||
* 生效标识:valid-cronexp
|
||||
*/
|
||||
private static final String VALID_KEY = "valid-";
|
||||
/**
|
||||
* 失效标识:invalid-cronexp
|
||||
*/
|
||||
private static final String INVALID_KEY = "invalid-";
|
||||
private static final JobKey STATUS_JOBKEY = JobKey.jobKey(STATUS_JOB, "statusGroup");
|
||||
private static final JobDetail STATUS_JOBDETAIL = JobBuilder.newJob(ScheduleStatusJob.class)
|
||||
.withIdentity(STATUS_JOBKEY)
|
||||
.storeDurably(true)
|
||||
.build();
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||
Scheduler scheduler = context.getScheduler();
|
||||
SchedulerDao dao = SpringContextHolder.getBean(SchedulerDao.class);
|
||||
JobDataMap dataMap = context.getJobDetail().getJobDataMap();
|
||||
long scheduleCfgId = dataMap.get("scheduleCfgId") == null ? 0:dataMap.getLong("scheduleCfgId");
|
||||
long limit = dataMap.get("limit") == null ? Constants.MAAT_JSON_SEND_SIZE:dataMap.getLong("limit");
|
||||
log.info(String.format("定时配置任务开始执行,scheduleCfgId:%s,limit:%s",scheduleCfgId,limit ));
|
||||
List<ScheduleCfg> allNewlySche = null;
|
||||
int totalNum = 0;
|
||||
do {
|
||||
allNewlySche = dao.findNewlyCfg(scheduleCfgId, limit,1,1);
|
||||
if(allNewlySche != null && allNewlySche.size() > 0) {
|
||||
List<ScheduleCfg> allAddSche = new ArrayList<>();
|
||||
totalNum += allNewlySche.size();
|
||||
//先取消之前的定时配置
|
||||
for(ScheduleCfg cfg : allNewlySche) {
|
||||
//获取有效的任务
|
||||
if(cfg.getDelFlag()==1) {
|
||||
allAddSche.add(cfg);
|
||||
}
|
||||
Integer compileId = cfg.getCompileId();
|
||||
try {
|
||||
//取消之前所有的 trigger
|
||||
GroupMatcher<TriggerKey> groupMatcher= GroupMatcher.triggerGroupEquals(STATUS_GROUP + compileId);
|
||||
Set<TriggerKey> triggerKeys = scheduler.getTriggerKeys(groupMatcher);
|
||||
if(triggerKeys != null && triggerKeys.size() > 0) {
|
||||
for(TriggerKey tk : triggerKeys) {
|
||||
scheduler.unscheduleJob(tk);
|
||||
}
|
||||
log.info(String.format("定时任务取消成功,compile:%s", compileId));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(String.format("定时任务取消异常,compileId:%s", compileId),e);
|
||||
}
|
||||
}
|
||||
for(ScheduleCfg cfg : allAddSche) {
|
||||
Integer compileId = cfg.getCompileId();
|
||||
try {
|
||||
//判断状态,重新添加最新的 trigger
|
||||
Integer isValid = cfg.getIsValid();
|
||||
Integer isAudit = cfg.getIsAudit();
|
||||
//添加定时任务的条件
|
||||
if((isValid == 1 && isAudit == 1) || (isValid == 0 && isAudit == 0)) {
|
||||
//添加定时任务,包括valid 和 invalid
|
||||
addJob(scheduler, cfg);
|
||||
log.info(String.format("定时任务添加成功,compile:%s", compileId));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(String.format("定时任务更新异常,compileId:%s", compileId),e);
|
||||
}
|
||||
}
|
||||
//最后 保存此次 最后的id
|
||||
ScheduleCfg lastCfg = allNewlySche.get(allNewlySche.size() -1);
|
||||
scheduleCfgId = lastCfg.getId();
|
||||
dataMap.put("scheduleCfgId", scheduleCfgId);
|
||||
log.info(String.format("加载定时任务,total num :%s", allNewlySche.size()));
|
||||
}
|
||||
} while (allNewlySche != null && allNewlySche.size() > 0);
|
||||
log.info(String.format("定时配置任务结束执行,total num:%s",totalNum));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 将定时任务信息添加到 定时器框架中调度
|
||||
* @param scheduler
|
||||
* @param cfg
|
||||
* @throws SchedulerException
|
||||
*/
|
||||
/*public static void addJob(Scheduler scheduler,ScheduleCfg cfg) throws SchedulerException {
|
||||
Integer compileId = cfg.getCompileId();
|
||||
String cronValid = cfg.getCronValid();
|
||||
String cronInvalid = cfg.getCronInvalid();
|
||||
Trigger validTrigger = createTrigger(cronValid, compileId, true, cfg);
|
||||
Trigger invalidTrigger = createTrigger(cronInvalid, compileId, false, cfg);
|
||||
boolean jobExist = scheduler.checkExists(STATUS_JOBKEY);
|
||||
if(!jobExist) {//判断 job 是否存在,不存在添加
|
||||
scheduler.addJob(STATUS_JOBDETAIL, false);
|
||||
}
|
||||
boolean checkExists = scheduler.checkExists(validTrigger.getKey());
|
||||
if(!checkExists) {//判断 valid trigger 是否存在,不存在添加
|
||||
scheduler.scheduleJob(validTrigger);
|
||||
}else {
|
||||
log.warn(String.format("Trigger already exists:%s ", validTrigger.getKey().toString()));
|
||||
}
|
||||
checkExists = scheduler.checkExists(invalidTrigger.getKey());
|
||||
if(!checkExists) {//判断 invalid trigger 是否存在,不存在添加
|
||||
scheduler.scheduleJob(invalidTrigger);
|
||||
}else {
|
||||
log.warn(String.format("Trigger already exists:%s ", invalidTrigger.getKey().toString()));
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
public static void addJob(Scheduler scheduler,ScheduleCfg cfg) throws SchedulerException {
|
||||
List<Trigger> triList = createTrigger(cfg);
|
||||
boolean jobExist = scheduler.checkExists(STATUS_JOBKEY);
|
||||
if(!jobExist) {//判断 job 是否存在,不存在添加
|
||||
scheduler.addJob(STATUS_JOBDETAIL, false);
|
||||
}
|
||||
for(Trigger tri : triList) {
|
||||
boolean checkExists = scheduler.checkExists(tri.getKey());
|
||||
if(!checkExists) {//判断 valid trigger 是否存在,不存在添加
|
||||
log.debug(String.format("定时任务添加,%s", tri.getKey()));
|
||||
scheduler.scheduleJob(tri);
|
||||
log.info(String.format("定时任务添加成功,%s", tri.getKey()));
|
||||
}else {
|
||||
log.warn(String.format("Trigger already exists:%s ", tri.getKey().toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将页面配置的内容 转换成 trigger
|
||||
* @param cfg
|
||||
* @return
|
||||
*/
|
||||
public static List<Trigger> createTrigger(ScheduleCfg cfg){
|
||||
String mode = cfg.getUserRegion1().toUpperCase();//定时任务运行模式:一次,每天,每周,每月
|
||||
List<Trigger> triList = null;
|
||||
switch (mode) {
|
||||
case "ALWAYS"://单次运行,但只创建单次生效触发器
|
||||
triList = createSimpleTrigger(cfg);
|
||||
break;
|
||||
case "SINGLE"://单次运行
|
||||
triList = createSimpleTrigger(cfg);
|
||||
break;
|
||||
case "EVERYDAY"://每天运行 0 0 0 2/1 * ? ,不符合要求,定义每天都执行,然后在 代码判断 间隔时间
|
||||
triList = createCalendarIntervalTrigger(cfg);
|
||||
break;
|
||||
case "EVERYWEEK"://每周运行
|
||||
triList = createCalendarIntervalTrigger(cfg);
|
||||
break;
|
||||
case "EVERYMONTH"://每月运行
|
||||
triList = createEveryMonthTrigger(cfg);
|
||||
break;
|
||||
default:
|
||||
log.warn(String.format("unknown mode : %s ", mode));
|
||||
break;
|
||||
}
|
||||
return triList;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 将时间转换成 时分秒
|
||||
* @param time
|
||||
* @return
|
||||
*/
|
||||
public static List<Integer> parseTime(String time) {
|
||||
if(StringUtils.isNoneBlank(time)) {
|
||||
String[] split = time.split(":");
|
||||
List<Integer> tl = new ArrayList<Integer>(3);
|
||||
for(String s : split) {
|
||||
tl.add(Integer.valueOf(s));
|
||||
}
|
||||
return tl;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Trigger createCronTrigger(String cron,Integer compileId,boolean isValid,ScheduleCfg cfg) {
|
||||
String triggerName = isValid ? (VALID_KEY + cron) : (INVALID_KEY + cron);
|
||||
JobDataMap dataMap = new JobDataMap();
|
||||
dataMap.put("isValid", isValid);
|
||||
dataMap.put("cfg", cfg);
|
||||
return TriggerBuilder.newTrigger()
|
||||
.withIdentity(createTiggerKey(triggerName, STATUS_GROUP+compileId))
|
||||
.withSchedule(CronScheduleBuilder.cronSchedule(cron))
|
||||
.usingJobData(dataMap)
|
||||
.forJob(STATUS_JOBDETAIL)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 一次执行
|
||||
* @param cfg
|
||||
* @return
|
||||
*/
|
||||
public static List<Trigger> createSimpleTrigger(ScheduleCfg cfg){
|
||||
List<Trigger> triList = new ArrayList<Trigger>();
|
||||
Integer compileId = cfg.getCompileId();
|
||||
String cronValid = cfg.getCronValid();
|
||||
String cronInvalid = cfg.getCronInvalid();
|
||||
Date validDate = null;
|
||||
Date invalidDate = null;
|
||||
if(StringUtils.isNotBlank(cronValid)){
|
||||
validDate = DateUtil.convertStringToDate(cronValid, Constants.COMMON_DATE_FORMAT);
|
||||
}
|
||||
if(StringUtils.isNotBlank(cronInvalid)){
|
||||
invalidDate = DateUtil.convertStringToDate(cronInvalid, Constants.COMMON_DATE_FORMAT);
|
||||
}
|
||||
JobDataMap dataMap = new JobDataMap();
|
||||
if(validDate!=null){//生效时间如果不为空,则创建定时生效触发器
|
||||
dataMap.put("isValid", true);
|
||||
dataMap.put("cfg", cfg);
|
||||
String triName = VALID_KEY + cfg.getUserRegion1() + "_" + cronValid;
|
||||
Trigger trigger = TriggerBuilder.newTrigger()
|
||||
.withIdentity(createTiggerKey(triName, STATUS_GROUP+compileId))
|
||||
.withSchedule(SimpleScheduleBuilder.simpleSchedule())
|
||||
.usingJobData(dataMap)
|
||||
.forJob(STATUS_JOBDETAIL)
|
||||
.startAt(validDate)
|
||||
.build();
|
||||
triList.add(trigger);
|
||||
}
|
||||
if(invalidDate!=null){//失效时间如果不为空,则创建定时失效触发器
|
||||
dataMap = new JobDataMap();
|
||||
dataMap.put("isValid", false);
|
||||
dataMap.put("cfg", cfg);
|
||||
String triName = INVALID_KEY + cfg.getUserRegion1() + "_" + cronInvalid;
|
||||
Trigger trigger = TriggerBuilder.newTrigger()
|
||||
.withIdentity(createTiggerKey(triName, STATUS_GROUP+compileId))
|
||||
.withSchedule(SimpleScheduleBuilder.simpleSchedule())
|
||||
.usingJobData(dataMap)
|
||||
.forJob(STATUS_JOBDETAIL)
|
||||
.startAt(invalidDate)
|
||||
.build();
|
||||
triList.add(trigger);
|
||||
}
|
||||
return triList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 间隔 n 天 或 n 周执行
|
||||
* @param cfg
|
||||
* @return
|
||||
*/
|
||||
public static List<Trigger> createCalendarIntervalTrigger(ScheduleCfg cfg) {
|
||||
List<Trigger> triList = new ArrayList<Trigger>();
|
||||
Integer compileId = cfg.getCompileId();
|
||||
String cronValid = cfg.getCronValid();
|
||||
String cronInvalid = cfg.getCronInvalid();
|
||||
String dayOrWeek = cfg.getUserRegion1();
|
||||
Integer interval = Integer.valueOf(cfg.getUserRegion2());
|
||||
List<Integer> validList = parseTime(cronValid);
|
||||
List<Integer> invalidList = parseTime(cronInvalid);
|
||||
Date validStartTime = DateBuilder.todayAt(validList.get(0), validList.get(1), validList.get(2));
|
||||
Date invalidTime = DateBuilder.todayAt(invalidList.get(0), invalidList.get(1), invalidList.get(2));
|
||||
CalendarIntervalScheduleBuilder intervalBuilder = null;
|
||||
if("EVERYDAY".equalsIgnoreCase(dayOrWeek)) {
|
||||
//开始时间+2分钟
|
||||
Calendar validStartCal=Calendar.getInstance();
|
||||
validStartCal.setTime(validStartTime);
|
||||
validStartCal.add(Calendar.MINUTE, 2);
|
||||
long validStartTimes=validStartCal.getTime().getTime();
|
||||
//结束时间+2分钟
|
||||
Calendar invalidCal=Calendar.getInstance();
|
||||
invalidCal.setTime(invalidTime);
|
||||
invalidCal.add(Calendar.MINUTE, 2);
|
||||
long invalidTimes=invalidCal.getTime().getTime();
|
||||
long currentTimes=new Date().getTime();
|
||||
//开始时间设置为今天已过时,则将开始时间加上周期
|
||||
if((currentTimes-validStartTimes) > 0) {
|
||||
Calendar validStartCalNew=Calendar.getInstance();
|
||||
validStartCalNew.setTime(validStartTime);
|
||||
validStartCalNew.add(Calendar.DAY_OF_MONTH, interval);
|
||||
validStartTime=validStartCalNew.getTime();
|
||||
}
|
||||
|
||||
//结束时间设置为今天已过时,则将开始时间加上周期
|
||||
if((currentTimes-invalidTimes) > 0) {
|
||||
Calendar invalidCalNew=Calendar.getInstance();
|
||||
invalidCalNew.setTime(invalidTime);
|
||||
invalidCalNew.add(Calendar.DAY_OF_MONTH, interval);
|
||||
invalidTime=invalidCalNew.getTime();
|
||||
}
|
||||
|
||||
|
||||
intervalBuilder = CalendarIntervalScheduleBuilder.calendarIntervalSchedule().withIntervalInDays(interval);
|
||||
//valid
|
||||
JobDataMap dataMap = new JobDataMap();
|
||||
dataMap.put("isValid", true);
|
||||
dataMap.put("cfg", cfg);
|
||||
String triName = VALID_KEY + dayOrWeek+"("+interval+")" + "_" + DateUtils.formatDate(validStartTime, Constants.COMMON_DATE_FORMAT);
|
||||
Trigger validTri = TriggerBuilder.newTrigger()
|
||||
.withIdentity(createTiggerKey(triName, STATUS_GROUP+compileId))
|
||||
.withSchedule(intervalBuilder)
|
||||
.usingJobData(dataMap)
|
||||
.forJob(STATUS_JOBDETAIL)
|
||||
.startAt(validStartTime)
|
||||
.build();
|
||||
triList.add(validTri);
|
||||
|
||||
//invalid
|
||||
dataMap = new JobDataMap();
|
||||
dataMap.put("isValid", false);
|
||||
dataMap.put("cfg", cfg);
|
||||
triName = INVALID_KEY + dayOrWeek +"("+interval+")" + "_" + DateUtils.formatDate(invalidTime, Constants.COMMON_DATE_FORMAT);
|
||||
validTri = TriggerBuilder.newTrigger()
|
||||
.withIdentity(createTiggerKey(triName, STATUS_GROUP+compileId))
|
||||
.withSchedule(intervalBuilder)
|
||||
.usingJobData(dataMap)
|
||||
.forJob(STATUS_JOBDETAIL)
|
||||
.startAt(invalidTime)
|
||||
.build();
|
||||
triList.add(validTri);
|
||||
}else if("EVERYWEEK".equalsIgnoreCase(dayOrWeek)) {
|
||||
intervalBuilder = CalendarIntervalScheduleBuilder.calendarIntervalSchedule().withIntervalInWeeks(interval);
|
||||
String[] weeks = cfg.getUserRegion3().split(",");
|
||||
for(String week : weeks) {
|
||||
if(StringUtils.isNoneBlank(week)) {
|
||||
Date temp = closestAfterWeek(validStartTime, Integer.valueOf(week));
|
||||
JobDataMap dataMap = new JobDataMap();
|
||||
dataMap.put("isValid", true);
|
||||
dataMap.put("cfg", cfg);
|
||||
String triName = VALID_KEY + dayOrWeek +week+"("+interval+")" + "_" + DateUtils.formatDate(temp, Constants.COMMON_DATE_FORMAT);
|
||||
Trigger validTri = TriggerBuilder.newTrigger()
|
||||
.withIdentity(createTiggerKey(triName, STATUS_GROUP+compileId))
|
||||
.withSchedule(intervalBuilder)
|
||||
.usingJobData(dataMap)
|
||||
.forJob(STATUS_JOBDETAIL)
|
||||
.startAt(temp)
|
||||
.build();
|
||||
triList.add(validTri);
|
||||
//invalid
|
||||
dataMap = new JobDataMap();
|
||||
dataMap.put("isValid", false);
|
||||
dataMap.put("cfg", cfg);
|
||||
temp = closestAfterWeek(invalidTime, Integer.valueOf(week));
|
||||
triName = INVALID_KEY + dayOrWeek +week+"("+interval+")" + "_" + DateUtils.formatDate(temp, Constants.COMMON_DATE_FORMAT);
|
||||
validTri = TriggerBuilder.newTrigger()
|
||||
.withIdentity(createTiggerKey(triName, STATUS_GROUP+compileId))
|
||||
.withSchedule(intervalBuilder)
|
||||
.usingJobData(dataMap)
|
||||
.forJob(STATUS_JOBDETAIL)
|
||||
.startAt(temp)
|
||||
.build();
|
||||
triList.add(validTri);
|
||||
}
|
||||
}
|
||||
}
|
||||
return triList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 每月 执行
|
||||
* @param cfg
|
||||
* @return
|
||||
*/
|
||||
public static List<Trigger> createEveryMonthTrigger(ScheduleCfg cfg){
|
||||
String dayWeek = cfg.getUserRegion3();
|
||||
String cronInvalid = cfg.getCronInvalid();
|
||||
String cronValid = cfg.getCronValid();
|
||||
StringBuilder cronSb = new StringBuilder();
|
||||
Trigger trigger = null;
|
||||
List<Integer> validList = parseTime(cronValid);//time 转换
|
||||
List<Integer> invalidList = parseTime(cronInvalid);//time 转换
|
||||
List<Trigger> triList = new ArrayList<Trigger>();
|
||||
String userRegion4 = cfg.getUserRegion4().toUpperCase();
|
||||
if("day".equalsIgnoreCase(dayWeek)) {//指定天
|
||||
boolean hasL = userRegion4.contains("L");
|
||||
StringBuilder chooseSb = new StringBuilder();
|
||||
for(String str : userRegion4.split(",")) {
|
||||
if(!"L".equalsIgnoreCase(str.trim())) {
|
||||
chooseSb.append(",").append(str);
|
||||
}
|
||||
}
|
||||
chooseSb.deleteCharAt(0);
|
||||
cronSb.append(validList.get(2)).append(" ")//秒
|
||||
.append(validList.get(1)).append(" ")//分
|
||||
.append(validList.get(0)).append(" ")//小时
|
||||
.append(chooseSb.toString()).append(" ")//日
|
||||
.append(cfg.getUserRegion2()).append(" ")//月
|
||||
.append("?").append(" ");//周
|
||||
trigger = createCronTrigger(cronSb.toString(), cfg.getCompileId(), true, cfg);
|
||||
triList.add(trigger);
|
||||
cronSb.setLength(0);
|
||||
cronSb.append(invalidList.get(2)).append(" ")//秒
|
||||
.append(invalidList.get(1)).append(" ")//分
|
||||
.append(invalidList.get(0)).append(" ")//小时
|
||||
.append(chooseSb.toString()).append(" ")//日
|
||||
.append(cfg.getUserRegion2()).append(" ")//月
|
||||
.append("?").append(" ");//周
|
||||
trigger = createCronTrigger(cronSb.toString(), cfg.getCompileId(), false, cfg);
|
||||
triList.add(trigger);
|
||||
if(hasL) {// 月的最后一天,quartz 不支持 1,L 这种指定,所以 L单独处理一下
|
||||
cronSb.setLength(0);
|
||||
cronSb.append(validList.get(2)).append(" ")//秒
|
||||
.append(validList.get(1)).append(" ")//分
|
||||
.append(validList.get(0)).append(" ")//小时
|
||||
.append("L").append(" ")//日
|
||||
.append(cfg.getUserRegion2()).append(" ")//月
|
||||
.append("?").append(" ");//周
|
||||
trigger = createCronTrigger(cronSb.toString(), cfg.getCompileId(), true, cfg);
|
||||
triList.add(trigger);
|
||||
cronSb.setLength(0);
|
||||
cronSb.append(invalidList.get(2)).append(" ")//秒
|
||||
.append(invalidList.get(1)).append(" ")//分
|
||||
.append(invalidList.get(0)).append(" ")//小时
|
||||
.append("L").append(" ")//日
|
||||
.append(cfg.getUserRegion2()).append(" ")//月
|
||||
.append("?").append(" ");//周
|
||||
trigger = createCronTrigger(cronSb.toString(), cfg.getCompileId(), false, cfg);
|
||||
triList.add(trigger);
|
||||
}
|
||||
}else if ("week".equalsIgnoreCase(dayWeek)) {//指定周,1#2: 第一周的周二,4L:最后一周的周四
|
||||
for(String nthWeek : userRegion4.split(",")) {//第几周
|
||||
for(String week : cfg.getUserRegion5().split(",")) {//星期几
|
||||
cronSb.setLength(0);
|
||||
cronSb.append(validList.get(2)).append(" ")//秒
|
||||
.append(validList.get(1)).append(" ")//分
|
||||
.append(validList.get(0)).append(" ")//小时
|
||||
.append("?").append(" ")//日
|
||||
.append(cfg.getUserRegion2()).append(" ");//月
|
||||
if("L".equalsIgnoreCase(nthWeek)) {
|
||||
cronSb.append(week).append("L");//周
|
||||
}else {
|
||||
cronSb.append(week).append("#").append(nthWeek);//周
|
||||
}
|
||||
trigger = createCronTrigger(cronSb.toString(), cfg.getCompileId(), true, cfg);
|
||||
triList.add(trigger);
|
||||
cronSb.setLength(0);
|
||||
cronSb.append(invalidList.get(2)).append(" ")//秒
|
||||
.append(invalidList.get(1)).append(" ")//分
|
||||
.append(invalidList.get(0)).append(" ")//小时
|
||||
.append("?").append(" ")//日
|
||||
.append(cfg.getUserRegion2()).append(" ");//月
|
||||
if("L".equalsIgnoreCase(nthWeek)) {
|
||||
cronSb.append(week).append("L");//周
|
||||
}else {
|
||||
cronSb.append(week).append("#").append(nthWeek);//周
|
||||
}
|
||||
trigger = createCronTrigger(cronSb.toString(), cfg.getCompileId(), false, cfg);
|
||||
triList.add(trigger);
|
||||
}
|
||||
}
|
||||
}
|
||||
return triList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查找最近的 星期几 ,包括今天(如果今天的时间点已过,从明天开始算)
|
||||
* @param date
|
||||
* @param w 周一开始 1 -7
|
||||
* @return
|
||||
*/
|
||||
public static Date closestAfterWeek(Date date,int w) {
|
||||
//设置calC为开始时间+2分钟,判断calC时间是否已过,如果小于当前时间则直接从明天开始算
|
||||
Calendar calC = Calendar.getInstance();
|
||||
calC.setTime(date);
|
||||
calC.add(Calendar.MINUTE, 2);
|
||||
long currentDate=new Date().getTime();//当前时间
|
||||
long weekStartDate=calC.getTime().getTime();//周任务开始时间+2分钟
|
||||
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(date);
|
||||
//如果开始时间已过期,则从明天开始算
|
||||
if((currentDate-weekStartDate) > 0) {
|
||||
cal.add(Calendar.DAY_OF_MONTH, 1);
|
||||
}
|
||||
int i = cal.get(Calendar.DAY_OF_WEEK);//周日开始 1-7
|
||||
i = (i==1)? 7: i-1;//转换为 周一到 周日 1-7
|
||||
cal.add(Calendar.DAY_OF_MONTH, (i>w)?(7-(i-w)) : (w-i));
|
||||
return cal.getTime();
|
||||
}
|
||||
|
||||
|
||||
public static TriggerKey createTiggerKey(String name,String group) {
|
||||
TriggerKey key = new TriggerKey(name, group);
|
||||
return key;
|
||||
}
|
||||
|
||||
/**
|
||||
* jquery cron 生成的cron 表达式,quartz 不能直接使用,需要做些修改
|
||||
* @param cron
|
||||
* @return
|
||||
*/
|
||||
public static String modifyCronExp(String cron) {
|
||||
String[] cronArr = cron.split("\\s");
|
||||
if("*".equals(cronArr[4])) {
|
||||
cronArr[4] = "?";
|
||||
}else {
|
||||
cronArr[3] = "*";
|
||||
cronArr[2] = "?";
|
||||
}
|
||||
return "0 " + StringUtils.join(cronArr, " ");
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
CronTriggerImpl cron = new CronTriggerImpl();
|
||||
try {
|
||||
String exp = "0 0 0 ? 1,2 1#4";
|
||||
cron.setCronExpression(exp);
|
||||
System.out.println(cron);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
137
src/main/java/com/nis/quartz/ScheduleStatisticASNIPNumJob.java
Normal file
137
src/main/java/com/nis/quartz/ScheduleStatisticASNIPNumJob.java
Normal file
@@ -0,0 +1,137 @@
|
||||
package com.nis.quartz;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.apache.ibatis.session.ExecutorType;
|
||||
import org.apache.ibatis.session.SqlSession;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.quartz.DisallowConcurrentExecution;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
import org.quartz.PersistJobDataAfterExecution;
|
||||
|
||||
import com.nis.util.IPUtil;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.web.dao.basics.AsnGroupInfoDao;
|
||||
import com.nis.web.dao.basics.AsnIpCfgDao;
|
||||
import com.nis.web.service.SpringContextHolder;
|
||||
|
||||
/**
|
||||
* 定时任务: 定时统计ASN 下IPv4和IPV6的个数
|
||||
* 1、每 n s 执行一次(两个小时执行一次)
|
||||
* 2、单线程执行
|
||||
* @author ddm
|
||||
*
|
||||
*/
|
||||
@DisallowConcurrentExecution
|
||||
@PersistJobDataAfterExecution
|
||||
public class ScheduleStatisticASNIPNumJob implements Job {
|
||||
private static final Logger logger = Logger.getLogger(ScheduleStatisticASNIPNumJob.class);
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||
AsnIpCfgDao asnIpCfgDao = SpringContextHolder.getBean(AsnIpCfgDao.class);
|
||||
logger.info("定时统计ASN IP个数开始。。。。。。。。。。。。。。");
|
||||
long start=System.currentTimeMillis();
|
||||
Map<Integer,Map<String,Long>> asnNumerMap=new HashMap<>();
|
||||
List<Object[]> asnIpList=new ArrayList<>();
|
||||
asnIpList=asnIpCfgDao.findAllAsnIpCfgList();
|
||||
|
||||
getAllASNIPNumber(asnIpList, asnNumerMap);
|
||||
|
||||
updateAllASNIPNumber(asnNumerMap);
|
||||
|
||||
long end=System.currentTimeMillis();
|
||||
logger.info("定时统计ASN IP个数结束:耗时("+(end-start)+"/毫秒)。。。。。。。。。。。。。。");
|
||||
}
|
||||
|
||||
public void getAllASNIPNumber(List<Object[]> asnIpList,Map<Integer,Map<String,Long>> asnNumerMap){
|
||||
logger.info("计算ASN IP开始:asn ip size:"+asnIpList.size()+"。。。。。。。。。。。。。。");
|
||||
long start=System.currentTimeMillis();
|
||||
if(!StringUtil.isEmpty(asnIpList)){
|
||||
try {
|
||||
for (Iterator iterator = asnIpList.iterator(); iterator.hasNext();) {
|
||||
Map asnIpMap=(Map) iterator.next();
|
||||
//groupId
|
||||
Integer asnGroupId = (Integer)asnIpMap.get("asn_ip_group");
|
||||
//ipType(4:v4,6:v6)
|
||||
Integer ipType= (Integer)asnIpMap.get("ip_type");
|
||||
//(1:mask,2:range,3:ip)
|
||||
//Integer ipPattern= (Integer)asnIpMap.get("ip_pattern");
|
||||
//dest_ip_address
|
||||
String ipAddress= (String)asnIpMap.get("dest_ip_address");
|
||||
long IPNumber=0;
|
||||
if(ipType.equals(4)){
|
||||
if(ipAddress.indexOf("/") > -1){
|
||||
Integer mask=Integer.parseInt(ipAddress.split("/")[1]);
|
||||
ipAddress=ipAddress.split("/")[0];
|
||||
IPNumber=IPUtil.getIpNum(ipAddress, mask);
|
||||
}else{
|
||||
IPNumber=1;
|
||||
}
|
||||
//判断组是否已经存在
|
||||
if(asnNumerMap.keySet().contains(asnGroupId)){
|
||||
asnNumerMap.get(asnGroupId).put("v4", asnNumerMap.get(asnGroupId).get("v4")+IPNumber);
|
||||
asnNumerMap.put(asnGroupId, asnNumerMap.get(asnGroupId));
|
||||
}else{
|
||||
Map<String, Long> map=new HashMap<>();
|
||||
map.put("v4", IPNumber);
|
||||
map.put("v6", 0l);
|
||||
asnNumerMap.put(asnGroupId, map);
|
||||
}
|
||||
}else{
|
||||
IPNumber=1;
|
||||
//判断组是否已经存在
|
||||
if(asnNumerMap.keySet().contains(asnGroupId)){
|
||||
asnNumerMap.get(asnGroupId).put("v6", asnNumerMap.get(asnGroupId).get("v6")+IPNumber);
|
||||
asnNumerMap.put(asnGroupId, asnNumerMap.get(asnGroupId));
|
||||
}else{
|
||||
Map<String, Long> map=new HashMap<>();
|
||||
map.put("v4", 0l);
|
||||
map.put("v6", IPNumber);
|
||||
asnNumerMap.put(asnGroupId, map);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("计算ASN IP个数失败",e);
|
||||
}
|
||||
}
|
||||
|
||||
long end=System.currentTimeMillis();
|
||||
logger.info("计算ASN IP个数结束:耗时("+(end-start)+"/毫秒)。。。。。。。。。。。。。。");
|
||||
}
|
||||
public void updateAllASNIPNumber(Map<Integer,Map<String,Long>> asnNumerMap) {
|
||||
logger.info("修改ASN IP个数开始:asn size:"+asnNumerMap.size()+"。。。。。。。。。。。。。。");
|
||||
long start=System.currentTimeMillis();
|
||||
if(!StringUtil.isEmpty(asnNumerMap)){
|
||||
int index=0;
|
||||
SqlSessionFactory sqlSessionFactory=SpringContextHolder.getBean(SqlSessionFactory.class);
|
||||
SqlSession batchSqlSession = null;
|
||||
try {
|
||||
batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, true);
|
||||
for(Entry<Integer,Map<String,Long>> e: asnNumerMap.entrySet()) {
|
||||
((AsnGroupInfoDao) batchSqlSession.getMapper(AsnGroupInfoDao.class)).updateIpNum(e.getValue().get("v4"),e.getValue().get("v6"),e.getKey());
|
||||
batchSqlSession.commit();
|
||||
index++;
|
||||
}
|
||||
}catch (Exception e) {
|
||||
logger.error("修改ASN IP个数失败", e);
|
||||
} finally {
|
||||
if(batchSqlSession != null){
|
||||
batchSqlSession.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
long end=System.currentTimeMillis();
|
||||
logger.info("修改ASN IP个数结束:耗时("+(end-start)+"/毫秒)。。。。。。。。。。。。。。");
|
||||
}
|
||||
}
|
||||
82
src/main/java/com/nis/quartz/ScheduleStatusJob.java
Normal file
82
src/main/java/com/nis/quartz/ScheduleStatusJob.java
Normal file
@@ -0,0 +1,82 @@
|
||||
package com.nis.quartz;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobDataMap;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
import org.quartz.Scheduler;
|
||||
import org.quartz.SchedulerException;
|
||||
|
||||
import com.nis.domain.ScheduleCfg;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.DateUtil;
|
||||
import com.nis.util.DictUtils;
|
||||
import com.nis.web.dao.SchedulerDao;
|
||||
import com.nis.web.service.ScheduleService;
|
||||
import com.nis.web.service.SpringContextHolder;
|
||||
|
||||
/**
|
||||
* 定时任务 真正执行类
|
||||
* 配置状态下发
|
||||
* 从trigger 的 jobDataMap 中取出 相关数据:compile,isValid
|
||||
* @author fang
|
||||
*
|
||||
*/
|
||||
public class ScheduleStatusJob implements Job{
|
||||
private static final Logger log = Logger.getLogger(ScheduleStatusJob.class);
|
||||
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||
|
||||
//全量同步状态
|
||||
String currentStatus = DictUtils.getDictLabel("currrent_sync_status", "status","0");
|
||||
//0:start:开始 1:init:初始化 2:doing:进行中
|
||||
|
||||
//全量同步过程中未执行的任务进入另一个job中,等待全量同步完成开始执行
|
||||
if(currentStatus.equals("0") || currentStatus.equals("1")||currentStatus.equals("2")) {
|
||||
//配置下发,并修改 配置表的状态,保存下发记录等
|
||||
SchedulerDao schedulerDao = SpringContextHolder.getBean(SchedulerDao.class);
|
||||
//从trigger中 获取 配置信息
|
||||
JobDataMap jobDataMap = context.getTrigger().getJobDataMap();
|
||||
boolean isValid = jobDataMap.getBoolean("isValid");
|
||||
|
||||
ScheduleCfg cfg = (ScheduleCfg)jobDataMap.get("cfg");
|
||||
cfg.setId(null);//新入库一个任务
|
||||
cfg.setType(2);//全量同步中未执行的任务
|
||||
cfg.setUserRegion1("single"); //只执行一次
|
||||
if(isValid) {
|
||||
cfg.setCronValid("1900-01-01 01:01:01"); //无实际效果,仅仅为填充值
|
||||
cfg.setCronInvalid("");
|
||||
}else {
|
||||
cfg.setCronValid("");
|
||||
cfg.setCronInvalid("1900-01-01 01:01:01");//无实际效果,仅仅为填充值
|
||||
}
|
||||
schedulerDao.insert(cfg);
|
||||
|
||||
}else {
|
||||
//从trigger中 获取 配置信息
|
||||
JobDataMap jobDataMap = context.getTrigger().getJobDataMap();
|
||||
boolean isValid = jobDataMap.getBoolean("isValid");
|
||||
ScheduleCfg cfg = (ScheduleCfg)jobDataMap.get("cfg");
|
||||
Integer compileId = cfg.getCompileId();
|
||||
log.debug(String.format("任务开始执行,compileId:%s,isValid:%s",compileId,isValid ));
|
||||
//配置下发,并修改 配置表的状态,保存下发记录等
|
||||
ScheduleService scheduleService = SpringContextHolder.getBean(ScheduleService.class);
|
||||
try {
|
||||
scheduleService.issueCompileInfo(cfg, isValid?1:0);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("定时任务"+cfg.getId()+"执行失败",e);
|
||||
}finally {
|
||||
log.debug(String.format("任务执行完成,compileId:%s,isValid:%s",compileId,isValid ));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
548
src/main/java/com/nis/quartz/ScheduleSyncCfgJob.java
Normal file
548
src/main/java/com/nis/quartz/ScheduleSyncCfgJob.java
Normal file
@@ -0,0 +1,548 @@
|
||||
package com.nis.quartz;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.quartz.CalendarIntervalScheduleBuilder;
|
||||
import org.quartz.CalendarIntervalTrigger;
|
||||
import org.quartz.CronScheduleBuilder;
|
||||
import org.quartz.DateBuilder;
|
||||
import org.quartz.DisallowConcurrentExecution;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobBuilder;
|
||||
import org.quartz.JobDataMap;
|
||||
import org.quartz.JobDetail;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
import org.quartz.JobKey;
|
||||
import org.quartz.PersistJobDataAfterExecution;
|
||||
import org.quartz.ScheduleBuilder;
|
||||
import org.quartz.Scheduler;
|
||||
import org.quartz.SchedulerException;
|
||||
import org.quartz.SimpleScheduleBuilder;
|
||||
import org.quartz.SimpleTrigger;
|
||||
import org.quartz.Trigger;
|
||||
import org.quartz.TriggerBuilder;
|
||||
import org.quartz.TriggerKey;
|
||||
import org.quartz.impl.matchers.GroupMatcher;
|
||||
import org.quartz.impl.triggers.CalendarIntervalTriggerImpl;
|
||||
import org.quartz.impl.triggers.CronTriggerImpl;
|
||||
import org.quartz.spi.MutableTrigger;
|
||||
|
||||
import com.nis.domain.ScheduleCfg;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.DateUtil;
|
||||
import com.nis.util.DateUtils;
|
||||
import com.nis.util.DictUtils;
|
||||
import com.nis.util.StringUtils;
|
||||
import com.nis.web.dao.SchedulerDao;
|
||||
import com.nis.web.service.SpringContextHolder;
|
||||
|
||||
/**
|
||||
* 定时任务 配置全量同步时未执行的定时任务加载
|
||||
* 1、每 n s 执行一次,每次读取 schedule_cfg 最新的数据
|
||||
* 2、删除或新增 定时任务
|
||||
* 3、单线程执行
|
||||
* @author ddm
|
||||
*
|
||||
*/
|
||||
@DisallowConcurrentExecution
|
||||
@PersistJobDataAfterExecution
|
||||
public class ScheduleSyncCfgJob implements Job {
|
||||
SimpleDateFormat sdf=new SimpleDateFormat(Constants.COMMON_DATE_FORMAT);
|
||||
private static final Logger log = Logger.getLogger(ScheduleSyncCfgJob.class);
|
||||
|
||||
/**
|
||||
* 状态组,格式:statusGroup-compileId
|
||||
*/
|
||||
private static final String STATUS_GROUP = "syncGroup-";
|
||||
private static final String STATUS_JOB = "SYNC-JOB";
|
||||
/**
|
||||
* 生效标识:valid-cronexp
|
||||
*/
|
||||
private static final String VALID_KEY = "valid-";
|
||||
/**
|
||||
* 失效标识:invalid-cronexp
|
||||
*/
|
||||
private static final String INVALID_KEY = "invalid-";
|
||||
private static final JobKey STATUS_JOBKEY = JobKey.jobKey(STATUS_JOB, "syncGroup");
|
||||
private static final JobDetail STATUS_JOBDETAIL = JobBuilder.newJob(ScheduleStatusJob.class)
|
||||
.withIdentity(STATUS_JOBKEY)
|
||||
.storeDurably(true)
|
||||
.build();
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||
Scheduler scheduler = context.getScheduler();
|
||||
SchedulerDao dao = SpringContextHolder.getBean(SchedulerDao.class);
|
||||
JobDataMap dataMap = context.getJobDetail().getJobDataMap();
|
||||
long scheduleCfgId = dataMap.get("scheduleCfgId") == null ? 0:dataMap.getLong("scheduleCfgId");
|
||||
long limit = dataMap.get("limit") == null ? Constants.MAAT_JSON_SEND_SIZE:dataMap.getLong("limit");
|
||||
log.info(String.format("Sync定时配置任务开始扫描,scheduleCfgId:%s,limit:%s",scheduleCfgId,limit ));
|
||||
List<ScheduleCfg> newlyCfg = null;
|
||||
int totalNum = 0;
|
||||
|
||||
//全量同步当前状态 0:start:开始 1:init:初始化 2:doing:进行中
|
||||
String currentStatus = DictUtils.getDictLabel("currrent_sync_status", "status","0");
|
||||
if(!(currentStatus.equals("0") || currentStatus.equals("1") || currentStatus.equals("2"))) {
|
||||
do {
|
||||
newlyCfg = dao.findNewlyCfg(scheduleCfgId, limit,2,null);
|
||||
if(newlyCfg != null && newlyCfg.size() > 0) {
|
||||
totalNum += newlyCfg.size();
|
||||
for(ScheduleCfg cfg : newlyCfg) {//先取消之前的定时配置
|
||||
Integer compileId = cfg.getCompileId();
|
||||
try {
|
||||
//取消之前所有的 trigger
|
||||
GroupMatcher<TriggerKey> groupMatcher= GroupMatcher.triggerGroupEquals(STATUS_GROUP + compileId);
|
||||
Set<TriggerKey> triggerKeys = scheduler.getTriggerKeys(groupMatcher);
|
||||
if(triggerKeys != null && triggerKeys.size() > 0) {
|
||||
for(TriggerKey tk : triggerKeys) {
|
||||
scheduler.unscheduleJob(tk);
|
||||
}
|
||||
log.info(String.format("Sync定时任务取消成功,compile:%s", compileId));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(String.format("Sync定时任务取消异常,compileId:%s", compileId),e);
|
||||
}
|
||||
}
|
||||
int index=0;
|
||||
for(ScheduleCfg cfg : newlyCfg) {
|
||||
Integer compileId = cfg.getCompileId();
|
||||
try {
|
||||
//判断状态,重新添加最新的 trigger
|
||||
Integer isValid = cfg.getIsValid();
|
||||
Integer isAudit = cfg.getIsAudit();
|
||||
//添加定时任务的条件
|
||||
if((isValid == 1 && isAudit == 1) || (isValid == 0 && isAudit == 0)) {
|
||||
//添加定时任务,包括valid 和 invalid
|
||||
addJob(scheduler, cfg,index);
|
||||
log.info(String.format("Sync定时任务添加成功,compile:%s", compileId));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(String.format("Sync定时任务更新异常,compileId:%s", compileId),e);
|
||||
}
|
||||
index++;
|
||||
}
|
||||
//最后 保存此次 最后的id
|
||||
ScheduleCfg lastCfg = newlyCfg.get(newlyCfg.size() -1);
|
||||
scheduleCfgId = lastCfg.getId();
|
||||
dataMap.put("scheduleCfgId", scheduleCfgId);
|
||||
log.info(String.format("Sync加载定时任务,total num :%s", newlyCfg.size()));
|
||||
}
|
||||
} while (newlyCfg != null && newlyCfg.size() > 0);
|
||||
log.info(String.format("Sync定时配置任务结束执行,total num:%s",totalNum));
|
||||
}
|
||||
log.info("全量同步中缓存的定时配置正在扫描(currentStatus:"+currentStatus+")");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 将定时任务信息添加到 定时器框架中调度
|
||||
* @param scheduler
|
||||
* @param cfg
|
||||
* @throws SchedulerException
|
||||
*/
|
||||
/*public static void addJob(Scheduler scheduler,ScheduleCfg cfg) throws SchedulerException {
|
||||
Integer compileId = cfg.getCompileId();
|
||||
String cronValid = cfg.getCronValid();
|
||||
String cronInvalid = cfg.getCronInvalid();
|
||||
Trigger validTrigger = createTrigger(cronValid, compileId, true, cfg);
|
||||
Trigger invalidTrigger = createTrigger(cronInvalid, compileId, false, cfg);
|
||||
boolean jobExist = scheduler.checkExists(STATUS_JOBKEY);
|
||||
if(!jobExist) {//判断 job 是否存在,不存在添加
|
||||
scheduler.addJob(STATUS_JOBDETAIL, false);
|
||||
}
|
||||
boolean checkExists = scheduler.checkExists(validTrigger.getKey());
|
||||
if(!checkExists) {//判断 valid trigger 是否存在,不存在添加
|
||||
scheduler.scheduleJob(validTrigger);
|
||||
}else {
|
||||
log.warn(String.format("Trigger already exists:%s ", validTrigger.getKey().toString()));
|
||||
}
|
||||
checkExists = scheduler.checkExists(invalidTrigger.getKey());
|
||||
if(!checkExists) {//判断 invalid trigger 是否存在,不存在添加
|
||||
scheduler.scheduleJob(invalidTrigger);
|
||||
}else {
|
||||
log.warn(String.format("Trigger already exists:%s ", invalidTrigger.getKey().toString()));
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
public static void addJob(Scheduler scheduler,ScheduleCfg cfg,int expire) throws SchedulerException {
|
||||
List<Trigger> triList = createTrigger(cfg,expire);
|
||||
boolean jobExist = scheduler.checkExists(STATUS_JOBKEY);
|
||||
if(!jobExist) {//判断 job 是否存在,不存在添加
|
||||
scheduler.addJob(STATUS_JOBDETAIL, false);
|
||||
}
|
||||
for(Trigger tri : triList) {
|
||||
boolean checkExists = scheduler.checkExists(tri.getKey());
|
||||
if(!checkExists) {//判断 valid trigger 是否存在,不存在添加
|
||||
log.debug(String.format("Sync定时任务添加,%s", tri.getKey()));
|
||||
scheduler.scheduleJob(tri);
|
||||
log.info(String.format("Sync定时任务添加成功,%s", tri.getKey()));
|
||||
}else {
|
||||
log.warn(String.format("Trigger(sync) already exists:%s ", tri.getKey().toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将页面配置的内容 转换成 trigger
|
||||
* @param cfg
|
||||
* @return
|
||||
*/
|
||||
public static List<Trigger> createTrigger(ScheduleCfg cfg,int expire){
|
||||
String mode = cfg.getUserRegion1().toUpperCase();//定时任务运行模式:一次,每天,每周,每月
|
||||
List<Trigger> triList = null;
|
||||
switch (mode) {
|
||||
case "ALWAYS"://单次运行,但只创建单次生效触发器
|
||||
triList = createSimpleTrigger(cfg,expire);
|
||||
break;
|
||||
case "SINGLE"://单次运行
|
||||
triList = createSimpleTrigger(cfg,expire);
|
||||
break;
|
||||
case "EVERYDAY"://每天运行 0 0 0 2/1 * ? ,不符合要求,定义每天都执行,然后在 代码判断 间隔时间
|
||||
triList = createCalendarIntervalTrigger(cfg);
|
||||
break;
|
||||
case "EVERYWEEK"://每周运行
|
||||
triList = createCalendarIntervalTrigger(cfg);
|
||||
break;
|
||||
case "EVERYMONTH"://每月运行
|
||||
triList = createEveryMonthTrigger(cfg);
|
||||
break;
|
||||
default:
|
||||
log.warn(String.format("unknown mode : %s ", mode));
|
||||
break;
|
||||
}
|
||||
return triList;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 将时间转换成 时分秒
|
||||
* @param time
|
||||
* @return
|
||||
*/
|
||||
public static List<Integer> parseTime(String time) {
|
||||
if(StringUtils.isNoneBlank(time)) {
|
||||
String[] split = time.split(":");
|
||||
List<Integer> tl = new ArrayList<Integer>(3);
|
||||
for(String s : split) {
|
||||
tl.add(Integer.valueOf(s));
|
||||
}
|
||||
return tl;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Trigger createCronTrigger(String cron,Integer compileId,boolean isValid,ScheduleCfg cfg) {
|
||||
String triggerName = isValid ? (VALID_KEY + cron) : (INVALID_KEY + cron);
|
||||
JobDataMap dataMap = new JobDataMap();
|
||||
dataMap.put("isValid", isValid);
|
||||
dataMap.put("cfg", cfg);
|
||||
return TriggerBuilder.newTrigger()
|
||||
.withIdentity(createTiggerKey(triggerName, STATUS_GROUP+compileId))
|
||||
.withSchedule(CronScheduleBuilder.cronSchedule(cron))
|
||||
.usingJobData(dataMap)
|
||||
.forJob(STATUS_JOBDETAIL)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 创建全量同步时未执行的任务,每个任务均为单词任务
|
||||
* @param cfg
|
||||
* @return
|
||||
*/
|
||||
public static List<Trigger> createSimpleTrigger(ScheduleCfg cfg,int expire){
|
||||
List<Trigger> triList = new ArrayList<Trigger>();
|
||||
Integer compileId = cfg.getCompileId();
|
||||
String cronValid = cfg.getCronValid();
|
||||
String cronInvalid = cfg.getCronInvalid();
|
||||
Date validDate = null;
|
||||
Date invalidDate = null;
|
||||
if(StringUtils.isNotBlank(cronValid)){
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.add(Calendar.MINUTE, (expire+1));
|
||||
validDate = c.getTime();
|
||||
|
||||
}
|
||||
if(StringUtils.isNotBlank(cronInvalid)){
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.add(Calendar.MINUTE, (expire+2));
|
||||
invalidDate = c.getTime();
|
||||
}
|
||||
JobDataMap dataMap = new JobDataMap();
|
||||
if(validDate!=null){//生效时间如果不为空,则创建定时生效触发器
|
||||
dataMap.put("isValid", true);
|
||||
dataMap.put("cfg", cfg);
|
||||
String triName = VALID_KEY + cfg.getUserRegion1() + "_" + cronValid;
|
||||
Trigger trigger = TriggerBuilder.newTrigger()
|
||||
.withIdentity(createTiggerKey(triName, STATUS_GROUP+compileId))
|
||||
.withSchedule(SimpleScheduleBuilder.simpleSchedule())
|
||||
.usingJobData(dataMap)
|
||||
.forJob(STATUS_JOBDETAIL)
|
||||
.startAt(validDate)
|
||||
.build();
|
||||
triList.add(trigger);
|
||||
}
|
||||
if(invalidDate!=null){//失效时间如果不为空,则创建定时失效触发器
|
||||
dataMap = new JobDataMap();
|
||||
dataMap.put("isValid", false);
|
||||
dataMap.put("cfg", cfg);
|
||||
String triName = INVALID_KEY + cfg.getUserRegion1() + "_" + cronInvalid;
|
||||
Trigger trigger = TriggerBuilder.newTrigger()
|
||||
.withIdentity(createTiggerKey(triName, STATUS_GROUP+compileId))
|
||||
.withSchedule(SimpleScheduleBuilder.simpleSchedule())
|
||||
.usingJobData(dataMap)
|
||||
.forJob(STATUS_JOBDETAIL)
|
||||
.startAt(invalidDate)
|
||||
.build();
|
||||
triList.add(trigger);
|
||||
}
|
||||
return triList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 间隔 n 天 或 n 周执行
|
||||
* @param cfg
|
||||
* @return
|
||||
*/
|
||||
public static List<Trigger> createCalendarIntervalTrigger(ScheduleCfg cfg) {
|
||||
List<Trigger> triList = new ArrayList<Trigger>();
|
||||
Integer compileId = cfg.getCompileId();
|
||||
String cronValid = cfg.getCronValid();
|
||||
String cronInvalid = cfg.getCronInvalid();
|
||||
String dayOrWeek = cfg.getUserRegion1();
|
||||
Integer interval = Integer.valueOf(cfg.getUserRegion2());
|
||||
List<Integer> validList = parseTime(cronValid);
|
||||
List<Integer> invalidList = parseTime(cronInvalid);
|
||||
Date validStartTime = DateBuilder.todayAt(validList.get(0), validList.get(1), validList.get(2));
|
||||
Date invalidTime = DateBuilder.todayAt(invalidList.get(0), invalidList.get(1), invalidList.get(2));
|
||||
CalendarIntervalScheduleBuilder intervalBuilder = null;
|
||||
if("EVERYDAY".equalsIgnoreCase(dayOrWeek)) {
|
||||
intervalBuilder = CalendarIntervalScheduleBuilder.calendarIntervalSchedule().withIntervalInDays(interval);
|
||||
//valid
|
||||
JobDataMap dataMap = new JobDataMap();
|
||||
dataMap.put("isValid", true);
|
||||
dataMap.put("cfg", cfg);
|
||||
String triName = VALID_KEY + dayOrWeek+"("+interval+")" + "_" + DateUtils.formatDate(validStartTime, Constants.COMMON_DATE_FORMAT);
|
||||
Trigger validTri = TriggerBuilder.newTrigger()
|
||||
.withIdentity(createTiggerKey(triName, STATUS_GROUP+compileId))
|
||||
.withSchedule(intervalBuilder)
|
||||
.usingJobData(dataMap)
|
||||
.forJob(STATUS_JOBDETAIL)
|
||||
.startAt(validStartTime)
|
||||
.build();
|
||||
triList.add(validTri);
|
||||
//invalid
|
||||
dataMap = new JobDataMap();
|
||||
dataMap.put("isValid", false);
|
||||
dataMap.put("cfg", cfg);
|
||||
triName = INVALID_KEY + dayOrWeek +"("+interval+")" + "_" + DateUtils.formatDate(invalidTime, Constants.COMMON_DATE_FORMAT);
|
||||
validTri = TriggerBuilder.newTrigger()
|
||||
.withIdentity(createTiggerKey(triName, STATUS_GROUP+compileId))
|
||||
.withSchedule(intervalBuilder)
|
||||
.usingJobData(dataMap)
|
||||
.forJob(STATUS_JOBDETAIL)
|
||||
.startAt(invalidTime)
|
||||
.build();
|
||||
triList.add(validTri);
|
||||
}else if("EVERYWEEK".equalsIgnoreCase(dayOrWeek)) {
|
||||
intervalBuilder = CalendarIntervalScheduleBuilder.calendarIntervalSchedule().withIntervalInWeeks(interval);
|
||||
String[] weeks = cfg.getUserRegion3().split(",");
|
||||
for(String week : weeks) {
|
||||
if(StringUtils.isNoneBlank(week)) {
|
||||
Date temp = closestAfterWeek(validStartTime, Integer.valueOf(week));
|
||||
JobDataMap dataMap = new JobDataMap();
|
||||
dataMap.put("isValid", true);
|
||||
dataMap.put("cfg", cfg);
|
||||
String triName = VALID_KEY + dayOrWeek +week+"("+interval+")" + "_" + DateUtils.formatDate(temp, Constants.COMMON_DATE_FORMAT);
|
||||
Trigger validTri = TriggerBuilder.newTrigger()
|
||||
.withIdentity(createTiggerKey(triName, STATUS_GROUP+compileId))
|
||||
.withSchedule(intervalBuilder)
|
||||
.usingJobData(dataMap)
|
||||
.forJob(STATUS_JOBDETAIL)
|
||||
.startAt(temp)
|
||||
.build();
|
||||
triList.add(validTri);
|
||||
//invalid
|
||||
dataMap = new JobDataMap();
|
||||
dataMap.put("isValid", false);
|
||||
dataMap.put("cfg", cfg);
|
||||
temp = closestAfterWeek(invalidTime, Integer.valueOf(week));
|
||||
triName = INVALID_KEY + dayOrWeek +week+"("+interval+")" + "_" + DateUtils.formatDate(temp, Constants.COMMON_DATE_FORMAT);
|
||||
validTri = TriggerBuilder.newTrigger()
|
||||
.withIdentity(createTiggerKey(triName, STATUS_GROUP+compileId))
|
||||
.withSchedule(intervalBuilder)
|
||||
.usingJobData(dataMap)
|
||||
.forJob(STATUS_JOBDETAIL)
|
||||
.startAt(temp)
|
||||
.build();
|
||||
triList.add(validTri);
|
||||
}
|
||||
}
|
||||
}
|
||||
return triList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 每月 执行
|
||||
* @param cfg
|
||||
* @return
|
||||
*/
|
||||
public static List<Trigger> createEveryMonthTrigger(ScheduleCfg cfg){
|
||||
String dayWeek = cfg.getUserRegion3();
|
||||
String cronInvalid = cfg.getCronInvalid();
|
||||
String cronValid = cfg.getCronValid();
|
||||
StringBuilder cronSb = new StringBuilder();
|
||||
Trigger trigger = null;
|
||||
List<Integer> validList = parseTime(cronValid);//time 转换
|
||||
List<Integer> invalidList = parseTime(cronInvalid);//time 转换
|
||||
List<Trigger> triList = new ArrayList<Trigger>();
|
||||
String userRegion4 = cfg.getUserRegion4().toUpperCase();
|
||||
if("day".equalsIgnoreCase(dayWeek)) {//指定天
|
||||
boolean hasL = userRegion4.contains("L");
|
||||
StringBuilder chooseSb = new StringBuilder();
|
||||
for(String str : userRegion4.split(",")) {
|
||||
if(!"L".equalsIgnoreCase(str.trim())) {
|
||||
chooseSb.append(",").append(str);
|
||||
}
|
||||
}
|
||||
chooseSb.deleteCharAt(0);
|
||||
cronSb.append(validList.get(2)).append(" ")//秒
|
||||
.append(validList.get(1)).append(" ")//分
|
||||
.append(validList.get(0)).append(" ")//小时
|
||||
.append(chooseSb.toString()).append(" ")//日
|
||||
.append(cfg.getUserRegion2()).append(" ")//月
|
||||
.append("?").append(" ");//周
|
||||
trigger = createCronTrigger(cronSb.toString(), cfg.getCompileId(), true, cfg);
|
||||
triList.add(trigger);
|
||||
cronSb.setLength(0);
|
||||
cronSb.append(invalidList.get(2)).append(" ")//秒
|
||||
.append(invalidList.get(1)).append(" ")//分
|
||||
.append(invalidList.get(0)).append(" ")//小时
|
||||
.append(chooseSb.toString()).append(" ")//日
|
||||
.append(cfg.getUserRegion2()).append(" ")//月
|
||||
.append("?").append(" ");//周
|
||||
trigger = createCronTrigger(cronSb.toString(), cfg.getCompileId(), false, cfg);
|
||||
triList.add(trigger);
|
||||
if(hasL) {// 月的最后一天,quartz 不支持 1,L 这种指定,所以 L单独处理一下
|
||||
cronSb.setLength(0);
|
||||
cronSb.append(validList.get(2)).append(" ")//秒
|
||||
.append(validList.get(1)).append(" ")//分
|
||||
.append(validList.get(0)).append(" ")//小时
|
||||
.append("L").append(" ")//日
|
||||
.append(cfg.getUserRegion2()).append(" ")//月
|
||||
.append("?").append(" ");//周
|
||||
trigger = createCronTrigger(cronSb.toString(), cfg.getCompileId(), true, cfg);
|
||||
triList.add(trigger);
|
||||
cronSb.setLength(0);
|
||||
cronSb.append(invalidList.get(2)).append(" ")//秒
|
||||
.append(invalidList.get(1)).append(" ")//分
|
||||
.append(invalidList.get(0)).append(" ")//小时
|
||||
.append("L").append(" ")//日
|
||||
.append(cfg.getUserRegion2()).append(" ")//月
|
||||
.append("?").append(" ");//周
|
||||
trigger = createCronTrigger(cronSb.toString(), cfg.getCompileId(), false, cfg);
|
||||
triList.add(trigger);
|
||||
}
|
||||
}else if ("week".equalsIgnoreCase(dayWeek)) {//指定周,1#2: 第一周的周二,4L:最后一周的周四
|
||||
for(String nthWeek : userRegion4.split(",")) {//第几周
|
||||
for(String week : cfg.getUserRegion5().split(",")) {//星期几
|
||||
cronSb.setLength(0);
|
||||
cronSb.append(validList.get(2)).append(" ")//秒
|
||||
.append(validList.get(1)).append(" ")//分
|
||||
.append(validList.get(0)).append(" ")//小时
|
||||
.append("?").append(" ")//日
|
||||
.append(cfg.getUserRegion2()).append(" ");//月
|
||||
if("L".equalsIgnoreCase(nthWeek)) {
|
||||
cronSb.append(week).append("L");//周
|
||||
}else {
|
||||
cronSb.append(week).append("#").append(nthWeek);//周
|
||||
}
|
||||
trigger = createCronTrigger(cronSb.toString(), cfg.getCompileId(), true, cfg);
|
||||
triList.add(trigger);
|
||||
cronSb.setLength(0);
|
||||
cronSb.append(invalidList.get(2)).append(" ")//秒
|
||||
.append(invalidList.get(1)).append(" ")//分
|
||||
.append(invalidList.get(0)).append(" ")//小时
|
||||
.append("?").append(" ")//日
|
||||
.append(cfg.getUserRegion2()).append(" ");//月
|
||||
if("L".equalsIgnoreCase(nthWeek)) {
|
||||
cronSb.append(week).append("L");//周
|
||||
}else {
|
||||
cronSb.append(week).append("#").append(nthWeek);//周
|
||||
}
|
||||
trigger = createCronTrigger(cronSb.toString(), cfg.getCompileId(), false, cfg);
|
||||
triList.add(trigger);
|
||||
}
|
||||
}
|
||||
}
|
||||
return triList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查找最近的 星期几 ,包括今天
|
||||
* @param date
|
||||
* @param w 周一开始 1 -7
|
||||
* @return
|
||||
*/
|
||||
public static Date closestAfterWeek(Date date,int w) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(date);
|
||||
int i = cal.get(Calendar.DAY_OF_WEEK);//周日开始 1-7
|
||||
i = (i==1)? 7: i-1;//转换为 周一到 周日 1-7
|
||||
cal.add(Calendar.DAY_OF_MONTH, (i>w)?(7-(i-w)) : (w-i));
|
||||
return cal.getTime();
|
||||
}
|
||||
|
||||
|
||||
public static TriggerKey createTiggerKey(String name,String group) {
|
||||
TriggerKey key = new TriggerKey(name, group);
|
||||
return key;
|
||||
}
|
||||
|
||||
/**
|
||||
* jquery cron 生成的cron 表达式,quartz 不能直接使用,需要做些修改
|
||||
* @param cron
|
||||
* @return
|
||||
*/
|
||||
public static String modifyCronExp(String cron) {
|
||||
String[] cronArr = cron.split("\\s");
|
||||
if("*".equals(cronArr[4])) {
|
||||
cronArr[4] = "?";
|
||||
}else {
|
||||
cronArr[3] = "*";
|
||||
cronArr[2] = "?";
|
||||
}
|
||||
return "0 " + StringUtils.join(cronArr, " ");
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
CronTriggerImpl cron = new CronTriggerImpl();
|
||||
try {
|
||||
String exp = "0 0 0 ? 1,2 1#4";
|
||||
cron.setCronExpression(exp);
|
||||
System.out.println(cron);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -194,6 +194,15 @@ public class CodeDicUtils {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* 用于显示日志isp运营商的信息
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
public static List<SysIspInfo> getIspListByIspNum(){
|
||||
List<SysIspInfo> result = codeSysIspInfoDicDao.getIspListByIspNum();;
|
||||
return result;
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
getCodeList(APP_CODE);
|
||||
}
|
||||
|
||||
580
src/main/java/com/nis/util/ConfigConvertUtil.java
Normal file
580
src/main/java/com/nis/util/ConfigConvertUtil.java
Normal file
@@ -0,0 +1,580 @@
|
||||
package com.nis.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.StringEscapeUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.googlecode.ipv6.IPv6Address;
|
||||
import com.googlecode.ipv6.IPv6Network;
|
||||
import com.nis.domain.basics.AsnIpCfg;
|
||||
import com.nis.domain.configuration.AppIpCfg;
|
||||
import com.nis.domain.configuration.BaseCfg;
|
||||
import com.nis.domain.configuration.BaseIpCfg;
|
||||
import com.nis.domain.configuration.BaseStringCfg;
|
||||
import com.nis.domain.configuration.ComplexkeywordCfg;
|
||||
import com.nis.domain.configuration.FileDigestCfg;
|
||||
import com.nis.domain.configuration.IpPortCfg;
|
||||
import com.nis.domain.maat.MaatCfg.DigestCfg;
|
||||
import com.nis.domain.maat.MaatCfg.GroupCfg;
|
||||
import com.nis.domain.maat.MaatCfg.IpCfg;
|
||||
import com.nis.domain.maat.MaatCfg.NumBoundaryCfg;
|
||||
import com.nis.domain.maat.MaatCfg.StringCfg;
|
||||
|
||||
public class ConfigConvertUtil {
|
||||
private static Logger logger = LoggerFactory.getLogger(ConfigConvertUtil.class);
|
||||
/**
|
||||
* 配置域转换
|
||||
* @param ipList
|
||||
* @param strList
|
||||
* @param complexStrList
|
||||
* @param numList
|
||||
* @param fileList
|
||||
* @param regionIds
|
||||
* @param groupIds
|
||||
* @param entity
|
||||
* @param compileId
|
||||
* @param auditTime
|
||||
* @param groupRelationList
|
||||
* @param ipRegionList
|
||||
* @param strRegionList
|
||||
* @param numRegionList
|
||||
* @param digestRegionList
|
||||
* @param areaIpRegionList
|
||||
* @param userRegion
|
||||
*/
|
||||
public static String configCovert(List<IpPortCfg> ipList,List<BaseStringCfg> strList,List<ComplexkeywordCfg> complexStrList,
|
||||
List<com.nis.domain.configuration.NumBoundaryCfg > numList,
|
||||
List<FileDigestCfg> fileList,List<Integer> regionIds,List<Integer> groupIds,BaseCfg entity,
|
||||
Integer compileId,Date auditTime,List<GroupCfg> groupRelationList,
|
||||
List<IpCfg> ipRegionList,
|
||||
List<StringCfg> strRegionList,
|
||||
List<NumBoundaryCfg> numRegionList,
|
||||
List<DigestCfg> digestRegionList,
|
||||
List<IpCfg> areaIpRegionList,String userRegion){
|
||||
List list1 = new ArrayList();
|
||||
List<BaseStringCfg> list2 = new ArrayList();
|
||||
List<ComplexkeywordCfg> list3 = new ArrayList();
|
||||
List<com.nis.domain.configuration.NumBoundaryCfg> list4 = new ArrayList();
|
||||
List<FileDigestCfg> list5 = new ArrayList();
|
||||
if(ipList.size()>0){
|
||||
for(int index=0;index<ipList.size();index++){
|
||||
IpPortCfg ip = ipList.get(index);
|
||||
if(ip.getCompileId().equals(compileId)){
|
||||
ip.setRegionId(regionIds.get(0));
|
||||
regionIds.remove(0);
|
||||
ip.setGroupId(groupIds.get(0));
|
||||
groupIds.remove(0);
|
||||
ip.setIsValid(entity.getIsValid());
|
||||
ip.setAuditTime(auditTime);
|
||||
list1.add(ip);
|
||||
}
|
||||
}
|
||||
}
|
||||
for(int index=0;index<strList.size();index++){
|
||||
BaseStringCfg str = strList.get(index);
|
||||
if(str.getCompileId().equals(compileId)){
|
||||
str.setRegionId(regionIds.get(0));
|
||||
regionIds.remove(0);
|
||||
str.setGroupId(groupIds.get(0));
|
||||
groupIds.remove(0);
|
||||
str.setIsValid(entity.getIsValid());
|
||||
str.setAuditTime(auditTime);
|
||||
list2.add(str);
|
||||
if(entity.getServiceId().equals(513)||entity.getServiceId().equals(515)){
|
||||
if(userRegion.equals("")){
|
||||
userRegion += Constants.USERREGION_DOMAIN_STR+"="+str.getCfgKeywords();
|
||||
}else{
|
||||
userRegion += Constants.USER_REGION_SPLIT+Constants.USERREGION_DOMAIN_STR+"="+str.getCfgKeywords();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for(int index=0;index<complexStrList.size();index++){
|
||||
ComplexkeywordCfg str = complexStrList.get(index);
|
||||
if(str.getCompileId().equals(compileId)){
|
||||
str.setRegionId(regionIds.get(0));
|
||||
regionIds.remove(0);
|
||||
str.setGroupId(groupIds.get(0));
|
||||
groupIds.remove(0);
|
||||
str.setIsValid(entity.getIsValid());
|
||||
str.setAuditTime(auditTime);
|
||||
list3.add(str);
|
||||
if(entity.getServiceId().equals(129) && str.getDistrict()!=null){//http监测
|
||||
String dictValue = DictUtils.getDictCode(Constants.HTTP_HEADER_DICT_MODULE, str.getDistrict());
|
||||
if(StringUtil.isEmpty(dictValue) || dictValue.equals("默认")){
|
||||
if(userRegion.equals("")){
|
||||
userRegion += Constants.HTTP_HEADER_USER_REGION_KEY+"="+str.getDistrict();
|
||||
}else{
|
||||
userRegion += Constants.USER_REGION_SPLIT+Constants.HTTP_HEADER_USER_REGION_KEY+"="+str.getDistrict();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for(int index=0;index<numList.size();index++){
|
||||
com.nis.domain.configuration.NumBoundaryCfg num = numList.get(index);
|
||||
if(num.getCompileId().equals(compileId)){
|
||||
num.setRegionId(regionIds.get(0));
|
||||
regionIds.remove(0);
|
||||
num.setGroupId(groupIds.get(0));
|
||||
groupIds.remove(0);
|
||||
num.setIsValid(entity.getIsValid());
|
||||
num.setAuditTime(auditTime);
|
||||
list4.add(num);
|
||||
}
|
||||
}
|
||||
for(int index=0;index<fileList.size();index++){
|
||||
FileDigestCfg file = fileList.get(index);
|
||||
if(file.getCompileId().equals(compileId)){
|
||||
file.setRegionId(regionIds.get(0));
|
||||
regionIds.remove(0);
|
||||
file.setGroupId(groupIds.get(0));
|
||||
groupIds.remove(0);
|
||||
file.setIsValid(entity.getIsValid());
|
||||
file.setAuditTime(auditTime);
|
||||
list5.add(file);
|
||||
}
|
||||
}
|
||||
if(list1.size()>0){
|
||||
ipList.removeAll(list1);
|
||||
Map<String,List> map = cfgToMaatConvert(ipRegionList,list1,1,groupRelationList);
|
||||
groupRelationList=map.get("groupList");
|
||||
ipRegionList=map.get("dstList");
|
||||
if(map.get("numRegionList")!=null){
|
||||
numRegionList.addAll(map.get("numRegionList"));
|
||||
}
|
||||
}
|
||||
if(list2.size()>0){
|
||||
strList.removeAll(list2);
|
||||
Map<String,List> map = cfgToMaatConvert(strRegionList,list2,2,groupRelationList);
|
||||
groupRelationList=map.get("groupList");
|
||||
strRegionList=map.get("dstList");
|
||||
}
|
||||
if(list3.size()>0){
|
||||
complexStrList.removeAll(list3);
|
||||
Map<String,List> map = cfgToMaatConvert(strRegionList,list3,3,groupRelationList);
|
||||
groupRelationList=map.get("groupList");
|
||||
strRegionList=map.get("dstList");
|
||||
}
|
||||
if(list4.size()>0){
|
||||
numList.removeAll(list4);
|
||||
Map<String,List> map = cfgToMaatConvert(numRegionList,list4,4,groupRelationList);
|
||||
groupRelationList=map.get("groupList");
|
||||
numRegionList=map.get("dstList");
|
||||
}
|
||||
if(list5.size()>0){
|
||||
fileList.removeAll(list5);
|
||||
Map<String,List> map = cfgToMaatConvert(digestRegionList,list5,5,groupRelationList);
|
||||
groupRelationList=map.get("groupList");
|
||||
digestRegionList=map.get("dstList");
|
||||
}
|
||||
return userRegion;
|
||||
}
|
||||
// asn IP 复用转换
|
||||
public static List<IpCfg> groupReuseCfgAddRemoveConvert(List<? extends BaseCfg<?>> ipCfgList, Integer isValid,
|
||||
Integer groupId) {
|
||||
logger.warn("convert data start");
|
||||
long start = System.currentTimeMillis();
|
||||
Date opTime = new Date();
|
||||
List<IpCfg> maatIpList = new ArrayList<>();
|
||||
if (ipCfgList.size() > 0) {
|
||||
// 只用一次instanceof,取代循环中每次都用一次instanceof
|
||||
if (ipCfgList.get(0) instanceof AsnIpCfg) {
|
||||
for (BaseCfg<?> _cfg : ipCfgList) {
|
||||
IpCfg cfg = new IpCfg();
|
||||
BaseIpCfg baseIpCfg = new BaseIpCfg();
|
||||
AsnIpCfg asnIpCfg = (AsnIpCfg) _cfg;
|
||||
BeanUtils.copyProperties(asnIpCfg, baseIpCfg);
|
||||
BeanUtils.copyProperties(baseIpCfg, cfg);
|
||||
cfg.setGroupId(asnIpCfg.getAsnIpGroup());
|
||||
cfg.setRegionId(asnIpCfg.getRegionId());
|
||||
String userRegion = "ASN_ID=AS" + asnIpCfg.getUserRegion1();
|
||||
cfg.setUserRegion(userRegion);
|
||||
cfg.setIsValid(isValid);
|
||||
cfg.setAuditTime(opTime);
|
||||
List<IpCfg> cfgs = ipConvert(cfg, baseIpCfg);
|
||||
maatIpList.addAll(cfgs);
|
||||
}
|
||||
} else if (ipCfgList.get(0) instanceof AppIpCfg) {
|
||||
for (BaseCfg<?> _cfg : ipCfgList) {
|
||||
IpCfg cfg = new IpCfg();
|
||||
BaseIpCfg baseIpCfg = new BaseIpCfg();
|
||||
AppIpCfg appIpCfg = (AppIpCfg) _cfg;
|
||||
BeanUtils.copyProperties(appIpCfg, baseIpCfg);
|
||||
BeanUtils.copyProperties(baseIpCfg, cfg);
|
||||
cfg.setGroupId(groupId);
|
||||
cfg.setRegionId(Integer.parseInt(appIpCfg.getUserRegion1()));
|
||||
String userRegion = "APP_ID=" + appIpCfg.getAppCode();
|
||||
cfg.setUserRegion(userRegion);
|
||||
cfg.setIsValid(isValid);
|
||||
cfg.setAuditTime(opTime);
|
||||
List<IpCfg> cfgs = ipConvert(cfg, baseIpCfg);
|
||||
maatIpList.addAll(cfgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
long end = System.currentTimeMillis();
|
||||
logger.warn("convert data finish,cost:" + (end - start));
|
||||
return maatIpList;
|
||||
}
|
||||
/**
|
||||
* 界面配置list转换为服务接口端的list,用于批量下发时,regionId,groupId已在该方法前被批量获取
|
||||
*
|
||||
* @param <T>
|
||||
* @param <T>
|
||||
* @param dstList
|
||||
* @param srcList
|
||||
* @param cfgType,1为IP类型,2为字符串类型,3为增强字符串,4数值类型,5摘要类,6回调类[但字符串类域配置和增强字符串域配置在接口参数中同属于strRegionList]
|
||||
* @param baseCfg,配置基本信息
|
||||
* @param groupRelationList
|
||||
* 配置分组列表
|
||||
* @return
|
||||
*/
|
||||
public static <T> Map<String, List> cfgToMaatConvert(List dstList, List<T> srcList, Integer cfgType,List groupRelationList) {
|
||||
Map<String, List> map = new HashMap();
|
||||
if (cfgType == 1) {
|
||||
List numRegionList = new ArrayList();
|
||||
Integer groupId = 0;
|
||||
Integer numGroupId = 0;
|
||||
for (int i = 0; i < srcList.size(); i++) {
|
||||
List<Integer> regionIdList = Lists.newArrayList();
|
||||
T srcCfg = srcList.get(i);
|
||||
BaseIpCfg baseIpCfg = new BaseIpCfg();
|
||||
BeanUtils.copyProperties(srcCfg, baseIpCfg,new String[]{"menuNameCode"});
|
||||
regionIdList.add(baseIpCfg.getRegionId());
|
||||
IpCfg cfg = new IpCfg();
|
||||
BeanUtils.copyProperties(baseIpCfg, cfg);
|
||||
//多条IP配置属于同一个分组
|
||||
if (groupId == 0) {
|
||||
GroupCfg group = new GroupCfg();
|
||||
groupId = baseIpCfg.getGroupId();
|
||||
group.setGroupId(groupId);
|
||||
group.setCompileId(baseIpCfg.getCompileId());
|
||||
group.setAuditTime(baseIpCfg.getAuditTime());
|
||||
group.setIsValid(baseIpCfg.getIsValid());
|
||||
groupRelationList.add(group);
|
||||
}
|
||||
cfg.setGroupId(groupId);
|
||||
cfg.setAuditTime(baseIpCfg.getAuditTime());
|
||||
cfg.setIsValid(baseIpCfg.getIsValid());
|
||||
List<IpCfg> cfgs = ipConvert(cfg, baseIpCfg);
|
||||
if (cfgs.size() > 1) {
|
||||
List<Integer> ids = ConfigServiceUtil.getId(3, cfgs.size() - 1);
|
||||
regionIdList.addAll(ids);
|
||||
}
|
||||
for (int j = i; j < cfgs.size() + i; j++) {
|
||||
cfgs.get(j - i).setRegionId(regionIdList.get(j));
|
||||
}
|
||||
dstList.addAll(cfgs);
|
||||
|
||||
// 如果protocolId非空非零,需要构造数值型域配置,多条相同协议的IP只需要一条数值域配置(目前没有不同协议IP&情况)
|
||||
if (baseIpCfg.getProtocolId() != null && baseIpCfg.getProtocolId() != 0) {
|
||||
if (numGroupId == 0) {
|
||||
GroupCfg group1 = new GroupCfg();
|
||||
group1.setGroupId(ConfigServiceUtil.getId(2, 1).get(0));
|
||||
group1.setCompileId(baseIpCfg.getCompileId());
|
||||
group1.setAuditTime(baseIpCfg.getAuditTime());
|
||||
group1.setIsValid(baseIpCfg.getIsValid());
|
||||
groupRelationList.add(group1);
|
||||
NumBoundaryCfg numCfg = new NumBoundaryCfg();
|
||||
numCfg.initDefaultValue();
|
||||
numCfg.setLowBoundary(baseIpCfg.getProtocolId());
|
||||
numCfg.setUpBoundary(baseIpCfg.getProtocolId());
|
||||
numCfg.setRegionId(ConfigServiceUtil.getId(3, 1).get(0));
|
||||
numCfg.setAuditTime(baseIpCfg.getAuditTime());
|
||||
numCfg.setGroupId(group1.getGroupId());
|
||||
numCfg.setIsValid(baseIpCfg.getIsValid());
|
||||
numRegionList.add(numCfg);
|
||||
map.put("numRegionList", numRegionList);
|
||||
numGroupId++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else if (cfgType == 2 || cfgType == 3) {
|
||||
for (int i = 0; i < srcList.size(); i++) {
|
||||
// 一条业务配置创建一个分组
|
||||
BaseCfg baseCfg = new BaseCfg();
|
||||
BeanUtils.copyProperties(srcList.get(i), baseCfg,new String[]{"menuNameCode"});//拷贝公共属性
|
||||
GroupCfg group = new GroupCfg();
|
||||
StringCfg cfg = new StringCfg();
|
||||
BeanUtils.copyProperties(srcList.get(i), cfg,new String[]{"menuNameCode"});//拷贝公共属性以及私有属性
|
||||
group.setGroupId(baseCfg.getGroupId());
|
||||
group.setCompileId(baseCfg.getCompileId());
|
||||
group.setAuditTime(baseCfg.getAuditTime());
|
||||
group.setIsValid(baseCfg.getIsValid());
|
||||
groupRelationList.add(group);
|
||||
cfg.setGroupId(group.getGroupId());
|
||||
cfg.setRegionId(baseCfg.getRegionId());
|
||||
cfg.setAuditTime(baseCfg.getAuditTime());
|
||||
cfg.setIsValid(baseCfg.getIsValid());
|
||||
// 处理配置关键字转译
|
||||
cfg.setCfgKeywords(keywordsEscape(cfg.getCfgKeywords()));
|
||||
// 增强字符串转换
|
||||
cfg.setDistrict(keywordsEscape(cfg.getDistrict()));
|
||||
dstList.add(cfg);
|
||||
}
|
||||
} else if (cfgType == 4) {
|
||||
for (int i = 0; i < srcList.size(); i++) {
|
||||
BaseCfg baseCfg = new BaseCfg();
|
||||
BeanUtils.copyProperties(srcList.get(i), baseCfg,new String[]{"menuNameCode"});//拷贝公共属性
|
||||
// 一条业务配置创建一个分组
|
||||
com.nis.domain.maat.MaatCfg.NumBoundaryCfg cfg = new com.nis.domain.maat.MaatCfg.NumBoundaryCfg();
|
||||
BeanUtils.copyProperties(srcList.get(i), cfg,new String[]{"menuNameCode"});
|
||||
GroupCfg group = new GroupCfg();
|
||||
group.setGroupId(baseCfg.getGroupId());
|
||||
group.setCompileId(baseCfg.getCompileId());
|
||||
group.setAuditTime(baseCfg.getAuditTime());
|
||||
group.setIsValid(baseCfg.getIsValid());
|
||||
groupRelationList.add(group);
|
||||
cfg.setGroupId(group.getGroupId());
|
||||
cfg.setRegionId(baseCfg.getRegionId());
|
||||
cfg.setAuditTime(baseCfg.getAuditTime());
|
||||
cfg.setIsValid(baseCfg.getIsValid());
|
||||
dstList.add(cfg);
|
||||
}
|
||||
} else if (cfgType == 5) {
|
||||
for (int i = 0; i < srcList.size(); i++) {
|
||||
BaseCfg baseCfg = new BaseCfg();
|
||||
BeanUtils.copyProperties(srcList.get(i), baseCfg,new String[]{"menuNameCode"});//拷贝公共属性
|
||||
// 一条业务配置创建一个分组
|
||||
com.nis.domain.maat.MaatCfg.DigestCfg cfg = new com.nis.domain.maat.MaatCfg.DigestCfg();
|
||||
BeanUtils.copyProperties(srcList.get(i), cfg,new String[]{"menuNameCode"});
|
||||
GroupCfg group = new GroupCfg();
|
||||
group.setGroupId(baseCfg.getGroupId());
|
||||
group.setCompileId(baseCfg.getCompileId());
|
||||
group.setAuditTime(baseCfg.getAuditTime());
|
||||
group.setIsValid(baseCfg.getIsValid());
|
||||
groupRelationList.add(group);
|
||||
cfg.setGroupId(group.getGroupId());
|
||||
cfg.setRegionId(baseCfg.getRegionId());
|
||||
cfg.setAuditTime(baseCfg.getAuditTime());
|
||||
cfg.setIsValid(baseCfg.getIsValid());
|
||||
dstList.add(cfg);
|
||||
}
|
||||
} else {
|
||||
dstList.addAll(srcList);
|
||||
}
|
||||
map.put("groupList", groupRelationList);
|
||||
map.put("dstList", dstList);
|
||||
return map;
|
||||
}
|
||||
/**
|
||||
* 关键字特殊字符转义处理
|
||||
* @param cfgKeywords
|
||||
* @return
|
||||
*/
|
||||
public static String keywordsEscape(String cfgKeywords) {
|
||||
if (StringUtils.isNotEmpty(cfgKeywords)) {
|
||||
// 不转译特殊字符
|
||||
cfgKeywords = cfgKeywords.trim();// 首先去掉首尾空格
|
||||
cfgKeywords = StringEscapeUtils.unescapeHtml4(cfgKeywords);
|
||||
cfgKeywords = cfgKeywords.replace("\\", "\\\\");
|
||||
cfgKeywords = cfgKeywords.replace("&", "\\&");
|
||||
cfgKeywords = cfgKeywords.replace(" ", "\\b");
|
||||
// ***and***在界面表示多个关键字的与表达式,此特殊字符串在common.js中使用定义,maat端以&表示
|
||||
cfgKeywords = cfgKeywords.replace(Constants.KEYWORD_EXPR, "&");
|
||||
|
||||
}
|
||||
return cfgKeywords;
|
||||
}
|
||||
/**
|
||||
* 界面IP配置转换为MAAT类或者回调类IP配置
|
||||
*
|
||||
* @param dstIp
|
||||
* @param srcIp
|
||||
* @return
|
||||
*/
|
||||
public static List<IpCfg> ipConvert(IpCfg dstIp, BaseIpCfg srcIp) {
|
||||
List<IpCfg> ipConvertList = Lists.newArrayList();
|
||||
List<IpCfg> tempList = Lists.newArrayList();
|
||||
List<IpCfg> tempList1 = Lists.newArrayList();
|
||||
if (srcIp.getIpType().equals(4)) {// IP V4
|
||||
if(srcIp.getSrcIpPattern().equals(2)) {//源IP范围
|
||||
if (srcIp.getSrcIpAddress() != null) {
|
||||
String startIpPart = srcIp.getSrcIpAddress().split("-")[0];
|
||||
String endIpPart = srcIp.getSrcIpAddress().split("-")[1];
|
||||
Integer startNum = Integer.parseInt(startIpPart.split("\\.")[3]);
|
||||
Integer endNum = Integer.parseInt(endIpPart.split("\\.")[3]);
|
||||
for (int i = startNum; i <= endNum; i++) {
|
||||
IpCfg tempIp = new IpCfg();
|
||||
BeanUtils.copyProperties(dstIp, tempIp);
|
||||
tempIp.setSrcIp(startIpPart.substring(0, startIpPart.lastIndexOf(".") + 1) + i);
|
||||
tempIp.setSrcIpMask("255.255.255.255");
|
||||
tempList.add(tempIp);
|
||||
}
|
||||
}else {
|
||||
dstIp.setSrcIp("0.0.0.0");
|
||||
dstIp.setSrcIpMask("255.255.255.255");
|
||||
tempList.add(dstIp);
|
||||
}
|
||||
}else if(srcIp.getSrcIpPattern().equals(1)){
|
||||
Integer srcMaskNum = Integer.parseInt(srcIp.getSrcIpAddress().split("/")[1]);
|
||||
if (srcMaskNum == 0) {
|
||||
dstIp.setSrcIpMask("0.0.0.0");
|
||||
} else {
|
||||
dstIp.setSrcIpMask(IpUtil.convertMask(srcMaskNum));
|
||||
}
|
||||
dstIp.setSrcIp(srcIp.getSrcIpAddress().split("/")[0]);
|
||||
tempList.add(dstIp);
|
||||
}else if(srcIp.getSrcIpPattern().equals(3)){
|
||||
dstIp.setSrcIp(srcIp.getSrcIpAddress());
|
||||
dstIp.setSrcIpMask("255.255.255.255");
|
||||
tempList.add(dstIp);
|
||||
}else {
|
||||
throw new RuntimeException("Unsupported IP Pattern " + srcIp.getSrcIpPattern());
|
||||
}
|
||||
if (srcIp.getDestIpAddress() != null) {
|
||||
if(srcIp.getDestIpPattern().equals(2)) {
|
||||
String startIpPart = srcIp.getDestIpAddress().split("-")[0];
|
||||
String endIpPart = srcIp.getDestIpAddress().split("-")[1];
|
||||
Integer startNum = Integer.parseInt(startIpPart.split("\\.")[3]);
|
||||
Integer endNum = Integer.parseInt(endIpPart.split("\\.")[3]);
|
||||
for (IpCfg _cfg : tempList) {
|
||||
for (int i = startNum; i <= endNum; i++) {
|
||||
IpCfg tempIp = new IpCfg();
|
||||
BeanUtils.copyProperties(_cfg, tempIp);
|
||||
tempIp.setDstIp(startIpPart.substring(0, startIpPart.lastIndexOf(".") + 1) + i);
|
||||
tempIp.setDstIpMask("255.255.255.255");
|
||||
// 处理
|
||||
convertPortValues(tempIp, srcIp);
|
||||
if (!tempIp.getSrcIp().equals(tempIp.getDstIp())) {
|
||||
tempList1.add(tempIp);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
tempList.clear();
|
||||
}else if(srcIp.getDestIpPattern().equals(1)) {
|
||||
Integer dstMaskNum = Integer.parseInt(srcIp.getDestIpAddress().split("/")[1]);
|
||||
for (IpCfg _cfg : tempList) {
|
||||
IpCfg tempIp = new IpCfg();
|
||||
BeanUtils.copyProperties(_cfg, tempIp);
|
||||
if (dstMaskNum == 0) {
|
||||
tempIp.setDstIpMask("0.0.0.0");
|
||||
} else {
|
||||
tempIp.setDstIpMask(IpUtil.convertMask(dstMaskNum));
|
||||
}
|
||||
tempIp.setDstIp(srcIp.getDestIpAddress().split("/")[0]);
|
||||
if (!tempIp.getSrcIp().equals(tempIp.getDstIp())) {
|
||||
// 处理
|
||||
convertPortValues(tempIp, srcIp);
|
||||
tempList1.add(tempIp);
|
||||
}
|
||||
}
|
||||
tempList.clear();
|
||||
}else {
|
||||
for (IpCfg _cfg : tempList) {
|
||||
IpCfg tempIp = new IpCfg();
|
||||
BeanUtils.copyProperties(_cfg, tempIp);
|
||||
tempIp.setDstIp(srcIp.getDestIpAddress());
|
||||
if (!tempIp.getSrcIp().equals(tempIp.getDstIp())) {
|
||||
tempIp.setDstIpMask("255.255.255.255");
|
||||
// 处理
|
||||
convertPortValues(tempIp, srcIp);
|
||||
tempList1.add(tempIp);
|
||||
}
|
||||
}
|
||||
tempList.clear();
|
||||
}
|
||||
}else {
|
||||
for (IpCfg _cfg : tempList) {
|
||||
_cfg.setDstIp("0.0.0.0");
|
||||
_cfg.setSrcIpMask("255.255.255.255");
|
||||
convertPortValues(_cfg, srcIp);
|
||||
}
|
||||
}
|
||||
if (tempList1.size() > 0) {
|
||||
ipConvertList.addAll(tempList1);
|
||||
} else {
|
||||
ipConvertList.addAll(tempList);
|
||||
}
|
||||
}else if(srcIp.getIpType().equals(6)){// IP V6
|
||||
if (srcIp.getSrcIpAddress() != null) {
|
||||
if(srcIp.getSrcIpPattern().equals(2)) {
|
||||
IPv6Address address1 = IPv6Address.fromString(srcIp.getSrcIpAddress().split("-")[0]);
|
||||
IPv6Address address2 = IPv6Address.fromString(srcIp.getSrcIpAddress().split("-")[1]);
|
||||
IPv6Network network = IPv6Network.fromTwoAddresses(address1, address2);
|
||||
dstIp.setSrcIp(address1.toString());
|
||||
dstIp.setSrcIpMask(network.getNetmask().asAddress().toString());
|
||||
}else if(srcIp.getSrcIpPattern().equals(1)){// IP/掩码
|
||||
IPv6Network strangeNetwork = IPv6Network.fromString(srcIp.getSrcIpAddress());
|
||||
dstIp.setSrcIp(srcIp.getSrcIpAddress().split("/")[0]);
|
||||
dstIp.setSrcIpMask(strangeNetwork.getNetmask().asAddress().toString());
|
||||
}else {// IP
|
||||
dstIp.setSrcIp(srcIp.getSrcIpAddress());
|
||||
dstIp.setSrcIpMask("FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF");
|
||||
}
|
||||
} else {
|
||||
dstIp.setSrcIp("::");
|
||||
dstIp.setSrcIpMask("FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF");
|
||||
}
|
||||
if (srcIp.getDestIpAddress() != null) {
|
||||
if(srcIp.getDestIpPattern().equals(2)) {
|
||||
IPv6Address address1 = IPv6Address.fromString(srcIp.getDestIpAddress().split("-")[0]);
|
||||
IPv6Address address2 = IPv6Address.fromString(srcIp.getDestIpAddress().split("-")[1]);
|
||||
IPv6Network network = IPv6Network.fromTwoAddresses(address1, address2);
|
||||
dstIp.setDstIp(address1.toString());
|
||||
dstIp.setDstIpMask(network.getNetmask().asAddress().toString());
|
||||
}else if(srcIp.getDestIpPattern().equals(1)) {// IP/掩码
|
||||
IPv6Network strangeNetwork = IPv6Network.fromString(srcIp.getDestIpAddress());
|
||||
dstIp.setDstIp(srcIp.getDestIpAddress().split("/")[0]);
|
||||
dstIp.setDstIpMask(strangeNetwork.getNetmask().asAddress().toString());
|
||||
}else {// IP
|
||||
dstIp.setDstIp(srcIp.getDestIpAddress());
|
||||
dstIp.setDstIpMask("FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF");
|
||||
}
|
||||
} else {
|
||||
dstIp.setDstIp("::");
|
||||
dstIp.setDstIpMask("FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF");
|
||||
}
|
||||
convertPortValues(dstIp, srcIp);
|
||||
ipConvertList.add(dstIp);
|
||||
}else {
|
||||
throw new RuntimeException("Unsupported IP type " + srcIp.getIpType());
|
||||
}
|
||||
return ipConvertList;
|
||||
}
|
||||
/**
|
||||
* 设置端口值
|
||||
*
|
||||
* @param dstIp
|
||||
* @param srcIp
|
||||
*/
|
||||
public static void convertPortValues(IpCfg dstIp, BaseIpCfg srcIp) {
|
||||
if (srcIp.getSrcPort() != null) {
|
||||
if (srcIp.getSrcPort().indexOf("/") != -1) {
|
||||
String srcMaskNum = srcIp.getSrcPort().split("/")[1];
|
||||
dstIp.setSrcPortMask(srcMaskNum);
|
||||
dstIp.setSrcPort(srcIp.getSrcPort().split("/")[0]);
|
||||
} else {
|
||||
dstIp.setSrcPort(srcIp.getSrcPort());
|
||||
dstIp.setSrcPortMask("65535");
|
||||
}
|
||||
} else {
|
||||
dstIp.setSrcPort("0");
|
||||
dstIp.setSrcPortMask("65535");
|
||||
}
|
||||
if (srcIp.getDestPort() != null) {
|
||||
if (srcIp.getDestPort().indexOf("/") != -1) {
|
||||
String dstMaskNum = srcIp.getDestPort().split("/")[1];
|
||||
dstIp.setDstPortMask(dstMaskNum);
|
||||
dstIp.setDstPort(srcIp.getDestPort().split("/")[0]);
|
||||
} else {
|
||||
dstIp.setDstPort(srcIp.getDestPort());
|
||||
dstIp.setDstPortMask("65535");
|
||||
}
|
||||
} else {
|
||||
dstIp.setDstPort("0");
|
||||
dstIp.setDstPortMask("65535");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.nis.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -11,6 +12,7 @@ import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.nis.domain.SysDataDictionaryItem;
|
||||
import com.nis.domain.SysDataDictionaryName;
|
||||
import com.nis.domain.basics.AsnGroupInfo;
|
||||
import com.nis.domain.basics.ServiceDictInfo;
|
||||
import com.nis.domain.basics.SysDictInfo;
|
||||
import com.nis.domain.configuration.BaseStringCfg;
|
||||
@@ -18,6 +20,7 @@ import com.nis.domain.configuration.CfgIndexInfo;
|
||||
import com.nis.domain.configuration.PxyObjTrustedCaCrl;
|
||||
import com.nis.domain.specific.SpecificServiceCfg;
|
||||
import com.nis.web.dao.SysDictDao;
|
||||
import com.nis.web.dao.basics.AsnGroupInfoDao;
|
||||
import com.nis.web.dao.basics.ServiceDictInfoDao;
|
||||
import com.nis.web.dao.basics.SysDictInfoDao;
|
||||
import com.nis.web.dao.configuration.PxyObjKeyringDao;
|
||||
@@ -41,6 +44,7 @@ public class ConfigDictUtils {
|
||||
private final static SpecificServiceCfgDao specificServiceCfgDao = SpringContextHolder.getBean(SpecificServiceCfgDao.class);
|
||||
private final static WebsiteCfgDao websiteCfgDao = SpringContextHolder.getBean(WebsiteCfgDao.class);
|
||||
private final static PxyObjKeyringDao pxyObjKeyringDao = SpringContextHolder.getBean(PxyObjKeyringDao.class);
|
||||
private final static AsnGroupInfoDao asnGroupInfoDao = SpringContextHolder.getBean(AsnGroupInfoDao.class);
|
||||
|
||||
/**
|
||||
* 根据主键查询配置详情
|
||||
@@ -203,4 +207,37 @@ public class ConfigDictUtils {
|
||||
}
|
||||
return crlFIle;
|
||||
}
|
||||
/**
|
||||
* 根据compileId获取配置内容
|
||||
* @param compileId
|
||||
* @return
|
||||
*/
|
||||
public static List<Integer> getASNIPNum(Integer groupId ) {
|
||||
List<Integer> ipNum=new ArrayList<>();
|
||||
try {
|
||||
if(!StringUtil.isEmpty(groupId)){
|
||||
List<Object[]> list=asnGroupInfoDao.getASNIPNum(groupId);
|
||||
if(!StringUtil.isEmpty(list)){
|
||||
int index=0;
|
||||
for (Iterator iterator = list.iterator(); iterator.hasNext();) {
|
||||
if(index==0){
|
||||
Map map=(Map) iterator.next();
|
||||
if(map != null){
|
||||
ipNum.add(0, (Integer) map.get("v4_num"));
|
||||
ipNum.add(1, (Integer) map.get("v6_num"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if(ipNum ==null || ipNum.size()==0){
|
||||
ipNum.add(0, 0);
|
||||
ipNum.add(1, 0);
|
||||
}
|
||||
return ipNum;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,6 +133,7 @@ public class ConfigServiceUtil {
|
||||
result=response.readEntity(String.class);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("request_service_failed",e);
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
||||
}
|
||||
if(response != null && response.getStatus() == 200){
|
||||
@@ -157,6 +158,7 @@ public class ConfigServiceUtil {
|
||||
long end=System.currentTimeMillis();
|
||||
logger.warn("get ids finish,cost:"+(end-start));
|
||||
} catch (Exception e) {
|
||||
logger.error("getId()",e);
|
||||
throw e;
|
||||
}finally {
|
||||
if (response != null) {
|
||||
@@ -188,6 +190,7 @@ public class ConfigServiceUtil {
|
||||
result=response.readEntity(String.class);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
||||
}
|
||||
if(response != null && response.getStatus() == 200){
|
||||
@@ -200,6 +203,7 @@ public class ConfigServiceUtil {
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+result);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("postMaatCfg()",e);
|
||||
throw e;
|
||||
}finally {
|
||||
if (response != null) {
|
||||
@@ -232,6 +236,7 @@ public class ConfigServiceUtil {
|
||||
result=response.readEntity(String.class);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
||||
}
|
||||
if(response != null && response.getStatus() == 200){
|
||||
@@ -241,6 +246,8 @@ public class ConfigServiceUtil {
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+result);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("postCallbackCfg()",e);
|
||||
throw e;
|
||||
}finally {
|
||||
if (response != null) {
|
||||
@@ -275,6 +282,7 @@ public class ConfigServiceUtil {
|
||||
result=response.readEntity(String.class);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
||||
}
|
||||
if(response != null && response.getStatus() == 200){
|
||||
@@ -284,6 +292,7 @@ public class ConfigServiceUtil {
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>"+result);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("postFileCfg()",e);
|
||||
throw e;
|
||||
} finally {
|
||||
if (response != null) {
|
||||
@@ -321,6 +330,7 @@ public class ConfigServiceUtil {
|
||||
result=response.readEntity(String.class);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
||||
}
|
||||
if(response != null && response.getStatus() == 200){
|
||||
@@ -330,6 +340,7 @@ public class ConfigServiceUtil {
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+result);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("delete()",e);
|
||||
throw e;
|
||||
} finally {
|
||||
if (response != null) {
|
||||
@@ -356,7 +367,7 @@ public class ConfigServiceUtil {
|
||||
}else if(type==2){
|
||||
url = url+Constants.CALLBACK_CFG;
|
||||
}else if(type==3) {
|
||||
url = url+Constants.DELETE_COMMON_REIGON;
|
||||
url = url+Constants.GROUP_REUSE_SOURCES;
|
||||
}
|
||||
//创建连接
|
||||
WebTarget wt = ClientUtil.getWebTarger(url);
|
||||
@@ -369,6 +380,7 @@ public class ConfigServiceUtil {
|
||||
result=response.readEntity(String.class);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
||||
}
|
||||
if(response !=null && response.getStatus() == 200){
|
||||
@@ -378,6 +390,7 @@ public class ConfigServiceUtil {
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+result);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("put()",e);
|
||||
throw e;
|
||||
}finally {
|
||||
if (response != null) {
|
||||
@@ -400,9 +413,9 @@ public class ConfigServiceUtil {
|
||||
url = url+Constants.MAAT_CFG;
|
||||
}else if(type==2){
|
||||
url = url+Constants.CALLBACK_CFG;
|
||||
}/*else if(type==3) {
|
||||
}else if(type==3) {
|
||||
url = url+Constants.GROUP_REUSE_SOURCES;
|
||||
}*/
|
||||
}
|
||||
logger.info("put url:"+url);
|
||||
//创建连接
|
||||
try {
|
||||
@@ -411,9 +424,11 @@ public class ConfigServiceUtil {
|
||||
// bean = (ToMaatResult) JSONObject.toBean(resObject,ToMaatResult.class);
|
||||
//获取响应结果
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+result);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("patch()",e);
|
||||
throw e;
|
||||
}
|
||||
|
||||
@@ -444,6 +459,7 @@ public class ConfigServiceUtil {
|
||||
result=response.readEntity(String.class);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
||||
}
|
||||
if(response !=null && response.getStatus() == 200){
|
||||
@@ -451,9 +467,11 @@ public class ConfigServiceUtil {
|
||||
JSONObject resObject = JSONObject.fromObject(result);
|
||||
bean = (ToMaatResult) JSONObject.toBean(resObject,ToMaatResult.class);
|
||||
}else{
|
||||
logger.info("获取文件摘要响应结果"+result);
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+result);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("getFileDigest()",e);
|
||||
throw e;
|
||||
} finally {
|
||||
if (response != null) {
|
||||
@@ -463,43 +481,26 @@ public class ConfigServiceUtil {
|
||||
return bean;
|
||||
}
|
||||
/**
|
||||
* 分组复用域配置新增,修改,删除
|
||||
* 分组复用域配置新增
|
||||
* @param params
|
||||
* @return
|
||||
* @throws MaatConvertException
|
||||
*/
|
||||
public static ToMaatResult auditCommonGroupRegionSources(String params,Integer action) throws MaatConvertException{
|
||||
public static ToMaatResult postGroupReuseSources(String params) throws MaatConvertException{
|
||||
ToMaatResult bean = null;
|
||||
Response response=null;
|
||||
try {
|
||||
logger.warn("postGroupReuseSources start");
|
||||
long start=System.currentTimeMillis();
|
||||
String result = null;
|
||||
String url = "";
|
||||
if(action.equals(Constants.OPACTION_POST)){
|
||||
url=Constants.SERVICE_URL+Constants.ADD_COMMON_REGION;
|
||||
}
|
||||
if(action.equals(Constants.OPACTION_PUT)){
|
||||
url=Constants.SERVICE_URL+Constants.UPDATE_COMMON_REIGON;
|
||||
}
|
||||
if(action.equals(Constants.OPACTION_DELETE)){
|
||||
url=Constants.SERVICE_URL+Constants.DELETE_COMMON_REIGON;
|
||||
}
|
||||
String url = Constants.SERVICE_URL+Constants.GROUP_REUSE_SOURCES;
|
||||
//创建连接
|
||||
WebTarget wt = ClientUtil.getWebTarger(url);
|
||||
logger.info("auditCommonGroupRegionSources url:"+url);
|
||||
logger.info("postGroupReuseSources url:"+url);
|
||||
//获取响应结果
|
||||
Builder header = wt.request(MediaType.APPLICATION_JSON).header("Content-Type", MediaType.APPLICATION_JSON);
|
||||
try {
|
||||
if(action.equals(Constants.OPACTION_POST)){
|
||||
response= header.post(Entity.entity(params, MediaType.APPLICATION_JSON));
|
||||
}
|
||||
if(action.equals(Constants.OPACTION_PUT)){
|
||||
response= header.put(Entity.entity(params, MediaType.APPLICATION_JSON));
|
||||
}
|
||||
if(action.equals(Constants.OPACTION_DELETE)){
|
||||
response= header.put(Entity.entity(params, MediaType.APPLICATION_JSON));
|
||||
}
|
||||
if(response != null) {
|
||||
result=response.readEntity(String.class);
|
||||
}
|
||||
@@ -515,8 +516,9 @@ public class ConfigServiceUtil {
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+result);
|
||||
}
|
||||
long end=System.currentTimeMillis();
|
||||
logger.warn("auditCommonGroupRegionSources end,cost:"+(end-start));
|
||||
logger.warn("postGroupReuseSources end,cost:"+(end-start));
|
||||
} catch (Exception e) {
|
||||
logger.error("postGroupReuseSources()",e);
|
||||
throw e;
|
||||
} finally {
|
||||
if (response != null) {
|
||||
@@ -525,7 +527,6 @@ public class ConfigServiceUtil {
|
||||
}
|
||||
return bean;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* getReport(配置日志总量统计查询)
|
||||
@@ -576,6 +577,7 @@ public class ConfigServiceUtil {
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+result);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("getReport()",e);
|
||||
throw e;
|
||||
} finally {
|
||||
if (response != null) {
|
||||
@@ -634,6 +636,7 @@ public class ConfigServiceUtil {
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+result);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("getReport()",e);
|
||||
throw e;
|
||||
} finally {
|
||||
if (response != null) {
|
||||
@@ -696,6 +699,7 @@ public class ConfigServiceUtil {
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+result);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("getReport()",e);
|
||||
throw e;
|
||||
} finally {
|
||||
if (response != null) {
|
||||
@@ -744,13 +748,24 @@ public class ConfigServiceUtil {
|
||||
result= response.readEntity(String.class);
|
||||
logger.info("cgi info:"+result);
|
||||
}else{
|
||||
if(response!= null) {
|
||||
throw new MaatConvertException("<spring:message code=\"cgi_service_failed\"/>:"+response.readEntity(String.class));
|
||||
}else {
|
||||
throw new MaatConvertException("<spring:message code=\"cgi_service_failed\"/>");
|
||||
Map<String, String> map = new HashMap<String, String>();
|
||||
result= response.readEntity(String.class);
|
||||
if(!StringUtil.isEmpty(result)){
|
||||
map = (Map<String, String>) JSON.parse(result);
|
||||
String error = map.get("error");
|
||||
if (!StringUtil.isEmpty(error)) {
|
||||
error=cgiError(error);
|
||||
throw new MaatConvertException(error);
|
||||
}else{
|
||||
throw new MaatConvertException(null);
|
||||
}
|
||||
}else{
|
||||
throw new MaatConvertException(null);
|
||||
}
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("getCGI()",e);
|
||||
throw e;
|
||||
} finally {
|
||||
if (response != null) {
|
||||
@@ -760,6 +775,28 @@ public class ConfigServiceUtil {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public static String cgiError(String error){
|
||||
String cgiError="";
|
||||
String er=error.toLowerCase().trim();
|
||||
String errors=Constants.CGI_ERROR;
|
||||
if(!StringUtil.isEmpty(errors)){
|
||||
String [] ers=errors.toLowerCase().split(",");
|
||||
for (int i = 0; i < ers.length; i++) {
|
||||
if(ers[i].trim().equals(er)){
|
||||
cgiError=error;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return cgiError;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 配置全量更新指令下发
|
||||
* @param params
|
||||
@@ -786,14 +823,15 @@ public class ConfigServiceUtil {
|
||||
} catch (Exception e) {
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
||||
}
|
||||
|
||||
bean = JSONObject.fromObject(result);
|
||||
if(response != null && response.getStatus() == 200){
|
||||
logger.info("get result success");
|
||||
bean = JSONObject.fromObject(result);
|
||||
}else{
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+result);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("configSyncCmd()",e);
|
||||
throw e;
|
||||
}finally {
|
||||
if (response != null) {
|
||||
@@ -830,11 +868,13 @@ public class ConfigServiceUtil {
|
||||
}
|
||||
if(response != null && response.getStatus() == 200){
|
||||
logger.info("get result success");
|
||||
//result="{\"status\": 201,\"businessCode\": 2001000,\"reason\":\"数据获取操作成功\",\"msg\": \"根据配置id获取对应的编译,组,域等信息成功\",\"fromuri\": \"/galaxy-service/service/cfg/v1/getAllKVByCompileId\",\"traceCode\": \"2019031211285044813363\",\"data\": [{\"service\":\"ntc\",\"status\":0,\"opTime\":\"2016-11-22 08:31:27\"}]}";
|
||||
bean= JSONObject.fromObject(result);
|
||||
}else{
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+result);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("configSyncStatus()",e);
|
||||
throw e;
|
||||
}finally {
|
||||
if (response != null) {
|
||||
@@ -881,6 +921,7 @@ public class ConfigServiceUtil {
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+result);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("configSync()",e);
|
||||
throw e;
|
||||
}finally {
|
||||
if (response != null) {
|
||||
@@ -921,6 +962,7 @@ public class ConfigServiceUtil {
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+result);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("configStatusUpdate()",e);
|
||||
throw e;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,9 +13,7 @@ public final class Constants {
|
||||
*/
|
||||
public static final int IMPORT_LIMIT=Configurations.getIntProperty("import_limit",10000);
|
||||
public static final Object IMPORT_LOCK=new Object();
|
||||
public static final String ADD_COMMON_REGION=Configurations.getStringProperty("addRegionToCommonGroup","");
|
||||
public static final String UPDATE_COMMON_REIGON=Configurations.getStringProperty("updateRegionToCommonGroup","");
|
||||
public static final String DELETE_COMMON_REIGON=Configurations.getStringProperty("deleteRegionToCommonGroup","");
|
||||
public static final String GROUP_REUSE_SOURCES=Configurations.getStringProperty("groupReuseSources","groupReuseSources");
|
||||
public static Integer APP_SPEC_SERVICE_CODE_MIN_VAL=Configurations.getIntProperty("app_spec_service_code_min_val", 300001);
|
||||
public static Integer APP_SPEC_SERVICE_CODE_MAX_VAL=Configurations.getIntProperty("app_spec_service_code_max_val", 268435455);
|
||||
public static String APP_CFG_USERREGION_SPLITOR=Configurations.getStringProperty("app_cfg_userregion_splitor", "&");
|
||||
@@ -23,7 +21,7 @@ public final class Constants {
|
||||
* MaatConfig 默认值
|
||||
*/
|
||||
public static Integer MAAT_CFG_DOLOG_DEFAULT=Configurations.getIntProperty("maat_cfg_dolog_default", 2);
|
||||
public static Integer MAAT_CFG_DOLOG_DOBLACKLIST_DEFAULT=Configurations.getIntProperty("maat_cfg_dolog_doblacklist_default", 1);
|
||||
public static Integer MAAT_CFG_DOLOG_DOBLACKLIST_DEFAULT=Configurations.getIntProperty("maat_cfg_dolog_doblacklist_default", 0);
|
||||
public static Integer MAAT_CFG_DOLOG_CONFIGPERCENT_DEFAULT=Configurations.getIntProperty("maat_cfg_dolog_configpercent_default", 100);
|
||||
public static Integer MAAT_CFG_DOLOG_CONFIGOPTION_DEFAULT=Configurations.getIntProperty("maat_cfg_dolog_configoption_default", 1);
|
||||
/**
|
||||
@@ -324,56 +322,18 @@ public final class Constants {
|
||||
// public static final boolean IS_USE_HIVE_DB =
|
||||
// Configurations.getBooleanProperty("isUseHiveDb", true);
|
||||
|
||||
/**
|
||||
* 是否获取数据中心查询记录的总条数
|
||||
*/
|
||||
|
||||
public static final boolean IS_GET_HIVECOUNT = Configurations.getBooleanProperty("isGetHiveCount", true);
|
||||
/**
|
||||
* 是否获取数据中心[神通]查询记录的总条数
|
||||
*/
|
||||
|
||||
public static final boolean IS_SELECT_CLUSTER = Configurations.getBooleanProperty("isSelectCluster", false);
|
||||
|
||||
/**
|
||||
* 神通数据库A的数据最早时间
|
||||
*/
|
||||
public static final Long CLUSTER_A_START_TIME = Configurations.getLongProperty("clusterAStartTime", new Date().getTime());
|
||||
|
||||
/**
|
||||
* 神通数据库B的数据最早时间
|
||||
*/
|
||||
public static final Long CLUSTER_B_START_TIME = Configurations.getLongProperty("clusterBStartTime", new Date().getTime());
|
||||
|
||||
/**
|
||||
* 每次获取数据中心多少条数据,咱们在对获取的数据进行分页处理
|
||||
*/
|
||||
public static final Long EVERY_GETHIVEDATANUM = Configurations.getLongProperty("everyGetHiveDataNum", 10000);
|
||||
|
||||
/**
|
||||
* 是否开启基础校验
|
||||
*/
|
||||
public static final boolean BASE_VALIDATE = Configurations.getBooleanProperty("baseValidate", true);
|
||||
|
||||
public static final Long DATACENTER_TIME = Configurations.getLongProperty("dataCenterTime", 48);
|
||||
|
||||
/**
|
||||
* 是否开启业务校验
|
||||
*/
|
||||
public static final boolean SERVICE_VALIDATE = Configurations.getBooleanProperty("serviceValidate", true);
|
||||
/**
|
||||
* 日志本地存储时间
|
||||
*/
|
||||
public static final Long LOG_LOCAL_TIME = Configurations.getLongProperty("logLocalTime", 48);
|
||||
/**
|
||||
* 实时统计默认时间
|
||||
*/
|
||||
public static final Long REPORT_LOCAL_TIME = Configurations.getLongProperty("reportLocalTime", 1);
|
||||
|
||||
/**
|
||||
* 日志是否从hive中查询
|
||||
*/
|
||||
public static final boolean SEL_FROM_HIVE = Configurations.getBooleanProperty("selFromHive", true);
|
||||
public static final boolean ONLY_SEL_FROM_HIVE = Configurations.getBooleanProperty("onlySelFromHive", true);
|
||||
|
||||
/**
|
||||
@@ -387,12 +347,6 @@ public final class Constants {
|
||||
*/
|
||||
public static final String SEARCH_DATEFORMAT = Configurations.getStringProperty("search.dateformat",
|
||||
"yyyy-MM-dd HH:mm:ss");
|
||||
public static final String SEARCH_ES_HOSTANDPORT_A = Configurations.getStringProperty("search.eshostandport_A",
|
||||
null);
|
||||
public static final String SEARCH_ES_HOSTANDPORT_B = Configurations.getStringProperty("search.eshostandport_B",
|
||||
null);
|
||||
public static final String SEARCH_ES_HOSTANDPORT_C = Configurations.getStringProperty("search.eshostandport_C",
|
||||
null);
|
||||
/**
|
||||
* 数据中心A版数据库名称,程序中每次查询时使用的数据库名称 use HIVEADBNAME
|
||||
*/
|
||||
@@ -409,6 +363,7 @@ public final class Constants {
|
||||
public static final String FILE_UPLOAD_CFG = Configurations.getStringProperty("fileUploadCfg","fileUploadSources");
|
||||
public static final String FILE_DIGEST_CFG=Configurations.getStringProperty("fileDigestCfg","fileDigestSources");
|
||||
public static final String CONFIG_ID_SOURCES=Configurations.getStringProperty("configIdSources","configPzIdSources");
|
||||
public static final String DEL_ALL_CFG=Configurations.getStringProperty("delAllCfg","delAllConfig");
|
||||
//日志查询接口URL
|
||||
public static final String LOG_BASE_URL = Configurations.getStringProperty("logBaseUrl","");
|
||||
public static final String NTC_SERVICE_REPORT=Configurations.getStringProperty("ntcServiceReport","ntcServiceReport");
|
||||
@@ -496,8 +451,6 @@ public final class Constants {
|
||||
public static final String HTTP_URL_REGION = Configurations.getStringProperty("http_url_region","http_url");
|
||||
public static final String VOIP_IP_REGION = Configurations.getStringProperty("voip_ip","av_voip_ip");
|
||||
public static final String VOIP_ACCOUNT_REGION = Configurations.getStringProperty("voip_account","av_voip_account");
|
||||
public static final String NTC_ASN_NUMBER = Configurations.getStringProperty("ntc_asn_number","NTC_ASN_NUMBER");
|
||||
public static final String ASN_KEY = Configurations.getStringProperty("asn_key","AS");
|
||||
public static final String MAAT_VERSION = Configurations.getStringProperty("maat_version","1.0");
|
||||
public static final Integer INSERT_ACTION = Configurations.getIntProperty("insert_action",1);
|
||||
public static final Integer UPDATE_ACTION = Configurations.getIntProperty("update_action",2);
|
||||
@@ -723,6 +676,9 @@ public final class Constants {
|
||||
public static final String TREND_TOTAL_REPORT=Configurations.getStringProperty("trendTotalReport","trendTotalReport");
|
||||
public static final String TRAFFIC_APP_TREND=Configurations.getStringProperty("trafficAppTrend","trafficAppTrend");
|
||||
public static final String APPCONN_RECORD_TOP100=Configurations.getStringProperty("appConnRecordTop100","appConnRecordTop100");
|
||||
public static final String TRAFFIC_APP_PPS_TREND=Configurations.getStringProperty("trafficAppPpsTrend","trafficAppPpsTrend");
|
||||
public static final String TRAFFIC_APP_BPS_TREND=Configurations.getStringProperty("trafficAppBpsTrend","trafficAppBpsTrend");
|
||||
|
||||
/**
|
||||
* httpclient 工具超时时间设置
|
||||
*/
|
||||
@@ -818,4 +774,25 @@ public final class Constants {
|
||||
* 流量日志的HTTP泛收接口URL
|
||||
*/
|
||||
public static final String NTC_HTTP_RECORD_LOG = Configurations.getStringProperty("ntcHttpRecordLog","");
|
||||
/**
|
||||
* 日期格式化
|
||||
*/
|
||||
public static final String COMMON_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
|
||||
/**
|
||||
* 时间格式化
|
||||
*/
|
||||
public static final String COMMON_TIME_FORMAT = "HH:mm:ss";
|
||||
/**
|
||||
* vpn cgi接口报错信息
|
||||
*/
|
||||
public static final String CGI_ERROR = Configurations.getStringProperty("cgiError","");
|
||||
|
||||
/**
|
||||
* 配置保护名单字典key
|
||||
*/
|
||||
public static final String CACHE_PROTECTION_LIST_DICT = "protetionListDict";
|
||||
/**
|
||||
* 管理员用户预警查询服务配置总量接口
|
||||
*/
|
||||
public static final String CONFIG_BY_SERVICE = Configurations.getStringProperty("getConfigByService","");
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package com.nis.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.dom4j.Node;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
@@ -96,6 +98,18 @@ public class DictUtils {
|
||||
}
|
||||
return itemList;
|
||||
}
|
||||
public static Map<String,String> getDictMap(String key){
|
||||
Map dictMap=new HashMap<String,String>();
|
||||
List<SysDataDictionaryItem> itemList = getDictData().get(key);
|
||||
if (StringUtil.isEmpty(itemList)) {
|
||||
return dictMap;
|
||||
}else {
|
||||
for(SysDataDictionaryItem item:itemList) {
|
||||
dictMap.put(item.getItemCode(), item.getItemValue());
|
||||
}
|
||||
}
|
||||
return dictMap;
|
||||
}
|
||||
|
||||
public static String getDictLabels(String dictKey, String itemCodes, String defaultValue){
|
||||
|
||||
@@ -246,6 +260,24 @@ public class DictUtils {
|
||||
|
||||
return allDictList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 功能业务字典,获取相应功能菜单对应的业务信息
|
||||
* @param functionId
|
||||
* @return
|
||||
*/
|
||||
public static List<FunctionServiceDict> getAllServiceList(){
|
||||
List<FunctionServiceDict> serviceList = new ArrayList();
|
||||
ServiceConfigTemplateUtil serviceTemplate = new ServiceConfigTemplateUtil();
|
||||
List<Node> serviceNodeList= serviceTemplate.getServiceNodeList();
|
||||
for (Node node : serviceNodeList) {
|
||||
FunctionServiceDict service=new FunctionServiceDict();
|
||||
service.setServiceId(Integer.valueOf(node.valueOf("@id")));
|
||||
service.setServiceName(node.valueOf("@desc"));
|
||||
serviceList.add(service);
|
||||
}
|
||||
return serviceList;
|
||||
}
|
||||
/**
|
||||
* 功能配置域字典,获取相应功能菜单对应的配置域信息
|
||||
* @param functionId
|
||||
|
||||
759
src/main/java/com/nis/util/IPUtil.java
Normal file
759
src/main/java/com/nis/util/IPUtil.java
Normal file
@@ -0,0 +1,759 @@
|
||||
package com.nis.util;
|
||||
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.nis.domain.Nets;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.StringWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
*
|
||||
* <p>对IPV4进行处理工具类.</p>
|
||||
* @author 中电积至有限公司 darnell
|
||||
* @version 1.0 创建时间:2018-08-30
|
||||
*
|
||||
*/
|
||||
public class IPUtil {
|
||||
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(IPUtil.class);
|
||||
private static byte pos []= new byte []{(byte)128,64,32,16,8,4,2,1};
|
||||
private static final Pattern IPV4Pattern = Pattern.
|
||||
compile("\\b((?!\\d\\d\\d)\\d+|1\\d\\d|2[0-4]\\d|25[0-5])\\.((?!\\d\\d\\d)\\d+|1\\d\\d|2[0-4]\\d|25[0-5])\\.((?!\\d\\d\\d)\\d+|1\\d\\d|2[0-4]\\d|25[0-5])\\.((?!\\d\\d\\d)\\d+|1\\d\\d|2[0-4]\\d|25[0-5])\\b");
|
||||
private static final Pattern IPV6_STD_PATTERN =
|
||||
Pattern.compile(
|
||||
"^(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$");
|
||||
|
||||
private static final Pattern IPV6_HEX_COMPRESSED_PATTERN =
|
||||
Pattern.compile(
|
||||
"^((?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?)::((?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?)$");
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* <p>将10进制IP转为字符串,网络序。IP((0-255).(0-255).(0-255).(0-255))格式.
|
||||
* ip10为字符串形式能给处理带来方便.
|
||||
* </p>
|
||||
* <pre>
|
||||
* IpUtil.getIpString("3232235777") = "192.168.1.1"
|
||||
* </pre>
|
||||
* @see #getIpDesimal(String)
|
||||
* @param ip10 10进制IP
|
||||
* @return 返回如<code>0.0.0.0</code>格式IP
|
||||
*/
|
||||
public static String getIpString(String ip10) {
|
||||
StringBuffer sb = new StringBuffer("");
|
||||
if (ip10.indexOf("-") > -1) {
|
||||
|
||||
Integer intIP = Integer.parseInt(setStrEmpty(ip10));
|
||||
|
||||
sb.append(String.valueOf(intIP&0x000000FF));
|
||||
sb.append(".");
|
||||
sb.append(String.valueOf((intIP&0x0000FFFF)>>>8));
|
||||
sb.append(".");//将高8位置0,然后右移16位
|
||||
sb.append(String.valueOf((intIP&0x00FFFFFF)>>>16));
|
||||
sb.append(".");
|
||||
sb.append(String.valueOf(intIP>>>24&0xFF));//直接右移24位
|
||||
return sb.toString();
|
||||
} else {
|
||||
|
||||
Long longIP = Long.parseLong(setStrEmpty(ip10));
|
||||
sb.append(String.valueOf(longIP&0x000000FF));
|
||||
sb.append(".");
|
||||
sb.append(String.valueOf((longIP&0x0000FFFF)>>>8));
|
||||
sb.append(".");//将高8位置0,然后右移16位
|
||||
sb.append(String.valueOf((longIP&0x00FFFFFF)>>>16));
|
||||
sb.append(".");
|
||||
sb.append(String.valueOf(longIP>>>24&0xFF));//直接右移24位
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* <p>将10进制IP转为字符串,主机序。IP((0-255).(0-255).(0-255).(0-255))格式.
|
||||
* ip10为字符串形式能给处理带来方便.
|
||||
* </p>
|
||||
* <pre>
|
||||
* IpUtil.getIpHostString("3232235777") = "192.168.1.1"
|
||||
* </pre>
|
||||
* @see #getIpDesimal(String)
|
||||
* @param ip10 10进制IP
|
||||
* @return 返回如<code>0.0.0.0</code>格式IP
|
||||
*/
|
||||
//将10进制整数形式转换成127.0.0.1形式的IP地址,按网络序
|
||||
public static String getIpHostString(String ip10) {
|
||||
StringBuffer sb = new StringBuffer(32);
|
||||
if (ip10.indexOf("-") > -1) {
|
||||
|
||||
Integer intIP = Integer.parseInt(setStrEmpty(ip10));
|
||||
|
||||
sb.append(String.valueOf(intIP >>> 24));// 直接右移24位
|
||||
sb.append(".");
|
||||
sb.append(String.valueOf((intIP & 0x00FFFFFF) >>> 16)); // 将高8位置0,然后右移16位
|
||||
sb.append(".");
|
||||
sb.append(String.valueOf((intIP & 0x0000FFFF) >>> 8));
|
||||
sb.append(".");
|
||||
sb.append(String.valueOf(intIP & 0x000000FF));
|
||||
return sb.toString();
|
||||
} else {
|
||||
Long longIP = Long.parseLong(setStrEmpty(ip10));
|
||||
|
||||
sb.append(String.valueOf(longIP >>> 24));// 直接右移24位
|
||||
sb.append(".");
|
||||
sb.append(String.valueOf((longIP & 0x00FFFFFF) >>> 16)); // 将高8位置0,然后右移16位
|
||||
sb.append(".");
|
||||
sb.append(String.valueOf((longIP & 0x0000FFFF) >>> 8));
|
||||
sb.append(".");
|
||||
sb.append(String.valueOf(longIP & 0x000000FF));
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 判断一个IP地址是否属于某一个子网
|
||||
*
|
||||
* @param ip IP地址
|
||||
* @param prefix 子网地址
|
||||
* @param prefixLen 掩码长度
|
||||
* @return true or false
|
||||
*/
|
||||
public static boolean inPrefix(String ip, String prefix, int prefixLen) {
|
||||
String binPrefix = toBinaryString(prefix);
|
||||
if (binPrefix.length() > prefixLen) {
|
||||
binPrefix = binPrefix.substring(0,prefixLen);
|
||||
}
|
||||
|
||||
String binIP = toBinaryString(ip);
|
||||
binIP = binIP.substring(0,prefixLen);
|
||||
if (binIP.equals(binPrefix)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获得两个IP间的范围,如192.168.0.128-192.168.2.256。
|
||||
* 注意:本方法不做合法性检查!
|
||||
*
|
||||
* @param startIp 起始IP
|
||||
* @param endIp 中止IP
|
||||
* @return 范围内的IP地址数组
|
||||
*/
|
||||
public static List<String> getIPRange(String startIp, String endIp) {
|
||||
|
||||
List<String> list = new ArrayList<String>();
|
||||
|
||||
try{
|
||||
|
||||
long start = getIpHostDesimal(startIp);
|
||||
long end = getIpHostDesimal(endIp);
|
||||
|
||||
for (long i = start; i <= end; i++) {
|
||||
list.add(getIpHostString(String.valueOf(i)));
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 验证IP为保留三个IP区域私有地址
|
||||
* @param ip IPV4
|
||||
* @return boolean true 私有地址 false 公有地址
|
||||
*/
|
||||
public static boolean internalIp(String ip) {
|
||||
byte[] addr = getAddress(ip);
|
||||
return internalIp(addr);
|
||||
}
|
||||
|
||||
private static boolean internalIp(byte[] addr) {
|
||||
final byte b0 = addr[0];
|
||||
final byte b1 = addr[1];
|
||||
//10.x.x.x/8
|
||||
final byte SECTION_1 = 0x0A;
|
||||
//172.16.x.x/12
|
||||
final byte SECTION_2 = (byte) 0xAC;
|
||||
final byte SECTION_3 = (byte) 0x10;
|
||||
final byte SECTION_4 = (byte) 0x1F;
|
||||
//192.168.x.x/16
|
||||
final byte SECTION_5 = (byte) 0xC0;
|
||||
final byte SECTION_6 = (byte) 0xA8;
|
||||
switch (b0) {
|
||||
case SECTION_1:
|
||||
return true;
|
||||
case SECTION_2:
|
||||
if (b1 >= SECTION_3 && b1 <= SECTION_4) {
|
||||
return true;
|
||||
}
|
||||
case SECTION_5:
|
||||
switch (b1) {
|
||||
case SECTION_6:
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得子网的所有IP地址;如:192.168.0.1/24。
|
||||
* 注意:本方法不做合法性检查!
|
||||
* @param prefix 子网所属IP地址
|
||||
* @param prefixLen 子网掩码
|
||||
* @return List<String>
|
||||
*/
|
||||
public static List<String> getIPRange(String prefix, int prefixLen) {
|
||||
String binPrefix = toBinaryString(prefix);
|
||||
if (binPrefix.length() > prefixLen) {
|
||||
binPrefix = binPrefix.substring(0,prefixLen);
|
||||
}
|
||||
StringBuffer ip1 = new StringBuffer(binPrefix);
|
||||
StringBuffer ip2 = new StringBuffer(binPrefix);
|
||||
for (int i = ip1.length(); i < 32; i++) {
|
||||
ip1.append('0');
|
||||
}
|
||||
for (int i = ip2.length(); i < 32; i++) {
|
||||
ip2.append('1');
|
||||
}
|
||||
|
||||
return getIPRange(toIPString(ip1.toString()),toIPString(ip2.toString()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* <p>根据标准ip段获取,该段子网掩码
|
||||
* </p>
|
||||
* @param startIP 起始ip,endIP 结束ip
|
||||
* @return 返回如<code>子网掩码</code>格式IP
|
||||
*/
|
||||
public static String getMask(String startIP,String endIP) {
|
||||
byte start [] = getAddress(startIP);
|
||||
byte end [] = getAddress(endIP);
|
||||
byte mask [] = new byte [start.length];
|
||||
boolean flag=false;
|
||||
for(int i=0; i<start.length; i++){
|
||||
|
||||
mask[i]=(byte)~(start[i]^end[i]);
|
||||
|
||||
if (flag) {
|
||||
mask[i]=0;
|
||||
}
|
||||
if(mask[i]!=-1){
|
||||
mask[i]=getMask(mask[i]);
|
||||
flag=true;
|
||||
}
|
||||
}
|
||||
return toString(mask);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static byte getMask(byte b) {
|
||||
if (b==0) {
|
||||
return b;
|
||||
}
|
||||
byte p = pos[0];
|
||||
for(int i=0;i<8;i++){
|
||||
if ((b&pos[i])==0) {
|
||||
break;
|
||||
}
|
||||
p=(byte)(p>>1);
|
||||
}
|
||||
p=(byte)(p<<1);
|
||||
return (byte)(b&p);
|
||||
}
|
||||
|
||||
|
||||
private static byte[] getAddress(String address) {
|
||||
String subStr [] = address.split("\\.");
|
||||
if(subStr.length!=4) {
|
||||
throw new IllegalArgumentException("所传入的IP地址不符合IPv4的规范");
|
||||
}
|
||||
byte b [] = new byte [4];
|
||||
for (int i=0;i<b.length;i++) {
|
||||
b [i]=(byte)Integer.parseInt(subStr[i]);
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 将IPv4形式掩码形式转为,整型掩码位数
|
||||
* @param netmarks
|
||||
* @return
|
||||
*/
|
||||
public static int getNetMask(String netmarks)
|
||||
{
|
||||
if(!isMask(netmarks)){
|
||||
throw(new RuntimeException("掩码格式错误!"));
|
||||
}
|
||||
StringBuffer sbf;
|
||||
String str;
|
||||
int inetmask=0,count=0;
|
||||
String[] ipList=netmarks.split("\\.");
|
||||
for(int n=0;n<ipList.length;n++)
|
||||
{
|
||||
sbf = toBin(Integer.parseInt(ipList[n]));
|
||||
str=sbf.reverse().toString();
|
||||
count=0;
|
||||
for(int i=0;i<str.length();i++){
|
||||
i=str.indexOf('1',i);
|
||||
if(i==-1){break;}
|
||||
count++;
|
||||
}
|
||||
inetmask+=count;
|
||||
}
|
||||
return inetmask;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算子网大小
|
||||
* @param netmask
|
||||
* @return
|
||||
*/
|
||||
public static int getPoolMax(int netmask)
|
||||
{
|
||||
if(netmask<=0||netmask>=32)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
int bits=32-netmask;
|
||||
return (int) Math.pow(2,bits) -2;
|
||||
}
|
||||
|
||||
private static StringBuffer toBin(int x)
|
||||
{
|
||||
StringBuffer result=new StringBuffer();
|
||||
result.append(x%2);
|
||||
x/=2;
|
||||
while(x>0){
|
||||
result.append(x%2);
|
||||
x/=2;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 根据起始IP地址和子网掩码计算终止IP
|
||||
* @return String 子网的结束IP
|
||||
*/
|
||||
public static String getEndIP(String StartIP,int netmask)
|
||||
{
|
||||
return getEndIP(StartIP,convertMask(netmask));
|
||||
}
|
||||
/**
|
||||
* 根据起始IP地址和子网掩码计算终止IP
|
||||
* @return String 子网的结束IP
|
||||
*/
|
||||
public static String getEndIP(String StartIP, String netmask)
|
||||
{
|
||||
Nets nets = new Nets();
|
||||
String[] start=Negation(StartIP,netmask).split("\\.");
|
||||
nets.setStartIP(start[0]+"."+start[1]+"."+start[2]+"."+(Integer.valueOf(start[3])+1));
|
||||
nets.setEndIP(TaskOR(Negation(StartIP,netmask),netmask));
|
||||
nets.setNetMask(netmask);
|
||||
return nets.getEndIP();
|
||||
}
|
||||
|
||||
/**
|
||||
* temp1根据temp2取反
|
||||
*/
|
||||
private static String Negation(String StartIP,String netmask)
|
||||
{
|
||||
String[] temp1=StartIP.trim().split("\\.");
|
||||
String[] temp2=netmask.trim().split("\\.");
|
||||
int[] rets=new int[4];
|
||||
for (int i =0;i<4;i++) {
|
||||
rets[i]=Integer.parseInt(temp1[i])&Integer.parseInt(temp2[i]);
|
||||
}
|
||||
return rets[0]+"."+rets[1]+"."+rets[2]+"."+rets[3];
|
||||
}
|
||||
/**
|
||||
* temp1根据temp2取或
|
||||
*/
|
||||
private static String TaskOR(String StartIP,String netmask)
|
||||
{
|
||||
String[] temp1=StartIP.trim().split("\\.");
|
||||
String[] temp2=netmask.trim().split("\\.");
|
||||
int[] rets=new int[4];
|
||||
for (int i =0;i<4;i++) {
|
||||
rets[i]=255-(Integer.parseInt(temp1[i])^Integer.parseInt(temp2[i]));
|
||||
}
|
||||
//return rets[0]+"."+rets[1]+"."+rets[2]+"."+(rets[3]-1);
|
||||
return rets[0]+"."+rets[1]+"."+rets[2]+"."+(rets[3]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* <p>将整型的掩码转换成IPv4型(30 -> 255.255.255.252).</p>
|
||||
*
|
||||
* @param mask 整型掩码.
|
||||
* @return IPv4型掩码.
|
||||
* @exception RuntimeException 掩码错误.
|
||||
*/
|
||||
public static String convertMask(int mask) {
|
||||
if (mask > 32 || mask < 8) {
|
||||
throw(new RuntimeException("掩码错误!应为8-32的整数。"));
|
||||
}
|
||||
return toIPString(maskToBinaryString(mask));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>将整型的掩码转换成反向IPv4型(30 -> 255.255.255.252).</p>
|
||||
*
|
||||
* @param mask 整型掩码.
|
||||
* @return IPv4型反向掩码.
|
||||
* @exception Exception 掩码错误.
|
||||
*/
|
||||
public static String convertReverseMask(int mask) throws Exception {
|
||||
if (mask > 32 || mask < 8) {
|
||||
throw(new Exception("掩码错误!应为8-32的整数。"));
|
||||
}
|
||||
return toIPString(reverseMaskToBinaryString(mask));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 将整型掩码转换成二进制字符串
|
||||
* @param mask 整型掩码
|
||||
* @return 二进制型掩码.
|
||||
*/
|
||||
private static String maskToBinaryString(int mask) {
|
||||
StringBuffer str = new StringBuffer();
|
||||
|
||||
for(int i=1;i<=32;i++) {
|
||||
if (i <= mask) {
|
||||
str.append('1');
|
||||
} else {
|
||||
str.append('0');
|
||||
}
|
||||
}
|
||||
return str.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 将整型掩码转换成二进制字符串
|
||||
* @param mask 整型掩码
|
||||
* @return 反向二进制型掩码.
|
||||
*/
|
||||
private static String reverseMaskToBinaryString(int mask) {
|
||||
StringBuffer str = new StringBuffer();
|
||||
|
||||
for(int i=1;i<=32;i++) {
|
||||
if (i <= mask) {
|
||||
str.append('0');
|
||||
} else {
|
||||
str.append('1');
|
||||
}
|
||||
}
|
||||
return str.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 将二进制字符串转换成IPv4型字符串
|
||||
* @param binary 二进制字符串
|
||||
* @return IPv4型IP.
|
||||
*/
|
||||
private static String toIPString(String binary) {
|
||||
if (binary.length() < 32) {
|
||||
for (int i=binary.length();i<32;i++) {
|
||||
binary = "0" + binary;
|
||||
}
|
||||
}
|
||||
|
||||
String part1 = binary.substring(0,8);
|
||||
String part2 = binary.substring(8,16);
|
||||
String part3 = binary.substring(16,24);
|
||||
String part4 = binary.substring(24);
|
||||
return Integer.parseInt(part1,2) + "."
|
||||
+ Integer.parseInt(part2,2) + "."
|
||||
+ Integer.parseInt(part3,2) + "."
|
||||
+ Integer.parseInt(part4,2);
|
||||
}
|
||||
/**
|
||||
* 获取子网的网络地址.
|
||||
*
|
||||
* @param ip IP地址.
|
||||
* @param mask 掩码.
|
||||
* @return 网络地址.
|
||||
* @exception Exception IP地址错误或掩码错误.
|
||||
*/
|
||||
public static String getSubNetIP(String ip, int mask) throws Exception {
|
||||
if (!isIP(ip)) {
|
||||
throw(new Exception("IP地址不合法!"));
|
||||
}
|
||||
String s1 = toBinaryString(ip);
|
||||
String s2 = maskToBinaryString(mask);
|
||||
return toIPString(Long.toBinaryString(Long.parseLong(s1,2)&Long.parseLong(s2,2)));
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>将整型掩码转换成IPv4型的反码(30 -> 0.0.0.3).</p>
|
||||
*
|
||||
* @param mask 整型掩码.
|
||||
* @return IPv4型反码.
|
||||
* @exception Exception 掩码错误.
|
||||
*/
|
||||
public static String reverseMask(int mask) throws Exception {
|
||||
if (mask > 32 || mask < 8) {
|
||||
throw(new Exception("掩码错误!应为8-32的整数。"));
|
||||
}
|
||||
String str = maskToBinaryString(mask);
|
||||
str = str.replace('0','2');
|
||||
str = str.replace('1','0');
|
||||
str = str.replace('2','1');
|
||||
return toIPString(str);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将IPv4型字符串转换成长度为32的二进制字符串
|
||||
* 需要加验证是否为IP
|
||||
*/
|
||||
public static String toBinaryString(String ip) {
|
||||
String[] array = ip.split("[.]");
|
||||
String str = "";
|
||||
for (int i=0; i<array.length; i++) {
|
||||
String s = Integer.toBinaryString(Integer.parseInt(array[i]));
|
||||
if (s.length() < 8) {
|
||||
for (int j=s.length();j<8;j++) {
|
||||
s = "0" + s;
|
||||
}
|
||||
}
|
||||
str += s;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* <p>验证Ip是否符合规则.给定字符串,判断是否符合正则验证的ip格式.</p>
|
||||
* <pre>例子说明:</pre>
|
||||
* @param ip ip字符
|
||||
* @return <code>true</code> ip符合验证规则, <code>false</code> ip不符合验证规则.
|
||||
*/
|
||||
public static boolean isIP(String ip) {
|
||||
if (ip == null) {
|
||||
return false;
|
||||
}
|
||||
Matcher mat = IPV4Pattern.matcher(ip);
|
||||
return mat.matches();
|
||||
}
|
||||
|
||||
|
||||
public static boolean isIPv6StdAddress(final String input) {
|
||||
return IPV6_STD_PATTERN.matcher(input).matches();
|
||||
}
|
||||
|
||||
public static boolean isIPv6HexCompressedAddress(final String input) {
|
||||
return IPV6_HEX_COMPRESSED_PATTERN.matcher(input).matches();
|
||||
}
|
||||
|
||||
public static boolean isIPv6Address(final String input) {
|
||||
return isIPv6StdAddress(input) || isIPv6HexCompressedAddress(input);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* <p>在web方式下获取客户端IP地址.</p>
|
||||
* <p>
|
||||
* 使用该方法,需要在有javaee.jar扩展包前提下.
|
||||
* </p>
|
||||
* @param request HttpServletRequest请求对象
|
||||
* @return 返回字符串IP地址
|
||||
*/
|
||||
public static String getIpAddr(HttpServletRequest request) {
|
||||
String ip = request.getHeader("X-Forwarded-For");
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("Proxy-Client-IP");
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("WL-Proxy-Client-IP");
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("HTTP_CLIENT_IP");
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("HTTP_X_FORWARDED_FOR");
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getRemoteAddr();
|
||||
}
|
||||
return ip;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* <p>验证mask是否符合规则.给定字符串,判断是否符合正则验证的mask格式.</p>
|
||||
* <pre>例子说明:</pre>
|
||||
* @param mask mask字符
|
||||
* @return <code>true</code> mask符合验证规则, <code>false</code> mask不符合验证规则.
|
||||
*/
|
||||
public static boolean isMask(String mask) {
|
||||
if (mask == null) {
|
||||
return false;
|
||||
}
|
||||
if(!isIP(mask)){
|
||||
return false;
|
||||
}
|
||||
String[] ips = mask.split("\\.");
|
||||
String binaryVal = "";
|
||||
for (int i = 0; i < ips.length; i++)
|
||||
{
|
||||
String binaryStr = Integer.toBinaryString(Integer.parseInt(ips[i]));
|
||||
Integer times = 8 - binaryStr.length();
|
||||
|
||||
for(int j = 0; j < times; j++)
|
||||
{
|
||||
binaryStr = "0" + binaryStr;
|
||||
}
|
||||
binaryVal += binaryStr;
|
||||
}
|
||||
if(binaryVal.indexOf("01")!=-1){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* <p>将IP进制转换成十进制网络字节序</p>
|
||||
* <p>
|
||||
* IP是一个字符串,符合IP的规则(0-255).(0-255).(0-255).(0-255).
|
||||
* 将ip转换成长整型的原因是:处理时间类型简单;入库节省空间,查询提高效率.
|
||||
* </p>
|
||||
* <pre>
|
||||
* IpUtil.getIpDesimal("192.168.1.1") = 3232235777
|
||||
* IpUtil.getIpDesimal("192.168.1.256") = -1 //不符合Ip规则
|
||||
* </pre>
|
||||
* @see #getIpString(String)
|
||||
* @param ip 符合IP规则的字符串
|
||||
* @return <code>-1</code> 验证ip不合法,<code>ip</code> 计算ip返回长整型.
|
||||
*/
|
||||
public static long getIpDesimal(String ip) {
|
||||
long ip10 = 0;
|
||||
if (!isIP(ip)) {
|
||||
return -1; // ip 不合法
|
||||
}
|
||||
String[] ss = ip.trim().split("\\.");
|
||||
for (int i = 0; i < 4; i++) {
|
||||
ip10 += Math.pow(256, i) * Long.parseLong(ss[i]);
|
||||
}
|
||||
|
||||
return ip10;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* <p>将IP进制转换成十进制主机字节序</p>
|
||||
* <p>
|
||||
* IP是一个字符串,符合IP的规则(0-255).(0-255).(0-255).(0-255).
|
||||
* 将ip转换成长整型的原因是:处理时间类型简单;入库节省空间,查询提高效率.
|
||||
* </p>
|
||||
* <pre>
|
||||
* IpUtil.getIpHostDesimal("192.168.1.1") = 3232235777
|
||||
* IpUtil.getIpHostDesimal("192.168.1.256") = -1 //不符合Ip规则
|
||||
* </pre>
|
||||
* @see #getIpString(String)
|
||||
* @param ip 符合IP规则的字符串
|
||||
* @return <code>-1</code> 验证ip不合法,<code>ip</code> 计算ip返回长整型.
|
||||
*/
|
||||
|
||||
public static long getIpHostDesimal(String ip) {
|
||||
long ip10 = 0;
|
||||
if (!isIP(ip)) {
|
||||
return -1; // ip 不合法
|
||||
}
|
||||
String[] ss = ip.trim().split("\\.");
|
||||
for (int i = 0; i < 4; i++) {
|
||||
ip10 += Math.pow(256, 3 - i) * Long.parseLong(ss[i]);
|
||||
}
|
||||
|
||||
return ip10;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* <p>获取IP/mask 包含IP数量,适合完整IPw网段</p>
|
||||
* <p>
|
||||
*
|
||||
*
|
||||
* </p>
|
||||
* <pre>
|
||||
*
|
||||
*
|
||||
* </pre>
|
||||
* @param ip 符合IP规则的字符串
|
||||
* @param mask 掩码格式
|
||||
* @return <code>-1</code> 验证ip不合法,<code>ip</code> 计算ip返回长整型.
|
||||
*/
|
||||
public static long getIpNum(String ip, int mask) {
|
||||
long num = 0;
|
||||
|
||||
if (isIP(ip)) {
|
||||
String endIp = getEndIP(ip, mask);
|
||||
num = getIpHostDesimal(endIp) - getIpHostDesimal(ip) +1;
|
||||
|
||||
} else {
|
||||
throw new IllegalArgumentException("所传入的IP地址不符合IPV4规范");
|
||||
}
|
||||
|
||||
return num;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// 此方法用于判断数据为空就置为0
|
||||
private static String setStrEmpty(String str) {
|
||||
if ("".equals(str) || str == null) {
|
||||
str = "0";
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
private static String toString(byte[] address) {
|
||||
StringWriter sw = new StringWriter(16);
|
||||
sw.write(Integer.toString(address[0]&0xFF));
|
||||
for(int i=1;i<address.length;i++){
|
||||
sw.write(".");
|
||||
sw.write(Integer.toString(address[i]&0xFF));
|
||||
}
|
||||
return sw.toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,46 +1,66 @@
|
||||
package com.nis.util;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.collections.map.CaseInsensitiveMap;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dom4j.Attribute;
|
||||
import org.dom4j.Element;
|
||||
import org.dom4j.Node;
|
||||
import org.dom4j.io.SAXReader;
|
||||
|
||||
import com.beust.jcommander.internal.Sets;
|
||||
import com.nis.domain.FunctionServiceDict;
|
||||
|
||||
import jersey.repackaged.com.google.common.collect.Lists;
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public class ServiceConfigTemplateUtil {
|
||||
|
||||
private Logger logger = Logger.getLogger(getClass());
|
||||
private static final Logger logger = Logger.getLogger(ServiceConfigTemplateUtil.class);
|
||||
|
||||
private static Node root;
|
||||
|
||||
static {
|
||||
if(root == null) {//2018年12月28日11:37:50 fang 改为只加载一次,且方法改为 static
|
||||
SAXReader reader = new SAXReader();
|
||||
org.dom4j.Document document = null;
|
||||
String configPath = "/service/service_config.xml";
|
||||
InputStream is = null;
|
||||
try {
|
||||
is = ServiceConfigTemplateUtil.class.getResourceAsStream(configPath);
|
||||
document = reader.read(is);
|
||||
root = document.getRootElement();
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if(is != null ){
|
||||
try {
|
||||
is.close();
|
||||
} catch (IOException e) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Node root;
|
||||
/**
|
||||
* 配置文件内容
|
||||
* @return
|
||||
*/
|
||||
public ServiceConfigTemplateUtil(){
|
||||
SAXReader reader = new SAXReader();
|
||||
org.dom4j.Document document = null;
|
||||
String configPath = "/service/service_config.xml";
|
||||
try {
|
||||
document = reader.read(ServiceConfigTemplateUtil.class.getResourceAsStream(configPath));
|
||||
root = document.getRootElement();
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* 获取业务节点列表
|
||||
* @return
|
||||
*/
|
||||
public List<Node> getServiceNodeList(){
|
||||
public static List<Node> getServiceNodeList(){
|
||||
List<Node> nodes = root.selectNodes("service");
|
||||
return nodes;
|
||||
}
|
||||
@@ -48,7 +68,7 @@ public class ServiceConfigTemplateUtil {
|
||||
* 获取业务列表
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,Object>> getServiceList(){
|
||||
public static List<Map<String,Object>> getServiceList(){
|
||||
List<Map<String,Object>> list =new ArrayList();
|
||||
List<Element> elements = root.selectNodes("service");
|
||||
for(Element element:elements){
|
||||
@@ -63,12 +83,47 @@ public class ServiceConfigTemplateUtil {
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static Set<String> getCompileTableName(){
|
||||
Set<String> result = Sets.newHashSet();
|
||||
List<Element> elements = root.selectNodes("service");
|
||||
for(Element element:elements){
|
||||
String ev = element.attribute("tableName").getStringValue();
|
||||
if(StringUtils.isNotBlank(ev)) {
|
||||
result.add(ev.toLowerCase());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据类名 获取对应的 表名
|
||||
* @param className
|
||||
* @return
|
||||
*/
|
||||
public static String getCfgTableNameByClassName(String className) {
|
||||
if(className == null) return null;
|
||||
List<Element> elements = root.selectNodes("service");
|
||||
for(Element element:elements){
|
||||
String ev = element.attribute("tableName").getStringValue();
|
||||
String cn = element.attribute("className").getStringValue();
|
||||
if(className.equalsIgnoreCase(cn)) {
|
||||
return ev.toLowerCase();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param functionId
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,Object>> getServiceListByFunctionId(Integer functionId){
|
||||
public static List<Map<String,Object>> getServiceListByFunctionId(Integer functionId){
|
||||
List<Map<String,Object>> list =new ArrayList();
|
||||
if(!StringUtil.isEmpty(functionId)) {
|
||||
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(functionId);
|
||||
@@ -133,7 +188,7 @@ public class ServiceConfigTemplateUtil {
|
||||
* 获取业务配置列表
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,Object>> getServiceCfgList(Element serviceNode){
|
||||
public static List<Map<String,Object>> getServiceCfgList(Element serviceNode){
|
||||
List<Map<String,Object>> list = new ArrayList();
|
||||
List<Element> elements = serviceNode.selectNodes("serviceCfg");
|
||||
for(Element element:elements){
|
||||
@@ -149,7 +204,7 @@ public class ServiceConfigTemplateUtil {
|
||||
* 获取用户自定义域列表
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,Object>> getUserRegionList(Element serviceNode){
|
||||
public static List<Map<String,Object>> getUserRegionList(Element serviceNode){
|
||||
List<Map<String,Object>> list = new ArrayList();
|
||||
List<Element> elements = serviceNode.selectNodes("userRegion");
|
||||
for(Element element:elements){
|
||||
@@ -167,7 +222,7 @@ public class ServiceConfigTemplateUtil {
|
||||
* @param attribute
|
||||
* @return
|
||||
*/
|
||||
public List getXmlParamListByTag(String tag,String attribute){
|
||||
public static List getXmlParamListByTag(String tag,String attribute){
|
||||
List list =new ArrayList();
|
||||
List<Element> elements = root.selectNodes(tag);
|
||||
for(Element element:elements){
|
||||
@@ -175,6 +230,24 @@ public class ServiceConfigTemplateUtil {
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static Set<String> getAllTableName(){
|
||||
//Set<String> tableName = getCompileTableName();
|
||||
Set<String> result = Sets.newHashSet();
|
||||
List<Map<String, Object>> serviceList = getServiceList();
|
||||
for (Map<String, Object> serviceNode : serviceList) {
|
||||
result.add(serviceNode.get("tableName").toString().trim());
|
||||
List<Map<String,Object>> cfgList = (List<Map<String, Object>>) serviceNode.get("cfgList");
|
||||
if(cfgList != null) {
|
||||
for (Map<String, Object> map : cfgList) {
|
||||
result.add(map.get("tableName").toString().trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
ServiceConfigTemplateUtil serviceTemplate = new ServiceConfigTemplateUtil();
|
||||
@@ -196,6 +269,7 @@ public class ServiceConfigTemplateUtil {
|
||||
|
||||
}
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -268,6 +268,7 @@ public class ExcelCsv {
|
||||
for (String key : keyList) {
|
||||
List<E> list=dataMap.get(key);
|
||||
List<List<String>> listT=new ArrayList<List<String>>();
|
||||
|
||||
for (E e : list){
|
||||
int colunm = 0;
|
||||
List<String> lisb=new ArrayList<String>();
|
||||
@@ -286,8 +287,8 @@ public class ExcelCsv {
|
||||
}
|
||||
}
|
||||
// If is dict, get dict label
|
||||
if (StringUtils.isNotBlank(ef.dictType())){
|
||||
String valStr=val==null?"":val.toString();
|
||||
if (StringUtils.isNotBlank(ef.dictType())){
|
||||
if("type".equals(ef.dictType()) || "attribute".equals(ef.dictType())
|
||||
|| "label".equals(ef.dictType())){
|
||||
// Get basic info
|
||||
@@ -297,9 +298,41 @@ public class ExcelCsv {
|
||||
String dict=DictUtils.getDictLabel(ef.dictType(), valStr, valStr);
|
||||
//如果找不到字典国际化值,把字典本身作为默认值放进去,不然导出就是空了
|
||||
val = msgProp.getProperty(dict,dict);
|
||||
//业务配置-stream 阻断类型中 阻断 改为 封堵(丢弃)
|
||||
if("block_type".equals(ef.title()) && dict.equals("action_reject")
|
||||
&& (Reflections.invokeGetter(e, "serviceId").toString().equals("35")
|
||||
|| Reflections.invokeGetter(e, "serviceId").toString().equals("33")
|
||||
|| Reflections.invokeGetter(e, "serviceId").toString().equals("36"))){
|
||||
dict="block_drop";
|
||||
val = msgProp.getProperty(dict,dict);
|
||||
}
|
||||
if ("action".equals(ef.title()) && dict.equals("action_reject")
|
||||
&& (Reflections.invokeGetter(e, "service").toString().equals("35")
|
||||
|| Reflections.invokeGetter(e, "service").toString().equals("33")
|
||||
|| Reflections.invokeGetter(e, "service").toString().equals("36"))) {
|
||||
dict="block_drop";
|
||||
val = msgProp.getProperty(dict,dict);
|
||||
}
|
||||
//ip spoofing redirect动作修改为Spoofing
|
||||
if(ef.title().equals("block_type")
|
||||
&& (Reflections.invokeGetter(e, "serviceId").toString().equals("518"))) {
|
||||
dict="action_spoofing";
|
||||
val = msgProp.getProperty(dict,dict);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(ef.title().equals("whether_area_block")&&!StringUtil.isEmpty(val)){
|
||||
Integer whetherAreaBlock=Integer.parseInt(valStr);
|
||||
if(whetherAreaBlock.equals(0)){
|
||||
val = msgProp.getProperty("all","all");
|
||||
}else if(whetherAreaBlock.equals(1)){
|
||||
val = msgProp.getProperty("selective","selective");
|
||||
}else{
|
||||
val ="";
|
||||
}
|
||||
}
|
||||
if(ef.title().equals("is_hex") && !StringUtil.isEmpty(val)){
|
||||
Integer isHex=Integer.parseInt(val.toString());
|
||||
if(isHex.equals(0) || isHex.equals(2)){
|
||||
@@ -312,7 +345,7 @@ public class ExcelCsv {
|
||||
}
|
||||
if(ef.title().equals("is_case_insenstive") && !StringUtil.isEmpty(val)){
|
||||
Integer isCaseSenstive=Integer.parseInt(val.toString());
|
||||
if(isCaseSenstive.equals(0) || isCaseSenstive.equals(1)){
|
||||
if(isCaseSenstive.equals(0)){
|
||||
val = msgProp.getProperty("case_insenstive","case_insenstive");
|
||||
}else if(isCaseSenstive.equals(1)){
|
||||
val = msgProp.getProperty("case_senstive","case_senstive");
|
||||
|
||||
@@ -39,8 +39,10 @@ import org.apache.poi.xssf.usermodel.XSSFClientAnchor;
|
||||
import org.apache.poi.xssf.usermodel.XSSFRichTextString;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.nis.domain.FunctionRegionDict;
|
||||
import com.nis.domain.FunctionServiceDict;
|
||||
import com.nis.domain.SysDataDictionaryItem;
|
||||
@@ -264,6 +266,9 @@ public class ExportExcel {
|
||||
commentStr=commentStr+msgProp.getProperty("rule_desc_tip")+":\n";
|
||||
index++;
|
||||
//1、非空
|
||||
commentStr=commentStr+"▶"+msgProp.getProperty("https_url_format_tip")+"\n";
|
||||
index++;
|
||||
//1、非空
|
||||
commentStr=commentStr+"▶"+msgProp.getProperty("required")+"\n";
|
||||
index++;
|
||||
}
|
||||
@@ -453,6 +458,19 @@ public class ExportExcel {
|
||||
}
|
||||
|
||||
}
|
||||
if("ip_group".equals(headerStr)) {
|
||||
commentStr="";
|
||||
//查询dns fake ip policyGroup列表
|
||||
List<PolicyGroupInfo> list=policyGroupInfoDao.findPolicyGroupInfosByType(5);
|
||||
if(!StringUtil.isEmpty(list)){
|
||||
for (PolicyGroupInfo policyGroupInfo : list) {
|
||||
commentStr=commentStr+policyGroupInfo.getServiceGroupId()+"("+policyGroupInfo.getGroupName()+")\n";
|
||||
index++;
|
||||
}
|
||||
}
|
||||
commentStr=msgProp.getProperty("select")+":\n"+commentStr;
|
||||
index++;
|
||||
}
|
||||
if("isp".equals(headerStr)) {
|
||||
commentStr="";
|
||||
List<Integer> itTypeList = new ArrayList<Integer>();
|
||||
@@ -496,7 +514,7 @@ public class ExportExcel {
|
||||
commentStr=commentStr+"▶"+msgProp.getProperty("required")+"\n";
|
||||
index++;
|
||||
}
|
||||
if(("domain_name".equals(headerStr)) && (region.getFunctionId().equals(560))){
|
||||
if("domain_name".equals(headerStr)){
|
||||
commentStr=commentStr+msgProp.getProperty("rule_desc_tip")+":\n";
|
||||
index++;
|
||||
//1、非空
|
||||
@@ -583,25 +601,28 @@ public class ExportExcel {
|
||||
commentStr="";
|
||||
}
|
||||
}else{
|
||||
String[] ipPatterns=region.getConfigIpPattern().split(";");
|
||||
if("client_ip".equals(headerStr)){
|
||||
Assert.isTrue(ipPatterns.length==2);
|
||||
String srcIpPattern=ipPatterns[0];
|
||||
if(((","+region.getConfigIpPortShow()+",").indexOf(",1,") > -1) ){
|
||||
commentStr="";
|
||||
if((","+region.getConfigIpType()+",").indexOf(",4,") > -1){
|
||||
if((","+region.getConfigIpPattern()+",").indexOf(",3,") > -1){
|
||||
if((","+srcIpPattern+",").indexOf(",3,") > -1){
|
||||
commentStr=commentStr+Constants.IPV4_DEFAULT_IP_VALUE+"(IPv4)"+"\n";
|
||||
if(StringUtil.isEmpty(defaultValue)){
|
||||
defaultValue=Constants.IPV4_DEFAULT_IP_VALUE;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
if((","+region.getConfigIpPattern()+",").indexOf(",2,") > -1){
|
||||
if((","+srcIpPattern+",").indexOf(",2,") > -1){
|
||||
commentStr=commentStr+Constants.IPV4_DEFAULT_IP_RANGE_VALUE+"("+msgProp.getProperty("ipv4_range_tip")+")"+"\n";
|
||||
if(StringUtil.isEmpty(defaultValue)){
|
||||
defaultValue=Constants.IPV4_DEFAULT_IP_RANGE_VALUE;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
if((","+region.getConfigIpPattern()+",").indexOf(",1,") > -1){
|
||||
if((","+srcIpPattern+",").indexOf(",1,") > -1){
|
||||
commentStr=commentStr+Constants.IPV4_DEFAULT_IP_SUBNET_VALUE+"("+msgProp.getProperty("ipv4_subnet_tip")+")"+"\n";
|
||||
if(StringUtil.isEmpty(defaultValue)){
|
||||
defaultValue=Constants.IPV4_DEFAULT_IP_SUBNET_VALUE;
|
||||
@@ -610,21 +631,21 @@ public class ExportExcel {
|
||||
}
|
||||
}
|
||||
if((","+region.getConfigIpType()+",").indexOf(",6,") > -1){
|
||||
if((","+region.getConfigIpPattern()+",").indexOf(",3,") > -1){
|
||||
if((","+srcIpPattern+",").indexOf(",3,") > -1){
|
||||
commentStr=commentStr+Constants.IPV6_DEFAULT_IP_VALUE+"(IPv6)"+"\n";
|
||||
if(StringUtil.isEmpty(defaultValue)){
|
||||
defaultValue=Constants.IPV6_DEFAULT_IP_VALUE;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
if((","+region.getConfigIpPattern()+",").indexOf(",2,") > -1){
|
||||
if((","+srcIpPattern+",").indexOf(",2,") > -1){
|
||||
commentStr=commentStr+Constants.IPV6_DEFAULT_IP_RANGE_VALUE+"("+msgProp.getProperty("ipv6_range_tip")+")"+"\n";
|
||||
if(StringUtil.isEmpty(defaultValue)){
|
||||
defaultValue=Constants.IPV6_DEFAULT_IP_RANGE_VALUE;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
if((","+region.getConfigIpPattern()+",").indexOf(",1,") > -1){
|
||||
if((","+srcIpPattern+",").indexOf(",1,") > -1){
|
||||
commentStr=commentStr+Constants.IPV6_DEFAULT_IP_SUBNET_VALUE+"("+msgProp.getProperty("ipv6_subnet_tip")+")"+"\n\n";
|
||||
if(StringUtil.isEmpty(defaultValue)){
|
||||
defaultValue=Constants.IPV6_DEFAULT_IP_SUBNET_VALUE;
|
||||
@@ -673,12 +694,12 @@ public class ExportExcel {
|
||||
,msgProp.getProperty("serverip"))+"\n";
|
||||
index++;
|
||||
index++;
|
||||
commentStr=commentStr+"▶"+String.format(msgProp.getProperty("the_same_ip_type_pattern"))+"\n";
|
||||
commentStr=commentStr+"▶"+String.format(msgProp.getProperty("the_same_ip_type"))+"\n";
|
||||
index++;
|
||||
index++;
|
||||
}
|
||||
//4、IP Range 开始IP和结束IP必须在同一网段
|
||||
if(((","+region.getConfigIpPattern()+",").indexOf(",2,") > -1)){
|
||||
if(((","+srcIpPattern+",").indexOf(",2,") > -1)){
|
||||
commentStr=commentStr+"▶"+msgProp.getProperty("ip_range")+","+msgProp.getProperty("ip_range_bit_field")+"\n";
|
||||
index++;
|
||||
index++;
|
||||
@@ -689,7 +710,7 @@ public class ExportExcel {
|
||||
}
|
||||
|
||||
//6、IPv4 Mask 掩码范围16-32
|
||||
if(((","+region.getConfigIpPattern()+",").indexOf(",1,") > -1)){
|
||||
if(((","+srcIpPattern+",").indexOf(",1,") > -1)){
|
||||
if(((","+region.getConfigIpType()+",").indexOf(",4,") > -1)){
|
||||
commentStr=commentStr+"▶"+msgProp.getProperty("ipv4_subnet_tip")+","+msgProp.getProperty("ipv4_mask_range_tip")+"\n";
|
||||
index++;
|
||||
@@ -705,24 +726,25 @@ public class ExportExcel {
|
||||
|
||||
}
|
||||
if("server_ip".equals(headerStr)){
|
||||
String destIpPattern=ipPatterns[1];
|
||||
if((","+region.getConfigIpPortShow()+",").indexOf(",3,") > -1){
|
||||
commentStr="";
|
||||
if((","+region.getConfigIpType()+",").indexOf(",4,") > -1){
|
||||
if((","+region.getConfigIpPattern()+",").indexOf(",3,") > -1){
|
||||
if((","+destIpPattern+",").indexOf(",3,") > -1){
|
||||
commentStr=commentStr+Constants.IPV4_DEFAULT_IP_VALUE+"(IPv4)"+"\n";
|
||||
if(StringUtil.isEmpty(defaultValue)){
|
||||
defaultValue=Constants.IPV4_DEFAULT_IP_VALUE;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
if((","+region.getConfigIpPattern()+",").indexOf(",2,") > -1){
|
||||
if((","+destIpPattern+",").indexOf(",2,") > -1){
|
||||
commentStr=commentStr+Constants.IPV4_DEFAULT_IP_RANGE_VALUE+"("+msgProp.getProperty("ipv4_range_tip")+")"+"\n";
|
||||
if(StringUtil.isEmpty(defaultValue)){
|
||||
defaultValue=Constants.IPV4_DEFAULT_IP_RANGE_VALUE;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
if((","+region.getConfigIpPattern()+",").indexOf(",1,") > -1){
|
||||
if((","+destIpPattern+",").indexOf(",1,") > -1){
|
||||
commentStr=commentStr+Constants.IPV4_DEFAULT_IP_SUBNET_VALUE+"("+msgProp.getProperty("ipv4_subnet_tip")+")"+"\n";
|
||||
if(StringUtil.isEmpty(defaultValue)){
|
||||
defaultValue=Constants.IPV4_DEFAULT_IP_SUBNET_VALUE;
|
||||
@@ -731,21 +753,21 @@ public class ExportExcel {
|
||||
}
|
||||
}
|
||||
if((","+region.getConfigIpType()+",").indexOf(",6,") > -1){
|
||||
if((","+region.getConfigIpPattern()+",").indexOf(",3,") > -1){
|
||||
if((","+destIpPattern+",").indexOf(",3,") > -1){
|
||||
commentStr=commentStr+Constants.IPV6_DEFAULT_IP_VALUE+"(IPv6)"+"\n";
|
||||
if(StringUtil.isEmpty(defaultValue)){
|
||||
defaultValue=Constants.IPV6_DEFAULT_IP_VALUE;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
if((","+region.getConfigIpPattern()+",").indexOf(",2,") > -1){
|
||||
if((","+destIpPattern+",").indexOf(",2,") > -1){
|
||||
commentStr=commentStr+Constants.IPV6_DEFAULT_IP_RANGE_VALUE+"("+msgProp.getProperty("ipv6_range_tip")+")"+"\n";
|
||||
if(StringUtil.isEmpty(defaultValue)){
|
||||
defaultValue=Constants.IPV6_DEFAULT_IP_RANGE_VALUE;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
if((","+region.getConfigIpPattern()+",").indexOf(",1,") > -1){
|
||||
if((","+destIpPattern+",").indexOf(",1,") > -1){
|
||||
commentStr=commentStr+Constants.IPV6_DEFAULT_IP_SUBNET_VALUE+"("+msgProp.getProperty("ipv6_subnet_tip")+")"+"\n\n";
|
||||
if(StringUtil.isEmpty(defaultValue)){
|
||||
defaultValue=Constants.IPV6_DEFAULT_IP_SUBNET_VALUE;
|
||||
@@ -778,12 +800,12 @@ public class ExportExcel {
|
||||
,msgProp.getProperty("serverip"))+"\n";
|
||||
index++;
|
||||
index++;
|
||||
commentStr=commentStr+"▶"+String.format(msgProp.getProperty("the_same_ip_type_pattern"))+"\n";
|
||||
commentStr=commentStr+"▶"+String.format(msgProp.getProperty("the_same_ip_type"))+"\n";
|
||||
index++;
|
||||
index++;
|
||||
}
|
||||
//4、IP Range 开始IP和结束IP必须在同一网段
|
||||
if(((","+region.getConfigIpPattern()+",").indexOf(",2,") > -1)){
|
||||
if(((","+destIpPattern+",").indexOf(",2,") > -1)){
|
||||
commentStr=commentStr+"▶"+msgProp.getProperty("ip_range")+","+msgProp.getProperty("ip_range_bit_field")+"\n";
|
||||
index++;
|
||||
index++;
|
||||
@@ -794,7 +816,7 @@ public class ExportExcel {
|
||||
}
|
||||
|
||||
//6、IPv4 Mask 掩码范围16-32
|
||||
if(((","+region.getConfigIpPattern()+",").indexOf(",1,") > -1)){
|
||||
if(((","+destIpPattern+",").indexOf(",1,") > -1)){
|
||||
if(((","+region.getConfigIpType()+",").indexOf(",4,") > -1)){
|
||||
commentStr=commentStr+"▶"+msgProp.getProperty("ipv4_subnet_tip")+","+msgProp.getProperty("ipv4_mask_range_tip")+"\n";
|
||||
index++;
|
||||
@@ -820,17 +842,20 @@ public class ExportExcel {
|
||||
}else{
|
||||
protocol=region.getConfigProtocol();
|
||||
}
|
||||
String[] portPatterns=region.getConfigPortPattern().split(";");
|
||||
Assert.isTrue(portPatterns.length==2);
|
||||
if("client_port".equals(headerStr)){
|
||||
String srcPortPattern=portPatterns[0];
|
||||
if(((","+region.getConfigIpPortShow()+",").indexOf(",2,") > -1)){
|
||||
commentStr="";
|
||||
if((","+region.getConfigPortPattern()+",").indexOf(",1,") > -1){
|
||||
if((","+srcPortPattern+",").indexOf(",1,") > -1){
|
||||
commentStr=commentStr+Constants.PORT_DEFAULT+"(Port)"+"\n";
|
||||
if(StringUtil.isEmpty(defaultValue)){
|
||||
defaultValue=Constants.PORT_DEFAULT;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
if((","+region.getConfigPortPattern()+",").indexOf(",2,") > -1){
|
||||
if((","+srcPortPattern+",").indexOf(",2,") > -1){
|
||||
commentStr=commentStr+Constants.PORT_MASK_DEFAULT+"(Port/"+msgProp.getProperty("port_mask")+")"+"\n\n";
|
||||
if(StringUtil.isEmpty(defaultValue)){
|
||||
defaultValue=Constants.PORT_MASK_DEFAULT;
|
||||
@@ -856,11 +881,11 @@ public class ExportExcel {
|
||||
index++;
|
||||
}
|
||||
//2、源端口、目的端口格式必须一致
|
||||
if(((","+region.getConfigIpPortShow()+",").indexOf(",2,") > -1) && ((","+region.getConfigIpPortShow()+",").indexOf(",4,") > -1)){
|
||||
commentStr=commentStr+"▶"+msgProp.getProperty("the_same_port_pattern")+"\n";
|
||||
index++;
|
||||
index++;
|
||||
}
|
||||
// if(((","+region.getConfigIpPortShow()+",").indexOf(",2,") > -1) && ((","+region.getConfigIpPortShow()+",").indexOf(",4,") > -1)){
|
||||
// commentStr=commentStr+"▶"+msgProp.getProperty("the_same_port_pattern")+"\n";
|
||||
// index++;
|
||||
// index++;
|
||||
// }
|
||||
//3、端口和端口掩码范围0-65535
|
||||
commentStr=commentStr+"▶"+msgProp.getProperty("port_mask_comment_tip")+"\n";
|
||||
index++;
|
||||
@@ -895,16 +920,17 @@ public class ExportExcel {
|
||||
}
|
||||
}
|
||||
if("server_port".equals(headerStr)){
|
||||
String destPortPattern=portPatterns[1];
|
||||
if((","+region.getConfigIpPortShow()+",").indexOf(",4,") > -1){
|
||||
commentStr="";
|
||||
if((","+region.getConfigPortPattern()+",").indexOf(",1,") > -1){
|
||||
if((","+destPortPattern+",").indexOf(",1,") > -1){
|
||||
commentStr=commentStr+Constants.PORT_DEFAULT+"(Port)"+"\n";
|
||||
if(StringUtil.isEmpty(defaultValue)){
|
||||
defaultValue=Constants.PORT_DEFAULT;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
if((","+region.getConfigPortPattern()+",").indexOf(",2,") > -1){
|
||||
if((","+destPortPattern+",").indexOf(",2,") > -1){
|
||||
commentStr=commentStr+Constants.PORT_MASK_DEFAULT+"(Port/"+msgProp.getProperty("port_mask")+")"+"\n\n";
|
||||
if(StringUtil.isEmpty(defaultValue)){
|
||||
defaultValue=Constants.PORT_MASK_DEFAULT;
|
||||
@@ -930,11 +956,11 @@ public class ExportExcel {
|
||||
index++;
|
||||
}
|
||||
//2、源端口、目的端口格式必须一致
|
||||
if(((","+region.getConfigIpPortShow()+",").indexOf(",2,") > -1) && ((","+region.getConfigIpPortShow()+",").indexOf(",4,") > -1)){
|
||||
commentStr=commentStr+"▶"+msgProp.getProperty("the_same_port_pattern")+"\n";
|
||||
index++;
|
||||
index++;
|
||||
}
|
||||
// if(((","+region.getConfigIpPortShow()+",").indexOf(",2,") > -1) && ((","+region.getConfigIpPortShow()+",").indexOf(",4,") > -1)){
|
||||
// commentStr=commentStr+"▶"+msgProp.getProperty("the_same_port_pattern")+"\n";
|
||||
// index++;
|
||||
// index++;
|
||||
// }
|
||||
//3、端口和端口掩码范围0-65535
|
||||
commentStr=commentStr+"▶"+msgProp.getProperty("port_mask_comment_tip")+"\n";
|
||||
index++;
|
||||
@@ -1113,9 +1139,9 @@ public class ExportExcel {
|
||||
commentStr="";
|
||||
}
|
||||
if(StringUtil.isEmpty(defaultValue)){
|
||||
defaultValue="0";
|
||||
defaultValue = region.getConfigDirection().split(",")[0];
|
||||
}
|
||||
defaultValue = region.getFunctionId().equals(301)?"1":defaultValue;
|
||||
|
||||
}
|
||||
/*}*/
|
||||
/*if(StringUtil.isEmpty(commentStr)){
|
||||
@@ -2233,7 +2259,9 @@ public class ExportExcel {
|
||||
* @return list 数据列表
|
||||
*/
|
||||
public <E> ExportExcel setDataList(Properties msgProp, Map<String,List> dataMap, Map<Object,Object> map){
|
||||
long start=System.currentTimeMillis(),end=System.currentTimeMillis();
|
||||
Set<String> keyList=dataMap.keySet();
|
||||
Map<String,Map<String,String>> dictMaps=Maps.newConcurrentMap();
|
||||
for (String key : keyList) {
|
||||
List<E> list=dataMap.get(key);
|
||||
for (E e : list){
|
||||
@@ -2263,9 +2291,39 @@ public class ExportExcel {
|
||||
val = getBasicInfo(ef.dictType(),map,valStr);
|
||||
}else{
|
||||
//字典数据已做国际化处理
|
||||
String dict=DictUtils.getDictLabel(ef.dictType(), valStr, valStr);
|
||||
String dict="";
|
||||
if(dictMaps.containsKey(ef.dictType())) {
|
||||
Map<String,String> dictM=dictMaps.get(ef.dictType());
|
||||
dict=dictM.containsKey(valStr)?dictM.get(valStr):valStr;
|
||||
}else {
|
||||
Map<String,String> dictM=DictUtils.getDictMap(ef.dictType());
|
||||
dictMaps.put(ef.dictType(), dictM);
|
||||
dict=dictM.containsKey(valStr)?dictM.get(valStr):valStr;
|
||||
}
|
||||
//String dict=DictUtils.getDictLabel(ef.dictType(), valStr, valStr);
|
||||
//如果找不到字典国际化值,把字典本身作为默认值放进去,不然导出就是空了
|
||||
val = msgProp.getProperty(dict,dict);
|
||||
//业务配置-stream 阻断类型中 阻断 改为 封堵(丢弃)
|
||||
if("block_type".equals(ef.title()) && dict.equals("action_reject")
|
||||
&& (Reflections.invokeGetter(e, "serviceId").toString().equals("35")
|
||||
|| Reflections.invokeGetter(e, "serviceId").toString().equals("33")
|
||||
|| Reflections.invokeGetter(e, "serviceId").toString().equals("36"))){
|
||||
dict="block_drop";
|
||||
val = msgProp.getProperty(dict,dict);
|
||||
}
|
||||
if ("action".equals(ef.title()) && dict.equals("action_reject")
|
||||
&& (Reflections.invokeGetter(e, "service").toString().equals("35")
|
||||
|| Reflections.invokeGetter(e, "service").toString().equals("33")
|
||||
|| Reflections.invokeGetter(e, "service").toString().equals("36"))) {
|
||||
dict="block_drop";
|
||||
val = msgProp.getProperty(dict,dict);
|
||||
}
|
||||
//ip spoofing redirect动作修改为Spoofing
|
||||
if(ef.title().equals("block_type")
|
||||
&& (Reflections.invokeGetter(e, "serviceId").toString().equals("518"))) {
|
||||
dict="action_spoofing";
|
||||
val = msgProp.getProperty(dict,dict);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2291,7 +2349,7 @@ public class ExportExcel {
|
||||
}
|
||||
if(ef.title().equals("is_case_insenstive") && !StringUtil.isEmpty(val)){
|
||||
Integer isCaseSenstive=Integer.parseInt(val.toString());
|
||||
if(isCaseSenstive.equals(0) || isCaseSenstive.equals(1)){
|
||||
if(isCaseSenstive.equals(0)){
|
||||
val = msgProp.getProperty("case_insenstive","case_insenstive");
|
||||
}else if(isCaseSenstive.equals(1)){
|
||||
val = msgProp.getProperty("case_senstive","case_senstive");
|
||||
@@ -2318,6 +2376,8 @@ public class ExportExcel {
|
||||
log.debug("Write success: ["+row.getRowNum()+"] "+sb.toString());
|
||||
}
|
||||
}
|
||||
end=System.currentTimeMillis();
|
||||
System.err.println("setDataList cost:"+(end-start));
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
@@ -2450,6 +2510,7 @@ public class ExportExcel {
|
||||
* @return
|
||||
*/
|
||||
public ExportExcel(Properties msgProp,List<String> titleList,Map<String,String> noExportMap,Map<String, Class<?>> clsMap, int type,String titleTime, int... groups){
|
||||
long start=System.currentTimeMillis(),end=System.currentTimeMillis();
|
||||
Map<String, List<String>> headerMap=new HashMap<String, List<String>>();
|
||||
Map<String, List<String>> commentMap=new HashMap<String, List<String>>();
|
||||
for (String title : titleList) {
|
||||
@@ -2575,6 +2636,8 @@ public class ExportExcel {
|
||||
annotationMap.put(title, annotationList);
|
||||
}
|
||||
initializeMultiSheet(msgProp,titleList, headerMap,commentMap,titleTime);
|
||||
end=System.currentTimeMillis();
|
||||
System.err.println("ExportExcel cost:"+(end-start));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,7 +12,9 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
@@ -20,6 +22,7 @@ import java.util.concurrent.BlockingQueue;
|
||||
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import org.apache.commons.lang3.StringEscapeUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
||||
import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
|
||||
@@ -420,19 +423,23 @@ public class ImportBigExcel extends XLSXCovertCSVReader{
|
||||
throw new RuntimeException("regionDict is null!");
|
||||
}
|
||||
if(dataList.size()==0) {
|
||||
throw new ServiceException(props.getProperty("noneData", "noneData"));
|
||||
throw new ServiceException(props.getProperty("no_data", "no_data"));
|
||||
}else if(this.hasImportLimit&&dataList.size()>(Constants.IMPORT_LIMIT+1)) {
|
||||
throw new ServiceException(props.getProperty("import_limit_is", "The maximum import size is")+" "+Constants.IMPORT_LIMIT);
|
||||
}
|
||||
// Get excel data
|
||||
BlockingQueue<E> _dataList =new ArrayBlockingQueue(dataList.size(),true);
|
||||
for (int i = 0; i < dataList.size(); i++) {
|
||||
E e = (E)cls.newInstance();
|
||||
if(i<=headerNum) {
|
||||
Map<String, Map<String, Object>> dictMap = new HashMap<String,Map<String, Object>>();
|
||||
Object val1 = null;
|
||||
for (int i = 0, len = dataList.size(); i < len; i++) {
|
||||
List<Object> row=dataList.get(i);
|
||||
//boolean flag = row.stream().allMatch(obj -> "".equals(obj));
|
||||
if(i <= headerNum || row.size() == 0) {// 跳过第一行和空行
|
||||
continue;
|
||||
}
|
||||
|
||||
E e = (E)cls.newInstance();
|
||||
int column = 0;
|
||||
List<Object> row=dataList.get(i);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (Object[] os : annotationList){
|
||||
Object val=row.get(column);
|
||||
@@ -441,7 +448,23 @@ public class ImportBigExcel extends XLSXCovertCSVReader{
|
||||
ExcelField ef = (ExcelField)os[0];
|
||||
// If is dict type, get dict value
|
||||
if (StringUtils.isNotBlank(ef.dictType())){
|
||||
Object val1 = DictUtils.getDictCode(ef.dictType(), val.toString(), "");
|
||||
// 缓存当前excel文件获取过的字典值
|
||||
if(!dictMap.containsKey(ef.dictType())) {
|
||||
val1 = DictUtils.getDictCode(ef.dictType(), val.toString(), "");
|
||||
Map<String, Object> putMap = new HashMap<String,Object>();
|
||||
putMap.put(val.toString(), val1);
|
||||
dictMap.put(ef.dictType(), putMap);
|
||||
}else {
|
||||
Map<String, Object> map = dictMap.get(ef.dictType());
|
||||
if(!map.containsKey(val.toString())) {
|
||||
val1 = DictUtils.getDictCode(ef.dictType(), val.toString(), "");
|
||||
map.put(val.toString(), val1);
|
||||
dictMap.put(ef.dictType(), map);
|
||||
}else {
|
||||
val1 = map.get(val.toString());
|
||||
}
|
||||
}
|
||||
|
||||
//没有获取到字典值的话会影响验证判断
|
||||
if(val1!=null&&StringUtils.isNotBlank(val1.toString())) {
|
||||
val=val1;
|
||||
@@ -465,11 +488,11 @@ public class ImportBigExcel extends XLSXCovertCSVReader{
|
||||
if (valType == String.class){
|
||||
String s = String.valueOf(val.toString().trim());
|
||||
//0.0.0.0表示任意IP的含义
|
||||
if(StringUtils.endsWith(s, ".0") && !s.endsWith("0.0.0.0")){
|
||||
val = StringUtils.substringBefore(s, ".0");
|
||||
}else{
|
||||
val = String.valueOf(val.toString().trim());
|
||||
}
|
||||
// if(StringUtils.endsWith(s, ".0") && !s.endsWith("0.0.0.0")){
|
||||
// val = StringUtils.substringBefore(s, ".0");
|
||||
// }else{
|
||||
val=val == null ? "" : StringEscapeUtils.escapeHtml4(val.toString().trim());
|
||||
// }
|
||||
}else if (valType == Integer.class){
|
||||
val = Double.valueOf(val.toString().trim()).intValue();
|
||||
}else if (valType == Long.class){
|
||||
|
||||
@@ -8,7 +8,9 @@ import java.sql.SQLException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.parsers.SAXParser;
|
||||
@@ -32,6 +34,8 @@ import org.xml.sax.SAXException;
|
||||
import org.xml.sax.XMLReader;
|
||||
import org.xml.sax.helpers.DefaultHandler;
|
||||
|
||||
import com.nis.util.StringUtil;
|
||||
|
||||
|
||||
/**
|
||||
* 使用CVS模式解决XLSX文件,可以有效解决用户模式内存溢出的问题
|
||||
@@ -102,12 +106,14 @@ public abstract class XLSXCovertCSVReader {
|
||||
// The last column printed to the output stream
|
||||
private int lastColumnNumber = -1;
|
||||
private List<Object> rowlist = new ArrayList<Object>();
|
||||
private Map<Integer,Object> rowMap = new HashMap<Integer, Object>();
|
||||
// Gathers characters as they are seen.
|
||||
private StringBuffer value;
|
||||
// private String[] record;
|
||||
// private List<String[]> rows = new ArrayList<String[]>();
|
||||
private boolean isCellNull = false;
|
||||
|
||||
private int upRowId; // 记录上一行行号
|
||||
/**
|
||||
* Accepts objects needed while parsing.
|
||||
*
|
||||
@@ -128,6 +134,7 @@ public abstract class XLSXCovertCSVReader {
|
||||
this.nextDataType = xssfDataType.NUMBER;
|
||||
this.formatter = new DataFormatter();
|
||||
rowlist.clear();// 每次读取都清空行集合
|
||||
rowMap.clear();
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -198,6 +205,21 @@ public abstract class XLSXCovertCSVReader {
|
||||
this.formatString = BuiltinFormats
|
||||
.getBuiltinFormat(this.formatIndex);
|
||||
}
|
||||
|
||||
}else if("row".equals(name)) {
|
||||
// 获取行号
|
||||
String r = attributes.getValue("r");
|
||||
int index = Integer.parseInt(r);
|
||||
|
||||
int gap = index - upRowId;
|
||||
if(gap > 1) { // 存在空行
|
||||
while(gap > 1) {
|
||||
optRows(sheetIndex,lastColumnNumber,rowlist);
|
||||
gap--;
|
||||
}
|
||||
|
||||
}
|
||||
upRowId = index;
|
||||
}
|
||||
lastContents = "";
|
||||
}
|
||||
@@ -287,6 +309,9 @@ public abstract class XLSXCovertCSVReader {
|
||||
int len = countNullCell(refnum, preRefnum);
|
||||
for(int i=0;i<len;i++){
|
||||
rowlist.add(curCol, "");
|
||||
if(!rowMap.containsKey(thisColumn)){
|
||||
rowMap.put(thisColumn, "");
|
||||
}
|
||||
curCol++;
|
||||
}
|
||||
}
|
||||
@@ -298,6 +323,7 @@ public abstract class XLSXCovertCSVReader {
|
||||
}
|
||||
// System.out.println("refnum="+refnum+"preRefnum="+preRefnum+"curCol="+curCol);
|
||||
rowlist.add(curCol, thisVal);
|
||||
rowMap.put(thisColumn, thisVal);
|
||||
rowData.add(new IndexValue(refnum,lastContents) );
|
||||
curCol++;
|
||||
// record[thisColumn] = thisStr;
|
||||
@@ -324,15 +350,24 @@ public abstract class XLSXCovertCSVReader {
|
||||
int len = countNullCell(maxRefnum, refnum);
|
||||
for(int i=0;i<=len;i++){
|
||||
rowlist.add(curCol, "");
|
||||
if(!rowMap.containsKey(thisColumn)){
|
||||
rowMap.put(thisColumn, "");
|
||||
}
|
||||
curCol++;
|
||||
}
|
||||
int totalLen= countTotalCell(maxRefnum);
|
||||
if(rowlist.size()<totalLen) {
|
||||
List<Object> tempList=new ArrayList<>(totalLen);
|
||||
for(int i=0;i<(totalLen-rowlist.size());i++) {
|
||||
tempList.add("");
|
||||
//修改某一个单元格为空,字段映射顺序错乱问题
|
||||
for(int i=0;i<totalLen;i++) {
|
||||
if(!StringUtil.isEmpty(rowMap.get(i))){
|
||||
tempList.add(rowMap.get(i));
|
||||
}else{
|
||||
tempList.add(i,"");
|
||||
}
|
||||
tempList.addAll(rowlist);
|
||||
|
||||
}
|
||||
//tempList.addAll(rowlist);
|
||||
rowlist= tempList;
|
||||
}
|
||||
}
|
||||
@@ -343,6 +378,7 @@ public abstract class XLSXCovertCSVReader {
|
||||
optRows(sheetIndex,lastColumnNumber,rowlist);
|
||||
|
||||
rowlist.clear();
|
||||
rowMap.clear();
|
||||
// rows.add(record.clone());
|
||||
isCellNull = false;
|
||||
// for (int i = 0; i < record.length; i++) {
|
||||
@@ -352,6 +388,7 @@ public abstract class XLSXCovertCSVReader {
|
||||
}
|
||||
rowlist.clear();
|
||||
rowData.clear();
|
||||
rowMap.clear();
|
||||
curCol = 0;
|
||||
preRefnum = null;
|
||||
refnum = null;
|
||||
|
||||
@@ -45,6 +45,7 @@ public class CheckAppFeatureComplexStringFormatThread implements Callable<String
|
||||
public String call() throws Exception {
|
||||
List<Object> dataList=Lists.newArrayList(Constants.MAAT_JSON_SEND_SIZE);
|
||||
StringBuffer msg=new StringBuffer();
|
||||
boolean error = false;
|
||||
while(!srcQueue.isEmpty()) {
|
||||
int size=srcQueue.drainTo(dataList,Constants.MAAT_JSON_SEND_SIZE);
|
||||
if(regionDict.getRegionType().intValue()==3) {
|
||||
@@ -57,10 +58,15 @@ public class CheckAppFeatureComplexStringFormatThread implements Callable<String
|
||||
//msg=e.getMessage();
|
||||
//msg.append(e.getMessage());
|
||||
//break;
|
||||
error = true;
|
||||
}
|
||||
}
|
||||
dataList.clear();
|
||||
}
|
||||
if(error) {
|
||||
msg.append("validate_error");
|
||||
}
|
||||
|
||||
return msg.toString();
|
||||
}
|
||||
public List<AppComplexFeatureCfg> checkAppComplexFeatureCfg(StringBuffer msg,
|
||||
|
||||
@@ -45,6 +45,7 @@ public class CheckComplexStringFormatThread implements Callable<String>{
|
||||
public String call() throws Exception {
|
||||
List<Object> dataList=Lists.newArrayList(Constants.MAAT_JSON_SEND_SIZE);
|
||||
StringBuffer msg=new StringBuffer();
|
||||
boolean error = false;
|
||||
while(!srcQueue.isEmpty()) {
|
||||
int size=srcQueue.drainTo(dataList,Constants.MAAT_JSON_SEND_SIZE);
|
||||
if(regionDict.getRegionType().intValue()==3) {
|
||||
@@ -57,10 +58,15 @@ public class CheckComplexStringFormatThread implements Callable<String>{
|
||||
//msg=e.getMessage();
|
||||
//msg.append(e.getMessage());
|
||||
//break;
|
||||
error = true;
|
||||
}
|
||||
}
|
||||
dataList.clear();
|
||||
}
|
||||
if(error) {
|
||||
msg.append("validate_error");
|
||||
}
|
||||
|
||||
return msg.toString();
|
||||
}
|
||||
public List<ComplexkeywordCfg> checkComplexStringCfg(StringBuffer msg,
|
||||
@@ -149,7 +155,7 @@ public class CheckComplexStringFormatThread implements Callable<String>{
|
||||
// 代理 HTTP(s)重定向
|
||||
if (regionDict.getFunctionId().equals(208)) {
|
||||
if(StringUtils.isBlank(baseStringCfg.getUserRegion1())) {
|
||||
baseStringCfg.setUserRegion1("301");
|
||||
baseStringCfg.setUserRegion1("302");
|
||||
}
|
||||
String userRegion1 = baseStringCfg.getUserRegion1();// 重定向应答码
|
||||
String userRegion2 = baseStringCfg.getUserRegion2();// 重定向URL
|
||||
@@ -375,7 +381,10 @@ public class CheckComplexStringFormatThread implements Callable<String>{
|
||||
prop.getProperty("is_case_insenstive")) + ";");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}
|
||||
|
||||
isHex = baseStringCfg.getIsHex();
|
||||
isCaseInsenstive = baseStringCfg.getIsCaseInsenstive();
|
||||
if (isHex.intValue() != 0 && isHex.intValue() != 1) {
|
||||
errInfo.append(
|
||||
String.format(prop.getProperty("is_incorrect"), prop.getProperty("is_hex")) + ";");
|
||||
@@ -411,9 +420,7 @@ public class CheckComplexStringFormatThread implements Callable<String>{
|
||||
prop.getProperty("key_word") + " '" + keyword + "' "+String.format(prop.getProperty("contains_non_hex_char")) + ";");
|
||||
}
|
||||
}
|
||||
}
|
||||
isHex = baseStringCfg.getIsHex();
|
||||
isCaseInsenstive = baseStringCfg.getIsCaseInsenstive();
|
||||
|
||||
if (isHex != null && isCaseInsenstive != null) {
|
||||
if (isHex.intValue() == 0 && isCaseInsenstive.intValue() == 0) {
|
||||
baseStringCfg.setIsHexbin(0);
|
||||
|
||||
@@ -42,6 +42,7 @@ public class CheckDnsResStrategyFormatThread implements Callable<String>{
|
||||
public String call() throws Exception {
|
||||
List<Object> dataList=Lists.newArrayList(Constants.MAAT_JSON_SEND_SIZE);
|
||||
StringBuffer msg=new StringBuffer();
|
||||
boolean error = false;
|
||||
while(!srcQueue.isEmpty()) {
|
||||
int size=srcQueue.drainTo(dataList,Constants.MAAT_JSON_SEND_SIZE);
|
||||
if(regionDict.getRegionType().intValue()==6) {
|
||||
@@ -53,10 +54,15 @@ public class CheckDnsResStrategyFormatThread implements Callable<String>{
|
||||
// TODO: handle exception
|
||||
//msg=e.getMessage();
|
||||
//break;
|
||||
error = true;
|
||||
}
|
||||
}
|
||||
dataList.clear();
|
||||
}
|
||||
if(error) {
|
||||
msg.append("validate_error");
|
||||
}
|
||||
|
||||
return msg.toString();
|
||||
}
|
||||
public List<DnsResStrategy> checkDnsResStrategyCfg(StringBuffer msg,List<?> list)
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.jets3t.service.ServiceException;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import com.beust.jcommander.internal.Lists;
|
||||
import com.nis.domain.FunctionRegionDict;
|
||||
@@ -27,6 +28,8 @@ import com.nis.domain.configuration.template.IpRateLimitTemplate;
|
||||
//import com.nis.util.AsnCacheUtils;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.DictUtils;
|
||||
import com.nis.util.IPUtil;
|
||||
import com.nis.util.StringUtil;
|
||||
|
||||
public class CheckIpFormatThread implements Callable<String>{
|
||||
private Logger logger=Logger.getLogger(CheckIpFormatThread.class);
|
||||
@@ -51,6 +54,7 @@ public class CheckIpFormatThread implements Callable<String>{
|
||||
public String call() throws Exception {
|
||||
List<Object> dataList=Lists.newArrayList(Constants.MAAT_JSON_SEND_SIZE);
|
||||
StringBuffer msg=new StringBuffer();
|
||||
boolean error = false;
|
||||
while(!srcQueue.isEmpty()) {
|
||||
int size=srcQueue.drainTo(dataList,Constants.MAAT_JSON_SEND_SIZE);
|
||||
if(regionDict.getRegionType().intValue()==1) {
|
||||
@@ -63,10 +67,15 @@ public class CheckIpFormatThread implements Callable<String>{
|
||||
// TODO: handle exception
|
||||
//msg.append(e.getMessage());
|
||||
//break;
|
||||
error = true;
|
||||
}
|
||||
}
|
||||
dataList.clear();
|
||||
}
|
||||
if(error) {
|
||||
msg.append("validate_error");
|
||||
}
|
||||
|
||||
return msg.toString();
|
||||
}
|
||||
public List<BaseIpCfg> checkIpCfg(StringBuffer msg,List<Map<Long,AsnGroupInfo>> asnNos, List<Object> list)
|
||||
@@ -85,14 +94,20 @@ public class CheckIpFormatThread implements Callable<String>{
|
||||
}
|
||||
boolean canIPv4 = ipType.indexOf("4") > -1;
|
||||
boolean canIPv6 = ipType.indexOf("6") > -1;
|
||||
String ipPattern = regionDict.getConfigIpPattern();
|
||||
if (StringUtils.isBlank(ipPattern)) {
|
||||
String[] ipPattern = regionDict.getConfigIpPattern().split(";");
|
||||
Assert.isTrue(ipPattern!=null&&ipPattern.length==2);
|
||||
String srcIpPattern = ipPattern[0];
|
||||
String destIpPattern = ipPattern[1];
|
||||
if (StringUtils.isBlank(srcIpPattern)||StringUtils.isBlank(destIpPattern)) {
|
||||
throw new RuntimeException("Found IP region,but ipPattern is Empty");
|
||||
}
|
||||
boolean canIPFormat = ipType.indexOf("3") > -1;
|
||||
boolean canIPSubnetFormat = ipType.indexOf("1") > -1;
|
||||
boolean canIPRangeFormat = ipType.indexOf("2") > -1;
|
||||
String portPattern = regionDict.getConfigPortPattern();
|
||||
String[] portPattern = regionDict.getConfigPortPattern().split(";");
|
||||
Assert.isTrue(ipPattern!=null&&ipPattern.length==2);
|
||||
String srcPortPattern=portPattern[0];
|
||||
String destPortPattern=portPattern[1];
|
||||
String protocol = regionDict.getConfigProtocol();
|
||||
String direction = regionDict.getConfigDirection();
|
||||
StringBuffer errTip = new StringBuffer();
|
||||
@@ -123,20 +138,19 @@ public class CheckIpFormatThread implements Callable<String>{
|
||||
// doLog属性检验
|
||||
this.validDoLog(baseIpCfg,errInfo);
|
||||
|
||||
if(regionDict.getFunctionId().equals(200)) {
|
||||
if(!serviceDict.getAction().equals(1)) {
|
||||
baseIpCfg.setDoLog(0);
|
||||
}
|
||||
}
|
||||
// doLog属性检验
|
||||
this.validDoLog(baseIpCfg,errInfo);
|
||||
|
||||
// 特殊字段验证
|
||||
// packet ip ratelimit
|
||||
if (serviceDict!=null&&serviceDict.getFunctionId().intValue() == 5 && serviceDict.getAction().intValue() == 64) {
|
||||
if (serviceDict!=null && serviceDict.getAction().intValue() == 64 && (serviceDict.getFunctionId().intValue() == 5
|
||||
|| serviceDict.getFunctionId().intValue() == 63
|
||||
|| serviceDict.getFunctionId().intValue() == 407
|
||||
|| serviceDict.getFunctionId().intValue() == 408) ) {
|
||||
String userRegion1 = IpRateLimitTemplate.userRegion1;
|
||||
baseIpCfg.setUserRegion1(userRegion1);
|
||||
if("0".equals(userRegion1)) {
|
||||
if(StringUtils.isBlank(baseIpCfg.getUserRegion2())) {
|
||||
baseIpCfg.setUserRegion2("0.1");
|
||||
}
|
||||
String userRegion2 = baseIpCfg.getUserRegion2();
|
||||
try {
|
||||
// Double ratelimt= Double.parseDouble(userRegion2);
|
||||
@@ -253,11 +267,7 @@ public class CheckIpFormatThread implements Callable<String>{
|
||||
}
|
||||
if (regionDict.getFunctionId().equals(600)) {//asn
|
||||
String organization=baseIpCfg.getOrganization();
|
||||
if(StringUtils.isBlank(organization)) {
|
||||
errInfo.append(
|
||||
String.format(prop.getProperty("can_not_null"), prop.getProperty("organization","Organization"))
|
||||
+ ";");
|
||||
}else {
|
||||
if(!StringUtils.isBlank(organization)) {
|
||||
if(organization.length() > 1024){
|
||||
errInfo.append(prop.getProperty("asn_name")+prop.getProperty("length_error")+" "+String.format(prop.getProperty("max_length")+":1024") + ";");
|
||||
}else {
|
||||
@@ -266,14 +276,9 @@ public class CheckIpFormatThread implements Callable<String>{
|
||||
}
|
||||
baseIpCfg.setOrganization(organization.trim().toUpperCase());
|
||||
}
|
||||
|
||||
}
|
||||
String country=baseIpCfg.getCountry();
|
||||
if(StringUtils.isBlank(country)) {
|
||||
errInfo.append(
|
||||
String.format(prop.getProperty("can_not_null"), prop.getProperty("country"))
|
||||
+ ";");
|
||||
}else {
|
||||
if(!StringUtils.isBlank(country)) {
|
||||
if(country.length() > 512){
|
||||
errInfo.append(prop.getProperty("country_code")+prop.getProperty("length_error")+" "+String.format(prop.getProperty("max_length")+":512") + ";");
|
||||
}else {
|
||||
@@ -281,11 +286,7 @@ public class CheckIpFormatThread implements Callable<String>{
|
||||
}
|
||||
}
|
||||
String detail=baseIpCfg.getDetail();
|
||||
if(StringUtils.isBlank(detail)) {
|
||||
errInfo.append(
|
||||
String.format(prop.getProperty("can_not_null"), prop.getProperty("detail"))
|
||||
+ ";");
|
||||
}else {
|
||||
if(!StringUtils.isBlank(detail)) {
|
||||
if(detail.length() > 1024||detail.length()<4){
|
||||
errInfo.append(prop.getProperty("details")+prop.getProperty("length_error")+" "+String.format(prop.getProperty("min_length")+":4,"+prop.getProperty("max_length")+":1024") + ";");
|
||||
}else {
|
||||
@@ -297,7 +298,7 @@ public class CheckIpFormatThread implements Callable<String>{
|
||||
if(StringUtils.isBlank(userRegion1)) {
|
||||
errInfo.append(
|
||||
String.format(prop.getProperty("can_not_null"), prop.getProperty("asn_no"))
|
||||
+ ";");
|
||||
+ ";org:"+baseIpCfg.getOrganization()+ ";asn:"+baseIpCfg.getOrganization()+ ";ip:"+baseIpCfg.getDestIpAddress());
|
||||
}else {
|
||||
try {
|
||||
Long asnNo=Long.parseLong(userRegion1);
|
||||
@@ -306,17 +307,21 @@ public class CheckIpFormatThread implements Callable<String>{
|
||||
String.format(prop.getProperty("must_between"),"1","4294967295" )
|
||||
+ ";");
|
||||
}else {
|
||||
if(StringUtil.isEmpty(baseIpCfg.getOrganization())){
|
||||
baseIpCfg.setOrganization(asnNo.toString());
|
||||
baseIpCfg.setCfgDesc(asnNo.toString());
|
||||
}
|
||||
// ConfigGroupInfo configGroupInfo=asnIpCfgService.getConfigGroupInfoByAsnNo(asnNo);
|
||||
if(asnNos!=null) {
|
||||
AsnGroupInfo configGroupInfo=asnGroupInfos==null?null:asnGroupInfos.get(asnNo);//从缓存中取
|
||||
//缓存中没有
|
||||
if(configGroupInfo==null) {
|
||||
synchronized (Constants.IMPORT_LOCK) {
|
||||
if(StringUtils.isNotBlank(baseIpCfg.getOrganization())&&StringUtils.isNotBlank(baseIpCfg.getCountry())) {
|
||||
if(StringUtils.isNotBlank(baseIpCfg.getOrganization())) {
|
||||
AsnGroupInfo groupInfo=new AsnGroupInfo();
|
||||
groupInfo.setOrganization(baseIpCfg.getOrganization().trim().toUpperCase());
|
||||
groupInfo.setCountry(baseIpCfg.getCountry().trim().toUpperCase());
|
||||
groupInfo.setDetail(baseIpCfg.getDetail().trim());
|
||||
groupInfo.setCountry(StringUtil.isEmpty(baseIpCfg.getCountry()) ? "":baseIpCfg.getCountry().trim().toUpperCase());
|
||||
groupInfo.setDetail(StringUtil.isEmpty(baseIpCfg.getDetail()) ? "":baseIpCfg.getDetail().trim());
|
||||
groupInfo.setIsValid(0);
|
||||
groupInfo.setAsnId(asnNo);
|
||||
if(asnNos.get(0).containsKey(asnNo)) {
|
||||
@@ -347,12 +352,8 @@ public class CheckIpFormatThread implements Callable<String>{
|
||||
if(!configGroupInfo.getOrganization().equalsIgnoreCase(baseIpCfg.getOrganization().trim())) {
|
||||
errInfo.append(prop.getProperty("organization","Organization")+" "+prop.getProperty("mismatch","Mismatch"));
|
||||
}
|
||||
if(!configGroupInfo.getCountry().equalsIgnoreCase(baseIpCfg.getCountry().trim())) {
|
||||
errInfo.append(prop.getProperty("country","Country")+" "+prop.getProperty("mismatch","Mismatch"));
|
||||
}
|
||||
if(!configGroupInfo.getDetail().equalsIgnoreCase(baseIpCfg.getDetail().trim())) {
|
||||
errInfo.append(prop.getProperty("detail","Detail")+" "+prop.getProperty("mismatch","Mismatch"));
|
||||
}
|
||||
configGroupInfo.setDetail(baseIpCfg.getDetail());
|
||||
configGroupInfo.setCountry(baseIpCfg.getCountry());
|
||||
if(StringUtils.isBlank(errInfo.toString())) {
|
||||
asnNos.get(1).put(asnNo,configGroupInfo);
|
||||
}
|
||||
@@ -453,7 +454,7 @@ public class CheckIpFormatThread implements Callable<String>{
|
||||
// 代理 HTTP(s)重定向
|
||||
if (regionDict.getFunctionId().equals(208)) {
|
||||
if(StringUtils.isBlank(baseIpCfg.getUserRegion1())) {
|
||||
baseIpCfg.setUserRegion1("301");
|
||||
baseIpCfg.setUserRegion1("302");
|
||||
}
|
||||
String userRegion1 = baseIpCfg.getUserRegion1();// 重定向应答码
|
||||
String userRegion2 = baseIpCfg.getUserRegion2();// 重定向URL
|
||||
@@ -594,6 +595,23 @@ public class CheckIpFormatThread implements Callable<String>{
|
||||
String subfix=baseIpCfg.getSrcIpAddress().split("-")[1];
|
||||
baseIpCfg.setSrcIpAddress(prefix+"-"+prefix.substring(0, prefix.lastIndexOf(".")+1)+subfix);
|
||||
}
|
||||
//Tip:判断业务是否只展示源IP列,如果是,判断源IP是否是默认值,如果是默认值,提示源IP不能是默认值
|
||||
if (configIpPortShow.indexOf("1") > -1 && configIpPortShow.indexOf("3") == -1) {// 源IP必填
|
||||
String srcIpAddress = baseIpCfg.getSrcIpAddress();
|
||||
Pattern ip4 = Constants.IPV4_IP_PATTERN;
|
||||
Pattern ip6 = Constants.IPV6_IP_PATTERN;
|
||||
Matcher ip4Matcher = ip4.matcher(srcIpAddress);
|
||||
Matcher ip6Matcher = ip6.matcher(srcIpAddress);
|
||||
if (ip4Matcher.matches() && srcIpAddress.startsWith("0.0.0.0")) {
|
||||
errInfo.append(prop.getProperty("client_ip")+" "
|
||||
+ String.format(prop.getProperty("can_not_be"), Constants.IPV4_DEFAULT_IP_VALUE)
|
||||
+ ";");
|
||||
} else if (ip6Matcher.matches() && srcIpAddress.startsWith("::")) {
|
||||
errInfo.append(prop.getProperty("client_ip")+" "
|
||||
+ String.format(prop.getProperty("can_not_be"), Constants.IPV6_DEFAULT_IP_VALUE)
|
||||
+ ";");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (StringUtils.isBlank(baseIpCfg.getDestIpAddress())) {
|
||||
destIpEmpty = true;
|
||||
@@ -605,6 +623,23 @@ public class CheckIpFormatThread implements Callable<String>{
|
||||
String subfix=baseIpCfg.getDestIpAddress().split("-")[1];
|
||||
baseIpCfg.setDestIpAddress(prefix+"-"+prefix.substring(0, prefix.lastIndexOf(".")+1)+subfix);
|
||||
}
|
||||
//Tip:判断业务是否只展示目的IP列,如果是,判断目的IP是否是默认值,如果是默认值,提示目的IP不能是默认值
|
||||
if (configIpPortShow.indexOf("3") > -1 && configIpPortShow.indexOf("1") == -1) {// 目的IP必填
|
||||
String destIpAddress = baseIpCfg.getDestIpAddress();
|
||||
Pattern ip4 = Constants.IPV4_IP_PATTERN;
|
||||
Pattern ip6 = Constants.IPV6_IP_PATTERN;
|
||||
Matcher ip4Matcher = ip4.matcher(destIpAddress);
|
||||
Matcher ip6Matcher = ip6.matcher(destIpAddress);
|
||||
if (ip4Matcher.matches() && destIpAddress.startsWith("0.0.0.0")) {
|
||||
errInfo.append(prop.getProperty("server_ip")+" "
|
||||
+ String.format(prop.getProperty("can_not_be"), Constants.IPV4_DEFAULT_IP_VALUE)
|
||||
+ ";");
|
||||
} else if (ip6Matcher.matches() && destIpAddress.startsWith("::")) {
|
||||
errInfo.append(prop.getProperty("server_ip")+" "
|
||||
+ String.format(prop.getProperty("can_not_be"), Constants.IPV6_DEFAULT_IP_VALUE)
|
||||
+ ";");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (StringUtils.isBlank(baseIpCfg.getSrcPort())) {
|
||||
srcPortEmpty = true;
|
||||
@@ -629,77 +664,49 @@ public class CheckIpFormatThread implements Callable<String>{
|
||||
prop.getProperty("server_ip", "Server IP")) + ";");
|
||||
} else if (configIpPortShow.indexOf("1") > -1) {
|
||||
String matchType = this.validIPAddress("client_ip", errInfo, baseIpCfg.getSrcIpAddress(),
|
||||
ipType, ipPattern);
|
||||
if (matchType.startsWith("IPV6")) {
|
||||
ipType, srcIpPattern);
|
||||
//设置源IP pattern
|
||||
if (matchType.endsWith("RANGE")) {
|
||||
// baseIpCfg.setSrcIpAddress(baseIpCfg.getSrcIpAddress());
|
||||
baseIpCfg.setDestIpAddress(Constants.IPV6_DEFAULT_IP_RANGE_VALUE);
|
||||
baseIpCfg.setIpPattern(2);
|
||||
if (baseIpCfg.getSrcIpAddress()
|
||||
.startsWith(Constants.IPV6_DEFAULT_IP_RANGE_VALUE.split("-")[0])) {
|
||||
errInfo.append(prop.getProperty("client_ip")+" "
|
||||
+ String.format(prop.getProperty("can_not_be"),
|
||||
Constants.IPV6_DEFAULT_IP_RANGE_VALUE.split("-")[0])
|
||||
+ ";");
|
||||
}
|
||||
baseIpCfg.setSrcIpPattern(2);
|
||||
} else if (matchType.endsWith("SUBNET")) {
|
||||
// baseIpCfg.setSrcIpAddress(baseIpCfg.getSrcIpAddress());
|
||||
baseIpCfg.setDestIpAddress(Constants.IPV6_DEFAULT_IP_SUBNET_VALUE);
|
||||
baseIpCfg.setIpPattern(1);
|
||||
if (baseIpCfg.getSrcIpAddress()
|
||||
.startsWith(Constants.IPV6_DEFAULT_IP_SUBNET_VALUE.split("/")[0])) {
|
||||
errInfo.append(
|
||||
prop.getProperty("client_ip")+" "
|
||||
+ String.format(prop.getProperty("can_not_be"),
|
||||
Constants.IPV6_DEFAULT_IP_SUBNET_VALUE.split("/")[0])
|
||||
+ ";");
|
||||
baseIpCfg.setSrcIpPattern(1);
|
||||
}else {
|
||||
baseIpCfg.setSrcIpPattern(3);
|
||||
}
|
||||
} else {
|
||||
// baseIpCfg.setSrcIpAddress(baseIpCfg.getSrcIpAddress());
|
||||
if (matchType.startsWith("IPV6")) {
|
||||
//设置dest ip值
|
||||
if(destIpPattern.indexOf("3")>-1) {//优先设置IP类型,因为拆分的IP较少
|
||||
baseIpCfg.setDestIpAddress(Constants.IPV6_DEFAULT_IP_VALUE);
|
||||
baseIpCfg.setIpPattern(3);
|
||||
if (baseIpCfg.getSrcIpAddress().equals(Constants.IPV6_DEFAULT_IP_VALUE)) {
|
||||
errInfo.append(prop.getProperty("client_ip")+" " + String.format(
|
||||
prop.getProperty("can_not_be"), Constants.IPV6_DEFAULT_IP_VALUE) + ";");
|
||||
}
|
||||
baseIpCfg.setDestIpPattern(3);
|
||||
}else if(destIpPattern.indexOf("1")>-1) {
|
||||
baseIpCfg.setDestIpAddress(Constants.IPV6_DEFAULT_IP_SUBNET_VALUE);
|
||||
baseIpCfg.setDestIpPattern(1);
|
||||
}else {
|
||||
baseIpCfg.setDestIpAddress(Constants.IPV6_DEFAULT_IP_RANGE_VALUE);
|
||||
baseIpCfg.setDestIpPattern(2);
|
||||
}
|
||||
//设置IP类型
|
||||
baseIpCfg.setIpType(6);
|
||||
} else {
|
||||
if (matchType.endsWith("RANGE")) {
|
||||
this.validIPv4Range("client_ip", errInfo, baseIpCfg.getSrcIpAddress());
|
||||
// baseIpCfg.setSrcIpAddress("0.0.0.0-"+baseIpCfg.getSrcIpAddress().split("-")[0].substring(0,baseIpCfg.getSrcIpAddress().indexOf("-")+1)+baseIpCfg.getSrcIpAddress().split("-")[1]);
|
||||
baseIpCfg.setDestIpAddress(Constants.IPV4_DEFAULT_IP_RANGE_VALUE);
|
||||
baseIpCfg.setIpPattern(2);
|
||||
if (baseIpCfg.getSrcIpAddress()
|
||||
.startsWith(Constants.IPV4_DEFAULT_IP_RANGE_VALUE.split("-")[0])) {
|
||||
errInfo.append(prop.getProperty("client_ip")+" "
|
||||
+ String.format(prop.getProperty("can_not_be"),
|
||||
Constants.IPV4_DEFAULT_IP_RANGE_VALUE.split("-")[0])
|
||||
+ ";");
|
||||
}
|
||||
} else if (matchType.endsWith("SUBNET")) {
|
||||
// baseIpCfg.setSrcIpAddress(baseIpCfg.getSrcIpAddress());
|
||||
baseIpCfg.setDestIpAddress(Constants.IPV4_DEFAULT_IP_SUBNET_VALUE);
|
||||
baseIpCfg.setIpPattern(1);
|
||||
if (baseIpCfg.getSrcIpAddress()
|
||||
.startsWith(Constants.IPV4_DEFAULT_IP_SUBNET_VALUE.split("/")[0])) {
|
||||
errInfo.append(
|
||||
prop.getProperty("client_ip")+" "
|
||||
+ String.format(prop.getProperty("can_not_be"),
|
||||
Constants.IPV4_DEFAULT_IP_SUBNET_VALUE.split("/")[0])
|
||||
+ ";");
|
||||
}
|
||||
} else {
|
||||
baseIpCfg.setSrcIpAddress(baseIpCfg.getSrcIpAddress());
|
||||
//设置dest ip值
|
||||
if(destIpPattern.indexOf("3")>-1) {//优先设置IP类型,因为拆分的IP较少
|
||||
baseIpCfg.setDestIpAddress(Constants.IPV4_DEFAULT_IP_VALUE);
|
||||
baseIpCfg.setIpPattern(3);
|
||||
if (baseIpCfg.getSrcIpAddress().equals(Constants.IPV4_DEFAULT_IP_VALUE)) {
|
||||
errInfo.append(prop.getProperty("client_ip")+" " + String.format(
|
||||
prop.getProperty("can_not_be"), Constants.IPV4_DEFAULT_IP_VALUE) + ";");
|
||||
}
|
||||
baseIpCfg.setDestIpPattern(3);
|
||||
}else if(destIpPattern.indexOf("1")>-1) {
|
||||
baseIpCfg.setDestIpAddress(Constants.IPV4_DEFAULT_IP_SUBNET_VALUE);
|
||||
baseIpCfg.setDestIpPattern(1);
|
||||
}else {
|
||||
baseIpCfg.setDestIpAddress(Constants.IPV4_DEFAULT_IP_RANGE_VALUE);
|
||||
baseIpCfg.setDestIpPattern(2);
|
||||
}
|
||||
baseIpCfg.setIpType(4);
|
||||
}
|
||||
//Tip:增加源IP和目的IP是否相等,如果相等,提示目的IP不能为空
|
||||
if ((configIpPortShow.indexOf("3") > -1 && configIpPortShow.indexOf("1") > -1)
|
||||
&& (baseIpCfg.getDestIpAddress().equals(baseIpCfg.getSrcIpAddress()))) {
|
||||
errInfo.append(String.format(prop.getProperty("can_not_null"),
|
||||
prop.getProperty("server_ip", "Server IP")) + ";");
|
||||
}
|
||||
}
|
||||
|
||||
} else if (srcIpEmpty) {// 源IP为空
|
||||
@@ -708,166 +715,175 @@ public class CheckIpFormatThread implements Callable<String>{
|
||||
prop.getProperty("client_ip", "Client IP")) + ";");
|
||||
} else if (configIpPortShow.indexOf("3") > -1) {
|
||||
String matchType = this.validIPAddress("server_ip", errInfo, baseIpCfg.getDestIpAddress(),
|
||||
ipType, ipPattern);
|
||||
if (matchType.startsWith("IPV6")) {
|
||||
ipType, destIpPattern);
|
||||
if (matchType.endsWith("RANGE")) {
|
||||
// baseIpCfg.setDestIpAddress(baseIpCfg.getDestIpAddress());
|
||||
baseIpCfg.setSrcIpAddress(Constants.IPV6_DEFAULT_IP_RANGE_VALUE);
|
||||
baseIpCfg.setIpPattern(2);
|
||||
if (baseIpCfg.getDestIpAddress()
|
||||
.startsWith(Constants.IPV6_DEFAULT_IP_RANGE_VALUE.split("-")[0])) {
|
||||
errInfo.append(prop.getProperty("server_ip")+" "
|
||||
+ String.format(prop.getProperty("can_not_be"),
|
||||
Constants.IPV6_DEFAULT_IP_RANGE_VALUE.split("-")[0])
|
||||
+ ";");
|
||||
}
|
||||
baseIpCfg.setDestIpPattern(2);
|
||||
} else if (matchType.endsWith("SUBNET")) {
|
||||
// baseIpCfg.setDestIpAddress(baseIpCfg.getDestIpAddress());
|
||||
baseIpCfg.setSrcIpAddress(Constants.IPV6_DEFAULT_IP_SUBNET_VALUE);
|
||||
baseIpCfg.setIpPattern(1);
|
||||
if (baseIpCfg.getDestIpAddress()
|
||||
.startsWith(Constants.IPV6_DEFAULT_IP_SUBNET_VALUE.split("/")[0])) {
|
||||
errInfo.append(
|
||||
prop.getProperty("server_ip")+" "
|
||||
+ String.format(prop.getProperty("can_not_be"),
|
||||
Constants.IPV6_DEFAULT_IP_SUBNET_VALUE.split("/")[0])
|
||||
+ ";");
|
||||
baseIpCfg.setDestIpPattern(1);
|
||||
}else {
|
||||
baseIpCfg.setDestIpPattern(3);
|
||||
}
|
||||
} else {
|
||||
// baseIpCfg.setDestIpAddress(baseIpCfg.getDestIpAddress());
|
||||
if (matchType.startsWith("IPV6")) {
|
||||
if(srcIpPattern.indexOf("3")>-1) {
|
||||
baseIpCfg.setSrcIpAddress(Constants.IPV6_DEFAULT_IP_VALUE);
|
||||
baseIpCfg.setIpPattern(3);
|
||||
if (baseIpCfg.getDestIpAddress().equals(Constants.IPV6_DEFAULT_IP_VALUE)) {
|
||||
errInfo.append(prop.getProperty("server_ip")+" " + String.format(
|
||||
prop.getProperty("can_not_be"), Constants.IPV6_DEFAULT_IP_VALUE) + ";");
|
||||
}
|
||||
baseIpCfg.setSrcIpPattern(3);
|
||||
}else if(srcIpPattern.indexOf("1")>-1) {
|
||||
baseIpCfg.setSrcIpAddress(Constants.IPV6_DEFAULT_IP_SUBNET_VALUE);
|
||||
baseIpCfg.setSrcIpPattern(1);
|
||||
}else {
|
||||
baseIpCfg.setSrcIpAddress(Constants.IPV6_DEFAULT_IP_RANGE_VALUE);
|
||||
baseIpCfg.setSrcIpPattern(2);
|
||||
}
|
||||
baseIpCfg.setIpType(6);
|
||||
} else {
|
||||
if (matchType.endsWith("RANGE")) {
|
||||
this.validIPv4Range("server_ip", errInfo, baseIpCfg.getDestIpAddress());
|
||||
// baseIpCfg.setDestIpAddress("0.0.0.0-"+baseIpCfg.getDestIpAddress().split("-")[0]
|
||||
// .substring(0,baseIpCfg.getDestIpAddress().indexOf("-")+1)
|
||||
// +baseIpCfg.getDestIpAddress().split("-")[1]);
|
||||
baseIpCfg.setSrcIpAddress(Constants.IPV4_DEFAULT_IP_RANGE_VALUE);
|
||||
baseIpCfg.setIpPattern(2);
|
||||
if (baseIpCfg.getDestIpAddress()
|
||||
.startsWith(Constants.IPV4_DEFAULT_IP_RANGE_VALUE.split("-")[0])) {
|
||||
errInfo.append(prop.getProperty("server_ip")+" "
|
||||
+ String.format(prop.getProperty("can_not_be"),
|
||||
Constants.IPV4_DEFAULT_IP_RANGE_VALUE.split("-")[0])
|
||||
+ ";");
|
||||
}
|
||||
} else if (matchType.endsWith("SUBNET")) {
|
||||
// baseIpCfg.setDestIpAddress(baseIpCfg.getDestIpAddress());
|
||||
baseIpCfg.setSrcIpAddress(Constants.IPV4_DEFAULT_IP_SUBNET_VALUE);
|
||||
baseIpCfg.setIpPattern(1);
|
||||
if (baseIpCfg.getDestIpAddress()
|
||||
.startsWith(Constants.IPV4_DEFAULT_IP_SUBNET_VALUE.split("/")[0])) {
|
||||
errInfo.append(
|
||||
prop.getProperty("server_ip")+" "
|
||||
+ String.format(prop.getProperty("can_not_be"),
|
||||
Constants.IPV4_DEFAULT_IP_SUBNET_VALUE.split("/")[0])
|
||||
+ ";");
|
||||
}
|
||||
} else {
|
||||
// baseIpCfg.setDestIpAddress(baseIpCfg.getDestIpAddress());
|
||||
if(srcIpPattern.indexOf("3")>-1) {
|
||||
baseIpCfg.setSrcIpAddress(Constants.IPV4_DEFAULT_IP_VALUE);
|
||||
baseIpCfg.setIpPattern(3);
|
||||
if (baseIpCfg.getDestIpAddress().equals(Constants.IPV4_DEFAULT_IP_VALUE)) {
|
||||
errInfo.append(prop.getProperty("server_ip")+" " + String.format(
|
||||
prop.getProperty("can_not_be"), Constants.IPV4_DEFAULT_IP_VALUE) + ";");
|
||||
}
|
||||
baseIpCfg.setSrcIpPattern(3);
|
||||
}else if(srcIpPattern.indexOf("1")>-1) {
|
||||
baseIpCfg.setSrcIpAddress(Constants.IPV4_DEFAULT_IP_SUBNET_VALUE);
|
||||
baseIpCfg.setSrcIpPattern(1);
|
||||
}else {
|
||||
baseIpCfg.setSrcIpAddress(Constants.IPV4_DEFAULT_IP_RANGE_VALUE);
|
||||
baseIpCfg.setSrcIpPattern(2);
|
||||
}
|
||||
baseIpCfg.setIpType(4);
|
||||
}
|
||||
//Tip:增加源IP和目的IP是否相等,如果相等,提示源的IP不能为空
|
||||
if ((configIpPortShow.indexOf("3") > -1 && configIpPortShow.indexOf("1") > -1)
|
||||
&& (baseIpCfg.getSrcIpAddress().equals(baseIpCfg.getDestIpAddress()))) {
|
||||
errInfo.append(String.format(prop.getProperty("can_not_null"),
|
||||
prop.getProperty("client_ip", "Client IP")) + ";");
|
||||
}
|
||||
}
|
||||
} else {// 全不为空
|
||||
String matchType = this.validIPAddress("client_ip", errInfo, baseIpCfg.getSrcIpAddress(), ipType,
|
||||
ipPattern);
|
||||
String matchType1 = this.validIPAddress("server_ip", errInfo, baseIpCfg.getDestIpAddress(), ipType,
|
||||
ipPattern);
|
||||
if (StringUtils.isNotBlank(matchType) && StringUtils.isNotBlank(matchType1)
|
||||
&& !matchType.equals(matchType1)) {
|
||||
errInfo.append(prop.get("the_same_ip_type_pattern") + ";");
|
||||
String srcMatchType = this.validIPAddress("client_ip", errInfo, baseIpCfg.getSrcIpAddress(), ipType,
|
||||
srcIpPattern);
|
||||
String destMatchType = this.validIPAddress("server_ip", errInfo, baseIpCfg.getDestIpAddress(), ipType,
|
||||
destIpPattern);
|
||||
if (StringUtils.isNotBlank(srcMatchType) && StringUtils.isNotBlank(destMatchType)
|
||||
&& ((srcMatchType.startsWith("IPV6")&&destMatchType.startsWith("IPV4"))
|
||||
||(srcMatchType.startsWith("IPV4")&&destMatchType.startsWith("IPV6")))) {
|
||||
errInfo.append(prop.get("the_same_ip_type") + ";");
|
||||
}
|
||||
// baseIpCfg.setSrcIpAddress(baseIpCfg.getSrcIpAddress());
|
||||
// baseIpCfg.setDestIpAddress(baseIpCfg.getDestIpAddress());
|
||||
if (matchType.startsWith("IPV6")) {
|
||||
if (srcMatchType.startsWith("IPV6")) {
|
||||
baseIpCfg.setIpType(6);
|
||||
} else {
|
||||
baseIpCfg.setIpType(4);
|
||||
}
|
||||
if (matchType.endsWith("RANGE")) {
|
||||
if (matchType.startsWith("IPV4")) {
|
||||
if (srcMatchType.endsWith("RANGE")) {
|
||||
baseIpCfg.setSrcIpPattern(2);
|
||||
}else if(srcMatchType.endsWith("SUBNET")) {
|
||||
baseIpCfg.setSrcIpPattern(1);
|
||||
}else {
|
||||
baseIpCfg.setSrcIpPattern(3);
|
||||
}
|
||||
if (destMatchType.endsWith("RANGE")) {
|
||||
baseIpCfg.setDestIpPattern(2);
|
||||
}else if(destMatchType.endsWith("SUBNET")) {
|
||||
baseIpCfg.setDestIpPattern(1);
|
||||
}else {
|
||||
baseIpCfg.setDestIpPattern(3);
|
||||
}
|
||||
if(baseIpCfg.getIpType().equals(4)) {
|
||||
if (srcMatchType.endsWith("RANGE")) {
|
||||
this.validIPv4Range("client_ip", errInfo, baseIpCfg.getSrcIpAddress());
|
||||
}
|
||||
if (destMatchType.endsWith("RANGE")) {
|
||||
this.validIPv4Range("server_ip", errInfo, baseIpCfg.getDestIpAddress());
|
||||
}
|
||||
|
||||
if (baseIpCfg.getSrcIpAddress().split("-")[0]
|
||||
.equals(baseIpCfg.getDestIpAddress().split("-")[0])) {
|
||||
//验证Ip范围
|
||||
if(StringUtils.isEmpty(errInfo)&&(srcMatchType.endsWith("RANGE")||destMatchType.endsWith("RANGE"))) {
|
||||
this.ValidateRangeCross(baseIpCfg.getSrcIpAddress(),baseIpCfg.getDestIpAddress(), errInfo);
|
||||
}
|
||||
}
|
||||
boolean same=false;
|
||||
if(baseIpCfg.getSrcIpAddress().indexOf("-")>-1) {
|
||||
if(baseIpCfg.getDestIpAddress().indexOf("-")>-1) {
|
||||
if(baseIpCfg.getSrcIpAddress().split("-")[0].equals(baseIpCfg.getDestIpAddress().split("-")[0])) {
|
||||
same=true;
|
||||
}
|
||||
}else if(baseIpCfg.getDestIpAddress().indexOf("/")>-1) {
|
||||
if(baseIpCfg.getSrcIpAddress().split("-")[0].equals(baseIpCfg.getDestIpAddress().split("/")[0])) {
|
||||
same=true;
|
||||
}
|
||||
}else {
|
||||
if(baseIpCfg.getSrcIpAddress().split("-")[0].equals(baseIpCfg.getDestIpAddress())) {
|
||||
same=true;
|
||||
}
|
||||
}
|
||||
}else if(baseIpCfg.getSrcIpAddress().indexOf("/")>-1){
|
||||
if(baseIpCfg.getDestIpAddress().indexOf("-")>-1) {
|
||||
if(baseIpCfg.getSrcIpAddress().split("/")[0].equals(baseIpCfg.getDestIpAddress().split("-")[0])) {
|
||||
same=true;
|
||||
}
|
||||
}else if(baseIpCfg.getDestIpAddress().indexOf("/")>-1) {
|
||||
if(baseIpCfg.getSrcIpAddress().split("/")[0].equals(baseIpCfg.getDestIpAddress().split("/")[0])) {
|
||||
same=true;
|
||||
}
|
||||
}else {
|
||||
if(baseIpCfg.getSrcIpAddress().split("/")[0].equals(baseIpCfg.getDestIpAddress())) {
|
||||
same=true;
|
||||
}
|
||||
}
|
||||
}else {
|
||||
if(baseIpCfg.getDestIpAddress().indexOf("-")>-1) {
|
||||
if(baseIpCfg.getSrcIpAddress().equals(baseIpCfg.getDestIpAddress().split("-")[0])) {
|
||||
same=true;
|
||||
}
|
||||
}else if(baseIpCfg.getDestIpAddress().indexOf("/")>-1) {
|
||||
if(baseIpCfg.getSrcIpAddress().equals(baseIpCfg.getDestIpAddress().split("/")[0])) {
|
||||
same=true;
|
||||
}
|
||||
}else {
|
||||
if(baseIpCfg.getSrcIpAddress().equals(baseIpCfg.getDestIpAddress())) {
|
||||
same=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(same) {
|
||||
errInfo.append(String.format(prop.getProperty("are_the_same"),
|
||||
baseIpCfg.getSrcIpAddress().split("-")[0],
|
||||
baseIpCfg.getDestIpAddress().split("-")[0]) + ";");
|
||||
}
|
||||
baseIpCfg.setIpPattern(2);
|
||||
} else if (matchType.endsWith("SUBNET")) {
|
||||
if (baseIpCfg.getSrcIpAddress().split("/")[0]
|
||||
.equals(baseIpCfg.getDestIpAddress().split("/")[0])) {
|
||||
errInfo.append(String.format(prop.getProperty("are_the_same"),
|
||||
baseIpCfg.getSrcIpAddress().split("/")[0],
|
||||
baseIpCfg.getDestIpAddress().split("/")[0]) + ";");
|
||||
}
|
||||
baseIpCfg.setIpPattern(1);
|
||||
} else {
|
||||
if (baseIpCfg.getSrcIpAddress().equals(baseIpCfg.getDestIpAddress())) {
|
||||
errInfo.append(String.format(prop.getProperty("are_the_same"),
|
||||
prop.getProperty("client_ip"), prop.getProperty("server_ip")) + ";");
|
||||
}
|
||||
baseIpCfg.setIpPattern(3);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO 判断源IP和目的IP的值
|
||||
// TODO 判断源IP和目的IP格式
|
||||
if (destPortEmpty) {
|
||||
if (srcPortEmpty) {
|
||||
if(srcPortPattern.indexOf("1")>-1) {
|
||||
baseIpCfg.setSrcPort("0");
|
||||
baseIpCfg.setDestPort("0");
|
||||
baseIpCfg.setPortPattern(1);
|
||||
} else {
|
||||
if (baseIpCfg.getSrcPort().indexOf("/") > -1) {
|
||||
baseIpCfg.setDestPort("0/0");
|
||||
baseIpCfg.setPortPattern(2);
|
||||
} else {
|
||||
baseIpCfg.setDestPort("0");
|
||||
baseIpCfg.setPortPattern(1);
|
||||
}
|
||||
baseIpCfg.setSrcPort(baseIpCfg.getSrcPort().trim());
|
||||
}
|
||||
} else {
|
||||
if (srcPortEmpty) {
|
||||
if (baseIpCfg.getDestPort().indexOf("/") > -1) {
|
||||
baseIpCfg.setSrcPortPattern(1);
|
||||
}else {
|
||||
baseIpCfg.setSrcPort("0/0");
|
||||
baseIpCfg.setPortPattern(2);
|
||||
} else {
|
||||
baseIpCfg.setSrcPort("0");
|
||||
baseIpCfg.setPortPattern(1);
|
||||
baseIpCfg.setSrcPortPattern(2);
|
||||
}
|
||||
} else {
|
||||
if (baseIpCfg.getSrcPort().indexOf("/") > -1) {
|
||||
baseIpCfg.setPortPattern(2);
|
||||
} else {
|
||||
baseIpCfg.setPortPattern(1);
|
||||
}else if(baseIpCfg.getSrcPort().indexOf("/")>-1) {
|
||||
baseIpCfg.setSrcPortPattern(2);
|
||||
}else {
|
||||
baseIpCfg.setSrcPortPattern(1);
|
||||
}
|
||||
baseIpCfg.setSrcPort(baseIpCfg.getSrcPort().trim());
|
||||
boolean validSrcPort = this.validPort(errInfo, baseIpCfg.getSrcPort(),
|
||||
srcPortPattern,"client_port");
|
||||
if (destPortEmpty) {
|
||||
if(destPortPattern.indexOf("1")>-1) {
|
||||
baseIpCfg.setDestPort("0");
|
||||
baseIpCfg.setDestPortPattern(1);
|
||||
}else {
|
||||
baseIpCfg.setDestPort("0/0");
|
||||
baseIpCfg.setDestPortPattern(2);
|
||||
}
|
||||
}else if(baseIpCfg.getDestPort().indexOf("/")>-1) {
|
||||
baseIpCfg.setDestPortPattern(2);
|
||||
}else {
|
||||
baseIpCfg.setDestPortPattern(1);
|
||||
}
|
||||
baseIpCfg.setDestPort(baseIpCfg.getDestPort().trim());
|
||||
}
|
||||
// TODO 判断源端口和目的端口格式
|
||||
// TODO 判断源和目的端口的值
|
||||
boolean validPort = this.validPort(errInfo, baseIpCfg.getSrcPort(), baseIpCfg.getDestPort(),
|
||||
portPattern);
|
||||
boolean validDestPort = this.validPort(errInfo, baseIpCfg.getDestPort(),
|
||||
srcPortPattern,"server_port");
|
||||
|
||||
if (baseIpCfg.getProtocol()==null) {
|
||||
//packet ip reject
|
||||
if(regionDict.getFunctionId().equals(5)&&serviceDict!=null&&serviceDict.getServiceId().equals(16)) {
|
||||
@@ -909,7 +925,7 @@ public class CheckIpFormatThread implements Callable<String>{
|
||||
}
|
||||
boolean validProtocol = this.validProtocol(errInfo, baseIpCfg.getProtocol(), protocol);
|
||||
// 验证protocol与port是否符合逻辑
|
||||
if (validProtocol && validPort) {
|
||||
if (validProtocol && validSrcPort&&validDestPort) {
|
||||
validProtocolAndPort(errInfo, baseIpCfg.getProtocol(), baseIpCfg.getSrcPort(),
|
||||
baseIpCfg.getDestPort());
|
||||
}
|
||||
@@ -932,6 +948,10 @@ public class CheckIpFormatThread implements Callable<String>{
|
||||
// TODO 判断Direction的值
|
||||
this.validDirection(errInfo, baseIpCfg.getDirection(), direction);
|
||||
}
|
||||
|
||||
//IP校验
|
||||
// this.validSrcAndDescIp(baseIpCfg.getSrcIpAddress(), baseIpCfg.getDestIpAddress(), configIpPortShow,errInfo);
|
||||
|
||||
if (errInfo.toString().length() > 0) {//
|
||||
errTip.append(String.format(prop.getProperty("line"), baseIpCfg.getIndex()) + ",");
|
||||
errTip.append(errInfo);
|
||||
@@ -1038,153 +1058,85 @@ public class CheckIpFormatThread implements Callable<String>{
|
||||
* @param portPattern
|
||||
* @throws ServiceException
|
||||
*/
|
||||
public boolean validPort(StringBuffer errInfo, String srcPortStr, String destPortStr, String portPattern)
|
||||
public boolean validPort(StringBuffer errInfo, String portStr, String portPattern,String portName)
|
||||
throws ServiceException {
|
||||
boolean valid = true;
|
||||
if (portPattern.equals("1")) {
|
||||
try {
|
||||
Integer srcPort = Integer.parseInt(srcPortStr);
|
||||
Integer srcPort = Integer.parseInt(portStr);
|
||||
if (srcPort < 0 || srcPort > 65535) {
|
||||
errInfo.append(prop.getProperty("client_port")
|
||||
errInfo.append(prop.getProperty(portName)
|
||||
+ String.format(prop.getProperty("must_between"), 0, 65535) + ";");
|
||||
valid = false;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
errInfo.append(String.format(prop.getProperty("not_number"), prop.getProperty("client_port")) + ";");
|
||||
valid = false;
|
||||
}
|
||||
try {
|
||||
Integer destPort = Integer.parseInt(destPortStr);
|
||||
if (destPort < 0 || destPort > 65535) {
|
||||
errInfo.append(prop.getProperty("server_port")
|
||||
+ String.format(prop.getProperty("must_between"), 0, 65535) + ";");
|
||||
valid = false;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
errInfo.append(String.format(prop.getProperty("not_number"), prop.getProperty("server_port")) + ";");
|
||||
errInfo.append(String.format(prop.getProperty("not_number"), prop.getProperty(portName)) + ";");
|
||||
valid = false;
|
||||
}
|
||||
|
||||
} else if (portPattern.equals("2")) {
|
||||
Pattern p = Constants.PORT_MASK_PATTERN;
|
||||
Matcher m = p.matcher(srcPortStr);
|
||||
Matcher m = p.matcher(portStr);
|
||||
if (!m.matches()) {
|
||||
errInfo.append(
|
||||
String.format(prop.getProperty("is_in_wrong_format"), prop.getProperty("client_port")) + ";");
|
||||
String.format(prop.getProperty("is_in_wrong_format"), prop.getProperty(portName)) + ";");
|
||||
valid = false;
|
||||
}
|
||||
m = p.matcher(destPortStr);
|
||||
if (!m.matches()) {
|
||||
errInfo.append(
|
||||
String.format(prop.getProperty("is_in_wrong_format"), prop.getProperty("server_port")) + ";");
|
||||
valid = false;
|
||||
}
|
||||
Integer srcPort = Integer.parseInt(srcPortStr.split("/")[0]);
|
||||
Integer srcPortMask = Integer.parseInt(srcPortStr.split("/")[1]);
|
||||
Integer destPort = Integer.parseInt(destPortStr.split("/")[0]);
|
||||
Integer destPortMask = Integer.parseInt(destPortStr.split("/")[1]);
|
||||
if (srcPort < 0 || srcPort > 65535) {
|
||||
errInfo.append(prop.getProperty("client_port")
|
||||
|
||||
Integer port = Integer.parseInt(portStr.split("/")[0]);
|
||||
Integer portMask = Integer.parseInt(portStr.split("/")[1]);
|
||||
|
||||
if (port < 0 || port > 65535) {
|
||||
errInfo.append(prop.getProperty(portName)
|
||||
+ String.format(prop.getProperty("must_between"), 0, 65535) + ";");
|
||||
valid = false;
|
||||
}
|
||||
if (srcPortMask < 0 || srcPortMask > 65535) {
|
||||
errInfo.append(prop.getProperty("client_port_mask")
|
||||
+ String.format(prop.getProperty("must_between"), 0, 65535) + ";");
|
||||
valid = false;
|
||||
}
|
||||
if (destPort < 0 || destPort > 65535) {
|
||||
errInfo.append(prop.getProperty("server_port")
|
||||
+ String.format(prop.getProperty("must_between"), 0, 65535) + ";");
|
||||
valid = false;
|
||||
}
|
||||
if (destPortMask < 0 || destPortMask > 65535) {
|
||||
errInfo.append(prop.getProperty("server_port_mask")
|
||||
if (portMask < 0 || portMask > 65535) {
|
||||
errInfo.append(prop.getProperty(portName+"_mask")
|
||||
+ String.format(prop.getProperty("must_between"), 0, 65535) + ";");
|
||||
valid = false;
|
||||
}
|
||||
|
||||
} else if (portPattern.indexOf("1") > -1 && portPattern.indexOf("2") > -1) {
|
||||
Pattern p = Constants.PORT_MASK_PATTERN;
|
||||
Pattern p1 = Constants.PORT_PATTERN;
|
||||
Matcher m = p.matcher(srcPortStr);// 源端口是端口掩码格式
|
||||
Matcher m1 = p.matcher(destPortStr);// 目的端口是端口掩码格式
|
||||
Matcher m2 = p1.matcher(srcPortStr);// 源端口是端口格式
|
||||
Matcher m3 = p1.matcher(destPortStr);// 目的端口是端口格式
|
||||
Matcher m = p.matcher(portStr);// 源端口是端口掩码格式
|
||||
Matcher m2 = p1.matcher(portStr);// 源端口是端口格式
|
||||
if (m.matches()) {
|
||||
Integer srcPort = Integer.parseInt(srcPortStr.split("/")[0]);
|
||||
Integer srcPortMask = Integer.parseInt(srcPortStr.split("/")[1]);
|
||||
Integer srcPort = Integer.parseInt(portStr.split("/")[0]);
|
||||
Integer srcPortMask = Integer.parseInt(portStr.split("/")[1]);
|
||||
if (srcPort < 0 || srcPort > 65535) {
|
||||
errInfo.append(prop.getProperty("client_port")
|
||||
errInfo.append(prop.getProperty(portName)
|
||||
+ String.format(prop.getProperty("must_between"), 0, 65535) + ";");
|
||||
valid = false;
|
||||
}
|
||||
if (srcPortMask < 0 || srcPortMask > 65535) {
|
||||
errInfo.append(prop.getProperty("client_port_mask")
|
||||
+ String.format(prop.getProperty("must_between"), 0, 65535) + ";");
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
if (m1.matches()) {
|
||||
Integer destPort = Integer.parseInt(destPortStr.split("/")[0]);
|
||||
Integer destPortMask = Integer.parseInt(destPortStr.split("/")[1]);
|
||||
|
||||
if (destPort < 0 || destPort > 65535) {
|
||||
errInfo.append(prop.getProperty("server_port")
|
||||
+ String.format(prop.getProperty("must_between"), 0, 65535) + ";");
|
||||
valid = false;
|
||||
}
|
||||
if (destPortMask < 0 || destPortMask > 65535) {
|
||||
errInfo.append(prop.getProperty("server_port_mask")
|
||||
errInfo.append(prop.getProperty(portName+"_mask")
|
||||
+ String.format(prop.getProperty("must_between"), 0, 65535) + ";");
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
if (m2.matches()) {
|
||||
try {
|
||||
Integer srcPort = Integer.parseInt(srcPortStr);
|
||||
Integer srcPort = Integer.parseInt(portStr);
|
||||
if (srcPort < 0 || srcPort > 65535) {
|
||||
errInfo.append(prop.getProperty("client_port")
|
||||
errInfo.append(prop.getProperty(portName)
|
||||
+ String.format(prop.getProperty("must_between"), 0, 65535) + ";");
|
||||
valid = false;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
errInfo.append(
|
||||
String.format(prop.getProperty("not_number"), prop.getProperty("client_port")) + ";");
|
||||
String.format(prop.getProperty("not_number"), prop.getProperty(portName)) + ";");
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
if (m3.matches()) {
|
||||
try {
|
||||
Integer destPort = Integer.parseInt(destPortStr);
|
||||
if (destPort < 0 || destPort > 65535) {
|
||||
errInfo.append(prop.getProperty("server_port")
|
||||
+ String.format(prop.getProperty("must_between"), 0, 65535) + ";");
|
||||
valid = false;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
errInfo.append(
|
||||
String.format(prop.getProperty("not_number"), prop.getProperty("server_port")) + ";");
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
if ((m.matches() && m3.matches()) || (m2.matches() && m1.matches())) {
|
||||
errInfo.append(prop.getProperty("the_same_port_pattern") + ";");
|
||||
valid = false;
|
||||
}
|
||||
if (!m.matches() && !m2.matches()) {
|
||||
errInfo.append(
|
||||
String.format(prop.getProperty("is_in_wrong_format"), prop.getProperty("client_port")) + ";");
|
||||
String.format(prop.getProperty("is_in_wrong_format"), prop.getProperty(portName)) + ";");
|
||||
valid = false;
|
||||
}
|
||||
if (!m1.matches() && !m3.matches()) {
|
||||
errInfo.append(
|
||||
String.format(prop.getProperty("is_in_wrong_format"), prop.getProperty("server_port")) + ";");
|
||||
valid = false;
|
||||
}
|
||||
|
||||
}
|
||||
return valid;
|
||||
}
|
||||
@@ -1377,7 +1329,44 @@ public class CheckIpFormatThread implements Callable<String>{
|
||||
}
|
||||
return matchType;
|
||||
}
|
||||
|
||||
public void ValidateRangeCross(String srcIp,String destIp,StringBuffer errInfo) {
|
||||
long srcStart=0l,srcEnd=0,srcNum=0l,destStart=0l,destEnd=0l,destNum=0l;
|
||||
if(srcIp.indexOf("-")>-1) {
|
||||
String[] srcArr=srcIp.split("\\-");
|
||||
srcStart=IPUtil.getIpHostDesimal(srcArr[0]);
|
||||
srcEnd=IPUtil.getIpHostDesimal(srcArr[1]);
|
||||
}else if(srcIp.indexOf("/")>-1) {
|
||||
srcNum=IPUtil.getIpHostDesimal(srcIp.split("/")[0]);
|
||||
}else {
|
||||
srcNum=IPUtil.getIpHostDesimal(srcIp);
|
||||
}
|
||||
if(destIp.indexOf("-")>-1) {
|
||||
String[] destArr=destIp.split("\\-");
|
||||
destStart=IPUtil.getIpHostDesimal(destArr[0]);
|
||||
destEnd=IPUtil.getIpHostDesimal(destArr[1]);
|
||||
}else if(destIp.indexOf("/")>-1) {
|
||||
destNum=IPUtil.getIpHostDesimal(destIp.split("/")[0]);
|
||||
}else {
|
||||
destNum=IPUtil.getIpHostDesimal(destIp);
|
||||
}
|
||||
if(srcNum==0l) {
|
||||
if(destNum==0l) {
|
||||
if(!(destEnd<srcStart||srcEnd<destStart)) {
|
||||
errInfo.append(prop.getProperty("range_cross")+";");
|
||||
}
|
||||
}else {
|
||||
if(destNum>=srcStart&&destNum<=srcEnd) {
|
||||
errInfo.append(prop.getProperty("range_cross")+";");
|
||||
}
|
||||
}
|
||||
}else {
|
||||
if(destNum==0l) {
|
||||
if(srcNum>=destStart&&srcNum<=destEnd) {
|
||||
errInfo.append(prop.getProperty("range_cross")+";");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public List<Map<Long, AsnGroupInfo>> getAsnNoMaps() {
|
||||
return asnNoMaps;
|
||||
}
|
||||
@@ -1390,5 +1379,4 @@ public class CheckIpFormatThread implements Callable<String>{
|
||||
public void setAsnGroupInfos(Map<Long, AsnGroupInfo> asnGroupInfos) {
|
||||
this.asnGroupInfos = asnGroupInfos;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ public class CheckStringFormatThread implements Callable<String>{
|
||||
public String call() throws Exception {
|
||||
List<Object> dataList=Lists.newArrayList(Constants.MAAT_JSON_SEND_SIZE);
|
||||
StringBuffer msg=new StringBuffer();
|
||||
boolean error = false;
|
||||
while(!srcQueue.isEmpty()) {
|
||||
int size=srcQueue.drainTo(dataList,Constants.MAAT_JSON_SEND_SIZE);
|
||||
if(regionDict.getRegionType().intValue()==2) {
|
||||
@@ -55,10 +56,15 @@ public class CheckStringFormatThread implements Callable<String>{
|
||||
// TODO: handle exception
|
||||
//msg=e.getMessage();
|
||||
//break;
|
||||
error = true;
|
||||
}
|
||||
}
|
||||
dataList.clear();
|
||||
}
|
||||
if(error) {
|
||||
msg.append("validate_error");
|
||||
}
|
||||
|
||||
return msg.toString();
|
||||
}
|
||||
|
||||
@@ -84,7 +90,7 @@ public class CheckStringFormatThread implements Callable<String>{
|
||||
}
|
||||
StringBuffer errTip = new StringBuffer();
|
||||
Pattern pattern = Pattern.compile("\t|\r|\n|\b|\f");
|
||||
Pattern domainPattern = Pattern.compile(Constants.DOMAIN_REGEXP);
|
||||
Pattern domainPattern = Pattern.compile("^[a-zA-Z0-9.-]*$");
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
StringBuffer errInfo = new StringBuffer();
|
||||
BaseStringCfg baseStringCfg = new BaseStringCfg();
|
||||
@@ -199,7 +205,7 @@ public class CheckStringFormatThread implements Callable<String>{
|
||||
// 代理 HTTP(s)重定向
|
||||
if (regionDict.getFunctionId().equals(208)) {
|
||||
if(StringUtils.isBlank(baseStringCfg.getUserRegion1())) {
|
||||
baseStringCfg.setUserRegion1("301");
|
||||
baseStringCfg.setUserRegion1("302");
|
||||
}
|
||||
String userRegion1 = baseStringCfg.getUserRegion1();// 重定向应答码
|
||||
String userRegion2 = baseStringCfg.getUserRegion2();// 重定向URL
|
||||
@@ -431,7 +437,10 @@ public class CheckStringFormatThread implements Callable<String>{
|
||||
prop.getProperty("is_case_insenstive")) + ";");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}
|
||||
|
||||
isHex = baseStringCfg.getIsHex();
|
||||
isCaseInsenstive = baseStringCfg.getIsCaseInsenstive();
|
||||
if (isHex.intValue() != 0 && isHex.intValue() != 1) {
|
||||
errInfo.append(
|
||||
String.format(prop.getProperty("is_incorrect"), prop.getProperty("is_hex")) + ";");
|
||||
@@ -463,13 +472,15 @@ public class CheckStringFormatThread implements Callable<String>{
|
||||
if (hexP.indexOf("1") != -1 && isHex.intValue() == 1) {
|
||||
boolean bl = Pattern.compile("^([0-9|a-f|A-F]*)$").matcher(keyword).matches();
|
||||
if(!bl) {
|
||||
String message = prop.getProperty("key_word");
|
||||
if(regionDict.getFunctionId().equals(403) || regionDict.getFunctionId().equals(200)) {
|
||||
message = prop.getProperty("domain_name");
|
||||
}
|
||||
errInfo.append(
|
||||
prop.getProperty("key_word") + " '" + keyword + "' "+String.format(prop.getProperty("contains_non_hex_char")) + ";");
|
||||
message + " '" + keyword + "' "+String.format(prop.getProperty("contains_non_hex_char")) + ";");
|
||||
}
|
||||
}
|
||||
}
|
||||
isHex = baseStringCfg.getIsHex();
|
||||
isCaseInsenstive = baseStringCfg.getIsCaseInsenstive();
|
||||
|
||||
if (isHex != null && isCaseInsenstive != null) {
|
||||
if (isHex.intValue() == 0 && isCaseInsenstive.intValue() == 0) {
|
||||
baseStringCfg.setIsHexbin(0);
|
||||
|
||||
@@ -3,12 +3,14 @@ package com.nis.util.excel.thread;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.commons.collections.map.CaseInsensitiveMap;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.jets3t.service.ServiceException;
|
||||
@@ -20,6 +22,7 @@ import com.nis.domain.FunctionServiceDict;
|
||||
import com.nis.domain.configuration.AppTopicDomainCfg;
|
||||
import com.nis.domain.configuration.WebsiteDomainTopic;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.DictUtils;
|
||||
import com.nis.web.security.UserUtils;
|
||||
import com.nis.web.service.SpringContextHolder;
|
||||
import com.nis.web.service.configuration.AppCfgService;
|
||||
@@ -44,6 +47,7 @@ public class CheckTopicWebsiteFormatThread implements Callable<String>{
|
||||
public String call() throws Exception {
|
||||
List<Object> dataList=Lists.newArrayList(Constants.MAAT_JSON_SEND_SIZE);
|
||||
StringBuffer msg=new StringBuffer();
|
||||
boolean error = false;
|
||||
while(!srcQueue.isEmpty()) {
|
||||
int size=srcQueue.drainTo(dataList,Constants.MAAT_JSON_SEND_SIZE);
|
||||
if(regionDict.getRegionType().intValue()==2) {
|
||||
@@ -55,10 +59,15 @@ public class CheckTopicWebsiteFormatThread implements Callable<String>{
|
||||
// TODO: handle exception
|
||||
//msg=e.getMessage();
|
||||
//break;
|
||||
error = true;
|
||||
}
|
||||
}
|
||||
dataList.clear();
|
||||
}
|
||||
if(error) {
|
||||
msg.append("validate_error");
|
||||
}
|
||||
|
||||
return msg.toString();
|
||||
}
|
||||
|
||||
@@ -84,7 +93,7 @@ public class CheckTopicWebsiteFormatThread implements Callable<String>{
|
||||
}
|
||||
StringBuffer errTip = new StringBuffer();
|
||||
Pattern pattern = Pattern.compile("\t|\r|\n|\b|\f");
|
||||
Pattern domainPattern = Pattern.compile(Constants.DOMAIN_REGEXP);
|
||||
Pattern domainPattern = Pattern.compile("^[a-zA-Z0-9.-]*$");
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
StringBuffer errInfo = new StringBuffer();
|
||||
AppTopicDomainCfg baseStringCfg = new AppTopicDomainCfg();
|
||||
@@ -99,16 +108,36 @@ public class CheckTopicWebsiteFormatThread implements Callable<String>{
|
||||
}
|
||||
|
||||
if (regionDict.getRegionType().equals(2)) {
|
||||
// 主题、网站校验
|
||||
Long topicId = baseStringCfg.getTopicId();
|
||||
Long websiteServiceId = baseStringCfg.getWebsiteServiceId();
|
||||
|
||||
if (topicId == null) {
|
||||
// 主题、网站验证
|
||||
String topic = baseStringCfg.getTopic();
|
||||
String websiteService = baseStringCfg.getWebsiteService();
|
||||
if(StringUtils.isBlank(topic)) {
|
||||
errInfo.append(
|
||||
String.format(prop.getProperty("can_not_null"), prop.getProperty("topic") + " ") + ";");
|
||||
}else {
|
||||
Map<String, String> dictMap = DictUtils.getDictOptionInReversion("TOPIC");
|
||||
CaseInsensitiveMap topicDictMap = new CaseInsensitiveMap(dictMap);
|
||||
String topicDictCode = (String)topicDictMap.get(topic);
|
||||
if(StringUtils.isBlank(topicDictCode)) {
|
||||
errInfo.append(prop.getProperty("topic") +" "+ prop.getProperty("not_exist") + ";");
|
||||
}else {
|
||||
baseStringCfg.setTopicId(Long.parseLong(topicDictCode));
|
||||
}
|
||||
}
|
||||
|
||||
if (websiteServiceId == null) {
|
||||
if(StringUtils.isBlank(websiteService)) {
|
||||
errInfo.append(
|
||||
String.format(prop.getProperty("can_not_null"), prop.getProperty("website_server") + " ") + ";");
|
||||
}else {
|
||||
Map<String, String> dictMap = DictUtils.getDictOptionInReversion("WEBSITE_SERVER");
|
||||
CaseInsensitiveMap websiteDictMap = new CaseInsensitiveMap(dictMap);
|
||||
String websiteServiceDictCode = (String)websiteDictMap.get(websiteService);
|
||||
if(StringUtils.isBlank(websiteServiceDictCode)) {
|
||||
errInfo.append(prop.getProperty("website_server") +" "+ prop.getProperty("not_exist") + ";");
|
||||
}else {
|
||||
baseStringCfg.setWebsiteServiceId(Long.parseLong(websiteServiceDictCode));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
String keyword = baseStringCfg.getCfgKeywords();
|
||||
@@ -225,7 +254,10 @@ public class CheckTopicWebsiteFormatThread implements Callable<String>{
|
||||
prop.getProperty("is_case_insenstive")) + ";");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}
|
||||
|
||||
isHex = baseStringCfg.getIsHex();
|
||||
isCaseInsenstive = baseStringCfg.getIsCaseInsenstive();
|
||||
if (isHex.intValue() != 0 && isHex.intValue() != 1) {
|
||||
errInfo.append(
|
||||
String.format(prop.getProperty("is_incorrect"), prop.getProperty("is_hex")) + ";");
|
||||
@@ -258,12 +290,10 @@ public class CheckTopicWebsiteFormatThread implements Callable<String>{
|
||||
boolean bl = Pattern.compile("^([0-9|a-f|A-F]*)$").matcher(keyword).matches();
|
||||
if(!bl) {
|
||||
errInfo.append(
|
||||
prop.getProperty("key_word") + " '" + keyword + "' "+String.format(prop.getProperty("contains_non_hex_char")) + ";");
|
||||
prop.getProperty("domain_name") + " '" + keyword + "' "+String.format(prop.getProperty("contains_non_hex_char")) + ";");
|
||||
}
|
||||
}
|
||||
}
|
||||
isHex = baseStringCfg.getIsHex();
|
||||
isCaseInsenstive = baseStringCfg.getIsCaseInsenstive();
|
||||
|
||||
if (isHex != null && isCaseInsenstive != null) {
|
||||
if (isHex.intValue() == 0 && isCaseInsenstive.intValue() == 0) {
|
||||
baseStringCfg.setIsHexbin(0);
|
||||
|
||||
@@ -44,7 +44,7 @@ public class DeleteAsnIpTread implements Callable<Throwable> {
|
||||
while(!asnNos.isEmpty()) {
|
||||
asnNos.drainTo(asnNoList,5);
|
||||
for(Long asnNo:asnNoList) {
|
||||
AsnGroupInfo configGroupInfo=null;//AsnCacheUtils.get(asnNo);
|
||||
AsnGroupInfo configGroupInfo=AsnCacheUtils.get(asnNo);
|
||||
if(configGroupInfo==null) {
|
||||
configGroupInfo=new AsnGroupInfo();
|
||||
configGroupInfo.setAsnId(asnNo);
|
||||
@@ -85,7 +85,7 @@ public class DeleteAsnIpTread implements Callable<Throwable> {
|
||||
}
|
||||
sb.deleteCharAt(sb.toString().lastIndexOf(","));
|
||||
asnIpCfgDao.delete(sb.toString());
|
||||
new AsnIpCfgService().asnIPRegionSendToMaat(listPage, Constants.VALID_NO,1);
|
||||
new AsnIpCfgService().asnIPRegionSendToMaat(listPage, Constants.VALID_NO);
|
||||
transactionManager.commit(status);
|
||||
listPage.clear();
|
||||
} catch (Throwable e) {
|
||||
|
||||
@@ -112,7 +112,7 @@ public class SaveAsnIpThread implements Callable<Throwable>{
|
||||
_cfg.setAsnIpGroup(asnNoMaps.get(1).get(Long.parseLong(_cfg.getUserRegion1())));
|
||||
}else {
|
||||
// ConfigGroupInfo info=asnIpCfgService.getConfigGroupInfoByAsnNo(Long.parseLong(_cfg.getUserRegion1()));
|
||||
AsnGroupInfo info=null;//AsnCacheUtils.get(Long.parseLong(_cfg.getUserRegion1()));
|
||||
AsnGroupInfo info=AsnCacheUtils.get(Long.parseLong(_cfg.getUserRegion1()));
|
||||
if(info==null) {
|
||||
info=new AsnGroupInfo();
|
||||
info.setAsnId(Long.parseLong(_cfg.getUserRegion1()));
|
||||
@@ -166,7 +166,7 @@ public class SaveAsnIpThread implements Callable<Throwable>{
|
||||
this.save(cfgs);
|
||||
// splitAndSend(toAddRegionAsnIpCfgs,Constants.VALID_YES);
|
||||
if(toAddRegionAsnIpCfgs.size()>0) {
|
||||
new AsnIpCfgService().asnIPRegionSendToMaat(toAddRegionAsnIpCfgs,Constants.VALID_YES,1);
|
||||
new AsnIpCfgService().asnIPRegionSendToMaat(toAddRegionAsnIpCfgs,Constants.VALID_YES);
|
||||
}
|
||||
cfgs.clear();
|
||||
toAddRegionAsnIpCfgs.clear();
|
||||
|
||||
@@ -23,6 +23,7 @@ import javax.ws.rs.client.Invocation.Builder;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.http.HttpStatus;
|
||||
import org.apache.http.client.ClientProtocolException;
|
||||
import org.apache.http.client.config.RequestConfig;
|
||||
@@ -37,6 +38,7 @@ import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.nis.exceptions.MaatConvertException;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.Encodes;
|
||||
@@ -236,6 +238,7 @@ public class HttpClientUtil {
|
||||
* @return 查询结果数据json
|
||||
*/
|
||||
public static String getMsg(String destUrl, Map<String, Object> params, HttpServletRequest req) throws IOException {
|
||||
long start=System.currentTimeMillis(), end=System.currentTimeMillis();
|
||||
// RequestContext requestContext = new RequestContext(req);
|
||||
|
||||
// CloseableHttpResponse response = null;
|
||||
@@ -283,6 +286,7 @@ public class HttpClientUtil {
|
||||
logger.error("获取消息失败,相应内容如下: " + result);
|
||||
throw new MaatConvertException(status+"");
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("获取消息失败,相应内容如下: " + result);
|
||||
@@ -292,6 +296,8 @@ public class HttpClientUtil {
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
end=System.currentTimeMillis();
|
||||
logger.warn("getMsg cost:"+(end-start)+"ms");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -302,12 +308,14 @@ public class HttpClientUtil {
|
||||
* @return
|
||||
*/
|
||||
public static String galaxyMessageFormat(String recv){
|
||||
JSONObject jobj = JSONObject.fromObject(recv);
|
||||
long start=System.currentTimeMillis(),end=System.currentTimeMillis();
|
||||
//JSONObject jobj = JSONObject.fromObject(recv);
|
||||
com.alibaba.fastjson.JSONObject jobj = JSON.parseObject(recv);
|
||||
Map<String, Object> parse = (Map<String, Object>)jobj;
|
||||
Map map = (Map) parse.get("data");
|
||||
List reslist=new ArrayList();
|
||||
List<Map<String,Object>> list= (List)map.get("list");
|
||||
if(list!=null&&list.size()>0){
|
||||
if(CollectionUtils.isNotEmpty(list)){
|
||||
for (Map<String,Object> m : list) {
|
||||
Map recvMap = new HashMap();
|
||||
Iterator<Entry<String, Object>> iterator = m.entrySet().iterator();
|
||||
@@ -316,12 +324,12 @@ public class HttpClientUtil {
|
||||
String key = next.getKey().toString();
|
||||
Object value = next.getValue();
|
||||
//处理字段为“null”情况
|
||||
if(value!=null&&"null".equals(value)){
|
||||
if("null".equals(value)){
|
||||
value="";
|
||||
}
|
||||
//处理时间字段为“0”情况
|
||||
if("foundTime".equals(key)||"recvTime".equals(key)){
|
||||
if(null!=value&&"0".equals(value)){
|
||||
if("0".equals(value)){
|
||||
value="";
|
||||
}
|
||||
}
|
||||
@@ -337,6 +345,8 @@ public class HttpClientUtil {
|
||||
parse.put("data", map);
|
||||
recv = parse.toString();
|
||||
}
|
||||
end=System.currentTimeMillis();
|
||||
logger.info("galaxyMessageFormat cost:"+(end-start));
|
||||
return recv;
|
||||
}
|
||||
|
||||
|
||||
69
src/main/java/com/nis/util/redis/RedisPoolHelper.java
Normal file
69
src/main/java/com/nis/util/redis/RedisPoolHelper.java
Normal file
@@ -0,0 +1,69 @@
|
||||
package com.nis.util.redis;
|
||||
|
||||
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.nis.util.Configurations;
|
||||
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.JedisPool;
|
||||
|
||||
public class RedisPoolHelper {
|
||||
private Logger logger=Logger.getLogger(RedisPoolHelper.class);
|
||||
private JedisPool jedisPool;
|
||||
private String host;
|
||||
private int timeout;
|
||||
public RedisPoolHelper(){
|
||||
init();
|
||||
}
|
||||
private void init() {
|
||||
synchronized (this) {
|
||||
if (jedisPool == null) {
|
||||
host=Configurations.getStringProperty("redis.host", "127.0.0.1:6379");
|
||||
timeout=Configurations.getIntProperty("redis.timeout", 10000);
|
||||
String[] hostAndPort = host.split(":");
|
||||
jedisPool = new JedisPool(getPoolConfig(), hostAndPort[0], Integer.parseInt(hostAndPort[1]), timeout);
|
||||
logger.info("redis pool init complate! host-->"+hostAndPort[0]+" port:"+Integer.parseInt(hostAndPort[1]));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public Jedis getJedis() {
|
||||
if (jedisPool == null) {
|
||||
init();
|
||||
}
|
||||
return jedisPool.getResource();
|
||||
}
|
||||
public JedisPool getJedisPool() {
|
||||
return jedisPool;
|
||||
}
|
||||
|
||||
public void setJedisPool(JedisPool jedisPool) {
|
||||
this.jedisPool = jedisPool;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* getPoolConfig(初始化连接池的配置,这里可以设置很多参数的,不过目前没加)
|
||||
* (这里描述这个方法适用条件 – 可选)
|
||||
* @return
|
||||
*GenericObjectPoolConfig
|
||||
* @exception
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private GenericObjectPoolConfig getPoolConfig(){
|
||||
GenericObjectPoolConfig config=new GenericObjectPoolConfig();
|
||||
config.setMaxTotal(Configurations.getIntProperty("redis.pool.maxtotal", 500));//整个池的最大值
|
||||
config.setMaxIdle(Configurations.getIntProperty("redis.pool.maxidle", 100));//最大空闲
|
||||
config.setMaxWaitMillis(Configurations.getIntProperty("redis.pool.maxwaitmillis", -1));//获取不到永远等待
|
||||
config.setBlockWhenExhausted(Configurations.getBooleanProperty("redis.pool.blockwhenexhausted", true));
|
||||
config.setNumTestsPerEvictionRun(Configurations.getIntProperty("redis.pool.numtestsperevictionrun", Integer.MAX_VALUE));//always test all idle object
|
||||
config.setTestOnBorrow(Configurations.getBooleanProperty("redis.pool.testonborrow", true));
|
||||
config.setTestOnReturn(Configurations.getBooleanProperty("redis.pool.testonreturn", false));
|
||||
config.setTestWhileIdle(Configurations.getBooleanProperty("redis.pool.testwhileidle", true));//发呆过长时间是否先test一下
|
||||
config.setTimeBetweenEvictionRunsMillis(Configurations.getLongProperty("redis.pool.timebetweenevictionrunsmillis", 60000L));//-1不启动,默认1min一次
|
||||
config.setMinEvictableIdleTimeMillis(Configurations.getLongProperty("redis.pool.minevictableidletimemillis", 60000L));//可发呆的时间,10mins
|
||||
return config;
|
||||
}
|
||||
|
||||
}
|
||||
38
src/main/java/com/nis/util/redis/SaveHelpInfoThread.java
Normal file
38
src/main/java/com/nis/util/redis/SaveHelpInfoThread.java
Normal file
@@ -0,0 +1,38 @@
|
||||
package com.nis.util.redis;
|
||||
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.JedisPool;
|
||||
|
||||
public class SaveHelpInfoThread extends Thread {
|
||||
private Logger logger=Logger.getLogger(SaveHelpInfoThread.class);
|
||||
private JedisPool jedisPool;
|
||||
private Jedis jedis;
|
||||
private String key;
|
||||
private String value;
|
||||
private int expire;
|
||||
public SaveHelpInfoThread(JedisPool jedisPool,String key,String value,int expire){
|
||||
this.jedisPool=jedisPool;
|
||||
this.key=key;
|
||||
this.value=value;
|
||||
this.expire=expire;
|
||||
jedis=jedisPool.getResource();
|
||||
|
||||
}
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
jedis.set(key, value);
|
||||
if(expire!=-1){
|
||||
jedis.expire(key, expire);
|
||||
}
|
||||
logger.debug("cache help[key --> "+key+"]");
|
||||
} catch (Exception e) {
|
||||
logger.error("save redis error",e);
|
||||
}finally{
|
||||
jedis.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -29,6 +29,7 @@ import com.google.gson.reflect.TypeToken;
|
||||
import com.nis.util.Configurations;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.CookieUtil;
|
||||
import com.nis.util.LogUtils;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.util.StringUtils;
|
||||
import com.nis.util.httpclient.HttpClientUtil;
|
||||
@@ -87,6 +88,7 @@ public class LoginController extends BaseController {
|
||||
CookieUtil.addCookie(response, "LOGINED", "false");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,6 +175,7 @@ public class LoginController extends BaseController {
|
||||
}
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
|
||||
|
||||
@@ -212,6 +215,7 @@ public class LoginController extends BaseController {
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
|
||||
return "redirect:"+request.getParameter("url");
|
||||
@@ -230,6 +234,7 @@ public class LoginController extends BaseController {
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
|
||||
return "redirect:"+request.getParameter("url");
|
||||
|
||||
@@ -1,23 +1,32 @@
|
||||
package com.nis.web.controller;
|
||||
|
||||
import java.net.URLDecoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import com.nis.domain.SysMenu;
|
||||
import com.nis.domain.configuration.HelpInfo;
|
||||
import com.nis.util.LogUtils;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.util.StringUtils;
|
||||
import com.nis.web.security.UserUtils;
|
||||
import com.nis.web.service.configuration.HelpInfoService;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("${adminPath}/sys/")
|
||||
public class SystemController extends BaseController{
|
||||
|
||||
@Autowired
|
||||
private HelpInfoService helpService;
|
||||
@RequestMapping("index")
|
||||
public String index(HttpServletRequest request, HttpServletResponse response,ModelMap model){
|
||||
return "/sys/sysIndex";
|
||||
@@ -91,15 +100,120 @@ public class SystemController extends BaseController{
|
||||
System.out.println(menu.getParentIds());
|
||||
newList.add(menu);
|
||||
}*/
|
||||
//将帮助文档缓存到redis
|
||||
helpService.cacheAllHelpInfo();
|
||||
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("help error",e);
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
logger.info("menuSize:"+newList.size());
|
||||
model.addAttribute("menuList",newList);
|
||||
return "/help";
|
||||
}
|
||||
/**
|
||||
* @param request
|
||||
* @param response
|
||||
* @param model
|
||||
* @param editedHelpInfo 修改之后的帮助文档内容
|
||||
* @param helpHrefVal 文档的路径
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("saveHelp")
|
||||
@ResponseBody
|
||||
public boolean saveHelp(HttpServletRequest request, HttpServletResponse response,ModelMap model,@RequestParam(required=true,value="editedHelpInfo")String editedHelpInfo,@RequestParam(required=true,value="helpHrefVal")String helpHrefVal){
|
||||
if(StringUtils.strIsBlank(helpHrefVal)){
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
StringBuffer helpInfoText=new StringBuffer(); //修改之后的内容
|
||||
helpInfoText.append(URLDecoder.decode(editedHelpInfo,"utf-8"));
|
||||
String helpHref=URLDecoder.decode(helpHrefVal,"utf-8");
|
||||
String[] split = StringUtils.split(helpHref, "/");
|
||||
if(split!=null&&split.length>0){
|
||||
HelpInfo helpInfo = new HelpInfo();
|
||||
helpInfo.setFileComment(helpInfoText.toString());
|
||||
helpInfo.setFileName(split[split.length-1]);
|
||||
helpService.saveHelpInfo(helpInfo);
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("save helpInfo error",e);
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* 查看帮助文档内容
|
||||
* @param request
|
||||
* @param response
|
||||
* @param model
|
||||
* @param helpHref
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("viewHelp")
|
||||
@ResponseBody
|
||||
public HelpInfo viewHelp(HttpServletRequest request, HttpServletResponse response,ModelMap model,@RequestParam(required=true,value="helpHref")String helpHref){
|
||||
|
||||
if(StringUtils.strIsBlank(helpHref)){
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
helpHref=URLDecoder.decode(helpHref,"utf-8");
|
||||
|
||||
String[] split = StringUtils.split(helpHref, "/");
|
||||
if(split!=null&&split.length>0){
|
||||
HelpInfo helpInfo = helpService.findHelpCommentByName(split[split.length-1]);
|
||||
return helpInfo;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("view helpInfo error",e);
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* 查看帮助文档备份内容
|
||||
* @param request
|
||||
* @param response
|
||||
* @param model
|
||||
* @param helpHref
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("viewBakHelp")
|
||||
@ResponseBody
|
||||
public HelpInfo viewBakHelp(HttpServletRequest request, HttpServletResponse response,ModelMap model,@RequestParam(required=true,value="helpHref")String helpHref){
|
||||
|
||||
if(StringUtils.strIsBlank(helpHref)){
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
helpHref=URLDecoder.decode(helpHref,"utf-8");
|
||||
|
||||
String[] split = StringUtils.split(helpHref, "/");
|
||||
if(split!=null&&split.length>0){
|
||||
HelpInfo helpInfo = helpService.findHelpBakCommentByName(split[split.length-1]);
|
||||
return helpInfo;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("view helpBakInfo error",e);
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@RequestMapping("clearPolicies")
|
||||
@ResponseBody
|
||||
public boolean clearPolicies(HttpServletRequest request, HttpServletResponse response) {
|
||||
try {
|
||||
systemService.clearPolicies();
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
logger.error("Clear Policies Error",e);
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
package com.nis.web.controller.basics;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@@ -23,6 +18,7 @@ import com.nis.domain.Page;
|
||||
import com.nis.domain.basics.AsnGroupInfo;
|
||||
import com.nis.domain.basics.AsnIpCfg;
|
||||
import com.nis.domain.specific.ConfigGroupInfo;
|
||||
import com.nis.util.LogUtils;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.web.controller.BaseController;
|
||||
/**
|
||||
@@ -72,7 +68,7 @@ public class AsnGroupController extends BaseController {
|
||||
//@RequiresPermissions(value={"basics:classification:add","basics:attribute:add","basics:label:add","basics:classification:edit","basics:attribute:edit","basics:label:edit"},logical=Logical.OR)
|
||||
@RequestMapping(value = "saveOrUpdate")
|
||||
public String saveOrUpdate(AsnGroupInfo cfg,Model model,
|
||||
RedirectAttributes redirectAttributes,String itType) {
|
||||
RedirectAttributes redirectAttributes,String itType,HttpServletRequest request) {
|
||||
|
||||
try {
|
||||
AsnGroupInfo asnGroup=asnGroupInfoService.getGroupIdByNameAndASNId(cfg.getOrganization().trim(), cfg.getCountry().trim(), cfg.getAsnId());
|
||||
@@ -85,6 +81,7 @@ public class AsnGroupController extends BaseController {
|
||||
} catch (Exception e) {
|
||||
logger.error("新增失败",e);
|
||||
addMessage(redirectAttributes,"error","save_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
|
||||
return "redirect:" + adminPath + "/basics/asnGroup/asnGroupList";
|
||||
@@ -99,15 +96,14 @@ public class AsnGroupController extends BaseController {
|
||||
*/
|
||||
//@RequiresPermissions(value={"basics:classification:del","basics:attribute:del","basics:label:del"},logical=Logical.OR)
|
||||
@RequestMapping(value={"delete"})
|
||||
public String delete(RedirectAttributes redirectAttributes,String ids,String asnIds) {
|
||||
public String delete(RedirectAttributes redirectAttributes,String ids,String asnIds,HttpServletRequest request) {
|
||||
try {
|
||||
asnGroupInfoService.delete(ids,asnIds);
|
||||
//TODO 查询本次删除的所有asnOrg组中是否存在asn 没有is_used=0的asn,如果存在则需要将整个组删除
|
||||
|
||||
addMessage(redirectAttributes,"success","delete_success");
|
||||
} catch (Exception e) {
|
||||
logger.error("删除失败",e);
|
||||
addMessage(redirectAttributes,"error","delete_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
return "redirect:" + adminPath + "/basics/asnGroup/asnGroupList";
|
||||
}
|
||||
@@ -162,14 +158,11 @@ public class AsnGroupController extends BaseController {
|
||||
*/
|
||||
@ResponseBody
|
||||
@RequestMapping(value = {"/checkAsnNo"})
|
||||
public boolean checkIp(AsnGroupInfo cfg, HttpServletRequest request, HttpServletResponse response){
|
||||
public AsnGroupInfo checkIp(AsnGroupInfo cfg, HttpServletRequest request, HttpServletResponse response){
|
||||
|
||||
AsnGroupInfo policyGroup = asnGroupInfoService.getInfoByAsnNo(cfg);
|
||||
if(policyGroup == null){
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return policyGroup;
|
||||
}
|
||||
/**
|
||||
* 校验asn号是否已存在
|
||||
@@ -185,38 +178,5 @@ public class AsnGroupController extends BaseController {
|
||||
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* 异步获取ASN组织信息
|
||||
* @param model
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value="ajaxGetAsnOrg")
|
||||
@ResponseBody
|
||||
public List ajaxGetAsnOrg( ConfigGroupInfo orgGroup,Model model){
|
||||
List<ConfigGroupInfo> orgaList=new ArrayList<>();
|
||||
try {
|
||||
orgaList=configGroupInfoService.findAllList(orgGroup);
|
||||
} catch (Exception e) {
|
||||
logger.error("异步获取ASN组织信息失败",e);
|
||||
return orgaList;
|
||||
}
|
||||
return orgaList;
|
||||
}
|
||||
/**
|
||||
* 异步获取ASN组织信息
|
||||
* @param model
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value="ajaxGetAsnNo")
|
||||
@ResponseBody
|
||||
public List ajaxGetAsnNo(AsnGroupInfo asnGroup,Model model){
|
||||
List<AsnGroupInfo> orgaList=new ArrayList<>();
|
||||
try {
|
||||
orgaList=asnGroupInfoService.findAsnGroupList(asnGroup);
|
||||
} catch (Exception e) {
|
||||
logger.error("异步获取ASN NO信息失败",e);
|
||||
return orgaList;
|
||||
}
|
||||
return orgaList;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
@@ -31,6 +32,7 @@ import com.nis.exceptions.MaatConvertException;
|
||||
//import com.nis.util.AsnCacheUtils;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.DictUtils;
|
||||
import com.nis.util.LogUtils;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.web.controller.BaseController;
|
||||
import com.nis.web.security.UserUtils;
|
||||
@@ -78,15 +80,21 @@ public class AsnIpController extends BaseController{
|
||||
public String save(Model model,HttpServletRequest request,HttpServletResponse response,@ModelAttribute("cfg")CfgIndexInfo cfg,RedirectAttributes redirectAttributes){
|
||||
try{
|
||||
asnIpCfgService.saveAsnIpCfg(cfg);
|
||||
addMessage(redirectAttributes,"success","save_success");
|
||||
}catch(Exception e){
|
||||
logger.error("信息保存失败",e);
|
||||
e.printStackTrace();
|
||||
if(e instanceof MaatConvertException) {
|
||||
addMessage(redirectAttributes,"error",e.getMessage());
|
||||
//配置仅保存
|
||||
if(StringUtil.isEmpty(cfg.getIsValid()) || cfg.getIsValid()!=1) {
|
||||
addMessage(redirectAttributes, "success", "save_success");
|
||||
}else {
|
||||
addMessage(redirectAttributes,"error","save_failed");
|
||||
//配置直接生效
|
||||
addMessage(redirectAttributes, "success", "audit_success");
|
||||
}
|
||||
} catch (MaatConvertException e) {
|
||||
logger.error("ASN IP配置下发失败:",e);
|
||||
addMessage(redirectAttributes, "error", "request_service_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
} catch (Exception e) {
|
||||
logger.error("ASN IP配置保存失败:",e);
|
||||
addMessage(redirectAttributes, "error", "save_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
|
||||
return "redirect:" + adminPath +"/basics/asn/list?functionId="+cfg.getFunctionId();
|
||||
@@ -97,11 +105,21 @@ public class AsnIpController extends BaseController{
|
||||
try{
|
||||
|
||||
asnIpCfgService.update(cfg);
|
||||
addMessage(redirectAttributes,"success","save_success");
|
||||
}catch(Exception e){
|
||||
logger.error("信息保存失败",e);
|
||||
e.printStackTrace();
|
||||
addMessage(redirectAttributes,"error","save_failed");
|
||||
//配置仅保存
|
||||
if(StringUtil.isEmpty(cfg.getIsValid()) || cfg.getIsValid()!=1) {
|
||||
addMessage(redirectAttributes, "success", "save_success");
|
||||
}else {
|
||||
//配置直接生效
|
||||
addMessage(redirectAttributes, "success", "audit_success");
|
||||
}
|
||||
} catch (MaatConvertException e) {
|
||||
logger.error("ASN IP配置下发失败:",e);
|
||||
addMessage(redirectAttributes, "error", "request_service_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
} catch (Exception e) {
|
||||
logger.error("ASN IP配置保存失败:",e);
|
||||
addMessage(redirectAttributes, "error", "save_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
|
||||
return "redirect:" + adminPath +"/basics/asn/list?functionId="+cfg.getFunctionId();
|
||||
@@ -134,24 +152,11 @@ public class AsnIpController extends BaseController{
|
||||
asnIpMap.put(Long.parseLong(asnIpCfg.getUserRegion1()), _asnIps);
|
||||
}
|
||||
}
|
||||
/********************每次下发一个组的region,保证事物********************/
|
||||
for (Long asnId : asnIpMap.keySet()) {
|
||||
try {
|
||||
asnIpCfgService.auditIpBatch(asnIpMap.get(asnId),asnId,isValid);
|
||||
} catch (Exception e) {
|
||||
logger.error("配置下发失败:",e);
|
||||
if(e instanceof MaatConvertException) {
|
||||
addMessage(redirectAttributes,"error", "request_service_failed");
|
||||
asnIpCfgService.auditIpBatch(asnIpMap,isAudit);
|
||||
}else {
|
||||
addMessage(redirectAttributes,"error", "audit_failed");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}/*else {
|
||||
//条件下所有配置审核
|
||||
Page<AsnIpCfg> searchPage=new Page<AsnIpCfg>(request,response,"a");
|
||||
Page<AsnIpCfg> auditPage=new Page<AsnIpCfg>(request,response,"a");
|
||||
Page<AsnIpCfg> searchPage=new Page<AsnIpCfg>(request,response,"r");
|
||||
Page<AsnIpCfg> auditPage=new Page<AsnIpCfg>(request,response,"r");
|
||||
BeanUtils.copyProperties(searchPage, auditPage);
|
||||
try {
|
||||
auditAll(auditPage,isValid , cfg);
|
||||
@@ -160,30 +165,39 @@ public class AsnIpController extends BaseController{
|
||||
logger.error("配置下发失败:",e);
|
||||
if(e instanceof MaatConvertException) {
|
||||
addMessage(redirectAttributes,"error", "request_service_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}else {
|
||||
addMessage(redirectAttributes,"error", "audit_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return list(model, request, response, cfg);
|
||||
}*/
|
||||
}
|
||||
return "redirect:" + adminPath +"/basics/asn/list?functionId="+cfg.getFunctionId();
|
||||
}
|
||||
@RequestMapping(value = {"/delete"})
|
||||
@RequiresPermissions(value={"asn:ip:config"})
|
||||
public String delete(Integer isValid
|
||||
,String ids,Integer functionId
|
||||
,RedirectAttributes redirectAttributes){
|
||||
public String delete(Integer isValid, String ids, Integer functionId, RedirectAttributes redirectAttributes,
|
||||
HttpServletRequest request, HttpServletResponse response, @ModelAttribute("cfg")AsnIpCfg cfg){
|
||||
try{
|
||||
if (!StringUtil.isEmpty(ids)) {
|
||||
asnIpCfgService.delete(ids);
|
||||
addMessage(redirectAttributes,"success","delete_success");
|
||||
}else {
|
||||
// 批量删除
|
||||
Page<CfgIndexInfo> searchPage = new Page<CfgIndexInfo>(request, response, "a");
|
||||
deleteAll(searchPage, functionId, cfg);
|
||||
}
|
||||
}catch(Exception e){
|
||||
logger.error("Delete failed",e);
|
||||
if(e instanceof MaatConvertException) {
|
||||
addMessage(redirectAttributes,"error",e.getMessage());
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}else {
|
||||
addMessage(redirectAttributes,"error","delete_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -272,6 +286,7 @@ public class AsnIpController extends BaseController{
|
||||
} catch (Exception e) {
|
||||
logger.error("asnIp export failed",e);
|
||||
addMessage(redirectAttributes,"error","export_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
//return "redirect:" + adminPath +"/ntc/iplist/list?functionId="+entity.getFunctionId();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
package com.nis.web.controller.basics;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.basics.ProtectionListInfo;
|
||||
import com.nis.util.LogUtils;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.web.controller.BaseController;
|
||||
|
||||
/**
|
||||
* 内置配置保护名单管理
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping(value = "${adminPath}/basics/innerProtectionList")
|
||||
public class InnerProtectionListController extends BaseController{
|
||||
|
||||
@RequestMapping(value = {"/list", ""})
|
||||
public String policyGroupList(ProtectionListInfo cfg,HttpServletRequest request, HttpServletResponse response, Model model,
|
||||
RedirectAttributes redirectAttributes) {
|
||||
if(cfg == null)cfg=new ProtectionListInfo();
|
||||
Page<ProtectionListInfo> pageCondition = new Page<ProtectionListInfo>(request, response,"r");
|
||||
Page page = innerProtectionListService.findProtectionInfoList(pageCondition,cfg);
|
||||
|
||||
model.addAttribute("cfg", cfg);
|
||||
model.addAttribute("page", page);
|
||||
return "/basics/protectionInfoList";
|
||||
}
|
||||
|
||||
@RequestMapping(value={"/form"})
|
||||
public String form(Integer groupType,String ids,Model model,String doAction,RedirectAttributes redirectAttributes) {
|
||||
ProtectionListInfo protectionListInfo = new ProtectionListInfo();
|
||||
if(!StringUtil.isEmpty(ids)){
|
||||
protectionListInfo = innerProtectionListService.getById(Integer.parseInt(ids));
|
||||
}
|
||||
model.addAttribute("_cfg", protectionListInfo);
|
||||
return "/basics/protectionInfoForm";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "saveOrUpdate")
|
||||
public String saveOrUpdate(ProtectionListInfo cfg,Model model,String itType,Integer groupType,
|
||||
RedirectAttributes redirectAttributes,HttpServletRequest request) {
|
||||
try {
|
||||
innerProtectionListService.saveOrUpdate(cfg);
|
||||
addMessage(redirectAttributes,"success","save_success");
|
||||
} catch (Exception e) {
|
||||
logger.error("新增失败",e);
|
||||
addMessage(redirectAttributes,"error","save_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
return "redirect:" + adminPath + "/basics/innerProtectionList/list";
|
||||
}
|
||||
|
||||
@RequestMapping(value={"delete"})
|
||||
public String delete(RedirectAttributes redirectAttributes,String ids,int isValid,HttpServletRequest request) {
|
||||
try {
|
||||
innerProtectionListService.deldete(ids,isValid);
|
||||
addMessage(redirectAttributes,"success","delete_success");
|
||||
} catch (Exception e) {
|
||||
logger.error("删除失败",e);
|
||||
addMessage(redirectAttributes,"error","delete_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
return "redirect:" + adminPath + "/basics/innerProtectionList/list";
|
||||
}
|
||||
|
||||
@RequestMapping(value="ajaxGetAllInfo",method=RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public Map<String,List<String>> ajaxGetAllInfo(HttpServletRequest request, HttpServletResponse response){
|
||||
return innerProtectionListService.ajaxGetAllInfo();
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验配置是否已存在
|
||||
* @param cfg
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@ResponseBody
|
||||
@RequestMapping(value = {"/checkKeywordExist"})
|
||||
public boolean checkKeywordExist(ProtectionListInfo cfg, HttpServletRequest request, HttpServletResponse response){
|
||||
if(!StringUtil.isEmpty(cfg.getProId())){ // 修改操作
|
||||
ProtectionListInfo info = innerProtectionListService.getById(cfg.getProId());
|
||||
if(info != null && info.getKeyword().equals(cfg.getKeyword()) && info.getTargetType().equals(cfg.getTargetType())){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Map<String, List<String>> map = innerProtectionListService.ajaxGetAllInfo();
|
||||
List<String> list = map.get(cfg.getTargetType());
|
||||
if(list != null) {
|
||||
if(list.contains(cfg.getKeyword())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@ import com.nis.domain.basics.IpReuseIpCfg;
|
||||
import com.nis.domain.configuration.CfgIndexInfo;
|
||||
import com.nis.exceptions.MaatConvertException;
|
||||
import com.nis.util.DictUtils;
|
||||
import com.nis.util.LogUtils;
|
||||
import com.nis.web.controller.BaseController;
|
||||
@Controller
|
||||
@RequestMapping(value = "${adminPath}/basics/vpn")
|
||||
@@ -75,6 +76,7 @@ public class IpReuseIpCfgController extends BaseController{
|
||||
logger.error("信息保存失败",e);
|
||||
e.printStackTrace();
|
||||
addMessage(redirectAttributes,"error","save_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
return "redirect:" + adminPath +"/basics/vpn/list?functionId="+entity.getFunctionId();
|
||||
}
|
||||
@@ -91,6 +93,7 @@ public class IpReuseIpCfgController extends BaseController{
|
||||
logger.error("信息保存失败",e);
|
||||
e.printStackTrace();
|
||||
addMessage(redirectAttributes,"error","save_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
return "redirect:" + adminPath +"/basics/vpn/list?functionId="+cfg.getFunctionId();
|
||||
}
|
||||
@@ -98,7 +101,7 @@ public class IpReuseIpCfgController extends BaseController{
|
||||
@RequiresPermissions(value={"asn:ip:config"})
|
||||
public String delete(Integer isValid
|
||||
,String ids,Integer functionId
|
||||
,RedirectAttributes redirectAttributes){
|
||||
,RedirectAttributes redirectAttributes,HttpServletRequest request){
|
||||
try{
|
||||
ipReuseIpCfgService.delete(isValid,ids);
|
||||
addMessage(redirectAttributes,"success","delete_success");
|
||||
@@ -106,8 +109,10 @@ public class IpReuseIpCfgController extends BaseController{
|
||||
logger.error("Delete failed",e);
|
||||
if(e instanceof MaatConvertException) {
|
||||
addMessage(redirectAttributes,"error",e.getMessage());
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}else {
|
||||
addMessage(redirectAttributes,"error","delete_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.basics.PolicyGroupInfo;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.LogUtils;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.web.controller.BaseController;
|
||||
/**
|
||||
@@ -71,7 +72,7 @@ public class PolicyGroupController extends BaseController {
|
||||
//@RequiresPermissions(value={"basics:classification:add","basics:attribute:add","basics:label:add","basics:classification:edit","basics:attribute:edit","basics:label:edit"},logical=Logical.OR)
|
||||
@RequestMapping(value = "saveOrUpdate")
|
||||
public String saveOrUpdate(PolicyGroupInfo cfg,Model model,
|
||||
RedirectAttributes redirectAttributes,String itType,Integer groupType) {
|
||||
RedirectAttributes redirectAttributes,String itType,Integer groupType,HttpServletRequest request) {
|
||||
|
||||
try {
|
||||
policyGroupInfoService.saveOrUpdate(cfg);
|
||||
@@ -79,6 +80,7 @@ public class PolicyGroupController extends BaseController {
|
||||
} catch (Exception e) {
|
||||
logger.error("新增失败",e);
|
||||
addMessage(redirectAttributes,"error","save_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
|
||||
return "redirect:" + adminPath + "/basics/policyGroup/policyGroupList?groupType="+groupType;
|
||||
@@ -93,13 +95,14 @@ public class PolicyGroupController extends BaseController {
|
||||
*/
|
||||
//@RequiresPermissions(value={"basics:classification:del","basics:attribute:del","basics:label:del"},logical=Logical.OR)
|
||||
@RequestMapping(value={"delete"})
|
||||
public String delete(RedirectAttributes redirectAttributes, Integer groupType,String ids,int isValid) {
|
||||
public String delete(RedirectAttributes redirectAttributes, Integer groupType,String ids,int isValid,HttpServletRequest request) {
|
||||
try {
|
||||
policyGroupInfoService.deldete(ids,isValid);
|
||||
addMessage(redirectAttributes,"success","delete_success");
|
||||
} catch (Exception e) {
|
||||
logger.error("删除失败",e);
|
||||
addMessage(redirectAttributes,"error","delete_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
return "redirect:" + adminPath + "/basics/policyGroup/policyGroupList?groupType="+groupType;
|
||||
}
|
||||
@@ -194,6 +197,7 @@ public class PolicyGroupController extends BaseController {
|
||||
} catch (Exception e) {
|
||||
logger.error("Group export failed",e);
|
||||
addMessage(redirectAttributes,"error","export_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
//return "redirect:" + adminPath +"/ntc/iplist/list?functionId="+entity.getFunctionId();
|
||||
}
|
||||
|
||||
@@ -24,10 +24,12 @@ import com.google.common.collect.Maps;
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.SysUser;
|
||||
import com.nis.domain.basics.ServiceDictInfo;
|
||||
import com.nis.domain.configuration.UserManage;
|
||||
import com.nis.util.ConfigDictUtils;
|
||||
import com.nis.util.Configurations;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.DateUtils;
|
||||
import com.nis.util.LogUtils;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.util.StringUtils;
|
||||
import com.nis.web.controller.BaseController;
|
||||
@@ -51,7 +53,7 @@ public class ServiceDictInfoController extends BaseController {
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="requestCancleInfoAjax", method = RequestMethod.POST)
|
||||
public String requestCancleInfoAjax(Integer cancelRequestId,String ids,String indexTable){
|
||||
public String requestCancleInfoAjax(Integer cancelRequestId,String ids,String indexTable,HttpServletRequest request){
|
||||
if(!StringUtil.isEmpty(ids)){
|
||||
String[] idArray = ids.split(",");
|
||||
for(String id :idArray){
|
||||
@@ -60,6 +62,7 @@ public class ServiceDictInfoController extends BaseController {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("审核添加取消来函信息失败",e);
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
return "false";
|
||||
}
|
||||
}
|
||||
@@ -75,7 +78,7 @@ public class ServiceDictInfoController extends BaseController {
|
||||
*/
|
||||
@ResponseBody
|
||||
@RequestMapping(value="requestCancleInfoNumber")
|
||||
public Map requestCancleInfoNumber(String ids,String indexTable){
|
||||
public Map requestCancleInfoNumber(String ids,String indexTable,HttpServletRequest request){
|
||||
List list = new ArrayList();
|
||||
String requestTitle="";
|
||||
Map map=new HashMap();
|
||||
@@ -93,6 +96,7 @@ public class ServiceDictInfoController extends BaseController {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("查询取消审核来函信息失败",e);
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
return map;
|
||||
}
|
||||
// }
|
||||
@@ -206,7 +210,7 @@ public class ServiceDictInfoController extends BaseController {
|
||||
*/
|
||||
@RequiresPermissions(value={"basics:classification:add","basics:attribute:add","basics:label:add","basics:vpn_ip:add","basics:classification:edit","basics:attribute:edit","basics:label:edit","basics:vpn_ip:edit"},logical=Logical.OR)
|
||||
@RequestMapping(value = "saveOrUpdate")
|
||||
public String saveOrUpdate(ServiceDictInfo serviceDictInfo,Model model, RedirectAttributes redirectAttributes,String itType) {
|
||||
public String saveOrUpdate(ServiceDictInfo serviceDictInfo,Model model, RedirectAttributes redirectAttributes,String itType,HttpServletRequest request) {
|
||||
|
||||
try {
|
||||
serviceDictInfoService.saveOrUpdate(serviceDictInfo);
|
||||
@@ -214,6 +218,7 @@ public class ServiceDictInfoController extends BaseController {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
addMessage(redirectAttributes,"error", "save_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
|
||||
return "redirect:" + adminPath + "/basics/serviceDictInfo/list?itType="+itType;
|
||||
@@ -230,13 +235,42 @@ public class ServiceDictInfoController extends BaseController {
|
||||
*/
|
||||
@RequiresPermissions(value={"basics:classification:del","basics:attribute:del","basics:label:del","basics:vpn_ip:del"},logical=Logical.OR)
|
||||
@RequestMapping(value={"delete"})
|
||||
public String delete(ServiceDictInfo serviceDictInfo, RedirectAttributes redirectAttributes, String itType, String mulitId) {
|
||||
public String delete(ServiceDictInfo serviceDictInfo, RedirectAttributes redirectAttributes, String itType, String mulitId,HttpServletRequest request) {
|
||||
try {
|
||||
serviceDictInfoService.deleteDict(mulitId);
|
||||
String exIp="";
|
||||
String id="";
|
||||
Properties msgProp = getMsgProp();
|
||||
if(itType.equals("5")){
|
||||
String [] ids=mulitId.split(",");
|
||||
for (int i = 0; i < ids.length; i++) {
|
||||
ServiceDictInfo dict= serviceDictInfoService.getDictById(Integer.valueOf(ids[i]));
|
||||
if(dict!=null){
|
||||
UserManage user =new UserManage();
|
||||
user.setServerIp(dict.getItemValue()+",");
|
||||
List<UserManage> list=userManageService.findList(user);
|
||||
if(list!=null && list.size()>0){
|
||||
exIp+=dict.getItemValue()+",";
|
||||
}else{
|
||||
id+=ids[i]+",";
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
id=mulitId;
|
||||
}
|
||||
if(!StringUtil.isEmpty(id)){
|
||||
serviceDictInfoService.deleteDict(id);
|
||||
}
|
||||
if(!StringUtil.isEmpty(exIp)){
|
||||
exIp=exIp.substring(0, exIp.length()-1);
|
||||
addMessage(redirectAttributes,"error", "IP "+exIp+" "+msgProp.getProperty("user_check"));
|
||||
}else{
|
||||
addMessage(redirectAttributes,"success", "delete_success");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
addMessage(redirectAttributes,"error", "delete_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
return "redirect:" + adminPath + "/basics/serviceDictInfo/list?itType="+itType;
|
||||
}
|
||||
@@ -557,6 +591,7 @@ public class ServiceDictInfoController extends BaseController {
|
||||
} catch (Exception e) {
|
||||
logger.error("dict white export failed", e);
|
||||
addMessage(redirectAttributes, "error", "export_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -593,4 +628,17 @@ public class ServiceDictInfoController extends BaseController {
|
||||
return dicName;
|
||||
}
|
||||
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value = "ajaxIpRepeat")
|
||||
public boolean ajaxIpRepeat(String oldIp, String ip,Integer type) {
|
||||
if (ip !=null && ip.equals(oldIp)) {
|
||||
return true;
|
||||
} else if (ip !=null && serviceDictInfoService.getByItemValue(ip,type) == null) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.nis.domain.basics.ServiceDictInfo;
|
||||
import com.nis.domain.basics.SysDictInfo;
|
||||
import com.nis.util.ConfigDictUtils;
|
||||
import com.nis.util.Configurations;
|
||||
import com.nis.util.LogUtils;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.util.StringUtils;
|
||||
import com.nis.web.controller.BaseController;
|
||||
@@ -151,7 +152,7 @@ public class SysDictInfoController extends BaseController {
|
||||
*/
|
||||
@RequiresPermissions(value={"basics:area:add","basics:isp:add","basics:scope:add","basics:area:edit","basics:isp:edit","basics:scope:edit"},logical=Logical.OR)
|
||||
@RequestMapping(value = "saveOrUpdate")
|
||||
public String saveOrUpdate(SysDictInfo sysDictInfo,Model model, RedirectAttributes redirectAttributes, String itType) {
|
||||
public String saveOrUpdate(SysDictInfo sysDictInfo,Model model, RedirectAttributes redirectAttributes, String itType,HttpServletRequest request) {
|
||||
|
||||
try {
|
||||
sysDictInfoService.saveOrUpdate(sysDictInfo);
|
||||
@@ -159,6 +160,7 @@ public class SysDictInfoController extends BaseController {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
addMessage(redirectAttributes,"error", "save_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
|
||||
return "redirect:" + adminPath + "/basics/sysDictInfo/list?itType="+itType;
|
||||
@@ -172,13 +174,14 @@ public class SysDictInfoController extends BaseController {
|
||||
*/
|
||||
@RequiresPermissions(value={"basics:area:del","basics:isp:del","basics:scope:del"},logical=Logical.OR)
|
||||
@RequestMapping(value={"delete"})
|
||||
public String delete(SysDictInfo sysDictInfo, RedirectAttributes redirectAttributes, String itType, String mulitId) {
|
||||
public String delete(SysDictInfo sysDictInfo, RedirectAttributes redirectAttributes, String itType, String mulitId,HttpServletRequest request) {
|
||||
try {
|
||||
sysDictInfoService.deleteDict(mulitId);
|
||||
addMessage(redirectAttributes,"success", "delete_success");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
addMessage(redirectAttributes,"error", "delete_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
return "redirect:" + adminPath + "/basics/sysDictInfo/list?itType="+itType;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.nis.domain.configuration.RequestInfo;
|
||||
import com.nis.domain.configuration.TaskInfo;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.DateUtils;
|
||||
import com.nis.util.LogUtils;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.util.excel.ExcelField;
|
||||
import com.nis.web.controller.BaseController;
|
||||
@@ -90,6 +91,7 @@ public class TaskInfoController extends BaseController{
|
||||
logger.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
addMessage(redirectAttributes,"error", "save_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
return "redirect:" + adminPath + "/basics/taskInfo/list?functionId="+taskInfo.getFunctionId()+"&repage";
|
||||
}
|
||||
@@ -233,6 +235,7 @@ public class TaskInfoController extends BaseController{
|
||||
} catch (Exception e) {
|
||||
logger.error("ip addr export failed",e);
|
||||
addMessage(redirectAttributes,"error", "export_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
//return "redirect:" + adminPath +"/ntc/iplist/list?functionId="+entity.getFunctionId();
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -58,6 +58,7 @@ import com.nis.util.Constants;
|
||||
import com.nis.util.DictUtils;
|
||||
import com.nis.util.FileUtils;
|
||||
import com.nis.util.JsonMapper;
|
||||
import com.nis.util.LogUtils;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.web.controller.BaseController;
|
||||
import com.nis.web.security.UserUtils;
|
||||
@@ -86,9 +87,23 @@ public class AppFeatureCfgController extends BaseController {
|
||||
Page<AppFeatureIndex> searchPage = new Page<AppFeatureIndex>(request, response, "r");
|
||||
Page<AppFeatureIndex> page = appMultiFeatureCfgService.findAppFeatureIndexList(searchPage, cfg);
|
||||
for (AppFeatureIndex entity : page.getList()) {
|
||||
SpecificServiceCfg app = specificServiceCfgService.getBySpecServiceId(entity.getSpecServiceId());
|
||||
// 查找社交应用的所有有效一级特定服务
|
||||
SpecificServiceCfg appSpec = new SpecificServiceCfg();
|
||||
for (SysDataDictionaryItem dict : DictUtils.getDictList("SPECIFIC_SERVICE_CFG_TYPE")) {
|
||||
if (Constants.SPECIFIC_SERVICE_CFG_TYPE_APP.equals(dict.getItemValue())) {
|
||||
appSpec.setCfgType(Integer.parseInt(dict.getItemCode()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
appSpec.setIsValid(Constants.VALID_YES);
|
||||
appSpec.setIsLeaf(0);
|
||||
appSpec.setSpecServiceCode(entity.getAppCode());
|
||||
List<SpecificServiceCfg> appList = specificServiceCfgService.findAllSpecificServiceCfg(appSpec, null);
|
||||
if (!StringUtil.isEmpty(appList)) {
|
||||
SpecificServiceCfg app = appList.get(0);
|
||||
entity.setAppName(app.getSpecServiceName());
|
||||
}
|
||||
}
|
||||
model.addAttribute("page", page);
|
||||
initPageCondition(model, cfg);
|
||||
return "/cfg/app/appMultiFeatureCfgList";
|
||||
@@ -114,6 +129,24 @@ public class AppFeatureCfgController extends BaseController {
|
||||
entity.getFunctionId(), null));
|
||||
entity.setNumCfgList(
|
||||
appMultiFeatureCfgService.getAppTcpCfg(entity.getCompileId(), entity.getFunctionId(), null));
|
||||
|
||||
// 查找社交应用的所有有效一级特定服务
|
||||
SpecificServiceCfg appSpec = new SpecificServiceCfg();
|
||||
for (SysDataDictionaryItem dict : DictUtils.getDictList("SPECIFIC_SERVICE_CFG_TYPE")) {
|
||||
if (Constants.SPECIFIC_SERVICE_CFG_TYPE_APP.equals(dict.getItemValue())) {
|
||||
appSpec.setCfgType(Integer.parseInt(dict.getItemCode()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
appSpec.setIsValid(Constants.VALID_YES);
|
||||
appSpec.setIsLeaf(0);
|
||||
appSpec.setSpecServiceCode(entity.getAppCode());
|
||||
List<SpecificServiceCfg> appList = specificServiceCfgService.findAllSpecificServiceCfg(appSpec, null);
|
||||
if (!StringUtil.isEmpty(appList)) {
|
||||
SpecificServiceCfg app = appList.get(0);
|
||||
entity.setSpecServiceId(app.getSpecServiceId());
|
||||
}
|
||||
|
||||
initUpdateFormCondition(model, entity);
|
||||
} else {
|
||||
initFormCondition(model, entity);
|
||||
@@ -142,14 +175,21 @@ public class AppFeatureCfgController extends BaseController {
|
||||
entity.setAppCode(specificService.getSpecServiceCode());
|
||||
}
|
||||
appMultiFeatureCfgService.saveOrUpdateAppFeatureCfg(entity);
|
||||
//配置仅保存
|
||||
if(StringUtil.isEmpty(entity.getIsValid()) || entity.getIsValid()!=1) {
|
||||
addMessage(redirectAttributes, "success", "save_success");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
if (e instanceof MaatConvertException) {
|
||||
addMessage(redirectAttributes, "error", "request_service_failed");
|
||||
} else {
|
||||
addMessage(redirectAttributes, "error", "save_failed");
|
||||
}else {
|
||||
//配置直接生效
|
||||
addMessage(redirectAttributes, "success", "audit_success");
|
||||
}
|
||||
} catch (MaatConvertException e) {
|
||||
logger.error("APP 特征配置下发失败:",e);
|
||||
addMessage(redirectAttributes, "error", "request_service_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
} catch (Exception e) {
|
||||
logger.error("APP 特征配置保存失败:",e);
|
||||
addMessage(redirectAttributes, "error", "save_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
|
||||
return "redirect:" + adminPath + "/app/feature/multiFeatureCfgList?functionId=" + entity.getFunctionId();
|
||||
@@ -176,20 +216,20 @@ public class AppFeatureCfgController extends BaseController {
|
||||
entity = appMultiFeatureCfgService.getAppFeatureIndex(Long.parseLong(id));
|
||||
entity.setIsAudit(isAudit);
|
||||
entity.setIsValid(isValid);
|
||||
entity.setAuditorId(UserUtils.getUser().getId());
|
||||
entity.setAuditTime(new Date());
|
||||
entity.setFunctionId(functionId);
|
||||
try {
|
||||
appMultiFeatureCfgService.auditAppFeatureCfg(entity, isAudit);
|
||||
appMultiFeatureCfgService.auditAppFeatureCfg(entity, isAudit,Constants.INSERT_ACTION);
|
||||
addMessage(redirectAttributes, "success", "audit_success");
|
||||
} catch (MaatConvertException e) {
|
||||
e.printStackTrace();
|
||||
logger.error("app 特征配置下发失败:" + e.getMessage());
|
||||
addMessage(redirectAttributes, "error", "request_service_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("app 特征配置下发失败:" + e.getMessage());
|
||||
addMessage(redirectAttributes, "error", "audit_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -204,8 +244,10 @@ public class AppFeatureCfgController extends BaseController {
|
||||
logger.error("配置下发失败:", e);
|
||||
if (e instanceof MaatConvertException) {
|
||||
addMessage(redirectAttributes, "error", "request_service_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
} else {
|
||||
addMessage(redirectAttributes, "error", "audit_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -225,8 +267,28 @@ public class AppFeatureCfgController extends BaseController {
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = { "updateAppFeatureCfgValid" })
|
||||
public String updateAppFeatureCfgValid(Integer isValid, String ids, Integer functionId) {
|
||||
public String updateAppFeatureCfgValid(Integer isValid, String ids, Integer functionId, RedirectAttributes redirectAttributes,
|
||||
HttpServletRequest request, HttpServletResponse response, @ModelAttribute("cfg")AppFeatureIndex cfg) {
|
||||
try {
|
||||
if (!StringUtil.isEmpty(ids)) {
|
||||
appMultiFeatureCfgService.updateAppFeatureCfgValid(isValid, ids, functionId);
|
||||
addMessage(redirectAttributes, "success", "delete_success");
|
||||
}else {
|
||||
// 批量删除
|
||||
Page<AppFeatureIndex> searchPage = new Page<AppFeatureIndex>(request, response, "a");
|
||||
deleteAll(searchPage, functionId, cfg);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("配置删除失败:", e);
|
||||
if (e instanceof MaatConvertException) {
|
||||
addMessage(redirectAttributes, "error", "request_service_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
} else {
|
||||
addMessage(redirectAttributes, "error", "delete_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
|
||||
}
|
||||
return "redirect:" + adminPath + "/app/feature/multiFeatureCfgList?functionId=" + functionId;
|
||||
}
|
||||
|
||||
@@ -321,9 +383,23 @@ public class AppFeatureCfgController extends BaseController {
|
||||
}
|
||||
|
||||
for (AppFeatureIndex feature : ipLists) {
|
||||
SpecificServiceCfg app = specificServiceCfgService.getBySpecServiceId(feature.getSpecServiceId());
|
||||
// 查找社交应用的所有有效一级特定服务
|
||||
SpecificServiceCfg appSpec = new SpecificServiceCfg();
|
||||
for (SysDataDictionaryItem dict : DictUtils.getDictList("SPECIFIC_SERVICE_CFG_TYPE")) {
|
||||
if (Constants.SPECIFIC_SERVICE_CFG_TYPE_APP.equals(dict.getItemValue())) {
|
||||
appSpec.setCfgType(Integer.parseInt(dict.getItemCode()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
appSpec.setIsValid(Constants.VALID_YES);
|
||||
appSpec.setIsLeaf(0);
|
||||
appSpec.setSpecServiceCode(feature.getAppCode());
|
||||
List<SpecificServiceCfg> appList = specificServiceCfgService.findAllSpecificServiceCfg(appSpec, null);
|
||||
if (!StringUtil.isEmpty(appList)) {
|
||||
SpecificServiceCfg app = appList.get(0);
|
||||
feature.setAppName(app.getSpecServiceName());
|
||||
}
|
||||
}
|
||||
String cfgIndexInfoNoExport = ",letter,whether_area_block,classification,attribute,label,do_log,block_type,client_port,ir_type,group_name,userregion1,userregion2,userregion3,userregion4,userregion5,";
|
||||
String appComplexNoExport = ",do_log,block_type,config_describe,valid_identifier,is_audit,creator,creator"
|
||||
+ ",config_time,editor,edit_time,auditor,audit_time"
|
||||
@@ -332,7 +408,7 @@ public class AppFeatureCfgController extends BaseController {
|
||||
String ipPortInfoNoExport = ",do_log,block_type,config_describe,valid_identifier,is_audit,creator,creator"
|
||||
+ ",config_time,editor,edit_time,auditor,audit_time"
|
||||
+ ",letter,whether_area_block,classification,attribute,label"
|
||||
+ ",userregion1,userregion2,userregion3,userregion4,userregion5,ir_type,group_name,";
|
||||
+ ",userregion1,userregion2,userregion3,userregion4,userregion5,ir_type,group_name,client_ip,src_ip_pattern,client_port,src_port_pattern,";
|
||||
|
||||
// 时间过滤
|
||||
if (entity.getSearch_create_time_start() == null && entity.getSearch_create_time_end() == null) {
|
||||
@@ -415,6 +491,7 @@ public class AppFeatureCfgController extends BaseController {
|
||||
} catch (Exception e) {
|
||||
logger.error("Appfeature export failed", e);
|
||||
addMessage(redirectAttributes, "error", "export_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
// return "redirect:" + adminPath
|
||||
// +"/ntc/iplist/list?functionId="+entity.getFunctionId();
|
||||
@@ -424,7 +501,12 @@ public class AppFeatureCfgController extends BaseController {
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
AppComplexFeatureCfg base = (AppComplexFeatureCfg) list.get(i);
|
||||
base.setIsHex(base.getIsHexbin());
|
||||
base.setIsCaseInsenstive(base.getIsHexbin());
|
||||
// '默认为0:大小写不敏感,且非HEX;1:HEX格式二进制;2:大小写敏感,且非HEX',
|
||||
if(base.getIsHexbin()==2){
|
||||
base.setIsCaseInsenstive(1);
|
||||
}else{
|
||||
base.setIsCaseInsenstive(0);
|
||||
}
|
||||
base.setCfgKeywords(Functions.replace(base.getCfgKeywords(), "***and***", " "));
|
||||
}
|
||||
return list;
|
||||
@@ -434,7 +516,12 @@ public class AppFeatureCfgController extends BaseController {
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
AppStringFeatureCfg base = (AppStringFeatureCfg) list.get(i);
|
||||
base.setIsHex(base.getIsHexbin());
|
||||
base.setIsCaseInsenstive(base.getIsHexbin());
|
||||
// '默认为0:大小写不敏感,且非HEX;1:HEX格式二进制;2:大小写敏感,且非HEX',
|
||||
if(base.getIsHexbin()==2){
|
||||
base.setIsCaseInsenstive(1);
|
||||
}else{
|
||||
base.setIsCaseInsenstive(0);
|
||||
}
|
||||
base.setCfgKeywords(Functions.replace(base.getCfgKeywords(), "***and***", " "));
|
||||
}
|
||||
return list;
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.SysDataDictionaryItem;
|
||||
import com.nis.domain.configuration.AppPolicyCfg;
|
||||
import com.nis.domain.configuration.BaseStringCfg;
|
||||
import com.nis.domain.configuration.CfgIndexInfo;
|
||||
@@ -36,6 +37,8 @@ import com.nis.exceptions.CallExternalProceduresException;
|
||||
import com.nis.exceptions.MaatConvertException;
|
||||
import com.nis.util.ConfigServiceUtil;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.DictUtils;
|
||||
import com.nis.util.LogUtils;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.web.controller.BaseController;
|
||||
import com.nis.web.security.UserUtils;
|
||||
@@ -129,6 +132,25 @@ public class BasicProtocolController extends BaseController {
|
||||
public String policyCfgForm(Model model, String ids, AppPolicyCfg entity) {
|
||||
if (StringUtils.isNotBlank(ids)) {
|
||||
entity = appCfgService.getAppPolicyCfg(Long.parseLong(ids), null);
|
||||
|
||||
|
||||
// 查找社交应用的所有有效一级特定服务
|
||||
SpecificServiceCfg appSpec = new SpecificServiceCfg();
|
||||
for (SysDataDictionaryItem dict : DictUtils.getDictList("SPECIFIC_SERVICE_CFG_TYPE")) {
|
||||
if (Constants.SPECIFIC_SERVICE_CFG_TYPE_BASIC_PROTOCOL.equals(dict.getItemValue())) {
|
||||
appSpec.setCfgType(Integer.parseInt(dict.getItemCode()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
appSpec.setIsValid(Constants.VALID_YES);
|
||||
appSpec.setIsLeaf(0);
|
||||
appSpec.setSpecServiceCode(entity.getAppCode());
|
||||
List<SpecificServiceCfg> appList = specificServiceCfgService.findAllSpecificServiceCfg(appSpec, null);
|
||||
if (!StringUtil.isEmpty(appList)) {
|
||||
SpecificServiceCfg app = appList.get(0);
|
||||
entity.setSpecServiceId(app.getSpecServiceId());
|
||||
}
|
||||
|
||||
initUpdateFormCondition(model, entity);
|
||||
} else {
|
||||
initFormCondition(model, entity);
|
||||
@@ -158,18 +180,25 @@ public class BasicProtocolController extends BaseController {
|
||||
entity.setAppCode(specificService.getSpecServiceCode());
|
||||
}
|
||||
appCfgService.saveOrUpdateAppPolicyCfg(entity);
|
||||
//配置仅保存
|
||||
if(StringUtil.isEmpty(entity.getIsValid()) || entity.getIsValid()!=1) {
|
||||
addMessage(redirectAttributes, "success", "save_success");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("基础协议信息保存失败", e);
|
||||
if (e instanceof MaatConvertException) {
|
||||
// addMessage(redirectAttributes,e.getMessage());
|
||||
addMessage(redirectAttributes, "error", "request_service_failed");
|
||||
} else if (e instanceof CallExternalProceduresException) {
|
||||
addMessage(redirectAttributes, "error", "call_external_procedures_failed");
|
||||
} else {
|
||||
addMessage(redirectAttributes, "error", "save_failed");
|
||||
}else {
|
||||
//配置直接生效
|
||||
addMessage(redirectAttributes, "success", "audit_success");
|
||||
}
|
||||
} catch (MaatConvertException e) {
|
||||
logger.error("基础协议配置下发失败:",e);
|
||||
addMessage(redirectAttributes, "error", "request_service_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
} catch (CallExternalProceduresException e) {
|
||||
logger.error("调用外部程序出错:",e);
|
||||
addMessage(redirectAttributes, "error", "call_external_procedures_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
} catch (Exception e) {
|
||||
logger.error("基础协议配置保存失败:",e);
|
||||
addMessage(redirectAttributes, "error", "save_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
|
||||
return "redirect:" + adminPath + "/basicprotocol/list?functionId=" + entity.getFunctionId();
|
||||
@@ -197,12 +226,10 @@ public class BasicProtocolController extends BaseController {
|
||||
entity = appCfgService.getAppPolicyCfg(Long.parseLong(id), null);
|
||||
entity.setIsAudit(isAudit);
|
||||
entity.setIsValid(isValid);
|
||||
entity.setAuditorId(UserUtils.getUser().getId());
|
||||
entity.setAuditTime(new Date());
|
||||
entity.setFunctionId(functionId);
|
||||
entity.setConfigType(Constants.SPECIFIC_SERVICE_CFG_TYPE_BASIC_PROTOCOL);
|
||||
try {
|
||||
appCfgService.auditAppPolicyCfg(entity, isAudit);
|
||||
appCfgService.auditAppPolicyCfg(entity, isAudit,Constants.INSERT_ACTION);
|
||||
addMessage(redirectAttributes, "success", "audit_success");
|
||||
} catch (Exception e) {
|
||||
if (e instanceof MaatConvertException) {
|
||||
@@ -210,10 +237,12 @@ public class BasicProtocolController extends BaseController {
|
||||
logger.info("app策略配置下发失败:" + e.getMessage());
|
||||
;
|
||||
addMessage(redirectAttributes, "error", "request_service_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
} else {
|
||||
e.printStackTrace();
|
||||
logger.error("app策略配置下发失败", e);
|
||||
addMessage(redirectAttributes, "error", "audit_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -230,8 +259,10 @@ public class BasicProtocolController extends BaseController {
|
||||
logger.error("配置下发失败:", e);
|
||||
if (e instanceof MaatConvertException) {
|
||||
addMessage(redirectAttributes, "error", "request_service_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
} else {
|
||||
addMessage(redirectAttributes, "error", "audit_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -251,21 +282,26 @@ public class BasicProtocolController extends BaseController {
|
||||
*/
|
||||
@RequestMapping(value = { "updateValid" })
|
||||
@RequiresPermissions(value = { "basicprotocol:config" })
|
||||
public String updateAppPolicyCfgValid(Integer isValid, String ids, Integer functionId,
|
||||
RedirectAttributes redirectAttributes) {
|
||||
public String updateAppPolicyCfgValid(Integer isValid, String ids, Integer functionId, RedirectAttributes redirectAttributes,
|
||||
HttpServletRequest request, HttpServletResponse response, @ModelAttribute("cfg")AppPolicyCfg cfg) {
|
||||
try {
|
||||
if(!StringUtil.isEmpty(ids)) {
|
||||
appCfgService.updateAppPolicyCfgValid(isValid, ids, functionId);
|
||||
addMessage(redirectAttributes, "success", "delete_success");
|
||||
}else {
|
||||
Page<AppPolicyCfg> searchPage = new Page<AppPolicyCfg>(request, response, "a");
|
||||
deleteAll(searchPage, functionId, cfg);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("基础协议信息保存失败", e);
|
||||
if (e instanceof MaatConvertException) {
|
||||
e.printStackTrace();
|
||||
addMessage(redirectAttributes, "error", "request_service_failed");
|
||||
} else if (e instanceof CallExternalProceduresException) {
|
||||
addMessage(redirectAttributes, "error", "call_external_procedures_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
} else {
|
||||
e.printStackTrace();
|
||||
addMessage(redirectAttributes, "error", "delete_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
}
|
||||
return "redirect:" + adminPath + "/basicprotocol/list?functionId=" + functionId;
|
||||
@@ -308,8 +344,20 @@ public class BasicProtocolController extends BaseController {
|
||||
logTotal.put("sum",0L);
|
||||
logTotals.add(logTotal);
|
||||
}
|
||||
SpecificServiceCfg app = specificServiceCfgService.getBySpecServiceId(policy.getSpecServiceId());
|
||||
if (app != null) {
|
||||
// 查找社交应用的所有有效一级特定服务 TODO
|
||||
SpecificServiceCfg appSpec = new SpecificServiceCfg();
|
||||
for (SysDataDictionaryItem dict : DictUtils.getDictList("SPECIFIC_SERVICE_CFG_TYPE")) {
|
||||
if (Constants.SPECIFIC_SERVICE_CFG_TYPE_BASIC_PROTOCOL.equals(dict.getItemValue())) {
|
||||
appSpec.setCfgType(Integer.parseInt(dict.getItemCode()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
appSpec.setIsValid(Constants.VALID_YES);
|
||||
appSpec.setIsLeaf(0);
|
||||
appSpec.setSpecServiceCode(policy.getAppCode());
|
||||
List<SpecificServiceCfg> appList = specificServiceCfgService.findAllSpecificServiceCfg(appSpec, null);
|
||||
if (!StringUtil.isEmpty(appList)) {
|
||||
SpecificServiceCfg app = appList.get(0);
|
||||
policy.setAppName(app.getSpecServiceName());
|
||||
}
|
||||
|
||||
@@ -392,6 +440,7 @@ public class BasicProtocolController extends BaseController {
|
||||
} catch (Exception e) {
|
||||
logger.error("ip addr export failed", e);
|
||||
addMessage(redirectAttributes, "error", "export_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
// return "redirect:" + adminPath
|
||||
// +"/ntc/iplist/list?functionId="+entity.getFunctionId();
|
||||
|
||||
@@ -8,10 +8,8 @@
|
||||
*/
|
||||
package com.nis.web.controller.configuration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
@@ -19,38 +17,22 @@ import java.util.Properties;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.axis2.databinding.types.soapencoding.Array;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
import com.nis.domain.FunctionRegionDict;
|
||||
import com.nis.domain.FunctionServiceDict;
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.basics.ServiceDictInfo;
|
||||
import com.nis.domain.configuration.BaseIpCfg;
|
||||
import com.nis.domain.configuration.CfgIndexInfo;
|
||||
import com.nis.domain.configuration.HttpBodyCfg;
|
||||
import com.nis.domain.configuration.HttpReqHeadCfg;
|
||||
import com.nis.domain.configuration.HttpResHeadCfg;
|
||||
import com.nis.domain.configuration.HttpUrlCfg;
|
||||
import com.nis.domain.configuration.template.IpAllTemplate;
|
||||
import com.nis.domain.configuration.template.IpCfgTemplate;
|
||||
import com.nis.domain.specific.ConfigGroupInfo;
|
||||
import com.nis.domain.configuration.IpPortCfg;
|
||||
import com.nis.domain.configuration.NtcSubscribeIdCfg;
|
||||
import com.nis.exceptions.MaatConvertException;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.DateUtils;
|
||||
import com.nis.util.DictUtils;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.util.excel.ExportExcel;
|
||||
import com.nis.util.excel.ImportExcel;
|
||||
import com.nis.web.controller.BaseController;
|
||||
import com.nis.web.dao.configuration.IpCfgDao;
|
||||
import com.nis.web.security.UserUtils;
|
||||
|
||||
/**
|
||||
* @ClassName: CommonController.java
|
||||
@@ -288,15 +270,7 @@ public class CommonController extends BaseController {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}*/
|
||||
public void _importFileTemplate(HttpServletRequest request,HttpServletResponse response,
|
||||
RedirectAttributes redirectAttributes,Integer functionId,Integer cfgRegionCode) {
|
||||
this.importCfgTemplate(request, response, redirectAttributes, functionId, cfgRegionCode);
|
||||
}
|
||||
@Deprecated
|
||||
public void _importFileTemplate(HttpServletRequest request,HttpServletResponse response,
|
||||
RedirectAttributes redirectAttributes,Integer functionId,Integer cfgRegionCode,Class clazz) {
|
||||
this.importCfgTemplate(request, response, redirectAttributes, functionId, cfgRegionCode,clazz);
|
||||
}
|
||||
|
||||
//ip配置导出
|
||||
public void _exportIp(String columns,Model model,HttpServletRequest request,HttpServletResponse response,
|
||||
IpPortCfg entity,String ids,RedirectAttributes redirectAttributes){
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.nis.util.ConfigServiceUtil;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.DateUtils;
|
||||
import com.nis.util.DictUtils;
|
||||
import com.nis.util.LogUtils;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.web.controller.BaseController;
|
||||
import com.nis.web.service.BaseService;
|
||||
@@ -51,10 +52,11 @@ public class ConfigSynchronizationController extends BaseController {
|
||||
* 下发同步命令
|
||||
*/
|
||||
@RequestMapping(value = {"configSync"})
|
||||
public String configSync(Model model,Integer cmd,HttpServletRequest request,HttpServletResponse response){
|
||||
public String configSync(Model model,Integer cmd,Integer serviceId,HttpServletRequest request,HttpServletResponse response){
|
||||
Map<String,Integer> map = new HashMap();
|
||||
map.put("syncStatus", cmd);
|
||||
JSONObject result = ConfigServiceUtil.configSyncCmd(BaseService.gsonToJson(map));
|
||||
//JSONObject result=JSONObject.fromObject("{\"status\": 201,\"businessCode\": 2001000,\"reason\":\"数据获取操作成功\",\"msg\": \"根据配置id获取对应的编译,组,域等信息成功\",\"fromuri\": \"/galaxy-service/service/cfg/v1/getAllKVByCompileId\",\"traceCode\": \"2019031211285044813363\",\"data\": [{\"service\":\"ntc\",\"status\":0,\"opTime\":\"2016-11-22 08:31:27\"}]}");
|
||||
if(result.get("status").equals(201)){//响应成功
|
||||
if(cmd.equals(1)){//同步
|
||||
SysDataDictionaryName sysDictName = new SysDataDictionaryName();
|
||||
@@ -71,13 +73,22 @@ public class ConfigSynchronizationController extends BaseController {
|
||||
dictService.updateDictItem(item);
|
||||
//删除字典缓存
|
||||
CacheUtils.remove(Constants.CACHE_DICT_MAP);
|
||||
|
||||
//全量同步之前等待一段时间,避免定时任务还未扫描到当前的同步状态。
|
||||
try{
|
||||
Thread.sleep(60000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
}
|
||||
send(model,request,response);
|
||||
}
|
||||
send(serviceId,model,request,response);
|
||||
}else if(cmd.equals(0)){//取消
|
||||
|
||||
}
|
||||
}
|
||||
model.addAttribute("serviceId", serviceId);
|
||||
return "/sys/configSyncInfo";
|
||||
}
|
||||
|
||||
@@ -85,26 +96,33 @@ public class ConfigSynchronizationController extends BaseController {
|
||||
* 下发同步配置
|
||||
*/
|
||||
@RequestMapping(value = {"send"})
|
||||
public void send(Model model,HttpServletRequest request,HttpServletResponse response){
|
||||
public void send(Integer serviceId,Model model,HttpServletRequest request,HttpServletResponse response){
|
||||
int status = -2;
|
||||
try {
|
||||
configSynchronizationService.send(request,response,null);
|
||||
configSynchronizationService.send(serviceId,request,response,null);
|
||||
status = 1;
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
} catch (SecurityException e) {
|
||||
e.printStackTrace();
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
} catch (IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}catch(MaatConvertException e){
|
||||
e.printStackTrace();
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
status = -1;
|
||||
}catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}finally{
|
||||
if(status!=1){
|
||||
SysDataDictionaryName sysDictName = new SysDataDictionaryName();
|
||||
@@ -129,6 +147,7 @@ public class ConfigSynchronizationController extends BaseController {
|
||||
boolean isFinished = true;
|
||||
while(isFinished){
|
||||
JSONObject result = ConfigServiceUtil.configSyncStatus();//获取同步状态
|
||||
//JSONObject result = JSONObject.fromObject("{\"status\": 200,\"businessCode\": 2001000,\"reason\":\"数据获取操作成功\",\"msg\": \"根据配置id获取对应的编译,组,域等信息成功\",\"fromuri\": \"/galaxy-service/service/cfg/v1/getAllKVByCompileId\",\"traceCode\": \"2019031211285044813363\",\"data\": [{\"service\":\"ntc\",\"status\":3,\"opTime\":\"2016-11-22 08:31:27\"}]}");
|
||||
if(result.get("status").equals(200)){
|
||||
List<Map<String,Object>> list = result.getJSONArray("data");
|
||||
if(!StringUtil.isEmpty(list)){
|
||||
@@ -162,6 +181,7 @@ public class ConfigSynchronizationController extends BaseController {
|
||||
Thread.sleep(60000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,6 +200,7 @@ public class ConfigSynchronizationController extends BaseController {
|
||||
String failStatus = DictUtils.getDictCode("config_sync_status", "fail","-2");
|
||||
Map<String,Object> map = Maps.newHashMap();
|
||||
if(!currentStatus.equals(successStatus) && !currentStatus.equals(failStatus) && !currentStatus.equals(serverFailStatus)){
|
||||
//JSONObject result = JSONObject.fromObject("{\"status\": 200,\"businessCode\": 2001000,\"reason\":\"数据获取操作成功\",\"msg\": \"根据配置id获取对应的编译,组,域等信息成功\",\"fromuri\": \"/galaxy-service/service/cfg/v1/getAllKVByCompileId\",\"traceCode\": \"2019031211285044813363\",\"data\": [{\"service\":\"ntc\",\"status\":0,\"opTime\":\"2016-11-22 08:31:27\"}]}");
|
||||
JSONObject result = ConfigServiceUtil.configSyncStatus();//获取同步状态
|
||||
if(result.get("status").equals(200)){
|
||||
List<Map<String,Object>> list = result.getJSONArray("data");
|
||||
|
||||
@@ -11,6 +11,7 @@ import java.util.Set;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
@@ -26,6 +27,7 @@ import com.nis.domain.Page;
|
||||
import com.nis.domain.SysDataDictionaryItem;
|
||||
import com.nis.domain.configuration.AppPolicyCfg;
|
||||
import com.nis.domain.configuration.BaseStringCfg;
|
||||
import com.nis.domain.configuration.CfgIndexInfo;
|
||||
import com.nis.domain.configuration.IpPortCfg;
|
||||
import com.nis.domain.configuration.NtcSubscribeIdCfg;
|
||||
import com.nis.domain.specific.SpecificServiceCfg;
|
||||
@@ -33,6 +35,7 @@ import com.nis.exceptions.CallExternalProceduresException;
|
||||
import com.nis.exceptions.MaatConvertException;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.DictUtils;
|
||||
import com.nis.util.LogUtils;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.web.controller.BaseController;
|
||||
import com.nis.web.security.UserUtils;
|
||||
@@ -111,7 +114,7 @@ public class EncryptedTunnelBehaviorController extends BaseController {
|
||||
public String ajaxSslSubList(Model model, Long cfgId, Integer index, Integer compileId) {
|
||||
AppPolicyCfg cfg = appCfgService.getAppPolicyCfg(cfgId, compileId);
|
||||
List<String[]> tabList = new ArrayList();
|
||||
if (cfg.getIpPortList() != null) {
|
||||
if (CollectionUtils.isNotEmpty(cfg.getIpPortList())) {
|
||||
String cfgType = null;
|
||||
for (IpPortCfg ip : cfg.getIpPortList()) {
|
||||
if (!ip.getCfgType().equals(cfgType)) {
|
||||
@@ -120,7 +123,7 @@ public class EncryptedTunnelBehaviorController extends BaseController {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (cfg.getNtcSubscribeIdCfgList() != null) {
|
||||
if (CollectionUtils.isNotEmpty(cfg.getNtcSubscribeIdCfgList())) {
|
||||
String cfgType = null;
|
||||
for (NtcSubscribeIdCfg ntc : cfg.getNtcSubscribeIdCfgList()) {
|
||||
if (!ntc.getCfgType().equals(cfgType)) {
|
||||
@@ -148,6 +151,24 @@ public class EncryptedTunnelBehaviorController extends BaseController {
|
||||
public String policyCfgForm(Model model, String ids, AppPolicyCfg entity) {
|
||||
if (StringUtils.isNotBlank(ids)) {
|
||||
entity = appCfgService.getAppPolicyCfg(Long.parseLong(ids), null);
|
||||
|
||||
// 查找社交应用的所有有效一级特定服务
|
||||
SpecificServiceCfg appSpec = new SpecificServiceCfg();
|
||||
for (SysDataDictionaryItem dict : DictUtils.getDictList("SPECIFIC_SERVICE_CFG_TYPE")) {
|
||||
if (Constants.SPECIFIC_SERVICE_CFG_TYPE_ENCRYPTED_TUNNEL_BEHAVIOR.equals(dict.getItemValue())) {
|
||||
appSpec.setCfgType(Integer.parseInt(dict.getItemCode()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
appSpec.setIsValid(Constants.VALID_YES);
|
||||
appSpec.setIsLeaf(0);
|
||||
appSpec.setSpecServiceCode(entity.getAppCode());
|
||||
List<SpecificServiceCfg> appList = specificServiceCfgService.findAllSpecificServiceCfg(appSpec, null);
|
||||
if (!StringUtil.isEmpty(appList)) {
|
||||
SpecificServiceCfg app = appList.get(0);
|
||||
entity.setSpecServiceId(app.getSpecServiceId());
|
||||
}
|
||||
|
||||
initUpdateFormCondition(model, entity);
|
||||
} else {
|
||||
initFormCondition(model, entity);
|
||||
@@ -177,17 +198,25 @@ public class EncryptedTunnelBehaviorController extends BaseController {
|
||||
entity.setAppCode(specificService.getSpecServiceCode());
|
||||
}
|
||||
appCfgService.saveOrUpdateAppPolicyCfg(entity);
|
||||
//配置仅保存
|
||||
if(StringUtil.isEmpty(entity.getIsValid()) || entity.getIsValid()!=1) {
|
||||
addMessage(redirectAttributes, "success", "save_success");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("加密隧道信息保存失败", e);
|
||||
if (e instanceof MaatConvertException) {
|
||||
addMessage(redirectAttributes, "error", "request_service_failed");
|
||||
} else if (e instanceof CallExternalProceduresException) {
|
||||
addMessage(redirectAttributes, "error", "call_external_procedures_failed");
|
||||
} else {
|
||||
addMessage(redirectAttributes, "error", "save_failed");
|
||||
}else {
|
||||
//配置直接生效
|
||||
addMessage(redirectAttributes, "success", "audit_success");
|
||||
}
|
||||
} catch (MaatConvertException e) {
|
||||
logger.error("加密隧道行为配置下发失败:",e);
|
||||
addMessage(redirectAttributes, "error", "request_service_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
} catch (CallExternalProceduresException e) {
|
||||
logger.error("调用外部程序出错:",e);
|
||||
addMessage(redirectAttributes, "error", "call_external_procedures_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
} catch (Exception e) {
|
||||
logger.error("加密隧道行为配置保存失败:",e);
|
||||
addMessage(redirectAttributes, "error", "save_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
|
||||
return "redirect:" + adminPath + "/encryptedtunnelbehav/list?functionId=" + entity.getFunctionId();
|
||||
@@ -220,7 +249,7 @@ public class EncryptedTunnelBehaviorController extends BaseController {
|
||||
entity.setFunctionId(functionId);
|
||||
entity.setConfigType(Constants.SPECIFIC_SERVICE_CFG_TYPE_ENCRYPTED_TUNNEL_BEHAVIOR);
|
||||
try {
|
||||
appCfgService.auditAppPolicyCfg(entity, isAudit);
|
||||
appCfgService.auditAppPolicyCfg(entity, isAudit,Constants.INSERT_ACTION);
|
||||
addMessage(redirectAttributes, "success", "audit_success");
|
||||
} catch (Exception e) {
|
||||
if (e instanceof MaatConvertException) {
|
||||
@@ -228,10 +257,12 @@ public class EncryptedTunnelBehaviorController extends BaseController {
|
||||
logger.info("加密隧道配置下发失败:" + e.getMessage());
|
||||
;
|
||||
addMessage(redirectAttributes, "error", "request_service_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
} else {
|
||||
e.printStackTrace();
|
||||
logger.error("加密隧道配置下发失败", e);
|
||||
addMessage(redirectAttributes, "error", "audit_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -248,8 +279,10 @@ public class EncryptedTunnelBehaviorController extends BaseController {
|
||||
logger.error("配置下发失败:", e);
|
||||
if (e instanceof MaatConvertException) {
|
||||
addMessage(redirectAttributes, "error", "request_service_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
} else {
|
||||
addMessage(redirectAttributes, "error", "audit_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -270,18 +303,28 @@ public class EncryptedTunnelBehaviorController extends BaseController {
|
||||
*/
|
||||
@RequestMapping(value = { "updateValid" })
|
||||
@RequiresPermissions(value = { "encryptedtunnelbehav:config" })
|
||||
public String updateAppPolicyCfgValid(Integer isValid, String ids, Integer functionId,
|
||||
RedirectAttributes redirectAttributes) {
|
||||
public String updateAppPolicyCfgValid(Integer isValid, String ids, Integer functionId, RedirectAttributes redirectAttributes,
|
||||
HttpServletRequest request, HttpServletResponse response, @ModelAttribute("cfg")AppPolicyCfg cfg) {
|
||||
try {
|
||||
if (!StringUtil.isEmpty(ids)) {
|
||||
appCfgService.updateAppPolicyCfgValid(isValid, ids, functionId);
|
||||
addMessage(redirectAttributes, "success", "delete_success");
|
||||
}else {
|
||||
// 批量删除
|
||||
Page<AppPolicyCfg> searchPage = new Page<AppPolicyCfg>(request, response, "a");
|
||||
deleteAll(searchPage, functionId, cfg);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("加密隧道协议保存失败", e);
|
||||
if (e instanceof MaatConvertException) {
|
||||
addMessage(redirectAttributes, "error", "request_service_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
} else if (e instanceof CallExternalProceduresException) {
|
||||
addMessage(redirectAttributes, "error", "call_external_procedures_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
} else {
|
||||
addMessage(redirectAttributes, "error", "delete_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
}
|
||||
return "redirect:" + adminPath + "/encryptedtunnelbehav/list?functionId=" + functionId;
|
||||
@@ -322,8 +365,20 @@ public class EncryptedTunnelBehaviorController extends BaseController {
|
||||
logTotal.put("sum",0L);
|
||||
logTotals.add(logTotal);
|
||||
}
|
||||
SpecificServiceCfg app = specificServiceCfgService.getBySpecServiceId(policy.getSpecServiceId());
|
||||
if (app != null) {
|
||||
// 查找社交应用的所有有效一级特定服务 TODO
|
||||
SpecificServiceCfg appSpec = new SpecificServiceCfg();
|
||||
for (SysDataDictionaryItem dict : DictUtils.getDictList("SPECIFIC_SERVICE_CFG_TYPE")) {
|
||||
if (Constants.SPECIFIC_SERVICE_CFG_TYPE_ENCRYPTED_TUNNEL_BEHAVIOR.equals(dict.getItemValue())) {
|
||||
appSpec.setCfgType(Integer.parseInt(dict.getItemCode()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
appSpec.setIsValid(Constants.VALID_YES);
|
||||
appSpec.setIsLeaf(0);
|
||||
appSpec.setSpecServiceCode(policy.getAppCode());
|
||||
List<SpecificServiceCfg> appList = specificServiceCfgService.findAllSpecificServiceCfg(appSpec, null);
|
||||
if (!StringUtil.isEmpty(appList)) {
|
||||
SpecificServiceCfg app = appList.get(0);
|
||||
policy.setBehaviorName(app.getSpecServiceName());
|
||||
}
|
||||
}
|
||||
@@ -429,6 +484,7 @@ public class EncryptedTunnelBehaviorController extends BaseController {
|
||||
} catch (Exception e) {
|
||||
logger.error("TunnelBehavior export failed", e);
|
||||
addMessage(redirectAttributes, "error", "export_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
// return "redirect:" + adminPath
|
||||
// +"/ntc/iplist/list?functionId="+entity.getFunctionId();
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.nis.web.controller.configuration;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@@ -16,6 +17,7 @@ import com.nis.domain.basics.PolicyGroupInfo;
|
||||
import com.nis.domain.configuration.GroupAreaInfo;
|
||||
import com.nis.exceptions.CallExternalProceduresException;
|
||||
import com.nis.exceptions.MaatConvertException;
|
||||
import com.nis.util.LogUtils;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.web.controller.BaseController;
|
||||
import com.nis.web.service.configuration.GroupAreaService;
|
||||
@@ -65,7 +67,7 @@ public class GroupAreaController extends BaseController {
|
||||
}
|
||||
|
||||
@RequestMapping(value = "saveOrUpdate")
|
||||
public String saveOrUpdate(GroupAreaInfo cfg,Model model,RedirectAttributes redirectAttributes) {
|
||||
public String saveOrUpdate(GroupAreaInfo cfg,Model model,RedirectAttributes redirectAttributes,HttpServletRequest request) {
|
||||
try {
|
||||
groupAreaService.saveOrUpdate(cfg);
|
||||
addMessage(redirectAttributes,"success","save_success");
|
||||
@@ -73,23 +75,27 @@ public class GroupAreaController extends BaseController {
|
||||
logger.error("新增失败",e);
|
||||
if(e instanceof MaatConvertException) {
|
||||
addMessage(redirectAttributes,"error","request_service_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}else if(e instanceof CallExternalProceduresException) {
|
||||
addMessage(redirectAttributes,"error","call_external_procedures_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}else {
|
||||
addMessage(redirectAttributes,"error","save_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
}
|
||||
return "redirect:" + adminPath + "/cfg/groupArea/groupAreaList";
|
||||
}
|
||||
|
||||
@RequestMapping(value={"delete"})
|
||||
public String delete(RedirectAttributes redirectAttributes, String ids,int isValid) {
|
||||
public String delete(RedirectAttributes redirectAttributes, String ids,int isValid,HttpServletRequest request) {
|
||||
try {
|
||||
groupAreaService.deldete(ids,isValid);
|
||||
addMessage(redirectAttributes,"success","delete_success");
|
||||
} catch (Exception e) {
|
||||
logger.error("删除失败",e);
|
||||
addMessage(redirectAttributes,"error","delete_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
return "redirect:" + adminPath + "/cfg/groupArea/groupAreaList";
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.nis.domain.log.BaseLogEntity;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.LogUtils;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.util.httpclient.HttpClientUtil;
|
||||
import com.nis.web.controller.BaseController;
|
||||
@@ -73,7 +74,7 @@ public class LogSearchController extends BaseController{
|
||||
|
||||
@RequestMapping(value="actionLogTrend")
|
||||
@ResponseBody
|
||||
public List actionTrans(String cfgId,String beginDate,String endDate,String serviceId){
|
||||
public List actionTrans(String cfgId,String beginDate,String endDate,String serviceId,HttpServletRequest request){
|
||||
Map<String, Object> fromJsonList = new HashMap<String, Object>();
|
||||
List resultList = new ArrayList();
|
||||
String url = Constants.LOG_BASE_URL+Constants.NTC_PZ_REPORT;
|
||||
@@ -96,6 +97,7 @@ public class LogSearchController extends BaseController{
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
resultList.add(Maps.newHashMap("error","request_service_failed"));
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.nis.domain.configuration.TaskInfo;
|
||||
import com.nis.domain.log.BaseLogEntity;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.DateUtils;
|
||||
import com.nis.util.LogUtils;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.util.excel.ExcelField;
|
||||
import com.nis.web.controller.BaseController;
|
||||
@@ -124,6 +125,7 @@ public class RequestInfoController extends BaseController{
|
||||
logger.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
addMessage(model,"error","save_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
return "redirect:" + adminPath + "/cfg/request/list?functionId="+requestInfo.getFunctionId()+"&repage";
|
||||
}
|
||||
@@ -286,6 +288,7 @@ public class RequestInfoController extends BaseController{
|
||||
} catch (Exception e) {
|
||||
logger.error("ip addr export failed",e);
|
||||
addMessage(redirectAttributes,"error", "export_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
//return "redirect:" + adminPath +"/ntc/iplist/list?functionId="+entity.getFunctionId();
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.nis.domain.basics.PolicyGroupInfo;
|
||||
import com.nis.domain.configuration.DnsIpCfg;
|
||||
import com.nis.exceptions.MaatConvertException;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.LogUtils;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.web.controller.BaseController;
|
||||
|
||||
@@ -69,7 +70,7 @@ public class DnsIpCfgController extends BaseController {
|
||||
*/
|
||||
@ResponseBody
|
||||
@RequestMapping(value = { "initSpoofingIp" })
|
||||
public String initSpoofingIp() {
|
||||
public String initSpoofingIp(HttpServletRequest request) {
|
||||
Properties msg = getMsgProp();
|
||||
try {
|
||||
DnsIpCfg entity = new DnsIpCfg();
|
||||
@@ -84,8 +85,10 @@ public class DnsIpCfgController extends BaseController {
|
||||
logger.error("初始化Spoofing ip失败", e);
|
||||
e.printStackTrace();
|
||||
if (e instanceof MaatConvertException) {
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
return msg.getProperty("request_service_failed");
|
||||
} else {
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
return msg.getProperty("save_failed");
|
||||
}
|
||||
}
|
||||
@@ -98,15 +101,21 @@ public class DnsIpCfgController extends BaseController {
|
||||
@ModelAttribute("cfg") DnsIpCfg cfg, RedirectAttributes redirectAttributes) {
|
||||
try {
|
||||
dnsIpCfgService.saveOrUpdate(cfg);
|
||||
//配置仅保存
|
||||
if(StringUtil.isEmpty(cfg.getIsValid()) || cfg.getIsValid()!=1) {
|
||||
addMessage(redirectAttributes, "success", "save_success");
|
||||
} catch (Exception e) {
|
||||
logger.error("信息保存失败", e);
|
||||
e.printStackTrace();
|
||||
if (e instanceof MaatConvertException) {
|
||||
addMessage(redirectAttributes, "error", "request_service_failed");
|
||||
} else {
|
||||
addMessage(redirectAttributes, "error", "save_failed");
|
||||
}else {
|
||||
//配置直接生效
|
||||
addMessage(redirectAttributes, "success", "audit_success");
|
||||
}
|
||||
} catch (MaatConvertException e) {
|
||||
logger.error("DNS欺骗ip配置下发失败:",e);
|
||||
addMessage(redirectAttributes, "error", "request_service_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
} catch (Exception e) {
|
||||
logger.error("DNS欺骗ip配置保存失败:",e);
|
||||
addMessage(redirectAttributes, "error", "save_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
|
||||
return "redirect:" + adminPath + "/cfg/dnsIp/list?functionId=" + cfg.getFunctionId();
|
||||
@@ -114,9 +123,28 @@ public class DnsIpCfgController extends BaseController {
|
||||
|
||||
@RequestMapping(value = { "/delete" })
|
||||
@RequiresPermissions(value = { "dns:fake:ip:config" })
|
||||
public String delete(Integer isAudit, Integer isValid, String ids, Integer functionId,
|
||||
RedirectAttributes redirectAttributes) {
|
||||
public String delete(Integer isAudit, Integer isValid, String ids, Integer functionId, RedirectAttributes redirectAttributes,
|
||||
HttpServletRequest request, HttpServletResponse response, @ModelAttribute("cfg")DnsIpCfg cfg) {
|
||||
try {
|
||||
if (!StringUtil.isEmpty(ids)) {
|
||||
dnsIpCfgService.delete(isAudit, isValid, ids, functionId);
|
||||
addMessage(redirectAttributes, "success", "delete_success");
|
||||
}else {
|
||||
// 批量删除
|
||||
Page<DnsIpCfg> searchPage = new Page<DnsIpCfg>(request, response, "a");
|
||||
deleteAll(searchPage, functionId, cfg);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("配置删除失败:", e);
|
||||
if (e instanceof MaatConvertException) {
|
||||
addMessage(redirectAttributes, "error", "request_service_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
} else {
|
||||
addMessage(redirectAttributes, "error", "delete_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
|
||||
}
|
||||
return "redirect:" + adminPath + "/cfg/dnsIp/list?functionId=" + functionId;
|
||||
}
|
||||
|
||||
@@ -136,10 +164,12 @@ public class DnsIpCfgController extends BaseController {
|
||||
e.printStackTrace();
|
||||
logger.info("dns fake ip配置下发失败:" + e.getMessage());
|
||||
addMessage(redirectAttributes, "error", "request_service_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.info("dns fake ip配置下发失败:" + e.getMessage());
|
||||
addMessage(redirectAttributes, "error", "audit_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -156,8 +186,10 @@ public class DnsIpCfgController extends BaseController {
|
||||
logger.error("配置下发失败:", e);
|
||||
if (e instanceof MaatConvertException) {
|
||||
addMessage(redirectAttributes, "error", "request_service_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
} else {
|
||||
addMessage(redirectAttributes, "error", "audit_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -218,7 +250,7 @@ public class DnsIpCfgController extends BaseController {
|
||||
}
|
||||
titleList.add(entity.getMenuNameCode());
|
||||
classMap.put(entity.getMenuNameCode(), DnsIpCfg.class);
|
||||
String cfgIndexInfoNoExport = ",log_total,whether_area_block,client_ip,port_pattern,client_port,server_port,ir_type,direction,protocol,do_log,client_port,ir_type,group_name,userregion1,userregion2,userregion3,userregion4,userregion5,";
|
||||
String cfgIndexInfoNoExport = ",log_total,whether_area_block,client_ip,src_ip_pattern,src_port_pattern,dest_port_pattern,client_port,server_port,ir_type,direction,protocol,do_log,client_port,ir_type,group_name,userregion1,userregion2,userregion3,userregion4,userregion5,";
|
||||
|
||||
// 时间过滤
|
||||
if (entity.getSearch_create_time_start() == null && entity.getSearch_create_time_end() == null) {
|
||||
@@ -250,8 +282,10 @@ public class DnsIpCfgController extends BaseController {
|
||||
logger.error("DnsIp export failed", e);
|
||||
if (e instanceof MaatConvertException) {
|
||||
addMessage(redirectAttributes, "error", "request_service_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
} else {
|
||||
addMessage(redirectAttributes, "error", "export_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
}
|
||||
// return "redirect:" + adminPath
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.nis.domain.configuration.IpPortCfg;
|
||||
import com.nis.domain.specific.SpecificServiceCfg;
|
||||
import com.nis.exceptions.MaatConvertException;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.LogUtils;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.web.controller.BaseController;
|
||||
|
||||
@@ -80,11 +81,21 @@ public class DnsResStrategyController extends BaseController {
|
||||
|
||||
dnsResStrategyService.saveOrUpdate(cfg);
|
||||
|
||||
//配置仅保存
|
||||
if(StringUtil.isEmpty(cfg.getIsValid()) || cfg.getIsValid()!=1) {
|
||||
addMessage(redirectAttributes, "success", "save_success");
|
||||
}else {
|
||||
//配置直接生效
|
||||
addMessage(redirectAttributes, "success", "audit_success");
|
||||
}
|
||||
} catch (MaatConvertException e) {
|
||||
logger.error("DNS响应策略配置下发失败:",e);
|
||||
addMessage(redirectAttributes, "error", "request_service_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
} catch (Exception e) {
|
||||
logger.error("DNS响应策略配置保存失败:",e);
|
||||
addMessage(redirectAttributes, "error", "save_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
|
||||
return "redirect:" + adminPath + "/maintenance/dnsResStrategy/list?functionId=" + cfg.getFunctionId();
|
||||
@@ -103,12 +114,28 @@ public class DnsResStrategyController extends BaseController {
|
||||
|
||||
@RequestMapping(value = { "/delete" })
|
||||
@RequiresPermissions(value = { "dns:res:strategy:config" })
|
||||
public String delete(Integer isAudit, Integer isValid, String ids, Integer functionId, Model model,
|
||||
public String delete(Integer isAudit, Integer isValid, String ids, Integer functionId, Model model, @ModelAttribute("cfg")DnsResStrategy cfg,
|
||||
HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes) {
|
||||
try {
|
||||
if (!StringUtil.isEmpty(ids)) {
|
||||
dnsResStrategyService.delete(isAudit, isValid, ids, functionId);
|
||||
addMessage(redirectAttributes, "success", "delete_success");
|
||||
}else {
|
||||
// 批量删除
|
||||
Page<DnsResStrategy> searchPage = new Page<DnsResStrategy>(request, response, "a");
|
||||
deleteAll(searchPage, functionId, cfg);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("配置删除失败:", e);
|
||||
if (e instanceof MaatConvertException) {
|
||||
addMessage(redirectAttributes, "error", "request_service_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
} else {
|
||||
addMessage(redirectAttributes, "error", "delete_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
|
||||
}
|
||||
return "redirect:" + adminPath + "/maintenance/dnsResStrategy/list?functionId=" + functionId;
|
||||
}
|
||||
|
||||
@@ -126,8 +153,10 @@ public class DnsResStrategyController extends BaseController {
|
||||
addMessage(redirectAttributes, "success", "audit_success");
|
||||
} catch (MaatConvertException e) {
|
||||
addMessage(redirectAttributes, "error", "request_service_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
} catch (Exception e) {
|
||||
addMessage(redirectAttributes, "error", "audit_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,8 +172,10 @@ public class DnsResStrategyController extends BaseController {
|
||||
logger.error("配置下发失败:", e);
|
||||
if (e instanceof MaatConvertException) {
|
||||
addMessage(redirectAttributes, "error", "request_service_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
} else {
|
||||
addMessage(redirectAttributes, "error", "audit_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -228,8 +259,10 @@ public class DnsResStrategyController extends BaseController {
|
||||
logger.error("Dns export failed", e);
|
||||
if (e instanceof MaatConvertException) {
|
||||
addMessage(redirectAttributes, "error", "request_service_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
} else {
|
||||
addMessage(redirectAttributes, "error", "export_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
}
|
||||
// return "redirect:" + adminPath
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.nis.domain.configuration.IpAddrPoolCfg;
|
||||
import com.nis.exceptions.MaatConvertException;
|
||||
import com.nis.util.ConfigServiceUtil;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.LogUtils;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.util.StringUtils;
|
||||
import com.nis.web.controller.BaseController;
|
||||
@@ -81,8 +82,10 @@ public class IpAddrPoolController extends BaseController{
|
||||
e.printStackTrace();
|
||||
if(e instanceof MaatConvertException) {
|
||||
addMessage(redirectAttributes,"error", "request_service_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}else {
|
||||
addMessage(redirectAttributes,"error", "save_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,7 +94,7 @@ public class IpAddrPoolController extends BaseController{
|
||||
|
||||
@RequestMapping(value = {"/snatAudit"})
|
||||
@RequiresPermissions(value={"ip:mulitiplex:pool:confirm"})
|
||||
public String snataudit(Integer isAudit,Integer isValid,String ids,Integer functionId,RedirectAttributes redirectAttributes) {
|
||||
public String snataudit(Integer isAudit,Integer isValid,String ids,Integer functionId,RedirectAttributes redirectAttributes,HttpServletRequest request) {
|
||||
if(!StringUtil.isEmpty(ids)){
|
||||
String[] idArray = ids.split(",");
|
||||
Date auditTime=new Date();
|
||||
@@ -104,8 +107,10 @@ public class IpAddrPoolController extends BaseController{
|
||||
logger.error("SNAT地址池配置下发失败:"+e.getMessage());
|
||||
if(e instanceof MaatConvertException) {
|
||||
addMessage(redirectAttributes,"error", "request_service_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}else {
|
||||
addMessage(redirectAttributes,"error", "audit_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -138,6 +143,7 @@ public class IpAddrPoolController extends BaseController{
|
||||
}catch(Exception e){
|
||||
logger.error(e);
|
||||
addMessage(redirectAttributes,"error","delete_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
return "redirect:" + adminPath +"/maintenance/ipMultiplexPoolCfg/snatlist?functionId="+functionId;
|
||||
}
|
||||
@@ -282,6 +288,7 @@ public class IpAddrPoolController extends BaseController{
|
||||
} catch (Exception e) {
|
||||
logger.error("ip white export failed", e);
|
||||
addMessage(redirectAttributes, "error", "export_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.nis.domain.configuration.IpMultiplexPoolCfg;
|
||||
import com.nis.domain.configuration.IpPortCfg;
|
||||
import com.nis.exceptions.MaatConvertException;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.LogUtils;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.web.controller.BaseController;
|
||||
import com.nis.web.service.basics.SysDictInfoService;
|
||||
@@ -72,8 +73,10 @@ public class IpMultiplexPoolCfgController extends BaseController {
|
||||
e.printStackTrace();
|
||||
if (e instanceof MaatConvertException) {
|
||||
addMessage(redirectAttributes, "error", "request_service_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
} else {
|
||||
addMessage(redirectAttributes, "error", "save_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,6 +106,7 @@ public class IpMultiplexPoolCfgController extends BaseController {
|
||||
} catch (Exception e) {
|
||||
logger.error(e);
|
||||
addMessage(redirectAttributes, "error", "delete_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
return "redirect:" + adminPath + "/maintenance/ipMultiplexPoolCfg/list?functionId=" + functionId;
|
||||
}
|
||||
@@ -110,7 +114,7 @@ public class IpMultiplexPoolCfgController extends BaseController {
|
||||
@RequestMapping(value = { "/audit" })
|
||||
@RequiresPermissions(value = { "ip:mulitiplex:pool:confirm" })
|
||||
public String audit(Integer isAudit, Integer isValid, String ids, Integer functionId,
|
||||
RedirectAttributes redirectAttributes) {
|
||||
RedirectAttributes redirectAttributes,HttpServletRequest request) {
|
||||
if (!StringUtil.isEmpty(ids)) {
|
||||
String[] idArray = ids.split(",");
|
||||
Date auditTime = new Date();
|
||||
@@ -126,6 +130,7 @@ public class IpMultiplexPoolCfgController extends BaseController {
|
||||
e.printStackTrace();
|
||||
logger.info("IP复用地址池配置下发失败:" + e.getMessage());
|
||||
addMessage(redirectAttributes, "error", "audit_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -309,6 +314,7 @@ public class IpMultiplexPoolCfgController extends BaseController {
|
||||
} catch (Exception e) {
|
||||
logger.error("snat export failed", e);
|
||||
addMessage(redirectAttributes, "error", "export_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
// return "redirect:" + adminPath
|
||||
// +"/ntc/iplist/list?functionId="+entity.getFunctionId();
|
||||
@@ -370,6 +376,7 @@ public class IpMultiplexPoolCfgController extends BaseController {
|
||||
} catch (Exception e) {
|
||||
logger.error("dnat export failed", e);
|
||||
addMessage(redirectAttributes, "error", "export_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
// return "redirect:" + adminPath
|
||||
// +"/ntc/iplist/list?functionId="+entity.getFunctionId();
|
||||
|
||||
@@ -11,6 +11,7 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.eclipse.jetty.util.ajax.JSON;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
@@ -23,22 +24,25 @@ import com.google.common.collect.Maps;
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.basics.IpReuseIpCfg;
|
||||
import com.nis.domain.basics.ServiceDictInfo;
|
||||
import com.nis.domain.configuration.BaseCfg;
|
||||
import com.nis.domain.configuration.BaseStringCfg;
|
||||
import com.nis.domain.configuration.CfgIndexInfo;
|
||||
import com.nis.domain.configuration.IpPortCfg;
|
||||
import com.nis.domain.configuration.IpReuseDnatPolicyCfg;
|
||||
import com.nis.domain.configuration.IpReusePolicyCfg;
|
||||
import com.nis.domain.configuration.UserManage;
|
||||
import com.nis.exceptions.MaatConvertException;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.DateUtils;
|
||||
import com.nis.util.LogUtils;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.util.StringUtils;
|
||||
import com.nis.web.controller.BaseController;
|
||||
import com.nis.web.service.configuration.IpMultiplexService;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("${adminPath}/maintenance/userManage")
|
||||
public class UserManageController extends BaseController{
|
||||
|
||||
@Autowired
|
||||
private IpMultiplexService ipMultiplexService;
|
||||
|
||||
@RequestMapping(value = {"/list"})
|
||||
@RequiresPermissions(value={"user:manage:view"})
|
||||
public String list(Model model,HttpServletRequest request,HttpServletResponse response
|
||||
@@ -69,13 +73,30 @@ public class UserManageController extends BaseController{
|
||||
public String delete(Integer isValid
|
||||
,String ids
|
||||
,RedirectAttributes redirectAttributes,HttpServletRequest request){
|
||||
String deleteSuccessIp="";
|
||||
String message="";
|
||||
Properties msgProp = getMsgProp();
|
||||
String exUser="";
|
||||
try{
|
||||
for (String id : ids.split(",")) {
|
||||
UserManage user=userManageService.getUserById(id);
|
||||
if(user != null && !StringUtil.isEmpty(user.getServerIp())) {
|
||||
//判断用户是否存在snat、dnat复用策略中
|
||||
boolean flag=true;
|
||||
if(user!=null && !StringUtil.isEmpty(user.getUserName())){
|
||||
//snat
|
||||
List<IpReusePolicyCfg> snatList=ipMultiplexService.findByUser(user.getUserName());
|
||||
if(snatList!=null && snatList.size()>0){
|
||||
exUser+=user.getUserName()+",";
|
||||
flag=false;
|
||||
}else{
|
||||
//dnat
|
||||
List<IpReuseDnatPolicyCfg> dnatList=ipMultiplexService.findDnatUser(user.getUserName());
|
||||
if(dnatList!=null && dnatList.size()>0){
|
||||
exUser+=user.getUserName()+",";
|
||||
flag=false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(user != null && !StringUtil.isEmpty(user.getServerIp()) && flag) {
|
||||
boolean lastIp=false;
|
||||
int deleteIpLenth=1;
|
||||
String serverIp=user.getServerIp().substring(0, user.getServerIp().length()-1);
|
||||
@@ -90,22 +111,36 @@ public class UserManageController extends BaseController{
|
||||
} catch (MaatConvertException e) {
|
||||
message=msgProp.getProperty("user")+" "+user.getUserName()+" "+ip+" "+msgProp.getProperty("cgi_failed")+" "+msgProp.getProperty("delete_failed");
|
||||
logger.error("用户vpn新增失败",e);
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
throw e;
|
||||
}catch (Exception e) {
|
||||
message=msgProp.getProperty("user")+" "+user.getUserName()+" "+ip+" "+msgProp.getProperty("cgi_failed")+" "+msgProp.getProperty("delete_failed");
|
||||
logger.error("用户vpn新增失败",e);
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!StringUtil.isEmpty(exUser)){
|
||||
exUser=exUser.substring(0, exUser.length()-1);
|
||||
addMessage(redirectAttributes,"error", msgProp.getProperty("user")+" "+exUser+" "+msgProp.getProperty("user_check"));
|
||||
}else{
|
||||
addMessage(redirectAttributes,"success","delete_success");
|
||||
}
|
||||
|
||||
}catch(Exception e){
|
||||
logger.error("Delete failed",e);
|
||||
if(e instanceof MaatConvertException) {
|
||||
addMessage(redirectAttributes,"error",message);
|
||||
if(!StringUtil.isEmpty(exUser)){
|
||||
exUser=exUser.substring(0, exUser.length()-1);
|
||||
message+="<br/> "+msgProp.getProperty("user")+" "+exUser+" "+msgProp.getProperty("user_check");
|
||||
}
|
||||
if(!StringUtil.isEmpty(e.getMessage())) {
|
||||
addMessage(redirectAttributes,"error",e.getMessage());
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}else {
|
||||
addMessage(redirectAttributes,"error",message);
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,13 +186,16 @@ public class UserManageController extends BaseController{
|
||||
} catch (MaatConvertException e) {
|
||||
message=msgProp.getProperty("user")+" "+entity.getUserName()+" "+ip+" "+msgProp.getProperty("cgi_failed")+" "+msgProp.getProperty("save_failed");
|
||||
logger.error("用户vpn新增失败",e);
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
throw e;
|
||||
}catch (Exception e) {
|
||||
message=msgProp.getProperty("user")+" "+entity.getUserName()+" "+ip+" "+msgProp.getProperty("cgi_failed")+" "+msgProp.getProperty("save_failed");
|
||||
logger.error("用户vpn新增失败",e);
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
addMessage(redirectAttributes,"success","save_success");
|
||||
}else{
|
||||
entity.setEditTime(createTime);
|
||||
entity.setEditorId(entity.getCurrentUser().getId());
|
||||
@@ -177,10 +215,12 @@ public class UserManageController extends BaseController{
|
||||
} catch (MaatConvertException e) {
|
||||
message=msgProp.getProperty("user")+" "+entity.getUserName()+msgProp.getProperty("password")+" "+msgProp.getProperty("cgi_failed")+" "+msgProp.getProperty("update_failed");
|
||||
logger.error("用户vpn密码修改失败",e);
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
throw e;
|
||||
}catch (Exception e) {
|
||||
message=msgProp.getProperty("user")+" "+entity.getUserName()+msgProp.getProperty("password")+" "+msgProp.getProperty("cgi_failed")+" "+msgProp.getProperty("update_failed");
|
||||
logger.error("用户vpn密码修改失败",e);
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
@@ -212,10 +252,12 @@ public class UserManageController extends BaseController{
|
||||
} catch (MaatConvertException e) {
|
||||
message=msgProp.getProperty("user")+" "+entity.getUserName()+" "+ip+" "+msgProp.getProperty("cgi_failed")+" "+msgProp.getProperty("save_failed");
|
||||
logger.error("用户vpn新增失败",e);
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
throw e;
|
||||
}catch (Exception e) {
|
||||
message=msgProp.getProperty("user")+" "+entity.getUserName()+" "+ip+" "+msgProp.getProperty("cgi_failed")+" "+msgProp.getProperty("save_failed");
|
||||
logger.error("用户vpn新增失败",e);
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
@@ -232,22 +274,36 @@ public class UserManageController extends BaseController{
|
||||
} catch (MaatConvertException e) {
|
||||
message=msgProp.getProperty("user")+" "+entity.getUserName()+" "+ip+" "+msgProp.getProperty("cgi_failed")+" "+msgProp.getProperty("save_failed");
|
||||
logger.error("用户vpn删除失败",e);
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
throw e;
|
||||
}catch (Exception e) {
|
||||
message=msgProp.getProperty("user")+" "+entity.getUserName()+" "+ip+" "+msgProp.getProperty("cgi_failed")+" "+msgProp.getProperty("save_failed");
|
||||
logger.error("用户vpn删除失败",e);
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
addMessage(redirectAttributes,"success","update_success");
|
||||
}
|
||||
} catch (MaatConvertException e) {
|
||||
if(!StringUtil.isEmpty(e.getMessage())) {
|
||||
addMessage(redirectAttributes,"error",e.getMessage());
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}else{
|
||||
addMessage(redirectAttributes,"error",message);
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
return "redirect:" + adminPath +"/maintenance/userManage/list";
|
||||
} catch (Exception e) {
|
||||
if(!StringUtil.isEmpty(e.getMessage())) {
|
||||
addMessage(redirectAttributes,"error",e.getMessage());
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}else{
|
||||
addMessage(redirectAttributes,"error",message);
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
return "redirect:" + adminPath +"/maintenance/userManage/list";
|
||||
}
|
||||
return "redirect:" + adminPath +"/maintenance/userManage/list";
|
||||
@@ -336,6 +392,7 @@ public class UserManageController extends BaseController{
|
||||
message+=","+ip;
|
||||
}
|
||||
logger.error("查询失败", e);
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
}
|
||||
mess.put("message", message);
|
||||
@@ -411,6 +468,7 @@ public class UserManageController extends BaseController{
|
||||
} catch (Exception e) {
|
||||
logger.error("user export failed", e);
|
||||
addMessage(redirectAttributes, "error", "export_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
// return "redirect:" + adminPath
|
||||
// +"/ntc/iplist/list?functionId="+entity.getFunctionId();
|
||||
|
||||
@@ -34,6 +34,7 @@ import com.nis.domain.configuration.DdosIpCfg;
|
||||
import com.nis.domain.configuration.RequestInfo;
|
||||
import com.nis.exceptions.MaatConvertException;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.LogUtils;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.web.controller.BaseController;
|
||||
import com.nis.web.security.UserUtils;
|
||||
@@ -57,6 +58,12 @@ public class DdosCfgController extends BaseController {
|
||||
@ModelAttribute("cfg") DdosIpCfg cfg) {
|
||||
if (!StringUtil.isEmpty(ids)) {
|
||||
cfg = ddosCfgService.getDdosIpCfg(Long.parseLong(ids), null);
|
||||
if(cfg.getBpsThreadshold()==0){
|
||||
cfg.setBpsThreadshold(null);
|
||||
};
|
||||
if(cfg.getPpsThreadshold()==0){
|
||||
cfg.setPpsThreadshold(null);
|
||||
};
|
||||
initUpdateFormCondition(model, cfg);
|
||||
} else {
|
||||
initFormCondition(model, cfg);
|
||||
@@ -71,15 +78,21 @@ public class DdosCfgController extends BaseController {
|
||||
@ModelAttribute("cfg") DdosIpCfg cfg, RedirectAttributes redirectAttributes) {
|
||||
try {
|
||||
ddosCfgService.saveOrUpdate(cfg);
|
||||
//配置仅保存
|
||||
if(StringUtil.isEmpty(cfg.getIsValid()) || cfg.getIsValid()!=1) {
|
||||
addMessage(redirectAttributes, "success", "save_success");
|
||||
} catch (Exception e) {
|
||||
logger.error("信息保存失败", e);
|
||||
e.printStackTrace();
|
||||
if (e instanceof MaatConvertException) {
|
||||
addMessage(redirectAttributes, "error", "request_service_failed");
|
||||
} else {
|
||||
addMessage(redirectAttributes, "error", "save_failed");
|
||||
}else {
|
||||
//配置直接生效
|
||||
addMessage(redirectAttributes, "success", "audit_success");
|
||||
}
|
||||
} catch (MaatConvertException e) {
|
||||
logger.error("DDOS配置下发失败:",e);
|
||||
addMessage(redirectAttributes, "error", "request_service_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
} catch (Exception e) {
|
||||
logger.error("DDOS配置保存失败:",e);
|
||||
addMessage(redirectAttributes, "error", "save_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
|
||||
return "redirect:" + adminPath + "/manipulation/ddos/list?functionId=" + cfg.getFunctionId();
|
||||
@@ -87,8 +100,28 @@ public class DdosCfgController extends BaseController {
|
||||
|
||||
@RequestMapping(value = { "/delete" })
|
||||
@RequiresPermissions(value = { "ddos:ip:config" })
|
||||
public String delete(Integer isAudit, Integer isValid, String ids, Integer functionId) {
|
||||
public String delete(Integer isAudit, Integer isValid, String ids, Integer functionId, RedirectAttributes redirectAttributes,
|
||||
HttpServletRequest request, HttpServletResponse response, @ModelAttribute("cfg")DdosIpCfg cfg) {
|
||||
try {
|
||||
if (!StringUtil.isEmpty(ids)) {
|
||||
ddosCfgService.delete(isAudit, isValid, ids, functionId);
|
||||
addMessage(redirectAttributes, "success", "delete_success");
|
||||
}else {
|
||||
// 批量删除
|
||||
Page<DdosIpCfg> searchPage = new Page<DdosIpCfg>(request, response, "a");
|
||||
deleteAll(searchPage, functionId, cfg);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("配置删除失败:", e);
|
||||
if (e instanceof MaatConvertException) {
|
||||
addMessage(redirectAttributes, "error", "request_service_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
} else {
|
||||
addMessage(redirectAttributes, "error", "delete_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
|
||||
}
|
||||
return "redirect:" + adminPath + "/manipulation/ddos/list?functionId=" + functionId;
|
||||
}
|
||||
|
||||
@@ -102,16 +135,18 @@ public class DdosCfgController extends BaseController {
|
||||
Date auditTime = new Date();
|
||||
for (String id : idArray) {
|
||||
try {
|
||||
ddosCfgService.audit(isAudit, isValid, functionId, id, auditTime);
|
||||
ddosCfgService.audit(isAudit, isValid, functionId, id, auditTime,Constants.INSERT_ACTION);
|
||||
addMessage(redirectAttributes, "success", "audit_success");
|
||||
} catch (MaatConvertException e) {
|
||||
e.printStackTrace();
|
||||
logger.info("dns fake ip配置下发失败:" + e.getMessage());
|
||||
addMessage(redirectAttributes, "error", "request_service_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.info("dns fake ip配置下发失败:" + e.getMessage());
|
||||
addMessage(redirectAttributes, "error", "audit_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -127,8 +162,10 @@ public class DdosCfgController extends BaseController {
|
||||
logger.error("配置下发失败:", e);
|
||||
if (e instanceof MaatConvertException) {
|
||||
addMessage(redirectAttributes, "error", "request_service_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
} else {
|
||||
addMessage(redirectAttributes, "error", "audit_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -240,6 +277,7 @@ public class DdosCfgController extends BaseController {
|
||||
} catch (Exception e) {
|
||||
logger.error("ddos export failed", e);
|
||||
addMessage(redirectAttributes, "error", "export_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
// return "redirect:" + adminPath
|
||||
// +"/ntc/iplist/list?functionId="+entity.getFunctionId();
|
||||
|
||||
@@ -40,11 +40,11 @@ import com.nis.domain.configuration.IpPortCfg;
|
||||
import com.nis.domain.configuration.IpReuseDnatPolicyCfg;
|
||||
import com.nis.domain.configuration.IpReusePolicyCfg;
|
||||
import com.nis.domain.configuration.UserManage;
|
||||
import com.nis.domain.configuration.template.IpMultiplexPolicyTemplate;
|
||||
import com.nis.exceptions.MaatConvertException;
|
||||
import com.nis.util.ConfigServiceUtil;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.DictUtils;
|
||||
import com.nis.util.LogUtils;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.web.controller.configuration.CommonController;
|
||||
import com.nis.web.service.configuration.IpMultiplexService;
|
||||
@@ -120,26 +120,6 @@ public class IpMultiplexController extends CommonController {
|
||||
return "redirect:" + adminPath + "/manipulation/ipmulitiplex/list?functionId=" + cfg.getFunctionId();
|
||||
}
|
||||
|
||||
// ip配置导入
|
||||
/*
|
||||
* @RequestMapping(value = "/import", method=RequestMethod.POST) public
|
||||
* String importIp(String cfgName,RedirectAttributes redirectAttributes,
|
||||
*
|
||||
* @RequestParam("file") MultipartFile file,IpPortCfg cfg) {
|
||||
* this._importIp(cfgName,redirectAttributes,
|
||||
* file,cfg,IpMultiplexPolicyTemplate.class);
|
||||
* redirectAttributes.addAttribute("urlPrefix","/manipulation/ipmulitiplex")
|
||||
* ; redirectAttributes.addAttribute("requiresPermissionPrefix",
|
||||
* "ip:mulitiplex"); return "redirect:" + adminPath
|
||||
* +"/manipulation/ipmulitiplex/list?functionId="+cfg.getFunctionId(); }
|
||||
*/
|
||||
// ip模板下载
|
||||
@RequestMapping(value = "import/template")
|
||||
public void importFileTemplate(HttpServletRequest request, HttpServletResponse response,
|
||||
RedirectAttributes redirectAttributes, Integer functionId, Integer cfgRegionCode) {
|
||||
this._importFileTemplate(request, response, redirectAttributes, functionId, cfgRegionCode,
|
||||
IpMultiplexPolicyTemplate.class);
|
||||
}
|
||||
|
||||
// ip配置导出
|
||||
@RequestMapping(value = "export")
|
||||
@@ -202,8 +182,10 @@ public class IpMultiplexController extends CommonController {
|
||||
e.printStackTrace();
|
||||
if (e instanceof MaatConvertException) {
|
||||
addMessage(redirectAttributes, "error", "request_service_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
} else {
|
||||
addMessage(redirectAttributes, "error", "save_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,6 +205,7 @@ public class IpMultiplexController extends CommonController {
|
||||
} catch (Exception e) {
|
||||
logger.error(e);
|
||||
addMessage(redirectAttributes, "error", "delete_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
|
||||
return "redirect:" + adminPath + "/manipulation/ipmulitiplex/snatPolicyList?functionId=" + functionId;
|
||||
@@ -231,7 +214,7 @@ public class IpMultiplexController extends CommonController {
|
||||
@RequestMapping(value = { "/auditSnat" })
|
||||
@RequiresPermissions("snat_policy:confirm")
|
||||
public String auditSnat(String ids, Integer isAudit, Integer isValid, Integer functionId,
|
||||
RedirectAttributes redirectAttributes) {
|
||||
RedirectAttributes redirectAttributes,HttpServletRequest request) {
|
||||
|
||||
if (!StringUtil.isEmpty(ids)) {
|
||||
String[] idArray = ids.split(",");
|
||||
@@ -245,8 +228,10 @@ public class IpMultiplexController extends CommonController {
|
||||
logger.error("SNAT策略配置下发失败:" + e.getMessage());
|
||||
if (e instanceof MaatConvertException) {
|
||||
addMessage(redirectAttributes, "error", "request_service_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
} else {
|
||||
addMessage(redirectAttributes, "error", "audit_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -302,6 +287,7 @@ public class IpMultiplexController extends CommonController {
|
||||
public List<IpAddrPoolCfg> ajaxGetAddrPools(HttpServletRequest request, HttpServletResponse response) {
|
||||
List<IpAddrPoolCfg> addrPools = ipAddrPoolCfgService.getEffectiveAddrPool();
|
||||
List<IpAddrPoolCfg> addrPoolsNew = new ArrayList<>();
|
||||
Properties msgProp = getMsgProp();
|
||||
for (IpAddrPoolCfg addrPool : addrPools) {
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("addr_pool_id", addrPool.getCfgId());
|
||||
@@ -309,6 +295,7 @@ public class IpMultiplexController extends CommonController {
|
||||
Map<String, Object> resultMap = ConfigServiceUtil.getCGIInfo(url, Constants.IP_NUM_GET, params);
|
||||
if (!StringUtil.isEmpty(resultMap) && !StringUtil.isEmpty(resultMap.get("num"))
|
||||
&& Integer.parseInt(resultMap.get("num").toString()) > 0) {
|
||||
addrPool.setAddrPoolName(msgProp.getProperty(addrPool.getAddrPoolName(),addrPool.getAddrPoolName()));
|
||||
addrPoolsNew.add(addrPool);
|
||||
}
|
||||
}
|
||||
@@ -386,8 +373,10 @@ public class IpMultiplexController extends CommonController {
|
||||
e.printStackTrace();
|
||||
if (e instanceof MaatConvertException) {
|
||||
addMessage(redirectAttributes, "error", "request_service_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
} else {
|
||||
addMessage(redirectAttributes, "error", "save_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
}
|
||||
return "redirect:" + adminPath + "/manipulation/ipmulitiplex/dnatPolicyList?functionId=" + cfg.getFunctionId();
|
||||
@@ -395,7 +384,7 @@ public class IpMultiplexController extends CommonController {
|
||||
|
||||
@RequestMapping(value = { "/dnatDelete" })
|
||||
@RequiresPermissions("dnat_policy:config")
|
||||
public String dnatDelete(String ids, Integer isValid, Integer functionId, RedirectAttributes redirectAttributes) {
|
||||
public String dnatDelete(String ids, Integer isValid, Integer functionId, RedirectAttributes redirectAttributes,HttpServletRequest request) {
|
||||
// this._deleteIp(cfgName,ids, compileIds, functionId, model);
|
||||
|
||||
try {
|
||||
@@ -406,6 +395,7 @@ public class IpMultiplexController extends CommonController {
|
||||
} catch (Exception e) {
|
||||
logger.error(e);
|
||||
addMessage(redirectAttributes, "error", "delete_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
|
||||
return "redirect:" + adminPath + "/manipulation/ipmulitiplex/dnatPolicyList?functionId=" + functionId;
|
||||
@@ -414,7 +404,7 @@ public class IpMultiplexController extends CommonController {
|
||||
@RequestMapping(value = { "/auditDnat" })
|
||||
@RequiresPermissions("dnat_policy:confirm")
|
||||
public String auditDnat(String ids, Integer isAudit, Integer isValid, Integer functionId,
|
||||
RedirectAttributes redirectAttributes) {
|
||||
RedirectAttributes redirectAttributes,HttpServletRequest request) {
|
||||
// this._auditIp(cfgName,ids, cfg, redirectAttributes);
|
||||
|
||||
if (!StringUtil.isEmpty(ids)) {
|
||||
@@ -429,8 +419,10 @@ public class IpMultiplexController extends CommonController {
|
||||
logger.error("DNAT策略配置下发失败:" + e.getMessage());
|
||||
if (e instanceof MaatConvertException) {
|
||||
addMessage(redirectAttributes, "error", "request_service_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
} else {
|
||||
addMessage(redirectAttributes, "error", "audit_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -482,6 +474,7 @@ public class IpMultiplexController extends CommonController {
|
||||
for (Integer id : set) {
|
||||
serviceIds.append(id+",");
|
||||
}
|
||||
if(serviceIds.length()>1&&compileIds.length()>1){
|
||||
String serviceIdsStr=serviceIds.toString().substring(1, serviceIds.length()-1);
|
||||
String compileIdsStr=compileIds.toString().substring(1, compileIds.length()-1);
|
||||
//获取日志总量
|
||||
@@ -489,6 +482,7 @@ public class IpMultiplexController extends CommonController {
|
||||
List<Map<String,Object>> logs = getLogTotal( null,serviceIdsStr,compileIdsStr);
|
||||
logTotals.addAll(logs);
|
||||
}
|
||||
}
|
||||
List<IpAddrPoolCfg> addrPools = ipAddrPoolCfgService.getEffectiveAddrPool();
|
||||
for (IpReusePolicyCfg ipReusePolicyCfg : ipLists) {
|
||||
if(ipReusePolicyCfg.getAddrPoolId()!=null){
|
||||
@@ -547,6 +541,7 @@ public class IpMultiplexController extends CommonController {
|
||||
} catch (Exception e) {
|
||||
logger.error("snat export failed", e);
|
||||
addMessage(redirectAttributes, "error", "export_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
// return "redirect:" + adminPath
|
||||
// +"/ntc/iplist/list?functionId="+entity.getFunctionId();
|
||||
@@ -602,6 +597,8 @@ public class IpMultiplexController extends CommonController {
|
||||
for (Integer id : set) {
|
||||
serviceIds.append(id+",");
|
||||
}
|
||||
|
||||
if(serviceIds.length()>1&&compileIds.length()>1){
|
||||
String serviceIdsStr=serviceIds.toString().substring(1, serviceIds.length()-1);
|
||||
String compileIdsStr=compileIds.toString().substring(1, compileIds.length()-1);
|
||||
//获取日志总量
|
||||
@@ -609,6 +606,7 @@ public class IpMultiplexController extends CommonController {
|
||||
List<Map<String,Object>> logs = getLogTotal( null,serviceIdsStr,compileIdsStr);
|
||||
logTotals.addAll(logs);
|
||||
}
|
||||
}
|
||||
titleList.add(entity.getMenuNameCode());
|
||||
classMap.put(entity.getMenuNameCode(), IpReuseDnatPolicyCfg.class);
|
||||
String snatNoExport = ",group_name,block_type,direction,client_ip,ip_type,ip_pattern,port_pattern,client_port,ir_type,do_log,whether_area_block,userregion1,userregion2,userregion3,userregion4,userregion5,";
|
||||
@@ -650,6 +648,7 @@ public class IpMultiplexController extends CommonController {
|
||||
} catch (Exception e) {
|
||||
logger.error("dnat export failed", e);
|
||||
addMessage(redirectAttributes, "error", "export_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
// return "redirect:" + adminPath
|
||||
// +"/ntc/iplist/list?functionId="+entity.getFunctionId();
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user