List of usage examples for java.net URI toString
public String toString()
From source file:org.jboss.aerogear.test.api.auth.LoginRequest.java
public Session login() { URI authServerEndpointUri = KeycloakUriBuilder.fromUri(getAuthServerUrl().toExternalForm()) .path(ServiceUrlConstants.TOKEN_PATH).build("aerogear"); Session session = Session.newSession(authServerEndpointUri.toString()); // FIXME dont use Session here! Fire up our own RestAssured Response response = session.given().header(Utilities.Headers.acceptJson()) .formParam(OAuth2Constants.GRANT_TYPE, "password").formParam("username", username) .formParam("password", password).formParam(OAuth2Constants.CLIENT_ID, "unified-push-server-js") .post();//from w ww .j a va 2 s .co m if (response.statusCode() == HttpStatus.SC_OK) { try { AccessTokenResponse tokenResponse = JsonSerialization.readValue(response.asString(), AccessTokenResponse.class); return new Session(getUnifiedPushServerUrl(), tokenResponse); } catch (IOException ex) { throw new RuntimeException( "Unable to demarshall payload from login request to AccessTokenResponse model class.", ex); } } else { throw new UnexpectedResponseException(response, HttpStatus.SC_OK); } }
From source file:biz.dfch.j.clickatell.ClickatellClient.java
public CoverageResponse getCoverage(@NotNullable String recipient) throws URISyntaxException, IOException { URI uriCoverage = new URI(String.format(APICOVERAGE, recipient)); String response = Request.Get(uriCoverage.toString()).setHeader(headerApiVersion) .setHeader(headerContentType).setHeader(headerAccept).setHeader("Authorization", bearerToken) .execute().returnContent().asString(); ObjectMapper om = new ObjectMapper(); om.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, true); CoverageResponse coverageResponse = om.readValue(response, CoverageResponse.class); return coverageResponse; }
From source file:org.jvoicexml.callmanager.mmi.http.HttpETLProtocolAdapter.java
@Override public void sendMMIEvent(Object channel, Mmi mmi) throws IOException { try {//from w w w.j a v a2s. c om final URI source = server.getURI(); final LifeCycleEvent event = mmi.getLifeCycleEvent(); event.setSource(source.toString()); final String target = event.getTarget(); if (target == null) { LOGGER.error("unable to send MMI event '" + mmi + "'. No target."); return; } final JAXBContext ctx = JAXBContext.newInstance(Mmi.class); final Marshaller marshaller = ctx.createMarshaller(); final ByteArrayOutputStream out = new ByteArrayOutputStream(); marshaller.marshal(mmi, out); final URI uri = new URI(target); final HttpClient client = new DefaultHttpClient(); final HttpPost post = new HttpPost(uri); final HttpEntity entity = new StringEntity(out.toString(), ContentType.APPLICATION_XML); post.setEntity(entity); client.execute(post); LOGGER.info("sending " + mmi + " to '" + uri + "'"); } catch (JAXBException e) { throw new IOException(e.getMessage(), e); } catch (URISyntaxException e) { throw new IOException(e.getMessage(), e); } }
From source file:com.marklogic.contentpump.ContentWithFileNameWritable.java
@Override public Content getContent(Configuration conf, ContentCreateOptions options, String uri) { String[] collections = conf.getStrings(MarkLogicConstants.OUTPUT_COLLECTION); String collectionUri = null;/* w w w . ja v a 2 s. com*/ try { URI fileUri = new URI(null, null, null, 0, fileName, null, null); collectionUri = fileUri.toString(); } catch (URISyntaxException e) { LOG.error("Error parsing file name as URI " + fileName, e); } if (collections != null) { List<String> optionList = new ArrayList<String>(); Collections.addAll(optionList, collections); if (collectionUri != null) { optionList.add(collectionUri); } collections = optionList.toArray(new String[0]); for (int i = 0; i < collections.length; i++) { collections[i] = collections[i].trim(); } options.setCollections(collections); } else { String[] col = new String[1]; col[0] = collectionUri; options.setCollections(col); } Content content = null; if (value instanceof Text) { content = ContentFactory.newContent(uri, ((Text) value).toString(), options); } else if (value instanceof MarkLogicNode) { content = ContentFactory.newContent(uri, ((MarkLogicNode) value).get(), options); } else if (value instanceof BytesWritable) { content = ContentFactory.newContent(uri, ((BytesWritable) value).getBytes(), 0, ((BytesWritable) value).getLength(), options); } return content; }
From source file:org.peterbaldwin.client.android.delicious.WebPageTitleRequest.java
@Override public URI getLocationURI(HttpResponse response, HttpContext context) throws ProtocolException { URI location = super.getLocationURI(response, context); if (location != null) { mRedirectLocation = location.toString(); }/*w ww . jav a 2s . c o m*/ return location; }
From source file:com.marklogic.contentpump.ImportRecordReader.java
/** * Apply URI replace option, encode URI if specified, apply URI prefix and * suffix configuration options and set the result as DocumentURI key. * //from ww w.j av a 2s . co m * @param uri Source string of document URI. * @param line Line number in the source if applicable; 0 otherwise. * @param col Column number in the source if applicable; 0 otherwise. * @param encode Encode uri if set to true. * * @return true if key indicates the record is to be skipped; false * otherwise. */ protected boolean setKey(String uri, int line, int col, boolean encode) { if (key == null) { key = new DocumentURIWithSourceInfo(uri, srcId); } // apply prefix, suffix and replace for URI if (uri != null && !uri.isEmpty()) { uri = URIUtil.applyUriReplace(uri, conf); key.setSkipReason(""); if (encode) { try { URI uriObj = new URI(null, null, null, 0, uri, null, null); uri = uriObj.toString(); } catch (URISyntaxException e) { uri = null; key.setSkipReason(e.getMessage()); } } uri = URIUtil.applyPrefixSuffix(uri, conf); } else { key.setSkipReason("empty uri value"); } key.setUri(uri); key.setSrcId(srcId); key.setSubId(subId); key.setColNumber(col); key.setLineNumber(line); if (LOG.isTraceEnabled()) { LOG.trace("Set key: " + key); } return key.isSkip(); }
From source file:org.keycloak.admin.client.Keycloak.java
/** * Create a secure proxy based on an absolute URI. * All set up with appropriate token/*from w w w .j a va 2 s .c om*/ * * @param proxyClass * @param absoluteURI * @param <T> * @return */ public <T> T proxy(Class<T> proxyClass, URI absoluteURI) { List providers = new ArrayList(); providers.add(new BearerAuthFilter(tokenManager)); providers.add(new JacksonJaxbJsonProvider()); WebClient.create(absoluteURI.toString(), providers); return JAXRSClientFactory.fromClient(client, proxyClass); //return client.target(absoluteURI).register(new BearerAuthFilter(tokenManager)).proxy(proxyClass); }
From source file:main.java.miro.validator.fetcher.RsyncFetcher.java
private boolean pointsToFile(URI uri) { for (String suffix : new String[] { ".cer", ".mft", ".roa", ".crl", ".gbr" }) { if (uri.toString().endsWith(suffix)) return true; }/* ww w . j a va2s . co m*/ return false; }
From source file:org.yql4j.impl.HttpComponentsYqlClient.java
/** * Create the HTTP request to execute.//from ww w . ja va 2 s.c o m * * @param query * the query specification * @return the HTTP request */ protected HttpUriRequest createHttpRequest(YqlQuery query) { URI uri = query.toUri(); logger.debug("YQL query URL: " + uri.toString()); return new HttpGet(uri); }
From source file:net.oneandone.shared.artifactory.SearchByChecksumTest.java
/** * Test of buildSearchURI method, of class SearchByChecksum. *//*from ww w .ja v a 2s.co m*/ @Test public void testBuildSearchURI() { URI buildSearchURI = sut.buildSearchURI("foo", Sha1.valueOf("d70e4ec32cf9ee8124ceec983147efc361153180")); assertEquals("http://localhost/api/search/checksum?repos=foo&sha1=d70e4ec32cf9ee8124ceec983147efc361153180", buildSearchURI.toString()); }