List of usage examples for org.apache.http.client.utils URIBuilder build
public URI build() throws URISyntaxException
From source file:hudson.plugins.jira.JiraRestService.java
public List<Component> getComponents(String projectKey) { final URIBuilder builder = new URIBuilder(uri) .setPath(String.format("%s/project/%s/components", baseApiPath, projectKey)); try {/*from ww w. j a v a 2 s . c o m*/ final Content content = buildGetRequest(builder.build()).execute().returnContent(); final List<Map<String, Object>> decoded = objectMapper.readValue(content.asString(), new TypeReference<List<Map<String, Object>>>() { }); final List<Component> components = new ArrayList<Component>(); for (final Map<String, Object> decodeComponent : decoded) { BasicUser lead = null; if (decodeComponent.containsKey("lead")) { final Map<String, Object> decodedLead = (Map<String, Object>) decodeComponent.get("lead"); lead = new BasicUser(URI.create((String) decodedLead.get("self")), (String) decodedLead.get("name"), (String) decodedLead.get("displayName")); } final Component component = new Component(URI.create((String) decodeComponent.get("self")), Long.parseLong((String) decodeComponent.get("id")), (String) decodeComponent.get("name"), (String) decodeComponent.get("description"), lead); components.add(component); } return components; } catch (Exception e) { LOGGER.log(WARNING, "jira rest client process workflow action error. cause: " + e.getMessage(), e); return Collections.emptyList(); } }
From source file:com.rackspacecloud.blueflood.outputs.handlers.HttpRollupHandlerWithESIntegrationTest.java
private URI getMetricsQueryURI(String metricName, String tenantid, long fromTimestamp) throws URISyntaxException { URIBuilder builder = new URIBuilder().setScheme("http").setHost("127.0.0.1").setPort(queryPort) .setPath("/v2.0/" + tenantid + "/views/" + metricName) .setParameter("from", String.valueOf(fromTimestamp)) .setParameter("to", String.valueOf(fromTimestamp + 86400000)).setParameter("resolution", "full"); return builder.build(); }
From source file:com.hp.octane.integrations.services.coverage.SonarServiceImpl.java
private String getWebhookKey(String ciNotificationUrl, String sonarURL, String token) throws SonarIntegrationException { try {/*w w w . j ava2 s .co m*/ URIBuilder uriBuilder = new URIBuilder(sonarURL + WEBHOOK_LIST_URI); HttpClient httpClient = HttpClientBuilder.create().build(); HttpGet request = new HttpGet(uriBuilder.build()); setTokenInHttpRequest(request, token); HttpResponse response = httpClient.execute(request); InputStream content = response.getEntity().getContent(); // if webhooks exist if (content.available() != 0) { JsonNode jsonResponse = CIPluginSDKUtils.getObjectMapper().readTree(content); if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { ArrayNode webhooksListJson = (ArrayNode) jsonResponse.get("webhooks"); if (webhooksListJson.size() > 0) { for (JsonNode webhookNode : webhooksListJson) { String entryURL = webhookNode.get("url").textValue(); if (entryURL.equals(ciNotificationUrl)) { return webhookNode.get("key").textValue(); } } } return null; } else { String errorMessage = "" .concat("failed to get webhook key from soanrqube with notification URL: ") .concat(ciNotificationUrl).concat(" with status code: ") .concat(String.valueOf(response.getStatusLine().getStatusCode())) .concat(" with errors: ").concat(jsonResponse.get("errors").toString()); throw new SonarIntegrationException(errorMessage); } } return null; } catch (SonarIntegrationException e) { logger.error(e.getMessage(), e); throw e; } catch (Exception e) { String errorMessage = "".concat("failed to get webhook key from soanrqube with notification URL: ") .concat(ciNotificationUrl); logger.error(errorMessage, e); throw new SonarIntegrationException(errorMessage, e); } }
From source file:org.talend.dataprep.api.service.command.preparation.PreparationMove.java
private HttpRequestBase onExecute(String id, String folder, String destination, String newName) { try {//from w ww . j a v a 2s. com URIBuilder uriBuilder = new URIBuilder(preparationServiceUrl + "/preparations/" + id + "/move"); if (StringUtils.isNotBlank(folder)) { uriBuilder.addParameter("folder", folder); } if (StringUtils.isNotBlank(destination)) { uriBuilder.addParameter("destination", destination); } if (StringUtils.isNotBlank(newName)) { uriBuilder.addParameter("newName", newName); } return new HttpPut(uriBuilder.build()); } catch (URISyntaxException e) { throw new TDPException(CommonErrorCodes.UNEXPECTED_EXCEPTION, e); } }
From source file:com.collective.celos.CelosClient.java
public void deleteRegistersWithPrefix(BucketID bucket, String prefix) throws Exception { URIBuilder uriBuilder = new URIBuilder(address); uriBuilder.setPath(uriBuilder.getPath() + REGISTER_PATH); uriBuilder.addParameter(BUCKET_PARAM, bucket.toString()); uriBuilder.addParameter(PREFIX_PARAM, prefix); executeDelete(uriBuilder.build()); }
From source file:com.amos.tool.SelfRedirectStrategy.java
/** * @since 4.1//from w w w .jav a2 s .c om */ protected URI createLocationURI(final String location) throws ProtocolException { System.out.println("redirect_location:" + location); try { final URIBuilder b = new URIBuilder(new URI(location).normalize()); final String host = b.getHost(); if (host != null) { b.setHost(host.toLowerCase(Locale.ENGLISH)); } final String path = b.getPath(); if (TextUtils.isEmpty(path)) { b.setPath("/"); } return b.build(); } catch (final URISyntaxException ex) { throw new ProtocolException("Invalid redirect URI: " + location, ex); } }
From source file:org.keycloak.broker.provider.util.SimpleHttp.java
private URI appendParameterToUrl(String url) throws IOException { URI uri = null;// w ww .ja v a 2 s .c o m try { URIBuilder uriBuilder = new URIBuilder(url); if (params != null) { for (Map.Entry<String, String> p : params.entrySet()) { uriBuilder.setParameter(p.getKey(), p.getValue()); } } uri = uriBuilder.build(); } catch (URISyntaxException e) { } return uri; }
From source file:com.collective.celos.CelosClient.java
public void setWorkflowPaused(WorkflowID workflowID, Boolean paused) throws Exception { URIBuilder uriBuilder = new URIBuilder(address); uriBuilder.setPath(uriBuilder.getPath() + PAUSE_PATH); uriBuilder.addParameter(ID_PARAM, workflowID.toString()); uriBuilder.addParameter(PAUSE_NODE, paused.toString()); executePost(uriBuilder.build()); }
From source file:com.collective.celos.CelosClient.java
/** * Sets the specified register value./* w ww .j ava 2 s. c o m*/ */ public void putRegister(BucketID bucket, RegisterKey key, JsonNode value) throws Exception { URIBuilder uriBuilder = new URIBuilder(address); uriBuilder.setPath(uriBuilder.getPath() + REGISTER_PATH); uriBuilder.addParameter(BUCKET_PARAM, bucket.toString()); uriBuilder.addParameter(KEY_PARAM, key.toString()); executePut(uriBuilder.build(), new StringEntity(Util.JSON_WRITER.writeValueAsString(value), StandardCharsets.UTF_8)); }