Skip to content

Commit

Permalink
cleaned up get and search
Browse files Browse the repository at this point in the history
Should have separated all of the get/search parts and everything that is es or os is now in registry-common.
  • Loading branch information
Al Niessner authored and Al Niessner committed Apr 16, 2024
1 parent ab2bca1 commit 4725927
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 68 deletions.
2 changes: 2 additions & 0 deletions src/main/java/gov/nasa/pds/harvest/HarvestMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ public class HarvestMain
public static void main(String[] args)
{
System.setProperty("sun.stdout.encoding", "UTF-8");
System.setProperty("javax.net.ssl.trustStore", "/home/niessner/Projects/PDS/TestData/OSV2/default.certs");
System.setProperty("javax.net.ssl.trustStorePassword", "2Painful!");
HarvestCli cli = new HarvestCli();
cli.run(args);
}
Expand Down
49 changes: 0 additions & 49 deletions src/main/java/gov/nasa/pds/harvest/dao/NonExistingIdsResponse.java

This file was deleted.

16 changes: 3 additions & 13 deletions src/main/java/gov/nasa/pds/harvest/dao/RegistryDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import gov.nasa.pds.registry.common.Request;
import gov.nasa.pds.registry.common.Response;
import gov.nasa.pds.registry.common.RestClient;
import gov.nasa.pds.registry.common.util.SearchResponseParser;


/**
Expand All @@ -23,9 +22,6 @@ public class RegistryDao
private String indexName;
private boolean pretty;

private SearchResponseParser parser;


/**
* Constructor
* @param client Elasticsearch client
Expand All @@ -48,7 +44,6 @@ public RegistryDao(RestClient client, String indexName, boolean pretty)
this.client = client;
this.indexName = indexName;
this.pretty = pretty;
parser = new SearchResponseParser();
}


Expand Down Expand Up @@ -78,16 +73,11 @@ public boolean idExists(String id) throws Exception
public Set<String> getNonExistingIds(Collection<String> ids) throws Exception
{
if(ids == null || ids.isEmpty()) return new HashSet<>();
Response resp = searchIds(ids);

NonExistingIdsResponse idsResp = new NonExistingIdsResponse(ids);
parser.parseResponse(resp, idsResp);

return idsResp.getIds();
return searchIds(ids).nonExistingIds(ids);
}


private Response searchIds(Collection<String> ids) throws Exception
private Response.Search searchIds(Collection<String> ids) throws Exception
{
if(ids == null || ids.isEmpty()) throw new InvalidPDS4ProductException("Error reading bundle/collection references. " +
"Verify the bundle/collection is valid prior to loading the data.");
Expand All @@ -96,7 +86,7 @@ private Response searchIds(Collection<String> ids) throws Exception
.buildTheseIds(ids)
.setIndex(this.indexName)
.setPretty(pretty);
Response resp = client.performRequest(req);
Response.Search resp = client.performRequest(req);

return resp;
}
Expand Down
10 changes: 4 additions & 6 deletions src/main/java/gov/nasa/pds/harvest/dao/RegistryManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,20 @@ private RegistryManager(ConnectionFactory conFact, boolean overwriteFlag) throws
this.conFact = conFact;
this.overwriteFlag = overwriteFlag;
this.counter = new Counter();

Logger log = LogManager.getLogger(this.getClass());
log.log(LogUtils.LEVEL_SUMMARY, "Connection: " + conFact);

client = conFact.createRestClient();

registryDao = new RegistryDao(client, conFact.getIndexName());
schemaDao = new SchemaDao(client, conFact.getIndexName());
ddDao = new DataDictionaryDao(client, conFact.getIndexName());

fieldNameCache = new FieldNameCache(ddDao, schemaDao);

registryWriter = new MetadataWriter(conFact, registryDao, counter);
registryWriter.setOverwriteExisting(overwriteFlag);

invWriter = new CollectionInventoryWriter(conFact);

if (!this.client.exists(this.conFact.getIndexName())) {
throw new RuntimeException("The index '" + this.conFact.getIndexName() + "' does not exist. Please create it first.");
}
}


Expand Down

0 comments on commit 4725927

Please sign in to comment.