List of usage examples for org.apache.http.client.utils URIUtils createURI
@Deprecated public static URI createURI(final String scheme, final String host, final int port, final String path, final String query, final String fragment) throws URISyntaxException
From source file:com.jelastic.JelasticService.java
public AuthenticationResponse authentication(String email, String password) { AuthenticationResponse authenticationResponse = null; try {// ww w .j a v a 2s .c o m List<NameValuePair> qparams = new ArrayList<NameValuePair>(); qparams.add(new BasicNameValuePair("login", email)); qparams.add(new BasicNameValuePair("password", password)); URI uri = URIUtils.createURI(getProtocol(), getApiHoster(), getPort(), getUrlAuthentication(), null, null); project.log("Authentication url : " + uri.toString(), Project.MSG_DEBUG); HttpPost httpPost = new HttpPost(uri); httpPost.setEntity(new UrlEncodedFormEntity(qparams, "UTF-8")); ResponseHandler<String> responseHandler = new BasicResponseHandler(); DefaultHttpClient httpclient = getHttpClient(); String responseBody = httpclient.execute(httpPost, responseHandler); setCookieStore(httpclient.getCookieStore()); project.log("Authentication response : " + responseBody, Project.MSG_DEBUG); authenticationResponse = deserialize(responseBody, AuthenticationResponse.class); } catch (URISyntaxException | IOException e) { project.log(e.getMessage(), Project.MSG_ERR); } return authenticationResponse; }
From source file:org.craftercms.social.util.UGCHttpClient.java
public HttpResponse like(String ticket, String ugcId) throws URISyntaxException, ClientProtocolException, IOException { List<NameValuePair> qparams = new ArrayList<NameValuePair>(); qparams.add(new BasicNameValuePair("ticket", ticket)); URI uri = URIUtils.createURI(scheme, host, port, appPath + "/api/2/ugc/like/" + ugcId + ".json", URLEncodedUtils.format(qparams, HTTP.UTF_8), null); HttpPost httppost = new HttpPost(uri); HttpClient httpclient = new DefaultHttpClient(); return httpclient.execute(httppost); }
From source file:gr.ntua.ivml.awareness.search.SearchServiceAccess.java
private URI constructURI(List<String> terms, String type, int startPage) { URI uri = null;/* www . ja v a 2 s . c o m*/ String delim = "+"; Iterator<String> it = terms.iterator(); String q = ""; if (it.hasNext()) { q = "\"" + it.next() + "\""; } while (it.hasNext()) { q += delim + "\"" + it.next() + "\""; } List<NameValuePair> qparams = new ArrayList<NameValuePair>(); qparams.add(new BasicNameValuePair("query", q)); if (type != null && type.length() > 0) { qparams.add(new BasicNameValuePair("qf", "TYPE:" + type.toUpperCase())); } qparams.add(new BasicNameValuePair("profile", "standard")); if (startPage == 0) qparams.add(new BasicNameValuePair("start", "1")); else qparams.add(new BasicNameValuePair("start", Integer.toString(startPage * 6))); qparams.add(new BasicNameValuePair("rows", "6")); qparams.add(new BasicNameValuePair("wskey", "api2demo")); try { uri = URIUtils.createURI("http", "preview.europeana.eu", 80, "/api/v2/search.json", URLEncodedUtils.format(qparams, "UTF-8"), null); } catch (URISyntaxException e) { e.printStackTrace(); } return uri; }
From source file:org.xwiki.wysiwyg.internal.plugin.alfresco.server.TicketAuthenticator.java
@Override public void authenticate(HttpRequestBase request) { String ticket = null;/*from ww w. jav a 2 s . c om*/ //get ticket from DB AlfrescoTiket dbTiket = ticketManager.getTicket(); //if there is a ticket for current user,use it if (dbTiket != null) { ticket = dbTiket.getTiket(); } /*if (ticket != null) { if (!ticketManager.validateAuthenticationTicket(ticket)) { //if ticket is not valid on alfresco, perform authentication ticket = getAuthenticationTicket(); } } else { //if there is no ticket in DB, perform authentication ticket = getAuthenticationTicket(); }*/ // Add the ticket to the query string. URI uri = request.getURI(); List<NameValuePair> parameters = URLEncodedUtils.parse(uri, QUERY_STRING_ENCODING); parameters.add(new BasicNameValuePair(AUTH_TICKET_PARAM, ticket)); String query = URLEncodedUtils.format(parameters, QUERY_STRING_ENCODING); try { request.setURI(URIUtils.createURI(uri.getScheme(), uri.getHost(), uri.getPort(), uri.getRawPath(), query, uri.getRawFragment())); } catch (URISyntaxException e) { // This shouldn't happen. } }
From source file:com.jzboy.couchdb.http.URITemplates.java
/** * URI used to get/set an upper bound on the number document revisions that CouchDB keeps track of * @see <a href="http://wiki.apache.org/couchdb/HTTP_database_API#Accessing_Database-specific_options">CouchDB Wiki</a> *//*from w w w. j a v a 2 s. c o m*/ public static URI revsLimit(String host, int port, String dbName) throws URISyntaxException { return URIUtils.createURI("http", host, port, dbName + "/_revs_limit", null, null); }
From source file:org.soyatec.windowsazure.authenticate.SharedKeyCredentialsWrapper.java
/** * Replace the uri container name./*from w ww .ja v a 2 s . c o m*/ * * @param uri * @param containerName * @return The uri after be replaced the container name with the input * containerName. */ private URI replaceContainerName(URI uri, String containerName) { if (containerName == null) { return uri; } try { String host = uri.getPath(); String[] temp = host.split("/"); temp[0] = containerName; return URIUtils.createURI(uri.getScheme(), uri.getHost(), uri.getPort(), join("/", temp), (uri.getQuery() == null ? Utilities.emptyString() : uri.getQuery()), uri.getFragment()); } catch (URISyntaxException e) { Logger.error("", e); } return uri; }
From source file:org.zaizi.alfresco.publishing.marklogic.MarkLogicPublishingHelper.java
/** * Gets the uri./*from w w w . j a v a 2s . c o m*/ * * @param nodeToPublish the node to publish * @param channelProperties the channel properties * @param taskToPerform the task to perform * @return the uri * @throws URISyntaxException the uRI syntax exception */ private URI getUri(final NodeRef nodeToPublish, final Map<QName, Serializable> channelProperties, String taskToPerform) throws URISyntaxException { URI uri = URIUtils.createURI(MarkLogicPublishingModel.PROTOCOL, (String) channelProperties.get(MarkLogicPublishingModel.PROP_HOST), (Integer) channelProperties.get(MarkLogicPublishingModel.PROP_PORT), taskToPerform, MarkLogicPublishingModel.URI + nodeToPublish.toString(), null); LOG.info("URI For MarkLogic Publishing channel:>>>> " + uri.toString()); return uri; }
From source file:org.sakaiproject.shortenedurl.impl.BitlyUrlService.java
/** * Make a GET request and append the Map of parameters onto the query string. * @param address the fully qualified URL to make the request to * @param parameters the Map of parameters, ie key,value pairs * @return// w ww . j a v a2 s.c o m */ private String doGet(String address, Map<String, String> parameters) { try { List<NameValuePair> queryParams = new ArrayList<NameValuePair>(); for (Map.Entry<String, String> entry : parameters.entrySet()) { queryParams.add(new BasicNameValuePair(entry.getKey(), entry.getValue())); } URI uri = URIUtils.createURI(null, address, -1, null, URLEncodedUtils.format(queryParams, "UTF-8"), null); log.info(uri.toString()); return doGet(uri.toString()); } catch (URISyntaxException e) { log.error(e.getClass() + ":" + e.getMessage()); } return null; }
From source file:com.eviware.soapui.impl.rest.actions.oauth.OltuOAuth2ClientFacade.java
private void appendAccessTokenToQuery(HttpRequestBase request, OAuthBearerClientRequest oAuthClientRequest) throws OAuthSystemException { String queryString = getQueryStringFromOAuthClientRequest(oAuthClientRequest); URI oldUri = request.getURI(); String requestQueryString = oldUri.getQuery() != null ? oldUri.getQuery() + "&" + queryString : queryString; try {/*from w w w. ja va 2s . com*/ request.setURI(URIUtils.createURI(oldUri.getScheme(), oldUri.getHost(), oldUri.getPort(), oldUri.getRawPath(), requestQueryString, oldUri.getFragment())); } catch (URISyntaxException e) { throw new OAuthSystemException(e); } }
From source file:edu.scripps.fl.pubchem.web.session.PCWebSession.java
/** * // w w w . ja v a 2s. c o m * Returns a description xml file for an aid * * @param aid * @return * @throws Exception */ public InputStream getDescrXML(int aid) throws Exception { // if we don't provide the version, we get the latest one anyway. // http://pubchem.ncbi.nlm.nih.gov/assay/assay.cgi?aid=2551&version=1.1&q=expdesc_xmldisplay List<NameValuePair> params = addParameters(new ArrayList<NameValuePair>(), "aid", aid, "q", "expdesc_xmldisplay"); URI uri = URIUtils.createURI("http", SITE, 80, "/assay/assay.cgi", URLEncodedUtils.format(params, "UTF-8"), null); HttpResponse response = getHttpClient().execute(new HttpGet(uri)); return response.getEntity().getContent(); }