From 17f3958ad662c7c459687589e8b43be2e0403102 Mon Sep 17 00:00:00 2001 From: catbref Date: Fri, 4 Jan 2019 16:00:37 +0000 Subject: [PATCH] Fix ApiService to use new org.qora.* package names Also add missing default for blockchain config file to Settings --- .settings/org.eclipse.core.resources.prefs | 1 - src/main/java/org/qora/api/ApiService.java | 2 +- src/main/java/org/qora/settings/Settings.java | 34 +++++++++---------- 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs index 62e13849..ed7df2b3 100644 --- a/.settings/org.eclipse.core.resources.prefs +++ b/.settings/org.eclipse.core.resources.prefs @@ -2,6 +2,5 @@ eclipse.preferences.version=1 encoding//src/main/java=UTF-8 encoding//src/main/resources=UTF-8 encoding//src/test/java=UTF-8 -encoding//target/generated-sources/package-info=UTF-8 encoding/=UTF-8 encoding/src=UTF-8 diff --git a/src/main/java/org/qora/api/ApiService.java b/src/main/java/org/qora/api/ApiService.java index 868e6e0c..ea562911 100644 --- a/src/main/java/org/qora/api/ApiService.java +++ b/src/main/java/org/qora/api/ApiService.java @@ -25,7 +25,7 @@ public class ApiService { public ApiService() { config = new ResourceConfig(); - config.packages("api.resource"); + config.packages("org.qora.api.resource"); config.register(OpenApiResource.class); config.register(ApiDefinition.class); config.register(AnnotationPostProcessor.class); diff --git a/src/main/java/org/qora/settings/Settings.java b/src/main/java/org/qora/settings/Settings.java index 022f14ff..9221a7b5 100644 --- a/src/main/java/org/qora/settings/Settings.java +++ b/src/main/java/org/qora/settings/Settings.java @@ -27,6 +27,7 @@ public class Settings { private String userpath = ""; private boolean useBitcoinTestNet = false; private boolean wipeUnconfirmedOnStart = true; + private String blockchainConfigPath = "blockchain.json"; // RPC private int rpcPort = 9085; @@ -132,27 +133,26 @@ public class Settings { // Blockchain config - if (json.containsKey("wipeUnconfirmedOnStart")) { + if (json.containsKey("wipeUnconfirmedOnStart")) this.wipeUnconfirmedOnStart = (Boolean) getTypedJson(json, "wipeUnconfirmedOnStart", Boolean.class); - } - if (json.containsKey("blockchainConfig")) { - String filename = (String) json.get("blockchainConfig"); - File file = new File(this.userpath + filename); + if (json.containsKey("blockchainConfig")) + blockchainConfigPath = (String) getTypedJson(json, "blockchainConfig", String.class); - if (!file.exists()) { - LOGGER.info("Blockchain config file not found: " + this.userpath + filename); - throw new RuntimeException("Unable to read blockchain config file"); - } + File file = new File(this.userpath + blockchainConfigPath); - try { - List lines = Files.readLines(file, Charsets.UTF_8); - JSONObject blockchainJSON = (JSONObject) JSONValue.parse(String.join("\n", lines)); - BlockChain.fromJSON(blockchainJSON); - } catch (IOException e) { - LOGGER.error("Unable to parse blockchain config file: " + this.userpath + filename); - throw new RuntimeException("Unable to parse blockchain config file", e); - } + if (!file.exists()) { + LOGGER.info("Blockchain config file not found: " + this.userpath + blockchainConfigPath); + throw new RuntimeException("Unable to read blockchain config file"); + } + + try { + List lines = Files.readLines(file, Charsets.UTF_8); + JSONObject blockchainJSON = (JSONObject) JSONValue.parse(String.join("\n", lines)); + BlockChain.fromJSON(blockchainJSON); + } catch (IOException e) { + LOGGER.error("Unable to parse blockchain config file: " + this.userpath + blockchainConfigPath); + throw new RuntimeException("Unable to parse blockchain config file", e); } }