Class CMSPage

java.lang.Object
io.goobi.viewer.model.cms.pages.CMSPage
All Implemented Interfaces:
Harvestable, IPolyglott, Serializable, Comparable<CMSPage>

@Entity public class CMSPage extends Object implements Comparable<CMSPage>, Harvestable, IPolyglott, Serializable
Represents a CMS page with configurable content components, metadata, and URL mappings.
See Also:
  • Field Details

  • Constructor Details

    • CMSPage

      public CMSPage()
      Creates a new CMSPage instance.
    • CMSPage

      public CMSPage(CMSPage original)
      creates a deep copy of the original CMSPage. Only copies persisted properties and performs initialization for them
      Parameters:
      original - source page to copy from
    • CMSPage

      public CMSPage(CMSPageTemplate original)
      creates a CMSPage from a CMSPageTemplate. Only copies persisted properties and performs initialization for them
      Parameters:
      original - template to derive the new page from
  • Method Details

    • initialiseCMSComponents

      public void initialiseCMSComponents(CMSTemplateManager templateManager)
    • hashCode

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

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

      public int compareTo(CMSPage o)
      Specified by:
      compareTo in interface Comparable<CMSPage>
    • addSidebarElement

      public void addSidebarElement(CMSSidebarElement element)
      addSidebarElement.
      Parameters:
      element - sidebar element to append to the list
    • getId

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

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

      public LocalDateTime getDateCreated()
      Getter for the field dateCreated.
      Returns:
      the date and time when this page was created
    • setDateCreated

      public void setDateCreated(LocalDateTime dateCreated)
      Setter for the field dateCreated.
      Parameters:
      dateCreated - the date and time when this page was created
    • getDateUpdated

      public LocalDateTime getDateUpdated()
      getDateUpdated.
      Specified by:
      getDateUpdated in interface Harvestable
      Returns:
      the date and time when this record was last updated
    • setDateUpdated

      public void setDateUpdated(LocalDateTime dateUpdated)
      Setter for the field dateUpdated.
      Parameters:
      dateUpdated - the date and time when this page was last updated
    • isPublished

      public boolean isPublished()
      isPublished.
      Returns:
      true if the publication status is PUBLISHED, false otherwise
    • setPublished

      public void setPublished(boolean published)
      Setter for the field published.
      Parameters:
      published - true sets the publication status to PUBLISHED, false sets it to PRIVATE
    • isUseDefaultSidebar

      public boolean isUseDefaultSidebar()
      isUseDefaultSidebar.
      Returns:
      true if this page uses the default sidebar instead of a custom one, false otherwise
    • setUseDefaultSidebar

      public void setUseDefaultSidebar(boolean useDefaultSidebar)
      Setter for the field useDefaultSidebar.
      Parameters:
      useDefaultSidebar - true if this page should use the default sidebar instead of a custom one
    • getSidebarElements

      public List<CMSSidebarElement> getSidebarElements()
      Getter for the field sidebarElements.
      Returns:
      the list of sidebar elements configured for this page
    • setSidebarElements

      public void setSidebarElements(List<CMSSidebarElement> sidebarElements)
      Setter for the field sidebarElements.
      Parameters:
      sidebarElements - the list of sidebar widget elements to assign to this page
    • addToSidebar

      public void addToSidebar(List<WidgetDisplayElement> widgets)
    • moveUpSidebarElement

      public void moveUpSidebarElement(CMSSidebarElement element)
    • moveDownSidebarElement

      public void moveDownSidebarElement(CMSSidebarElement element)
    • removeSidebarElement

      public void removeSidebarElement(CMSSidebarElement element)
    • containsSidebarElement

      public boolean containsSidebarElement(WidgetDisplayElement widget)
    • getCategories

      public List<CMSCategory> getCategories()
      Getter for the field categories.
      Returns:
      the list of categories assigned to this page
    • setCategories

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

      public void addCategory(CMSCategory category)
      addCategory.
      Parameters:
      category - category to add if not already present
    • removeCategory

      public void removeCategory(CMSCategory category)
      removeCategory.
      Parameters:
      category - category to remove from this page
    • getSidebarElementString

      public String getSidebarElementString()
      Getter for the field sidebarElementString.
      Returns:
      the serialized sidebar element configuration string
    • setSidebarElementString

      public void setSidebarElementString(String sidebarElementString)
      Setter for the field sidebarElementString.
      Parameters:
      sidebarElementString - serialized sidebar element configuration string
    • getTitle

      public String getTitle()
      getTitle.
      Returns:
      the CMS page title in the default language
    • getTitle

      public String getTitle(Locale locale)
      getTitle.
      Parameters:
      locale - locale of the desired title translation
      Returns:
      the CMS page title in the given locale
    • getTitleTranslations

      public de.intranda.metadata.multilanguage.IMetadataValue getTitleTranslations()
    • getMenuTitle

      public String getMenuTitle()
      getMenuTitle.
      Returns:
      the CMS page menu title in the default language
    • getMenuTitle

      public String getMenuTitle(Locale locale)
      getMenuTitle.
      Parameters:
      locale - locale of the desired menu title translation
      Returns:
      the CMS page menu title in the given locale
    • getMenuTitleOrTitle

      public String getMenuTitleOrTitle()
      getMenuTitleOrTitle.
      Returns:
      the CMS page menu title in the default language, falling back to the title if the menu title is empty
    • getMenuTitleOrTitle

      public String getMenuTitleOrTitle(Locale locale)
      getMenuTitleOrTitle.
      Parameters:
      locale - locale of the desired translation
      Returns:
      the CMS page menu title in the given locale, falling back to the title if not available
    • getMenuTitleTranslations

      public TranslatedText getMenuTitleTranslations()
    • getPageSorting

      public Long getPageSorting()
      Getter for the field pageSorting.
      Returns:
      the numeric sort position used for page ordering, or null if not set
    • getPageSortingOrElse

      public Long getPageSortingOrElse(long defaultOrder)
    • setPageSorting

      public void setPageSorting(Long pageSorting)
      Setter for the field pageSorting.
      Parameters:
      pageSorting - numeric sort position for page ordering
    • getSubTheme

      public String getSubTheme()
      Getter for the field subTheme.
      Returns:
      the sub-theme discriminator value for this page, or an empty string if none is set
    • setSubTheme

      public void setSubTheme(String subTheme)
      Setter for the field subTheme.
      Parameters:
      subTheme - sub-theme discriminator value for this page
    • getPageUrl

      public String getPageUrl()
      getPageUrl.
      Returns:
      the pretty url to this page (using alternative url if set)
    • getUrl

      public String getUrl()
      Like getPageUrl() but does not require CmsBean (which is unavailable in different threads).
      Returns:
      URL to this page
    • getListPage

      public int getListPage()
      Gets the pagination number for this page's main list if it contains one.
      Returns:
      a int.
    • setListPage

      public void setListPage(int listPage)
      Sets the pagination number for this page's main list if it contains one.
      Parameters:
      listPage - current pagination page number of the main list
    • getPersistentUrl

      public String getPersistentUrl()
      Getter for the field persistentUrl.
      Returns:
      the custom URL path for this page, without leading or trailing slashes
    • setPersistentUrl

      public void setPersistentUrl(String persistentUrl)
      Setter for the field persistentUrl.
      Parameters:
      persistentUrl - the custom URL path for this page; leading and trailing slashes are stripped
    • getRelativeUrlPath

      public String getRelativeUrlPath()
      getRelativeUrlPath.
      Returns:
      the relative URL path for this CMS page, using static or persistent URL if available
    • getRelativeUrlPath

      public String getRelativeUrlPath(boolean pretty)
      getRelativeUrlPath.
      Parameters:
      pretty - if true, use static or persistent URL when available
      Returns:
      the relative URL path for this CMS page, optionally using the pretty URL
    • isHasSidebarElements

      public boolean isHasSidebarElements()
      isHasSidebarElements.
      Returns:
      true if this page uses the default sidebar or has at least one custom sidebar element, false otherwise
    • setParentPageId

      public void setParentPageId(String parentPageId)
      Setter for the field parentPageId.
      Parameters:
      parentPageId - the string ID of the parent CMS page, or null if this page has no parent
    • getParentPageId

      public String getParentPageId()
      Getter for the field parentPageId.
      Returns:
      the string ID of the parent CMS page, or null if this page has no parent
    • isMayContainUrlParameters

      public boolean isMayContainUrlParameters()
      isMayContainUrlParameters.
      Returns:
      true if this page contains paged components that require URL parameters, false otherwise
    • isContainsPagedComponents

      public boolean isContainsPagedComponents()
    • getRelatedPI

      public String getRelatedPI()
      Getter for the field relatedPI.
      Returns:
      the persistent identifier of the record associated with this CMS page, or null if none is set
    • setRelatedPI

      public void setRelatedPI(String relatedPI)
      Setter for the field relatedPI.
      Parameters:
      relatedPI - the persistent identifier of the record associated with this CMS page
    • isUseAsDefaultRecordView

      public boolean isUseAsDefaultRecordView()
    • setUseAsDefaultRecordView

      public void setUseAsDefaultRecordView(boolean useAsDefaultRecordView)
    • getProperty

      public CMSProperty getProperty(String key) throws ClassCastException
      Returns the property with the given key or else creates a new one with that key and returns it.
      Parameters:
      key - property key to look up or create
      Returns:
      the property with the given key or else creates a new one with that key and returns it
      Throws:
      ClassCastException - if the returned property has the wrong generic type.
    • toString

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

      public String getWrapperElementClass()
      Getter for the field wrapperElementClass.
      Returns:
      the wrapperElementClass
    • setWrapperElementClass

      public void setWrapperElementClass(String wrapperElementClass)
      Setter for the field wrapperElementClass.
      Parameters:
      wrapperElementClass - the wrapperElementClass to set
    • isSearchable

      public boolean isSearchable()
    • setSearchable

      public void setSearchable(boolean searchable)
    • getAccessCondition

      public String getAccessCondition()
      Returns the access condition configured for this CMS page.
      Returns:
      the access condition property value, or null if no access condition is configured
    • setAccessCondition

      public void setAccessCondition(String accessCondition)
    • deleteExportedTextFiles

      public int deleteExportedTextFiles() throws ViewerConfigurationException
      Deletes exported HTML/TEXT fragments from a related record's data folder. Should be called when deleting this CMS page.
      Returns:
      Number of deleted files
      Throws:
      ViewerConfigurationException - if any.
    • exportTexts

      public List<File> exportTexts(String outputFolderPath, String namingScheme) throws IOException
      Exports text/html fragments from this page's content items for indexing.
      Parameters:
      outputFolderPath - destination directory for exported text fragments
      namingScheme - filename pattern used when writing exported files
      Returns:
      a list of exported text fragment files written to the output folder
      Throws:
      IOException - if any.
    • exportAsXml

      public org.jdom2.Document exportAsXml()
      Exports relevant page contents as JDOM2 document for indexing.
      Returns:
      Document
    • writeSelectableCategories

      public void writeSelectableCategories()
      Retrieve all categories fresh from the DAO and write them to this depending on the state of the selectableCategories list. Saving the categories from selectableCategories directly leads to ConcurrentModificationexception when persisting page
    • getSelectableCategories

      public List<Selectable<CMSCategory>> getSelectableCategories() throws DAOException
      Getter for the field selectableCategories.
      Returns:
      the list of all allowed categories wrapped as selectable items, with selection state reflecting current page categories
      Throws:
      DAOException - if any.
    • resetSelectableCategories

      public void resetSelectableCategories()
    • getPi

      public String getPi()
      getPi.
      Specified by:
      getPi in interface Harvestable
      Returns:
      the persistent identifier (PI) of this harvestable record
    • hasTopbarComponents

      public boolean hasTopbarComponents()
    • getTopbarComponents

      public List<CMSComponent> getTopbarComponents()
    • getAdminBackendUrl

      public String getAdminBackendUrl()
    • getPersistentComponents

      public List<PersistentCMSComponent> getPersistentComponents()
    • isComponentsLoaded

      public boolean isComponentsLoaded()
    • getComponents

      public List<CMSComponent> getComponents()
    • getAsCMSComponent

      public CMSComponent getAsCMSComponent(PersistentCMSComponent p)
    • removeComponent

      public boolean removeComponent(CMSComponent component)
    • addComponent

      public PersistentCMSComponent addComponent(String filename, CMSTemplateManager templateManager) throws IllegalArgumentException, IllegalStateException
      Throws:
      IllegalArgumentException
      IllegalStateException
    • isComplete

      public boolean isComplete(Locale locale)
      Description copied from interface: IPolyglott
      If this returns true, an associated language tab should have the 'already-translated' class, otherwise the '-partly-translated' class unless IPolyglott.isEmpty(Locale) also returns true.
      Specified by:
      isComplete in interface IPolyglott
      Parameters:
      locale - the locale to check translation completeness for
      Returns:
      true if IPolyglott.isValid(Locale) returns true for the given locale and all fields contain a value which have a value in the default locale. For the default locale, IPolyglott.isComplete(Locale) and IPolyglott.isValid(Locale) are identical. For implementations with only one field, both methods are also always identical
    • isValid

      public boolean isValid(Locale locale)
      Description copied from interface: IPolyglott
      Only meaningful for the default language for which all required fields must be filled.
      Specified by:
      isValid in interface IPolyglott
      Parameters:
      locale - the locale to validate required fields for
      Returns:
      true if all required fields contain a value in the given locale
    • isEmpty

      public boolean isEmpty(Locale locale)
      Description copied from interface: IPolyglott
      If this returns true, an associated language tab should have neither the 'already-translated' nor the '-partly-translated' class.
      Specified by:
      isEmpty in interface IPolyglott
      Parameters:
      locale - the locale to check for empty fields
      Returns:
      true if no fields are filled for the given locale
    • getSelectedLocale

      public Locale getSelectedLocale()
      Specified by:
      getSelectedLocale in interface IPolyglott
      Returns:
      the locale currently set by IPolyglott.setSelectedLocale(Locale)
    • setSelectedLocale

      public void setSelectedLocale(Locale locale)
      Description copied from interface: IPolyglott
      Sets the locale to use for display and editing.
      Specified by:
      setSelectedLocale in interface IPolyglott
      Parameters:
      locale - the locale to select
    • hasSearchFunctionality

      public boolean hasSearchFunctionality()
    • getSearch

      public Optional<SearchFunctionality> getSearch()
    • getTemplate

      public Optional<CMSPageTemplate> getTemplate()
    • setComponentOrder

      public void setComponentOrder(CMSComponent component, int order)
      Set the order attribute of the PersistentCMSComponent belonging to the given CMSComponent to the given order value. Also, sets the order value of all Components which previously had the given order to the order value of the given component
      Parameters:
      component - the CMS component whose order to set
      order - the new order value to assign
    • incrementOrder

      public void incrementOrder(CMSComponent component)
    • decrementOrder

      public void decrementOrder(CMSComponent component)
    • isFirstComponent

      public boolean isFirstComponent(CMSComponent component)
    • isLastComponent

      public boolean isLastComponent(CMSComponent component)
    • setTitle

      public void setTitle(TranslatedText title)
    • setMenuTitle

      public void setMenuTitle(TranslatedText menuTitle)
    • addPersistentComponent

      public void addPersistentComponent(PersistentCMSComponent persistentComponent)
    • getPreviewItems

      public List<CMSContentItem> getPreviewItems()
    • getPreviewItems

      public List<CMSContentItem> getPreviewItems(String itemId)
    • getPreviewItem

      public CMSContentItem getPreviewItem(String itemId)
    • getPreviewComponents

      public List<CMSComponent> getPreviewComponents()
    • getGroupedPageViewComponents

      public List<CMSComponentGroup> getGroupedPageViewComponents()
    • getPageViewComponents

      public List<CMSComponent> getPageViewComponents()
    • isLockComponents

      public boolean isLockComponents()
    • isLegacyPage

      public boolean isLegacyPage()
    • getTemplateId

      public Long getTemplateId()
    • setTemplateId

      public void setTemplateId(Long templateId)