Package io.goobi.viewer.managedbeans
Class CmsMediaBean
java.lang.Object
io.goobi.viewer.managedbeans.CmsMediaBean
- All Implemented Interfaces:
Serializable
JSF backing bean for CMS media file management including upload, editing, and deletion.
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateMediaItem.voiddeleteMedia(CMSMediaItem item) deleteMedia.voidDeletes all mediaItems fromgetMediaItems()which are are marked as selected.getAllMedia.getAllMediaCategories.static Stringstatic Stringstatic StringGetter for the fielddataProvider.static Stringstatic Stringstatic StringgetFileName(Part filePart) getFileName.Getter for the fieldfilenameFilter.Getter for the fieldfilter.static StringgetImageFilter.static Stringstatic StringgetMediaFileAsString.static StringgetMediaItems.static StringgetMediaPreviewUrl.static StringgetMediaUrl(CMSMediaItem item) getMediaUrl.static StringgetMediaUrl(CMSMediaItem item, String width, String height) getMediaUrl.Getter for the fieldselectedMediaItem.Getter for the fieldselectedTag.static Stringstatic StringbooleanisAllSelected.booleanisAudio(CMSMediaItem item) isAudio.booleanisImage(CMSMediaItem item) isImage.booleanisText(CMSMediaItem item) isText.booleanisVideo(CMSMediaItem item) isVideo.booleanneedsPaginator.voidreloadMediaList.voidreloadMediaList(boolean resetCurrentPage) reloadMediaList.voidReload all media items, along with the available categories.voidsaveMedia(CMSMediaItem media) saveMedia.voidsaveMedia(CMSMediaItem media, List<Selectable<CMSCategory>> categories) Save media item, adding or removing the given categories, depending whether they are selected or not. ifUser.hasPrivilegeForAllSubthemeDiscriminatorValues()is false for the current user and none of the given categories is selected, then don't change the media categories since doing so would break category restrictionsvoidSaves all mediaItems fromgetMediaItems()which are are marked as selected.voidsaveSelectedMediaItem.voidsetAllSelected(boolean allSelected) Setter for the fieldallSelected.voidsetFilenameFilter(String filter) Setter for the fieldfilenameFilter.voidSetter for the fieldfilter.voidsetSelectedMediaItem(CategorizableTranslatedSelectable<CMSMediaItem> selectedMediaItem) Setter for the fieldselectedMediaItem.voidsetSelectedTag(String selectedTag) Setter for the fieldselectedTag.voidtoggleSelectedMediaItem(CategorizableTranslatedSelectable<CMSMediaItem> selectedMediaItem) toggleSelectedMediaItem.
-
Field Details
-
userBean
-
-
Constructor Details
-
CmsMediaBean
public CmsMediaBean()Creates a new CmsMediaBean instance.
-
-
Method Details
-
resetData
public void resetData()Reload all media items, along with the available categories. -
createMediaItem
createMediaItem.- Returns:
- a new CMSMediaItem initialized with metadata entries for all configured locales
-
deleteMedia
deleteMedia.- Parameters:
item- media item to delete from the database and filesystem- Throws:
DAOException- if any.
-
getAllMedia
getAllMedia.- Returns:
- a list of all CMS media items accessible to the current user
- Throws:
DAOException- if any.
-
getDataProvider
Getter for the fielddataProvider.- Returns:
- the TableDataProvider for the CMS media item list
-
getMediaItems
getMediaItems.- Returns:
- a list of categorizable translated selectable CMS media items for the current page in the paginated media list
- Throws:
DAOException- if any.
-
reloadMediaList
public void reloadMediaList()reloadMediaList. -
reloadMediaList
public void reloadMediaList(boolean resetCurrentPage) reloadMediaList.- Parameters:
resetCurrentPage- if true, navigate back to the first page after reload
-
deleteSelectedItems
Deletes all mediaItems fromgetMediaItems()which are are marked as selected. Reloads the media list- Throws:
DAOException- if any.
-
saveSelectedItems
Saves all mediaItems fromgetMediaItems()which are are marked as selected. Reloads the media list- Throws:
DAOException- if any.
-
getMediaUrl
getMediaUrl.- Parameters:
item- media item for which to build the URL- Returns:
- the URL to the given CMS media item at its natural size
- Throws:
NumberFormatException- if any.ViewerConfigurationException- if any.
-
getMediaUrl
getMediaUrl.- Parameters:
item- media item for which to build the URLwidth- requested image width in pixels, or null/blank for autoheight- requested image height in pixels, or null/blank for auto- Returns:
- the URL to the given CMS media item scaled to the specified dimensions
- Throws:
ViewerConfigurationException- if any.
-
getMediaFileAsString
getMediaFileAsString.- Parameters:
item- media item whose file content is retrieved via REST- Returns:
- the text content of the given CMS media item fetched via REST API, or empty string on failure
- Throws:
ViewerConfigurationException- if any.
-
getMediaPreviewUrl
getMediaPreviewUrl.- Parameters:
item- media item for which to build a preview thumbnail URL- Returns:
- the URL to a 160px-high preview thumbnail of the given CMS media item
- Throws:
NumberFormatException- if any.ViewerConfigurationException- if any.
-
isImage
isImage.- Parameters:
item- media item whose filename is tested- Returns:
- true if the given media item's filename matches the image file filter pattern, false otherwise
-
isVideo
isVideo.- Parameters:
item- media item whose filename is tested- Returns:
- true if the given media item's filename matches the video file filter pattern, false otherwise
-
isAudio
isAudio.- Parameters:
item- media item whose filename is tested- Returns:
- true if the given media item's filename matches the audio file filter pattern, false otherwise
-
isText
isText.- Parameters:
item- media item whose filename is tested- Returns:
- true if the given media item's filename matches the document/text file filter pattern, false otherwise
-
saveSelectedMediaItem
saveSelectedMediaItem.- Throws:
DAOException- if any.
-
saveMedia
public void saveMedia(CMSMediaItem media, List<Selectable<CMSCategory>> categories) throws DAOException Save media item, adding or removing the given categories, depending whether they are selected or not. ifUser.hasPrivilegeForAllSubthemeDiscriminatorValues()is false for the current user and none of the given categories is selected, then don't change the media categories since doing so would break category restrictions- Parameters:
media- media item to persist to the databasecategories- selectable categories to apply or remove from the media item- Throws:
DAOException- if any.
-
saveMedia
saveMedia.- Parameters:
media- media item to add or update in the database- Throws:
DAOException- if any.
-
getFileName
getFileName.- Parameters:
filePart- multipart upload part from which the filename is extracted- Returns:
- the filename extracted from the content-disposition header of the upload part, or null if not found
-
setSelectedTag
Setter for the fieldselectedTag.- Parameters:
selectedTag- the tag name to filter the media list by
-
getSelectedTag
Getter for the fieldselectedTag.- Returns:
- the tag currently selected to filter the media list
-
getAllMediaCategories
getAllMediaCategories.- Returns:
- a list of all CMS categories available for media items
- Throws:
DAOException- if any.
-
getImageFilter
getImageFilter.- Returns:
- a regex matching only filenames ending with one of the supported image format suffixes
-
getVideoFilter
-
getAudioFilter
-
getDocumentFilter
-
getMediaFilter
-
getImageTypes
-
getVideoTypes
-
getAudioTypes
-
getDocumentTypes
-
getAllTypes
-
getFilter
Getter for the fieldfilter.- Returns:
- the media type filter string currently applied to the media list
-
setFilter
Setter for the fieldfilter.- Parameters:
filter- the media type filter string; triggers a reload of the media list if changed
-
getFilenameFilter
Getter for the fieldfilenameFilter.- Returns:
- the filename filter string currently applied to restrict the media list
-
setFilenameFilter
Setter for the fieldfilenameFilter.- Parameters:
filter- the filename filter string; triggers a reload of the media list if changed
-
setSelectedMediaItem
Setter for the fieldselectedMediaItem.- Parameters:
selectedMediaItem- the media item to mark as selected, or null to clear the selection
-
toggleSelectedMediaItem
public void toggleSelectedMediaItem(CategorizableTranslatedSelectable<CMSMediaItem> selectedMediaItem) toggleSelectedMediaItem.- Parameters:
selectedMediaItem- media item to select, or deselect if already selected
-
getSelectedMediaItem
Getter for the fieldselectedMediaItem.- Returns:
- the currently selected media item, or null if none is selected
-
setAllSelected
public void setAllSelected(boolean allSelected) Setter for the fieldallSelected.- Parameters:
allSelected- true to mark all media items as selected, false to deselect all
-
isAllSelected
public boolean isAllSelected()isAllSelected.- Returns:
- true if all media items are currently marked as selected, false otherwise
-
needsPaginator
public boolean needsPaginator()needsPaginator.- Returns:
- true if there is more than one page in the data-provider. False otherwise
-