Class DefaultCMSAdminContentSlotService

    • Field Detail

      • DEFAULT_CONTENTSLOT_FOR_PAGE_UID_PREFIX

        public static final java.lang.String DEFAULT_CONTENTSLOT_FOR_PAGE_UID_PREFIX
        See Also:
        Constant Field Values
      • DEFAULT_CONTENTSLOT_UID_SUFFIX

        public static final java.lang.String DEFAULT_CONTENTSLOT_UID_SUFFIX
        See Also:
        Constant Field Values
    • Constructor Detail

      • DefaultCMSAdminContentSlotService

        public DefaultCMSAdminContentSlotService()
    • Method Detail

      • createContentSlot

        public ContentSlotModel createContentSlot​(AbstractPageModel page,
                                                  java.lang.String id,
                                                  java.lang.String name,
                                                  java.lang.String position)
        Creates the ContentSlotModel object and ContentSlotForPageModel relation. Method explicitly saves both objects.
        Specified by:
        createContentSlot in interface CMSAdminContentSlotService
        Parameters:
        page - the page which will be set for ContentSlotForPageModel relation.
        id - the id of content slot.
        name - the name of content slot.
        position - the position of page.
        Returns:
        the ContentSlotModel object.
      • createContentSlot

        public ContentSlotModel createContentSlot​(AbstractPageModel page,
                                                  java.lang.String id,
                                                  java.lang.String name,
                                                  java.lang.String position,
                                                  boolean active)
        Creates the ContentSlotModel object and ContentSlotForPageModel relation. Method explicitly saves both objects.
        Specified by:
        createContentSlot in interface CMSAdminContentSlotService
        Parameters:
        page - the page which will be set for ContentSlotForPageModel relation.
        id - the id of content slot.
        name - the name of content slot.
        position - the position of page.
        active - the activity of content slot (true or false)
        Returns:
        the ContentSlotModel object.
      • createContentSlot

        public ContentSlotModel createContentSlot​(AbstractPageModel page,
                                                  java.lang.String id,
                                                  java.lang.String name,
                                                  java.lang.String position,
                                                  boolean active,
                                                  java.util.Date activeFrom,
                                                  java.util.Date activeUntil)
        Creates the ContentSlotModel object and ContentSlotForPageModel relation. Method explicitly saves both objects.
        Specified by:
        createContentSlot in interface CMSAdminContentSlotService
        Parameters:
        page - the page which will be set for ContentSlotForPageModel relation.
        id - the id of content slot.
        name - the name of content slot.
        position - the position of page.
        active - the activity of content slot (true or false)
        activeFrom - start date of activity.
        activeUntil - end date of activity.
        Returns:
        the ContentSlotModel object.
      • generateContentSlotUid

        protected java.lang.String generateContentSlotUid​(AbstractPageModel page,
                                                          java.lang.String position)
        Generate the Content Slot Uid after the slot position and page Uid
        Parameters:
        page - page model to get the uid from
        position - the position on the slot
        Returns:
        the content slot uid
      • generateContentSlotForPageUID

        protected java.lang.String generateContentSlotForPageUID()
        Generate the content slot id using the page uid prefix and the key generator.
        Returns:
        a content slot uid
      • deleteRelationByPosition

        public void deleteRelationByPosition​(AbstractPageModel page,
                                             java.lang.String position)
        deletes a relation between a page and a content slot. The content slot will be identified via the position
        Specified by:
        deleteRelationByPosition in interface CMSAdminContentSlotService
        Parameters:
        page - the page model
        position - the position
      • getContentSlotsForPage

        public java.util.Collection<ContentSlotData> getContentSlotsForPage​(AbstractPageModel page)
        returns a collection of all content slots for the given page. This also includes content slots which are defined in the master template. If on a certain position a content slot is defined in the master and page, it will return the content slot from the page
        Specified by:
        getContentSlotsForPage in interface CMSAdminContentSlotService
        Parameters:
        page - the page model
        Returns:
        all content slots for a given page
      • getContentSlotsForPage

        public java.util.Collection<ContentSlotData> getContentSlotsForPage​(AbstractPageModel page,
                                                                            boolean includeMasterTemplateSlots)
        Returns a collection of all content slots for the given page. If desired, the collection will include the content slots which are defined in the master template. If on a certain position a content slot is defined in the master and page, it will return the content slot from the page.
        Specified by:
        getContentSlotsForPage in interface CMSAdminContentSlotService
        Parameters:
        page - the page for which to retrieve the content slots
        includeMasterTemplateSlots - true to include the content slots defined in the master page template, false otherwise
        Returns:
        all content slots for a given page
      • appendTemplateSlots

        protected java.util.List<ContentSlotModel> appendTemplateSlots​(PageTemplateModel pageTemplate,
                                                                       java.util.Set<java.lang.String> positions,
                                                                       java.util.List<ContentSlotData> contentSlots,
                                                                       AbstractPageModel page)
        Gets all of the content slots for templates that do not share a position already identified in the content slots for pages. Also, if a page content slot's position matches with that of a slot for a template then mark the page slot as override.
        Parameters:
        pageTemplate - - the page template
        positions - - the positions
        contentSlots - - the list of content slot which new slots values will be appended to
        page - - the page containing the content slot
        Returns:
        list of template slots appended to the contentSlots list
      • updatePositionCMSComponentInContentSlot

        public void updatePositionCMSComponentInContentSlot​(AbstractCMSComponentModel component,
                                                            ContentSlotModel slot,
                                                            java.lang.Integer index)
        Description copied from interface: CMSAdminContentSlotService
        Update the position of an existing component item into a specific index position of an existing content slot.

        If the index provided is larger than the last available position in the slot, then the component will be added to the last position.

        Specified by:
        updatePositionCMSComponentInContentSlot in interface CMSAdminContentSlotService
        Parameters:
        component - - the component item; never null
        slot - - the content slot; never null
        index - - where to insert the component in the slot; never null, must be a positive number
      • addCMSComponentToContentSlot

        public void addCMSComponentToContentSlot​(AbstractCMSComponentModel component,
                                                 ContentSlotModel slot,
                                                 java.lang.Integer index)
        Description copied from interface: CMSAdminContentSlotService
        Add an existing component item into a specific index position of an existing content slot.

        If the index provided is larger than the last available position in the slot, then the component will be added to the last position.

        Specified by:
        addCMSComponentToContentSlot in interface CMSAdminContentSlotService
        Parameters:
        component - - the component item; never null
        slot - - the content slot; never null
        index - - where to insert the component in the slot; never null, must be a positive number
      • hasOtherRelations

        public boolean hasOtherRelations​(AbstractPageModel page,
                                         ContentSlotModel contentSlot)
        Checks if there are other relations between the given content slot and other pages (except the given one)
        Specified by:
        hasOtherRelations in interface CMSAdminContentSlotService
        Parameters:
        page - the page model
        contentSlot - the content slot model
        Returns:
        true if there are other relations between the content slot and other pages; false otherwise
      • hasRelations

        public boolean hasRelations​(ContentSlotModel contentSlot)
        Checks if the given content slot has relations to one or more pages
        Specified by:
        hasRelations in interface CMSAdminContentSlotService
        Parameters:
        contentSlot - the content slot model
        Returns:
        true if there are relations to at least one other page; false otherwise
      • getContentSlotPosition

        public java.lang.String getContentSlotPosition​(AbstractPageModel page,
                                                       ContentSlotModel contentSlot)
        Description copied from interface: CMSAdminContentSlotService
        Find the position of the content slot on the page or its associated page template
        Specified by:
        getContentSlotPosition in interface CMSAdminContentSlotService
        Parameters:
        page - the page model containing the content slot
        contentSlot - the content slot to search for
        Returns:
        the position of the content slot on the page; null if not found
      • throwTypePermissionException

        protected void throwTypePermissionException​(java.lang.String permissionName,
                                                    java.lang.String typeCode)
        Parameters:
        permissionName - permission name
        typeCode - type code
      • setCmsAdminComponentService

        public void setCmsAdminComponentService​(CMSAdminComponentService cmsAdminComponentService)
      • setCmsContentSlotDao

        public void setCmsContentSlotDao​(CMSContentSlotDao cmsContentSlotDao)
      • setCmsDataFactory

        public void setCmsDataFactory​(CMSDataFactory cmsDataFactory)
      • setKeyGenerator

        public void setKeyGenerator​(KeyGenerator keyGenerator)
      • setAdminSiteService

        public void setAdminSiteService​(CMSAdminSiteService adminSiteService)
      • setConfigurationService

        public void setConfigurationService​(ConfigurationService configurationService)
      • setCmsCatalogLevelService

        public void setCmsCatalogLevelService​(CatalogLevelService cmsCatalogLevelService)
      • getContentSlotForPageUidPrefix

        public java.lang.String getContentSlotForPageUidPrefix()
      • setContentSlotForPageUidPrefix

        public void setContentSlotForPageUidPrefix​(java.lang.String contentSlotForPageUidPrefix)
      • getContentSlotUidSuffix

        public java.lang.String getContentSlotUidSuffix()
      • setContentSlotUidSuffix

        public void setContentSlotUidSuffix​(java.lang.String contentSlotUidSuffix)
      • setPermissionCRUDService

        public void setPermissionCRUDService​(PermissionCRUDService permissionCRUDService)