List of usage examples for org.apache.http.client.utils URIBuilder addParameter
public URIBuilder addParameter(final String param, final String value)
From source file:com.kurtraschke.wmata.gtfsrealtime.services.WMATAAPIService.java
public Routes downloadRouteList() throws WMATAAPIException { try {//w w w .ja v a 2 s .c o m URIBuilder b = new URIBuilder("http://api.wmata.com/Bus.svc/json/JRoutes"); b.addParameter(API_KEY_PARAM_NAME, _apiKey); return mapUrl(b.build(), true, Routes.class, _jsonMapper); } catch (Exception e) { throw new WMATAAPIException(e); } }
From source file:com.sheepdog.mashmesh.PickupNotification.java
private URI createStaticMapUri(String overviewPolyline) throws URISyntaxException { URIBuilder uriBuilder = new URIBuilder(STATIC_MAPS_ENDPOINT_URL); uriBuilder.addParameter("sensor", "false"); uriBuilder.addParameter("key", ApplicationConfiguration.getApiKey()); uriBuilder.addParameter("size", "600x400"); uriBuilder.addParameter("markers", "color:green|label:A|" + itinerary.getStartLatLng()); uriBuilder.addParameter("markers", "color:blue|label:B|" + itinerary.getPickupLatLng()); uriBuilder.addParameter("markers", "color:blue|label:C|" + itinerary.getEndLatLng()); uriBuilder.addParameter("language", "en_US"); uriBuilder.addParameter("maptype", "roadmap"); if (!overviewPolyline.isEmpty()) { uriBuilder.addParameter("path", "weight:4|color:blue|enc:" + overviewPolyline); }// ww w.j a v a2 s .com return uriBuilder.build(); }
From source file:org.eclipse.packagedrone.testing.server.channel.UploadApiV2Test.java
@Test public void upload1() throws URISyntaxException, IOException { final ChannelTester tester = getTester(); final File file = getAbsolutePath(CommonResources.BUNDLE_1_RESOURCE); final URIBuilder b = new URIBuilder( resolve("/api/v2/upload/channel/%s/%s", tester.getId(), file.getName())); b.setUserInfo("deploy", this.deployKey); b.addParameter("foo:bar", "baz"); try (final CloseableHttpResponse response = upload(b, file)) { Assert.assertEquals(200, response.getStatusLine().getStatusCode()); }/*from w ww.j a v a 2s . c om*/ final Set<String> arts = tester.getAllArtifactIds(); Assert.assertEquals(1, arts.size()); }
From source file:com.cloud.utils.rest.HttpUriRequestBuilder.java
private URI buildUri() { try {/* w w w . j ava2 s.c om*/ final URIBuilder builder = new URIBuilder().setPath(path); for (final Map.Entry<String, String> entry : parameters.entrySet()) { builder.addParameter(entry.getKey(), entry.getValue()); } return builder.build(); } catch (final URISyntaxException e) { throw new IllegalArgumentException("Unable to build REST Service URI", e); } }
From source file:org.emmanet.util.Filter.java
/** * Generates a query string for use in an HTTP GET request from this <code>Filter * </code> instance. Returns an empty string if this filter instance has no * parameters.//from ww w .j a v a 2s .c o m * * @return a query string for use in an HTTP GET request. */ public String generateQueryString() { URIBuilder builder = new URIBuilder(); if (!geneId.isEmpty()) builder.addParameter("geneId", geneId); if (!geneName.isEmpty()) builder.addParameter("geneName", geneName); if (!geneSymbol.isEmpty()) builder.addParameter("geneSymbol", geneSymbol); if (!chromosome.isEmpty()) builder.addParameter("chromosome", chromosome); if (!mgiReference.isEmpty()) builder.addParameter("mgiReference", mgiReference); if (!alleleId.isEmpty()) builder.addParameter("alleleId", alleleId); if (!alleleName.isEmpty()) builder.addParameter("alleleName", alleleName); if (!alleleSymbol.isEmpty()) builder.addParameter("alleleSymbol", alleleSymbol); String query = ""; try { query = builder.build().getQuery(); } catch (URISyntaxException e) { } return query; }
From source file:org.mitre.openid.connect.client.service.impl.EncryptedAuthRequestUrlBuilder.java
@Override public String buildAuthRequestUrl(ServerConfiguration serverConfig, RegisteredClient clientConfig, String redirectUri, String nonce, String state, Map<String, String> options, String loginHint) { // create our signed JWT for the request object JWTClaimsSet.Builder claims = new JWTClaimsSet.Builder(); //set parameters to JwtClaims claims.claim("response_type", "code"); claims.claim("client_id", clientConfig.getClientId()); claims.claim("scope", Joiner.on(" ").join(clientConfig.getScope())); // build our redirect URI claims.claim("redirect_uri", redirectUri); // this comes back in the id token claims.claim("nonce", nonce); // this comes back in the auth request return claims.claim("state", state); // Optional parameters for (Entry<String, String> option : options.entrySet()) { claims.claim(option.getKey(), option.getValue()); }/* ww w . jav a2 s. c o m*/ // if there's a login hint, send it if (!Strings.isNullOrEmpty(loginHint)) { claims.claim("login_hint", loginHint); } EncryptedJWT jwt = new EncryptedJWT(new JWEHeader(alg, enc), claims.build()); JWTEncryptionAndDecryptionService encryptor = encrypterService.getEncrypter(serverConfig.getJwksUri()); encryptor.encryptJwt(jwt); try { URIBuilder uriBuilder = new URIBuilder(serverConfig.getAuthorizationEndpointUri()); uriBuilder.addParameter("request", jwt.serialize()); // build out the URI return uriBuilder.build().toString(); } catch (URISyntaxException e) { throw new AuthenticationServiceException("Malformed Authorization Endpoint Uri", e); } }
From source file:org.talend.dataprep.api.service.command.dataset.CloneDataSet.java
/** * Constructor./*from w w w .j a va2s . c o m*/ * * @param dataSetId the requested dataset id. * @param folderPath the folder to clone the dataset * @param cloneName the cloned name */ public CloneDataSet(String dataSetId, String folderPath, String cloneName) { super(GenericCommand.DATASET_GROUP); execute(() -> { try { URIBuilder uriBuilder = new URIBuilder(datasetServiceUrl + "/datasets/clone/" + dataSetId); if (StringUtils.isNotEmpty(folderPath)) { uriBuilder.addParameter("folderPath", folderPath); } if (StringUtils.isNotEmpty(cloneName)) { uriBuilder.addParameter("cloneName", cloneName); } return new HttpPut(uriBuilder.build()); } catch (URISyntaxException e) { throw new TDPException(CommonErrorCodes.UNEXPECTED_EXCEPTION, e); } }); onError(e -> new TDPException(APIErrorCodes.UNABLE_TO_COPY_DATASET_CONTENT, e, ExceptionContext.build().put("id", dataSetId))); on(HttpStatus.OK, HttpStatus.BAD_REQUEST).then((httpRequestBase, httpResponse) -> { try { // we transfer status code and content type return new HttpResponse(httpResponse.getStatusLine().getStatusCode(), // IOUtils.toString(httpResponse.getEntity().getContent()), // httpResponse.getStatusLine().getStatusCode() == HttpStatus.BAD_REQUEST.value() ? // APPLICATION_JSON_VALUE : TEXT_PLAIN_VALUE); } catch (IOException e) { throw new TDPException(CommonErrorCodes.UNEXPECTED_EXCEPTION, e); } finally { httpRequestBase.releaseConnection(); } }); }
From source file:com.kurtraschke.wmata.gtfsrealtime.services.WMATAAPIService.java
public BusPositions downloadBusPositions() throws WMATAAPIException { try {/*w w w . j a v a 2s .c o m*/ URIBuilder b = new URIBuilder("http://api.wmata.com/Bus.svc/json/JBusPositions"); b.addParameter(API_KEY_PARAM_NAME, _apiKey); return mapUrl(b.build(), false, BusPositions.class, _jsonMapper); } catch (Exception e) { throw new WMATAAPIException(e); } }
From source file:com.revo.deployr.client.core.impl.RRepositoryFileImpl.java
public InputStream download() throws RClientException, RSecurityException { try {/* www. ja v a 2s . com*/ String urlBase = liveContext.serverurl + REndpoints.RREPOSITORYFILEDOWNLOAD; String urlPath = urlBase + ";jsessionid=" + liveContext.httpcookie; URIBuilder builder = new URIBuilder(urlPath); builder.addParameter("filename", this.about.filename); builder.addParameter("directory", this.about.directory); builder.addParameter("author", this.about.author); builder.addParameter("version", this.about.version); return liveContext.executor.download(builder); } catch (Exception ex) { throw new RClientException("Download failed: " + ex.getMessage()); } }
From source file:com.kurtraschke.wmata.gtfsrealtime.services.WMATAAPIService.java
public RouteSchedule downloadRouteScheduleInfo(String routeId, String date) throws WMATAAPIException { try {/* w w w. j a v a2 s . co m*/ URIBuilder b = new URIBuilder("http://api.wmata.com/Bus.svc/json/JRouteSchedule"); b.addParameter(API_KEY_PARAM_NAME, _apiKey); b.addParameter("includeVariations", "false"); b.addParameter("date", date); b.addParameter("routeID", routeId); return mapUrl(b.build(), true, RouteSchedule.class, _jsonMapper); } catch (Exception e) { throw new WMATAAPIException(e); } }