Examples of resource()


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

                        offset = offset + trackList.getTracks().size();
                        request = createRequest(offset, CHUNK_SIZE);
                        if (squeezeboxServerPasswordHash != null && squeezeboxServerPasswordHash.length() > 0) {
                            response = c.resource(SERVICE_URL).accept("application/json").header("X-Scanner", 1).post(JSONObject.class, request);
                        } else {
                            response = c.resource(SERVICE_URL).accept("application/json").post(JSONObject.class, request);
                        }
                        trackList = mapper.readValue(response.getString("result"), TrackListData.class);
                    } else {
                        trackList = null;
                    }
View Full Code Here

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

        playlistUris.add("inbox");
        playlistUris.add("starred");

        try {
            System.out.println("Making call to: " + SERVICE_URL + "/playlists.json");
            JSONObject response = c.resource(SERVICE_URL + "/playlists.json").accept("application/json").get(JSONObject.class);
            try {
                JSONArray playlistArray = response.getJSONArray("playlists");
                for (int i = 0; i < playlistArray.length(); i++) {
                    try {
                        playlistUris.add(playlistArray.getJSONObject(i).getString("uri"));
View Full Code Here

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

                //TODO: Error handling ?
            }

            int noOfTracks = 0;
            for (String playlistUri : playlistUris) {
                response = c.resource(SERVICE_URL + "/" + playlistUri + "/playlists.json").accept("application/json").get(JSONObject.class);

                try {
                    SpotifyPlaylistData playlistData = mapper.readValue(response.toString(), SpotifyPlaylistData.class);
                    playlists.add(playlistData);
                    noOfTracks += playlistData.getTracks().size();
View Full Code Here

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

                                    track.getTags().add(new TagData(TagData.SPOTIFY_ARTIST_ID, artistData.getUri()));
                                }
                            }
                        } else {
                            //TODO: Remove this as soon as 2.2.7 of spotifyd has been officially released
                            response = c.resource(SERVICE_URL + "/" + trackData.getUri() + "/browse.json").accept("application/json").get(JSONObject.class);
                            try {
                                if (response.has("index") && !response.getString("index").equals("0")) {
                                    track.getTags().add(new TagData(TagData.TRACKNUM, response.getString("index")));
                                }
                                if (response.has("disc") && !response.getString("disc").equals("0")) {
View Full Code Here

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

    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");
        for (int i = 0; i < releases.getLength(); i++) {
View Full Code Here

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

  @Test
  public void testRegistration() throws JSONException, Exception {
    RegistrationResponse response;
    Client client = createTestClient();
    WebResource webResource = client.resource(AGENT_URL + "test/register");
    response = webResource.type(MediaType.APPLICATION_JSON)
        .post(RegistrationResponse.class, createDummyJSONRegister());
    Assert.assertEquals(RegistrationStatus.OK, response.getResponseStatus());
  }
View Full Code Here

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

  @Test
  public void testHeartbeat() throws JSONException, Exception {
    HeartBeatResponse response;
    Client client = createTestClient();
    WebResource webResource = client.resource(AGENT_URL + "test/heartbeat");
    response = webResource.type(MediaType.APPLICATION_JSON)
        .post(HeartBeatResponse.class, createDummyHeartBeat());
    assertEquals(response.getResponseId(), 0L);
  }
View Full Code Here

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

  }

  @Test
  public void testHeadURL() throws JSONException, Exception {
    Client client = createTestClient();
    WebResource webResource = client.resource(AGENT_URL);
    ClientResponse response = webResource.type(MediaType.APPLICATION_JSON)
                                         .head();
    assertEquals(200, response.getStatus());
  }
View Full Code Here

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

    } else {
      pattern = "http://localhost:%s/";
      url = String.format(pattern, configuration.getClientApiPort());
    }

    this.ambariWebResource = client.resource(url);

    //Install auth filters
    ClientFilter csrfFilter = new CsrfProtectionFilter("RequestSchedule");
    ClientFilter tokenFilter = new InternalTokenClientFilter(tokenStorage);
    ambariClient.addFilter(csrfFilter);
View Full Code Here

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

        if (!baseUrl.endsWith("/")) {
            baseUrl += "/";
        }
        Client client = Client.create(new DefaultClientConfig());
        setFalconTimeOut(client);
        service = client.resource(UriBuilder.fromUri(baseUrl).build());
        client.resource(UriBuilder.fromUri(baseUrl).build());

        // addHeaders();
    }
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.