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.datalift.datacubeviz.DatacubeVizController.java

@GET
@Path("/ws/datasetsnew")
@Produces({ MediaTypes.APPLICATION_JSON_UTF8 })
public Response getDataSetsNew(@QueryParam("project") java.net.URI projectId) {
    Project p = this.getProject(projectId);
    InputStream data = null;/*from  w  w w .  ja va  2 s .c  o  m*/
    JSONObject jsonObject = null;

    new LinkedList<org.datalift.datacubeviz.container.Source>();
    for (Source s : p.getSources()) {
        if (model.isValidSource(s)) {
            new org.datalift.datacubeviz.container.Source(s.getUri().toString(), s.getTitle());

            TransformedRdfSource rdf = (TransformedRdfSource) s;

            try {
                // String query =
                // "SELECT DISTINCT ?uri ?title WHERE { GRAPH <"
                // + rdf.getTargetGraph()
                // + "> { ?uri a <"
                // + model.DATACUBE_DATASET_NS
                // +
                // "> . ?uri <http://www.w3.org/2000/01/rdf-schema#label> ?title . } }";

                String query = "PREFIX qb: <http://purl.org/linked-data/cube#>"
                        + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>"
                        + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>"
                        + "PREFIX dct: <http://purl.org/dc/terms/>"
                        + "PREFIX dc: <http://purl.org/dc/elements/1.1/>"
                        + "PREFIX foaf: <http://xmlns.com/foaf/0.1/>"
                        + "PREFIX skos: <http://www.w3.org/2004/02/skos/core#>"
                        + "PREFIX sdmx: <http://purl.org/linked-data/sdmx#>"
                        + "PREFIX sdmx-subject: <http://purl.org/linked-data/sdmx/2009/subject#>" + ""
                        + "SELECT *" + "WHERE {" + "GRAPH <" + rdf.getTargetGraph() + "> {" + "  ?ds a <"
                        + DatacubeVizModel.DATACUBE_DATASET_NS + "> ." + ""
                        + "  OPTIONAL {{?ds dct:identifier ?id} UNION {?ds dc:identifier ?id}} ."
                        + "  OPTIONAL {?ds foaf:depiction ?depiction} ." + "  OPTIONAL {"
                        + "    {?ds rdfs:label ?titleFR} UNION {?ds dct:title ?titleFR} UNION {?ds dc:title ?titleFR}."
                        + "    FILTER langMatches(lang(?titleFR), 'FR') ." + "  } ." + "  OPTIONAL {"
                        + "    {?ds rdfs:label ?titleEN} UNION {?ds dct:title ?titleEN} UNION {?ds dc:title ?titleEN}."
                        + "    FILTER langMatches(lang(?titleEN), 'EN') ." + "  } ." + "  OPTIONAL {"
                        + "    {?ds rdfs:label ?titleOther} UNION {?ds dct:title ?titleOther} UNION {?ds dc:title ?titleOther}."
                        + "    FILTER (!langMatches(lang(?titleOther), 'EN') &&  !langMatches(lang(?titleOther), 'FR')) ."
                        + "  } ." + "" + "  OPTIONAL {"
                        + "    {?ds rdfs:comment ?descriptionFR} UNION {?ds dct:description ?descriptionFR} UNION {?ds dc:description ?descriptionFR} ."
                        + "    FILTER langMatches(lang(?descriptionFR), 'FR') ." + "  } ." + "  OPTIONAL {"
                        + "    {?ds rdfs:comment ?descriptionEN} UNION {?ds dct:description ?descriptionEN} UNION {?ds dc:description ?descriptionEN} ."
                        + "    FILTER langMatches(lang(?descriptionEN), 'EN') ." + "  } ." + "  OPTIONAL {"
                        + "    {?ds rdfs:comment ?descriptionOther} UNION {?ds dct:description ?descriptionOther} UNION {?ds dc:description ?descriptionOther} ."
                        + "    FILTER (!langMatches(lang(?descriptionOther), 'EN') &&  !langMatches(lang(?descriptionOther), 'FR')) ."
                        + "  } ." + "" + "  OPTIONAL {?ds dct:license ?license} ."
                        + "  OPTIONAL {{?ds dct:source ?source} UNION {?ds dc:source ?source}} ."
                        + "  OPTIONAL {?ds rdfs:seeAlso ?seeAlso} ." + ""
                        + "  OPTIONAL {{?ds dct:date ?date} UNION {?ds dc:date ?date}} ."
                        + "  OPTIONAL {?ds dct:created ?created} ." + "  OPTIONAL {?ds dct:issued ?issued} ."
                        + "  OPTIONAL {?ds dct:modified ?modified} ." + "" + "  OPTIONAL {"
                        + "    {?ds dct:subject ?subject} UNION {?ds dc:subject ?subject} ." + ""
                        + "    OPTIONAL {" + "      FILTER (!isLiteral(?subject))" + "      OPTIONAL {"
                        + "        ?subject a ?subjectType"
                        + "        FILTER (?subjectType = skos:Concept || ?subjectType = sdmx:Concept || ?subjectType = sdmx-subject:)"
                        + "        OPTIONAL {" + "          {?subject skos:prefLabel ?subjectLabel} ."
                        + "        } ." + "      }" + "    } ." + "  } ." + "" + "  OPTIONAL {"
                        + "    {?ds dct:contributor ?contributor} UNION {?ds dc:contributor ?contributor} ."
                        + "    OPTIONAL {"
                        + "      {?contributor foaf:name ?contributorName} UNION {?contributor rdfs:label ?contributorName} ."
                        + "    } ." + "    OPTIONAL {"
                        + "      {?contributor foaf:homepage ?contributorPage} UNION {?contributor foaf:page ?contributorPage} UNION {?contributor rdfs:seeAlso ?contributorPage}."
                        + "    } ." + "  } ." + "" + "  OPTIONAL {"
                        + "    {?ds dct:creator ?creator} UNION {?ds dc:creator ?creator} ." + "    OPTIONAL {"
                        + "      {?creator foaf:name ?creatorName} UNION {?creator rdfs:label ?creatorName} ."
                        + "    } ." + "    OPTIONAL {"
                        + "      {?creator foaf:homepage ?creatorPage} UNION {?creator foaf:page ?creatorPage} UNION {?creator rdfs:seeAlso ?creatorPage}."
                        + "    } ." + "  } ." + "" + "  OPTIONAL {"
                        + "    {?ds dct:publisher ?publisher} UNION {?ds dc:publisher ?publisher} ."
                        + "    OPTIONAL {"
                        + "      {?publisher foaf:name ?publisherName} UNION {?publisher rdfs:label ?publisherName} ."
                        + "    } ." + "    OPTIONAL {"
                        + "      {?publisher foaf:homepage ?publisherPage} UNION {?publisher foaf:page ?publisherPage} UNION {?publisher rdfs:seeAlso ?publisherPage}."
                        + "    } . } .  } }";
                // Use URI multi-argument constructor to escape query
                // string.
                URL repo_url = new URL(DatacubeVizModel.INTERNAL_REPO.getEndpointUrl());

                String buf = "?query=" + URIUtil.encodeQuery(query).replaceAll("&", "%26");
                LOG.debug("query: {}", query);
                LOG.debug("buf: {}", buf.toString());
                // buf.append("&default-graph-uri=").append(repo_url);

                URL url = new URI(repo_url + buf).toURL();

                // Build HTTP request.
                LOG.debug("url: {}", url.toString());
                HttpURLConnection cnx = (HttpURLConnection) (url.openConnection());
                cnx.setRequestMethod("GET");
                cnx.setConnectTimeout(2000); // 2 sec.
                cnx.setReadTimeout(30000); // 30 sec.
                cnx.setRequestProperty(ACCEPT, "application/xml");
                // Force server connection.
                cnx.connect();
                // Check for error data.
                data = cnx.getErrorStream();
                if (data == null) {
                    // No error data available. => get response data.
                    data = cnx.getInputStream();
                    StringWriter writer = new StringWriter();
                    IOUtils.copy(data, writer, "UTF-8");
                    String datastring = writer.toString();
                    LOG.debug("data received: {}", datastring);
                    jsonObject = XML.toJSONObject(datastring);
                    LOG.debug("json generated: {}", jsonObject.toString());
                }

            } catch (Exception e) {
                e.printStackTrace();
            }
        }

    }

    return Response.status(200).type(MediaTypes.APPLICATION_JSON_UTF8).entity(jsonObject.toString()).build();
}

