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
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
35 additions
and
33 deletions
+35
-33
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
+8
-19
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
;
import
com.example.fuzzControll.exception.ServerException
;
import
com.example.fuzzControll.pojo.vo.AjaxResult
;
import
com.example.fuzzControll.service.GetServerMessageService
;
import
lombok.extern.slf4j.Slf4j
;
...
...
@@ -26,8 +27,8 @@ public class KittyServerMessageController {
public
AjaxResult
getStats
(
)
{
try
{
return
AjaxResult
.
success
(
getServerMessageService
.
getStats
());
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
());
}
catch
(
Server
Exception
e
)
{
log
.
error
(
e
.
get
Default
Message
());
return
AjaxResult
.
error
(
"stats信息获取失败!"
);
}
}
...
...
@@ -38,8 +39,8 @@ public class KittyServerMessageController {
public
AjaxResult
getTemplateInfo
(
)
{
try
{
return
AjaxResult
.
success
(
getServerMessageService
.
getTemplateInfo
());
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
());
}
catch
(
Server
Exception
e
)
{
log
.
error
(
e
.
get
Default
Message
());
return
AjaxResult
.
error
(
"templateInfo信息获取失败!"
);
}
}
...
...
@@ -50,8 +51,8 @@ public class KittyServerMessageController {
public
AjaxResult
getStages
(
)
{
try
{
return
AjaxResult
.
success
(
getServerMessageService
.
getStages
());
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
());
}
catch
(
Server
Exception
e
)
{
log
.
error
(
e
.
get
Default
Message
());
return
AjaxResult
.
error
(
"stages信息获取失败!"
);
}
}
...
...
@@ -62,8 +63,8 @@ public class KittyServerMessageController {
public
AjaxResult
getReport
(
)
{
try
{
return
AjaxResult
.
success
(
getServerMessageService
.
getReport
());
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
());
}
catch
(
Server
Exception
e
)
{
log
.
error
(
e
.
get
Default
Message
());
return
AjaxResult
.
error
(
"report信息获取失败!"
);
}
}
...
...
fuzzbackend/src/main/java/com/example/fuzzControll/controller/SeedFileController.java
View file @
37f1305f
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.service.SeedFileService
;
import
lombok.extern.slf4j.Slf4j
;
...
...
@@ -32,8 +34,8 @@ public class SeedFileController {
List
<
String
>
files
=
null
;
try
{
files
=
service
.
getSeedFiles
();
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
());
}
catch
(
Cmd
Exception
e
)
{
log
.
error
(
e
.
get
Default
Message
());
return
AjaxResult
.
error
(
"种子文件获取失败!"
);
}
return
AjaxResult
.
success
(
files
);
...
...
@@ -46,8 +48,8 @@ public class SeedFileController {
public
AjaxResult
delete
(
@PathVariable
(
"fileName"
)
String
fileName
)
{
try
{
service
.
delFile
(
fileName
);
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
());
}
catch
(
Cmd
Exception
e
)
{
log
.
error
(
e
.
get
Default
Message
());
return
AjaxResult
.
error
(
"种子文件删除失败!"
);
}
return
AjaxResult
.
success
(
"种子文件删除成功!"
);
...
...
@@ -59,8 +61,8 @@ public class SeedFileController {
public
AjaxResult
upload
(
MultipartFile
file
)
{
try
{
service
.
upload
(
file
);
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
());
}
catch
(
FileException
|
Cmd
Exception
e
)
{
log
.
error
(
e
.
get
Default
Message
());
return
AjaxResult
.
error
(
"种子文件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{
this
.
defaultMessage
=
defaultMessage
;
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{
public
FileException
(
String
defaultMessage
)
{
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 {
CloseableHttpResponse
templateInfoResponse
=
httpClient
.
execute
(
httpGetTemplateInfo
);)
{
return
EntityUtils
.
toString
(
templateInfoResponse
.
getEntity
(),
"utf-8"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
new
ServerException
(
"get server templateInfo error !"
);
}
}
...
...
@@ -35,6 +36,7 @@ public class GetServerMessageImpl implements GetServerMessageService {
CloseableHttpResponse
statsResponse
=
httpClient
.
execute
(
httpGetStats
);)
{
return
EntityUtils
.
toString
(
statsResponse
.
getEntity
(),
"utf-8"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
new
ServerException
(
"get server stats error !"
);
}
}
...
...
@@ -44,6 +46,7 @@ public class GetServerMessageImpl implements GetServerMessageService {
CloseableHttpResponse
reportResponse
=
httpClient
.
execute
(
httpGetStats
);)
{
return
EntityUtils
.
toString
(
reportResponse
.
getEntity
(),
"utf-8"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
new
ServerException
(
"get server report error !"
);
}
...
...
@@ -54,6 +57,7 @@ public class GetServerMessageImpl implements GetServerMessageService {
CloseableHttpResponse
stagesResponse
=
httpClient
.
execute
(
httpGetStats
);)
{
return
EntityUtils
.
toString
(
stagesResponse
.
getEntity
(),
"utf-8"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
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 {
SeedProperties
properties
;
@Override
public
List
<
String
>
getSeedFiles
()
throws
CmdException
{
return
cmdTools
.
runCmd
(
CmdConstent
.
GET_FILE_NAME
+
properties
.
getSeedPath
(),
"getSeedFiles"
);
public
List
<
String
>
getSeedFiles
()
throws
CmdException
{
return
cmdTools
.
runCmd
(
CmdConstent
.
GET_FILE_NAME
+
properties
.
getSeedPath
(),
"getSeedFiles"
);
}
//todo 同步修改可能会出现问题
...
...
@@ -31,49 +31,38 @@ public class SeedFileServiceImpl implements SeedFileService {
public
void
delFile
(
String
fileName
)
throws
CmdException
{
int
fileCountBefore
=
0
;
int
fileCountAfter
=
0
;
try
{
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."
);
}
catch
(
CmdException
e
)
{
throw
new
CmdException
(
e
.
getMessage
());
}
if
(
fileCountAfter
==
fileCountBefore
){
if
(
fileCountAfter
==
fileCountBefore
)
{
throw
new
CmdException
(
"Delete unsuccess ! The file has not changed .Attempt to change permissions."
);
}
}
@Override
public
void
upload
(
MultipartFile
file
)
throws
FileException
,
CmdException
{
public
void
upload
(
MultipartFile
file
)
throws
FileException
,
CmdException
{
int
fileCountBefore
=
0
;
int
fileCountAfter
=
0
;
try
{
fileCountBefore
=
getSeedFileCount
(
"upload before."
);
fileTools
.
load
(
file
);
fileCountAfter
=
getSeedFileCount
(
"upload after."
);
}
catch
(
CmdException
e
)
{
throw
new
CmdException
(
e
.
getMessage
());
}
catch
(
FileException
e
){
throw
new
FileException
(
e
.
getMessage
());
}
if
(
fileCountAfter
==
fileCountBefore
){
if
(
fileCountAfter
==
fileCountBefore
)
{
throw
new
FileException
(
"upload file error !The file failed to be submitted.Attempt to change permissions."
);
}
}
/**
*
* 获取种子文件目录下文件数量
*/
@Override
public
int
getSeedFileCount
(
String
msg
)
throws
CmdException
{
int
count
=
0
;
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
();
}
catch
(
CmdException
e
)
{
throw
new
CmdException
(
e
.
getMessage
()
+
" when "
+
msg
);
throw
new
CmdException
(
e
.
getMessage
()
+
" when "
+
msg
);
}
return
count
;
}
...
...
fuzzbackend/src/main/java/com/example/fuzzControll/tools/CmdTools.java
View file @
37f1305f
...
...
@@ -32,6 +32,7 @@ public class CmdTools {
printMessage
(
process
.
getErrorStream
(),
new
ArrayList
<
String
>());
process
.
waitFor
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
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