Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fuzzBackEnd
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钱炳权
fuzzBackEnd
Commits
37f1305f
Commit
37f1305f
authored
Apr 21, 2024
by
钱炳权
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
inhance exception tips
parent
0745a33d
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
40 additions
and
38 deletions
+40
-38
KittyServerMessageController.java
...fuzzControll/controller/KittyServerMessageController.java
+9
-8
SeedFileController.java
...m/example/fuzzControll/controller/SeedFileController.java
+8
-6
BaseException.java
...ava/com/example/fuzzControll/exception/BaseException.java
+4
-0
FileException.java
...ava/com/example/fuzzControll/exception/FileException.java
+1
-0
GetServerMessageImpl.java
...ample/fuzzControll/service/impl/GetServerMessageImpl.java
+4
-0
SeedFileServiceImpl.java
...xample/fuzzControll/service/impl/SeedFileServiceImpl.java
+13
-24
CmdTools.java
...rc/main/java/com/example/fuzzControll/tools/CmdTools.java
+1
-0
No files found.
fuzzbackend/src/main/java/com/example/fuzzControll/controller/KittyServerMessageController.java
View file @
37f1305f
package
com
.
example
.
fuzzControll
.
controller
;
package
com
.
example
.
fuzzControll
.
controller
;
import
com.example.fuzzControll.exception.ServerException
;
import
com.example.fuzzControll.pojo.vo.AjaxResult
;
import
com.example.fuzzControll.pojo.vo.AjaxResult
;
import
com.example.fuzzControll.service.GetServerMessageService
;
import
com.example.fuzzControll.service.GetServerMessageService
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
...
@@ -26,8 +27,8 @@ public class KittyServerMessageController {
...
@@ -26,8 +27,8 @@ public class KittyServerMessageController {
public
AjaxResult
getStats
(
)
{
public
AjaxResult
getStats
(
)
{
try
{
try
{
return
AjaxResult
.
success
(
getServerMessageService
.
getStats
());
return
AjaxResult
.
success
(
getServerMessageService
.
getStats
());
}
catch
(
Exception
e
)
{
}
catch
(
Server
Exception
e
)
{
log
.
error
(
e
.
getMessage
());
log
.
error
(
e
.
get
Default
Message
());
return
AjaxResult
.
error
(
"stats信息获取失败!"
);
return
AjaxResult
.
error
(
"stats信息获取失败!"
);
}
}
}
}
...
@@ -38,8 +39,8 @@ public class KittyServerMessageController {
...
@@ -38,8 +39,8 @@ public class KittyServerMessageController {
public
AjaxResult
getTemplateInfo
(
)
{
public
AjaxResult
getTemplateInfo
(
)
{
try
{
try
{
return
AjaxResult
.
success
(
getServerMessageService
.
getTemplateInfo
());
return
AjaxResult
.
success
(
getServerMessageService
.
getTemplateInfo
());
}
catch
(
Exception
e
)
{
}
catch
(
Server
Exception
e
)
{
log
.
error
(
e
.
getMessage
());
log
.
error
(
e
.
get
Default
Message
());
return
AjaxResult
.
error
(
"templateInfo信息获取失败!"
);
return
AjaxResult
.
error
(
"templateInfo信息获取失败!"
);
}
}
}
}
...
@@ -50,8 +51,8 @@ public class KittyServerMessageController {
...
@@ -50,8 +51,8 @@ public class KittyServerMessageController {
public
AjaxResult
getStages
(
)
{
public
AjaxResult
getStages
(
)
{
try
{
try
{
return
AjaxResult
.
success
(
getServerMessageService
.
getStages
());
return
AjaxResult
.
success
(
getServerMessageService
.
getStages
());
}
catch
(
Exception
e
)
{
}
catch
(
Server
Exception
e
)
{
log
.
error
(
e
.
getMessage
());
log
.
error
(
e
.
get
Default
Message
());
return
AjaxResult
.
error
(
"stages信息获取失败!"
);
return
AjaxResult
.
error
(
"stages信息获取失败!"
);
}
}
}
}
...
@@ -62,8 +63,8 @@ public class KittyServerMessageController {
...
@@ -62,8 +63,8 @@ public class KittyServerMessageController {
public
AjaxResult
getReport
(
)
{
public
AjaxResult
getReport
(
)
{
try
{
try
{
return
AjaxResult
.
success
(
getServerMessageService
.
getReport
());
return
AjaxResult
.
success
(
getServerMessageService
.
getReport
());
}
catch
(
Exception
e
)
{
}
catch
(
Server
Exception
e
)
{
log
.
error
(
e
.
getMessage
());
log
.
error
(
e
.
get
Default
Message
());
return
AjaxResult
.
error
(
"report信息获取失败!"
);
return
AjaxResult
.
error
(
"report信息获取失败!"
);
}
}
}
}
...
...
fuzzbackend/src/main/java/com/example/fuzzControll/controller/SeedFileController.java
View file @
37f1305f
package
com
.
example
.
fuzzControll
.
controller
;
package
com
.
example
.
fuzzControll
.
controller
;
import
com.example.fuzzControll.exception.CmdException
;
import
com.example.fuzzControll.exception.FileException
;
import
com.example.fuzzControll.pojo.vo.AjaxResult
;
import
com.example.fuzzControll.pojo.vo.AjaxResult
;
import
com.example.fuzzControll.service.SeedFileService
;
import
com.example.fuzzControll.service.SeedFileService
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
...
@@ -32,8 +34,8 @@ public class SeedFileController {
...
@@ -32,8 +34,8 @@ public class SeedFileController {
List
<
String
>
files
=
null
;
List
<
String
>
files
=
null
;
try
{
try
{
files
=
service
.
getSeedFiles
();
files
=
service
.
getSeedFiles
();
}
catch
(
Exception
e
)
{
}
catch
(
Cmd
Exception
e
)
{
log
.
error
(
e
.
getMessage
());
log
.
error
(
e
.
get
Default
Message
());
return
AjaxResult
.
error
(
"种子文件获取失败!"
);
return
AjaxResult
.
error
(
"种子文件获取失败!"
);
}
}
return
AjaxResult
.
success
(
files
);
return
AjaxResult
.
success
(
files
);
...
@@ -46,8 +48,8 @@ public class SeedFileController {
...
@@ -46,8 +48,8 @@ public class SeedFileController {
public
AjaxResult
delete
(
@PathVariable
(
"fileName"
)
String
fileName
)
{
public
AjaxResult
delete
(
@PathVariable
(
"fileName"
)
String
fileName
)
{
try
{
try
{
service
.
delFile
(
fileName
);
service
.
delFile
(
fileName
);
}
catch
(
Exception
e
)
{
}
catch
(
Cmd
Exception
e
)
{
log
.
error
(
e
.
getMessage
());
log
.
error
(
e
.
get
Default
Message
());
return
AjaxResult
.
error
(
"种子文件删除失败!"
);
return
AjaxResult
.
error
(
"种子文件删除失败!"
);
}
}
return
AjaxResult
.
success
(
"种子文件删除成功!"
);
return
AjaxResult
.
success
(
"种子文件删除成功!"
);
...
@@ -59,8 +61,8 @@ public class SeedFileController {
...
@@ -59,8 +61,8 @@ public class SeedFileController {
public
AjaxResult
upload
(
MultipartFile
file
)
{
public
AjaxResult
upload
(
MultipartFile
file
)
{
try
{
try
{
service
.
upload
(
file
);
service
.
upload
(
file
);
}
catch
(
Exception
e
)
{
}
catch
(
FileException
|
Cmd
Exception
e
)
{
log
.
error
(
e
.
getMessage
());
log
.
error
(
e
.
get
Default
Message
());
return
AjaxResult
.
error
(
"种子文件upload失败!"
);
return
AjaxResult
.
error
(
"种子文件upload失败!"
);
}
}
return
AjaxResult
.
success
(
"种子文件upload成功!"
);
return
AjaxResult
.
success
(
"种子文件upload成功!"
);
...
...
fuzzbackend/src/main/java/com/example/fuzzControll/exception/BaseException.java
View file @
37f1305f
...
@@ -22,4 +22,8 @@ public class BaseException extends RuntimeException{
...
@@ -22,4 +22,8 @@ public class BaseException extends RuntimeException{
this
.
defaultMessage
=
defaultMessage
;
this
.
defaultMessage
=
defaultMessage
;
this
.
module
=
module
;
this
.
module
=
module
;
}
}
public
String
getDefaultMessage
()
{
return
defaultMessage
;
}
}
}
fuzzbackend/src/main/java/com/example/fuzzControll/exception/FileException.java
View file @
37f1305f
...
@@ -8,4 +8,5 @@ public class FileException extends BaseException{
...
@@ -8,4 +8,5 @@ public class FileException extends BaseException{
public
FileException
(
String
defaultMessage
)
{
public
FileException
(
String
defaultMessage
)
{
super
(
defaultMessage
,
"file"
);
super
(
defaultMessage
,
"file"
);
}
}
}
}
fuzzbackend/src/main/java/com/example/fuzzControll/service/impl/GetServerMessageImpl.java
View file @
37f1305f
...
@@ -26,6 +26,7 @@ public class GetServerMessageImpl implements GetServerMessageService {
...
@@ -26,6 +26,7 @@ public class GetServerMessageImpl implements GetServerMessageService {
CloseableHttpResponse
templateInfoResponse
=
httpClient
.
execute
(
httpGetTemplateInfo
);)
{
CloseableHttpResponse
templateInfoResponse
=
httpClient
.
execute
(
httpGetTemplateInfo
);)
{
return
EntityUtils
.
toString
(
templateInfoResponse
.
getEntity
(),
"utf-8"
);
return
EntityUtils
.
toString
(
templateInfoResponse
.
getEntity
(),
"utf-8"
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
new
ServerException
(
"get server templateInfo error !"
);
throw
new
ServerException
(
"get server templateInfo error !"
);
}
}
}
}
...
@@ -35,6 +36,7 @@ public class GetServerMessageImpl implements GetServerMessageService {
...
@@ -35,6 +36,7 @@ public class GetServerMessageImpl implements GetServerMessageService {
CloseableHttpResponse
statsResponse
=
httpClient
.
execute
(
httpGetStats
);)
{
CloseableHttpResponse
statsResponse
=
httpClient
.
execute
(
httpGetStats
);)
{
return
EntityUtils
.
toString
(
statsResponse
.
getEntity
(),
"utf-8"
);
return
EntityUtils
.
toString
(
statsResponse
.
getEntity
(),
"utf-8"
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
new
ServerException
(
"get server stats error !"
);
throw
new
ServerException
(
"get server stats error !"
);
}
}
}
}
...
@@ -44,6 +46,7 @@ public class GetServerMessageImpl implements GetServerMessageService {
...
@@ -44,6 +46,7 @@ public class GetServerMessageImpl implements GetServerMessageService {
CloseableHttpResponse
reportResponse
=
httpClient
.
execute
(
httpGetStats
);)
{
CloseableHttpResponse
reportResponse
=
httpClient
.
execute
(
httpGetStats
);)
{
return
EntityUtils
.
toString
(
reportResponse
.
getEntity
(),
"utf-8"
);
return
EntityUtils
.
toString
(
reportResponse
.
getEntity
(),
"utf-8"
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
new
ServerException
(
"get server report error !"
);
throw
new
ServerException
(
"get server report error !"
);
}
}
...
@@ -54,6 +57,7 @@ public class GetServerMessageImpl implements GetServerMessageService {
...
@@ -54,6 +57,7 @@ public class GetServerMessageImpl implements GetServerMessageService {
CloseableHttpResponse
stagesResponse
=
httpClient
.
execute
(
httpGetStats
);)
{
CloseableHttpResponse
stagesResponse
=
httpClient
.
execute
(
httpGetStats
);)
{
return
EntityUtils
.
toString
(
stagesResponse
.
getEntity
(),
"utf-8"
);
return
EntityUtils
.
toString
(
stagesResponse
.
getEntity
(),
"utf-8"
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
new
ServerException
(
"get server stages error !"
);
throw
new
ServerException
(
"get server stages error !"
);
}
}
}
}
...
...
fuzzbackend/src/main/java/com/example/fuzzControll/service/impl/SeedFileServiceImpl.java
View file @
37f1305f
...
@@ -22,8 +22,8 @@ public class SeedFileServiceImpl implements SeedFileService {
...
@@ -22,8 +22,8 @@ public class SeedFileServiceImpl implements SeedFileService {
SeedProperties
properties
;
SeedProperties
properties
;
@Override
@Override
public
List
<
String
>
getSeedFiles
()
throws
CmdException
{
public
List
<
String
>
getSeedFiles
()
throws
CmdException
{
return
cmdTools
.
runCmd
(
CmdConstent
.
GET_FILE_NAME
+
properties
.
getSeedPath
(),
"getSeedFiles"
);
return
cmdTools
.
runCmd
(
CmdConstent
.
GET_FILE_NAME
+
properties
.
getSeedPath
(),
"getSeedFiles"
);
}
}
//todo 同步修改可能会出现问题
//todo 同步修改可能会出现问题
...
@@ -31,49 +31,38 @@ public class SeedFileServiceImpl implements SeedFileService {
...
@@ -31,49 +31,38 @@ public class SeedFileServiceImpl implements SeedFileService {
public
void
delFile
(
String
fileName
)
throws
CmdException
{
public
void
delFile
(
String
fileName
)
throws
CmdException
{
int
fileCountBefore
=
0
;
int
fileCountBefore
=
0
;
int
fileCountAfter
=
0
;
int
fileCountAfter
=
0
;
try
{
fileCountBefore
=
getSeedFileCount
(
"delFile before."
);
fileCountBefore
=
getSeedFileCount
(
"delFile before."
);
cmdTools
.
runCmd
(
CmdConstent
.
DELETE_FILE
+
properties
.
getSeedPath
()
+
"/"
+
fileName
,
"delFile"
);
cmdTools
.
runCmd
(
CmdConstent
.
DELETE_FILE
+
properties
.
getSeedPath
()
+
"/"
+
fileName
,
"delFile"
);
fileCountAfter
=
getSeedFileCount
(
"delFile after."
);
fileCountAfter
=
getSeedFileCount
(
"delFile after."
);
if
(
fileCountAfter
==
fileCountBefore
)
{
}
catch
(
CmdException
e
)
{
throw
new
CmdException
(
e
.
getMessage
());
}
if
(
fileCountAfter
==
fileCountBefore
){
throw
new
CmdException
(
"Delete unsuccess ! The file has not changed .Attempt to change permissions."
);
throw
new
CmdException
(
"Delete unsuccess ! The file has not changed .Attempt to change permissions."
);
}
}
}
}
@Override
@Override
public
void
upload
(
MultipartFile
file
)
throws
FileException
,
CmdException
{
public
void
upload
(
MultipartFile
file
)
throws
FileException
,
CmdException
{
int
fileCountBefore
=
0
;
int
fileCountBefore
=
0
;
int
fileCountAfter
=
0
;
int
fileCountAfter
=
0
;
try
{
fileCountBefore
=
getSeedFileCount
(
"upload before."
);
fileCountBefore
=
getSeedFileCount
(
"upload before."
);
fileTools
.
load
(
file
);
fileTools
.
load
(
file
);
fileCountAfter
=
getSeedFileCount
(
"upload after."
);
fileCountAfter
=
getSeedFileCount
(
"upload after."
);
if
(
fileCountAfter
==
fileCountBefore
)
{
}
catch
(
CmdException
e
)
{
throw
new
CmdException
(
e
.
getMessage
());
}
catch
(
FileException
e
){
throw
new
FileException
(
e
.
getMessage
());
}
if
(
fileCountAfter
==
fileCountBefore
){
throw
new
FileException
(
"upload file error !The file failed to be submitted.Attempt to change permissions."
);
throw
new
FileException
(
"upload file error !The file failed to be submitted.Attempt to change permissions."
);
}
}
}
}
/**
/**
*
* 获取种子文件目录下文件数量
* 获取种子文件目录下文件数量
*/
*/
@Override
@Override
public
int
getSeedFileCount
(
String
msg
)
throws
CmdException
{
public
int
getSeedFileCount
(
String
msg
)
throws
CmdException
{
int
count
=
0
;
int
count
=
0
;
try
{
try
{
List
<
String
>
files
=
cmdTools
.
runCmd
(
CmdConstent
.
GET_FILE_NAME
+
properties
.
getSeedPath
(),
"getSeedFileCount"
);
List
<
String
>
files
=
cmdTools
.
runCmd
(
CmdConstent
.
GET_FILE_NAME
+
properties
.
getSeedPath
(),
"getSeedFileCount"
);
count
=
files
.
size
();
count
=
files
.
size
();
}
catch
(
CmdException
e
)
{
}
catch
(
CmdException
e
)
{
throw
new
CmdException
(
e
.
getMessage
()
+
" when "
+
msg
);
throw
new
CmdException
(
e
.
getMessage
()
+
" when "
+
msg
);
}
}
return
count
;
return
count
;
}
}
...
...
fuzzbackend/src/main/java/com/example/fuzzControll/tools/CmdTools.java
View file @
37f1305f
...
@@ -32,6 +32,7 @@ public class CmdTools {
...
@@ -32,6 +32,7 @@ public class CmdTools {
printMessage
(
process
.
getErrorStream
(),
new
ArrayList
<
String
>());
printMessage
(
process
.
getErrorStream
(),
new
ArrayList
<
String
>());
process
.
waitFor
();
process
.
waitFor
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
new
CmdException
(
caller
+
" run cmd failed!"
);
throw
new
CmdException
(
caller
+
" run cmd failed!"
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment