Commit 37917551 authored by Benoit Lavenier's avatar Benoit Lavenier

[fix] Allow to redefine software return by GET /network/peering (need by gchange-pod)

parent dd167aa0
......@@ -101,13 +101,13 @@ http.cors.enabled: true
#
# action.destructive_requires_name: true
#
# Security to isolate plugin classpath - /!\ WARNING: should be DISABLE for Duniter4j
# Security to isolate plugin classpath - /!\ WARNING: should be DISABLE for Cesium+ Pod
#
security.manager.enabled: false
#
# ---------------------------------- Duniter4j ---------------------------------
# ---------------------------------- Cesium+ Pod ---------------------------------
#
# Enable duniter4j plugin (default: true)
# Enable Cesium+ pod plugins (default: true)
#
# duniter.enable: false
#
......@@ -141,7 +141,11 @@ duniter.port: 10901
#
# duniter.stats.enable: false
#
# ---------------------------------- Duniter4j security module -------------------
# Software name (used when calling GET request on /node/summary) (default: 'cesium-plus-pod')
#
# duniter.software.name: cesium-plus-pod
#
# ---------------------------------- Cesium+ Pod > security module -------------------
#
# Keyring, use to sign emitted documents (user events, subscription, etc.).
# If not set, random keys will be generated.
......@@ -149,11 +153,11 @@ duniter.port: 10901
# duniter.keyring.salt:
# duniter.keyring.password:
#
# Enable security - will restrict HTTP access to only Duniter4j known indices - /!\ WARNING: should be enable for production use
# Enable security - will restrict HTTP access to only Cesium+ known indices - /!\ WARNING: should be enable for production use
#
duniter.security.enable: true
#
# ---------------------------------- Duniter4j P2P module -------------------------
# ---------------------------------- Cesium+ Pod > P2P module -------------------------
#
# Enable P2P synchronize between ES peers ? (default: true)
#
......@@ -210,7 +214,7 @@ duniter.p2p.includes.endpoints: [
#
# duniter.p2p.peering.interval: 7200
#
# ---------------------------------- Duniter4j document moderation ---------------
# ---------------------------------- Cesium+ Pod > document moderation ---------------
#
# Filter too old document, if time older that 'maxPastDelta' (in seconds). (default: 7200 =2h)
#
......@@ -224,7 +228,7 @@ duniter.p2p.includes.endpoints: [
#
# duniter.document.allowAdminDeletion: true
#
# ---------------------------------- Duniter4j Mail module -----------------------
# ---------------------------------- Cesium+ Pod > Mail module -----------------------
#
# Enable mail module ?
#
......@@ -257,18 +261,23 @@ duniter.mail.enable: false
#
# duniter.mail.subject.prefix: '[Cesium+]'
# ---------------------------------- Duniter4j Websocket server ----------------------
# ---------------------------------- Cesium+ Pod > Websocket server ----------------------
#
# Websocket port (default: 9400-9410)
#
duniter.ws.port: 9400-9410
#
# ---------------------------------- Duniter4j Subscription module -------------------
# ---------------------------------- Cesium+ Pod > Subscription module -------------------
#
# Enable subscription module (Need to enable mail features)
#
duniter.subscription.enable: false
#
# Options to debug this features (DEV only)
#
# duniter.subscription.email.atStartup: false
# duniter.subscription.email.debug: false
#
# Email subscription: Day of the week to trigger weekly (default: 2 = monday)
#
# duniter.subscription.email.dayOfWeek: 2
......@@ -281,7 +290,7 @@ duniter.subscription.enable: false
#
# duniter.subscription.email.link.url: 'https://domain.com/cesium'
#
# ---------------------------------- Duniter4j Share module -------------------
# ---------------------------------- Cesium+ Pod > Share module -------------------
#
#
# Share title: `og:site_name` (default: 'Cesium')
......
......@@ -104,13 +104,13 @@ http.cors.enabled: true
#
# action.destructive_requires_name: true
#
# Security to isolate plugin classpath - /!\ WARNING: should be DISABLE for Duniter4j
# Security to isolate plugin classpath - /!\ WARNING: should be DISABLE for Cesium+ Pod
#
security.manager.enabled: false
#
# ---------------------------------- Duniter4j ---------------------------------
# ---------------------------------- Cesium+ Pod ---------------------------------
#
# Enable duniter4j plugin (default: true)
# Enable Cesium+ pod plugins (default: true)
#
# duniter.enable: false
#
......@@ -144,7 +144,11 @@ duniter.useSsl: true
#
# duniter.stats.enable: false
#
# ---------------------------------- Duniter4j security module -------------------
# Software name (used when calling GET request on /node/summary) (default: 'cesium-plus-pod')
#
# duniter.software.name: cesium-plus-pod
#
# ---------------------------------- Cesium+ Pod > security module -------------------
#
# Keyring, use to sign emitted documents (user events, subscription, etc.).
# If not set, random keys will be generated.
......@@ -152,11 +156,11 @@ duniter.useSsl: true
duniter.keyring.salt: 'abc'
duniter.keyring.password: 'def'
#
# Enable security - will restrict HTTP access to only Duniter4j known indices - /!\ WARNING: should be enable for production use
# Enable security - will restrict HTTP access to only Cesium+ known indices - /!\ WARNING: should be enable for production use
#
duniter.security.enable: true
#
# ---------------------------------- Duniter4j P2P module -------------------------
# ---------------------------------- Cesium+ Pod > P2P module -------------------------
#
# Enable P2P synchronize between ES peers ? (default: true)
#
......@@ -213,7 +217,7 @@ duniter.p2p.includes.endpoints: [
#
#duniter.p2p.peering.interval: 60
#
# ---------------------------------- Duniter4j document moderation ---------------
# ---------------------------------- Cesium+ Pod > document moderation ---------------
#
# Filter too old document, if time older that 'maxPastDelta' (in seconds). (default: 7200 =2h)
#
......@@ -227,7 +231,7 @@ duniter.p2p.includes.endpoints: [
#
# duniter.document.allowAdminDeletion: true
#
# ---------------------------------- Duniter4j Mail module -----------------------
# ---------------------------------- Cesium+ Pod > Mail module -----------------------
#
# Enable mail module ?
#
......@@ -260,19 +264,19 @@ duniter.mail.enable: false
#
# duniter.mail.subject.prefix: '[Cesium+]'
# ---------------------------------- Duniter4j Websocket server ----------------------
# ---------------------------------- Cesium+ Pod > Websocket server ----------------------
#
# Websocket port (default: 9400-9410)
#
duniter.ws.port: 9400-9410
#
# ---------------------------------- Duniter4j Subscription module -------------------
# ---------------------------------- Cesium+ Pod > Subscription module -------------------
#
# Enable subscription module (Need to enable mail features)
#
# duniter.subscription.enable: false
#
# Opions to DEBUG this features
# Options to debug this features (DEV only)
#
# duniter.subscription.email.atStartup: false
# duniter.subscription.email.debug: false
......@@ -289,7 +293,7 @@ duniter.ws.port: 9400-9410
#
# duniter.subscription.email.link.url: 'https://domain.com/cesium'
#
# ---------------------------------- Duniter4j Share module -------------------
# ---------------------------------- Cesium+ Pod > Share module -------------------
#
#
# Share title: `og:site_name` (default: 'Cesium')
......
......@@ -27,7 +27,7 @@
<dependency>
<groupId>org.duniter</groupId>
<artifactId>duniter4j-core-client</artifactId>
<version>1.1.0</version>
<version>${duniter4j.version}</version>
<exclusions>
<exclusion>
<groupId>com.google.guava</groupId>
......
app.name=duniter4j
duniter4j.config.path=sqqs
duniter4j.version=${project.version}
duniter4j.site.url=${project.url}
duniter4j.inceptionYear=${project.inceptionYear}
......
......@@ -49,6 +49,7 @@ import org.nuiton.i18n.I18n;
import java.io.File;
import java.io.IOException;
import java.util.*;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.stream.Collectors;
import static org.nuiton.i18n.I18n.t;
......@@ -63,9 +64,10 @@ public class PluginSettings extends AbstractLifecycleComponent<PluginSettings> {
private static KeyPair nodeKeyPair;
private static boolean isRandomNodeKeyPair;
private static String nodePubkey;
private static List<String> i18nBundleNames = new CopyOnWriteArrayList<>(); // Default
private static boolean isI18nStarted = false;
protected final Settings settings;
private List<String> i18nBundleNames = new ArrayList<>(); // Default
private String clusterRemoteUrl;
private final CryptoService cryptoService;
......@@ -104,8 +106,9 @@ public class PluginSettings extends AbstractLifecycleComponent<PluginSettings> {
ApplicationConfigHelper.loadAllDefaultOption(applicationConfig,
providers);
// Ovverides defaults
// Overrides defaults Duniter4j options
String baseDir = settings.get("path.home");
applicationConfig.setConfigFileName("duniter4j.config");
applicationConfig.setDefaultOption(ConfigurationOption.BASEDIR.getKey(), baseDir);
applicationConfig.setDefaultOption(ConfigurationOption.NODE_HOST.getKey(), getNodeBmaHost());
applicationConfig.setDefaultOption(ConfigurationOption.NODE_PORT.getKey(), String.valueOf(getNodeBmaPort()));
......@@ -164,6 +167,12 @@ public class PluginSettings extends AbstractLifecycleComponent<PluginSettings> {
return settings;
}
/* -- settings on App -- */
public String getSoftwareName() {
return settings.get("duniter.software.name", "cesium-plus-pod");
}
/* -- settings on cluster -- */
public String getClusterName() {
......@@ -447,8 +456,25 @@ public class PluginSettings extends AbstractLifecycleComponent<PluginSettings> {
i18nLocale, i18nDirectory));
}
if (logger.isDebugEnabled()) {
logger.debug(String.format("Using I18n Bundles: %s",getI18nBundleNames()));
}
I18n.init(new I18nInitializer(i18nDirectory, getI18nBundleNames()),
i18nLocale);
isI18nStarted = true;
}
protected void reloadI18n() {
try {
I18n.close();
initI18n();
}
catch(IOException e) {
logger.error("Could not reload I18n");
}
}
protected String getI18nBundleName() {
......@@ -462,6 +488,11 @@ public class PluginSettings extends AbstractLifecycleComponent<PluginSettings> {
public void addI18nBundleName(String i18nBundleName) {
if (!this.i18nBundleNames.contains(i18nBundleName)) {
this.i18nBundleNames.add(i18nBundleName);
if (isI18nStarted) {
reloadI18n();
}
}
}
......
......@@ -24,11 +24,9 @@ package org.duniter.elasticsearch.rest.node;
import org.duniter.core.client.config.Configuration;
import org.duniter.core.exception.TechnicalException;
import org.duniter.elasticsearch.rest.AbstractRestPostIndexAction;
import org.duniter.elasticsearch.PluginSettings;
import org.duniter.elasticsearch.rest.XContentRestResponse;
import org.duniter.elasticsearch.rest.XContentThrowableRestResponse;
import org.duniter.elasticsearch.rest.security.RestSecurityController;
import org.duniter.elasticsearch.service.CurrencyService;
import org.elasticsearch.client.Client;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
......@@ -44,9 +42,16 @@ import java.io.IOException;
*/
public class RestNodeSummaryGetAction extends BaseRestHandler {
private final String software;
private final String version;
@Inject
public RestNodeSummaryGetAction(Settings settings, RestController controller, Client client, RestSecurityController securityController) {
public RestNodeSummaryGetAction(PluginSettings pluginSettings, Settings settings, RestController controller, Client client, RestSecurityController securityController) {
super(settings, controller, client);
this.software = pluginSettings.getSoftwareName();
this.version = Configuration.instance().getVersion().toString();
securityController.allow(RestRequest.Method.GET, "/node/summary");
controller.registerHandler(RestRequest.Method.GET, "/node/summary", this);
}
......@@ -64,10 +69,10 @@ public class RestNodeSummaryGetAction extends BaseRestHandler {
.startObject("duniter")
// software
.field("software", "duniter4j-elasticsearch")
.field("software", software)
// version
.field("version", Configuration.instance().getVersion().toString())
.field("version", version)
// status
.field("status", RestStatus.OK.getStatus())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment