Search in sources :

Example 1 with EncoderException

use of org.apache.commons.codec.EncoderException in project OpenAttestation by OpenAttestation.

the class ApiClient method querystring.

private String querystring(MultivaluedMap<String, String> query) {
    URLCodec urlsafe = new URLCodec("UTF-8");
    String queryString = "";
    ArrayList<String> params = new ArrayList<String>();
    for (String key : query.keySet()) {
        if (query.get(key) == null) {
            params.add(key + "=");
        } else {
            for (String value : query.get(key)) {
                try {
                    // XXX assumes that the keys don't have any special characters
                    params.add(key + "=" + urlsafe.encode(value));
                } catch (EncoderException ex) {
                    log.error("Cannot encode query parameter: {}", value, ex);
                }
            }
        }
        queryString = StringUtils.join(params, "&");
    }
    return queryString;
}
Also used : URLCodec(org.apache.commons.codec.net.URLCodec) EncoderException(org.apache.commons.codec.EncoderException) ArrayList(java.util.ArrayList)

Aggregations

ArrayList (java.util.ArrayList)1 EncoderException (org.apache.commons.codec.EncoderException)1 URLCodec (org.apache.commons.codec.net.URLCodec)1