Commit 229d8fbf authored by Benoit Lavenier's avatar Benoit Lavenier

[fix] Fix unit test

[enh] Add web site
parent c4f6c5e1
This diff is collapsed.
duniter4j
======
Duniter4j
=========
duniter4j is a Java Client API for [Duniter](http://duniter.org).
Duniter4j is a Java Client API for [Duniter](http://duniter.org).
## Components
......
This diff is collapsed.
......@@ -9,6 +9,7 @@
<artifactId>duniter4j-client</artifactId>
<name>Duniter4j :: Client</name>
<description>A command line tools, to communicate with a Duniter network</description>
<properties>
<jTextUtilsVersion>0.3.3</jTextUtilsVersion>
......@@ -61,12 +62,10 @@
<dependency>
<groupId>dnl.utils</groupId>
<artifactId>j-text-utils</artifactId>
<version>${jTextUtilsVersion}</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<!-- for CSV network output -->
......
......@@ -14,13 +14,13 @@
# - Lesser General Public License (LGPL) v 3.0
# - Lesser General Public License (LPGL)
# - Lesser General Public License (LPGL) v 2.1
# - Lesser General Public License (LPGL) version 3.0
# - MIT License
# - The Apache Software License, Version 2.0
#-------------------------------------------------------------------------------
# Please fill the missing licenses for dependencies :
#
#
#Tue Mar 28 09:33:08 CEST 2017
commons-primitives--commons-primitives--1.0=The Apache Software License, Version 2.0
#Tue Nov 21 18:04:39 CET 2017
dnl.utils--j-text-utils--0.3.3=GNU General Lesser Public License (LGPL) version 3.0
net.sf.opencsv--opencsv--2.3=GNU General Lesser Public License (LGPL) version 3.0
This diff is collapsed.
......@@ -10,6 +10,7 @@
<artifactId>duniter4j-core-client</artifactId>
<packaging>jar</packaging>
<name>Duniter4j :: Core Client API</name>
<description>A useful API to communicate with a Duniter network</description>
<properties>
<i18n.bundleOutputName>duniter4j-core-client-i18n</i18n.bundleOutputName>
......
# Generated by org.codehaus.mojo.license.AddThirdPartyMojo
#-------------------------------------------------------------------------------
# Already used licenses in project :
# - BSD License
# - CDDL+GPL
# - COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
# - Dual license consisting of the CDDL v1.1 and GPL v2
# - Eclipse Public License 1.0
# - General Public License (GPL) v3
# - Indiana University Extreme! Lab Software License, vesion 1.1.1
# - Lesser General Public License (LGPL) v 3.0
# - Lesser General Public License (LPGL)
# - Lesser General Public License (LPGL) v 2.1
# - MIT License
# - New BSD License
# - The Apache Software License, Version 2.0
#-------------------------------------------------------------------------------
# Please fill the missing licenses for dependencies :
#
#
#Wed Nov 16 11:35:31 CET 2016
commons-primitives--commons-primitives--1.0=The Apache Software License, Version 2.0
package org.duniter.core.client.example;
/*-
* #%L
* Duniter4j :: Core Client API
* %%
* Copyright (C) 2014 - 2017 Duniter Team
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-3.0.html>.
* #L%
*/
import org.duniter.core.client.config.Configuration;
import org.duniter.core.client.model.bma.BlockchainBlock;
import org.duniter.core.client.model.local.Peer;
import org.duniter.core.client.service.ServiceLocator;
public class Example1 {
public static void main(String[] args) {
// Init configuration
String configFilename = "duniter4j-config.properties";
Configuration config = new Configuration(configFilename, args);
Configuration.setInstance(config);
// Set a wallet id (an identifier required for cache)
ServiceLocator.instance().getDataContext().setAccountId(0);
// Initialize service locator
ServiceLocator.instance().init();
// Create a peer, from configuration
Peer aPeer = Peer.newBuilder()
.setHost(config.getNodeHost())
.setPort(config.getNodePort())
.build();
// Do something fun !
BlockchainBlock currentBlock = ServiceLocator.instance().getBlockchainRemoteService().getCurrentBlock(aPeer);
System.out.println(String.format("Hello %s world !", currentBlock.getCurrency()));
}
}
......@@ -36,7 +36,7 @@ public class Record implements LocalEntity<String> {
public static final String PROPERTY_SIGNATURE="signature";
public static final String PROPERTY_TIME="time";
private String version;
private Integer version;
private String id;
private String issuer;
private String hash;
......@@ -55,11 +55,11 @@ public class Record implements LocalEntity<String> {
this.time = another.getTime();
}
public String getVersion() {
public Integer getVersion() {
return version;
}
public void setVersion(String version) {
public void setVersion(Integer version) {
this.version = version;
}
......
package org.duniter.core.client.model.exception;
/*-
* #%L
* Duniter4j :: Core Client API
* %%
* Copyright (C) 2014 - 2017 EIS
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-3.0.html>.
* #L%
*/
import org.duniter.core.exception.TechnicalException;
/**
......
package org.duniter.core.client.model.local;
/*-
* #%L
* Duniter4j :: Core Client API
* %%
* Copyright (C) 2014 - 2017 EIS
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-3.0.html>.
* #L%
*/
import org.duniter.core.client.model.bma.EndpointApi;
/**
......
......@@ -6,29 +6,29 @@ duniter4j.client.core.invalidResponseContentType=[%s] Type de réponse invalide\
duniter4j.client.core.timeout=Délai d'attente de la requête dépassé
duniter4j.client.notFound=Ressource non trouvée [%s]
duniter4j.client.status=Echec de requete HTTP [%s] \: %s
duniter4j.config=
duniter4j.config.option.basedir.description=
duniter4j.config.option.cache.directory.description=
duniter4j.config.option.data.directory.description=
duniter4j.config.option.i18n.directory.description=
duniter4j.config.option.i18n.locale.description=
duniter4j.config.option.inceptionYear.description=
duniter4j.config.option.network.loadPeers.maxDuration.description=
duniter4j.config=Options de configuration Duniter4j \:\: client
duniter4j.config.option.basedir.description=Répertoire de travail de l'application
duniter4j.config.option.cache.directory.description=Répertoire pour le cache applicatif
duniter4j.config.option.data.directory.description=Répertoire de stockage des données
duniter4j.config.option.i18n.directory.description=Répertoire de stockage des traductions
duniter4j.config.option.i18n.locale.description=Locale (langue) à utiliser
duniter4j.config.option.inceptionYear.description=Anée de réalisation
duniter4j.config.option.network.loadPeers.maxDuration.description=Délai maximum de chargement des pairs
duniter4j.config.option.network.maxConnections.description=
duniter4j.config.option.network.maxConnectionsPerHost.description=
duniter4j.config.option.network.timeout.description=
duniter4j.config.option.node.currency.description=
duniter4j.config.option.node.elasticsearch.host.description=
duniter4j.config.option.node.elasticsearch.port.description=
duniter4j.config.option.node.elasticsearch.protocol.description=
duniter4j.config.option.node.elasticsearch.url.description=
duniter4j.config.option.node.host.description=
duniter4j.config.option.node.port.description=
duniter4j.config.option.node.protocol.description=
duniter4j.config.option.organizationName.description=
duniter4j.config.option.passwd.description=
duniter4j.config.option.salt.description=
duniter4j.config.option.site.url.description=
duniter4j.config.option.tmp.directory.description=
duniter4j.config.option.version.description=
duniter4j.config.parse.error=
duniter4j.config.option.network.timeout.description=Délai d'attente maximal pour joindre un pair
duniter4j.config.option.node.currency.description=Symbole de la monnaie
duniter4j.config.option.node.elasticsearch.host.description=Hôte du noeud ES
duniter4j.config.option.node.elasticsearch.port.description=Port du noeud ES
duniter4j.config.option.node.elasticsearch.protocol.description=Protocole du noeud ES
duniter4j.config.option.node.elasticsearch.url.description=URL du noeud ES
duniter4j.config.option.node.host.description=Hôte du noeud Duniter
duniter4j.config.option.node.port.description=Port du noeud Duniter
duniter4j.config.option.node.protocol.description=Protocole du noeud Duniter
duniter4j.config.option.organizationName.description=Organisme développant le projet
duniter4j.config.option.passwd.description=Mot de passe du trousseau
duniter4j.config.option.salt.description=Sel (salt) du trousseau
duniter4j.config.option.site.url.description=URL du site du projet
duniter4j.config.option.tmp.directory.description=Répertoire temporaire
duniter4j.config.option.version.description=version de l'application
duniter4j.config.parse.error=Erreur lors de la lecture du fichier de configuration
......@@ -12,7 +12,7 @@ log4j.logger.org.duniter=DEBUG
log4j.logger.org.duniter.core.client.service.bma.AbstractNetworkService=WARN
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.file=ucoin-client.log
log4j.appender.file.file=duniter4j-core-client.log
log4j.appender.file.MaxFileSize=10MB
log4j.appender.file.MaxBackupIndex=4
......
package org.duniter.core.client.model;
/*-
* #%L
* Duniter4j :: Core Client API
* %%
* Copyright (C) 2014 - 2017 EIS
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-3.0.html>.
* #L%
*/
import com.fasterxml.jackson.databind.ObjectMapper;
import org.duniter.core.client.model.bma.BlockchainBlock;
import org.duniter.core.client.model.bma.jackson.JacksonUtils;
......
package org.duniter.core.client.model;
/*-
* #%L
* Duniter4j :: Core Client API
* %%
* Copyright (C) 2014 - 2017 EIS
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-3.0.html>.
* #L%
*/
import org.duniter.core.client.model.bma.BlockchainBlock;
import org.duniter.core.client.model.exception.InvalidFormatException;
import org.duniter.core.client.model.local.Movement;
......
duniter4j.node.host=g1-test.cgeek.fr
duniter4j.node.port=80
duniter4j.node.host=g1-test.duniter.org
duniter4j.node.port=10900
duniter4j.node.elasticsearch.host=localhost
duniter4j.node.elasticsearch.port=9200
......@@ -9,7 +9,7 @@ log4j.appender.stdout.layout.ConversionPattern=%d{ISO8601} %5p (%c:%L) - %m%n
# File output
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.file=ucoin-client.log
log4j.appender.file.file=duniter4j-core-client.log
log4j.appender.file.MaxFileSize=10MB
log4j.appender.file.MaxBackupIndex=4
......@@ -18,8 +18,8 @@ log4j.appender.file.layout.ConversionPattern=%d{ISO8601} %5p %c - %m%n
# duniter4j levels
log4j.logger.org.duniter=INFO
log4j.logger.org.duniter.core.client.service=DEBUG
log4j.logger.org.duniter.core.client.service.bma=DEBUG
#log4j.logger.org.duniter.core.client.service=DEBUG
#log4j.logger.org.duniter.core.client.service.bma=DEBUG
log4j.logger.org.duniter.core.beans=WARN
log4j.logger.org.duniter.core.client.service=TRACE
......
This diff is collapsed.
......@@ -10,6 +10,7 @@
<artifactId>duniter4j-core-shared</artifactId>
<packaging>jar</packaging>
<name>Duniter4j :: Core Shared</name>
<description>Common library used by all Duniter4j modules</description>
<properties>
<i18n.bundleOutputName>duniter4j-core-i18n</i18n.bundleOutputName>
......
# Generated by org.codehaus.mojo.license.AddThirdPartyMojo
#-------------------------------------------------------------------------------
# Already used licenses in project :
# - BSD License
# - COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
# - Dual license consisting of the CDDL v1.1 and GPL v2
# - Eclipse Public License 1.0
# - Indiana University Extreme! Lab Software License, vesion 1.1.1
# - Lesser General Public License (LGPL) v 3.0
# - Lesser General Public License (LPGL)
# - Lesser General Public License (LPGL) v 2.1
# - MIT License
# - New BSD License
# - The Apache Software License, Version 2.0
#-------------------------------------------------------------------------------
# Please fill the missing licenses for dependencies :
#
#
#Wed Nov 16 11:35:28 CET 2016
commons-primitives--commons-primitives--1.0=The Apache Software License, Version 2.0
package org.duniter.core.util;
/*-
* #%L
* Duniter4j :: Core Shared
* %%
* Copyright (C) 2014 - 2017 EIS
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-3.0.html>.
* #L%
*/
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
......
package org.duniter.core.util;
/*-
* #%L
* Duniter4j :: Core Shared
* %%
* Copyright (C) 2014 - 2017 EIS
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-3.0.html>.
* #L%
*/
import com.google.common.collect.MapMaker;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......
package org.duniter.core.util;
/*-
* #%L
* Duniter4j :: Core Shared
* %%
* Copyright (C) 2014 - 2017 EIS
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-3.0.html>.
* #L%
*/
import java.util.Iterator;
import java.util.PrimitiveIterator;
......
......@@ -45,9 +45,9 @@ public class JsonAttributeParser<T extends Object> {
STRING
}
public static final String REGEX_ATTRIBUTE_STRING_VALUE = "\\\"%s\\\"\\s*:\\s*\"([^\"]+)\\\"";
public static final String REGEX_ATTRIBUTE_NUMERIC_VALUE = "\\\"%s\\\"\\s*:\\s*([\\d]+(?:[.][\\d]+)?)";
public static final String REGEX_ATTRIBUTE_BOOLEAN_VALUE = "\\\"%s\\\"\\s*:\\s*(true|false)";
public static final String REGEX_ATTRIBUTE_STRING_VALUE = "\\\"%s\\\"\\s*:\\s*(?:\"([^\"]+)\\\"|null)";
public static final String REGEX_ATTRIBUTE_NUMERIC_VALUE = "\\\"%s\\\"\\s*:\\s*(?:([\\d]+(?:[.][\\d]+)?)|null)";
public static final String REGEX_ATTRIBUTE_BOOLEAN_VALUE = "\\\"%s\\\"\\s*:\\s*(?:(true|false)|null)";
public static JsonAttributeParser<String> newStringParser(final String attributeName){
return new JsonAttributeParser<>(attributeName, String.class);
......@@ -141,11 +141,13 @@ public class JsonAttributeParser<T extends Object> {
int end = matcher.end();
char before = jsonString.charAt(start-1);
boolean hasCommaBefore = before == ',';
while (before == ',' || before == ' ' || before == '\t' || before == '\n') {
before = jsonString.charAt(--start-1);
hasCommaBefore = hasCommaBefore || (before == ',');
}
char after = jsonString.charAt(end);
while (after == ',' || after == ' ' || after == '\t' || after == '\n') {
while ((!hasCommaBefore && after == ',') || after == ' ' || after == '\t' || after == '\n') {
after = jsonString.charAt(++end);
}
......
This diff is collapsed.
......@@ -8,8 +8,9 @@
</parent>
<artifactId>duniter4j-es-assembly</artifactId>
<name>Duniter4j :: ElasticSearch Assembly</name>
<packaging>pom</packaging>
<name>Duniter4j :: ElasticSearch Assembly</name>
<description>Build a ElasticSearch releases with all Duniter4j plugins</description>
<properties>
<!-- bundle configuration -->
......
This diff is collapsed.
......@@ -10,6 +10,7 @@
<artifactId>duniter4j-es-core</artifactId>
<packaging>jar</packaging>
<name>Duniter4j :: ElasticSearch Core plugin</name>
<description>A ElasticSearch plugin that can index data from a Duniter currency</description>
<properties>
<!-- i18n configuration -->
......
# Generated by org.codehaus.mojo.license.AddThirdPartyMojo
#-------------------------------------------------------------------------------
# Already used licenses in project :
# - ASL, version 2
# - Apache License 2.0
# - Apache License Version 2.0
# - BSD License
# - CC0 1.0 Universal
# - COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
# - Eclipse Public License 1.0
# - General Public License (GPL) v3
# - Indiana University Extreme! Lab Software License, vesion 1.1.1
# - LGPL, version 2.1
# - Lesser General Public License (LGPL) v 3.0
# - Lesser General Public License (LPGL)
# - Lesser General Public License (LPGL) v 2.1
# - MIT License
# - New BSD License
# - Public Domain, per Creative Commons CC0
# - The Apache Software License, Version 2.0
#-------------------------------------------------------------------------------
# Please fill the missing licenses for dependencies :
#
#
#Tue Jan 05 15:24:57 CET 2016
commons-primitives--commons-primitives--1.0=The Apache Software License, Version 2.0
......@@ -5,5 +5,5 @@ site=false
jvm=true
classname=org.duniter.elasticsearch.Plugin
java.version=1.8
elasticsearch.version=2.4.5
elasticsearch.version=2.4.6
isolated=false
package org.duniter.elasticsearch.dao;
/*-
* #%L
* Duniter4j :: ElasticSearch Core plugin
* %%
* Copyright (C) 2014 - 2017 EIS
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-3.0.html>.
* #L%
*/
import org.duniter.elasticsearch.model.DocStat;
import org.elasticsearch.action.index.IndexRequestBuilder;
......
package org.duniter.elasticsearch.model;
/*-
* #%L
* Duniter4j :: ElasticSearch Core plugin
* %%
* Copyright (C) 2014 - 2017 EIS
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-3.0.html>.
* #L%
*/
import org.duniter.core.client.model.elasticsearch.Record;
public class SynchroExecution extends Record {
......
package org.duniter.elasticsearch.synchro;
/*-
* #%L
* Duniter4j :: ElasticSearch Core plugin
* %%
* Copyright (C) 2014 - 2017 EIS
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-3.0.html>.
* #L%
*/
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.Lists;
......