Skip to content

Commit

Permalink
Fixed encoding problems
Browse files Browse the repository at this point in the history
  • Loading branch information
Alberto Romeu committed Dec 11, 2014
1 parent bb60013 commit d47b9b1
Show file tree
Hide file tree
Showing 8 changed files with 453 additions and 20 deletions.
Expand Up @@ -85,7 +85,7 @@ public ArrayList<JTSFeature> parse(String contentFile,
|| filter.apply(element);
}

addAttribute(element, feature, destProp);
addAttribute(service.encode(element), feature, destProp);
}

try {
Expand Down
Expand Up @@ -179,11 +179,11 @@ public void processValue(String arg0) {
if (hasToBeParsed(fType, destProp)) {
checkValidAttribute(localFilter, arg0.toString());
if (writerContentHandler != null)
writerContentHandler.addElementToFeature(arg0.toString(),
writerContentHandler.addElementToFeature(service.encode(arg0.toString()),
destProp, this.currentFeatureGeoJSON);

// System.out.println(destProp + " --- " + arg0);
contentHandler.addElementToFeature(arg0.toString(), destProp,
contentHandler.addElementToFeature(service.encode(arg0.toString()), destProp,
this.currentFeature);
return;
}
Expand Down Expand Up @@ -408,16 +408,16 @@ public void endNewElement() {

public Object fillService(JPEContentHandler handler, Object feature,
DescribeService service) {
return handler.addElementToFeature(service.getId(), JPEParser.SERVICE,
return handler.addElementToFeature(service.encode(service.getId()), JPEParser.SERVICE,
feature);
}

public Object fillCategories(JPEContentHandler handler, Object feature,
DescribeService service) {
String categories = service.getCategoriesAsString();

return handler.addElementToFeature(categories, JPEParser.CATEGORIES,
feature);
return handler.addElementToFeature(service.encode(categories),
JPEParser.CATEGORIES, feature);
}

/**
Expand Down
Expand Up @@ -133,7 +133,8 @@ public ArrayList<JTSFeature> parse(String contentFile,
hasPassedFilter = hasPassedFilter
|| filter.apply(attribute);
}
addAttribute(attribute, feature, destProp);
addAttribute(service.encode(attribute), feature,
destProp);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Expand Down
Expand Up @@ -33,6 +33,7 @@

package es.alrocar.poiproxy.configuration;

import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -71,7 +72,7 @@ public class DescribeService {

public final static String SEARCH_TYPE = "search";
public final static String BROWSE_TYPE = "browse";
private static final String DEFAULT_ENCODING = "UTF-8";
public static final String DEFAULT_ENCODING = "UTF-8";
public static final String DEFAULT_SRS = "EPSG:4326";

public static final String TIMESTAMP = "timestamp";
Expand All @@ -84,7 +85,7 @@ public class DescribeService {

@JsonIgnore
private Auth auth = new Auth();

private String format;
private String dateFormat = TIMESTAMP;
private String csvSeparator;
Expand Down Expand Up @@ -247,6 +248,15 @@ public String getRequestForParam(List<Param> optionalParam,
return url + optionalUrl;
}

public String encode(String element) {
try {
return new String(element.getBytes(this.getEncoding()),
DescribeService.DEFAULT_ENCODING);
} catch (UnsupportedEncodingException e) {
return element;
}
}

private String processRequestParams(ArrayList<String> requestParams,
ServiceParams params) {
String p;
Expand Down
Expand Up @@ -686,7 +686,7 @@ public String doRequest(String url, DescribeService service, String id)
+ id + File.separator + service.getContentFile());
}

return new String(data);
return new String(data, service.getEncoding());
}

/**
Expand Down
7 changes: 0 additions & 7 deletions generated/swagger-ui/browse.json

This file was deleted.

0 comments on commit d47b9b1

Please sign in to comment.