|
|
@@ -15,6 +15,7 @@ import java.util.stream.Stream;
|
|
|
import java.util.zip.CRC32;
|
|
|
|
|
|
import com.x.base.core.project.config.Config;
|
|
|
+import com.x.base.core.project.config.Nodes;
|
|
|
import com.x.base.core.project.connection.ActionResponse;
|
|
|
import com.x.base.core.project.connection.CipherConnectionAction;
|
|
|
import com.x.base.core.project.connection.FilePart;
|
|
|
@@ -26,6 +27,7 @@ import com.x.base.core.project.tools.DefaultCharset;
|
|
|
import com.x.base.core.project.tools.ListTools;
|
|
|
import com.x.base.core.project.tools.StringTools;
|
|
|
|
|
|
+import org.apache.commons.lang3.BooleanUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
|
public class Applications extends ConcurrentHashMap<String, CopyOnWriteArrayList<Application>> {
|
|
|
@@ -109,6 +111,25 @@ public class Applications extends ConcurrentHashMap<String, CopyOnWriteArrayList
|
|
|
|
|
|
public ActionResponse getQuery(Boolean xdebugger, String applicationName, String uri, String seed)
|
|
|
throws Exception {
|
|
|
+ if(applicationName.equalsIgnoreCase("x_program_center")|| applicationName.equalsIgnoreCase(x_program_center.class.getName())) {
|
|
|
+ Nodes nodes = Config.nodes();
|
|
|
+ for (String node : nodes.keySet()) {
|
|
|
+ if (nodes.get(node).getCenter().getEnable()) {
|
|
|
+ Integer port = nodes.get(node).getCenter().getPort();
|
|
|
+ StringBuffer buffer = new StringBuffer();
|
|
|
+ if (BooleanUtils.isTrue(nodes.get(node).getCenter().getSslEnable())) {
|
|
|
+ buffer.append("https://").append(StringUtils.isNotEmpty(node) ? node : "127.0.0.1")
|
|
|
+ .append(":" + port);
|
|
|
+ } else {
|
|
|
+ buffer.append("http://").append(StringUtils.isNotEmpty(node) ? node : "127.0.0.1")
|
|
|
+ .append(":" + port);
|
|
|
+ }
|
|
|
+ buffer.append("/x_program_center/jaxrs/");
|
|
|
+ return CipherConnectionAction.get(xdebugger, buffer.toString()+ CipherConnectionAction.trim(uri));
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
String name = this.findApplicationName(applicationName);
|
|
|
if (StringUtils.isEmpty(name)) {
|
|
|
throw new ExceptionFindApplicationName(applicationName);
|
|
|
@@ -162,6 +183,27 @@ public class Applications extends ConcurrentHashMap<String, CopyOnWriteArrayList
|
|
|
|
|
|
public byte[] getQueryBinary(Boolean xdebugger, String applicationName, String uri, String seed) throws Exception {
|
|
|
String name = this.findApplicationName(applicationName);
|
|
|
+
|
|
|
+ if(applicationName.equalsIgnoreCase("x_program_center")|| applicationName.equalsIgnoreCase(x_program_center.class.getName())) {
|
|
|
+ Nodes nodes = Config.nodes();
|
|
|
+ for (String node : nodes.keySet()) {
|
|
|
+ if (nodes.get(node).getCenter().getEnable()) {
|
|
|
+ Integer port = nodes.get(node).getCenter().getPort();
|
|
|
+ StringBuffer buffer = new StringBuffer();
|
|
|
+ if (BooleanUtils.isTrue(nodes.get(node).getCenter().getSslEnable())) {
|
|
|
+ buffer.append("https://").append(StringUtils.isNotEmpty(node) ? node : "127.0.0.1")
|
|
|
+ .append(":" + port);
|
|
|
+ } else {
|
|
|
+ buffer.append("http://").append(StringUtils.isNotEmpty(node) ? node : "127.0.0.1")
|
|
|
+ .append(":" + port);
|
|
|
+ }
|
|
|
+ buffer.append("/x_program_center/jaxrs/");
|
|
|
+ return CipherConnectionAction.getBinary(xdebugger,
|
|
|
+ buffer.toString() + CipherConnectionAction.trim(uri));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if (StringUtils.isEmpty(name)) {
|
|
|
throw new ExceptionFindApplicationName(applicationName);
|
|
|
}
|
|
|
@@ -215,6 +257,26 @@ public class Applications extends ConcurrentHashMap<String, CopyOnWriteArrayList
|
|
|
|
|
|
public ActionResponse deleteQuery(Boolean xdebugger, String applicationName, String uri, String seed)
|
|
|
throws Exception {
|
|
|
+ if(applicationName.equalsIgnoreCase("x_program_center")|| applicationName.equalsIgnoreCase(x_program_center.class.getName())) {
|
|
|
+ Nodes nodes = Config.nodes();
|
|
|
+ for (String node : nodes.keySet()) {
|
|
|
+ if (nodes.get(node).getCenter().getEnable()) {
|
|
|
+ Integer port = nodes.get(node).getCenter().getPort();
|
|
|
+ StringBuffer buffer = new StringBuffer();
|
|
|
+ if (BooleanUtils.isTrue(nodes.get(node).getCenter().getSslEnable())) {
|
|
|
+ buffer.append("https://").append(StringUtils.isNotEmpty(node) ? node : "127.0.0.1")
|
|
|
+ .append(":" + port);
|
|
|
+ } else {
|
|
|
+ buffer.append("http://").append(StringUtils.isNotEmpty(node) ? node : "127.0.0.1")
|
|
|
+ .append(":" + port);
|
|
|
+ }
|
|
|
+ buffer.append("/x_program_center/jaxrs/");
|
|
|
+
|
|
|
+ return CipherConnectionAction.delete(xdebugger,
|
|
|
+ buffer.toString() + CipherConnectionAction.trim(uri));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
String name = this.findApplicationName(applicationName);
|
|
|
if (StringUtils.isEmpty(name)) {
|
|
|
throw new ExceptionFindApplicationName(applicationName);
|
|
|
@@ -269,6 +331,26 @@ public class Applications extends ConcurrentHashMap<String, CopyOnWriteArrayList
|
|
|
|
|
|
public byte[] deleteQueryBinary(Boolean xdebugger, String applicationName, String uri, String seed)
|
|
|
throws Exception {
|
|
|
+ if(applicationName.equalsIgnoreCase("x_program_center")|| applicationName.equalsIgnoreCase(x_program_center.class.getName())) {
|
|
|
+ Nodes nodes = Config.nodes();
|
|
|
+ for (String node : nodes.keySet()) {
|
|
|
+ if (nodes.get(node).getCenter().getEnable()) {
|
|
|
+ Integer port = nodes.get(node).getCenter().getPort();
|
|
|
+ StringBuffer buffer = new StringBuffer();
|
|
|
+ if (BooleanUtils.isTrue(nodes.get(node).getCenter().getSslEnable())) {
|
|
|
+ buffer.append("https://").append(StringUtils.isNotEmpty(node) ? node : "127.0.0.1")
|
|
|
+ .append(":" + port);
|
|
|
+ } else {
|
|
|
+ buffer.append("http://").append(StringUtils.isNotEmpty(node) ? node : "127.0.0.1")
|
|
|
+ .append(":" + port);
|
|
|
+ }
|
|
|
+ buffer.append("/x_program_center/jaxrs/");
|
|
|
+
|
|
|
+ return CipherConnectionAction.deleteBinary(xdebugger,
|
|
|
+ buffer.toString() + CipherConnectionAction.trim(uri));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
String name = this.findApplicationName(applicationName);
|
|
|
if (StringUtils.isEmpty(name)) {
|
|
|
throw new ExceptionFindApplicationName(applicationName);
|
|
|
@@ -325,6 +407,26 @@ public class Applications extends ConcurrentHashMap<String, CopyOnWriteArrayList
|
|
|
|
|
|
public ActionResponse postQuery(Boolean xdebugger, String applicationName, String uri, Object body, String seed)
|
|
|
throws Exception {
|
|
|
+ if(applicationName.equalsIgnoreCase("x_program_center")|| applicationName.equalsIgnoreCase(x_program_center.class.getName())) {
|
|
|
+ Nodes nodes = Config.nodes();
|
|
|
+ for (String node : nodes.keySet()) {
|
|
|
+ if (nodes.get(node).getCenter().getEnable()) {
|
|
|
+ Integer port = nodes.get(node).getCenter().getPort();
|
|
|
+ StringBuffer buffer = new StringBuffer();
|
|
|
+ if (BooleanUtils.isTrue(nodes.get(node).getCenter().getSslEnable())) {
|
|
|
+ buffer.append("https://").append(StringUtils.isNotEmpty(node) ? node : "127.0.0.1")
|
|
|
+ .append(":" + port);
|
|
|
+ } else {
|
|
|
+ buffer.append("http://").append(StringUtils.isNotEmpty(node) ? node : "127.0.0.1")
|
|
|
+ .append(":" + port);
|
|
|
+ }
|
|
|
+ buffer.append("/x_program_center/jaxrs/");
|
|
|
+
|
|
|
+ return CipherConnectionAction.post(xdebugger, buffer.toString() + CipherConnectionAction.trim(uri),
|
|
|
+ body);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
String name = this.findApplicationName(applicationName);
|
|
|
if (StringUtils.isEmpty(name)) {
|
|
|
throw new ExceptionFindApplicationName(applicationName);
|
|
|
@@ -381,6 +483,27 @@ public class Applications extends ConcurrentHashMap<String, CopyOnWriteArrayList
|
|
|
|
|
|
public byte[] postQueryBinary(Boolean xdebugger, String applicationName, String uri, Object body, String seed)
|
|
|
throws Exception {
|
|
|
+ if(applicationName.equalsIgnoreCase("x_program_center")|| applicationName.equalsIgnoreCase(x_program_center.class.getName())) {
|
|
|
+ Nodes nodes = Config.nodes();
|
|
|
+ for (String node : nodes.keySet()) {
|
|
|
+ if (nodes.get(node).getCenter().getEnable()) {
|
|
|
+ Integer port = nodes.get(node).getCenter().getPort();
|
|
|
+ StringBuffer buffer = new StringBuffer();
|
|
|
+ if (BooleanUtils.isTrue(nodes.get(node).getCenter().getSslEnable())) {
|
|
|
+ buffer.append("https://").append(StringUtils.isNotEmpty(node) ? node : "127.0.0.1")
|
|
|
+ .append(":" + port);
|
|
|
+ } else {
|
|
|
+ buffer.append("http://").append(StringUtils.isNotEmpty(node) ? node : "127.0.0.1")
|
|
|
+ .append(":" + port);
|
|
|
+ }
|
|
|
+ buffer.append("/x_program_center/jaxrs/");
|
|
|
+
|
|
|
+ return CipherConnectionAction.postBinary(xdebugger,
|
|
|
+ buffer.toString() + CipherConnectionAction.trim(uri), body);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
String name = this.findApplicationName(applicationName);
|
|
|
if (StringUtils.isEmpty(name)) {
|
|
|
throw new ExceptionFindApplicationName(applicationName);
|
|
|
@@ -442,6 +565,27 @@ public class Applications extends ConcurrentHashMap<String, CopyOnWriteArrayList
|
|
|
|
|
|
public byte[] postQueryMultiPartBinary(Boolean xdebugger, String applicationName, String uri,
|
|
|
Collection<FormField> formFields, Collection<FilePart> fileParts, String seed) throws Exception {
|
|
|
+ if(applicationName.equalsIgnoreCase("x_program_center")|| applicationName.equalsIgnoreCase(x_program_center.class.getName())) {
|
|
|
+ Nodes nodes = Config.nodes();
|
|
|
+ for (String node : nodes.keySet()) {
|
|
|
+ if (nodes.get(node).getCenter().getEnable()) {
|
|
|
+ Integer port = nodes.get(node).getCenter().getPort();
|
|
|
+ StringBuffer buffer = new StringBuffer();
|
|
|
+ if (BooleanUtils.isTrue(nodes.get(node).getCenter().getSslEnable())) {
|
|
|
+ buffer.append("https://").append(StringUtils.isNotEmpty(node) ? node : "127.0.0.1")
|
|
|
+ .append(":" + port);
|
|
|
+ } else {
|
|
|
+ buffer.append("http://").append(StringUtils.isNotEmpty(node) ? node : "127.0.0.1")
|
|
|
+ .append(":" + port);
|
|
|
+ }
|
|
|
+ buffer.append("/x_program_center/jaxrs/");
|
|
|
+
|
|
|
+ return CipherConnectionAction.postMultiPartBinary(xdebugger,
|
|
|
+ buffer.toString() + CipherConnectionAction.trim(uri), formFields, fileParts);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
String name = this.findApplicationName(applicationName);
|
|
|
if (StringUtils.isEmpty(name)) {
|
|
|
throw new ExceptionFindApplicationName(applicationName);
|
|
|
@@ -498,6 +642,28 @@ public class Applications extends ConcurrentHashMap<String, CopyOnWriteArrayList
|
|
|
|
|
|
public ActionResponse putQuery(Boolean xdebugger, String applicationName, String uri, Object body, String seed)
|
|
|
throws Exception {
|
|
|
+
|
|
|
+ if(applicationName.equalsIgnoreCase("x_program_center")|| applicationName.equalsIgnoreCase(x_program_center.class.getName())) {
|
|
|
+ Nodes nodes = Config.nodes();
|
|
|
+ for (String node : nodes.keySet()) {
|
|
|
+ if (nodes.get(node).getCenter().getEnable()) {
|
|
|
+ Integer port = nodes.get(node).getCenter().getPort();
|
|
|
+ StringBuffer buffer = new StringBuffer();
|
|
|
+ if (BooleanUtils.isTrue(nodes.get(node).getCenter().getSslEnable())) {
|
|
|
+ buffer.append("https://").append(StringUtils.isNotEmpty(node) ? node : "127.0.0.1")
|
|
|
+ .append(":" + port);
|
|
|
+ } else {
|
|
|
+ buffer.append("http://").append(StringUtils.isNotEmpty(node) ? node : "127.0.0.1")
|
|
|
+ .append(":" + port);
|
|
|
+ }
|
|
|
+ buffer.append("/x_program_center/jaxrs/");
|
|
|
+
|
|
|
+ return CipherConnectionAction.put(xdebugger, buffer.toString() + CipherConnectionAction.trim(uri),
|
|
|
+ body);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
String name = this.findApplicationName(applicationName);
|
|
|
if (StringUtils.isEmpty(name)) {
|
|
|
throw new ExceptionFindApplicationName(applicationName);
|
|
|
@@ -522,7 +688,10 @@ public class Applications extends ConcurrentHashMap<String, CopyOnWriteArrayList
|
|
|
return str;
|
|
|
}
|
|
|
}
|
|
|
- return null;
|
|
|
+ if(name.equalsIgnoreCase("x_program_center")|| name.equalsIgnoreCase(x_program_center.class.getName())) {
|
|
|
+ return "x_program_center";
|
|
|
+ }
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
public Application findApplicationWithNode(String className, String node) throws Exception {
|
|
|
@@ -602,12 +771,35 @@ public class Applications extends ConcurrentHashMap<String, CopyOnWriteArrayList
|
|
|
}
|
|
|
|
|
|
public String describeApi(String name) throws Exception {
|
|
|
- String applicationName = this.findApplicationName(name);
|
|
|
- if (StringUtils.isEmpty(applicationName)) {
|
|
|
- throw new Exception("getDescribe can not find application with name:" + name + ".");
|
|
|
+ String urlDescribeApiJson = "";
|
|
|
+ if(name.equalsIgnoreCase("x_program_center")|| name.equalsIgnoreCase(x_program_center.class.getName())) {
|
|
|
+ Nodes nodes = Config.nodes();
|
|
|
+ for (String node : nodes.keySet()) {
|
|
|
+ if (nodes.get(node).getCenter().getEnable()) {
|
|
|
+ Integer port = nodes.get(node).getCenter().getPort();
|
|
|
+ StringBuffer buffer = new StringBuffer();
|
|
|
+ if (BooleanUtils.isTrue(nodes.get(node).getCenter().getSslEnable())) {
|
|
|
+ buffer.append("https://").append(StringUtils.isNotEmpty(node) ? node : "127.0.0.1")
|
|
|
+ .append(":" + port);
|
|
|
+ } else {
|
|
|
+ buffer.append("http://").append(StringUtils.isNotEmpty(node) ? node : "127.0.0.1")
|
|
|
+ .append(":" + port);
|
|
|
+ }
|
|
|
+ buffer.append("/x_program_center/describe/api.json");
|
|
|
+ urlDescribeApiJson = buffer.toString();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ String applicationName = this.findApplicationName(name);
|
|
|
+ if (StringUtils.isEmpty(applicationName)) {
|
|
|
+ throw new Exception("getDescribe can not find application with name:" + name + ".");
|
|
|
+ }
|
|
|
+ Application application = this.randomWithWeight(applicationName);
|
|
|
+ //return HttpConnection.getAsString(application.getUrlDescribeApiJson(), null);
|
|
|
+ urlDescribeApiJson = application.getUrlDescribeApiJson();
|
|
|
}
|
|
|
- Application application = this.randomWithWeight(applicationName);
|
|
|
- return HttpConnection.getAsString(application.getUrlDescribeApiJson(), null);
|
|
|
+ return HttpConnection.getAsString(urlDescribeApiJson, null);
|
|
|
}
|
|
|
|
|
|
}
|