diff --git a/core/src/main/java/org/mapfish/print/http/MfClientHttpRequestFactoryImpl.java b/core/src/main/java/org/mapfish/print/http/MfClientHttpRequestFactoryImpl.java index 9407c35e0e..d877248c20 100644 --- a/core/src/main/java/org/mapfish/print/http/MfClientHttpRequestFactoryImpl.java +++ b/core/src/main/java/org/mapfish/print/http/MfClientHttpRequestFactoryImpl.java @@ -113,7 +113,7 @@ private static final class RandomizingDnsResolver extends SystemDefaultDnsResolv public InetAddress[] resolve(final String host) throws UnknownHostException { final List list = Arrays.asList(super.resolve(host)); Collections.shuffle(list); - return list.toArray(new InetAddress[list.size()]); + return list.toArray(new InetAddress[0]); } } diff --git a/core/src/main/java/org/mapfish/print/map/image/wms/WmsUtilities.java b/core/src/main/java/org/mapfish/print/map/image/wms/WmsUtilities.java index c15a0dce66..56c982abe2 100644 --- a/core/src/main/java/org/mapfish/print/map/image/wms/WmsUtilities.java +++ b/core/src/main/java/org/mapfish/print/map/image/wms/WmsUtilities.java @@ -4,10 +4,10 @@ import com.google.common.collect.Multimap; import java.awt.Dimension; import java.io.IOException; +import java.net.MalformedURLException; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; -import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Collection; @@ -52,21 +52,7 @@ public static URI makeWmsGetLayerRequest( final double angle, final ReferencedEnvelope bounds) throws FactoryException, URISyntaxException, IOException { - if (commonURI == null || commonURI.getAuthority() == null) { - throw new RuntimeException("Invalid WMS URI: " + commonURI); - } - String[] authority = commonURI.getAuthority().split(":"); - URL url; - if (authority.length == 2) { - url = - new URL( - commonURI.getScheme(), - authority[0], - Integer.parseInt(authority[1]), - commonURI.getPath()); - } else { - url = new URL(commonURI.getScheme(), authority[0], commonURI.getPath()); - } + URL url = getUrl(commonURI); final GetMapRequest getMapRequest = WmsVersion.lookup(wmsLayerParam.version).getGetMapRequest(url); getMapRequest.setBBox(bounds); @@ -86,7 +72,7 @@ public static URI makeWmsGetLayerRequest( Multimap extraParams = HashMultimap.create(); if (commonURI.getQuery() != null) { - for (NameValuePair pair : URLEncodedUtils.parse(commonURI, Charset.forName("UTF-8"))) { + for (NameValuePair pair : URLEncodedUtils.parse(commonURI, StandardCharsets.UTF_8)) { extraParams.put(pair.getName(), pair.getValue()); } } @@ -102,6 +88,25 @@ public static URI makeWmsGetLayerRequest( return URIUtils.addParams(getMapUri, extraParams, Collections.emptySet()); } + private static URL getUrl(URI commonURI) throws MalformedURLException { + if (commonURI == null || commonURI.getAuthority() == null) { + throw new RuntimeException("Invalid WMS URI: " + commonURI); + } + String[] authority = commonURI.getAuthority().split(":"); + URL url; + if (authority.length == 2) { + url = + new URL( + commonURI.getScheme(), + authority[0], + Integer.parseInt(authority[1]), + commonURI.getPath()); + } else { + url = new URL(commonURI.getScheme(), authority[0], commonURI.getPath()); + } + return url; + } + private static void addDpiParam( final Multimap extraParams, final int dpi, final ServerType type) { switch (type) { @@ -117,7 +122,7 @@ private static void addDpiParam( break; case GEOSERVER: if (!contains(extraParams, FORMAT_OPTIONS)) { - extraParams.put(FORMAT_OPTIONS, "dpi:" + Integer.toString(dpi)); + extraParams.put(FORMAT_OPTIONS, "dpi:" + dpi); } else if (!isDpiSet(extraParams)) { setDpiValue(extraParams, dpi); } @@ -131,12 +136,6 @@ private static void addAngleParam( final Multimap extraParams, final double angle, final ServerType type) { switch (type) { case MAPSERVER: - if (!contains(extraParams, "ANGLE")) { - extraParams.put("ANGLE", Double.toString(Math.toDegrees(angle))); - } - break; - case QGISSERVER: - break; case GEOSERVER: if (!contains(extraParams, "ANGLE")) { extraParams.put("ANGLE", Double.toString(Math.toDegrees(angle))); @@ -179,7 +178,7 @@ private static void setDpiValue(final Multimap extraParams, fina List newValues = new ArrayList<>(); for (String value : values) { if (!StringUtils.isEmpty(value)) { - value += ";dpi:" + Integer.toString(dpi); + value += ";dpi:" + dpi; newValues.add(value); } } diff --git a/core/src/main/java/org/mapfish/print/processor/map/CreateMapPagesProcessor.java b/core/src/main/java/org/mapfish/print/processor/map/CreateMapPagesProcessor.java index 0594d7fdc6..1d301a53df 100644 --- a/core/src/main/java/org/mapfish/print/processor/map/CreateMapPagesProcessor.java +++ b/core/src/main/java/org/mapfish/print/processor/map/CreateMapPagesProcessor.java @@ -199,7 +199,7 @@ public final Output execute(final Input values, final ExecutionContext context) } LOGGER.info("Paging generate {} maps definitions.", mapList.size()); DataSourceAttributeValue datasourceAttributes = new DataSourceAttributeValue(); - datasourceAttributes.attributesValues = mapList.toArray(new Map[mapList.size()]); + datasourceAttributes.attributesValues = mapList.toArray(new Map[0]); return new Output(datasourceAttributes); } diff --git a/core/src/main/java/org/mapfish/print/servlet/job/impl/RegistryJobQueue.java b/core/src/main/java/org/mapfish/print/servlet/job/impl/RegistryJobQueue.java index ae2a2d9fe4..a71008760e 100644 --- a/core/src/main/java/org/mapfish/print/servlet/job/impl/RegistryJobQueue.java +++ b/core/src/main/java/org/mapfish/print/servlet/job/impl/RegistryJobQueue.java @@ -217,7 +217,7 @@ private PrintJobStatusImpl load(final String referenceId) PrintJobStatus.Status status = PrintJobStatus.Status.valueOf(metadata.getString(JSON_STATUS)); PJsonObject requestData = new PJsonObject(metadata.getJSONObject(JSON_REQUEST_DATA), "spec"); - Long startTime = metadata.getLong(JSON_START_DATE); + long startTime = metadata.getLong(JSON_START_DATE); long requestCount = metadata.getLong(JSON_REQUEST_COUNT); JSONObject accessJSON = metadata.getJSONObject(JSON_ACCESS_ASSERTION); diff --git a/core/src/main/java/org/mapfish/print/wrapper/multi/PMultiObject.java b/core/src/main/java/org/mapfish/print/wrapper/multi/PMultiObject.java index ba50389b2c..0aefd1c909 100644 --- a/core/src/main/java/org/mapfish/print/wrapper/multi/PMultiObject.java +++ b/core/src/main/java/org/mapfish/print/wrapper/multi/PMultiObject.java @@ -135,7 +135,7 @@ public final PObject optObject(final String key) { if (results.size() == 1) { return results.get(0); } - return new PMultiObject(results.toArray(new PObject[results.size()])); + return new PMultiObject(results.toArray(new PObject[0])); } @Override