List of usage examples for java.net URI toString
public String toString()
From source file:api.BaiduFolkMusicApi.java
private URI getRequestUri(List<NameValuePair> parameters) { try {//from w w w. jav a2 s . c o m parameters.add(new BasicNameValuePair("errordetails", "1")); URIBuilder uriBuilder = new URIBuilder(this.apiInvokeAddress); uriBuilder.addParameters(parameters); URI uri = uriBuilder.build(); String uriStr = uri.toString(); System.out.println(uriStr); return uri; } catch (URISyntaxException ex) { Logger.getLogger(BaiduFolkMusicApi.class.getName()).log(Level.SEVERE, null, ex); } return null; }
From source file:client.ConfigServerClient.java
/** * Gets the data for a particular hostclass. * * @param hostclass the hostclass to lookup * @return the data for the hostclass//from w w w . j a va2s . c o m */ public F.Promise<HostclassOutput> getHostclassData(final String hostclass) { final URI uri = uri(String.format("/hostclass/%s", hostclass)); return WS.url(uri.toString()).get() .map(wsResponse -> YAML_MAPPER.readValue(wsResponse.getBody(), HostclassOutput.class)); }
From source file:org.yaoha.OsmNodeRetrieverTask.java
public void addTask(URI uri) { Log.d(OsmNodeRetrieverTask.class.getSimpleName(), "Added request: " + uri.toString()); synchronized (queue) { queue.add(uri);/* w ww . j ava 2 s. co m*/ } Log.d(OsmNodeRetrieverTask.class.getSimpleName(), "Queue holds " + queue.size() + " tasks"); }
From source file:com.easarrive.image.thumbor.executer.service.impl.SQSNotificationHandlerForThumbor.java
private String getAccessUrl(S3Object s3Object) throws Exception { S3ObjectInputStream s3ObjectInputStream = s3Object.getObjectContent(); HttpRequestBase httpRequestBase = s3ObjectInputStream.getHttpRequest(); URI uri = httpRequestBase.getURI(); String accessUrl = uri.toString(); return accessUrl; }
From source file:com.ironiacorp.http.impl.httpclient3.PostRequest.java
public HttpJob call() { URI uri = (URI) job.getUri(); PostMethod postMethod = new PostMethod(uri.toString()); HttpMethodResult result = new HttpMethodResult(); postMethod.setRequestBody(parameters.toArray(new NameValuePair[0])); try {//from w ww .jav a 2s . c om int statusCode = client.executeMethod(postMethod); if (statusCode != HttpStatus.SC_OK) { System.err.println("Method failed: " + postMethod.getStatusLine()); } InputStream inputStream = postMethod.getResponseBodyAsStream(); if (inputStream != null) { result.setContent(inputStream); result.setStatusCode(statusCode); job.setResult(result); } } catch (HttpException e) { } catch (IOException e) { // In case of an IOException the connection will be released // back to the connection manager automatically } catch (RuntimeException ex) { // In case of an unexpected exception you may want to abort // the HTTP request in order to shut down the underlying // connection and release it back to the connection manager. postMethod.abort(); } return job; }
From source file:es.upm.oeg.examples.watson.service.PersonalityInsightsService.java
public String analyse(String text) throws IOException, URISyntaxException { logger.info("Analyzing the text: \n" + text); URI profileURI = new URI(baseURL + "/v2/profile").normalize(); logger.info("Profile URI: " + profileURI.toString()); Request profileRequest = Request.Post(profileURI).addHeader("Accept", "application/json").bodyString(text, ContentType.TEXT_PLAIN);/*w ww .j a v a 2s . c om*/ Executor executor = Executor.newInstance().auth(username, password); Response response = executor.execute(profileRequest); HttpResponse httpResponse = response.returnResponse(); StatusLine statusLine = httpResponse.getStatusLine(); ByteArrayOutputStream os = new ByteArrayOutputStream(); httpResponse.getEntity().writeTo(os); String responseBody = new String(os.toByteArray()); if (statusLine.getStatusCode() == HttpStatus.SC_OK) { return responseBody; } else { String msg = String.format("Personality Insights Service failed - %d %s \n %s", statusLine.getStatusCode(), statusLine.getReasonPhrase(), response); logger.severe(msg); throw new RuntimeException(msg); } }
From source file:com.vmware.photon.controller.model.adapters.vsphere.ovf.OvfParserTest.java
/** * Test is ignore because it is slow./*from w w w . j a va 2s. c o m*/ * @throws IOException */ @Test @Ignore public void tarsAreDownloadedAndExtracted() throws IOException { HttpClient client = OvfRetriever.newInsecureClient(); OvfRetriever retriever = new OvfRetriever(client); String photonOs = "https://bintray.com/vmware/photon/download_file?file_path=photon-custom-hw10-1.0-13c08b6.ova"; URI ovfUri = retriever.downloadIfOva(URI.create(photonOs)); assertTrue(ovfUri.toString().endsWith("photon-custom-hw10.ovf")); }
From source file:de.shadowhunt.subversion.internal.httpv1.CheckoutOperation.java
@Override protected HttpUriRequest createRequest() { final Writer body = new StringBuilderWriter(); try {/* w ww . ja v a 2 s . c om*/ final XMLStreamWriter writer = XML_OUTPUT_FACTORY.createXMLStreamWriter(body); writer.writeStartDocument(XmlConstants.ENCODING, XmlConstants.VERSION_1_0); writer.writeStartElement("checkout"); writer.writeDefaultNamespace(XmlConstants.DAV_NAMESPACE); writer.writeStartElement("activity-set"); writer.writeStartElement("href"); final URI transactionURI = URIUtils.createURI(repository, transaction); writer.writeCData(transactionURI.toString()); writer.writeEndElement(); // href writer.writeEndElement(); // activity-set writer.writeEmptyElement("apply-to-version"); writer.writeEndElement(); //checkout writer.writeEndDocument(); writer.close(); } catch (final XMLStreamException e) { throw new SubversionException("could not create request body", e); } final URI uri = URIUtils.createURI(repository, resource); final DavTemplateRequest request = new DavTemplateRequest("CHECKOUT", uri); request.setEntity(new StringEntity(body.toString(), CONTENT_TYPE_XML)); return request; }
From source file:org.commonjava.aprox.dotmaven.settings.AbstractSettingsTest.java
protected final String getDotMavenUrl(final String path) throws URISyntaxException, MalformedURLException { final String mavdavPath = PathUtils.normalize("/../mavdav", path); System.out.println("Resolving dotMaven URL. Base URL: '" + client.getBaseUrl() + "'\ndotMaven path: '" + mavdavPath + "'"); final URI result = resolve(new URI(client.getBaseUrl()), new URI(mavdavPath)); System.out.println("Resulting URI: '" + result.toString() + "'"); final String url = result.toURL().toExternalForm(); System.out.println("Resulting URL: '" + url + "'"); return url;/* w w w . j a va 2 s .co m*/ }
From source file:org.metaservice.manager.blazegraph.FastRangeCountRequestBuilder.java
public MutationResult execute() throws ManagerException { try {/* w ww. ja v a 2 s . c o m*/ JAXBContext jaxbContext = JAXBContext.newInstance(MutationResult.class); URIBuilder uriBuilder = new URIBuilder(path); if (subject != null) { uriBuilder.setParameter("s", format(subject)); } if (object != null) { uriBuilder.setParameter("o", format(object)); } if (predicate != null) { uriBuilder.setParameter("p", format(predicate)); } if (context != null) { uriBuilder.setParameter("c", format(context)); } uriBuilder.addParameter("ESTCARD", null); URI uri = uriBuilder.build(); LOGGER.debug("QUERY = " + uri.toString()); String s = Request.Get(uri).connectTimeout(1000).socketTimeout(10000) .setHeader("Accept", "application/xml").execute().returnContent().asString(); LOGGER.debug("RESULT = " + s); return (MutationResult) jaxbContext.createUnmarshaller().unmarshal(new StringReader(s)); } catch (JAXBException | URISyntaxException | IOException e) { throw new ManagerException(e); } }