List of usage examples for java.net URI toString
public String toString()
From source file:com.comcast.cats.configuration.StringsDMHandler.java
/** * To get default server location with host name. * //from ww w .j a v a 2 s . c o m * @param hostName * @return URI to the server. * @throws URISyntaxException */ protected URI getDefaultServerLocation(String hostName) throws URISyntaxException { URI uri = new URI("http://" + hostName + STRINGS_DM_SERVER_LOCATION); logger.info("Strings DM Server Location: " + uri.toString()); return uri; }
From source file:oracle.custom.ui.servlet.ConfigInputCheck.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.//w w w . j a v a 2s . c om * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { System.out.println("processing ConfigInputCheck request"); try { PrintWriter out = response.getWriter(); String whichform = request.getParameter("whichform"); String domain = request.getParameter("domain"); String idcsUrl = request.getParameter("idcsUrl"); String myUrl = request.getParameter("myUrl"); String clientId = request.getParameter("clientId"); String clientSecret = request.getParameter("clientSecret"); String appId = request.getParameter("appId"); String appSecret = request.getParameter("appSecret"); switch (whichform) { case "checkOpenID": OpenIdConfiguration openidConf = OpenIdConfiguration.getButDontSave(idcsUrl); URIBuilder builder = new URIBuilder(openidConf.getAuthzEndpoint()); builder.addParameter("client_id", clientId); builder.addParameter("response_type", "code"); builder.addParameter("redirect_uri", myUrl + "atreturn/"); builder.addParameter("scope", "urn:opc:idm:t.user.me openid urn:opc:idm:__myscopes__"); builder.addParameter("nonce", UUID.randomUUID().toString()); URI url = builder.build(); System.out.println("URL: " + url.toString()); // now go get it HttpClient client = ServerUtils.getClient(); HttpGet get = new HttpGet(url); HttpHost host = new HttpHost(url.getHost(), url.getPort(), url.getScheme()); HttpResponse httpResponse = client.execute(host, get); try { // IDCS behavior has changed. // older versions returned 303 with a Location: header // current version returns 200 with HTML if ((httpResponse.getStatusLine().getStatusCode() == 303) || (httpResponse.getStatusLine().getStatusCode() == 200)) { System.out.println("Request seems to have worked"); out.print("Success?"); } else throw new ServletException("Invalid status from OAuth AZ URL. Expected 303, got " + httpResponse.getStatusLine().getStatusCode()); } finally { if (response instanceof CloseableHttpResponse) { ((CloseableHttpResponse) response).close(); } } break; default: throw new Exception("Invalid request"); } } catch (Exception e) { e.printStackTrace(); throw new ServletException("Error."); } }
From source file:com.all.backend.web.util.TestHttpPostHelper.java
@Test public void shouldGetPost() throws Exception { String post = "http://192.168.1.2/openinviter/retrieveContacts.php? email=joseluisdelacruzmorales@hotmail.com&password=passwd&provider=hotmail"; HttpPost httpPost = httpPostHelper.get(post); URI uri = httpPost.getURI(); assertEquals(expectedPost, uri.toString()); }
From source file:cz.cvut.portal.kos.services.RestKOSapiService.java
public Course getCourse(String code, int detailLevel) { validateArgument(code);// w w w . j a va 2 s. c o m URI url = path(coursesGetUri).expand("code", code).queryParam("detail", detailLevel).build(); // pass as String to perform encoding Entry<Course> entry = rest.getForObject(url.toString(), Entry.class); return entry.getContent(); }
From source file:com.rightscale.provider.rest.DashboardSession.java
public HttpGet createGet(URI uri) { HttpGet get = new HttpGet(uri.toString()); get.addHeader("Host", uri.getAuthority()); get.addHeader("Accept", "application/json,text/json,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"); get.addHeader("User-Agent", "com.rightscale.provider"); get.addHeader("X-API-Version", "1.0"); return get;/*from ww w. ja v a 2s .c o m*/ }
From source file:se.vgregion.pubsub.push.repository.jpa.JpaPolledPublisherRepository.java
@Override public PolledPublisher findByUrl(URI url) { try {//w ww.j a v a 2s. c o m return (PolledPublisher) entityManager .createQuery("select l from " + type.getName() + " l " + "where l.url = :url") .setParameter("url", url.toString()).getSingleResult(); } catch (NoResultException e) { return null; } }
From source file:org.nekorp.workflow.desktop.data.access.rest.CustomerDAOImp.java
@Override public void guardar(Customer dato) { try {// www.j a v a 2 s . co m if (dato.getId() == null) { URI resource = factory.getTemplate().postForLocation(factory.getRootUlr() + "/customer", dato); String[] uri = StringUtils.split(resource.toString(), '/'); String id = uri[uri.length - 1]; CustomerPojo datoPjo = (CustomerPojo) dato; datoPjo.setId(Long.valueOf(id)); } else { Map<String, Object> map = new HashMap<>(); map.put("id", dato.getId()); factory.getTemplate().postForLocation(factory.getRootUlr() + "/customer/{id}", dato, map); } } catch (HttpStatusCodeException ex) { try { BasicErrorMessage errorObj = objectMapper.readValue(ex.getResponseBodyAsString(), BasicErrorMessage.class); CustomerDAOImp.LOGGER.error("error msg: " + Arrays.toString(errorObj.getMessage())); } catch (Exception exd) { CustomerDAOImp.LOGGER.error(exd); } throw ex; } }
From source file:gr.upatras.ece.nam.baker.fiware.OAuthClientManager.java
public URI getAuthorizationServiceURI(URI redirectUri, /* state */String reservationRequestKey) { String scope = null;//from w ww . j a v a2 s. co m return OAuthClientUtils.getAuthorizationURI(authorizationServiceURI, consumer.getKey(), redirectUri.toString(), reservationRequestKey, scope); }
From source file:no.api.meteo.client.DefaultMeteoClient.java
@Override public MeteoResponse fetchContent(URI uri) throws MeteoClientException { log.debug("Going to fetch content from : %", uri.toString()); CloseableHttpClient client = createClient(); CloseableHttpResponse response = null; try {/*ww w . j av a 2s . com*/ response = client.execute(prepareHttpGet(uri)); validateResponse(response); return handleEntity(uri, response); } catch (IOException e) { throw new MeteoClientException("Got IOException while fetching content for: " + uri.toString(), e); } finally { closeResponse(response); closeClient(client); } }
From source file:org.coffeebreaks.validators.w3c.W3cMarkupValidator.java
public ValidationResult validateUri(URI uri, ValidationRequest request) throws IOException { return validateW3cMarkup("uri", uri.toString(), true); }