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);
}
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);
}
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);
}
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);
}
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);
}
}
Aggregations