gov.nasa.pds.citool.registry.client.RegistryClientSolr Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of catalog-legacy Show documentation
Show all versions of catalog-legacy Show documentation
The Legacy Catalog Tool provides functionality for ingesting PDS3 catalog files into the PDS4 infrastructure including the Registry Service.
package gov.nasa.pds.citool.registry.client;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.request.AbstractUpdateRequest;
import org.apache.solr.client.solrj.request.ContentStreamUpdateRequest;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrDocumentList;
import org.apache.solr.common.util.NamedList;
import gov.nasa.pds.citool.registry.model.FileInfo;
import gov.nasa.pds.citool.registry.model.RegistryObject;
public class RegistryClientSolr implements RegistryClient
{
private static final String PDS_COLLECTION = "pds";
private static final String FILE_COLLECTION = ".system";
private static final String BLOB_EP = "/.system/blob/";
private Logger log;
private SolrClient solrClient;
RegistryClientSolr(String solrUrl)
{
log = Logger.getLogger(this.getClass().getName());
solrClient = new HttpSolrClient.Builder(solrUrl).build();
}
public String publishObject(RegistryObject obj) throws Exception
{
return obj.getLid();
}
public boolean publishFile(FileInfo fi) throws Exception
{
// A file with this MD5 hash already exists
if(md5Exists(fi))
{
return false;
}
File file = new File(fi.path);
String blobName = fi.lid.replaceAll(":", ".");
String endPoint = BLOB_EP + blobName;
ContentStreamUpdateRequest req = new ContentStreamUpdateRequest(endPoint);
req.addFile(file, "application/octet-stream");
req.setAction(AbstractUpdateRequest.ACTION.COMMIT, true, true);
try
{
NamedList
© 2015 - 2024 Weber Informatics LLC | Privacy Policy