Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
BalanceContract.AccountBalanceRequest.Builder builder
= BalanceContract.AccountBalanceRequest.newBuilder();
JsonFormat.merge(params.getParams(), builder, params.isVisible());
fillResponse(params.isVisible(), builder.build(), response);
try (AutoCloseable ignored = JsonFormat.pushInt64AsString(params.isInt64AsString())) {
fillResponse(params.isVisible(), builder.build(), response);
}
} catch (Exception e) {
Util.processError(e, response);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@ public class GetAccountByIdServlet extends RateLimiterServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response) {
try {
boolean visible = Util.getVisible(request);
boolean int64AsString = Util.getInt64AsString(request);
String accountId = request.getParameter("account_id");
Account.Builder build = Account.newBuilder();
JSONObject jsonObject = new JSONObject();
jsonObject.put("account_id", accountId);
JsonFormat.merge(jsonObject.toJSONString(), build, visible);
fillResponse(build.build(), visible, response);
try (AutoCloseable ignored = JsonFormat.pushInt64AsString(int64AsString)) {
fillResponse(build.build(), visible, response);
}
} catch (Exception e) {
Util.processError(e, response);
}
Expand All @@ -37,7 +40,9 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
PostParams params = PostParams.getPostParams(request);
Account.Builder build = Account.newBuilder();
JsonFormat.merge(params.getParams(), build, params.isVisible());
fillResponse(build.build(), params.isVisible(), response);
try (AutoCloseable ignored = JsonFormat.pushInt64AsString(params.isInt64AsString())) {
fillResponse(build.build(), params.isVisible(), response);
}
} catch (Exception e) {
Util.processError(e, response);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@ public class GetAccountNetServlet extends RateLimiterServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response) {
try {
boolean visible = Util.getVisible(request);
boolean int64AsString = Util.getInt64AsString(request);
String address = request.getParameter("address");
if (visible) {
address = Util.getHexAddress(address);
}
fillResponse(visible, ByteString.copyFrom(ByteArray.fromHexString(address)), response);
try (AutoCloseable ignored = JsonFormat.pushInt64AsString(int64AsString)) {
fillResponse(visible, ByteString.copyFrom(ByteArray.fromHexString(address)), response);
}
} catch (Exception e) {
Util.processError(e, response);
}
Expand All @@ -37,7 +40,9 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
PostParams params = PostParams.getPostParams(request);
Account.Builder build = Account.newBuilder();
JsonFormat.merge(params.getParams(), build, params.isVisible());
fillResponse(params.isVisible(), build.getAddress(), response);
try (AutoCloseable ignored = JsonFormat.pushInt64AsString(params.isInt64AsString())) {
fillResponse(params.isVisible(), build.getAddress(), response);
}
} catch (Exception e) {
Util.processError(e, response);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@ public class GetAccountResourceServlet extends RateLimiterServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response) {
try {
boolean visible = Util.getVisible(request);
boolean int64AsString = Util.getInt64AsString(request);
String address = request.getParameter("address");
if (visible) {
address = Util.getHexAddress(address);
}
fillResponse(visible, ByteString.copyFrom(ByteArray.fromHexString(address)), response);
try (AutoCloseable ignored = JsonFormat.pushInt64AsString(int64AsString)) {
fillResponse(visible, ByteString.copyFrom(ByteArray.fromHexString(address)), response);
}
} catch (Exception e) {
Util.processError(e, response);
}
Expand All @@ -39,8 +42,10 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
if (params.isVisible()) {
address = Util.getHexAddress(address);
}
fillResponse(params.isVisible(), ByteString.copyFrom(ByteArray.fromHexString(address)),
response);
try (AutoCloseable ignored = JsonFormat.pushInt64AsString(params.isInt64AsString())) {
fillResponse(params.isVisible(), ByteString.copyFrom(ByteArray.fromHexString(address)),
response);
}
} catch (Exception e) {
Util.processError(e, response);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,15 @@ public class GetAccountServlet extends RateLimiterServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response) {
try {
boolean visible = Util.getVisible(request);
boolean int64AsString = Util.getInt64AsString(request);
String address = request.getParameter("address");
Account.Builder build = Account.newBuilder();
JSONObject jsonObject = new JSONObject();
jsonObject.put("address", address);
JsonFormat.merge(jsonObject.toJSONString(), build, visible);
fillResponse(visible, build.build(), response);
try (AutoCloseable ignored = JsonFormat.pushInt64AsString(int64AsString)) {
fillResponse(visible, build.build(), response);
}
} catch (Exception e) {
Util.processError(e, response);
}
Expand All @@ -36,7 +39,9 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
PostParams params = PostParams.getPostParams(request);
Account.Builder build = Account.newBuilder();
JsonFormat.merge(params.getParams(), build, params.isVisible());
fillResponse(params.isVisible(), build.build(), response);
try (AutoCloseable ignored = JsonFormat.pushInt64AsString(params.isInt64AsString())) {
fillResponse(params.isVisible(), build.build(), response);
}
} catch (Exception e) {
Util.processError(e, response);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@ public class GetAssetIssueByAccountServlet extends RateLimiterServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response) {
try {
boolean visible = Util.getVisible(request);
boolean int64AsString = Util.getInt64AsString(request);
String address = request.getParameter("address");
if (visible) {
address = Util.getHexAddress(address);
}
fillResponse(visible, ByteString.copyFrom(ByteArray.fromHexString(address)), response);
try (AutoCloseable ignored = JsonFormat.pushInt64AsString(int64AsString)) {
fillResponse(visible, ByteString.copyFrom(ByteArray.fromHexString(address)), response);
}
} catch (Exception e) {
Util.processError(e, response);
}
Expand All @@ -37,7 +40,9 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
PostParams params = PostParams.getPostParams(request);
Account.Builder build = Account.newBuilder();
JsonFormat.merge(params.getParams(), build, params.isVisible());
fillResponse(params.isVisible(), build.getAddress(), response);
try (AutoCloseable ignored = JsonFormat.pushInt64AsString(params.isInt64AsString())) {
fillResponse(params.isVisible(), build.getAddress(), response);
}
} catch (Exception e) {
Util.processError(e, response);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@ public class GetAssetIssueByIdServlet extends RateLimiterServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response) {
try {
boolean visible = Util.getVisible(request);
boolean int64AsString = Util.getInt64AsString(request);
String input = request.getParameter("value");
AssetIssueContract reply = wallet.getAssetIssueById(input);
if (reply != null) {
response.getWriter().println(JsonFormat.printToString(reply, visible));
try (AutoCloseable ignored = JsonFormat.pushInt64AsString(int64AsString)) {
response.getWriter().println(JsonFormat.printToString(reply, visible));
}
} else {
response.getWriter().println("{}");
}
Expand All @@ -39,7 +42,9 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
String id = jsonObject.getString("value");
AssetIssueContract reply = wallet.getAssetIssueById(id);
if (reply != null) {
response.getWriter().println(JsonFormat.printToString(reply, params.isVisible()));
try (AutoCloseable ignored = JsonFormat.pushInt64AsString(params.isInt64AsString())) {
response.getWriter().println(JsonFormat.printToString(reply, params.isVisible()));
}
} else {
response.getWriter().println("{}");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,14 @@ public class GetAssetIssueByNameServlet extends RateLimiterServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response) {
try {
boolean visible = Util.getVisible(request);
boolean int64AsString = Util.getInt64AsString(request);
String input = request.getParameter("value");
if (visible) {
input = Util.getHexString(input);
}
fillResponse(visible, ByteString.copyFrom(ByteArray.fromHexString(input)), response);
try (AutoCloseable ignored = JsonFormat.pushInt64AsString(int64AsString)) {
fillResponse(visible, ByteString.copyFrom(ByteArray.fromHexString(input)), response);
}
} catch (Exception e) {
Util.processError(e, response);
}
Expand All @@ -41,8 +44,10 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
if (params.isVisible()) {
value = Util.getHexString(value);
}
fillResponse(params.isVisible(), ByteString.copyFrom(
ByteArray.fromHexString(value)), response);
try (AutoCloseable ignored = JsonFormat.pushInt64AsString(params.isInt64AsString())) {
fillResponse(params.isVisible(), ByteString.copyFrom(
ByteArray.fromHexString(value)), response);
}
} catch (Exception e) {
Util.processError(e, response);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@ public class GetAssetIssueListByNameServlet extends RateLimiterServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response) {
try {
boolean visible = Util.getVisible(request);
boolean int64AsString = Util.getInt64AsString(request);
String value = request.getParameter("value");
fillResponse(visible, value, response);
try (AutoCloseable ignored = JsonFormat.pushInt64AsString(int64AsString)) {
fillResponse(visible, value, response);
}
} catch (Exception e) {
Util.processError(e, response);
}
Expand All @@ -36,7 +39,9 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
PostParams params = PostParams.getPostParams(request);
JSONObject jsonObject = JSON.parseObject(params.getParams());
String value = jsonObject.getString("value");
fillResponse(params.isVisible(), value, response);
try (AutoCloseable ignored = JsonFormat.pushInt64AsString(params.isInt64AsString())) {
fillResponse(params.isVisible(), value, response);
}
} catch (Exception e) {
Util.processError(e, response);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ public class GetAssetIssueListServlet extends RateLimiterServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response) {
try {
boolean visible = Util.getVisible(request);
boolean int64AsString = Util.getInt64AsString(request);
AssetIssueList reply = wallet.getAssetIssueList();
if (reply != null) {
response.getWriter().println(JsonFormat.printToString(reply, visible));
try (AutoCloseable ignored = JsonFormat.pushInt64AsString(int64AsString)) {
response.getWriter().println(JsonFormat.printToString(reply, visible));
}
} else {
response.getWriter().println("{}");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,19 @@ public class GetAvailableUnfreezeCountServlet extends RateLimiterServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response) {
try {
boolean visible = Util.getVisible(request);
boolean int64AsString = Util.getInt64AsString(request);
String ownerAddress = request.getParameter("ownerAddress");
if (ownerAddress == null) {
ownerAddress = request.getParameter("owner_address");
}
if (visible) {
ownerAddress = Util.getHexAddress(ownerAddress);
}
fillResponse(visible,
ByteString.copyFrom(ByteArray.fromHexString(ownerAddress)),
response);
try (AutoCloseable ignored = JsonFormat.pushInt64AsString(int64AsString)) {
fillResponse(visible,
ByteString.copyFrom(ByteArray.fromHexString(ownerAddress)),
response);
}
} catch (Exception e) {
Util.processError(e, response);
}
Expand All @@ -44,9 +47,11 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
GrpcAPI.GetAvailableUnfreezeCountRequestMessage.Builder build =
GrpcAPI.GetAvailableUnfreezeCountRequestMessage.newBuilder();
JsonFormat.merge(params.getParams(), build, params.isVisible());
fillResponse(params.isVisible(),
build.getOwnerAddress(),
response);
try (AutoCloseable ignored = JsonFormat.pushInt64AsString(params.isInt64AsString())) {
fillResponse(params.isVisible(),
build.getOwnerAddress(),
response);
}
} catch (Exception e) {
Util.processError(e, response);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
BlockBalanceTrace.BlockIdentifier.Builder builder = BlockBalanceTrace.BlockIdentifier
.newBuilder();
JsonFormat.merge(params.getParams(), builder, params.isVisible());
fillResponse(params.isVisible(), builder.build(), response);
try (AutoCloseable ignored = JsonFormat.pushInt64AsString(params.isInt64AsString())) {
fillResponse(params.isVisible(), builder.build(), response);
}
} catch (Exception e) {
Util.processError(e, response);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ public class GetBlockByIdServlet extends RateLimiterServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response) {
try {
boolean visible = Util.getVisible(request);
boolean int64AsString = Util.getInt64AsString(request);
String input = request.getParameter("value");
fillResponse(visible, ByteString.copyFrom(ByteArray.fromHexString(input)), response);
try (AutoCloseable ignored = JsonFormat.pushInt64AsString(int64AsString)) {
fillResponse(visible, ByteString.copyFrom(ByteArray.fromHexString(input)), response);
}
} catch (Exception e) {
Util.processError(e, response);
}
Expand All @@ -35,7 +38,9 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
PostParams params = PostParams.getPostParams(request);
BytesMessage.Builder build = BytesMessage.newBuilder();
JsonFormat.merge(params.getParams(), build, params.isVisible());
fillResponse(params.isVisible(), build.getValue(), response);
try (AutoCloseable ignored = JsonFormat.pushInt64AsString(params.isInt64AsString())) {
fillResponse(params.isVisible(), build.getValue(), response);
}
} catch (Exception e) {
Util.processError(e, response);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ public class GetBlockByLatestNumServlet extends RateLimiterServlet {

protected void doGet(HttpServletRequest request, HttpServletResponse response) {
try {
fillResponse(Util.getVisible(request), Long.parseLong(request.getParameter("num")), response);
try (AutoCloseable ignored = JsonFormat.pushInt64AsString(Util.getInt64AsString(request))) {
fillResponse(Util.getVisible(request), Long.parseLong(request.getParameter("num")),
response);
}
} catch (Exception e) {
Util.processError(e, response);
}
Expand All @@ -32,7 +35,9 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
PostParams params = PostParams.getPostParams(request);
NumberMessage.Builder build = NumberMessage.newBuilder();
JsonFormat.merge(params.getParams(), build, params.isVisible());
fillResponse(params.isVisible(), build.getNum(), response);
try (AutoCloseable ignored = JsonFormat.pushInt64AsString(params.isInt64AsString())) {
fillResponse(params.isVisible(), build.getNum(), response);
}
} catch (Exception e) {
Util.processError(e, response);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ public class GetBlockByLimitNextServlet extends RateLimiterServlet {

protected void doGet(HttpServletRequest request, HttpServletResponse response) {
try {
fillResponse(Util.getVisible(request), Long.parseLong(request.getParameter("startNum")),
Long.parseLong(request.getParameter("endNum")), response);
try (AutoCloseable ignored = JsonFormat.pushInt64AsString(Util.getInt64AsString(request))) {
fillResponse(Util.getVisible(request), Long.parseLong(request.getParameter("startNum")),
Long.parseLong(request.getParameter("endNum")), response);
}
} catch (Exception e) {
Util.processError(e, response);
}
Expand All @@ -33,7 +35,9 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
PostParams params = PostParams.getPostParams(request);
BlockLimit.Builder build = BlockLimit.newBuilder();
JsonFormat.merge(params.getParams(), build, params.isVisible());
fillResponse(params.isVisible(), build.getStartNum(), build.getEndNum(), response);
try (AutoCloseable ignored = JsonFormat.pushInt64AsString(params.isInt64AsString())) {
fillResponse(params.isVisible(), build.getStartNum(), build.getEndNum(), response);
}
} catch (Exception e) {
Util.processError(e, response);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) {
if (numStr != null) {
num = Long.parseLong(numStr);
}
fillResponse(Util.getVisible(request), num, response);
try (AutoCloseable ignored = JsonFormat.pushInt64AsString(Util.getInt64AsString(request))) {
fillResponse(Util.getVisible(request), num, response);
}
} catch (Exception e) {
Util.processError(e, response);
}
Expand All @@ -38,7 +40,9 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
PostParams params = PostParams.getPostParams(request);
NumberMessage.Builder build = NumberMessage.newBuilder();
JsonFormat.merge(params.getParams(), build, params.isVisible());
fillResponse(params.isVisible(), build.getNum(), response);
try (AutoCloseable ignored = JsonFormat.pushInt64AsString(params.isInt64AsString())) {
fillResponse(params.isVisible(), build.getNum(), response);
}
} catch (Exception e) {
Util.processError(e, response);
}
Expand Down
Loading
Loading