Skip to content

Commit

Permalink
Remove dead code. Minor refactorings.
Browse files Browse the repository at this point in the history
  • Loading branch information
sebr72 committed May 21, 2024
1 parent 887f96b commit 14d2f54
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ private static final class RandomizingDnsResolver extends SystemDefaultDnsResolv
public InetAddress[] resolve(final String host) throws UnknownHostException {
final List<InetAddress> list = Arrays.asList(super.resolve(host));
Collections.shuffle(list);
return list.toArray(new InetAddress[list.size()]);
return list.toArray(new InetAddress[0]);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -86,7 +72,7 @@ public static URI makeWmsGetLayerRequest(

Multimap<String, String> 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());
}
}
Expand All @@ -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<String, String> extraParams, final int dpi, final ServerType type) {
switch (type) {
Expand All @@ -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);
}
Expand All @@ -131,12 +136,6 @@ private static void addAngleParam(
final Multimap<String, String> 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)));
Expand Down Expand Up @@ -179,7 +178,7 @@ private static void setDpiValue(final Multimap<String, String> extraParams, fina
List<String> newValues = new ArrayList<>();
for (String value : values) {
if (!StringUtils.isEmpty(value)) {
value += ";dpi:" + Integer.toString(dpi);
value += ";dpi:" + dpi;
newValues.add(value);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 14d2f54

Please sign in to comment.