Class CMSMediaItem

java.lang.Object
io.goobi.viewer.model.cms.media.CMSMediaItem
All Implemented Interfaces:
BrowseElementInfo, Serializable, Comparable<CMSMediaItem>

@Entity public class CMSMediaItem extends Object implements BrowseElementInfo, Comparable<CMSMediaItem>, Serializable
Represents a media file (image, video, audio, or document) managed in the CMS media library.
See Also:
  • Field Details

    • CONTENT_TYPE_XML

      public static final String CONTENT_TYPE_XML
      Constant CONTENT_TYPE_XML="text/xml".
      See Also:
    • CONTENT_TYPE_SVG

      public static final String CONTENT_TYPE_SVG
      Constant CONTENT_TYPE_SVG="image/svg+xml".
      See Also:
    • CONTENT_TYPE_ICO

      public static final String CONTENT_TYPE_ICO
      Constant CONTENT_TYPE_SVG="image/svg+xml".
      See Also:
    • CONTENT_TYPE_PDF

      public static final String CONTENT_TYPE_PDF
      Constant CONTENT_TYPE_PDF="application/pdf".
      See Also:
    • CONTENT_TYPE_GIF

      public static final String CONTENT_TYPE_GIF
      Constant CONTENT_TYPE_GIF="application/gif".
      See Also:
    • CONTENT_TYPE_VIDEO

      public static final String CONTENT_TYPE_VIDEO
      Constant CONTENT_TYPE_VIDEO="video".
      See Also:
    • CONTENT_TYPE_AUDIO

      public static final String CONTENT_TYPE_AUDIO
      Constant CONTENT_TYPE_AUDIO="audio".
      See Also:
  • Constructor Details

    • CMSMediaItem

      public CMSMediaItem()
      Default constructor.
    • CMSMediaItem

      public CMSMediaItem(CMSMediaItem orig)
      Copy constructor.
      Parameters:
      orig - source media item to copy from
  • Method Details

    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • getContentType

      public String getContentType()
      Determines this media item's file's content type via the extension.
      Returns:
      Content type string
    • isHasExportableText

      public boolean isHasExportableText()
      Checks whether this media item contains a text file that can be exported for indexing.
      Returns:
      true if item content types allows for text export; false otherwise
    • getId

      public Long getId()
      Getter for the field id.
      Returns:
      the database primary key of this media item
    • setId

      public void setId(Long id)
      Setter for the field id.
      Parameters:
      id - the database primary key to set
    • getFileName

      public String getFileName()
      Getter for the field fileName.
      Returns:
      the file name of the media file
    • setFileName

      public void setFileName(String fileName)
      Setter for the field fileName.
      Parameters:
      fileName - the file name of the media file (also resets the cached last modified time)
    • setAlternativeText

      @Deprecated(since="2026.01") public void setAlternativeText(String alternativeText)
      Deprecated.
      Setter for the field alternativeText.
      Parameters:
      alternativeText - the legacy alternative text value to store
    • getMetadataForLocale

      public CMSMediaItemMetadata getMetadataForLocale(Locale locale)
      getMetadataForLocale.
      Parameters:
      locale - locale used to look up the language tag
      Returns:
      media item metadata for the given locale; null if no locale given
    • getMetadataForLanguage

      public CMSMediaItemMetadata getMetadataForLanguage(String language)
      getMetadataForLanguage.
      Parameters:
      language - BCP 47 language code to look up
      Returns:
      media item metadata for the given locale
    • getMetadata

      public List<CMSMediaItemMetadata> getMetadata()
      Getter for the field metadata.
      Returns:
      the list of language-specific metadata entries for this media item
    • setMetadata

      public void setMetadata(List<CMSMediaItemMetadata> metadata)
      Setter for the field metadata.
      Parameters:
      metadata - the list of language-specific metadata entries to assign
    • addMetadata

      public void addMetadata(CMSMediaItemMetadata metadata)
      Adds a metadata item to the list of image metadata. If a metadata item with the same language string exists, it is replaced
      Parameters:
      metadata - metadata entry to add or replace for its language
    • getCurrentLanguageMetadata

      public CMSMediaItemMetadata getCurrentLanguageMetadata()
      getCurrentLanguageMetadata.
      Returns:
      metadata list for the current language
    • hasCateories

      public boolean hasCateories()
      hasCateories.
      Returns:
      true if this media item has at least one assigned category, false otherwise
    • getCategories

      public List<CMSCategory> getCategories()
    • setCategories

      public void setCategories(List<CMSCategory> categories)
      Setter for the field categories.
      Parameters:
      categories - replacement list of categories to assign
    • removeCategory

      public boolean removeCategory(CMSCategory cat)
      removeCategory.
      Parameters:
      cat - category to remove from this item
      Returns:
      true if the category was present and has been removed, false otherwise
    • addCategory

      public boolean addCategory(CMSCategory cat)
      addCategory.
      Parameters:
      cat - category to add if not already present
      Returns:
      true if the category was added, false if it was already present
    • isImportant

      public boolean isImportant()
    • setImportant

      public void setImportant(boolean important)
      setImportant.
      Parameters:
      important - true sets priority to IMPORTANT, false to DEFAULT
    • getPriority

      public CMSMediaItem.Priority getPriority()
    • setPriority

      public void setPriority(CMSMediaItem.Priority priority)
      Setter for the field priority.
      Parameters:
      priority - the display priority to assign to this media item
    • getLinkURI

      public URI getLinkURI()
      getLinkURI.
      Specified by:
      getLinkURI in interface BrowseElementInfo
      Returns:
      the link URI for this media item, resolved using the current HTTP request
    • getLinkURI

      public URI getLinkURI(HttpServletRequest request)
      getLinkURI.
      Specified by:
      getLinkURI in interface BrowseElementInfo
      Parameters:
      request - a HttpServletRequest object.
      Returns:
      the link URI for this browse element, resolved relative to the given request context
    • getLink

      public String getLink()
      Getter for the field link.
      Returns:
      the entered link url
    • setLink

      public void setLink(String linkUrl)
      Set the link for this media item.
      Parameters:
      linkUrl - URL string to associate with this media item
      Throws:
      URISyntaxException - if any.
    • getDescription

      public String getDescription()
      getDescription.
      Specified by:
      getDescription in interface BrowseElementInfo
      Returns:
      the description of this browse element in the default language
    • getName

      public String getName()
      getName.
      Specified by:
      getName in interface BrowseElementInfo
      Returns:
      the name of this browse element
    • getAlternativeText

      public String getAlternativeText()
    • getAlternativeTextOld

      @Deprecated(since="2026.01") public String getAlternativeTextOld()
      Deprecated.
    • getIconURI

      public URI getIconURI()
      getIconURI.
      Specified by:
      getIconURI in interface BrowseElementInfo
      Returns:
      the icon URI for this browse element, or null if no icon is set
    • getIconURI

      public URI getIconURI(int width, int height)
      getIconURI.
      Specified by:
      getIconURI in interface BrowseElementInfo
      Parameters:
      width - a int.
      height - a int.
      Returns:
      the icon URI scaled to the given width and height, or null if no icon is set
    • getIconURI

      public URI getIconURI(int size)
      getIconURI.
      Specified by:
      getIconURI in interface BrowseElementInfo
      Parameters:
      size - a int.
      Returns:
      the icon URI scaled to the given square size, or null if no icon is set
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getName

      public String getName(String language)
    • getDescription

      public String getDescription(String language)
      Specified by:
      getDescription in interface BrowseElementInfo
      Parameters:
      language - language code for the requested description
      Returns:
      the description of this browse element in the given language
    • getDisplayOrder

      public int getDisplayOrder()
    • setDisplayOrder

      public void setDisplayOrder(int displayOrder)
      Setter for the field displayOrder.
      Parameters:
      displayOrder - the sort order index for displaying this media item in lists
    • getImageURI

      public String getImageURI()
      getImageURI.
      Returns:
      the file URI to the CMS media image file
    • getTranslationsForName

      public de.intranda.metadata.multilanguage.IMetadataValue getTranslationsForName()
      getTranslationsForName.
      Specified by:
      getTranslationsForName in interface BrowseElementInfo
      Returns:
      the multilingual name translations for this browse element
    • getTranslationsForDescription

      public de.intranda.metadata.multilanguage.IMetadataValue getTranslationsForDescription()
      getTranslationsForDescription.
      Specified by:
      getTranslationsForDescription in interface BrowseElementInfo
      Returns:
      the multilingual metadata value containing description translations for all configured languages
    • getTranslationsForAlternativeText

      public de.intranda.metadata.multilanguage.IMetadataValue getTranslationsForAlternativeText()
      getTranslationsForAlternativeText.
      Returns:
      the multilingual metadata value containing alternative text translations for all configured languages
    • isFinished

      public boolean isFinished(Locale locale)
      isFinished.
      Parameters:
      locale - locale to check for a non-blank name entry
      Returns:
      true if the metadata name for the given locale is non-blank, false otherwise
    • getFinishedLocales

      public List<Locale> getFinishedLocales()
      getFinishedLocales.
      Returns:
      a list of locales for which this media item has a non-blank name translation
    • compareTo

      public int compareTo(CMSMediaItem o)
      Specified by:
      compareTo in interface Comparable<CMSMediaItem>
    • getLastModifiedTime

      public FileTime getLastModifiedTime()
      Getter for the field lastModifiedTime.
      Returns:
      the lastModifiedTime. May be null only if no file exists or last modified time cannot be read
    • getFilePath

      public Path getFilePath()
      getFilePath.
      Returns:
      the filesystem path to the CMS media file
    • wrapCategories

      public List<Selectable<CMSCategory>> wrapCategories(List<CMSCategory> categories)
      wrapCategories.
      Parameters:
      categories - all available categories to wrap with selection state
      Returns:
      the categoryMap. Never null. If it isn't defined yet, create a map from all categories