Skip to content

Commit

Permalink
remove harvest config
Browse files Browse the repository at this point in the history
User must now supply the conneciton URL and auth file.
  • Loading branch information
Al Niessner authored and Al Niessner committed Oct 9, 2024
1 parent bf9394b commit 8d5b86b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 24 deletions.
5 changes: 0 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -379,11 +379,6 @@
<artifactId>registry-common</artifactId>
<version>2.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>gov.nasa.pds</groupId>
<artifactId>harvest</artifactId>
<version>4.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
Expand Down
10 changes: 1 addition & 9 deletions src/main/java/gov/nasa/pds/validate/ri/AuthInformation.java
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
package gov.nasa.pds.validate.ri;

import java.io.File;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.lang.NotImplementedException;
import gov.nasa.pds.registry.common.ConnectionFactory;
import gov.nasa.pds.registry.common.EstablishConnectionFactory;
import gov.nasa.pds.registry.common.cfg.ConfigManager;

public class AuthInformation {
final private String apiAuthFile;
final private String harvestConfig;
final private String osAuthFile;
final private String regConn;
private transient ConnectionFactory factory = null;
private AuthInformation(String a, String A, String c, String r) {
private AuthInformation(String a, String A, String r) {
this.apiAuthFile = A;
this.harvestConfig = c;
this.osAuthFile = a;
this.regConn = r;
}
public static AuthInformation buildFrom(CommandLine cl) {
return new AuthInformation(
cl.getOptionValue("a",""),
cl.getOptionValue("A",""),
cl.getOptionValue("c",""),
cl.getOptionValue("r",""));
}
public synchronized ConnectionFactory getConnectionFactory() throws Exception {
Expand All @@ -34,9 +29,6 @@ public synchronized ConnectionFactory getConnectionFactory() throws Exception {
if (!this.osAuthFile.isBlank()) {
this.factory = EstablishConnectionFactory.from(this.regConn, this.osAuthFile);
}
if (!this.harvestConfig.isBlank()) {
this.factory = ConfigManager.exchangeRegistry(ConfigManager.read(new File(this.harvestConfig)).getRegistry());
}
if (this.factory == null) {
throw new IllegalArgumentException("did not supply necessary arguments on the CLI");
}
Expand Down
14 changes: 4 additions & 10 deletions src/main/java/gov/nasa/pds/validate/ri/CommandLineInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ public CommandLineInterface() {
this.opts.addOption(Option.builder("a").argName("auth-file").desc(
"file with the 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("c").argName("harvest-config").desc(
"file used by harvest to ingest data that contains the appropriate authorization and registry connection information")
.hasArg(true).longOpt("harvest-config").numberOfArgs(1).optionalArg(true).build());
this.opts.addOption(Option.builder("h").desc("show this text and exit").hasArg(false)
.longOpt("help").optionalArg(true).build());
this.opts.addOption(Option.builder("r").argName("registry-connection").desc(
Expand Down Expand Up @@ -65,7 +62,7 @@ public void help() {
"with two variables, 'user' and 'password' for example: \n" +
" user=janedoe\n" +
" password=mypassword\n\n" +
"Both -a and -r are required with using them and are mutually exclusive with -c.\n\n",
"Both -a and -r are required.\n\n",
true);
}

Expand All @@ -91,14 +88,11 @@ public int process(String[] args)
ctx.updateLoggers();

if (cl.hasOption("A")) {
throw new ParseException("Not yet implemented. Must provide OpenSearch Registry authorization information through -a and -r, or through -c.");
throw new ParseException("Not yet implemented. Must provide OpenSearch Registry authorization information through -a and -r.");
} else {
boolean both = cl.hasOption("a") && cl.hasOption("r");
boolean neither = !cl.hasOption("a") && !cl.hasOption("r");
if (cl.hasOption("c") && !neither) {
throw new ParseException("Cannot give -a nor -r with -c.");
} else if (!both) {
throw new ParseException("Both -a and -r must be given when either is given.");
if (!both) {
throw new ParseException("Both -a and -r must be given.");
} else {
log.warn("Using Registry OpenSearch Database to check references.");
}
Expand Down

0 comments on commit 8d5b86b

Please sign in to comment.