Commit add097a3 by Nepxion

重构类结构

parent 9138da46
......@@ -40,4 +40,7 @@ public class DiscoveryConstant {
public static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss.SSS";
public static final String ENCODING_UTF_8 = "UTF-8";
public static final String SEPARATE = ";";
public static final String OK = "OK";
public static final String NO = "NO";
}
\ No newline at end of file
......@@ -20,7 +20,7 @@ public class JsonUtil {
static {
objectMapper = new ObjectMapper();
// objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"));
// objectMapper.setDateFormat(new SimpleDateFormat(DiscoveryConstant.DATE_FORMAT));
}
public static <T> String toJson(T object) {
......
......@@ -19,6 +19,7 @@ import org.springframework.http.MediaType;
import org.springframework.web.client.RestTemplate;
import com.fasterxml.jackson.core.type.TypeReference;
import com.nepxion.discovery.common.constant.DiscoveryConstant;
import com.nepxion.discovery.common.entity.ResultEntity;
import com.nepxion.discovery.common.entity.RouterEntity;
import com.nepxion.discovery.common.handler.RestErrorHandler;
......@@ -81,7 +82,7 @@ public class ServiceController {
String result = restTemplate.postForEntity(url, entity, String.class).getBody();
if (!StringUtils.equals(result, "OK") && !StringUtils.equals(result, "NO")) {
if (!StringUtils.equals(result, DiscoveryConstant.OK) && !StringUtils.equals(result, DiscoveryConstant.NO)) {
result = RestUtil.getCause(restTemplate);
}
......@@ -93,7 +94,7 @@ public class ServiceController {
String result = restTemplate.postForEntity(url, null, String.class).getBody();
if (!StringUtils.equals(result, "OK") && !StringUtils.equals(result, "NO")) {
if (!StringUtils.equals(result, DiscoveryConstant.OK) && !StringUtils.equals(result, DiscoveryConstant.NO)) {
result = RestUtil.getCause(restTemplate);
}
......@@ -132,7 +133,7 @@ public class ServiceController {
String result = restTemplate.postForEntity(url, entity, String.class).getBody();
if (!StringUtils.equals(result, "OK")) {
if (!StringUtils.equals(result, DiscoveryConstant.OK)) {
result = RestUtil.getCause(restTemplate);
}
......@@ -153,7 +154,7 @@ public class ServiceController {
String result = restTemplate.postForEntity(url, null, String.class).getBody();
if (!StringUtils.equals(result, "OK")) {
if (!StringUtils.equals(result, DiscoveryConstant.OK)) {
result = RestUtil.getCause(restTemplate);
}
......@@ -174,7 +175,7 @@ public class ServiceController {
String result = restTemplate.postForEntity(url, version, String.class).getBody();
if (!StringUtils.equals(result, "OK")) {
if (!StringUtils.equals(result, DiscoveryConstant.OK)) {
result = RestUtil.getCause(restTemplate);
}
......@@ -195,7 +196,7 @@ public class ServiceController {
String result = restTemplate.postForEntity(url, null, String.class).getBody();
if (!StringUtils.equals(result, "OK")) {
if (!StringUtils.equals(result, DiscoveryConstant.OK)) {
result = RestUtil.getCause(restTemplate);
}
......
......@@ -233,7 +233,7 @@ public class ConsoleEndpoint {
try {
boolean result = configAdapter.updateConfig(group, serviceId, config);
return ResponseEntity.ok().body(result ? "OK" : "NO");
return ResponseEntity.ok().body(result ? DiscoveryConstant.OK : DiscoveryConstant.NO);
} catch (Exception e) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(e.getMessage());
}
......@@ -249,7 +249,7 @@ public class ConsoleEndpoint {
try {
boolean result = configAdapter.clearConfig(group, serviceId);
return ResponseEntity.ok().body(result ? "OK" : "NO");
return ResponseEntity.ok().body(result ? DiscoveryConstant.OK : DiscoveryConstant.NO);
} catch (Exception e) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(e.getMessage());
}
......
......@@ -60,7 +60,7 @@ public abstract class AbstractRestInvoker {
checkPermission(serviceInstance);
result = doRest(url);
if (!StringUtils.equals(result, "OK")) {
if (!StringUtils.equals(result, DiscoveryConstant.OK)) {
result = RestUtil.getCause(restTemplate);
}
} catch (Exception e) {
......
......@@ -30,6 +30,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.nepxion.discovery.common.constant.DiscoveryConstant;
import com.nepxion.discovery.common.entity.RuleEntity;
import com.nepxion.discovery.plugin.framework.adapter.PluginAdapter;
import com.nepxion.discovery.plugin.framework.context.PluginContextAware;
......@@ -109,7 +110,7 @@ public class ConfigEndpoint {
// return ResponseEntity.ok().build();
return ResponseEntity.ok().body("OK");
return ResponseEntity.ok().body(DiscoveryConstant.OK);
}
private ResponseEntity<?> clear(boolean async) {
......@@ -125,7 +126,7 @@ public class ConfigEndpoint {
pluginEventWapper.fireRuleCleared(new RuleClearedEvent(), async);
return ResponseEntity.ok().body("OK");
return ResponseEntity.ok().body(DiscoveryConstant.OK);
}
private ResponseEntity<List<String>> view(boolean async) {
......
......@@ -115,7 +115,7 @@ public class VersionEndpoint {
pluginEventWapper.fireVersionUpdated(new VersionUpdatedEvent(dynamicVersion, localVersion), async);
return ResponseEntity.ok().body("OK");
return ResponseEntity.ok().body(DiscoveryConstant.OK);
}
private ResponseEntity<?> clear(String version, boolean async) {
......@@ -131,7 +131,7 @@ public class VersionEndpoint {
pluginEventWapper.fireVersionCleared(new VersionClearedEvent(version), async);
return ResponseEntity.ok().body("OK");
return ResponseEntity.ok().body(DiscoveryConstant.OK);
}
private ResponseEntity<List<String>> view(boolean async) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment