/**
   * Return a (filtered) list of profiles
   *
   * @param filter if not null, filter the results by full name (name and surname)
   * @param token an user or client access token
   * @return a list of basic profile
   * @throws ProfileServiceException
   */
  public List<BasicProfile> getBasicProfiles(String filter, String token)
      throws SecurityException, ProfileServiceException {
    String query = null;
    if (filter != null) {
      try {
        query = "?filter=" + URLEncoder.encode(filter == null ? "" : filter, "utf8");
      } catch (UnsupportedEncodingException e1) {
        throw new ProfileServiceException(e1);
      }
    } else {
      query = "";
    }

    String json;
    try {
      json = RemoteConnector.getJSON(profileManagerURL, BASIC_PROFILE + ALL + query, token);
    } catch (RemoteException e1) {
      throw new ProfileServiceException(e1);
    }

    try {
      return JsonUtils.toObject(json, BasicProfiles.class).getProfiles();
    } catch (Exception e) {
      return Collections.emptyList();
    }
  }
 /**
  * Return the basic profile associated to the access token owner
  *
  * @param token a user access token
  * @return a basic profile
  * @throws ProfileServiceException
  */
 public BasicProfile getBasicProfile(String token)
     throws SecurityException, ProfileServiceException {
   try {
     String json = RemoteConnector.getJSON(profileManagerURL, BASIC_PROFILE + "me", token);
     return JsonUtils.toObject(json, BasicProfile.class);
   } catch (RemoteException e) {
     throw new ProfileServiceException(e);
   }
 }
 /**
  * Returns the list of basic profiles of a list of users
  *
  * @param userIds
  * @param token a user or client access token
  * @return
  * @throws ProfileServiceException
  */
 public List<BasicProfile> getBasicProfilesByUserId(List<String> userIds, String token)
     throws ProfileServiceException {
   Map<String, Object> parameters = new HashMap<String, Object>();
   parameters.put("userIds", userIds);
   try {
     String json =
         RemoteConnector.getJSON(profileManagerURL, BASIC_PROFILE + "profiles", token, parameters);
     return JsonUtils.toObject(json, BasicProfiles.class).getProfiles();
   } catch (RemoteException e) {
     throw new ProfileServiceException(e);
   }
 }
 /**
  * Returns the list of account profiles of a list of users
  *
  * @param userIds
  * @param token a user or client access token
  * @return
  * @throws ProfileServiceException
  */
 public List<AccountProfile> getAccountProfilesByUserId(List<String> userIds, String token)
     throws ProfileServiceException {
   Map<String, Object> parameters = new HashMap<String, Object>();
   parameters.put("userIds", userIds);
   try {
     String json =
         RemoteConnector.getJSON(
             profileManagerURL, ACCOUNT_PROFILE + "profiles", token, parameters);
     Map<String, Object> map = JsonUtils.toObject(json, Map.class);
     List<Object> list = (List<Object>) map.get("profiles");
     List<AccountProfile> profiles = new ArrayList<AccountProfile>();
     if (list != null) {
       for (Object o : list) {
         profiles.add(AccountProfile.valueOf((Map) o));
       }
     }
     return profiles;
   } catch (RemoteException e) {
     throw new ProfileServiceException(e);
   }
 }