add packing logic of heaader.response

This commit is contained in:
haoeliu@foxmail.com 2023-03-15 15:29:56 +08:00
parent 1a8cb9c2a7
commit 849e8b6601

View File

@ -3,10 +3,7 @@ package org.bdware.sc.engine.hook;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import org.bdware.doip.codec.doipMessage.DoipMessage;
import org.bdware.doip.codec.doipMessage.DoipMessageFactory;
import org.bdware.doip.codec.doipMessage.DoipResponseCode;
import org.bdware.doip.codec.doipMessage.MessageHeader;
import org.bdware.doip.codec.doipMessage.*;
import org.bdware.doip.codec.operations.BasicOperations;
import org.bdware.sc.JSEngine;
import org.bdware.sc.bean.ContractRequest;
@ -76,6 +73,12 @@ public class DOOPAfterExecHandler implements AnnotationHook {
// 和HTTP一样所有需要的字段自己封装校验规则也比较简单这里只做简单的包装返回即可
if(header != null) {
originDoipMsg.header = JsonUtil.fromJson(header, MessageHeader.class);
// response字段根据白皮书上的规定处于header下人为包装到parameters的response中
String headerRespCode = header.get("response") != null ? header.get("response").getAsString() : null;
if(headerRespCode != null) {
if (originDoipMsg.header.parameters == null) originDoipMsg.header.parameters = new HeaderParameter(null, null);
originDoipMsg.header.parameters.response = DoipResponseCode.valueOf(headerRespCode);
}
}
if(body != null) {