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.janoz.usenet.processors.impl.WebbasedProcessor.java
private URI constructURI(String command, List<NameValuePair> fields) throws IOException { try {//from w w w .j a va 2 s .c o m String url = (((rootDir == null) || (rootDir.length() == 0)) ? "" : "/" + rootDir) + "/" + command; String params = null; if (fields != null) { params = URLEncodedUtils.format(fields, "UTF-8"); } return URIUtils.createURI(serverProtocol, serverAddress, serverPort, url, params, null); } catch (URISyntaxException e) { throw new IOException(e); } }
From source file:com.jzboy.couchdb.http.URITemplates.java
/** * URI used to download a file attachment *///from w w w .ja va 2s. c o m public static URI attachment(String host, int port, String dbName, String docId, String fileName) throws URISyntaxException { String path = String.format("%s/%s/%s", dbName, docId, fileName); return URIUtils.createURI("http", host, port, path, null, null); }
From source file:com.github.feribg.audiogetter.helpers.Utils.java
/** * Used to build an mp3 skull search query. An initial request might be needed to fetch the * CSRF token from the page source before searching * @param query//from w w w . ja v a 2s .c o m * @param csrf * @return * @throws URISyntaxException */ public static URI getMp3SkullSearchURI(String query, String csrf) throws URISyntaxException { List<NameValuePair> qparams = new ArrayList<NameValuePair>(); qparams.add(new BasicNameValuePair("q", query)); qparams.add(new BasicNameValuePair("fckh", csrf)); return URIUtils.createURI(Constants.Mp3skull.API_SCHEME, Constants.Mp3skull.API_HOST, -1, Constants.Mp3skull.API_SEARCH, URLEncodedUtils.format(qparams, "UTF-8"), null); }
From source file:org.craftercms.social.util.UGCHttpClient.java
public HttpResponse getModerationStatus(String ticket, String moderationStatus) 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/moderation/" + moderationStatus + ".json", URLEncodedUtils.format(qparams, HTTP.UTF_8), null); HttpGet httpget = new HttpGet(uri); HttpClient httpclient = new DefaultHttpClient(); return httpclient.execute(httpget); }
From source file:com.healthcit.cacure.dao.CouchDBDao.java
public String replicateDataInContextSpecificDb(String context) throws URISyntaxException, IOException { URI replicationUri = URIUtils.createURI("http", host, port, "/_replicate", null, null); JSONObject replicationBody = new JSONObject(); String contextSpecificDb = getSourceDbName() + buildDbSuffix(context); JSONArray docIds = getDocIdsByContextFromMasterDb(context); replicationBody.put("source", getSourceDbName()); replicationBody.put("target", contextSpecificDb); replicationBody.put("doc_ids", docIds); log.info("JSON for replication: " + replicationBody.toString()); String response = runPostQuery(replicationUri, replicationBody.toString()); if (!wasCouchDbOperationSuccessful(response)) throw new IOException("Could not initiate replication: " + response); log.info("Replication initiated."); return response; }
From source file:com.github.feribg.audiogetter.helpers.Utils.java
/** * Get the base Mp3Skull url to determine CSRF token for the session * @return//from ww w .ja va 2s.co m * @throws URISyntaxException */ public static URI getMp3SkullBaseURI() throws URISyntaxException { return URIUtils.createURI(Constants.Mp3skull.API_SCHEME, Constants.Mp3skull.API_HOST, -1, null, null, null); }
From source file:com.janoz.usenet.searchers.impl.NzbsOrgConnectorImpl.java
/** * /*from w w w . j a v a2 s . c om*/ * @param action * @param params Parameters WILL BE MODIFIED * @return * @throws URISyntaxException */ private URI getUri(String action, List<NameValuePair> params) throws URISyntaxException { params.add(new BasicNameValuePair("i", userId)); params.add(new BasicNameValuePair("h", passwordHash)); return URIUtils.createURI("http", "nzbs.org", 80, action, URLEncodedUtils.format(params, "UTF-8"), null); }
From source file:com.jelastic.JelasticService.java
CreateObjectResponse createObject(UploadResponse upLoader, AuthenticationResponse authentication) { CreateObjectResponse createObjectResponse = null; try {//from w w w.j a v a2 s . c om DefaultHttpClient httpclient = getHttpClient(); List<NameValuePair> nameValuePairList = new ArrayList<NameValuePair>(); nameValuePairList.add(new BasicNameValuePair("charset", "UTF-8")); nameValuePairList.add(new BasicNameValuePair("session", authentication.getSession())); nameValuePairList.add(new BasicNameValuePair("type", "JDeploy")); nameValuePairList.add(new BasicNameValuePair("data", "{'name':'" + upLoader.getName() + "', 'archive':'" + upLoader.getFile() + "', 'link':0, 'size':" + upLoader.getSize() + ", 'comment':'" + upLoader.getName() + "'}")); UrlEncodedFormEntity entity = new UrlEncodedFormEntity(nameValuePairList, "UTF-8"); for (NameValuePair nameValuePair : nameValuePairList) { project.log(nameValuePair.getName() + " : " + nameValuePair.getValue(), Project.MSG_DEBUG); } URI uri = URIUtils.createURI(getProtocol(), getApiHoster(), getPort(), getUrlCreateObject(), null, null); project.log("CreateObject url : " + uri.toString(), Project.MSG_DEBUG); HttpPost httpPost = new HttpPost(uri); httpPost.setEntity(entity); ResponseHandler<String> responseHandler = new BasicResponseHandler(); String responseBody = httpclient.execute(httpPost, responseHandler); project.log("CreateObject response : " + responseBody, Project.MSG_DEBUG); createObjectResponse = deserialize(responseBody, CreateObjectResponse.class); } catch (URISyntaxException | IOException e) { project.log(e.getMessage(), Project.MSG_ERR); } return createObjectResponse; }
From source file:com.ovea.facebook.client.DefaultFacebookClient.java
private JSONType post(String proto, String host, String path, List<NameValuePair> qparams, List<NameValuePair> pparams) { try {// www. j a v a 2s . c om URI uri = URIUtils.createURI(proto, host, -1, path, qparams == null ? null : URLEncodedUtils.format(qparams, "UTF-8"), null); HttpPost post = new HttpPost(uri); if (pparams != null) { post.setEntity(new UrlEncodedFormEntity(pparams, HTTP.UTF_8)); } HttpResponse response = httpClient().execute(post); String contentType = response.getEntity().getContentType().getValue(); contentType = contentType == null ? "" : contentType.toLowerCase(); if (contentType.startsWith("application/json") || contentType.startsWith("text/javascript")) { return JSON.parse(EntityUtils.toString(response.getEntity())); } else { return JSON.object().put("data", EntityUtils.toString(response.getEntity())); } } catch (Exception e) { throw new FacebookException(e.getMessage(), e); } }
From source file:com.jzboy.couchdb.http.URITemplates.java
/** * URI used for CRUD operations on an attachment *//*from w ww .j a v a 2 s.co m*/ public static URI attachment(Database db, Document doc, String fileName) throws URISyntaxException { String query = doc.hasRev() ? "rev=" + doc.getRev() : null; String path = String.format("%s/%s/%s", db.getDbName(), doc.getId(), fileName); return URIUtils.createURI("http", db.getServer().getHost(), db.getServer().getPort(), path, query, null); }