Class DefaultCMSVersionService

    • Constructor Detail

      • DefaultCMSVersionService

        public DefaultCMSVersionService()
    • Method Detail

      • generatePayloadForVersion

        protected java.lang.String generatePayloadForVersion​(CMSVersionModel version)
        Generates a payload for a version.
        Parameters:
        version - The CMSVersion model.
        Returns:
        The payload for a version.
      • getItemFromVersion

        public ItemModel getItemFromVersion​(CMSVersionModel version)
        Retrieves an existing ItemModel and populates the item model using the data saved in the CMSVersionModel.
        Primary keys will be preserved for the retrieved ItemModel and any ItemModel's that are in relationship with the target.
        Specified by:
        getItemFromVersion in interface CMSVersionService
        Parameters:
        version - The version used to retrieve an ItemModel
        Returns:
        The existing ItemModel updated with the data from the version payload
      • getVersionByUid

        public java.util.Optional<CMSVersionModel> getVersionByUid​(java.lang.String uid)
        Description copied from interface: CMSVersionService
        Finds the {code CMSVersionModel} by uid.
        Specified by:
        getVersionByUid in interface CMSVersionService
        Parameters:
        uid - The uid of the CMSVersion model
        Returns:
        The CMSVersion model; can be Optional#empty()
      • getVersionByLabel

        public java.util.Optional<CMSVersionModel> getVersionByLabel​(CMSItemModel itemModel,
                                                                     java.lang.String label)
        Description copied from interface: CMSVersionService
        Finds the {code CMSVersionModel} containing the provided label for a given item.
        Specified by:
        getVersionByLabel in interface CMSVersionService
        Parameters:
        itemModel - the item model containing all the versions to search in
        label - the label on the cms version to search for
        Returns:
        The CMSVersion model; can be Optional#empty()
      • getTransactionId

        public java.lang.String getTransactionId()
        Description copied from interface: CMSVersionService
        Returns the version ID stored in the session attribute SessionService Cms2Constants.SESSION_VERSION_TRANSACTION_ID.
        Specified by:
        getTransactionId in interface CMSVersionService
        Returns:
        The Version ID.
      • createRevisionForItem

        public CMSVersionModel createRevisionForItem​(CMSItemModel itemModel)
        Description copied from interface: CMSVersionService
        Creates a revision for the given item and updates its payload.

        Note that a "revision" is a CMSVersionModel without a label.

        Specified by:
        createRevisionForItem in interface CMSVersionService
        Parameters:
        itemModel - The item model for versioning.
        Returns:
        The CMSVersion model.
      • createVersionForItem

        public CMSVersionModel createVersionForItem​(CMSItemModel itemModel,
                                                    java.lang.String label,
                                                    java.lang.String description)
        Description copied from interface: CMSVersionService
        Creates a version for the given item and updates its payload.

        Note that a "version" is a CMSVersionModel with an existing label.

        Specified by:
        createVersionForItem in interface CMSVersionService
        Parameters:
        itemModel - The item model for versioning.
        label - The label for the version
        description - The description for the version
        Returns:
        The CMSVersion model.
      • rollbackVersionForUid

        public java.util.Optional<ItemModel> rollbackVersionForUid​(java.lang.String uid)
        Description copied from interface: CMSVersionService
        Rolls back an ItemModel to a specific version. If no version is found, an Optional#empty() is returned.
        Specified by:
        rollbackVersionForUid in interface CMSVersionService
        Parameters:
        uid - The uid of the CMSVersionModel which the ItemModel will be rolled back to
        Returns:
        an Optional containing the updated ItemModel after it was rolled back; can be Optional#empty() when no version is found to perform the rollback operation.
      • isPreview

        protected boolean isPreview()
      • restoreHomepageAttribute

        protected void restoreHomepageAttribute​(ItemModel itemModel)
        Restore homepage attribute for Content pages to use the value from the original page.
        Parameters:
        itemModel - the item model.
      • updatePageApprovalStatus

        protected void updatePageApprovalStatus​(ItemModel itemModel)
        Updates the approval status attribute for any pages to CHECK, to indicate that the page was modified.
        Parameters:
        itemModel - the item model.
      • createPartialVersionForItem

        protected CMSVersionModel createPartialVersionForItem​(CMSItemModel itemModel)
        Generates a partial version for ItemModel.

        Note: A version entry is considered as partially field when the payload attribute is not populated.

        Parameters:
        itemModel - The item model for versioning.
        Returns:
        The partially filled CMSVersion model.
      • generateVersionUid

        public java.lang.String generateVersionUid()
        Generates version uid using versionUidGenerator.
        Specified by:
        generateVersionUid in interface CMSVersionService
        Returns:
        The uid of the version.
      • isVersionable

        public boolean isVersionable​(CMSItemModel itemModel)
        Determines if an itemModel is versionable An item is versionable when:
        1. ItemModel is a CMSItemModel
        2. CMSItemModel is in the currently active CatalogVersion
        3. CMSItemModel is not a shared content slot
        Specified by:
        isVersionable in interface CMSVersionService
        Parameters:
        itemModel - The item model.
        Returns:
        TRUE if the item is versionable; FALSE otherwise.
      • deleteVersionsForItem

        public void deleteVersionsForItem​(CMSItemModel itemModel)
        Description copied from interface: CMSVersionService
        Deletes all tagged versions for a CMSItemModel. Does not delete orphaned aggregated types linked to the item by relations. They will be deleted by garbage collection if enabled.
        Specified by:
        deleteVersionsForItem in interface CMSVersionService
        Parameters:
        itemModel - the item model for which all related tagged versions will be deleted
      • findPageVersionedByTransactionId

        public java.util.Optional<AbstractPageModel> findPageVersionedByTransactionId​(java.lang.String transactionId)
        Description copied from interface: CMSVersionService
        Finds the page associated to a transaction ID.

        When a page is versioned, the page and all its associated items are versioned. Each of them has a different version, but they all share the same transactionId; only one page can be associated to a transaction ID.

        Specified by:
        findPageVersionedByTransactionId in interface CMSVersionService
        Parameters:
        transactionId - The ID of the transaction for which to find its associated page.
        Returns:
        an Optional containing the page associated to the given transactionId; can be Optional#empty() when the transactionId identifies a transaction where a page was not versioned.
      • isTaggedVersion

        protected boolean isTaggedVersion​(CMSVersionModel cmsVersionModel)
        Determines if the cms version is tagged
        Parameters:
        cmsVersionModel - the cms version
        Returns:
        true if the cms version has a valid label
      • isInActiveSessionCatalog

        protected boolean isInActiveSessionCatalog​(CMSItemModel itemModel)
        Determines if the item is defined in the current (active session) catalog version or in a parent catalog (multi-country).
        Parameters:
        itemModel - the item to be evaluated
        Returns:
        TRUE when the item is defined in the active catalog version; FALSE otherwise.
      • belongsToPage

        protected boolean belongsToPage​(CMSItemModel itemModel)
        Determines if the item is a content slot defined for the page (ContentSlotForPage relation) or the page template (ContentSlotForTemplate relation).
        Parameters:
        itemModel - the item to be evaluated
        Returns:
        TRUE when the item is defined for the page; FALSE otherwise.
      • generateTransactionId

        protected java.lang.String generateTransactionId()
        Generates transaction id using transactionIdGenerator.
      • checkReadTypePermission

        protected void checkReadTypePermission​(java.lang.String typeCode)
        Checks whether current user has READ type permission for typeCode;
        Parameters:
        typeCode - the type code
      • checkCreateTypePermission

        protected void checkCreateTypePermission​(java.lang.String typeCode)
        Checks whether current user has CREATE type permission for typeCode;
        Parameters:
        typeCode - the type code
      • checkRemoveTypePermission

        protected void checkRemoveTypePermission​(java.lang.String typeCode)
        Checks whether current user has REMOVE type permission for typeCode;
        Parameters:
        typeCode - the type code
      • checkChangeTypePermission

        protected void checkChangeTypePermission​(java.lang.String typeCode)
        Checks whether current user has CHANGE type permission for typeCode;
        Parameters:
        typeCode - the type code
      • throwTypePermissionException

        protected void throwTypePermissionException​(java.lang.String permissionName,
                                                    java.lang.String typeCode)
        Throws TypePermissionException if current user does not have permission for typeCode.
        Parameters:
        permissionName -
        typeCode -
      • setTransactionIdGenerator

        public void setTransactionIdGenerator​(PersistentKeyGenerator transactionIdGenerator)
      • setSessionService

        public void setSessionService​(SessionService sessionService)
      • getModelService

        protected ModelService getModelService()
      • setModelService

        public void setModelService​(ModelService modelService)
      • getTypeService

        protected TypeService getTypeService()
      • setTypeService

        public void setTypeService​(TypeService typeService)
      • setCmsAdminItemService

        public void setCmsAdminItemService​(CMSAdminItemService cmsAdminItemService)
      • setCmsVersionDao

        public void setCmsVersionDao​(CMSVersionDao cmsVersionDao)
      • setCmsAdminContentSlotService

        public void setCmsAdminContentSlotService​(CMSAdminContentSlotService cmsAdminContentSlotService)
      • setCmsAdminSiteService

        public void setCmsAdminSiteService​(CMSAdminSiteService cmsAdminSiteService)
      • getCmsVersionToDataConverter

        protected Converter<ItemModel,​java.lang.String> getCmsVersionToDataConverter()
      • setCmsVersionToDataConverter

        public void setCmsVersionToDataConverter​(Converter<ItemModel,​java.lang.String> cmsVersionToDataConverter)
      • setCmsVersionToModelPreviewConverter

        public void setCmsVersionToModelPreviewConverter​(Converter<CMSVersionModel,​ItemModel> cmsVersionToModelPreviewConverter)
      • setCmsSessionSearchRestrictionsDisabler

        public void setCmsSessionSearchRestrictionsDisabler​(SessionSearchRestrictionsDisabler cmsSessionSearchRestrictionsDisabler)
      • setCmsVersionToModelRollbackConverter

        public void setCmsVersionToModelRollbackConverter​(Converter<CMSVersionModel,​ItemModel> cmsVersionToModelRollbackConverter)
      • setPermissionCRUDService

        public void setPermissionCRUDService​(PermissionCRUDService permissionCRUDService)
      • getPageTypePredicate

        protected java.util.function.Predicate<ItemModel> getPageTypePredicate()
      • setPageTypePredicate

        public void setPageTypePredicate​(java.util.function.Predicate<ItemModel> pageTypePredicate)
      • getContentPageTypePredicate

        protected java.util.function.Predicate<ItemModel> getContentPageTypePredicate()
      • setContentPageTypePredicate

        public void setContentPageTypePredicate​(java.util.function.Predicate<ItemModel> contentPageTypePredicate)