/** Delete the main image and the thumbnail, and go to the "add image" screen. */
  private ResponseValues doDeleteThenEdit(VitroRequest vreq, Individual entity) {
    ImageUploadHelper helper =
        new ImageUploadHelper(fileStorage, vreq.getFullWebappDaoFactory(), getServletContext());

    helper.removeExistingImage(entity);

    return showAddImagePage(vreq, entity);
  }
  /** The user has specified how to crop the thumbnail. Crop it and attach it to the main image. */
  private ResponseValues doCreateThumbnail(VitroRequest vreq, Individual entity) {
    ImageUploadHelper helper =
        new ImageUploadHelper(fileStorage, vreq.getFullWebappDaoFactory(), getServletContext());

    try {
      CropRectangle crop = validateCropCoordinates(vreq);
      FileInfo newImage = helper.getNewImageInfo(vreq);
      FileInfo thumbnail = helper.generateThumbnail(crop, newImage);

      helper.removeExistingImage(entity);
      helper.storeImageFiles(entity, newImage, thumbnail);

      return showExitPage(vreq, entity);
    } catch (UserMistakeException e) {
      return showErrorMessage(vreq, entity, e.getMessage());
    }
  }
  /**
   * The user has selected their main image file. Remove any previous main image (and thumbnail),
   * and attach the new main image.
   */
  private ResponseValues doUploadImage(VitroRequest vreq, Individual entity) {
    ImageUploadHelper helper =
        new ImageUploadHelper(fileStorage, vreq.getFullWebappDaoFactory(), getServletContext());

    try {
      // Did they provide a file to upload? If not, show an error.
      FileItem fileItem = helper.validateImageFromRequest(vreq);

      // Put it in the file system, and store a reference in the session.
      FileInfo fileInfo = helper.storeNewImage(fileItem, vreq);

      // How big is the new image? If not big enough, show an error.
      Dimensions size = helper.getNewImageSize(fileInfo);

      // Go to the cropping page.
      return showCropImagePage(vreq, entity, fileInfo.getBytestreamAliasUrl(), size);
    } catch (UserMistakeException e) {
      return showErrorMessage(vreq, entity, e.getMessage());
    }
  }
 public ImageUploadPanel(String pId) {
   this(pId, ImageUploadHelper.getTemporaryDirPath());
 }