List of usage examples for org.apache.http.client.utils URIBuilder addParameter
public URIBuilder addParameter(final String param, final String value)
From source file:org.talend.dataprep.api.service.command.dataset.CopyDataSet.java
/** * Private constructor./*from w w w. ja v a 2s. c o m*/ * * @param id the dataset id to copy. * @param name the copy name. */ private CopyDataSet(String id, String name) { super(GenericCommand.DATASET_GROUP); execute(() -> { try { URIBuilder uriBuilder = new URIBuilder(datasetServiceUrl + "/datasets/" + id + "/copy"); if (StringUtils.isNotBlank(name)) { uriBuilder.addParameter("copyName", name); } return new HttpPost(uriBuilder.build()); } catch (URISyntaxException e) { throw new TDPException(UNEXPECTED_EXCEPTION, e); } }); on(HttpStatus.OK).then(asString()); }
From source file:com.anrisoftware.simplerest.owncloudocs.OwncloudOcsShares.java
private void addParameters(URIBuilder builder) { builder.addParameter("format", "json"); if (path != null) { addPathParameters(builder);// w ww. j a v a 2s .c o m } }
From source file:fr.ippon.wip.http.request.GetRequestBuilder.java
public HttpRequestBase buildHttpRequest() throws URISyntaxException { URI encodedURI = new URI(getRequestedURL()); URIBuilder uriBuilder = new URIBuilder(encodedURI); if (parameterMap != null) for (Map.Entry<String, String> entry : parameterMap.entries()) uriBuilder.addParameter(entry.getKey(), entry.getValue()); return new HttpGet(uriBuilder.build()); }
From source file:com.anrisoftware.simplerest.owncloudocs.OwncloudOcsShares.java
private void addPathParameters(URIBuilder builder) { builder.addParameter("path", path); if (reshares != null) { builder.addParameter("reshares", Boolean.toString(reshares)); }//w w w . j a v a 2 s .c o m if (subfiles != null) { builder.addParameter("subfiles", Boolean.toString(subfiles)); } }
From source file:com.axelor.studio.web.ReportBuilderController.java
private ActionResponse downloadPdf(String html, String fileName, Boolean printPageNo, ActionResponse response) throws URISyntaxException { URIBuilder builder = new URIBuilder("ws/htmlToPdf"); builder.addParameter("html", html); builder.addParameter("fileName", fileName); if (printPageNo != null && printPageNo) { builder.addParameter("printPageNo", "true"); }/* w ww. j a v a 2 s . c o m*/ String url = builder.build().toString(); response.setView(ActionView.define(I18n.get("Print")).add("html", url).param("download", "true") .param("fileName", fileName).map()); return response; }
From source file:com.activiti.service.activiti.SubmittedFormService.java
public JsonNode listFormSubmittedForms(ServerConfig serverConfig, String formId, Map<String, String[]> parameterMap) { URIBuilder builder = clientUtil.createUriBuilder("/enterprise/form-submitted-forms/" + formId); for (String name : parameterMap.keySet()) { builder.addParameter(name, parameterMap.get(name)[0]); }/*from w ww. ja va 2 s . c o m*/ HttpGet get = new HttpGet(clientUtil.getServerUrl(serverConfig, builder.toString())); return clientUtil.executeRequest(get, serverConfig); }
From source file:org.talend.dataprep.api.service.command.dataset.CreateOrUpdateDataSet.java
/** * Private constructor.//from w w w . j a v a2 s . c o m * * @param id the dataset id. * @param name the dataset name. * @param dataSetContent the new dataset content. */ private CreateOrUpdateDataSet(String id, String name, InputStream dataSetContent) { super(GenericCommand.DATASET_GROUP); execute(() -> { try { URIBuilder uriBuilder = new URIBuilder(datasetServiceUrl + "/datasets/" + id + "/raw/"); if (!StringUtils.isEmpty(name)) { uriBuilder.addParameter("name", name); } final HttpPut put = new HttpPut(uriBuilder.build()); // $NON-NLS-1$ //$NON-NLS-2$ put.setEntity(new InputStreamEntity(dataSetContent)); return put; } catch (URISyntaxException e) { throw new TDPException(CommonErrorCodes.UNEXPECTED_EXCEPTION, e); } }); onError(e -> new TDPException(APIErrorCodes.UNABLE_TO_CREATE_OR_UPDATE_DATASET, e)); on(HttpStatus.NO_CONTENT, HttpStatus.ACCEPTED).then(emptyString()); on(HttpStatus.OK).then(asString()); }
From source file:com.flipkart.aesop.serializer.batch.reader.UserInfoServiceScanReader.java
/** * Interface method implementation.Scans and retrieves a number of {@link UserInfo} instances looked up from a service end-point. The scan stops once no more * data is returned by the service endpoint. * Note : The end-point and parameters used here are very specific to this sample. Also the code is mostly for testing and production * ready (no Http connection pools etc.) * @see org.springframework.batch.item.ItemReader#read() *//*from w w w . ja v a 2 s . co m*/ public UserInfo read() throws Exception, UnexpectedInputException, ParseException { // return data from local queue if available already synchronized (this) { // include the check for empty and remove in one synchronized block to avoid race conditions if (!this.localQueue.isEmpty()) { LOGGER.debug("Returning data from local cache. Cache size : " + this.localQueue.size()); return this.localQueue.poll(); } } parallelFetch.acquire(); int startIndex = 0; synchronized (this) { startIndex = resultCount += BATCH_SIZE; } if (this.resultCount < MAX_RESULTS) { DefaultHttpClient httpclient = new DefaultHttpClient(); HttpGet executionGet = new HttpGet(BATCH_SERVICE_URL); URIBuilder uriBuilder = new URIBuilder(executionGet.getURI()); uriBuilder.addParameter("start", String.valueOf(startIndex)); uriBuilder.addParameter("count", String.valueOf(BATCH_SIZE)); ((HttpRequestBase) executionGet).setURI(uriBuilder.build()); HttpResponse httpResponse = httpclient.execute(executionGet); String response = new String(EntityUtils.toByteArray(httpResponse.getEntity())); ScanResult scanResult = objectMapper.readValue(response, ScanResult.class); if (scanResult.getCount() <= 0) { parallelFetch.release(); return null; } LOGGER.info("Fetched User Info objects in range - Start : {}. Count : {}", startIndex, scanResult.getCount()); for (UserInfo userInfo : scanResult.getResponse()) { this.localQueue.add(userInfo); } } parallelFetch.release(); return this.localQueue.poll(); }
From source file:org.mitre.openid.connect.client.service.impl.ThirdPartyIssuerService.java
@Override public IssuerServiceResponse getIssuer(HttpServletRequest request) { // if the issuer is passed in, return that String iss = request.getParameter("iss"); if (!Strings.isNullOrEmpty(iss)) { if (!whitelist.isEmpty() && !whitelist.contains(iss)) { throw new AuthenticationServiceException( "Whitelist was nonempty, issuer was not in whitelist: " + iss); }/*from w w w.j a v a2 s .c o m*/ if (blacklist.contains(iss)) { throw new AuthenticationServiceException("Issuer was in blacklist: " + iss); } return new IssuerServiceResponse(iss, request.getParameter("login_hint"), request.getParameter("target_link_uri")); } else { try { // otherwise, need to forward to the account chooser String redirectUri = request.getRequestURL().toString(); URIBuilder builder = new URIBuilder(accountChooserUrl); builder.addParameter("redirect_uri", redirectUri); return new IssuerServiceResponse(builder.build().toString()); } catch (URISyntaxException e) { throw new AuthenticationServiceException("Account Chooser URL is not valid", e); } } }
From source file:org.apache.tika.parser.geo.topic.gazetteer.GeoGazetteerClient.java
/** * Calls API of lucene-geo-gazetteer to search location name in gazetteer. * @param locations List of locations to be searched in gazetteer * @return Map of input location strings to gazetteer locations */// w w w. j a va2s . com public Map<String, List<Location>> getLocations(List<String> locations) { HttpClient httpClient = new DefaultHttpClient(); try { URIBuilder uri = new URIBuilder(url + SEARCH_API); for (String loc : locations) { uri.addParameter(SEARCH_PARAM, loc); } HttpGet httpGet = new HttpGet(uri.build()); HttpResponse resp = httpClient.execute(httpGet); String respJson = IOUtils.toString(resp.getEntity().getContent(), Charsets.UTF_8); @SuppressWarnings("serial") Type typeDef = new TypeToken<Map<String, List<Location>>>() { }.getType(); return new Gson().fromJson(respJson, typeDef); } catch (Exception e) { LOG.error(e.getMessage(), e); } return null; }