Exemplo n.º 1
0
  /**
   * Edit the photos contained in the photoset.
   *
   * <p>This will replace the photos in the photoset with the photos in the array.
   *
   * @param photosetId the photoset to change.
   * @param photoId the ID of the primary photo.
   * @param photoList photos that the set should contain.
   * @throws Exception if there are any errors
   */
  public void editPhotos(String photosetId, String photoId, List<Photo> photoList)
      throws Exception {
    logger.info(
        "Executing editPhotos on photoset "
            + photosetId
            + ", using primary photo "
            + photoId
            + ", and "
            + photoList.size()
            + " photos.");
    //	RequestContext rc = FlickrHelper.getInstance().getRequestContext();
    //	PhotosetsInterface pi = FlickrHelper.getInstance().getPhotosetsInterface();
    //	pi.editPhotos(photosetId, photoId, photoIds);

    List<String> idList = new ArrayList<String>();
    for (Photo p : photoList) {
      idList.add(p.getPhotoId());
    }

    //	PhotosetsApi.getInstance().editPhotos(photosetId, photoId, idList);
    Response response =
        JinxFactory.getInstance().getPhotosetsApi().editPhotos(photosetId, photoId, idList);
    if (response.getCode() != 0) {
      throw new Exception(
          "Error editing photos. Code " + response.getCode() + ":" + response.getMessage());
    }
  }
Exemplo n.º 2
0
 /**
  * Adds the specified photo to the specified photoset.
  *
  * @param photosetId the id of the photoset to add the photo to.
  * @param photoId the id of the photo to add to the photoset.
  * @throws Exception if there are any errors.
  */
 public void addPhoto(String photosetId, String photoId) throws Exception {
   //	RequestContext rc = FlickrHelper.getInstance().getRequestContext();
   //	PhotosetsInterface pi = FlickrHelper.getInstance().getPhotosetsInterface();
   //	pi.addPhoto(photosetId, photoId);
   Response response = JinxFactory.getInstance().getPhotosetsApi().addPhoto(photosetId, photoId);
   if (response.getCode() != 0) {
     throw new Exception(
         "Unable to add photo. Code " + response.getCode() + ":" + response.getMessage());
   }
   //	PhotosetsApi.getInstance().addPhoto(photosetId, photoId);
 }
Exemplo n.º 3
0
  /**
   * Reorder photosets.
   *
   * @param photosetIdList
   * @throws Exception
   */
  public void orderSets(List<String> photosetIdList) throws Exception {
    logger.info("Reordering photosets.");
    //	RequestContext rc = FlickrHelper.getInstance().getRequestContext();
    //	PhotosetsInterface pi = FlickrHelper.getInstance().getPhotosetsInterface();
    //	pi.orderSets(photosetIds);

    //	PhotosetsApi.getInstance().orderSets(photosetIdList);
    Response response = JinxFactory.getInstance().getPhotosetsApi().orderSets(photosetIdList);
    if (response.getCode() != 0) {
      throw new Exception(
          "There was an error while ordering sets. Code "
              + response.getCode()
              + ":"
              + response.getMessage());
    }
  }
Exemplo n.º 4
0
  /**
   * Delete the specified photoset from Flickr.
   *
   * @param ssPhotoset the photoset to delete.
   * @throws Exception if there are any errors.
   */
  public void delete(SSPhotoset ssPhotoset) throws Exception {
    if (ssPhotoset == null) {
      throw new Exception("delete: PARAMETER CANNOT BE NULL.");
    }

    //	RequestContext rc = FlickrHelper.getInstance().getRequestContext();
    //	PhotosetsInterface pi = FlickrHelper.getInstance().getPhotosetsInterface();
    //	pi.delete(ssPhotoset.getId());
    //	PhotosetsApi.getInstance().delete(ssPhotoset.getId());
    Response response =
        JinxFactory.getInstance().getPhotosetsApi().delete(ssPhotoset.getPhotosetId());
    if (response.getCode() != 0) {
      throw new Exception(
          "Error deleting photoset. Code " + response.getCode() + ":" + response.getMessage());
    }
  }
Exemplo n.º 5
0
  /**
   * Edit the title and description of an existing set.
   *
   * @param ssPhotoset the photoset to edit
   * @throws Exception if there are any errors
   */
  public void editMeta(SSPhotoset ssPhotoset) throws Exception {
    //	RequestContext rc = FlickrHelper.getInstance().getRequestContext();
    //	PhotosetsInterface pi = FlickrHelper.getInstance().getPhotosetsInterface();
    //	pi.editMeta(ssPhotoset.getId(), ssPhotoset.getTitle(), ssPhotoset.getDescription());

    //	PhotosetsApi.getInstance().editMeta(ssPhotoset.getId(), ssPhotoset.getTitle(),
    // ssPhotoset.getDescription());
    Response response =
        JinxFactory.getInstance()
            .getPhotosetsApi()
            .editMeta(
                ssPhotoset.getPhotosetId(), ssPhotoset.getTitle(), ssPhotoset.getDescription());
    if (response.getCode() != 0) {
      throw new Exception(
          "There was an error while editing set. Code "
              + response.getCode()
              + ":"
              + response.getMessage());
    }
  }
Exemplo n.º 6
0
  /**
   * Remove the specified photo from the photoset.
   *
   * @param ssPhotoset the photoset to remove the photo from.
   * @param photoId the ID of the photo to be removed.
   * @throws Exception if there are any errors, or if either parameter is null.
   */
  public void removePhoto(SSPhotoset ssPhotoset, String photoId) throws Exception {
    if (ssPhotoset == null) {
      throw new Exception("removePhoto: PARAMETER CANNOT BE NULL.");
    }
    if (photoId == null) {
      throw new Exception("removePhoto: PHOTO CANNOT BE NULL.");
    }

    //	RequestContext rc = FlickrHelper.getInstance().getRequestContext();
    //	PhotosetsInterface pi = FlickrHelper.getInstance().getPhotosetsInterface();
    //	pi.removePhoto(ssPhotoset.getId(), photoId);
    //	PhotosetsApi.getInstance().removePhoto(ssPhotoset.getId(), photoId);
    Response response =
        JinxFactory.getInstance()
            .getPhotosetsApi()
            .removePhoto(ssPhotoset.getPhotosetId(), photoId);
    if (response.getCode() == 0) {
      logger.info("Photo " + photoId + " removed from set " + ssPhotoset.getPhotosetId());
    } else {
      throw new Exception(
          "Error removing photo. Code " + response.getCode() + ":" + response.getMessage());
    }
  }