From source file:org.eclipse.mylyn.internal.gerrit.core.client.GerritClient29.java

private org.eclipse.mylyn.internal.gerrit.core.client.rest.AccountInfo getAccountInfo(String account,
        IProgressMonitor monitor) throws GerritException, URIException {
    if (GerritSystemAccount.GERRIT_SYSTEM_NAME.equals(account)) {
        return GerritSystemAccount.GERRIT_SYSTEM;
    }/* w w w .j a va  2s.co  m*/
    String st = URIUtil.encodeQuery(account);
    final String uri = "/accounts/" + st; //$NON-NLS-1$
    org.eclipse.mylyn.internal.gerrit.core.client.rest.AccountInfo accountInfo = executeGetRestRequest(uri,
            org.eclipse.mylyn.internal.gerrit.core.client.rest.AccountInfo.class, monitor);
    return accountInfo;
}

From source file:org.entando.entando.plugins.jpoauthclient.aps.system.services.client.ProviderConnectionManager.java

private void addQueryString(HttpMethodBase method, Properties parameters) throws Throwable {
    if (null == parameters)
        return;/*from   ww  w . j a  v a 2  s  .c  om*/
    StringBuilder builder = new StringBuilder();
    boolean first = true;
    Iterator<Object> keyIter = parameters.keySet().iterator();
    while (keyIter.hasNext()) {
        Object key = keyIter.next();
        if (!first)
            builder.append("&");
        builder.append(key.toString()).append("=").append(parameters.getProperty(key.toString()));
        if (first)
            first = false;
    }
    method.setQueryString(URIUtil.encodeQuery(builder.toString()));
}

