gov.nasa.pds.registry.common.connection.es.BulkRespImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of registry-common Show documentation
Show all versions of registry-common Show documentation
Common code used by Harvest and Registry Manager.
package gov.nasa.pds.registry.common.connection.es;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.NotImplementedException;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import com.google.gson.Gson;
import gov.nasa.pds.registry.common.Response;
class BulkRespImpl implements Response.Bulk {
final int errorCount;
final private Logger log;
final private org.elasticsearch.client.Response response;
BulkRespImpl (org.elasticsearch.client.Response response) {
this.log = LogManager.getLogger(this.getClass());
this.errorCount = this.parse(response.toString());
this.response = response;
}
@SuppressWarnings("rawtypes") // necessary evil to manipulate heterogenous structures
private int parse (String resp) {
int numErrors = 0;
try
{
// TODO: Use streaming parser. Stop parsing if there are no errors.
// Parse JSON response
Gson gson = new Gson();
Map json = (Map)gson.fromJson(resp, Object.class);
Boolean hasErrors = (Boolean)json.get("errors");
if(hasErrors)
{
@SuppressWarnings("unchecked")
List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy