Package org.opensocial

Examples of org.opensocial.Request


    Client client = new Client(new OrkutSandboxProvider(useRest),
        new OAuth2LeggedScheme(ORKUT_KEY, ORKUT_SECRET, ORKUT_ID));

    try {
      Request request = AppDataService.updateAppData("key", randomValue);
      client.send(request);
    } catch (Exception e) {
      fail("Exception occurred while processing update request");
    }

    try {
      Request request = AppDataService.getAppData();
      Response response = client.send(request);

      AppData data = response.getEntry();
      assertTrue(data.getDataForUser(ORKUT_ID, "key").equals(randomValue));
    } catch (Exception e) {
      fail("Exception occurred while processing retrieve request");
    }

    try {
      Request request = AppDataService.deleteAppData("key");
      client.send(request);
    } catch (Exception e) {
      fail("Exception occurred while processing delete request");
    }

    try {
      Request request = AppDataService.getAppData();
      Response response = client.send(request);

      AppData data = response.getEntry();
      assertTrue(data.hasField(ORKUT_ID));
      assertTrue(data.getDataForUser(ORKUT_ID, "key") == null);
View Full Code Here


    try {
      Map<String, String> data = new HashMap<String, String>();
      data.put("key1", randomValue1);
      data.put("key2", randomValue2);

      Request request = AppDataService.updateAppData(data);
      client.send(request);
    } catch (Exception e) {
      fail("Exception occurred while processing update request");
    }

    try {
      Request request = AppDataService.getAppData();
      Response response = client.send(request);

      AppData data = response.getEntry();
      assertTrue(data.getDataForUser(ORKUT_ID, "key1").equals(randomValue1));
      assertTrue(data.getDataForUser(ORKUT_ID, "key2").equals(randomValue2));
    } catch (Exception e) {
      fail("Exception occurred while processing retrieve request");
    }

    try {
      Request request = AppDataService.deleteAppData(
          new String[] {"key1", "key2"});
      client.send(request);
    } catch (Exception e) {
      fail("Exception occurred while processing delete request");
    }

    try {
      Request request = AppDataService.getAppData();
      Response response = client.send(request);

      AppData data = response.getEntry();
      assertTrue(data.hasField(ORKUT_ID));
      assertTrue(data.getDataForUser(ORKUT_ID, "key1") == null);
View Full Code Here

  @Test
  public void retrieve() {
    try {
      Client client = new Client(new MySpaceProvider(),
          new OAuth2LeggedScheme(MYSPACE_KEY, MYSPACE_SECRET, MYSPACE_ID));
      Request request = ProfileCommentsService.getComments();
      Response response = client.send(request);

      Comment comment = response.getEntry();
      assertTrue(comment.getId() != null);
      assertTrue(comment.getBody() != null);
View Full Code Here

   * @param  guid OpenSocial ID of user whose AppData is to be fetched
   * @return      new Request object to fetch the specified user's AppData
   * @see         AppData
   */
  public static Request getAppData(String guid) {
    Request request = new Request(restTemplate, "appdata.get", "GET");
    request.setModelClass(AppData.class);
    request.setSelector(SELF);
    request.setAppId(APP);
    request.setGuid(guid);

    return request;
  }
View Full Code Here

   * @return      new Request object to fetch the AppData for the specified
   *              user's friends
   * @see         AppData
   */
  public static Request getFriendAppData(String guid) {
    Request request = new Request(restTemplate, "appdata.get", "GET");
    request.setModelClass(AppData.class);
    request.setSelector(FRIENDS);
    request.setAppId(APP);
    request.setGuid(guid);

    return request;
  }
View Full Code Here

   *
   * @param  data Map of key/value pairs to be persisted in AppData
   * @return      new Request object to update the current viewer's AppData
   */
  public static Request updateAppData(Map<String, String> data) {
    Request request = new Request(restTemplate, "appdata.update", "PUT");
    request.setSelector(SELF);
    request.setAppId(APP);
    request.setGuid(VIEWER);

    // Add RPC payload parameters
    List<String> fields = new ArrayList<String>(data.size());
    for (Map.Entry<String, String> field : data.entrySet()) {
      fields.add(field.getKey());
    }

    request.addRpcPayloadParameter("data", data);
    request.addRpcPayloadParameter("fields", fields);

    // Add REST query string parameters
    StringBuilder fieldsBuilder = new StringBuilder();
    for (Map.Entry<String, String> datum : data.entrySet()) {
      if (fieldsBuilder.length() != 0) {
        fieldsBuilder.append(",");
      }
      fieldsBuilder.append(datum.getKey());
    }

    request.addRestQueryStringParameter("fields", fieldsBuilder.toString());

    // Add REST payload parameters
    for (Map.Entry<String, String> datum : data.entrySet()) {
      request.addRestPayloadParameter(datum.getKey(), datum.getValue());
    }

    return request;
  }
View Full Code Here

   * @param  keys List of AppData keys to delete
   * @return      new Request object to delete one or more keys in the current
   *              viewer's AppData
   */
  public static Request deleteAppData(List<String> keys) {
    Request request = new Request(restTemplate, "appdata.delete", "DELETE");
    request.setSelector(SELF);
    request.setAppId(APP);
    request.setGuid(ME);

    // Add RPC parameters
    request.addRpcPayloadParameter("fields", keys);

    // Add REST parameters
    StringBuilder fieldsBuilder = new StringBuilder();
    for (String key : keys) {
      if (fieldsBuilder.length() != 0) {
        fieldsBuilder.append(",");
      }
      fieldsBuilder.append(key);
    }

    request.addRestQueryStringParameter("fields", fieldsBuilder.toString());

    return request;
  }
View Full Code Here

   * @return         new Request object to fetch the current viewer's media
   *                 items
   * @see            MediaItem
   */
  public static Request getMediaItems(String albumId) {
    Request request = new Request(restTemplate, "mediaItems.get", "GET");
    request.setModelClass(MediaItem.class);
    request.addComponent(Request.ALBUM_ID, albumId);
    request.setGroupId(SELF);
    request.setGuid(ME);

    return request;
  }
View Full Code Here

   * @param  albumId ID of album containing media item to fetch
   * @return         new Request object to fetch the specified media item
   * @see            MediaItem
   */
  public static Request getMediaItem(String itemId, String albumId) {
    Request request = getMediaItems(albumId);
    request.addComponent(Request.ITEM_ID, itemId);

    return request;
  }
View Full Code Here

   * Returns a new Request instance which, when submitted, fetches all video
   * categories supported by the container and makes this data available as a
   * JSON array of JSON objects; currently works with MySpace only.
   */
  public static Request getSupportedVideoCategories() {
    Request request = new Request(restTemplate, null, "GET");
    request.addComponent(Request.ALBUM_ID, "@videos");
    request.addComponent(Request.ITEM_ID, "@supportedcategories");
    request.setGuid(ME);

    return request;
  }
View Full Code Here

TOP

Related Classes of org.opensocial.Request

Copyright © 2018 www.massapicom. 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.