From source file:org.fao.geonet.kernel.KeywordBean.java

/**
 * Transforms a KeywordBean object into its iso19139 representation.
 * /* w w w . j  a v a 2  s.  com*/
 * <pre>
 *       <gmd:keyword xmlns:gmd="http://www.isotc211.org/2005/gmd" xmlns:gco="http://www.isotc211.org/2005/gco" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="">
 *           <gmx:Anchor xlink:href="link_to_keyword_generator">A KEYWORD GENERATED BY XLINK SERVICE</gco:Anchor>
 *      </gmd:keyword>
 *     <gmd:type>
 *        <gmd:MD_KeywordTypeCode codeList="http://www.isotc211.org/2005/resources/codeList.xml#MD_KeywordTypeCode" codeListValue="TYPE"/>
 *     </gmd:type>
 *     <gmd:thesaurusName>
 *        <gmd:CI_Citation>
 *           <gmd:title>
 *              <gco:CharacterString>THESAURUS NAME</gco:CharacterString>
 *           </gmd:title>
 *           <gmd:date gco:nilReason="unknown"/>
 *            <gmd:identifier>
 *          <gmd:MD_Identifier>
 *                  <gmd:code>
 *                     <gmx:Anchor xlink:href="http://localhost:8080/geonetwork/srv/eng/metadata.show?uuid=bc44a748-f1a1-4775-9395-a4a6d8bb8df6">register.theme.bc44a748-f1a1-4775-9395-a4a6d8bb8df6</gmx:Anchor>
 *                  </gmd:code>
 *          </gmd:MD_Identifier>
 *            </gmd:identifier>
 *        </gmd:CI_Citation>
 *     </gmd:thesaurusName>
 * </pre>
 * 
 * @return an iso19139 representation of the keyword
 */
public Element getIso19139() {
    Element ele = new Element("MD_Keywords", Namespaces.GMD);
    Element el = new Element("keyword", Namespaces.GMD);
    Element an = new Element("Anchor", Namespaces.GMX);
    Element cs = new Element("CharacterString", Namespaces.GCO);
    if (getUriCode() != null && getUriCode().length() != 0) {
        try {
            an.setText(getDefaultValue());
            an.setAttribute("href", URIUtil.encodeQuery(keywordUrl + getUriCode()), Namespaces.XLINK);
            el.addContent(an);
        } catch (URIException e) { // what to do here? Just add the value
            cs.setText(getDefaultValue());
            el.addContent(cs);
        }
    } else {
        cs.setText(getDefaultValue());
        el.addContent(cs);
    }

    Element type = KeywordBean.createKeywordTypeElt(this);

    Element thesaurusName = KeywordBean.createThesaurusNameElt(this);

    ele.addContent(el);
    ele.addContent(type);
    ele.addContent(thesaurusName);

    return ele;
}

