mirror of
https://gitee.com/BDWare/cp.git
synced 2025-01-09 17:34:08 +00:00
fix doop before handler
This commit is contained in:
parent
fd1690c97b
commit
76f564c777
@ -6,7 +6,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = "org.bdware.sc"
|
||||
version = "1.8.7"
|
||||
version = "1.8.9"
|
||||
tasks.withType(JavaCompile) {
|
||||
// options.compilerArgs << '-Xlint:none'
|
||||
// options.compilerArgs << '-Xlint:deprecation' << "-Werror"
|
||||
@ -68,7 +68,7 @@ jar {
|
||||
// while develop at local use "false"
|
||||
configurations.runtimeClasspath.filter {
|
||||
it.getAbsolutePath().contains("/lib/")
|
||||
// false
|
||||
// false
|
||||
}.collect {
|
||||
it.isDirectory() ? it : zipTree(it)
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ import org.bdware.doip.codec.doipMessage.DoipResponseCode;
|
||||
import org.bdware.doip.codec.operations.BasicOperations;
|
||||
import org.bdware.sc.JSEngine;
|
||||
import org.bdware.sc.boundry.ScriptReturnException;
|
||||
import org.bdware.sc.engine.JSONTool;
|
||||
import org.bdware.sc.conn.ByteUtil;
|
||||
import org.bdware.sc.entity.DoipMessagePacker;
|
||||
import org.bdware.sc.node.AnnotationHook;
|
||||
import org.bdware.sc.node.ArgPacks;
|
||||
@ -41,7 +41,11 @@ public class DOOPAfterExecHandler implements AnnotationHook {
|
||||
} else {
|
||||
// pack
|
||||
if (!(argPacks.ret instanceof DoipMessage)) {
|
||||
JsonObject jsonObjectRes = ((JsonElement)argPacks.ret).getAsJsonObject();
|
||||
JsonObject jsonObjectRes = ((JsonElement) argPacks.ret).getAsJsonObject();
|
||||
if (!jsonObjectRes.has("bodyBase64Encoded") || jsonObjectRes.get("bodyBase64Encoded").getAsBoolean() == false) {
|
||||
String body = jsonObjectRes.get("body").getAsString();
|
||||
jsonObjectRes.addProperty("body", ByteUtil.encodeBASE64(body.getBytes(StandardCharsets.UTF_8)));
|
||||
}
|
||||
// validate json response
|
||||
ArgSchemaVisitor visitor = new ArgSchemaVisitor(jsonObjectRes);
|
||||
validateJsonElementRulesByArgSchemaVisitor(jsonResponseRules, visitor);
|
||||
|
@ -82,8 +82,11 @@ public class DOOPBeforeExecHandler implements AnnotationHook {
|
||||
}
|
||||
|
||||
public DoipMessage convertHttpRequestToDoipMessage(ContractRequest httpReq) {
|
||||
JsonObject jsonParams = JsonParser.parseString(httpReq.getArg().getAsString()).getAsJsonObject();
|
||||
JsonDoipMessage doipMessage = JsonUtil.fromJson(jsonParams, JsonDoipMessage.class);
|
||||
JsonElement arg = httpReq.getArg();
|
||||
if (!arg.isJsonObject()) {
|
||||
arg = JsonParser.parseString(arg.getAsString());
|
||||
}
|
||||
JsonDoipMessage doipMessage = JsonUtil.fromJson(arg, JsonDoipMessage.class);
|
||||
return doipMessage.toRequestDoipMessage();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user