diff --git a/core/src/main/java/org/mapfish/print/http/ErrorResponseClientHttpResponse.java b/core/src/main/java/org/mapfish/print/http/ErrorResponseClientHttpResponse.java index 61e59196a4..c21874a2b3 100644 --- a/core/src/main/java/org/mapfish/print/http/ErrorResponseClientHttpResponse.java +++ b/core/src/main/java/org/mapfish/print/http/ErrorResponseClientHttpResponse.java @@ -9,8 +9,8 @@ public class ErrorResponseClientHttpResponse extends AbstractClientHttpResponse { private final Exception exception; - /** HTTP code use in response for non HTTP errors. */ - private static final int FAKE_HTTP_ERROR_CODE = 999; + /** HTTP code use in response for non HTTP errors, (Not Acceptable). */ + private static final int FAKE_HTTP_ERROR_CODE = 406; public ErrorResponseClientHttpResponse(final Exception e) { assert e != null; @@ -38,7 +38,8 @@ public int getRawStatusCode() { @Nonnull public String getStatusText() { return String.format( - "%s: %s", this.exception.getClass().getSimpleName(), this.exception.getMessage()); + "Not true HTTP code, %s: %s, see above error", + this.exception.getClass().getSimpleName(), this.exception.getMessage()); } @Override diff --git a/core/src/main/java/org/mapfish/print/map/geotools/FeaturesParser.java b/core/src/main/java/org/mapfish/print/map/geotools/FeaturesParser.java index d4e3e45891..13b8df38a9 100644 --- a/core/src/main/java/org/mapfish/print/map/geotools/FeaturesParser.java +++ b/core/src/main/java/org/mapfish/print/map/geotools/FeaturesParser.java @@ -61,7 +61,7 @@ public FeaturesParser( } @VisibleForTesting - static final CoordinateReferenceSystem parseCoordinateReferenceSystem( + static CoordinateReferenceSystem parseCoordinateReferenceSystem( final MfClientHttpRequestFactory requestFactory, final JSONObject geojson, final boolean forceLongitudeFirst) { @@ -93,7 +93,7 @@ static final CoordinateReferenceSystem parseCoordinateReferenceSystem( requestFactory.createRequest(new URI(uri), HttpMethod.GET); try (ClientHttpResponse response = request.execute()) { - if (response.getStatusCode() == HttpStatus.OK) { + if (response.getRawStatusCode() == HttpStatus.OK.value()) { final String wkt = IOUtils.toString(response.getBody(), Constants.DEFAULT_ENCODING); try { @@ -108,7 +108,8 @@ static final CoordinateReferenceSystem parseCoordinateReferenceSystem( } } } else { - LOGGER.warn("Unable to load linked CRS from geojson: \n{}", crsJson); + LOGGER.warn( + "Unsupported link type {} in linked CRS from geojson: \n{}", linkType, crsJson); } } else { code.append(getProperty(crsJson, "code")); @@ -147,7 +148,6 @@ private static String getProperty(final JSONObject crsJson, final String nameCod * @param template the template * @param features what to parse * @return the feature collection - * @throws IOException */ public final SimpleFeatureCollection autoTreat(final Template template, final String features) throws IOException { @@ -189,7 +189,6 @@ public final SimpleFeatureCollection treatStringAsURL( * * @param geoJsonString what to parse * @return the feature collection - * @throws IOException */ public final SimpleFeatureCollection treatStringAsGeoJson(final String geoJsonString) throws IOException { @@ -231,7 +230,7 @@ private SimpleFeatureType createFeatureType(@Nonnull final String geojsonData) { builder.setName("GeosjonFeatureType"); final JSONArray features = geojson.getJSONArray("features"); - if (features.length() == 0) { + if (features.isEmpty()) { // do not try to build the feature type if there are no features return null; } diff --git a/core/src/main/java/org/mapfish/print/map/image/AbstractSingleImageLayer.java b/core/src/main/java/org/mapfish/print/map/image/AbstractSingleImageLayer.java index 2082c70b15..9ce0821658 100644 --- a/core/src/main/java/org/mapfish/print/map/image/AbstractSingleImageLayer.java +++ b/core/src/main/java/org/mapfish/print/map/image/AbstractSingleImageLayer.java @@ -202,14 +202,15 @@ private boolean isResponseStatusCodeValid( final String stringBody, final String baseMetricName) throws IOException { - if (httpResponse.getStatusCode() != HttpStatus.OK) { + if (httpResponse.getRawStatusCode() != HttpStatus.OK.value()) { String message = String.format( - "Invalid status code for %s (%d!=%d).With request headers:\n%s\n" + "Invalid status code for %s (%d!=%d), status: %s. With request headers:\n%s\n" + "The response was: '%s'\nWith response headers:\n%s", request.getURI(), - httpResponse.getStatusCode().value(), + httpResponse.getRawStatusCode(), HttpStatus.OK.value(), + httpResponse.getStatusText(), String.join("\n", Utils.getPrintableHeadersList(request.getHeaders())), httpResponse.getStatusText(), String.join("\n", Utils.getPrintableHeadersList(httpResponse.getHeaders()))); diff --git a/core/src/main/java/org/mapfish/print/map/style/ParserPluginUtils.java b/core/src/main/java/org/mapfish/print/map/style/ParserPluginUtils.java index 379aba9a80..4fc4635c5e 100644 --- a/core/src/main/java/org/mapfish/print/map/style/ParserPluginUtils.java +++ b/core/src/main/java/org/mapfish/print/map/style/ParserPluginUtils.java @@ -34,7 +34,7 @@ public static Optional