Example usage for org.apache.commons.httpclient.util URIUtil encodeQuery

List of usage examples for org.apache.commons.httpclient.util URIUtil encodeQuery

Introduction

In this page you can find the example usage for org.apache.commons.httpclient.util URIUtil encodeQuery.

Prototype

public static String encodeQuery(String unescaped) throws URIException 

Source Link

Document

Escape and encode a string regarded as the query component of an URI with the default protocol charset.

Usage

From source file:org.openhab.binding.ecobee.internal.messages.RefreshTokenRequest.java

private String buildQueryString() {
    final StringBuilder urlBuilder = new StringBuilder(RESOURCE_URL);

    try {//from  w  w  w . j av  a2 s.  c  o m
        urlBuilder.append("?grant_type=refresh_token");
        urlBuilder.append("&code=");
        urlBuilder.append(refreshToken);
        urlBuilder.append("&client_id=");
        urlBuilder.append(appKey);
        return URIUtil.encodeQuery(urlBuilder.toString());
    } catch (final Exception e) {
        throw new EcobeeException(e);
    }
}

From source file:org.openhab.binding.ecobee.internal.messages.ThermostatRequest.java

private String buildQueryString() {
    final StringBuilder urlBuilder = new StringBuilder(RESOURCE_URL);

    try {/*from  w ww  . j ava 2  s  .c  om*/
        urlBuilder.append("?json=");
        urlBuilder.append(JSON.writeValueAsString(this));
        return URIUtil.encodeQuery(urlBuilder.toString());
    } catch (final Exception e) {
        throw new EcobeeException(e);
    }
}

From source file:org.openhab.binding.ecobee.internal.messages.TokenRequest.java

private String buildQueryString() {
    final StringBuilder urlBuilder = new StringBuilder(RESOURCE_URL);

    try {//from w  w w  .j  a  va2  s .  c om
        urlBuilder.append("?grant_type=ecobeePin");
        urlBuilder.append("&code=");
        urlBuilder.append(authToken);
        urlBuilder.append("&client_id=");
        urlBuilder.append(appKey);
        return URIUtil.encodeQuery(urlBuilder.toString());
    } catch (final Exception e) {
        throw new EcobeeException(e);
    }
}

From source file:org.openhab.binding.ecobee.internal.messages.UpdateThermostatRequest.java

private String buildQueryString() {
    final StringBuilder urlBuilder = new StringBuilder(RESOURCE_URL);

    try {// ww w. j  a v a  2  s  .com
        urlBuilder.append("?json=true&token=");
        urlBuilder.append(this.accessToken);
        return URIUtil.encodeQuery(urlBuilder.toString());
    } catch (final Exception e) {
        throw new EcobeeException(e);
    }
}

From source file:org.openhab.binding.mojio.messages.AuthorizeRequest.java

private String buildQueryString() {
    final StringBuilder urlBuilder = new StringBuilder(RESOURCE_URL);

    try {/*  w w  w. j a  va 2  s. c o m*/
        urlBuilder.append(appKey);
        urlBuilder.append("?secretKey=");
        urlBuilder.append(appSecret);
        urlBuilder.append("&minutes=43200&userOrEmail=");
        urlBuilder.append(username);
        urlBuilder.append("&password=");
        urlBuilder.append(password);
        return URIUtil.encodeQuery(urlBuilder.toString());
    } catch (final Exception e) {
        throw new MojioException(e);
    }
}

From source file:org.openhab.binding.mojio.messages.GetMojioData.java

private String buildQueryString() {
    final StringBuilder urlBuilder = new StringBuilder(RESOURCE_URL);

    try {// w ww  .  j a  v a  2  s  . co  m
        urlBuilder.append("?limit=");
        urlBuilder.append(this.limit);
        urlBuilder.append("&offset=");
        urlBuilder.append(offset);
        urlBuilder.append("&sortBy=");
        urlBuilder.append(sortBy);
        urlBuilder.append("&desc=");
        urlBuilder.append(order);
        urlBuilder.append("&criteria=");
        urlBuilder.append(criteria);
        return URIUtil.encodeQuery(urlBuilder.toString());
    } catch (final Exception e) {
        throw new MojioException(e);
    }
}

From source file:org.openhab.binding.nest.internal.messages.AccessTokenRequest.java

private String buildQueryString() {
    final StringBuilder urlBuilder = new StringBuilder(RESOURCE_URL);

    try {//from  w ww  . j  a va 2 s .c  om
        urlBuilder.append("?code=");
        urlBuilder.append(this.pinCode);
        urlBuilder.append("&client_id=");
        urlBuilder.append(this.clientId);
        urlBuilder.append("&client_secret=");
        urlBuilder.append(this.clientSecret);
        urlBuilder.append("&grant_type=authorization_code");
        return URIUtil.encodeQuery(urlBuilder.toString());
    } catch (final Exception e) {
        throw new NestException(e);
    }
}

From source file:org.openhab.binding.nest.internal.messages.DataModelRequest.java

private String buildQueryString() {
    final StringBuilder urlBuilder = new StringBuilder(RESOURCE_URL);

    try {/*from w  w  w  .  j ava2  s  .  com*/
        urlBuilder.append("?auth=");
        urlBuilder.append(this.accessToken);
        return URIUtil.encodeQuery(urlBuilder.toString());
    } catch (final Exception e) {
        throw new NestException(e);
    }
}

From source file:org.pentaho.di.core.refinery.publish.agilebi.ModelServerPublish.java

public DatabaseConnection connectionNameExists(String connectionName) {

    if (StringUtils.isBlank(connectionName)) {
        return null;
    }//w w w.j a  v  a2 s .c  o  m

    try {
        String storeDomainUrl = biServerConnection.getUrl() + DATA_ACCESS_API_CONNECTION_GET + REST_NAME_PARM
                + connectionName;
        storeDomainUrl = URIUtil.encodeQuery(storeDomainUrl);
        WebResource resource = getClient().resource(storeDomainUrl);
        Builder builder = resource.type(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_XML);
        ClientResponse response = httpGet(builder);
        if (response != null && response.getStatus() == 200) {

            String payload = response.getEntity(String.class);
            DatabaseConnection connection = JAXBUtils.unmarshalFromJson(payload, DatabaseConnection.class);

            return connection;
        }
    } catch (Exception ex) {
        Log.error(ex.getMessage());
    }

    return null;
}

From source file:org.sigmah.server.endpoint.export.sigmah.spreadsheet.CalcUtils.java

public static void applyLink(final Cell cell, String linkName, String target) throws Throwable {
    java.net.URI uri = new java.net.URI(URIUtil.encodeQuery("#" + normalizeAsLink(target)));
    cell.addParagraph(linkName).applyHyperlink(uri);
}