Project

General

Profile

Revision c6d85210

IDc6d85210d08b374ed43095b2999ef4b08a1662db
Parent 1de8f66a
Child 1c83c1e2

Added by Patrick Plitzner over 3 years ago

ref #7362 Encode queries to URLs

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/webimport/termimport/requests/AbstractTerminologyServiceRequest.java
12 12
import java.io.IOException;
13 13
import java.io.InputStreamReader;
14 14
import java.net.HttpURLConnection;
15
import java.net.URI;
16
import java.net.URISyntaxException;
15 17
import java.net.URL;
16 18
import java.util.List;
17 19

  
......
24 26
    public String request() {
25 27

  
26 28
        try {
27
            String uriString = TerminologyServiceConstants.SERVICE_URL
29
            String queryString = "format=json&";
30
            String pathString = "/api/terminologies/"
28 31
                    + (getTerminologyId()!=null?getTerminologyId()+"/":"")
29 32
                    + (getServiceUri()!=null?getServiceUri()+"/":"");
30 33

  
31 34
            List<RequestParameter> serviceParameters = getServiceParameters();
32 35
            if(serviceParameters!=null){
33
                uriString += "?format=json&";
34 36
                StringBuilder params = new StringBuilder();
35 37
                serviceParameters.forEach(param->params.append(param.key+"="+param.value+"&"));
36
                uriString += params.toString();
38
                queryString += params.toString();
37 39
            }
38
            URL url = new URL(uriString);
40
            URI uri = new URI("https", "dev-gfbio.bgbm.org", pathString, queryString, null);
41
            URL url = uri.toURL();
39 42
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
40 43
            conn.setRequestProperty("Accept", "application/json");
41 44

  
......
54 57

  
55 58
        } catch (IOException e) {
56 59
            e.printStackTrace();
60
        } catch (URISyntaxException e) {
61
            e.printStackTrace();
57 62
        }
58 63
        return null;
59 64
    }
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/webimport/termimport/requests/TerminologyServiceConstants.java
15 15
 */
16 16
public interface TerminologyServiceConstants {
17 17

  
18
    public static final String SERVICE_URL = "https://dev-gfbio.bgbm.org/api/terminologies/";
19 18
    public static final String NARROWER_SERVICE_URL = "narrower";
20 19
    public static final String BROADER_SERVICE_URL = "broader";
21 20
    public static final String SUGGEST_SERVICE_URL = "suggest";

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)