Search in sources :

Example 21 with BasicNameValuePair

use of org.apache.http.message.BasicNameValuePair in project musiccabinet by hakko.

the class GroupWeeklyArtistChartClient method getWeeklyArtistChart.

public WSResponse getWeeklyArtistChart(LastFmGroup lastFmGroup) throws ApplicationException {
    WebserviceInvocation webserviceInvocation = new WebserviceInvocation(GROUP_WEEKLY_ARTIST_CHART, lastFmGroup);
    List<NameValuePair> params = getDefaultParameterList();
    params.add(new BasicNameValuePair(PARAM_METHOD, METHOD));
    params.add(new BasicNameValuePair(PARAM_GROUP, lastFmGroup.getName()));
    return executeWSRequest(webserviceInvocation, params);
}
Also used : BasicNameValuePair(org.apache.http.message.BasicNameValuePair) NameValuePair(org.apache.http.NameValuePair) BasicNameValuePair(org.apache.http.message.BasicNameValuePair) WebserviceInvocation(com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation)

Example 22 with BasicNameValuePair

use of org.apache.http.message.BasicNameValuePair in project musiccabinet by hakko.

the class RadioPlaylistClient method getRadioPlaylist.

public WSResponse getRadioPlaylist() throws ApplicationException {
    List<NameValuePair> params = getDefaultParameterList();
    params.add(new BasicNameValuePair(PARAM_METHOD, METHOD));
    params.add(new BasicNameValuePair(PARAM_SK, "5cd6b262eed1fcecc8752eb78eb1db78"));
    return executeWSRequest(null, params);
}
Also used : BasicNameValuePair(org.apache.http.message.BasicNameValuePair) NameValuePair(org.apache.http.NameValuePair) BasicNameValuePair(org.apache.http.message.BasicNameValuePair)

Example 23 with BasicNameValuePair

use of org.apache.http.message.BasicNameValuePair in project musiccabinet by hakko.

the class ScrobbleClient method scrobble.

public WSResponse scrobble(Scrobble scrobble) throws ApplicationException {
    List<NameValuePair> params = getDefaultParameterList();
    params.add(new BasicNameValuePair(PARAM_METHOD, METHOD));
    params.add(new BasicNameValuePair(PARAM_ARTIST, scrobble.getTrack().getMetaData().getArtist()));
    params.add(new BasicNameValuePair(PARAM_TRACK, scrobble.getTrack().getName()));
    params.add(new BasicNameValuePair(PARAM_TIMESTAMP, "" + (scrobble.getStartTime().getMillis() / 1000)));
    params.add(new BasicNameValuePair(PARAM_ALBUM, scrobble.getTrack().getMetaData().getAlbum()));
    params.add(new BasicNameValuePair(PARAM_SK, scrobble.getLastFmUser().getSessionKey()));
    return executeWSRequest(params);
}
Also used : BasicNameValuePair(org.apache.http.message.BasicNameValuePair) NameValuePair(org.apache.http.NameValuePair) BasicNameValuePair(org.apache.http.message.BasicNameValuePair)

Example 24 with BasicNameValuePair

use of org.apache.http.message.BasicNameValuePair in project musiccabinet by hakko.

the class ScrobbledTracksClient method getLibraryTracks.

public WSResponse getLibraryTracks(short page, String user) throws ApplicationException {
    WebserviceInvocation webserviceInvocation = new WebserviceInvocation(GET_SCROBBLED_TRACKS, page);
    List<NameValuePair> params = getDefaultParameterList();
    params.add(new BasicNameValuePair(PARAM_METHOD, METHOD));
    params.add(new BasicNameValuePair(PARAM_USER, user));
    params.add(new BasicNameValuePair(PARAM_PAGE, Short.toString(page)));
    params.add(new BasicNameValuePair(PARAM_LIMIT, LIMIT));
    return executeWSRequest(webserviceInvocation, params);
}
Also used : BasicNameValuePair(org.apache.http.message.BasicNameValuePair) NameValuePair(org.apache.http.NameValuePair) BasicNameValuePair(org.apache.http.message.BasicNameValuePair) WebserviceInvocation(com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation)

