build: config spotless plugin and reformat code

This commit is contained in:
Frank.R.Wu 2023-06-15 11:08:02 +08:00
parent 912ecc21fc
commit 6dfe551a1d
34 changed files with 545 additions and 631 deletions

View File

@ -5,6 +5,8 @@ plugins {
id 'signing'
}
apply from: '../spotless.gradle'
sourceSets {
main {
java {

View File

@ -4,8 +4,7 @@ public class ByteHexUtil {
protected static final char[] hexArray = "0123456789ABCDEF".toCharArray();
// lower ascii only
private static final int[] HEX_TO_INT =
new int[]{
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 0-15
new int[] {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 0-15
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 16-31
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 32-47
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, // 48-63

View File

@ -5,7 +5,7 @@ import java.io.InputStreamReader;
public class Entry {
//release 地址47.93.86.250 root:i1235813
// release 地址47.93.86.250 root:i1235813
public static void main(String[] args) {
try {
if (args == null || args.length < 2) {
@ -36,8 +36,10 @@ public class Entry {
Thread.sleep(1000);
Process p = Runtime.getRuntime().exec("./bdledger_go");
BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));
BufferedReader stdError = new BufferedReader(new InputStreamReader(p.getErrorStream()));
BufferedReader stdInput = new BufferedReader(
new InputStreamReader(p.getInputStream()));
BufferedReader stdError = new BufferedReader(
new InputStreamReader(p.getErrorStream()));
// read the output from the command
System.out.println("Here is the standard output of the command:\n");
@ -46,7 +48,8 @@ public class Entry {
}
// read any errors from the attempted command
System.out.println("Here is the standard error of the command (if any):\n");
System.out.println(
"Here is the standard error of the command (if any):\n");
while ((s = stdError.readLine()) != null) {
System.out.println(s);
}
@ -57,14 +60,14 @@ public class Entry {
}
});
t2.start();
//CMHttpServer.start(getPort(args));
// CMHttpServer.start(getPort(args));
break;
case "NC":
case "NodeCenter":
//NodeCenterServer.start(getPort(args));
// NodeCenterServer.start(getPort(args));
break;
case "Index":
// IndexServer.start(getPort(args));
// IndexServer.start(getPort(args));
default:
printUsage();
}

View File

@ -84,11 +84,8 @@ public class ActionExecutor<T, U> {
handlers.put(method.getName(), new Pair<>(method, obj));
if (!method.getReturnType().equals(Void.TYPE)
|| method.getParameterCount() != 2) {
LOGGER.error(
"action ret is not void:"
+ obj.getClass().getCanonicalName()
+ "-->"
+ method.getName());
LOGGER.error("action ret is not void:"
+ obj.getClass().getCanonicalName() + "-->" + method.getName());
System.exit(0);
}
@ -97,10 +94,8 @@ public class ActionExecutor<T, U> {
handlers.put(a, new Pair<>(method, obj));
if (!method.getReturnType().equals(Void.TYPE)
|| method.getParameterCount() != 2) {
LOGGER.error(
"action ret is not void:"
+ obj.getClass().getCanonicalName()
+ "-->"
LOGGER.error("action ret is not void:"
+ obj.getClass().getCanonicalName() + "-->"
+ method.getName());
System.exit(0);
@ -144,9 +139,7 @@ public class ActionExecutor<T, U> {
try {
pair.first.invoke(pair.second, args, callback);
} catch (Exception e) {
LOGGER.debug(
pair.first.getDeclaringClass().getCanonicalName()
+ "->"
LOGGER.debug(pair.first.getDeclaringClass().getCanonicalName() + "->"
+ pair.first.getName());
e.printStackTrace();
}

View File

@ -49,7 +49,8 @@ public class HttpResultCallback extends ResultCallback implements Runnable {
bytes = ret.getBytes();
}
assert bytes != null;
response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, OK, Unpooled.wrappedBuffer(bytes));
response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, OK,
Unpooled.wrappedBuffer(bytes));
for (String key : extraHeaders.keySet())
response.headers().add(key, extraHeaders.get(key));

View File

@ -28,8 +28,8 @@ public class HttpServerSentEventResultCallback extends HttpResultCallback implem
}
public void writeInitialHead() {
HttpResponse response = new DefaultHttpResponse(HttpVersion.HTTP_1_1,
HttpResponseStatus.OK);
HttpResponse response =
new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
for (String key : extraHeaders.keySet())
response.headers().add(key, extraHeaders.get(key));
ctxField.writeAndFlush(response);
@ -63,13 +63,16 @@ public class HttpServerSentEventResultCallback extends HttpResultCallback implem
public void run() {
try {
if (System.currentTimeMillis() - lastUpdate < 10000L) {
//reschedule
// reschedule
LOGGER.info("Reschedule time out");
currentScheduler = scheduledThreadPool.schedule(this, 10, TimeUnit.SECONDS);
return;
}
if (!closed) {
final ByteBuf buffer = Unpooled.copiedBuffer("{\"action\":\"onDistributeFinish\",\"progress\":\"-1\",\"data\":\"timeout\"}" + "\n\n", StandardCharsets.UTF_8);
final ByteBuf buffer = Unpooled.copiedBuffer(
"{\"action\":\"onDistributeFinish\",\"progress\":\"-1\",\"data\":\"timeout\"}"
+ "\n\n",
StandardCharsets.UTF_8);
ctxField.writeAndFlush(new DefaultHttpContent(buffer));
}
close();

View File

@ -15,10 +15,11 @@ public class ReplyUtil {
resultCallback.onResult(ret);
}
public static void replyWithStatus(ResultCallback resultCallback, String action, boolean status,Object data) {
public static void replyWithStatus(ResultCallback resultCallback, String action, boolean status,
Object data) {
Map<String, Object> ret = new HashMap<>();
ret.put("action", action);
ret.put("status",status);
ret.put("status", status);
ret.put("data", data);
resultCallback.onResult(ret);
}

View File

@ -19,11 +19,8 @@ import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
public class SyncResult {
public static final HashedWheelTimer timer = new HashedWheelTimer(
Executors.defaultThreadFactory(),
5,
TimeUnit.MILLISECONDS,
2);
public static final HashedWheelTimer timer =
new HashedWheelTimer(Executors.defaultThreadFactory(), 5, TimeUnit.MILLISECONDS, 2);
private static final Logger LOGGER = LogManager.getLogger(SyncResult.class);
public Map<String, ResultCallback> waitObj = new ConcurrentHashMap<>();
@ -38,10 +35,8 @@ public class SyncResult {
}
}
public void instrumentWakeUp(
String requestID,
InstrumentedResultCallback instrumentedResultCallback,
JsonObject result) {
public void instrumentWakeUp(String requestID,
InstrumentedResultCallback instrumentedResultCallback, JsonObject result) {
ResultCallback ob = waitObj.get(requestID);
// TODO 难怪之前这是注释的
waitObj.remove(requestID);

View File

@ -28,7 +28,8 @@ public class ArgParser {
private static final Logger LOGGER = LogManager.getLogger(ArgParser.class);
public static JsonObject parseGetAndVerify(FullHttpRequest msg, VerifiedCallback cb) throws Exception {
public static JsonObject parseGetAndVerify(FullHttpRequest msg, VerifiedCallback cb)
throws Exception {
QueryStringDecoder decoderQuery = new QueryStringDecoder(msg.uri());
Map<String, List<String>> parameters = decoderQuery.parameters();
JsonObject transformedParam = new JsonObject();
@ -49,17 +50,17 @@ public class ArgParser {
return transformedParam;
}
private static void verifyParam(JsonObject transformedParam, String toVerifyStr, VerifiedCallback cb) {
private static void verifyParam(JsonObject transformedParam, String toVerifyStr,
VerifiedCallback cb) {
boolean verify = false;
if (transformedParam.has("pubKey")) {
LOGGER.info("before verifying: " + toVerifyStr);
try {
ECPublicKeyParameters pubKey =
BCECUtil.createECPublicKeyFromStrParameters(
transformedParam.get("pubKey").getAsString(), SM2Util.CURVE, SM2Util.DOMAIN_PARAMS);
verify =
SM2Util.verify(
pubKey, toVerifyStr.getBytes(), ByteUtils.fromHexString(transformedParam.get("sign").getAsString()));
ECPublicKeyParameters pubKey = BCECUtil.createECPublicKeyFromStrParameters(
transformedParam.get("pubKey").getAsString(), SM2Util.CURVE,
SM2Util.DOMAIN_PARAMS);
verify = SM2Util.verify(pubKey, toVerifyStr.getBytes(),
ByteUtils.fromHexString(transformedParam.get("sign").getAsString()));
} catch (Exception e) {
LOGGER.error(e.getMessage());
@ -71,7 +72,8 @@ public class ArgParser {
return;
}
public static JsonObject parsePostAndVerify(FullHttpRequest msg, VerifiedCallback cb) throws Exception {
public static JsonObject parsePostAndVerify(FullHttpRequest msg, VerifiedCallback cb)
throws Exception {
ByteBuf content = msg.content();
JsonObject map =
JsonParser.parseReader(new InputStreamReader(new ByteBufInputStream(content)))
@ -80,13 +82,15 @@ public class ArgParser {
boolean isFirst = true;
for (String key : map.keySet()) {
if (!key.equals("sign")) {
if (!isFirst) toSign.append("&");
if (!isFirst)
toSign.append("&");
isFirst = false;
toSign.append(key).append("=");
JsonElement je = map.get(key);
if (je.isJsonPrimitive())
toSign.append(je.getAsString());
else toSign.append(je.toString());
else
toSign.append(je.toString());
}
}
verifyParam(map, toSign.toString(), cb);

View File

@ -24,7 +24,8 @@ public class FileDownloaderCallback extends HttpResultCallback {
public void onResult(final String filePath) {
try {
final RandomAccessFile file = new RandomAccessFile(filePath, "r");
HttpResponse response = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
HttpResponse response =
new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
// 设置文件格式内容
response.headers().set(HttpHeaderNames.CONTENT_TYPE, "application/x-msdownload");
response.headers().set(HttpHeaderNames.CONTENT_DISPOSITION,
@ -33,13 +34,14 @@ public class FileDownloaderCallback extends HttpResultCallback {
HttpUtil.setContentLength(response, file.length());
LOGGER.debug("FileLength:" + file.length());
ctxField.write(response);
ChannelFuture future = ctxField.write(new DefaultFileRegion(file.getChannel(), 0, file.length()),
ChannelFuture future =
ctxField.write(new DefaultFileRegion(file.getChannel(), 0, file.length()),
ctxField.newProgressivePromise());
ctxField.writeAndFlush(LastHttpContent.EMPTY_LAST_CONTENT);
future.addListener(new ChannelProgressiveFutureListener() {
@Override
public void operationProgressed(ChannelProgressiveFuture future, long progress, long total) {
}
public void operationProgressed(ChannelProgressiveFuture future, long progress,
long total) {}
@Override
public void operationComplete(ChannelProgressiveFuture future) throws Exception {

View File

@ -24,12 +24,8 @@ public class HttpFileHandleAdapter extends SimpleChannelInboundHandler<FullHttpR
}
public static void sendError(ChannelHandlerContext ctx, HttpResponseStatus status) {
FullHttpResponse response =
new DefaultFullHttpResponse(
HTTP_1_1,
status,
Unpooled.wrappedBuffer(
("Failure: " + status + "\r\n").getBytes()));
FullHttpResponse response = new DefaultFullHttpResponse(HTTP_1_1, status,
Unpooled.wrappedBuffer(("Failure: " + status + "\r\n").getBytes()));
response.headers().set(HttpHeaderNames.CONTENT_TYPE, "text/plain; charset=UTF-8");
ctx.writeAndFlush(response).addListener(ChannelFutureListener.CLOSE);
}

View File

@ -1,15 +1,7 @@
package org.bdware.server.http;
public enum HttpMethod {
OPTIONS,
GET,
HEAD,
POST,
PUT,
PATCH,
DELETE,
TRACE,
CONNECT;
OPTIONS, GET, HEAD, POST, PUT, PATCH, DELETE, TRACE, CONNECT;
io.netty.handler.codec.http.HttpMethod get() {
switch (this) {

View File

@ -80,21 +80,17 @@ public class URIHandler {
for (Tuple<String, Method, Object> t : handlers.get(m)) {
String className = t.u.getDeclaringClass().getSimpleName();
sbl.append("\t\t").append(t.t.isEmpty() ? "<null>" : t.t).append(" --> ")
.append(className.isEmpty() ? "null" : className)
.append(".").append(t.u.getName()).append("\n");
.append(className.isEmpty() ? "null" : className).append(".")
.append(t.u.getName()).append("\n");
}
}
LOGGER.info(sbl.substring(0, sbl.length() - 1));
}
private void sendUnsupported(ChannelHandlerContext ctx) {
FullHttpResponse response =
new DefaultFullHttpResponse(
HTTP_1_1,
HttpResponseStatus.BAD_REQUEST,
Unpooled.wrappedBuffer(
("Failure: " + HttpResponseStatus.BAD_REQUEST + "\r\n")
.getBytes()));
FullHttpResponse response = new DefaultFullHttpResponse(HTTP_1_1,
HttpResponseStatus.BAD_REQUEST, Unpooled.wrappedBuffer(
("Failure: " + HttpResponseStatus.BAD_REQUEST + "\r\n").getBytes()));
response.headers().set(HttpHeaderNames.CONTENT_TYPE, "text/plain; charset=UTF-8");
ctx.writeAndFlush(response).addListener(ChannelFutureListener.CLOSE);
}

View File

@ -9,5 +9,6 @@ import java.lang.annotation.Target;
@Target(ElementType.METHOD)
public @interface URIPath {
String[] value() default {""};
HttpMethod method() default HttpMethod.GET;
}

View File

@ -22,9 +22,9 @@ public class CMNodeBean {
// TODO nodeMangerPubkey
public void updateContract(Map<String, String> json) {
String jsonStr = json.get("contracts");
contracts = JsonUtil.fromJson(jsonStr, new TypeToken<List<ContractDesp>>() {
}.getType());
// KeyValueDBUtil.instance.setValue(NCTables.NodesDB.toString(), pubKey, JsonUtil.toJson(this));
contracts = JsonUtil.fromJson(jsonStr, new TypeToken<List<ContractDesp>>() {}.getType());
// KeyValueDBUtil.instance.setValue(NCTables.NodesDB.toString(), pubKey,
// JsonUtil.toJson(this));
}
@ -33,7 +33,8 @@ public class CMNodeBean {
public String formatContractName(String contractIDOrName) {
if (null != contracts) {
for (ContractDesp desp : contracts) {
if (desp.contractID.equals(contractIDOrName) || desp.contractName.equals(contractIDOrName)) {
if (desp.contractID.equals(contractIDOrName)
|| desp.contractName.equals(contractIDOrName)) {
return desp.contractName;
}
}
@ -44,7 +45,8 @@ public class CMNodeBean {
public boolean containsContract(String contractIDOrName) {
if (null != contracts) {
for (ContractDesp desp : contracts) {
if (desp.contractID.equals(contractIDOrName) || desp.contractName.equals(contractIDOrName))
if (desp.contractID.equals(contractIDOrName)
|| desp.contractName.equals(contractIDOrName))
return true;
}
}
@ -54,7 +56,8 @@ public class CMNodeBean {
public boolean containsEvent(String contractIDOrName, String event) {
if (null != contracts) {
for (ContractDesp desp : contracts) {
if (desp.contractID.equals(contractIDOrName) || desp.contractName.equals(contractIDOrName)) {
if (desp.contractID.equals(contractIDOrName)
|| desp.contractName.equals(contractIDOrName)) {
if (desp.events.containsKey(event))
return true;
}

View File

@ -1,42 +1,42 @@
package org.bdware.server.permission;
public enum Permission {
// GetSessionID(0), GetRole(0), Login(0), // 默认权限设置为0
// ApplyRole(1 << 0), // 匿名用户申请成为节点管理员NodePortal角色
// NodeStateList(1 << 1), // 中心节点查看节点管理员的所管理所有节点的状态
// AuthNodeManager(1 << 2), // 授权节点管理员
// DeleteNodeManager(1 << 3), // 从网络中删除某个节点管理员
// ListAllUsers(1 << 4), // ListAllUser
// ListApplyUser(1 << 5), // ListApplyUser
// ListTrustCluster(1 << 6), // 查看可信执行集群列表
// AssignTrustedCluster(1 << 7), // 分配可信执行集群
//
// // ==================NodePotral===============
// //ApplyNodeRole(1<<6),//申请节点角色
// AuthNodeRole(1 << 8), // 授权角色
// DeleteRole(1 << 9), // 从用户角色中删除某一种角色
// ListAllAuthUsers(1 << 10), // 查看已授权用户
// ListUnAuthUsers(1 << 11), // 查看未授权用户
//
// StartContract(1 << 12), ExecuteContract(1 << 13), StopContract(1 << 14), // stop和kill一样
// UploadContract(1 << 15), // 上传合约代码修改代码更新合约代码保存代码)
// DownloadContract(1 << 16), // 下载合约代码
// DeleteContract(1 << 17), // 删除合约代码
//
// ContractCodeStatisticsList(1 << 18), // 查看合约代码统计数据合约文件大小)
// StaticAnalysis(1 << 19), // 静态分析
// ConfigureContractPermission(1 << 20), // 配置合约权限
// ContractProgressList(1L << 22L), // 查看合约进程(listContractProcess)
//
// QueryActionLog(1L << 24L), // 增加listLog(时间戳)
// QueryUserStateLog(1L << 25L), // 查看节点日志
// ListLocalNodeStatus(1L << 26L), // 节点状态(此节点)
// ListContractLog(1L << 27L), // 合约日志
//
// TimeTravel(1L << 28L), ManualDump(1L << 29L), // 手动dump
// ForkContractStatus(1L << 30L), // 合约状态从别处迁移到自己本地
// ConfigureNode(1L << 31L), // 配置节点信息
// listProjects(1L << 32L),// 合约提供者
// GetSessionID(0), GetRole(0), Login(0), // 默认权限设置为0
// ApplyRole(1 << 0), // 匿名用户申请成为节点管理员NodePortal角色
// NodeStateList(1 << 1), // 中心节点查看节点管理员的所管理所有节点的状态
// AuthNodeManager(1 << 2), // 授权节点管理员
// DeleteNodeManager(1 << 3), // 从网络中删除某个节点管理员
// ListAllUsers(1 << 4), // ListAllUser
// ListApplyUser(1 << 5), // ListApplyUser
// ListTrustCluster(1 << 6), // 查看可信执行集群列表
// AssignTrustedCluster(1 << 7), // 分配可信执行集群
//
// // ==================NodePotral===============
// //ApplyNodeRole(1<<6),//申请节点角色
// AuthNodeRole(1 << 8), // 授权角色
// DeleteRole(1 << 9), // 从用户角色中删除某一种角色
// ListAllAuthUsers(1 << 10), // 查看已授权用户
// ListUnAuthUsers(1 << 11), // 查看未授权用户
//
// StartContract(1 << 12), ExecuteContract(1 << 13), StopContract(1 << 14), // stop和kill一样
// UploadContract(1 << 15), // 上传合约代码修改代码更新合约代码保存代码)
// DownloadContract(1 << 16), // 下载合约代码
// DeleteContract(1 << 17), // 删除合约代码
//
// ContractCodeStatisticsList(1 << 18), // 查看合约代码统计数据合约文件大小)
// StaticAnalysis(1 << 19), // 静态分析
// ConfigureContractPermission(1 << 20), // 配置合约权限
// ContractProgressList(1L << 22L), // 查看合约进程(listContractProcess)
//
// QueryActionLog(1L << 24L), // 增加listLog(时间戳)
// QueryUserStateLog(1L << 25L), // 查看节点日志
// ListLocalNodeStatus(1L << 26L), // 节点状态(此节点)
// ListContractLog(1L << 27L), // 合约日志
//
// TimeTravel(1L << 28L), ManualDump(1L << 29L), // 手动dump
// ForkContractStatus(1L << 30L), // 合约状态从别处迁移到自己本地
// ConfigureNode(1L << 31L), // 配置节点信息
// listProjects(1L << 32L),// 合约提供者
// 新加的一些权限
@ -45,16 +45,10 @@ public enum Permission {
// TODO: 20205/20 需要整理权限就权限和最新的权限
// CenterManager (其他部分代码中出现的暂未合并整理)
ApplyRole(1 << 0),
NodeStateList(1 << 1),
AuthNodeManager(1 << 2),
ListAllUsers(1 << 3),
ListApplyUser(1 << 4),
DeleteNodeManager(1 << 5),
ListTrustCluster(1 << 6),
AssignTrustedCluster(1 << 7),
QueryActionLog(1 << 8),
QueryUserStateLog(1 << 9),
ApplyRole(1 << 0), NodeStateList(1 << 1), AuthNodeManager(1 << 2), ListAllUsers(
1 << 3), ListApplyUser(1 << 4), DeleteNodeManager(1 << 5), ListTrustCluster(
1 << 6), AssignTrustedCluster(
1 << 7), QueryActionLog(1 << 8), QueryUserStateLog(1 << 9),
// Node
ConfigureNode(1 << 10), // 其他地方代码中的权限

View File

@ -1,13 +1,8 @@
package org.bdware.server.permission;
public enum Role {
CenterManager(0x3ffL),
NodeManager(0xe41L),
Node(0x1L),
ContractProvider(0x3f000L),
ContractInstanceManager(0x7ff10c0L),
ContractUser(0x5c0000L),
Anonymous(0);
CenterManager(0x3ffL), NodeManager(0xe41L), Node(0x1L), ContractProvider(
0x3f000L), ContractInstanceManager(0x7ff10c0L), ContractUser(0x5c0000L), Anonymous(0);
long value;

View File

@ -5,13 +5,11 @@ import io.netty.buffer.Unpooled;
import io.netty.channel.CombinedChannelDuplexHandler;
import io.netty.handler.codec.DelimiterBasedFrameDecoder;
public class DelimiterCodec
extends CombinedChannelDuplexHandler<
DelimiterBasedFrameDecoder, DelimiterBasedFrameEncoder> {
public class DelimiterCodec extends
CombinedChannelDuplexHandler<DelimiterBasedFrameDecoder, DelimiterBasedFrameEncoder> {
public DelimiterCodec() {
ByteBuf buf = Unpooled.wrappedBuffer(DelimiterBasedFrameEncoder.delimiter);
init(
new DelimiterBasedFrameDecoder(10 * 1024 * 1024, buf),
init(new DelimiterBasedFrameDecoder(10 * 1024 * 1024, buf),
new DelimiterBasedFrameEncoder());
}
}

View File

@ -36,25 +36,26 @@ public class WebSocketIndexPageHandler extends SimpleChannelInboundHandler<FullH
protected void channelRead0(ChannelHandlerContext ctx, FullHttpRequest req) throws Exception {
// Handle a bad request.
if (!req.getUri().startsWith("/SCIDE/SCExecutor")) {
sendHttpResponse(ctx, req,
new DefaultFullHttpResponse(req.protocolVersion(), NOT_FOUND, ctx.alloc().buffer(0)));
sendHttpResponse(ctx, req, new DefaultFullHttpResponse(req.protocolVersion(), NOT_FOUND,
ctx.alloc().buffer(0)));
return;
}
if (!req.decoderResult().isSuccess()) {
sendHttpResponse(ctx, req,
new DefaultFullHttpResponse(req.protocolVersion(), BAD_REQUEST, ctx.alloc().buffer(0)));
sendHttpResponse(ctx, req, new DefaultFullHttpResponse(req.protocolVersion(),
BAD_REQUEST, ctx.alloc().buffer(0)));
return;
}
// Allow only GET methods.
if (!GET.equals(req.method())) {
sendHttpResponse(ctx, req,
new DefaultFullHttpResponse(req.protocolVersion(), FORBIDDEN, ctx.alloc().buffer(0)));
sendHttpResponse(ctx, req, new DefaultFullHttpResponse(req.protocolVersion(), FORBIDDEN,
ctx.alloc().buffer(0)));
return;
}
// Send the index page
if ("/SCIDE/SCExecutor/".equals(req.uri()) || "/SCIDE/SCExecutor/index.html".equals(req.uri())) {
if ("/SCIDE/SCExecutor/".equals(req.uri())
|| "/SCIDE/SCExecutor/index.html".equals(req.uri())) {
String webSocketLocation = getWebSocketLocation(ctx.pipeline(), req, websocketPath);
ByteBuf content = WebSocketServerIndexPage.getContent(webSocketLocation);
FullHttpResponse res = new DefaultFullHttpResponse(req.protocolVersion(), OK, content);
@ -62,8 +63,8 @@ public class WebSocketIndexPageHandler extends SimpleChannelInboundHandler<FullH
HttpUtil.setContentLength(res, content.readableBytes());
sendHttpResponse(ctx, req, res);
} else {
sendHttpResponse(ctx, req,
new DefaultFullHttpResponse(req.protocolVersion(), NOT_FOUND, ctx.alloc().buffer(0)));
sendHttpResponse(ctx, req, new DefaultFullHttpResponse(req.protocolVersion(), NOT_FOUND,
ctx.alloc().buffer(0)));
}
}
@ -73,7 +74,8 @@ public class WebSocketIndexPageHandler extends SimpleChannelInboundHandler<FullH
ctx.close();
}
private static void sendHttpResponse(ChannelHandlerContext ctx, FullHttpRequest req, FullHttpResponse res) {
private static void sendHttpResponse(ChannelHandlerContext ctx, FullHttpRequest req,
FullHttpResponse res) {
// Generate an error page if response getStatus code is not OK (200).
HttpResponseStatus responseStatus = res.status();
if (responseStatus.code() != 200) {

View File

@ -9,93 +9,33 @@ public final class WebSocketServerIndexPage {
private static final String NEWLINE = "\r\n";
public static ByteBuf getContent(String webSocketLocation) {
String str =
"<html><head><title>Web Socket Test</title></head>"
+ NEWLINE
+ "<body>"
+ NEWLINE
+ "<script type=\"text/javascript\">"
+ NEWLINE
+ "var socket;"
+ NEWLINE
+ "if (!window.WebSocket) {"
+ NEWLINE
+ " window.WebSocket = window.MozWebSocket;"
+ NEWLINE
+ '}'
+ NEWLINE
+ "if (window.WebSocket) {"
+ NEWLINE
+ " socket = new WebSocket(\""
+ webSocketLocation
+ "\");"
+ NEWLINE
+ " socket.onmessage = function(event) {"
+ NEWLINE
+ " var ta = document.getElementById('responseText');"
+ NEWLINE
+ " ta.value = ta.value + '\\n' + event.data"
+ NEWLINE
+ " };"
+ NEWLINE
+ " socket.onopen = function(event) {"
+ NEWLINE
+ " var ta = document.getElementById('responseText');"
+ NEWLINE
+ " ta.value = \"Web Socket opened!\";"
+ NEWLINE
+ " };"
+ NEWLINE
+ " socket.onclose = function(event) {"
+ NEWLINE
+ " var ta = document.getElementById('responseText');"
+ NEWLINE
+ " ta.value = ta.value + \"Web Socket closed\"; "
+ NEWLINE
+ " };"
+ NEWLINE
+ "} else {"
+ NEWLINE
+ " alert(\"Your browser does not support Web Socket.\");"
+ NEWLINE
+ '}'
+ NEWLINE
+ NEWLINE
+ "function send(message) {"
+ NEWLINE
+ " if (!window.WebSocket) { return; }"
+ NEWLINE
+ " if (socket.readyState == WebSocket.OPEN) {"
+ NEWLINE
+ " socket.send(message);"
+ NEWLINE
+ " } else {"
+ NEWLINE
+ " alert(\"The socket is not open.\");"
+ NEWLINE
+ " }"
+ NEWLINE
+ '}'
+ NEWLINE
+ "</script>"
+ NEWLINE
+ "<form onsubmit=\"return false;\">"
+ NEWLINE
String str = "<html><head><title>Web Socket Test</title></head>" + NEWLINE + "<body>"
+ NEWLINE + "<script type=\"text/javascript\">" + NEWLINE + "var socket;" + NEWLINE
+ "if (!window.WebSocket) {" + NEWLINE + " window.WebSocket = window.MozWebSocket;"
+ NEWLINE + '}' + NEWLINE + "if (window.WebSocket) {" + NEWLINE
+ " socket = new WebSocket(\"" + webSocketLocation + "\");" + NEWLINE
+ " socket.onmessage = function(event) {" + NEWLINE
+ " var ta = document.getElementById('responseText');" + NEWLINE
+ " ta.value = ta.value + '\\n' + event.data" + NEWLINE + " };" + NEWLINE
+ " socket.onopen = function(event) {" + NEWLINE
+ " var ta = document.getElementById('responseText');" + NEWLINE
+ " ta.value = \"Web Socket opened!\";" + NEWLINE + " };" + NEWLINE
+ " socket.onclose = function(event) {" + NEWLINE
+ " var ta = document.getElementById('responseText');" + NEWLINE
+ " ta.value = ta.value + \"Web Socket closed\"; " + NEWLINE + " };" + NEWLINE
+ "} else {" + NEWLINE + " alert(\"Your browser does not support Web Socket.\");"
+ NEWLINE + '}' + NEWLINE + NEWLINE + "function send(message) {" + NEWLINE
+ " if (!window.WebSocket) { return; }" + NEWLINE
+ " if (socket.readyState == WebSocket.OPEN) {" + NEWLINE
+ " socket.send(message);" + NEWLINE + " } else {" + NEWLINE
+ " alert(\"The socket is not open.\");" + NEWLINE + " }" + NEWLINE + '}'
+ NEWLINE + "</script>" + NEWLINE + "<form onsubmit=\"return false;\">" + NEWLINE
+ "<input type=\"text\" name=\"message\" value=\"Hello, World!\"/>"
+ "<input type=\"button\" value=\"Send Web Socket Data\""
+ NEWLINE
+ " onclick=\"send(this.form.message.value)\" />"
+ NEWLINE
+ "<h3>Output</h3>"
+ NEWLINE
+ "<input type=\"button\" value=\"Send Web Socket Data\"" + NEWLINE
+ " onclick=\"send(this.form.message.value)\" />" + NEWLINE
+ "<h3>Output</h3>" + NEWLINE
+ "<textarea id=\"responseText\" style=\"width:500px;height:300px;\"></textarea>"
+ NEWLINE
+ "</form>"
+ NEWLINE
+ "</body>"
+ NEWLINE
+ "</html>"
+ NEWLINE;
+ NEWLINE + "</form>" + NEWLINE + "</body>" + NEWLINE + "</html>" + NEWLINE;
return Unpooled.wrappedBuffer(str.getBytes());
}

View File

@ -22,7 +22,7 @@ public class IndexServer {
}
public static void main(String[] args) throws Exception {
// NodeCenterServer.start(18001);
// NodeCenterServer.start(18001);
start(1614);
}
@ -44,7 +44,8 @@ public class IndexServer {
.childHandler(new ChannelInitializer<SocketChannel>() {
@Override
protected void initChannel(SocketChannel arg0) throws Exception {
arg0.pipeline().addLast(new HttpServerCodec()).addLast(new HttpObjectAggregator(65536))
arg0.pipeline().addLast(new HttpServerCodec())
.addLast(new HttpObjectAggregator(65536))
.addLast(new ChunkedWriteHandler()).addLast(serverHandler);
}
});

View File

@ -20,8 +20,7 @@ public class IndexAction {
static final String MISSING_ARGUMENT = "{\"status\":\"Errorr\",\"data\":\"missing arguments\"}";
static Map<String, LenVarTimeSerialIndex2> fileMap = new HashMap<>();
public IndexAction() {
}
public IndexAction() {}
@Action(async = true)
public void createFile(JsonObject args, final ResultCallback resultCallback) {
@ -41,9 +40,9 @@ public class IndexAction {
for (int i = 0; i < dataLength; i++)
fout.write(1);
fout.close();
// LenVarTimeSerialIndex2 index = getIndexFile(fileName);
resultCallback.onResult(
"{\"status\":\"Success\",\"dataLength\":" + dataLength + ",\".datasize\":" + f.length() + "}");
// LenVarTimeSerialIndex2 index = getIndexFile(fileName);
resultCallback.onResult("{\"status\":\"Success\",\"dataLength\":" + dataLength
+ ",\".datasize\":" + f.length() + "}");
} catch (Exception e) {
ByteArrayOutputStream bo = new ByteArrayOutputStream();
@ -85,7 +84,8 @@ public class IndexAction {
try {
LenVarTimeSerialIndex2 index = getIndexFile(args.get("file").getAsString());
resultCallback.onResult("{\"dataSize\":" + index.dataSize + ",\"fileSize\":" + index.fileSize + "}");
resultCallback.onResult(
"{\"dataSize\":" + index.dataSize + ",\"fileSize\":" + index.fileSize + "}");
} catch (Exception e) {
ByteArrayOutputStream bo = new ByteArrayOutputStream();

View File

@ -34,11 +34,10 @@ public class IndexHttpHandler extends SimpleChannelInboundHandler<HttpObject> {
private static final String UNSUPPORTED_HTTP_METHOD = "{\"msg\":\"unsupported http method\"}";
private static final String UNSUPPORTED_ACTION = "{\"msg\":\"unsupported action\"}";
private static final Logger LOGGER = LogManager.getLogger(IndexHttpHandler.class);
private static ActionExecutor<ResultCallback, JsonObject> actionExecutor = new ActionExecutor<>(
Executors.newFixedThreadPool(5), new IndexAction());
private static ActionExecutor<ResultCallback, JsonObject> actionExecutor =
new ActionExecutor<>(Executors.newFixedThreadPool(5), new IndexAction());
public IndexHttpHandler() {
}
public IndexHttpHandler() {}
@Override
public void channelReadComplete(ChannelHandlerContext ctx) {
@ -58,7 +57,8 @@ public class IndexHttpHandler extends SimpleChannelInboundHandler<HttpObject> {
private void handleHttpRequest(ChannelHandlerContext ctx, FullHttpRequest msg) {
if (!msg.uri().startsWith("/SCIDE/Index")) {
try {
DefaultFullHttpResponse fullResponse = new DefaultFullHttpResponse(msg.getProtocolVersion(), OK,
DefaultFullHttpResponse fullResponse =
new DefaultFullHttpResponse(msg.getProtocolVersion(), OK,
Unpooled.wrappedBuffer(UNSUPPORTED_HTTP_METHOD.getBytes()));
ChannelFuture f = ctx.write(fullResponse);
f.addListener(ChannelFutureListener.CLOSE);
@ -109,8 +109,8 @@ public class IndexHttpHandler extends SimpleChannelInboundHandler<HttpObject> {
String action = null;
if (!map.has("action")) {
ret = UNSUPPORTED_ACTION.getBytes();
DefaultFullHttpResponse response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, OK,
Unpooled.wrappedBuffer(ret));
DefaultFullHttpResponse response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1,
OK, Unpooled.wrappedBuffer(ret));
ChannelFuture f = ctx.write(response);
f.addListener(ChannelFutureListener.CLOSE);
return;

View File

@ -14,30 +14,22 @@ public class URIHandlerTest {
handler.register(this);
}
@URIPath(
method = HttpMethod.OPTIONS,
value = {"/"})
@URIPath(method = HttpMethod.OPTIONS, value = {"/"})
public void h1(ChannelHandlerContext ctx, FullHttpRequest request) {
return;
}
@URIPath(
method = HttpMethod.GET,
value = {"/SCIDE/ABC/", "/SCIDE/CEEEE"})
@URIPath(method = HttpMethod.GET, value = {"/SCIDE/ABC/", "/SCIDE/CEEEE"})
public void h2(ChannelHandlerContext ctx, FullHttpRequest request) {
return;
}
@URIPath(
method = HttpMethod.GET,
value = {"/"})
@URIPath(method = HttpMethod.GET, value = {"/"})
public void h3(ChannelHandlerContext ctx, FullHttpRequest request) {
return;
}
@URIPath(
method = HttpMethod.GET,
value = {"/client"})
@URIPath(method = HttpMethod.GET, value = {"/client"})
public void h4(ChannelHandlerContext ctx, FullHttpRequest request) {
return;
}

View File

@ -35,11 +35,12 @@ public class PermissionTest {
setNodeManager.add(ManageNode);
setNodeManager.add(GetNodeInfo);
setCenterManager.add(TakeScreenShot);
long NodeManager = 0L;//2248150849
long NodeManager = 0L;// 2248150849
for (Permission p : setNodeManager) {
NodeManager |= p.getValue();
}
System.out.println("[NodeManager]" + String.format("0x%xL", NodeManager) + " " + NodeManager);
System.out
.println("[NodeManager]" + String.format("0x%xL", NodeManager) + " " + NodeManager);
EnumSet<Permission> setContractProvider = EnumSet.noneOf(Permission.class);
// 合约提供者
@ -74,7 +75,8 @@ public class PermissionTest {
for (Permission p : ContractInstanceManager) {
ContractInstanceManagerVAL |= p.getValue();
}
System.out.println("[ContractInstanceManager]" + String.format("0x%xL", ContractInstanceManagerVAL));
System.out.println(
"[ContractInstanceManager]" + String.format("0x%xL", ContractInstanceManagerVAL));
EnumSet<Permission> ContractUser = EnumSet.noneOf(Permission.class);
// 合约使用者

View File

@ -42,13 +42,8 @@ public class BDLedgerClient {
public void send() {
String mockedFrom = "0xb60e8dd61c5d32be8058bb8eb970870f07233155";
LedgerProto.SendTransactionResponse ret2 =
client.sendTransactionSync(
"default",
CommonProto.TransactionType.MESSAGE,
mockedFrom,
random.nextLong(),
mockedFrom,
LedgerProto.SendTransactionResponse ret2 = client.sendTransactionSync("default",
CommonProto.TransactionType.MESSAGE, mockedFrom, random.nextLong(), mockedFrom,
"Hellooooo".getBytes(StandardCharsets.UTF_8));
ByteString hash = ret2.getHash();
System.out.println("[BDLedgerClient] hash:" + byteArray2Str(hash.toByteArray(), 0));
@ -60,9 +55,7 @@ public class BDLedgerClient {
// "ea508a07b79afc03c94a84ff190ca29f1153ef75"
// cb304919522a4acd8f2b23fadf993829ac40795a
QueryProto.GetBlocksResponse blocks =
client.getBlocksSync(
"default",
System.currentTimeMillis() - 23L * 3600L * 1000L,
client.getBlocksSync("default", System.currentTimeMillis() - 23L * 3600L * 1000L,
QueryProto.IncludeTransactions.FULL);
System.out.println("BlockCount:" + blocks.getBlocksCount());
// GetTransactionByHashResponse result = client.getTransactionByHashSync("test",
@ -75,9 +68,8 @@ public class BDLedgerClient {
public void queryTransaction() {
// test2 31b50daa8d607c673af5ef449a4d78c70bf952d4
// bdcontract cb304919522a4acd8f2b23fadf993829ac40795a
QueryProto.GetTransactionByHashResponse result =
client.getTransactionByHashSync(
"default", "78bf9fb27963b26bf2f8d558f20bf44559178b67");
QueryProto.GetTransactionByHashResponse result = client.getTransactionByHashSync("default",
"78bf9fb27963b26bf2f8d558f20bf44559178b67");
ByteString bytes = result.getTransaction().getData();
System.out.println(new String(bytes.toByteArray()));
}

View File

@ -17,7 +17,7 @@ public class CMHttpTest {
}
private static void CMActionTest() {
//http_load
// http_load
String host = "http://127.0.0.1:18000/SCIDE/CMManager?action=";
String url1 = host + "ping";
System.out.println(httpGet(url1));
@ -39,7 +39,8 @@ public class CMHttpTest {
System.out.println(httpGet(url1));
url1 = host + "killAllContract";
System.out.println(httpGet(url1));
url1 = host + "startContractBatched&fileList=" + URLEncoder.encode("[\"algorithmExample.yjs\",\"AAA.yjs\"]");
url1 = host + "startContractBatched&fileList="
+ URLEncoder.encode("[\"algorithmExample.yjs\",\"AAA.yjs\"]");
System.out.println(httpGet(url1));
// url1 = host + "startContractInTempZips";
// System.out.println(httpGet(url1));
@ -52,8 +53,8 @@ public class CMHttpTest {
System.out.println(httpGet(url1));
url1 = host + "downloadUUID";
System.out.println(httpGet(url1));
url1 = host + "updateConfig&key=projectDir&val="
+ URLEncoder.encode("/Users/huaqiancai/java_workspace/SmartContract/contractExamples");
url1 = host + "updateConfig&key=projectDir&val=" + URLEncoder
.encode("/Users/huaqiancai/java_workspace/SmartContract/contractExamples");
System.out.println(httpGet(url1));
url1 = host + "loadConfig";
System.out.println(httpGet(url1));

View File

@ -11,11 +11,11 @@ import org.bdware.sc.bean.ContractDesp;
public class GsonParseTest {
public static void main(String[] args) {
String jsonStr = "{\"action\":\"updateContract\",\"contracts\":\"[{\\\"contractID\\\":\\\"-1306108766\\\",\\\"contractName\\\":\\\"EventSuberAtCHQ\\\",\\\"events\\\":[\\\"def\\\"],\\\"exportedFunctions\\\":[{\\\"annotations\\\":[{\\\"type\\\":\\\"LogType\\\",\\\"args\\\":[\\\"\\\\\\\"Arg\\\\\\\"\\\"]}],\\\"functionName\\\":\\\"init\\\"},{\\\"annotations\\\":[{\\\"type\\\":\\\"LogType\\\",\\\"args\\\":[\\\"\\\\\\\"Arg\\\\\\\"\\\"]}],\\\"functionName\\\":\\\"handler\\\"}]}]\"}\n";
String jsonStr =
"{\"action\":\"updateContract\",\"contracts\":\"[{\\\"contractID\\\":\\\"-1306108766\\\",\\\"contractName\\\":\\\"EventSuberAtCHQ\\\",\\\"events\\\":[\\\"def\\\"],\\\"exportedFunctions\\\":[{\\\"annotations\\\":[{\\\"type\\\":\\\"LogType\\\",\\\"args\\\":[\\\"\\\\\\\"Arg\\\\\\\"\\\"]}],\\\"functionName\\\":\\\"init\\\"},{\\\"annotations\\\":[{\\\"type\\\":\\\"LogType\\\",\\\"args\\\":[\\\"\\\\\\\"Arg\\\\\\\"\\\"]}],\\\"functionName\\\":\\\"handler\\\"}]}]\"}\n";
JsonObject jo = new JsonParser().parse(jsonStr).getAsJsonObject();
List<ContractDesp> contracts = new Gson().fromJson(jo.get("contracts").getAsString(),
new TypeToken<List<ContractDesp>>() {
}.getType());
new TypeToken<List<ContractDesp>>() {}.getType());
System.out.println(new GsonBuilder().setPrettyPrinting().create().toJson(contracts));
}
}

View File

@ -33,7 +33,8 @@ public class HttpPostFormTest {
String BOUNDARY = "----------" + System.currentTimeMillis();
// httpConnection.setRequestProperty("Content-Type", "multipart/form-data;
// boundary=" + BOUNDARY);
httpConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded;boundary=" + BOUNDARY);
httpConnection.setRequestProperty("Content-Type",
"application/x-www-form-urlencoded;boundary=" + BOUNDARY);
// 连接从postUrl.openConnection()至此的配置必须要在connect之前完成
// 要注意的是connection.getOutputStream会隐含的进行connect
@ -75,7 +76,8 @@ public class HttpPostFormTest {
}
try {
reader = new BufferedReader(new InputStreamReader(httpConnection.getInputStream(), "UTF-8"));
reader = new BufferedReader(
new InputStreamReader(httpConnection.getInputStream(), "UTF-8"));
while ((responseMessage = reader.readLine()) != null) {
response.append(responseMessage);
response.append("\n");

View File

@ -27,7 +27,8 @@ public class NCHttpTest {
url1 = host + "updateContract";
System.out.println(httpGet(url1));
url1 = host + "executeContractOnOtherNodes&requestID=33333&contractRequest={\"contractID\":\"BDCoin\",\"action\":\"totalSupply\",\"arg\":\"n\"}";
url1 = host
+ "executeContractOnOtherNodes&requestID=33333&contractRequest={\"contractID\":\"BDCoin\",\"action\":\"totalSupply\",\"arg\":\"n\"}";
System.out.println(httpGet(url1));
// url1 = host + "startContractInTempZips";
// System.out.println(httpGet(url1));
@ -40,8 +41,8 @@ public class NCHttpTest {
System.out.println(httpGet(url1));
url1 = host + "downloadUUID";
System.out.println(httpGet(url1));
url1 = host + "updateConfig&key=projectDir&val="
+ URLEncoder.encode("/Users/huaqiancai/java_workspace/SmartContract/contractExamples");
url1 = host + "updateConfig&key=projectDir&val=" + URLEncoder
.encode("/Users/huaqiancai/java_workspace/SmartContract/contractExamples");
System.out.println(httpGet(url1));
url1 = host + "loadConfig";
System.out.println(httpGet(url1));

View File

@ -4,16 +4,19 @@ public class StringTest {
public static void main(String[] arg) {
// String str = "\\manifest.json\\dadad\\daaa";
// System.out.println(str.replaceAll("\\\\", (byte)"/"));
byte[] arr = new byte[] { (byte) 0x1, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x2, (byte) 0xff, (byte) 0xff,
(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0x89, (byte) 0x7f, (byte) 0x51, (byte) 0x8c, (byte) 0x50,
(byte) 0xbb, (byte) 0xd0, (byte) 0x7f, (byte) 0xff, (byte) 0xff, (byte) 0xe9, (byte) 0xf4, (byte) 0xf8,
(byte) 0xfc, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x4, (byte) 0xff, (byte) 0xff, (byte) 0xff,
(byte) 0xff, (byte) 0xff, (byte) 0x89, (byte) 0x7f, (byte) 0x51, (byte) 0x8c, (byte) 0x3e, (byte) 0xf4,
(byte) 0x8, (byte) 0x40, (byte) 0x9f, (byte) 0x84, (byte) 0x50, (byte) 0xbb, (byte) 0xd0, (byte) 0x7f,
(byte) 0xff, (byte) 0xff, (byte) 0xe9, (byte) 0xf4, (byte) 0xf8, (byte) 0xfc, (byte) 0xf8, (byte) 0xfc,
(byte) 0x0 };
byte[] arr = new byte[] {(byte) 0x1, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x2,
(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0x89,
(byte) 0x7f, (byte) 0x51, (byte) 0x8c, (byte) 0x50, (byte) 0xbb, (byte) 0xd0,
(byte) 0x7f, (byte) 0xff, (byte) 0xff, (byte) 0xe9, (byte) 0xf4, (byte) 0xf8,
(byte) 0xfc, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x4, (byte) 0xff,
(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0x89, (byte) 0x7f,
(byte) 0x51, (byte) 0x8c, (byte) 0x3e, (byte) 0xf4, (byte) 0x8, (byte) 0x40,
(byte) 0x9f, (byte) 0x84, (byte) 0x50, (byte) 0xbb, (byte) 0xd0, (byte) 0x7f,
(byte) 0xff, (byte) 0xff, (byte) 0xe9, (byte) 0xf4, (byte) 0xf8, (byte) 0xfc,
(byte) 0xf8, (byte) 0xfc, (byte) 0x0};
System.out.println(new String(arr));
String str = "042668227e8283cc132863cf7b83489f81056c87a19f878515d6787db7f86da7145ae05926b8e8053e59f93afdddc8705d7e17a5293b60a124a2e842d3c77cf74f";
String str =
"042668227e8283cc132863cf7b83489f81056c87a19f878515d6787db7f86da7145ae05926b8e8053e59f93afdddc8705d7e17a5293b60a124a2e842d3c77cf74f";
System.out.println(str.hashCode());
}
}