/** The individual has an image - go to the Replace Image page. */
 private TemplateResponseValues showReplaceImagePage(
     VitroRequest vreq, Individual entity, ImageInfo imageInfo) {
   String placeholderUrl = vreq.getParameter(PARAMETER_PLACEHOLDER_URL);
   TemplateResponseValues rv = new TemplateResponseValues(TEMPLATE_REPLACE);
   rv.put(BODY_THUMBNAIL_URL, UrlBuilder.getUrl(imageInfo.getThumbnail().getBytestreamAliasUrl()));
   rv.put(BODY_DELETE_URL, formAction(entity.getURI(), ACTION_DELETE_EDIT, placeholderUrl));
   rv.put(BODY_FORM_ACTION, formAction(entity.getURI(), ACTION_UPLOAD, placeholderUrl));
   rv.put(BODY_CANCEL_URL, exitPageUrl(vreq, entity.getURI()));
   rv.put(BODY_TITLE, "Replace image" + forName(entity));
   rv.put(BODY_MAX_FILE_SIZE, MAXIMUM_FILE_SIZE / (1024 * 1024));
   rv.put(BODY_THUMBNAIL_HEIGHT, THUMBNAIL_HEIGHT);
   rv.put(BODY_THUMBNAIL_WIDTH, THUMBNAIL_WIDTH);
   return rv;
 }
 /** We got their main image - go to the Crop Image page. */
 private TemplateResponseValues showCropImagePage(
     VitroRequest vreq, Individual entity, String imageUrl, Dimensions dimensions) {
   String placeholderUrl = vreq.getParameter(PARAMETER_PLACEHOLDER_URL);
   TemplateResponseValues rv = new TemplateResponseValues(TEMPLATE_CROP);
   rv.put(BODY_MAIN_IMAGE_URL, UrlBuilder.getUrl(imageUrl));
   rv.put(BODY_MAIN_IMAGE_HEIGHT, dimensions.height);
   rv.put(BODY_MAIN_IMAGE_WIDTH, dimensions.width);
   rv.put(BODY_FORM_ACTION, formAction(entity.getURI(), ACTION_SAVE, placeholderUrl));
   rv.put(BODY_CANCEL_URL, exitPageUrl(vreq, entity.getURI()));
   rv.put(BODY_TITLE, "Crop Photo" + forName(entity));
   return rv;
 }
  /**
   * The individual has no image - go to the Add Image page.
   *
   * @param entity if this is null, then all URLs lead to the welcome page.
   */
  private TemplateResponseValues showAddImagePage(VitroRequest vreq, Individual entity) {

    String placeholderUrl = vreq.getParameter(PARAMETER_PLACEHOLDER_URL);

    String formAction =
        (entity == null) ? "" : formAction(entity.getURI(), ACTION_UPLOAD, placeholderUrl);
    String cancelUrl = (entity == null) ? "" : exitPageUrl(vreq, entity.getURI());

    TemplateResponseValues rv = new TemplateResponseValues(TEMPLATE_NEW);

    rv.put(BODY_THUMBNAIL_URL, placeholderUrl);
    rv.put(BODY_FORM_ACTION, formAction);
    rv.put(BODY_CANCEL_URL, cancelUrl);
    rv.put(BODY_TITLE, "Upload image" + forName(entity));
    rv.put(BODY_MAX_FILE_SIZE, MAXIMUM_FILE_SIZE / (1024 * 1024));
    rv.put(BODY_THUMBNAIL_HEIGHT, THUMBNAIL_HEIGHT);
    rv.put(BODY_THUMBNAIL_WIDTH, THUMBNAIL_WIDTH);
    return rv;
  }
 /** The individual has an image, but the user did something wrong. */
 private TemplateResponseValues showReplaceImagePageWithError(
     VitroRequest vreq, Individual entity, ImageInfo imageInfo, String message) {
   TemplateResponseValues rv = showReplaceImagePage(vreq, entity, imageInfo);
   rv.put(BODY_ERROR_MESSAGE, message);
   return rv;
 }