Skip to content

Deprecate --es argument in favor of --registry #129

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,8 @@ private void initOptions()

bld = Option.builder("es").hasArg().argName("url");
options.addOption(bld.build());
bld = Option.builder("registry").hasArg().argName("url");
options.addOption(bld.build());

bld = Option.builder("auth").hasArg().argName("file");
options.addOption(bld.build());
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/gov/nasa/pds/registry/mgr/cmd/CliCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,13 @@ public interface CliCommand
* @throws Exception an exception
*/
public void run(CommandLine cmdLine) throws Exception;
public static String getUsersRegistry (CommandLine cmdLine) {
if (cmdLine.hasOption("registry")) {
return cmdLine.getOptionValue("registry");
} else if (cmdLine.hasOption("es")) {
return cmdLine.getOptionValue("es");
} else {
throw new RuntimeException("Must provide -registry on the command line. See usuage for more details.");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
*/
public class DeleteDataCmd implements CliCommand
{
private String filterMessage;


/**
* Constructor
*/
Expand All @@ -38,7 +35,7 @@ public void run(CommandLine cmdLine) throws Exception
return;
}

String esUrl = cmdLine.getOptionValue("es", "app:/connections/direct/localhost.xml");
String esUrl = CliCommand.getUsersRegistry(cmdLine);
String authPath = cmdLine.getOptionValue("auth");


Expand Down Expand Up @@ -89,7 +86,6 @@ private void buildEsQuery(CommandLine cmdLine, Request.DeleteByQuery regQuery, R
String id = cmdLine.getOptionValue("lidvid");
if(id != null)
{
this.filterMessage = " LIDVID: " + id;
regQuery.createFilterQuery("lidvid", id);
refsQuery.createFilterQuery("collection_lidvid", id);
return;
Expand All @@ -98,7 +94,6 @@ private void buildEsQuery(CommandLine cmdLine, Request.DeleteByQuery regQuery, R
id = cmdLine.getOptionValue("packageId");
if(id != null)
{
this.filterMessage = " Package ID: " + id;
regQuery.createFilterQuery("_package_id", id);
refsQuery.createFilterQuery("_package_id", id);

Expand All @@ -122,7 +117,8 @@ public void printHelp()
System.out.println(" -all Delete all data");
System.out.println("Optional parameters:");
System.out.println(" -auth <file> Authentication config file");
System.out.println(" -es <url> Elasticsearch URL. Default is app:/connections/direct/localhost.xml");
System.out.println(" -es <url> (deprecated) File URI to the configuration to connect to the registry. For example, file:///home/user/.pds/mcp.xml. Default is app:/connections/direct/localhost.xml");
System.out.println(" -registry <url> File URI to the configuration to connect to the registry. For example, file:///home/user/.pds/mcp.xml. Default is app:/connections/direct/localhost.xml");
System.out.println();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void run(CommandLine cmdLine) throws Exception
throw new Exception("Missing required parameter '-file'");
}

String esUrl = cmdLine.getOptionValue("es", "app:/connections/direct/localhost.xml");
String esUrl = CliCommand.getUsersRegistry(cmdLine);
String authPath = cmdLine.getOptionValue("auth");

extractFilterParams(cmdLine);
Expand Down Expand Up @@ -135,7 +135,8 @@ public void printHelp()
System.out.println(" -all Export all data");
System.out.println("Optional parameters:");
System.out.println(" -auth <file> Authentication config file");
System.out.println(" -es <url> Elasticsearch URL. Default is app:/connections/direct/localhost.xml");
System.out.println(" -es <url> (deprecated) File URI to the configuration to connect to the registry. For example, file:///home/user/.pds/mcp.xml. Default is app:/connections/direct/localhost.xml");
System.out.println(" -registry <url> File URI to the configuration to connect to the registry. For example, file:///home/user/.pds/mcp.xml. Default is app:/connections/direct/localhost.xml");
System.out.println();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void run(CommandLine cmdLine) throws Exception
return;
}

String esUrl = cmdLine.getOptionValue("es", "app:/connections/direct/localhost.xml");
String esUrl = CliCommand.getUsersRegistry(cmdLine);
String authPath = cmdLine.getOptionValue("auth");

// Lidvid
Expand Down Expand Up @@ -103,7 +103,8 @@ public void printHelp()
System.out.println(" -file <path> Output file path");
System.out.println("Optional parameters:");
System.out.println(" -auth <file> Authentication config file");
System.out.println(" -es <url> Elasticsearch URL. Default is app:/connections/direct/localhost.xml");
System.out.println(" -es <url> (deprecated) File URI to the configuration to connect to the registry. For example, file:///home/user/.pds/mcp.xml. Default is app:/connections/direct/localhost.xml");
System.out.println(" -registry <url> File URI to the configuration to connect to the registry. For example, file:///home/user/.pds/mcp.xml. Default is app:/connections/direct/localhost.xml");
System.out.println();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void run(CommandLine cmdLine) throws Exception
return;
}

String esUrl = cmdLine.getOptionValue("es", "app:/connections/direct/localhost.xml");
String esUrl = CliCommand.getUsersRegistry(cmdLine);
String authPath = cmdLine.getOptionValue("auth");

String status = getStatus(cmdLine);
Expand Down Expand Up @@ -123,7 +123,8 @@ public void printHelp() {
" For a collection also update primary references from collection inventory.");
System.out.println("Optional parameters:");
System.out.println(" -auth <file> Authentication config file");
System.out.println(" -es <url> Elasticsearch URL. Default is http://localhost:9200");
System.out.println(" -es <url> (deprecated) File URI to the configuration to connect to the registry. For example, file:///home/user/.pds/mcp.xml. Default is app:/connections/direct/localhost.xml");
System.out.println(" -registry <url> File URI to the configuration to connect to the registry. For example, file:///home/user/.pds/mcp.xml. Default is app:/connections/direct/localhost.xml");
System.out.println();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void run(CommandLine cmdLine) throws Exception
printHelp();
return;
}
String url = cmdLine.getOptionValue("es", "app:/connections/direct/localhost.xml");
String url = CliCommand.getUsersRegistry(cmdLine);
String authFile = cmdLine.getOptionValue("auth");
String filePath = cmdLine.getOptionValue("file");
if(filePath == null) throw new Exception("Missing required parameter '-file'");
Expand Down Expand Up @@ -167,7 +167,8 @@ public void printHelp()
System.out.println(" -file <path> CSV file with the list of IDs");
System.out.println("Optional parameters:");
System.out.println(" -auth <file> Authentication config file");
System.out.println(" -es <url> Elasticsearch URL. Default is app:/connections/direct/localhost.xml");
System.out.println(" -es <url> (deprecated) File URI to the configuration to connect to the registry. For example, file:///home/user/.pds/mcp.xml. Default is app:/connections/direct/localhost.xml");
System.out.println(" -registry <url> File URI to the configuration to connect to the registry. For example, file:///home/user/.pds/mcp.xml. Default is app:/connections/direct/localhost.xml");
System.out.println();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void run(CommandLine cmdLine) throws Exception
return;
}

esUrl = cmdLine.getOptionValue("es", "app:/connections/direct/localhost.xml");
esUrl = CliCommand.getUsersRegistry(cmdLine);
authPath = cmdLine.getOptionValue("auth");
this.conFact = EstablishConnectionFactory.from(esUrl, authPath);
String id = cmdLine.getOptionValue("id");
Expand Down Expand Up @@ -112,7 +112,8 @@ public void printHelp()
System.out.println(" -ns <namespace> Delete data by namespace");
System.out.println("Optional parameters:");
System.out.println(" -auth <file> Authentication config file");
System.out.println(" -es <url> Elasticsearch URL. Default is app:/connections/direct/localhost.xml");
System.out.println(" -es <url> (deprecated) File URI to the configuration to connect to the registry. For example, file:///home/user/.pds/mcp.xml. Default is app:/connections/direct/localhost.xml");
System.out.println(" -registry <url> File URI to the configuration to connect to the registry. For example, file:///home/user/.pds/mcp.xml. Default is app:/connections/direct/localhost.xml");
System.out.println();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void run(CommandLine cmdLine) throws Exception
throw new Exception("Missing required parameter '-file'");
}

