Exemplo n.º 1
0
 /**
  * Get the metadata for an album on Last.fm using the album name or a musicbrainz id. See
  * playlist.fetch on how to get the album playlist.
  *
  * @param artist Artist's name
  * @param albumOrMbid Album name or MBID
  * @param username The username for the context of the request. If supplied, the user's playcount
  *     for this album is included in the response.
  * @param apiKey The API key
  * @return Album metadata
  */
 public static final Album getInfo(
     final Context context,
     final String artist,
     final String albumOrMbid,
     final String username,
     final String apiKey) {
   final Map<String, String> params = new HashMap<String, String>();
   params.put("artist", artist);
   params.put("album", albumOrMbid);
   MapUtilities.nullSafePut(params, "username", username);
   final Result result = Caller.getInstance(context).call("album.getInfo", apiKey, params);
   return ResponseBuilder.buildItem(result, Album.class);
 }
Exemplo n.º 2
0
  /**
   * Apply existing advices loaded into the NCubeManager, to the passed in n-cube. This allows
   * advices to be added first, and then let them be applied 'on demand' as an n-cube is loaded
   * later.
   *
   * @param appId ApplicationID
   * @param ncube NCube to which all matching advices will be applied.
   */
  private static void applyAdvices(ApplicationID appId, NCube ncube) {
    final Map<String, Advice> appAdvices = advices.get(appId);

    if (MapUtilities.isEmpty(appAdvices)) {
      return;
    }
    for (Map.Entry<String, Advice> entry : appAdvices.entrySet()) {
      final Advice advice = entry.getValue();
      final String wildcard = entry.getKey().replace(advice.getName() + '/', "");
      final String regex = StringUtilities.wildcardToRegexString(wildcard);
      final Axis axis = ncube.getAxis("method");
      addAdviceToMatchedCube(advice, regex, ncube, axis);
    }
  }