From source file:org.fao.geonet.kernel.KeywordBean.java

/**
 * Transforms a list of KeywordBean object into its iso19139 representation.
 *  /*  w w  w .ja v  a2  s .  co  m*/
 *  <pre>
 *  <gmd:MD_Keywords>
 *     <gmd:keyword>
 *        <gmx:Anchor xlink:href="link_to_keyword_generator">Keyword 1</gmx:Anchor>
 *     </gmd:keyword>
 *       <gmd:keyword>
 *        <gmx:Anchor xlink:href="link_to_keyword_generator">Keyword 2</gmx:Anchor>
 *     </gmd:keyword>
 *     <gmd:type>
 *        <gmd:MD_KeywordTypeCode codeList="http://www.isotc211.org/2005/resources/codeList.xml#MD_KeywordTypeCode" codeListValue="TYPE"/>
 *     </gmd:type>
 *     <gmd:thesaurusName>
 *        <gmd:CI_Citation id="geonetwork.thesaurus.register.theme.bc44a748-f1a1-4775-9395-a4a6d8bb8df6">
 *           <gmd:title>
 *              <gco:CharacterString>THESAURUS NAME</gco:CharacterString>
 *           </gmd:title>
 *           <gmd:date gco:nilReason="unknown"/>
 *            <gmd:identifier>
 *          <gmd:MD_Identifier>
 *                  <gmd:code>
 *                     <gmx:Anchor xlink:href="http://localhost:8080/geonetwork/srv/eng/metadata.show?uuid=bc44a748-f1a1-4775-9395-a4a6d8bb8df6">register.theme.bc44a748-f1a1-4775-9395-a4a6d8bb8df6</gmx:Anchor>
 *                  </gmd:code>
 *          </gmd:MD_Identifier>
 *            </gmd:identifier>
 *        </gmd:CI_Citation>
 *     </gmd:thesaurusName>
 *  </gmd:MD_Keywords>
 *  </pre>
 *       
 *  
 * @param kbList
 * @return a complex iso19139 representation of the keyword
 */
public static Element getComplexIso19139Elt(List<KeywordBean> kbList) {
    Element root = new Element("MD_Keywords", Namespaces.GMD);

    Element cs = new Element("CharacterString", Namespaces.GCO);
    Element an = new Element("Anchor", Namespaces.GMX);

    List<Element> keywords = new ArrayList<Element>();

    Element type = null;
    Element thesaurusName = null;

    for (KeywordBean kb : kbList) {
        Element keyword = new Element("keyword", Namespaces.GMD);
        if (kb.getUriCode() != null && kb.getUriCode().length() != 0) {
            try {
                an.setText(kb.getDefaultValue());
                an.setAttribute("href", URIUtil.encodeQuery(kb.keywordUrl + kb.getUriCode()), Namespaces.XLINK);
                keyword.addContent((Content) an.clone());
            } catch (URIException e) {
                cs.setText(kb.getDefaultValue());
                keyword.addContent((Content) cs.clone());
            }
        } else {
            cs.setText(kb.getDefaultValue());
            keyword.addContent((Content) cs.clone());
        }
        keywords.add((Element) keyword.detach());
        if (type == null)
            type = KeywordBean.createKeywordTypeElt(kb);
        if (thesaurusName == null)
            thesaurusName = KeywordBean.createThesaurusNameElt(kb);
    }

    // Add elements to the root MD_Keywords element.
    root.addContent(keywords);
    root.addContent(type);
    root.addContent(thesaurusName);

    return root;
}

From source file:org.isisaddons.wicket.gmap3.cpt.service.LocationLookupService.java

