/**
  * This function determines whether user can upload image or not. If the current profile being
  * viewed is owner's profile then user can upload image.
  *
  * @return boolean which determines whether to render upload html component or not.
  */
 public boolean getUploadRendered() {
   ProfileBean currenProfile = (ProfileBean) getSessionScope().get("currentProfile");
   ProfileBean ownerProfile = (ProfileBean) getSessionScope().get("ownerProfile");
   if (ownerProfile.getUserAuth().getUserId() != currenProfile.getUserAuth().getUserId())
     uploadRendered = false;
   return uploadRendered;
 }
 /**
  * This function is used whether delete component is visible or not.
  *
  * @return String
  */
 public String getDeleteAction() {
   ProfileBean currenProfile = (ProfileBean) getSessionScope().get("currentProfile");
   ProfileBean ownerProfile = (ProfileBean) getSessionScope().get("ownerProfile");
   // It checks if current profile is not the owner profile then delete action is not display.
   if (ownerProfile.getUserAuth().getUserId() != currenProfile.getUserAuth().getUserId())
     deleteAction = "false";
   return deleteAction;
 }
  /**
   * This function is used to delete album using deleteAlbum service.
   *
   * @return String
   */
  public String deleteAlbum() {

    try {
      IPerson person = (IPerson) ServiceLocator.getService("PersonSvc");
      ProfileBean profileBean = (ProfileBean) getSessionScope().get("currentProfile");
      int userId = profileBean.getUserAuth().getUserId();

      String imageId = (String) getRequestParam().get("imageId");

      person.deleteAlbum(Integer.parseInt(imageId));
    } catch (SysException e) {
      e.printStackTrace();
    }

    return "success";
  }
  /**
   * This function is used to fetch user album. It uses getPersonAlbum service to receive user
   * images.
   *
   * @return Collection which contains list of user images.
   */
  public Collection getUserAlbumList() {

    IPerson person;
    try {

      ProfileBean profileBean = (ProfileBean) getSessionScope().get("currentProfile");
      int userId = profileBean.getUserAuth().getUserId();

      person = (IPerson) ServiceLocator.getService("PersonSvc");
      List<UserAlbum> userAlbumList = (List<UserAlbum>) person.getPersonAlbum(userId);
      getSessionScope().put("userAlbumList", userAlbumList);

      return userAlbumList.get(0).getImage();
    } catch (SysException e) {
      e.printStackTrace();
    }

    return null;
  }