SpecialFileCheckOperation.jsp
4.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ include file="/templetecheck/filecheck/CheckUserIsSysadmin.jsp" %>
<%@ page import="com.alibaba.fastjson.JSONObject" %>
<%@ page import="weaver.general.BaseBean" %>
<%@ page import="weaver.conn.RecordSet" %>
<%@ page import="weaver.general.Util" %>
<%@ page import="weaver.templetecheck.filecheck.*" %>
<%@ page import="java.util.Set" %>
<%
String operation = Util.null2String(request.getParameter("operation"));
if("exportSpecialFileReport".equalsIgnoreCase(operation)){
ExportReportOperation ero = new ExportReportOperation();
ero.exportReport("upgradecheckSpecialFileresult");
out.print("{\"status\":\"ok\"}");
return;
}else if("refleshNonStandardFile".equalsIgnoreCase(operation)){//重新获取非标文件
if(NonStandardFiles.runningStatus==1){
out.print("{\"status\":\"false\"}");
}else{
NonStandardFiles.runningStatus=1;
RecordSet rs=new RecordSet();
new BaseBean().writeLog("删除非标文件列表,执行重新获取非标准文件");
rs.executeUpdate("delete from nonStandardFile");
NonStandardFiles nonStandardFiles = new NonStandardFiles();
nonStandardFiles.getNonStandardFileList();
NonStandardFiles.runningStatus=0;
out.print("{\"status\":\"ok\"}");
}
return;
}else if("checkNoStanderrunstatus".equalsIgnoreCase(operation)){//获取刷新非标文件的状态
if(NonStandardFiles.runningStatus==0){
out.print("{\"status\":\"ok\"}");
}else{
out.print("{\"status\":\"false\"}");
}
}else if("checkrunstatus".equalsIgnoreCase(operation)) {//获取文件校验的状态
if (CheckRule.runningStatus == 0) {
out.print("{\"status\":\"ok\"}");
} else {
out.print("{\"status\":\"false\"}");
}
}else if("stopmatchfilethread".equals(operation)){
try{
if(MatchSpecialFileThread.MatchSpecialStatus==1){
new BaseBean().writeLog("开始执行停止线程的工作");
Set<Thread> runningThreads=Thread.getAllStackTraces().keySet();
for(Thread runningThread:runningThreads){
if(runningThread.getName().equals("executematchSpecialFile")){//找到执行指定文件检测的线程
new BaseBean().writeLog("找到并停止线程停止线程的工作");
runningThread.stop();//关闭线程
new BaseBean().writeLog("停止指定文件检测线程结束");
break;
}
}
}else{
new BaseBean().writeLog("文件检测程序未运行");
}
}catch(Exception e){
e.printStackTrace();
}
MatchSpecialFileThread.MatchSpecialStatus=0;//检测线程的状态变回来
CheckRule.runningStatus=0;//状态改变回来
}else if("searchthreadstatus".equals(operation)){//查看线程是否正在运行
if(MatchSpecialFileThread.MatchSpecialStatus==1){
out.print("{\"status\":\"false\"}");
}else{
out.print("{\"status\":\"ok\"}");
}
}else if("stoploadtable".equals(operation)){//用来阻塞页面加载的
while(MatchSpecialFileThread.MatchSpecialStatus==1){
Thread.sleep(5000);
continue;
}
out.print("{\"status\":\"ok\"}");
}else{
String ruleid = Util.null2String(request.getParameter("ruleid"));
String filepath = Util.null2String(request.getParameter("filepath")).trim();
filepath = java.net.URLDecoder.decode(filepath,"UTF-8").trim();
String checktype = Util.null2String(request.getParameter("checktype"),"0");
String fileids=Util.null2String(request.getParameter("fileids"),"-1");
String isWorkflow=Util.null2String(request.getParameter("isWorkflow"),"false");
JSONObject object = new JSONObject();
if(operation == null || "".equals(operation)) {
out.print(object.toString());
} else if("matchspecialfile".equals(operation)){
if(CheckRule.runningStatus==1){
return;
}else{
try{
CheckRule.runningStatus=1;//将运行状态置成1
MatchSpecialFileThread.MatchSpecialStatus=1;//将线程状态置成1
MatchSpecialFileThread maft=new MatchSpecialFileThread(ruleid,filepath,checktype,fileids,isWorkflow);
Thread thread=new Thread(maft);
thread.setName("executematchSpecialFile");
thread.start();
}catch(Exception e){
e.printStackTrace();
new BaseBean().writeLog("execute matschspecialFile error :info "+e.toString());
}
}
}
}
%>