mirror of
https://gitee.com/BDWare/cp.git
synced 2025-01-10 01:44:08 +00:00
fix arg schema bugs
This commit is contained in:
parent
56d140a2c7
commit
64cdfecd67
@ -6,7 +6,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = "org.bdware.sc"
|
||||
version = "1.6.5"
|
||||
version = "1.6.7"
|
||||
repositories {
|
||||
mavenCentral()
|
||||
mavenLocal()
|
||||
|
@ -92,8 +92,8 @@ public class DebugMain {
|
||||
String urlFormat = ("http://%s/SCIDE/SCManager?action=%s&arg=%s");
|
||||
String url = String.format(urlFormat, config.agentAddress, "getAgentConfig", "");
|
||||
Map<String, Object> resp = HttpUtil.httpGet(url);
|
||||
String data = (String
|
||||
) resp.get("response");
|
||||
String data = (String) resp.get("response");
|
||||
assert (int) resp.get("responseCode") == 200;
|
||||
JsonObject jsonObject = JsonUtil.parseStringAsJsonObject(data);
|
||||
config.cmi = jsonObject.get("cmi").getAsString();
|
||||
config.dbPath = jsonObject.get("dbPath").getAsString();
|
||||
|
@ -5,12 +5,9 @@ import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.bdware.sc.ContractProcess;
|
||||
import org.bdware.sc.JSEngine;
|
||||
import org.bdware.sc.bean.ContractRequest;
|
||||
import org.bdware.sc.bean.ProjectConfig;
|
||||
import org.bdware.sc.boundry.ScriptReturnException;
|
||||
import org.bdware.sc.engine.DesktopEngine;
|
||||
import org.bdware.sc.node.AnnotationHook;
|
||||
import org.bdware.sc.node.AnnotationNode;
|
||||
import org.bdware.sc.node.FunctionNode;
|
||||
@ -38,13 +35,12 @@ public class ArgSchemaHandler implements AnnotationHook {
|
||||
|
||||
@Override
|
||||
public Object handle(ContractRequest input, JSEngine Engine, Object ret) throws ScriptReturnException {
|
||||
//input.getArg();
|
||||
JsonElement je = input.getArg();
|
||||
ArgSchemaVisitor visitor;
|
||||
if (je.isJsonObject())
|
||||
visitor = new ArgSchemaVisitor(input.getArg().getAsJsonObject());
|
||||
else
|
||||
visitor = new ArgSchemaVisitor(JsonParser.parseString(input.getArg().toString()));
|
||||
visitor = new ArgSchemaVisitor(JsonParser.parseString(input.getArg().getAsString()));
|
||||
if (je.toString().isEmpty() && !a.getArgs().get(0).equals("")) {
|
||||
JsonObject jo = new JsonObject();
|
||||
jo.addProperty("msg", "[Empty argument] argument should not be empty");
|
||||
|
@ -1,9 +1,5 @@
|
||||
package org.bdware.sc.engine.hook;
|
||||
|
||||
import com.alibaba.datax.transport.transformer.maskingMethods.cryptology.AESEncryptionImpl;
|
||||
import com.alibaba.datax.transport.transformer.maskingMethods.cryptology.FormatPreservingEncryptionImpl;
|
||||
import com.alibaba.datax.transport.transformer.maskingMethods.differentialPrivacy.EpsilonDifferentialPrivacyImpl;
|
||||
import com.alibaba.datax.transport.transformer.maskingMethods.irreversibleInterference.MD5EncryptionImpl;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
@ -41,15 +37,12 @@ public class ArgSchemaVisitor extends JsonVisitor {
|
||||
message += visitor.message;
|
||||
}
|
||||
status &= visitor.status;
|
||||
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
message += "[Missing argument] " + key.substring(1) + " should be supplied ";
|
||||
status = false;
|
||||
errorCode = 1002;
|
||||
}
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
if (jo.has(key)) {
|
||||
ArgSchemaVisitor visitor = new ArgSchemaVisitor(jo.get(key));
|
||||
visitor.visit(schema.get(key));
|
||||
@ -63,6 +56,10 @@ public class ArgSchemaVisitor extends JsonVisitor {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
message += "[Incorrect type] should be object";
|
||||
status = false;
|
||||
errorCode = 1003;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
@ -72,7 +69,6 @@ public class ArgSchemaVisitor extends JsonVisitor {
|
||||
if (root.isJsonArray()) {
|
||||
JsonArray array = root.getAsJsonArray();
|
||||
//message = new JsonArray();
|
||||
|
||||
for (int i = 0; i < array.size(); i++) {
|
||||
ArgSchemaVisitor visitor = new ArgSchemaVisitor(array.get(i));
|
||||
visitor.visit(ele.get(0));
|
||||
@ -116,8 +112,7 @@ public class ArgSchemaVisitor extends JsonVisitor {
|
||||
errorCode = 1001;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
else if (type.equals("boolean")) {
|
||||
} else if (type.equals("boolean")) {
|
||||
if (root.isJsonPrimitive() && root.getAsJsonPrimitive().isBoolean()) {
|
||||
return this;
|
||||
} else {
|
||||
@ -126,8 +121,7 @@ public class ArgSchemaVisitor extends JsonVisitor {
|
||||
errorCode = 1001;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
else if (type.equals("[]")) {
|
||||
} else if (type.equals("[]")) {
|
||||
if (root.isJsonArray()) {
|
||||
return this;
|
||||
} else {
|
||||
@ -136,8 +130,7 @@ public class ArgSchemaVisitor extends JsonVisitor {
|
||||
errorCode = 1001;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
else if (type.equals("{}")) {
|
||||
} else if (type.equals("{}")) {
|
||||
if (root.isJsonObject()) {
|
||||
return this;
|
||||
} else {
|
||||
@ -160,7 +153,12 @@ public class ArgSchemaVisitor extends JsonVisitor {
|
||||
//https://github.com/guohf/DataX-Masking
|
||||
return this;
|
||||
}
|
||||
public boolean getStatus(){return status;}
|
||||
|
||||
public String getException() {return message;}
|
||||
public boolean getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public String getException() {
|
||||
return message;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user