summaryrefslogtreecommitdiffstats
path: root/vespaclient-java
diff options
context:
space:
mode:
authorBjørn Christian Seime <bjorncs@oath.com>2018-10-15 11:11:47 +0200
committerBjørn Christian Seime <bjorncs@oath.com>2018-10-15 11:11:47 +0200
commitae2daa90050c1bd218e92b27e568a3de4e6c59a3 (patch)
tree8d1526956aa2601635dead41343053d7f743a6a4 /vespaclient-java
parentebad90033c69645616b644fc06e5e789507ecad0 (diff)
Add --xmloutput to vespa-get + vespa-visit
Diffstat (limited to 'vespaclient-java')
-rw-r--r--vespaclient-java/src/main/java/com/yahoo/vespaget/CommandLineOptions.java13
-rw-r--r--vespaclient-java/src/main/java/com/yahoo/vespavisit/VdsVisit.java15
2 files changed, 25 insertions, 3 deletions
diff --git a/vespaclient-java/src/main/java/com/yahoo/vespaget/CommandLineOptions.java b/vespaclient-java/src/main/java/com/yahoo/vespaget/CommandLineOptions.java
index 51138db8d00..76aaf283a16 100644
--- a/vespaclient-java/src/main/java/com/yahoo/vespaget/CommandLineOptions.java
+++ b/vespaclient-java/src/main/java/com/yahoo/vespaget/CommandLineOptions.java
@@ -37,6 +37,7 @@ public class CommandLineOptions {
public static final String PRIORITY_OPTION = "priority";
public static final String LOADTYPE_OPTION = "loadtype";
public static final String JSONOUTPUT_OPTION = "jsonoutput";
+ public static final String XMLOUTPUT_OPTION = "xmloutput";
private final Options options = createOptions();
private final InputStream stdIn;
@@ -136,6 +137,11 @@ public class CommandLineOptions {
.desc("JSON output")
.longOpt(JSONOUTPUT_OPTION).build());
+ options.addOption(Option.builder("x")
+ .hasArg(false)
+ .desc("XML output (default format)")
+ .longOpt(XMLOUTPUT_OPTION).build());
+
return options;
}
@@ -165,11 +171,16 @@ public class CommandLineOptions {
boolean noRetry = cl.hasOption(NORETRY_OPTION);
boolean showDocSize = cl.hasOption(SHOWDOCSIZE_OPTION);
boolean jsonOutput = cl.hasOption(JSONOUTPUT_OPTION);
+ boolean xmlOutput = cl.hasOption(XMLOUTPUT_OPTION);
int trace = getTrace(cl);
DocumentProtocol.Priority priority = getPriority(cl);
double timeout = getTimeout(cl);
Iterator<String> documentIds = getDocumentIds(cl);
+ if (jsonOutput && xmlOutput) {
+ throw new IllegalArgumentException("Cannot combine both xml and json output");
+ }
+
if (printIdsOnly && headersOnly) {
throw new IllegalArgumentException("Print ids and headers only options are mutually exclusive.");
}
@@ -216,7 +227,7 @@ public class CommandLineOptions {
.setTraceLevel(trace)
.setPriority(priority)
.setTimeout(timeout)
- .setJsonOutput(jsonOutput)
+ .setJsonOutput(!jsonOutput && !xmlOutput ? false : jsonOutput) // TODO Vespa 7 Change default to JSON
.build();
} catch (ParseException pe) {
throw new IllegalArgumentException(pe.getMessage());
diff --git a/vespaclient-java/src/main/java/com/yahoo/vespavisit/VdsVisit.java b/vespaclient-java/src/main/java/com/yahoo/vespavisit/VdsVisit.java
index 16d860a1d98..1df9a1e38cd 100644
--- a/vespaclient-java/src/main/java/com/yahoo/vespavisit/VdsVisit.java
+++ b/vespaclient-java/src/main/java/com/yahoo/vespavisit/VdsVisit.java
@@ -349,6 +349,13 @@ public class VdsVisit {
.hasArg(false)
.build());
+ options.addOption(Option.builder("x")
+ .longOpt("xmloutput")
+ .desc("Output documents as XML (default format)")
+ .hasArg(false)
+ .build());
+
+
options.addOption(Option.builder()
.longOpt("bucketspace")
.hasArg(true)
@@ -573,9 +580,13 @@ public class VdsVisit {
throttlePolicy.setMaxPendingCount(((Number)line.getParsedOptionValue("maxpendingsuperbuckets")).intValue());
params.setThrottlePolicy(throttlePolicy);
}
- if (line.hasOption("jsonoutput")) {
- allParams.setJsonOutput(true);
+
+ boolean jsonOutput = line.hasOption("jsonoutput");
+ boolean xmlOutput = line.hasOption("xmloutput");
+ if (jsonOutput && xmlOutput) {
+ throw new IllegalArgumentException("Cannot combine both xml and json output");
}
+ allParams.setJsonOutput(!jsonOutput && !xmlOutput ? false : jsonOutput); // TODO Vespa 7 Change default to JSON
allParams.setVisitorParameters(params);
return allParams;