String esUrl = cmdLine.getOptionValue("es", "app:/connections/direct/localhost.xml");
String esUrl = CliCommand.getUsersRegistry(cmdLine);
String authPath = cmdLine.getOptionValue("auth");

System.out.println("Elasticsearch URL: " + esUrl);
Expand All @@ -64,7 +64,8 @@ public void printHelp()
System.out.println(" -file <path> Output file path");
System.out.println("Optional parameters:");
System.out.println(" -auth <file> Authentication config file");
System.out.println(" -es <url> Elasticsearch URL. Default is app:/connections/direct/localhost.xml");
System.out.println(" -es <url> (deprecated) File URI to the configuration to connect to the registry. For example, file:///home/user/.pds/mcp.xml. Default is app:/connections/direct/localhost.xml");
System.out.println(" -registry <url> File URI to the configuration to connect to the registry. For example, file:///home/user/.pds/mcp.xml. Default is app:/connections/direct/localhost.xml");
System.out.println();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void run(CommandLine cmdLine) throws Exception

String authFile = cmdLine.getOptionValue("auth");
String namespace = cmdLine.getOptionValue("ns");
String url = cmdLine.getOptionValue("es", "app:/connections/direct/localhost.xml");
String url = CliCommand.getUsersRegistry(cmdLine);

