v0.2.53..v0.2.54 changeset PullApiCommand.java
Garret Voltz edited this page Mar 31, 2020
·
1 revision
diff --git a/hoot-services/src/main/java/hoot/services/controllers/grail/PullApiCommand.java b/hoot-services/src/main/java/hoot/services/controllers/grail/PullApiCommand.java
index 663025a..bb5b259 100644
--- a/hoot-services/src/main/java/hoot/services/controllers/grail/PullApiCommand.java
+++ b/hoot-services/src/main/java/hoot/services/controllers/grail/PullApiCommand.java
@@ -35,7 +35,6 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.net.URL;
import java.security.KeyStore;
import java.time.LocalDateTime;
@@ -53,7 +52,6 @@ import org.apache.http.impl.client.HttpClients;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import hoot.services.HootProperties;
import hoot.services.command.CommandResult;
import hoot.services.command.InternalCommand;
import hoot.services.geo.BoundingBox;
@@ -119,6 +117,7 @@ class PullApiCommand implements InternalCommand {
url = PullOverpassCommand.getOverpassUrl(replaceSensitiveData(params.getPullUrl()), boundingBox.toServicesString(), "xml", params.getCustomQuery());
// if cert path and phrase are specified then we assume to use them for the request
+ // this will have a valid cert so no need to support self-signed
if (!replaceSensitiveData(PRIVATE_OVERPASS_CERT_PATH).equals(PRIVATE_OVERPASS_CERT_PATH)) {
try {
responseStream = getHttpResponseWithSSL(url);
@@ -134,15 +133,16 @@ class PullApiCommand implements InternalCommand {
File outputFile = new File(params.getOutput());
if (responseStream == null) {
- URL requestUrl = new URL(url);
- FileUtils.copyURLToFile(requestUrl,outputFile, Integer.parseInt(HootProperties.HTTP_TIMEOUT), Integer.parseInt(HootProperties.HTTP_TIMEOUT));
- } else {
- FileUtils.copyInputStreamToFile(responseStream, outputFile);
+ responseStream = GrailResource.getUrlInputStreamWithNullHostnameVerifier(url);
}
+
+ FileUtils.copyInputStreamToFile(responseStream, outputFile);
+ responseStream.close();
}
catch (IOException ex) {
- String msg = "Failure to pull data from the OSM API [" + url + "]" + ex.getMessage();
- throw new WebApplicationException(ex, Response.serverError().entity(msg).build());
+ String msg = "Failure to pull data from the OSM API [" + url + "] " + ex.getMessage();
+ logger.error(msg);
+ throw new WebApplicationException(ex, Response.serverError().entity(ex.getMessage()).build());
}
}