Package com.sun.jersey.api.client

Examples of com.sun.jersey.api.client.Client.addFilter()


    }

    private Client client() {
        Client client = Client.create();
        if (username != null) {
            client.addFilter(new HTTPBasicAuthFilter(username, password));
        }
        return client;
    }

}
View Full Code Here


        if (!hostMap.containsKey(host)) {
            ClientConfig clientConfig = new DefaultClientConfig();
            clientConfig.getClasses().add(MultiPartWriter.class);
            Client client = Client.create(clientConfig);
            if (isDebug) {
                client.addFilter(new LoggingFilter());
            }
            hostMap.put(host, client);
        }
        return hostMap.get(host);
    }
View Full Code Here

    }
  }
 
  protected void lookup(int duration, String fingerprint) {
    Client client = Client.create();
    client.addFilter(new LoggingFilter(System.out));
    client.addFilter(new GZIPContentEncodingFilter(true));
    WebResource webResource = client.resource(this.ACOUSTID_SERVICE_URL);
   
// DONE: convert this (parameter in url) to form encoded post
//    JSONObject object = webResource.queryParam("client", SERVICE_KEY)
View Full Code Here

  }
 
  protected void lookup(int duration, String fingerprint) {
    Client client = Client.create();
    client.addFilter(new LoggingFilter(System.out));
    client.addFilter(new GZIPContentEncodingFilter(true));
    WebResource webResource = client.resource(this.ACOUSTID_SERVICE_URL);
   
// DONE: convert this (parameter in url) to form encoded post
//    JSONObject object = webResource.queryParam("client", SERVICE_KEY)
//          .queryParam("duration", "341")
View Full Code Here

        try {
            JSONObject request = createRequest(offset, CHUNK_SIZE);
            Client c = Client.create();
            if (squeezeboxServerUsername != null && squeezeboxServerUsername.length() > 0) {
                if (squeezeboxServerPassword != null && squeezeboxServerPassword.length() > 0) {
                    c.addFilter(new HTTPBasicAuthFilter(squeezeboxServerUsername, squeezeboxServerPassword));
                } else if (squeezeboxServerPasswordHash != null && squeezeboxServerPasswordHash.length() > 0) {
                    c.addFilter(new HTTPBasicAuthFilter(squeezeboxServerUsername, squeezeboxServerPasswordHash));
                }
            }
            JSONObject response = null;
View Full Code Here

            Client c = Client.create();
            if (squeezeboxServerUsername != null && squeezeboxServerUsername.length() > 0) {
                if (squeezeboxServerPassword != null && squeezeboxServerPassword.length() > 0) {
                    c.addFilter(new HTTPBasicAuthFilter(squeezeboxServerUsername, squeezeboxServerPassword));
                } else if (squeezeboxServerPasswordHash != null && squeezeboxServerPasswordHash.length() > 0) {
                    c.addFilter(new HTTPBasicAuthFilter(squeezeboxServerUsername, squeezeboxServerPasswordHash));
                }
            }
            JSONObject response = null;
            if (squeezeboxServerPasswordHash != null && squeezeboxServerPasswordHash.length() > 0) {
                response = c.resource(SERVICE_URL).accept("application/json").header("X-Scanner", 1).post(JSONObject.class, request);
View Full Code Here

    private void importRelease(Map<String, List<String>> result, Map<String, String> artistCache, Map<String, String> personCache, Map<String, String> labelCache, Map<String, String> genreCache, Map<String, String> styleCache, String discogsReleaseId) throws ParserConfigurationException, IOException, SAXException {
//        String data = Client.create().resource("http://www.discogs.com/release/" + discogsReleaseId + "?f=xml&api_key=" + API_KEY).accept(MediaType.APPLICATION_XML).header("Accept-Encoding", "gzip").header("User-Agent",USER_AGENT).get(String.class);
// Logging version
      Client client = Client.create();
    client.addFilter(new LoggingFilter(System.out));
    WebResource webResource = client.resource("http://www.discogs.com/release/" + discogsReleaseId + "?f=xml&api_key=" + API_KEY);
    String data = webResource.accept(MediaType.APPLICATION_XML).header("Accept-Encoding", "gzip").header("User-Agent",USER_AGENT).get(String.class);
   
        Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream(data.getBytes()));
        NodeList releases = doc.getElementsByTagName("release");
View Full Code Here

    String url = "http://localhost:8080/pentaho";

    final ClientConfig config = new DefaultClientConfig();
    config.getProperties().put(ClientConfig.PROPERTY_FOLLOW_REDIRECTS, true);
    Client client = Client.create(config);
    client.addFilter(new HTTPBasicAuthFilter("joe", "password"));

    final WebResource resource = client.resource(url + "/api/repo/files/children?depth=-1&filter=*");
    final RepositoryFileTreeDto tree = resource.path("").accept(MediaType.APPLICATION_XML_TYPE).get(RepositoryFileTreeDto.class);

    printDebugInfo(tree);
View Full Code Here

     */
    private WebResource.Builder prepareClient(String additionalResourceUrl)
    {
      final Client client = Client.create();
        if (configuration.isAuthorisation()) {
            client.addFilter(new HTTPBasicAuthFilter(
                           configuration.getAdminUser(),
                           configuration.getAdminPassword()));
        }
        client.addFilter(new CsrfProtectionFilter());
        return client.resource(this.adminBaseUrl + additionalResourceUrl).accept(MediaType.APPLICATION_XML_TYPE);
View Full Code Here

        if (configuration.isAuthorisation()) {
            client.addFilter(new HTTPBasicAuthFilter(
                           configuration.getAdminUser(),
                           configuration.getAdminPassword()));
        }
        client.addFilter(new CsrfProtectionFilter());
        return client.resource(this.adminBaseUrl + additionalResourceUrl).accept(MediaType.APPLICATION_XML_TYPE);
    }
 
    private Map getResponseMap(ClientResponse response) throws ContainerException
    {
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.