Skip to content
This repository has been archived by the owner on Feb 22, 2024. It is now read-only.

Commit

Permalink
problem fixed with accept header
Browse files Browse the repository at this point in the history
  • Loading branch information
gaborremenyi committed Feb 19, 2015
1 parent e95712f commit fd13f9f
Showing 1 changed file with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
import eu.fusepool.p3.vocab.FAM;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLDecoder;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
Expand Down Expand Up @@ -80,11 +82,17 @@ public DictionaryMatcherTransformer(String queryString) {
// get taxonomy URI
String taxonomy = queryParams.get("taxonomy");

if (StringUtils.isEmpty(taxonomy)) {
if (StringUtils.isBlank(taxonomy)) {
throw new TransformerException(HttpServletResponse.SC_BAD_REQUEST, "ERROR: Taxonomy URI was not provided! \nUsage: http://<transformer>/?taxonomy=<taxonomy_URI>");
}

// get case sensitivity
try {
// decode taxonomy URI
taxonomy = URLDecoder.decode(taxonomy, "UTF-8");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}

boolean caseSensitivity = queryParams.get("casesensitive") != null;

// get stemming language
Expand All @@ -105,8 +113,9 @@ public DictionaryMatcherTransformer(String queryString) {
// if it is not valid try to get it from resources
uri = Reader.class.getResource("/" + taxonomy).toURI();
}
URL url = uri.toURL();
inputStream = url.openStream();
URLConnection connection = uri.toURL().openConnection();
connection.setRequestProperty("Accept", "application/rdf+xml");
inputStream = connection.getInputStream();
} catch (URISyntaxException | NullPointerException | IOException e) {
throw new TransformerException(HttpServletResponse.SC_BAD_REQUEST, "ERROR: Taxonomy URI is invalid! (\"" + taxonomy + "\")");
}
Expand Down

0 comments on commit fd13f9f

Please sign in to comment.