@Programmatic
public Location lookup(final String description) {

    final GetMethod get = new GetMethod(BASEURL + MODE);
    try {// w  ww  .  ja  v  a2 s. c o  m
        final String query = URIUtil.encodeQuery("?address=" + description + "&sensor=false");
        get.setQueryString(query);

        httpclient.executeMethod(get);

        final String xml = get.getResponseBodyAsString();
        final SAXBuilder builder = new SAXBuilder();
        Document doc = builder.build(new StringReader(xml));
        Element root = doc.getRootElement();
        String lat = root.getChild("result").getChild("geometry").getChild("location").getChildTextTrim("lat");
        String lon = root.getChild("result").getChild("geometry").getChild("location").getChildTextTrim("lng");
        return Location.fromString(lat + ";" + lon);
    } catch (Exception ex) {
        return null;
    }
}

From source file:org.jbpm.formModeler.core.model.RangeProviderForm.java

private String getFormDirUri(Path formPath) {
    String fileName = formPath.getFileName();
    try {//w  ww .  j  a  va  2s  . c o  m
        fileName = URIUtil.encodeQuery(fileName);
    } catch (Exception e) {

    }
    return formPath.toURI().substring(0, formPath.toURI().lastIndexOf(fileName) - 1);
}

From source file:org.kuali.kra.lookup.S2sOpportunityLookupableHelperServiceImpl.java

public Collection performLookup(LookupForm lookupForm, Collection resultTable, boolean bounded) {
    Collection displayList;//from w w w .  j  ava  2  s  . c o m
    displayList = super.performLookup(lookupForm, resultTable, bounded);
    ResultRow row;
    for (Iterator iter = resultTable.iterator(); iter.hasNext();) {
        row = (ResultRow) iter.next();

        List<Column> columns = row.getColumns();
        if (!lookupForm.getBackLocation().contains("proposalDevelopmentGrantsGov")) {
            String cfdaNumber = columns.get(0).getPropertyValue();
            String closingDate = columns.get(1).getPropertyValue();
            String competetionId = columns.get(2).getPropertyValue();
            String instructionUrl = columns.get(3).getPropertyValue();
            String openingDate = columns.get(4).getPropertyValue();
            String oppurtunityId = columns.get(5).getPropertyValue();
            String oppurtunityTitle = columns.get(6).getPropertyValue();
            String schemaUrl = columns.get(7).getPropertyValue();

            String createProposalUrl = null;
            try {
                String encodedUrl = URIUtil.encodeQuery(lookupForm.getBackLocation()
                        + "?channelTitle=CreateProposal&channelUrl=proposalDevelopmentProposal.do?methodToCall=docHandler&command=initiate&docTypeName=ProposalDevelopmentDocument"
                        + "&createProposalFromGrantsGov=true"
                        + "&document.developmentProposalList[0].s2sOpportunity.cfdaNumber=" + cfdaNumber
                        + "&document.developmentProposalList[0].s2sOpportunity.opportunityId=" + oppurtunityId
                        + "&document.developmentProposalList[0].s2sOpportunity.opportunityTitle="
                        + oppurtunityTitle + "&document.developmentProposalList[0].s2sOpportunity.closingDate="
                        + closingDate + "&document.developmentProposalList[0].s2sOpportunity.openingDate="
                        + openingDate + "&document.developmentProposalList[0].s2sOpportunity.instructionUrl="
                        + instructionUrl + "&document.developmentProposalList[0].s2sOpportunity.competetionId="
                        + competetionId + "&document.developmentProposalList[0].s2sOpportunity.schemaUrl="
                        + schemaUrl);
                createProposalUrl = "<a href=" + encodedUrl + ">Create Proposal</a>";
                row.setReturnUrl(createProposalUrl);
            } catch (URIException e) {
                LOG.error(e.getMessage(), e);
            }
        }
        for (Iterator iterator = columns.iterator(); iterator.hasNext();) {
            Column col = (Column) iterator.next();

            if (StringUtils.equalsIgnoreCase(col.getColumnTitle(), "Instruction Page")
                    || StringUtils.equalsIgnoreCase(col.getColumnTitle(), "Schema URL")) {
                col.setPropertyURL(col.getPropertyValue());
            }
        }
    }
    return displayList;
}