if (authFile == null || authFile.isBlank()) {
throw new IllegalArgumentException("missing argument: -auth must be given");
Expand Down Expand Up @@ -80,7 +80,8 @@ public void printHelp()
System.out.println();
System.out.println("Optional parameters:");
System.out.println(" -auth <file> Authentication config file");
System.out.println(" -es <url> Elasticsearch URL. Default is app:/connections/direct/localhost.xml");
System.out.println(" -es <url> (deprecated) File URI to the configuration to connect to the registry. For example, file:///home/user/.pds/mcp.xml. Default is app:/connections/direct/localhost.xml");
System.out.println(" -registry <url> File URI to the configuration to connect to the registry. For example, file:///home/user/.pds/mcp.xml. Default is app:/connections/direct/localhost.xml");
System.out.println(" -ns <namespace> LDD namespace. Can be used with -dd parameter.");
System.out.println();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ public void printHelp()
System.out.println(" -csv <path> Custom data dictionary file in CSV format");
System.out.println("Optional parameters:");
System.out.println(" -auth <file> Authentication config file");
System.out.println(" -es <url> Elasticsearch URL. Default is app:/connections/direct/localhost.xml");
System.out.println(" -es <url> (deprecated) File URI to the configuration to connect to the registry. For example, file:///home/user/.pds/mcp.xml. Default is app:/connections/direct/localhost.xml");
System.out.println(" -registry <url> File URI to the configuration to connect to the registry. For example, file:///home/user/.pds/mcp.xml. Default is app:/connections/direct/localhost.xml");
System.out.println(" -ns <namespace> LDD namespace. Can be used with -dd parameter.");
System.out.println();
}
Expand All @@ -67,7 +68,7 @@ public void run(CommandLine cmdLine) throws Exception
return;
}

this.url = cmdLine.getOptionValue("es", "app:/connections/direct/localhost.xml");
this.url = CliCommand.getUsersRegistry(cmdLine);
this.authFile = cmdLine.getOptionValue("auth");

RegistryManager.init(url, authFile);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void run(CommandLine cmdLine) throws Exception
return;
}

esUrl = cmdLine.getOptionValue("es", "app:/connections/direct/localhost.xml");
esUrl = CliCommand.getUsersRegistry(cmdLine);
authPath = cmdLine.getOptionValue("auth");

boolean replace= cmdLine.hasOption("r");
Expand Down Expand Up @@ -84,7 +84,8 @@ public void printHelp()
System.out.println("Optional parameters:");
System.out.println(" -r Recreate data dictionary index (replace old data dictionary)");
System.out.println(" -auth <file> Authentication config file");
System.out.println(" -es <url> Elasticsearch URL. Default is app:/connections/direct/localhost.xml");
System.out.println(" -es <url> (deprecated) File URI to the configuration to connect to the registry. For example, file:///home/user/.pds/mcp.xml. Default is app:/connections/direct/localhost.xml");
System.out.println(" -registry <url> File URI to the configuration to connect to the registry. For example, file:///home/user/.pds/mcp.xml. Default is app:/connections/direct/localhost.xml");
System.out.println();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void run(CommandLine cmdLine) throws Exception
return;
}

String esUrl = cmdLine.getOptionValue("es", "app://connections/direct/localhost.xml");
String esUrl = CliCommand.getUsersRegistry(cmdLine);
String authPath = cmdLine.getOptionValue("auth");
int shards = parseShards(cmdLine.getOptionValue("shards", "1"));
int replicas = parseReplicas(cmdLine.getOptionValue("replicas", "0"));
Expand Down Expand Up @@ -134,7 +134,8 @@ public void printHelp()
System.out.println();
System.out.println("Optional parameters:");
System.out.println(" -auth <file> Authentication config file");
System.out.println(" -es <url> Elasticsearch URL. Default is app:/connections/direct/localhost.xml");
System.out.println(" -es <url> (deprecated) File URI to the configuration to connect to the registry. For example, file:///home/user/.pds/mcp.xml. Default is app:/connections/direct/localhost.xml");
System.out.println(" -registry <url> File URI to the configuration to connect to the registry. For example, file:///home/user/.pds/mcp.xml. Default is app:/connections/direct/localhost.xml");
System.out.println(" -shards <number> Number of shards (partitions) for direct connection only. Default is 1");
System.out.println(" -replicas <number> Number of replicas (extra copies) for direct connection only. Default is 0");
System.out.println();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void run(CommandLine cmdLine) throws Exception
return;
}

String esUrl = cmdLine.getOptionValue("es", "app:/connections/direct/localhost.xml");
String esUrl = CliCommand.getUsersRegistry(cmdLine);
String authPath = cmdLine.getOptionValue("auth");

RestClient client = null;
Expand Down Expand Up @@ -69,7 +69,8 @@ public void printHelp()
System.out.println();
System.out.println("Optional parameters:");
System.out.println(" -auth <file> Authentication config file");
System.out.println(" -es <url> Elasticsearch URL. Default is app:/connections/direct/localhost.xml");
System.out.println(" -es <url> (deprecated) File URI to the configuration to connect to the registry. For example, file:///home/user/.pds/mcp.xml. Default is app:/connections/direct/localhost.xml");
System.out.println(" -registry <url> File URI to the configuration to connect to the registry. For example, file:///home/user/.pds/mcp.xml. Default is app:/connections/direct/localhost.xml");
}

}
Loading