use of com.bsnbase.sdk.entity.base.BaseResArrayModel in project PCNGateway-Java-SDK by BSNDA.
the class HttpService method arrayPost.
public BaseResArrayModel<K> arrayPost(BaseReqModel<T> req, String url, Class<K> clazz) {
String res;
BaseResArrayModel<K> resModel = new BaseResArrayModel<K>();
try {
req.sign();
res = doPost(req, url);
} catch (Exception e) {
e.printStackTrace();
throw new GlobalException(ResultInfoEnum.SYSTEM_ERROR);
}
if (res != null && res.length() > 0) {
try {
resModel = JSON.parseObject(res, resModel.getClass());
String bodystr = JSON.toJSONString(resModel.getBody());
resModel.setBody(JSON.parseArray(bodystr, clazz));
} catch (JsonException e) {
throw new GlobalException(ResultInfoEnum.DATA_CONVERSION_ERROR);
}
// Signature verfication, data transfer
if (resModel == null) {
throw new GlobalException(ResultInfoEnum.INVALID_RESPONSE_ERROR);
}
boolean result = false;
try {
result = resModel.verify();
} catch (Exception e) {
throw new GlobalException(ResultInfoEnum.RES_MAC_ERROR);
}
if (!result) {
throw new GlobalException(ResultInfoEnum.RES_MAC_ERROR);
}
if (resModel.getHeader().getCode() != 0) {
throw new GlobalException(resModel.getHeader().getMsg());
} else {
}
return resModel;
} else {
throw new GlobalException(ResultInfoEnum.SYSTEM_ERROR);
}
}
Aggregations