Package javax.ws.rs.core

Examples of javax.ws.rs.core.UriBuilder.scheme()


            Domain domain = habitat.getComponent(Domain.class);
            String forwardInstanceName = extractTargetInstanceName(sourceUriInfo);
            Server forwardInstance = domain.getServerNamed(forwardInstanceName);
            if (forwardInstance != null) {
                UriBuilder forwardUriBuilder = constructForwardURLPath(sourceUriInfo);
                URI forwardURI = forwardUriBuilder.scheme("https").host(forwardInstance.getAdminHost()).port(forwardInstance.getAdminPort()).build(); //Host and Port are replaced to that of forwardInstanceName
                Client client = Util.getJerseyClient(habitat);
                WebResource.Builder resourceBuilder = client.resource(forwardURI).accept(MediaType.APPLICATION_JSON);
                ClientResponse response = resourceBuilder.get(ClientResponse.class); //TODO if the target server is down, we get ClientResponseException. Need to handle it
                ClientResponse.Status status = ClientResponse.Status.fromStatusCode(response.getStatus());
                if (status.getFamily() == javax.ws.rs.core.Response.Status.Family.SUCCESSFUL) {
View Full Code Here


            Domain domain = habitat.getService(Domain.class);
            String forwardInstanceName = extractTargetInstanceName(sourceUriInfo);
            Server forwardInstance = domain.getServerNamed(forwardInstanceName);
            if (forwardInstance != null) {
                UriBuilder forwardUriBuilder = constructForwardURLPath(sourceUriInfo);
                URI forwardURI = forwardUriBuilder.scheme("https").host(forwardInstance.getAdminHost()).port(forwardInstance.getAdminPort()).build(); //Host and Port are replaced to that of forwardInstanceName
                client = addAuthenticationInfo(client, forwardInstance, habitat);
                WebTarget resourceBuilder = client.target(forwardURI);
                Response response = resourceBuilder.request(MediaType.APPLICATION_JSON).get(Response.class); //TODO if the target server is down, we get ClientResponseException. Need to handle it
                Response.Status status = Response.Status.fromStatusCode(response.getStatus());
                if (status.getFamily() == javax.ws.rs.core.Response.Status.Family.SUCCESSFUL) {
View Full Code Here

public class UriBuilderImplTest extends TestCase {

    public void testUriBuilderSimple() {
        UriBuilder builder = new UriBuilderImpl();
        builder.scheme("http").host("localhost").port(8080);
        builder.segment("some", "path");
        builder.segment("matrix1");
        builder.matrixParam("a", "1");
        builder.matrixParam("b", "2");
        builder.segment("matrix2");
View Full Code Here

        assertEquals("?q3&q4=b4", uriString);
    }

    public void testSchemeSpecificPart() {
        UriBuilder builder = new UriBuilderImpl();
        builder.scheme("http");
        builder.fragment("frag");

        builder.schemeSpecificPart("//iamlegend.hp.com@localhost:80/path1/{var1}/path3");
        String uriStr = builder.build("path2").toString();
        assertEquals("http://iamlegend.hp.com@localhost:80/path1/path2/path3#frag", uriStr);
View Full Code Here

        assertEquals("//localhost:8080/some/path/pathEx/a+b/a+bc%2Bd#frag", uriString);
    }

    public void testUri() throws Exception {
        UriBuilder builder = new UriBuilderImpl();
        builder.scheme("http").host("localhost").port(80).segment("path1", "path2");
        builder.matrixParam("mat1", "{var1}", "v2");
        builder.fragment("fragment");
        URI uri = URI.create("http://iamlegend@remotehost:90/path3;mat2=v1/path4#this%20fragment");
        builder.uri(uri);
        String uriStr = builder.build().toString();
View Full Code Here

            UriBuilder.fromUri(new URI("ftp://ftp.ftpsite.site/files/file.txt"));
        uriBuilder = uriBuilder.uri(new URI("//%2F%2Fftp.ftpsite.site/files/file.txt"));
        assertEquals("ftp://ftp.ftpsite.site/files/file.txt", uriBuilder.build().toString());

        uriBuilder = UriBuilder.fromUri(new URI("ftp.ftpsite.site/files/file.txt"));
        uriBuilder = uriBuilder.scheme("ftp");
        uriBuilder = uriBuilder.uri(new URI("//%2F%2Fftp.ftpsite.site/files/file.txt"));
        assertEquals("ftp://ftp.ftpsite.site/files/file.txt", uriBuilder.build().toString());

        uriBuilder = UriBuilder.fromUri(new URI("mailto:ibmuser@ibm.com"));
        uriBuilder = uriBuilder.uri(new URI("ibmuser@ibm.com"));
View Full Code Here

        uriBuilder = UriBuilder.fromUri(new URI("mailto:ibmuser@ibm.com"));
        uriBuilder = uriBuilder.uri(new URI("ibmuser@ibm.com"));
        assertEquals("mailto:ibmuser@ibm.com", uriBuilder.build().toString());

        uriBuilder = UriBuilder.fromUri(new URI("ibmuser@ibm.com"));
        uriBuilder.scheme("mailto");
        uriBuilder = uriBuilder.uri(new URI("ibmuser@ibm.com"));
        assertEquals("mailto:ibmuser@ibm.com", uriBuilder.build().toString());

        uriBuilder = UriBuilder.fromUri(new URI("news:ibm.com"));
        uriBuilder = uriBuilder.uri(new URI("http://ibm.com"));
View Full Code Here

            .build().toString());
    }

    public void testClone() {
        UriBuilder builder1 = new UriBuilderImpl();
        builder1.scheme("http").host("localhost").port(80);
        builder1.segment("path1", "path2");
        builder1.matrixParam("mat1", "{var1}", "v2");
        builder1.queryParam("q1", "abc");
        builder1.fragment("fragment");
        UriBuilder builder2 = builder1.clone();
View Full Code Here

            Domain domain = habitat.getService(Domain.class);
            String forwardInstanceName = extractTargetInstanceName(sourceUriInfo);
            Server forwardInstance = domain.getServerNamed(forwardInstanceName);
            if (forwardInstance != null) {
                UriBuilder forwardUriBuilder = constructForwardURLPath(sourceUriInfo);
                URI forwardURI = forwardUriBuilder.scheme("https").host(forwardInstance.getAdminHost()).port(forwardInstance.getAdminPort()).build(); //Host and Port are replaced to that of forwardInstanceName
                WebTarget resourceBuilder = client.target(forwardURI);
                addAuthenticationInfo(client, resourceBuilder, forwardInstance, habitat);
                Response response = resourceBuilder.request(MediaType.APPLICATION_JSON).get(Response.class); //TODO if the target server is down, we get ClientResponseException. Need to handle it
                Response.Status status = Response.Status.fromStatusCode(response.getStatus());
                if (status.getFamily() == javax.ws.rs.core.Response.Status.Family.SUCCESSFUL) {
View Full Code Here

   @Test
   public void testNullHost()
   {
      UriBuilder builder = UriBuilder.fromUri("http://example.com/foo/bar");
      builder.scheme(null);
      builder.host(null);
      URI uri = builder.build();
      System.out.println(uri.toString());
      Assert.assertEquals(uri.toString(), "/foo/bar");
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.