Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
discovery
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
谢捷峰
discovery
Commits
e4b1dc3d
Commit
e4b1dc3d
authored
Jul 10, 2018
by
Nepxion
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化代码
parent
5b266993
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
30 deletions
+22
-30
discovery-plugin-admin-center/src/main/java/com/nepxion/discovery/plugin/admincenter/endpoint/ConfigEndpoint.java
+22
-30
No files found.
discovery-plugin-admin-center/src/main/java/com/nepxion/discovery/plugin/admincenter/endpoint/ConfigEndpoint.java
View file @
e4b1dc3d
...
...
@@ -57,23 +57,7 @@ public class ConfigEndpoint implements MvcEndpoint {
@ResponseBody
@ManagedOperation
public
ResponseEntity
<?>
sendAsync
(
@RequestBody
@ApiParam
(
value
=
"规则配置内容,XML格式"
,
required
=
true
)
String
config
)
{
Boolean
discoveryControlEnabled
=
pluginContextAware
.
isDiscoveryControlEnabled
();
if
(!
discoveryControlEnabled
)
{
// return new ResponseEntity<>(Collections.singletonMap("Message", "Discovery control is disabled"), HttpStatus.NOT_FOUND);
return
ResponseEntity
.
status
(
HttpStatus
.
INTERNAL_SERVER_ERROR
).
body
(
"Discovery control is disabled"
);
}
try
{
InputStream
inputStream
=
IOUtils
.
toInputStream
(
config
,
PluginConstant
.
ENCODING_UTF_8
);
pluginEventWapper
.
fireRuleChanged
(
new
RuleChangedEvent
(
inputStream
),
true
);
}
catch
(
IOException
e
)
{
return
toExceptionResponseEntity
(
e
,
true
);
}
// return ResponseEntity.ok().build();
return
ResponseEntity
.
ok
().
body
(
"OK"
);
return
send
(
config
,
true
);
}
@RequestMapping
(
path
=
"/config/send-sync"
,
method
=
RequestMethod
.
POST
)
...
...
@@ -81,19 +65,7 @@ public class ConfigEndpoint implements MvcEndpoint {
@ResponseBody
@ManagedOperation
public
ResponseEntity
<?>
sendSync
(
@RequestBody
@ApiParam
(
value
=
"规则配置内容,XML格式"
,
required
=
true
)
String
config
)
{
Boolean
discoveryControlEnabled
=
pluginContextAware
.
isDiscoveryControlEnabled
();
if
(!
discoveryControlEnabled
)
{
return
ResponseEntity
.
status
(
HttpStatus
.
INTERNAL_SERVER_ERROR
).
body
(
"Discovery control is disabled"
);
}
try
{
InputStream
inputStream
=
IOUtils
.
toInputStream
(
config
,
PluginConstant
.
ENCODING_UTF_8
);
pluginEventWapper
.
fireRuleChanged
(
new
RuleChangedEvent
(
inputStream
),
false
);
}
catch
(
IOException
e
)
{
return
toExceptionResponseEntity
(
e
,
true
);
}
return
ResponseEntity
.
ok
().
body
(
"OK"
);
return
send
(
config
,
false
);
}
@RequestMapping
(
path
=
"/config/view"
,
method
=
RequestMethod
.
GET
)
...
...
@@ -111,6 +83,26 @@ public class ConfigEndpoint implements MvcEndpoint {
return
ResponseEntity
.
ok
().
body
(
content
);
}
private
ResponseEntity
<?>
send
(
String
config
,
boolean
async
)
{
Boolean
discoveryControlEnabled
=
pluginContextAware
.
isDiscoveryControlEnabled
();
if
(!
discoveryControlEnabled
)
{
// return new ResponseEntity<>(Collections.singletonMap("Message", "Discovery control is disabled"), HttpStatus.NOT_FOUND);
return
ResponseEntity
.
status
(
HttpStatus
.
INTERNAL_SERVER_ERROR
).
body
(
"Discovery control is disabled"
);
}
try
{
InputStream
inputStream
=
IOUtils
.
toInputStream
(
config
,
PluginConstant
.
ENCODING_UTF_8
);
pluginEventWapper
.
fireRuleChanged
(
new
RuleChangedEvent
(
inputStream
),
async
);
}
catch
(
IOException
e
)
{
return
toExceptionResponseEntity
(
e
,
true
);
}
// return ResponseEntity.ok().build();
return
ResponseEntity
.
ok
().
body
(
"OK"
);
}
private
ResponseEntity
<
String
>
toExceptionResponseEntity
(
Exception
e
,
boolean
showDetail
)
{
String
message
=
null
;
if
(
showDetail
)
{
...
...
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