new broker api client application
This commit is contained in:
parent
aabe1dd6c7
commit
f44042cf52
|
@ -0,0 +1,35 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<parent>
|
||||
<groupId>eu.dnetlib.dhp</groupId>
|
||||
<artifactId>cmd-line-apps</artifactId>
|
||||
<version>3.1.8-SNAPSHOT</version>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>dhp-broker-client</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>dhp-broker-client</name>
|
||||
<description>D-Net Broker - Command Line Client</description>
|
||||
|
||||
<dependencies>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<executable>true</executable>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,109 @@
|
|||
package eu.dnetlib.broker;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.CommandLineParser;
|
||||
import org.apache.commons.cli.DefaultParser;
|
||||
import org.apache.commons.cli.HelpFormatter;
|
||||
import org.apache.commons.cli.Option;
|
||||
import org.apache.commons.cli.Options;
|
||||
import org.apache.commons.cli.ParseException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class BrokerClientApp implements CommandLineRunner {
|
||||
|
||||
private static Logger log = LoggerFactory.getLogger(BrokerClientApp.class);
|
||||
|
||||
@Value("${dhp.broker.api.base-url}")
|
||||
private String defaultBrokerApiBaseUrl;
|
||||
|
||||
public static void main(final String[] args) {
|
||||
SpringApplication.run(BrokerClientApp.class, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final String... args) {
|
||||
log.info("EXECUTING : command line runner");
|
||||
|
||||
final Options options = new Options();
|
||||
|
||||
options.addOption(Option.builder("v")
|
||||
.required(false)
|
||||
.hasArg(false)
|
||||
.desc("verbose")
|
||||
.build());
|
||||
|
||||
options.addOption(Option.builder("u")
|
||||
.required(true)
|
||||
.hasArg(true)
|
||||
.longOpt("user")
|
||||
.desc("the email of the subscriber")
|
||||
.build());
|
||||
|
||||
options.addOption(Option.builder("bu")
|
||||
.required(false)
|
||||
.hasArg(true)
|
||||
.longOpt("baseurl")
|
||||
.desc("the broker public api baseUrl")
|
||||
.build());
|
||||
|
||||
options.addOption(Option.builder("o")
|
||||
.required(true)
|
||||
.hasArg(true)
|
||||
.longOpt("output")
|
||||
.desc("the output dir")
|
||||
.build());
|
||||
|
||||
try {
|
||||
|
||||
final CommandLineParser parser = new DefaultParser();
|
||||
|
||||
final CommandLine cmd = parser.parse(options, args);
|
||||
|
||||
if (cmd.hasOption("v")) {
|
||||
|
||||
}
|
||||
|
||||
final String user = cmd.getOptionValue("u");
|
||||
final String baseUrl = cmd.getOptionValue("bu", defaultBrokerApiBaseUrl);
|
||||
final String outputDir = cmd.getOptionValue("o");
|
||||
|
||||
log.info("USER: " + user);
|
||||
log.info("BASE_URL: " + baseUrl);
|
||||
log.info("OUPUT DIR: " + outputDir);
|
||||
|
||||
} catch (final ParseException e) {
|
||||
System.err.println("\nERROR: Unable to parse command-line arguments " + Arrays.toString(args) + " due to: " + e);
|
||||
printHelp(options);
|
||||
}
|
||||
}
|
||||
|
||||
private void printHelp(final Options options) {
|
||||
final HelpFormatter formatter = new HelpFormatter();
|
||||
|
||||
final String syntax = "Main";
|
||||
System.out.println("\n=====");
|
||||
System.out.println("USAGE");
|
||||
System.out.println("=====");
|
||||
final PrintWriter pw = new PrintWriter(System.out);
|
||||
formatter.printUsage(pw, 80, syntax, options);
|
||||
pw.flush();
|
||||
|
||||
final String usageHeader = "OpenAIRE Broker - Public API Client\n";
|
||||
final String usageFooter = "\nSee http://.../... for further details.";
|
||||
System.out.println("\n====");
|
||||
System.out.println("HELP");
|
||||
System.out.println("====");
|
||||
|
||||
formatter.printHelp(syntax, options);
|
||||
System.out.println();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
spring.main.banner-mode=off
|
||||
|
||||
logging.level.root=INFO
|
||||
|
||||
|
||||
dhp.broker.api.base-url + http://test.it/test
|
|
@ -0,0 +1,58 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<parent>
|
||||
<groupId>eu.dnetlib.dhp</groupId>
|
||||
<artifactId>dnet-applications</artifactId>
|
||||
<version>3.1.8-SNAPSHOT</version>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>cmd-line-apps</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<modules>
|
||||
<module>dhp-broker-client</module>
|
||||
</modules>
|
||||
|
||||
<dependencies>
|
||||
<!-- Spring Boot -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-cli</groupId>
|
||||
<artifactId>commons-cli</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<executable>true</executable>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
</project>
|
14
pom.xml
14
pom.xml
|
@ -29,6 +29,7 @@
|
|||
<modules>
|
||||
<module>libs</module>
|
||||
<module>apps</module>
|
||||
<module>cmd-line-apps</module>
|
||||
</modules>
|
||||
|
||||
<issueManagement>
|
||||
|
@ -144,6 +145,12 @@
|
|||
<version>${dnet-hadoop-version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-cli</groupId>
|
||||
<artifactId>commons-cli</artifactId>
|
||||
<version>1.4</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
|
@ -161,13 +168,6 @@
|
|||
<version>2.4</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-cli</groupId>
|
||||
<artifactId>commons-cli</artifactId>
|
||||
<version>1.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>dom4j</groupId>
|
||||
<artifactId>dom4j</artifactId>
|
||||
|
|
Loading…
Reference in New Issue