From source file:org.nuxeo.ecm.tokenauth.TestTokenAuthenticationServlet.java

@Test
public void testServlet() throws Exception {

    HttpClient httpClient = new HttpClient();

    HttpMethod getMethod = null;/*from  w w w.  j  a va  2s  . c o m*/
    try {
        // ------------ Test bad authentication ----------------
        getMethod = new GetMethod(
                "http://localhost:18080/authentication/token?applicationName=myFavoriteApp&deviceId=dead-beaf-cafe-babe&permission=rw");
        int status = executeGetMethod(httpClient, getMethod, "Administrator", "badPassword");
        // Receives 404 because of redirection to error page
        assertEquals(404, status);

        // ------------ Test omitting required parameters ----------------
        // Token acquisition
        getMethod = new GetMethod("http://localhost:18080/authentication/token?applicationName=myFavoriteApp");
        status = executeGetMethod(httpClient, getMethod, "Administrator", "Administrator");
        assertEquals(400, status);

        // Token revocation
        getMethod = new GetMethod(
                "http://localhost:18080/authentication/token?applicationName=myFavoriteApp&revoke=true");
        status = executeGetMethod(httpClient, getMethod, "Administrator", "Administrator");
        assertEquals(400, status);

        // ------------ Test acquiring token ----------------
        String queryParams = URIUtil
                .encodeQuery("applicationName=Nuxeo Drive&deviceId=dead-beaf-cafe-babe&permission=rw");
        URI uri = new URI("http", null, "localhost", 18080, "/authentication/token", queryParams, null);
        getMethod = new GetMethod(uri.toString());
        // Acquire new token
        status = executeGetMethod(httpClient, getMethod, "Administrator", "Administrator");
        assertEquals(201, status);
        String token = getMethod.getResponseBodyAsString();
        assertNotNull(token);
        assertNotNull(getTokenAuthenticationService().getUserName(token));
        assertEquals(1, getTokenAuthenticationService().getTokenBindings("Administrator").size());

        // Acquire existing token
        status = httpClient.executeMethod(getMethod);
        assertEquals(201, status);
        String existingToken = getMethod.getResponseBodyAsString();
        assertEquals(token, existingToken);

        // ------------ Test revoking token ----------------
        // Non existing token, should do nothing
        getMethod = new GetMethod(
                "http://localhost:18080/authentication/token?applicationName=nonExistingApp&deviceId=dead-beaf-cafe-babe&revoke=true");
        status = executeGetMethod(httpClient, getMethod, "Administrator", "Administrator");
        assertEquals(400, status);
        String response = getMethod.getResponseBodyAsString();
        assertEquals(String.format(
                "No token found for userName %s, applicationName %s and deviceId %s; nothing to do.",
                "Administrator", "nonExistingApp", "dead-beaf-cafe-babe"), response);

        // Existing token
        queryParams = URIUtil
                .encodeQuery("applicationName=Nuxeo Drive&deviceId=dead-beaf-cafe-babe&revoke=true");
        uri = new URI("http", null, "localhost", 18080, "/authentication/token", queryParams, null);
        getMethod = new GetMethod(uri.toString());
        status = executeGetMethod(httpClient, getMethod, "Administrator", "Administrator");
        assertEquals(202, status);
        response = getMethod.getResponseBodyAsString();
        assertEquals(String.format("Token revoked for userName %s, applicationName %s and deviceId %s.",
                "Administrator", "Nuxeo Drive", "dead-beaf-cafe-babe"), response);
        nextTransaction(); // see committed changes
        assertNull(getTokenAuthenticationService().getUserName(token));
        assertTrue(getTokenAuthenticationService().getTokenBindings("Administrator").isEmpty());
    } finally {
        getMethod.releaseConnection();
    }
}

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

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

    try {//  ww  w  .j  av  a 2s  .c  om
        urlBuilder.append("?response_type=ecobeePin");
        urlBuilder.append("&client_id=");
        urlBuilder.append(appKey);
        urlBuilder.append("&scope=");
        urlBuilder.append(scope);
        return URIUtil.encodeQuery(urlBuilder.toString());
    } catch (final Exception e) {
        throw new EcobeeException(e);
    }
}