Class ImageConsumption

java.lang.Object
io.meeds.layout.model.ImageConsumption

public class ImageConsumption extends Object
The upload ids one layout write consumes: each id is claimed once while the call's description is applied, before any write, and stands in the layout as a placeholder until the attachments are saved and their URLs take its place. The object id of an image is the call's key prefix, the live page or site as the editor keys its attachments, then the element's storage id, or the upload id for an element the call creates.
  • Field Details

  • Constructor Details

    • ImageConsumption

      public ImageConsumption(String keyPrefix, Predicate<String> staged)
      Parameters:
      keyPrefix - the live page's or site's storage id, page_<id> or site_<id>
      staged - whether an upload id names a staged resource
  • Method Details

    • none

      public static ImageConsumption none()
      Returns:
      a consumption that accepts no upload id: the writers of a call that carries none
    • claim

      public String claim(String uploadId, String objectType, String elementStorageId, String path) throws org.exoplatform.commons.exception.ObjectNotFoundException
      Parameters:
      uploadId - the id the call gave
      objectType - the attachment object type of the background
      elementStorageId - the styled element's storage id, null for one the call creates
      path - the image block's path, named by the refusal of a blank id or of a call that takes no image
      Returns:
      the placeholder written in the layout until the URL is known
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException - when no staged resource has the id
    • getTargets

      public Map<String, ImageTarget> getTargets()
    • isEmpty

      public boolean isEmpty()
    • setUrl

      public void setUrl(String uploadId, String url)
    • resolve

      public String resolve(String value)
      Parameters:
      value - a stored image value
      Returns:
      the URL the placeholder stands for, the value itself otherwise
    • addAttached

      public void addAttached(AttachedImage image)
    • getAttached

      public List<AttachedImage> getAttached()