Skip to content

Commit

Permalink
Merge pull request #141 from NiordOrg/wms-replacement
Browse files Browse the repository at this point in the history
Allow WMS Layer without password
  • Loading branch information
kaspernielsen committed May 14, 2024
2 parents 2e5bb40 + 0e11944 commit 032b41e
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) t
WebUtils.cache(response, CACHE_TIMEOUT);

// Check that the WMS provider has been defined using system properties
if (StringUtils.isBlank(wmsProvider) ||
StringUtils.isBlank(wmsPassword)) {
if (StringUtils.isBlank(wmsProvider)) {
response.sendRedirect(BLANK_IMAGE);
return;
}
Expand All @@ -132,14 +131,16 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) t
.filter(p -> StringUtils.isBlank(wmsLayers) || !"layers".equalsIgnoreCase(p.getKey()))
.map(p -> String.format("%s=%s", p.getKey(), p.getValue()[0]))
.collect(Collectors.joining("&"));
params += String.format("&TOKEN=%s", wmsPassword);
if (!StringUtils.isBlank(wmsPassword)) {
params += String.format("&TOKEN=%s", wmsPassword);
}
if (StringUtils.isNotBlank(wmsLayers)) {
params += String.format("&LAYERS=%s", wmsLayers);
}

String url = wmsProvider + "?" + params;

log.trace("Loading image " + url);

try {
URL urlUrl = new URL(url);
URLConnection con = urlUrl.openConnection();
Expand Down

0 comments on commit 032b41e

Please sign in to comment.