|
17 | 17 | import jakarta.persistence.EntityManager; |
18 | 18 | import java.lang.invoke.MethodHandles; |
19 | 19 | import java.net.URI; |
| 20 | +import java.nio.charset.StandardCharsets; |
20 | 21 | import java.util.HashMap; |
21 | 22 | import java.util.List; |
22 | 23 | import java.util.Map; |
|
32 | 33 | import org.springframework.stereotype.Service; |
33 | 34 | import org.springframework.transaction.annotation.Transactional; |
34 | 35 | import org.springframework.web.util.UriComponentsBuilder; |
| 36 | +import org.springframework.web.util.UriUtils; |
35 | 37 | import org.tailormap.api.controller.GeoServiceProxyController; |
36 | 38 | import org.tailormap.api.persistence.Application; |
37 | 39 | import org.tailormap.api.persistence.Configuration; |
@@ -197,16 +199,28 @@ private List<WMSStyle> getProxiedLegendStyles( |
197 | 199 | Application application, AppTreeLayerNode appTreeLayerNode, List<WMSStyle> legendStyles) { |
198 | 200 | String legendProxyUrl = getLegendProxyUrl(application, appTreeLayerNode); |
199 | 201 | return legendStyles.stream() |
200 | | - .map(style -> |
| 202 | + .map(style -> { |
| 203 | + try { |
201 | 204 | // Create a copy of the style so we don't mutate configuration objects |
202 | | - new WMSStyle() |
| 205 | + return new WMSStyle() |
203 | 206 | .name(style.getName()) |
204 | 207 | .title(style.getTitle()) |
205 | 208 | .abstractText(style.getAbstractText()) |
206 | 209 | .legendUrl(UriComponentsBuilder.fromUriString(legendProxyUrl) |
207 | | - .queryParam("STYLE", style.getName()) |
| 210 | + .queryParam("STYLE", UriUtils.encode(style.getName(), StandardCharsets.UTF_8)) |
208 | 211 | .build(true) |
209 | | - .toUri())) |
| 212 | + .toUri()); |
| 213 | + } catch (Exception e) { |
| 214 | + logger.warn( |
| 215 | + "Failed to create proxied legend style for application {} layer {} style {}: {}", |
| 216 | + application.getId(), |
| 217 | + appTreeLayerNode.getId(), |
| 218 | + style.getName(), |
| 219 | + e.getMessage()); |
| 220 | + return null; |
| 221 | + } |
| 222 | + }) |
| 223 | + .filter(Objects::nonNull) |
210 | 224 | .toList(); |
211 | 225 | } |
212 | 226 |
|
|
0 commit comments