Example 25 with BasicNameValuePair

use of org.apache.http.message.BasicNameValuePair in project commons-gdx by gemserk.

the class RemoteVersionProviderTextPlainFileImpl method getLatestVersion.

@Override
public ApplicationVersion getLatestVersion(String currentVersionNumber) {
    try {
        HttpClient httpClient = new DefaultHttpClient();
        List<NameValuePair> params = new ArrayList<NameValuePair>();
        params.add(new BasicNameValuePair("currentVersion", currentVersionNumber));
        String encodedParams = URLEncodedUtils.format(params, "UTF-8");
        URI uri = URIUtils.resolve(versionUri, latestVersionKey + "?" + encodedParams);
        HttpGet httpget = new HttpGet(uri);
        if (logger.isDebugEnabled())
            logger.debug("Fetching latest version");
        HttpResponse response = httpClient.execute(httpget);
        StatusLine statusLine = response.getStatusLine();
        if (statusLine.getStatusCode() != HttpStatus.SC_OK)
            throw new RuntimeException("Failed to retrieve version: " + statusLine.toString());
        String contents = EntityUtils.toString(response.getEntity());
        if (logger.isDebugEnabled())
            logger.debug("Version text plain file contents: " + contents);
        String[] contentsLines = contents.split("[\n]+");
        if (contentsLines.length == 1) {
            String versionNumber = contentsLines[0];
            return new ApplicationVersionImpl(versionNumber);
        } else if (contentsLines.length > 1) {
            String versionNumber = contentsLines[0];
            String[] changeLog = new String[contentsLines.length - 1];
            System.arraycopy(contentsLines, 1, changeLog, 0, contentsLines.length - 1);
            return new ApplicationVersionImpl(versionNumber, changeLog);
        }
        throw new RuntimeException("Version text was empty, failed to build version");
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : BasicNameValuePair(org.apache.http.message.BasicNameValuePair) NameValuePair(org.apache.http.NameValuePair) HttpGet(org.apache.http.client.methods.HttpGet) ArrayList(java.util.ArrayList) HttpResponse(org.apache.http.HttpResponse) URI(java.net.URI) DefaultHttpClient(org.apache.http.impl.client.DefaultHttpClient) URISyntaxException(java.net.URISyntaxException) StatusLine(org.apache.http.StatusLine) DefaultHttpClient(org.apache.http.impl.client.DefaultHttpClient) HttpClient(org.apache.http.client.HttpClient) BasicNameValuePair(org.apache.http.message.BasicNameValuePair)

Aggregations

BasicNameValuePair (org.apache.http.message.BasicNameValuePair)289 NameValuePair (org.apache.http.NameValuePair)199 ArrayList (java.util.ArrayList)187 UrlEncodedFormEntity (org.apache.http.client.entity.UrlEncodedFormEntity)101 HttpPost (org.apache.http.client.methods.HttpPost)87 HttpResponse (org.apache.http.HttpResponse)77 HttpEntity (org.apache.http.HttpEntity)58 IOException (java.io.IOException)55 DefaultHttpClient (org.apache.http.impl.client.DefaultHttpClient)33 Test (org.junit.Test)32 HttpGet (org.apache.http.client.methods.HttpGet)29 ClientProtocolException (org.apache.http.client.ClientProtocolException)28 CSVReader (com.talend.csv.CSVReader)27 HttpClient (org.apache.http.client.HttpClient)25 UnsupportedEncodingException (java.io.UnsupportedEncodingException)23 HashMap (java.util.HashMap)20 JSONObject (org.json.JSONObject)20 Map (java.util.Map)19 URI (java.net.URI)16 WebserviceInvocation (com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation)15