Skip to content

Commit

Permalink
Handle feature type names that need URL encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
aaime committed Aug 20, 2018
1 parent ae9528d commit 8e76aa4
Showing 1 changed file with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
package org.geoserver.wfs3;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
Expand Down Expand Up @@ -110,6 +112,9 @@ private RequestWrapper(HttpServletRequest wrapped) {
if (matches) {
request = "getFeature";
String layerName = matcher.group(1);
if (layerName != null) {
layerName = urlDecode(layerName);
}
setLayerName(layerName);
this.featureId = matcher.group(2);
}
Expand All @@ -123,6 +128,9 @@ private RequestWrapper(HttpServletRequest wrapped) {
if (matches) {
request = "getFeature";
String layerName = matcher.group(1);
if (layerName != null) {
layerName = urlDecode(layerName);
}
setLayerName(layerName);
}
return matches;
Expand All @@ -135,6 +143,9 @@ private RequestWrapper(HttpServletRequest wrapped) {
if (matches) {
request = "collection";
String layerName = matcher.group(1);
if (layerName != null) {
layerName = urlDecode(layerName);
}
setLayerName(layerName);
}
return matches;
Expand Down Expand Up @@ -212,7 +223,7 @@ private void setLayerName(String layerName) {
typeName = layers.get(0).prefixedName();
} else {
throw new HttpErrorCodeException(
HttpStatus.NOT_FOUND.value(), "Could not find layer " + layerName);
HttpStatus.NOT_FOUND.value(), "Could not find feature type " + layerName);
}
}

Expand Down Expand Up @@ -281,4 +292,19 @@ public String getParameter(String name) {
}
}
}

/**
* URL decodes the given string
*
* @param name
* @return
*/
private String urlDecode(String name) {
try {
name = URLDecoder.decode(name, "UTF-8");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
return name;
}
}

0 comments on commit 8e76aa4

Please sign in to comment.