From d6b5ed4692bac1c77eed873742e84d0705e6cf4a Mon Sep 17 00:00:00 2001 From: Jordan Padams <33492486+jordanpadams@users.noreply.github.com> Date: Wed, 1 Nov 2023 17:42:54 +0000 Subject: [PATCH] Improved help information Expand help information to be more descriptive for users. --- .../pds/validate/ri/CommandLineInterface.java | 47 ++++++++++++++----- .../gov/nasa/pds/validate/ri/UserInput.java | 2 +- 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/src/main/java/gov/nasa/pds/validate/ri/CommandLineInterface.java b/src/main/java/gov/nasa/pds/validate/ri/CommandLineInterface.java index cea407e4f..c342dae52 100644 --- a/src/main/java/gov/nasa/pds/validate/ri/CommandLineInterface.java +++ b/src/main/java/gov/nasa/pds/validate/ri/CommandLineInterface.java @@ -24,11 +24,14 @@ public class CommandLineInterface { public CommandLineInterface() { super(); this.opts = new Options(); - this.opts.addOption(Option.builder("A").argName("auth-file").desc( - "file with the URL and credential content to have full (all product states) read-only access to the registry API") - .hasArg(true).longOpt("auth-api").numberOfArgs(1).optionalArg(true).build()); + + // Disabling this argument for the time being since the Search API does not yet support authorized access + // this.opts.addOption(Option.builder("A").argName("auth-file").desc( + // "file with the URL and credential content to have full (all product states) read-only access to the Registry Search API") + // .hasArg(true).longOpt("auth-api").numberOfArgs(1).optionalArg(true).build()); + this.opts.addOption(Option.builder("a").argName("auth-file").desc( - "file with the URL and credential content to have full, direct read-only access to the search DB") + "file with the URL and credential content to have full, direct read-only access to the Registry OpenSearch DB") .hasArg(true).longOpt("auth-opensearch").numberOfArgs(1).optionalArg(true).build()); this.opts.addOption(Option.builder("h").desc("show this text and exit").hasArg(false) .longOpt("help").optionalArg(true).build()); @@ -41,9 +44,25 @@ public CommandLineInterface() { public void help() { new HelpFormatter().printHelp("ValidateReferenceIntegrity", - "\nChecks the search DB that all references exist. If the api-auth is provided, then it will also check that the registry API also finds all the references.\n\nAll arguments are either a lidvid, label, or manifest file.\n A lidvid must start with urn:nasa:pds:.\n A label must be a well formed PDS XML file.\n A manifest file is one item per line with an item being a lidvid or label. Each line must be terminated by a LF.\n\nMultiple arguments may be given in any order: 'urn:nasa:pds:foo::1.0 label.xml urn:nasa:pds:bar::2.0 manifest.txt'.\n\n", + "\nChecks that (1) all product references within a given product and " + + "(2) any aggregrate product references (bundles -> collections -> products) " + + "exist in the Registry OpenSearch DB or Search API. \n\n" + + "Expected positional arguments are either a lidvid, label, or manifest file.\n" + + " * A lidvid must start with urn:.\n" + + " * A label must be a well formed PDS XML file.\n" + + " * A manifest file is one item per line with an item being a lidvid or label. Each line must be terminated by a LF.\n\n" + + "Multiple arguments may be given in any order, for example:\n" + + " > validate-refs urn:nasa:pds:foo::1.0 label.xml urn:nasa:pds:bar::2.0 manifest.txt\n\n", opts, - "\nAn auth-file is either a text file of the Java property format with two variables: 'url' and 'credentials'. The 'url' property should be the complete base URL to the Registry Search endpoint or Search API, e.g. 'https://localhost:9876/base', and 'credentials' a path to a java property file with the user name, password, and other credential information as that used by harvest. Or it is an XML text file used by harvest with containing the 'auth' attribute.\n\n", + "\nAn auth-file is either a text file of the Java property format " + + "with two variables: 'url' and 'credentials'. \n" + + " * The 'url' property is the complete base URL to the Registry OpenSearch endpoint or Search API, e.g. 'https://my-registry.es.amazonaws.com/_search', and " + + " * The 'credentials' is the path to:" + + " * Harvest config file containing the necessary Registry OpenSearch authorization" + + " " + " * Java Properties file with a 'user' and 'password' specified, for example: " + + " user=janedoe" + " password=mypassword\n\n" true); } @@ -68,13 +87,19 @@ public int process(String[] args) if (cl.hasOption("verbose")) loggerConfig.setLevel(Level.INFO); ctx.updateLoggers(); - if (!cl.hasOption("a")) - throw new ParseException( - "Not yet implemented. Must provide OpenSearch Registry authorization information."); + + // Disabling this argument for the time being since the Search API does not yet support authorized access + // this.opts.addOption(Option.builder("A").argName("auth-file").desc( + // "file with the URL and credential content to have full (all product states) read-only access to the Registry Search API") + // .hasArg(true).longOpt("auth-api").numberOfArgs(1).optionalArg(true).build()); + // if (!cl.hasOption("a")) + // throw new ParseException( + // "Not yet implemented. Must provide OpenSearch Registry authorization information."); + if (cl.getArgList().size() < 1) - throw new ParseException("Must provide at least one LIDVID as a starting point."); + throw new ParseException("Must provide at least one LIDVID, Label file path, or manifest file path as a starting point."); if (!cl.hasOption("A")) - log.warn("Using OpenSearch Registry to check references."); + log.warn("Using Registry OpenSearch Database to check references."); if (cl.hasOption("t")) { try { diff --git a/src/main/java/gov/nasa/pds/validate/ri/UserInput.java b/src/main/java/gov/nasa/pds/validate/ri/UserInput.java index 8fcf2624f..fc937111a 100644 --- a/src/main/java/gov/nasa/pds/validate/ri/UserInput.java +++ b/src/main/java/gov/nasa/pds/validate/ri/UserInput.java @@ -57,7 +57,7 @@ private boolean isLabel (String cliArg) { private List process (List cliList){ List lidvids = new ArrayList(); for (String cliArg : cliList) { - if (cliArg.startsWith ("urn:nasa:pds:")) { + if (cliArg.startsWith ("urn:")) { lidvids.add (cliArg); } else if (this.isLabel (cliArg)) { lidvids.add (this.labels_lidvid);