Package org.opensocial

Examples of org.opensocial.Request


    if (item.getAlbumId() == null || item.getAlbumId().equals("")) {
      throw new RequestException("Passed MediaItem object does not have " +
          "album_id property set");
    }

    Request request = new Request(restTemplate, "mediaItems.create", "POST");
    request.addComponent(Request.ALBUM_ID, item.getAlbumId());
    request.setGroupId(SELF);
    request.setGuid(ME);

    // Add REST payload parameters
    request.addRestPayloadParameters(item);

    return request;
  }
View Full Code Here


   * @throws IOException      if an I/O error occurs while reading the passed
   *                          file
   */
  public static Request uploadImage(MediaItem item, File content) throws
      RequestException, IOException {
    Request request = uploadMediaItem(item, content);

    // Add REST query string parameters
    request.addRestQueryStringParameter("type", "image");

    return request;
  }
View Full Code Here

   * @throws IOException      if an I/O error occurs while reading the passed
   *                          file
   */
  public static Request uploadVideo(MediaItem item, File content) throws
      RequestException, IOException {
    Request request = uploadMediaItem(item, content);

    // Add REST query string parameters
    request.addRestQueryStringParameter("type", "video");

    if (item.getCaption() != null) {
      request.addRestQueryStringParameter("caption", item.getCaption());
    }
    if (item.getDescription() != null) {
      request.addRestQueryStringParameter("description",
          item.getDescription());
    }
    if (item.hasField("msCategories")) {
      request.addRestQueryStringParameter("msCategories",
          item.getFieldAsString("msCategories"));
    }
    if (item.hasField("language")) {
      request.addRestQueryStringParameter("language",
          item.getFieldAsString("language"));
    }
    if (item.hasField("tags")) {
      request.addRestQueryStringParameter("tags",
          item.getFieldAsString("tags"));
    }

    return request;
  }
View Full Code Here

    if (item.getMimeType() == null || item.getMimeType().equals("")) {
      throw new RequestException("Passed MediaItem object does not have " +
          "mime_type property set");
    }

    Request request = new Request(restTemplate, "mediaItems.create", "POST");
    request.addComponent(Request.ALBUM_ID, item.getAlbumId());
    request.setGroupId(SELF);
    request.setGuid(ME);

    byte[] bytes = getBytes(content);
    if (bytes != null) {
      request.setCustomPayload(bytes);
      request.setContentType(item.getMimeType());
    }

    return request;
  }
View Full Code Here

    if (item.getAlbumId() == null || item.getAlbumId().equals("")) {
      throw new RequestException("Passed MediaItem object does not have " +
          "album_id property set");
    }

    Request request = new Request(restTemplate, "mediaItems.update", "PUT");
    request.addComponent(Request.ALBUM_ID, item.getAlbumId());
    request.addComponent(Request.ITEM_ID, item.getId());
    request.setGroupId(SELF);
    request.setGuid(ME);

    // Add REST payload parameters
    request.addRestPayloadParameters(item);

    return request;
  }
View Full Code Here

   * @param  itemId  ID of media item to delete
   * @param  albumId ID of album containing media item to delete
   * @return         new Request object to delete an existing media item
   */
  public static Request deleteMediaItem(String itemId, String albumId) {
    Request request = new Request(restTemplate, "mediaItems.delete", "DELETE");
    request.addComponent(Request.ALBUM_ID, albumId);
    request.addComponent(Request.ITEM_ID, itemId);
    request.setGroupId(SELF);
    request.setGuid(ME);

    return request;
  }
View Full Code Here

   *
   * @return new Request object to fetch the current viewer's albums
   * @see    Album
   */
  public static Request getAlbums() {
    Request request = new Request(restTemplate, "albums.get", "GET");
    request.setModelClass(Album.class);
    request.setGroupId(SELF);
    request.setGuid(ME);

    return request;
  }
View Full Code Here

   * @param  albumId ID of album to fetch
   * @return         new Request object to fetch the specified album
   * @see            Album
   */
  public static Request getAlbum(String albumId) {
    Request request = getAlbums();
    request.addComponent(Request.ALBUM_ID, albumId);

    return request;
  }
View Full Code Here

   * @param  album Album object specifying the album parameters to pass into
   *               the request; typically, caption and description are set
   * @return       new Request object to create a new album
   */
  public static Request createAlbum(Album album) {
    Request request = new Request(restTemplate, "albums.create", "POST");
    request.setGroupId(SELF);
    request.setGuid(ME);

    // Add REST payload parameters
    request.addRestPayloadParameters(album);

    return request;
  }
View Full Code Here

    if (album.getId() == null || album.getId().equals("")) {
      throw new RequestException("Passed Album object does not have ID " +
          "property set");
    }

    Request request = new Request(restTemplate, "albums.update", "PUT");
    request.addComponent(Request.ALBUM_ID, album.getId());
    request.setGroupId(SELF);
    request.setGuid(ME);

    // Add REST payload parameters
    request.addRestPayloadParameters(album);

    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.