public String getModuleName() { return this.json.getString( "module", "unkonwn" ); }
public String getModuleName() { return this.json.getString( "module", "unkonwn" ); }
public synchronized WalletBalance getWalletInfo() throws WalletCallException, IOException, InterruptedException { WalletBalance balance = new WalletBalance(); JsonObject objResponse = this.executeCommandAndGetJsonObject("z_gettotalbalance", null); balance.transparentBalance = Double.valueOf(objResponse.getString("transparent", "-1")); balance.privateBalance = Double.valueOf(objResponse.getString("private", "-1")); balance.totalBalance = Double.valueOf(objResponse.getString("total", "-1")); objResponse = this.executeCommandAndGetJsonObject("z_gettotalbalance", "0"); balance.transparentUnconfirmedBalance = Double.valueOf(objResponse.getString("transparent", "-1")); balance.privateUnconfirmedBalance = Double.valueOf(objResponse.getString("private", "-1")); balance.totalUnconfirmedBalance = Double.valueOf(objResponse.getString("total", "-1")); return balance; }
public synchronized WalletBalance getWalletInfo() throws WalletCallException, IOException, InterruptedException { WalletBalance balance = new WalletBalance(); JsonObject objResponse = this.executeCommandAndGetJsonObject("z_gettotalbalance", null); balance.transparentBalance = Double.valueOf(objResponse.getString("transparent", "-1")); balance.privateBalance = Double.valueOf(objResponse.getString("private", "-1")); balance.totalBalance = Double.valueOf(objResponse.getString("total", "-1")); objResponse = this.executeCommandAndGetJsonObject("z_gettotalbalance", "0"); balance.transparentUnconfirmedBalance = Double.valueOf(objResponse.getString("transparent", "-1")); balance.privateUnconfirmedBalance = Double.valueOf(objResponse.getString("private", "-1")); balance.totalUnconfirmedBalance = Double.valueOf(objResponse.getString("total", "-1")); return balance; }
/** * Find the class of an object. * @param object The object. * @return The objects class. */ public static Class<?> findClazzOfJsonObject(JsonObject object, ClassLoader targetcl) { Class<?> ret = null; String clname = object.getString(CLASSNAME_MARKER, null); if(clname!=null) ret = SReflect.classForName0(clname, targetcl); return ret; }
public static String getVersion(String nodeModulePath) throws IOException { File pack = new File(nodeModulePath,"package.json"); if ( pack.exists() ) { String version = null; JsonObject pjson = Json.parse(new FileReader(pack)).asObject(); return pjson.getString("version", null); } return null; }
private static List<ErrorDetail> parseErrorDetails(JsonObject stat) { final List<ErrorDetail> errorDetailsList = new ArrayList<>(); final JsonValue errorDetails = stat.get("errorDetails"); if (errorDetails != null && !errorDetails.isNull()) { for (JsonValue errorInfo : errorDetails.asArray()) { final JsonObject errorInfoObject = errorInfo.asObject(); final String fullUri = errorInfoObject.getString("fullURI", ""); final String originalBody = errorInfoObject.getString("originalBody", ""); final String headerDiff = errorInfoObject.getString("headerDiff", ""); final String bodyDiff = errorInfoObject.getString("bodyDiff", ""); final String statusDiff = errorInfoObject.getString("statusDiff", ""); final Map<String, String> headers = parseHeaders(errorInfoObject); errorDetailsList.add(new ErrorDetail(fullUri, headers, originalBody, bodyDiff, headerDiff, statusDiff)); } } return errorDetailsList; }
public synchronized String[] getWalletPublicAddressesWithUnspentOutputs() throws WalletCallException, IOException, InterruptedException { JsonArray jsonUnspentOutputs = executeCommandAndGetJsonArray("listunspent", "0"); Set<String> addresses = new HashSet<>(); for (int i = 0; i < jsonUnspentOutputs.size(); i++) { JsonObject outp = jsonUnspentOutputs.get(i).asObject(); addresses.add(outp.getString("address", "ERROR!")); } return addresses.toArray(new String[0]); }
public synchronized String[] getWalletPublicAddressesWithUnspentOutputs() throws WalletCallException, IOException, InterruptedException { JsonArray jsonUnspentOutputs = executeCommandAndGetJsonArray("listunspent", "0"); Set<String> addresses = new HashSet<>(); for (int i = 0; i < jsonUnspentOutputs.size(); i++) { JsonObject outp = jsonUnspentOutputs.get(i).asObject(); addresses.add(outp.getString("address", "ERROR!")); } return addresses.toArray(new String[0]); }
public synchronized String[] getWalletAllPublicAddresses() throws WalletCallException, IOException, InterruptedException { JsonArray jsonReceivedOutputs = executeCommandAndGetJsonArray("listreceivedbyaddress", "0", "true"); Set<String> addresses = new HashSet<>(); for (int i = 0; i < jsonReceivedOutputs.size(); i++) { JsonObject outp = jsonReceivedOutputs.get(i).asObject(); addresses.add(outp.getString("address", "ERROR!")); } return addresses.toArray(new String[0]); }
public synchronized String[] getWalletAllPublicAddresses() throws WalletCallException, IOException, InterruptedException { JsonArray jsonReceivedOutputs = executeCommandAndGetJsonArray("listreceivedbyaddress", "0", "true"); Set<String> addresses = new HashSet<>(); for (int i = 0; i < jsonReceivedOutputs.size(); i++) { JsonObject outp = jsonReceivedOutputs.get(i).asObject(); addresses.add(outp.getString("address", "ERROR!")); } return addresses.toArray(new String[0]); }
@Override public ModelAndView doPost(IHTTPSession session) { JsonValue request = Json.parse(WebServer.getRequestBody(session)); if (!request.isObject()) { return new BadRequest("expected object"); } String username = ((JsonObject) request).getString("username", null); String password = ((JsonObject) request).getString("password", null); return doLogin(auth, username, password); }
public synchronized boolean isCompletedOperationSuccessful(String opID) throws WalletCallException, IOException, InterruptedException { JsonArray response = this.executeCommandAndGetJsonArray( "z_getoperationstatus", wrapStringParameter("[\"" + opID + "\"]")); JsonObject jsonStatus = response.get(0).asObject(); String status = jsonStatus.getString("status", "ERROR"); Log.info("Operation " + opID + " status is " + response + "."); if (status.equalsIgnoreCase("success")) { return true; } else if (status.equalsIgnoreCase("error") || status.equalsIgnoreCase("failed")) { return false; } else { throw new WalletCallException("Unexpected final operation status response from wallet: " + response.toString()); } }
public static Observation deserialize(byte[] data) { JsonObject v = (JsonObject) Json.parse(new String(data)); EndpointContext endpointContext = EndpointContextSerDes.deserialize(v.get("peer").asObject()); byte[] req = Hex.decodeHex(v.getString("request", null).toCharArray()); RawData rawData = RawData.outbound(req, endpointContext, null, false); Request request = (Request) parser.parseMessage(rawData); request.setDestinationContext(endpointContext); JsonValue ctxValue = v.get("context"); if (ctxValue != null) { Map<String, String> context = new HashMap<>(); JsonObject ctxObject = (JsonObject) ctxValue; for (String name : ctxObject.names()) { context.put(name, ctxObject.getString(name, null)); } request.setUserContext(context); } return new Observation(request, endpointContext); }
public static Observation deserialize(byte[] data) { JsonObject v = (JsonObject) Json.parse(new String(data)); EndpointContext endpointContext = EndpointContextSerDes.deserialize(v.get("peer").asObject()); byte[] req = Hex.decodeHex(v.getString("request", null).toCharArray()); RawData rawData = RawData.outbound(req, endpointContext, null, false); Request request = (Request) parser.parseMessage(rawData); request.setDestinationContext(endpointContext); JsonValue ctxValue = v.get("context"); if (ctxValue != null) { Map<String, String> context = new HashMap<>(); JsonObject ctxObject = (JsonObject) ctxValue; for (String name : ctxObject.names()) { context.put(name, ctxObject.getString(name, null)); } request.setUserContext(context); } return new Observation(request, endpointContext); }
public synchronized String getOperationFinalErrorMessage(String opID) throws WalletCallException, IOException, InterruptedException { JsonArray response = this.executeCommandAndGetJsonArray( "z_getoperationstatus", wrapStringParameter("[\"" + opID + "\"]")); JsonObject jsonStatus = response.get(0).asObject(); JsonObject jsonError = jsonStatus.get("error").asObject(); return jsonError.getString("message", "ERROR!"); }
public synchronized String getOperationFinalErrorMessage(String opID) throws WalletCallException, IOException, InterruptedException { JsonArray response = this.executeCommandAndGetJsonArray( "z_getoperationstatus", wrapStringParameter("[\"" + opID + "\"]")); JsonObject jsonStatus = response.get(0).asObject(); JsonObject jsonError = jsonStatus.get("error").asObject(); return jsonError.getString("message", "ERROR!"); }
private Packet dropTable(String jsonValue) { String dbName = JsonObject.readFrom(jsonValue).getString("dbName", ""); String tableName = JsonObject.readFrom(jsonValue).getString("tableName", ""); Warehouse warehouse = LocalStore.getWarehouse(dbName); int type = ExchangeCode.DROP_TABLE_FALURE.ordinal(); String responseInfor = "Falure"; if (warehouse.dropTable(tableName)) { type = ExchangeCode.DROP_TABLE_SUCCESS.ordinal(); responseInfor = "Success"; } Packet resPacket = new Packet(); resPacket.setMimeType(0); resPacket.setExecuteType(type); resPacket.setData(new SimpleString(responseInfor)); return resPacket; }
private Packet countTable(String jsonValue) { String dbName = JsonObject.readFrom(jsonValue).getString("dbName", ""); String tableName = JsonObject.readFrom(jsonValue).getString("tableName", ""); Warehouse warehouse = LocalStore.getWarehouse(dbName); int type = ExchangeCode.COUNT_TABLE_FALURE.ordinal(); String responseInfor = "Falure"; int count = warehouse.count(tableName); if (count > -1) { type = ExchangeCode.COUNT_TABLE_SUCCESS.ordinal(); responseInfor = count + ""; } Packet resPacket = new Packet(); resPacket.setMimeType(0); resPacket.setExecuteType(type); resPacket.setData(new SimpleString(responseInfor)); return resPacket; }
@Test public void testSaveAndLoad() { String apiKey = UUID.randomUUID().toString(); boolean syncSpectogram = true; client.saveR2CloudConfiguration(apiKey, syncSpectogram); JsonObject config = client.getR2CloudConfiguration(); assertEquals(apiKey, config.getString("apiKey", null)); assertTrue(config.getBoolean("syncSpectogram", false)); }