Class DefaultCMSVersionService

java.lang.Object
de.hybris.platform.cms2.version.service.impl.DefaultCMSVersionService
All Implemented Interfaces:
CMSVersionService

public class DefaultCMSVersionService extends Object implements CMSVersionService
Default implementation of the CMSVersionService
  • Constructor Details

    • DefaultCMSVersionService

      public DefaultCMSVersionService()
  • Method Details

    • generatePayloadForVersion

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

      public ItemModel createItemFromVersion(CMSVersionModel version)
      Creates a new ItemModel and populates the item model using the data saved in the CMSVersionModel.
      Primary key field values will be created on saving the ItemModel to the persistence store, including any ItemModel's that are in relationship with the target ItemModel.
      Specified by:
      createItemFromVersion in interface CMSVersionService
      Parameters:
      version - The version used to create an ItemModel
      Returns:
      The new ItemModel created from the version payload
    • 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 Optional<CMSVersionModel> getVersionByUid(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 Optional<CMSVersionModel> getVersionByLabel(CMSItemModel itemModel, 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()
    • getVersionsForItem

      protected List<CMSVersionModel> getVersionsForItem(CMSItemModel itemModel)
      Finds all CMSVersionModel versions for a given CMSItemModel
      Parameters:
      itemModel - the item model for which to return all versions
      Returns:
      A List of CMSVersionModel
    • getTransactionId

      public 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, String label, 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 Optional<ItemModel> rollbackVersionForUid(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 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 Optional<AbstractPageModel> findPageVersionedByTransactionId(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 String generateTransactionId()
      Generates transaction id using transactionIdGenerator.
    • getCMSItemByVersion

      protected CMSItemModel getCMSItemByVersion(CMSVersionModel version)
    • checkReadTypePermission

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

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

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

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

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

      protected PersistentKeyGenerator getVersionUidGenerator()
    • setVersionUidGenerator

      public void setVersionUidGenerator(PersistentKeyGenerator versionUidGenerator)
    • getTransactionIdGenerator

      protected PersistentKeyGenerator getTransactionIdGenerator()
    • setTransactionIdGenerator

      public void setTransactionIdGenerator(PersistentKeyGenerator transactionIdGenerator)
    • getSessionService

      protected SessionService getSessionService()
    • 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)
    • getCmsAdminItemService

      protected CMSAdminItemService getCmsAdminItemService()
    • setCmsAdminItemService

      public void setCmsAdminItemService(CMSAdminItemService cmsAdminItemService)
    • getCmsVersionDao

      protected CMSVersionDao getCmsVersionDao()
    • setCmsVersionDao

      public void setCmsVersionDao(CMSVersionDao cmsVersionDao)
    • getCmsAdminContentSlotService

      public CMSAdminContentSlotService getCmsAdminContentSlotService()
    • setCmsAdminContentSlotService

      public void setCmsAdminContentSlotService(CMSAdminContentSlotService cmsAdminContentSlotService)
    • getCmsAdminSiteService

      protected CMSAdminSiteService getCmsAdminSiteService()
    • setCmsAdminSiteService

      public void setCmsAdminSiteService(CMSAdminSiteService cmsAdminSiteService)
    • getCmsVersionToDataConverter

      protected Converter<ItemModel,String> getCmsVersionToDataConverter()
    • setCmsVersionToDataConverter

      public void setCmsVersionToDataConverter(Converter<ItemModel,String> cmsVersionToDataConverter)
    • getCmsVersionToModelPreviewConverter

      protected Converter<CMSVersionModel,ItemModel> getCmsVersionToModelPreviewConverter()
    • setCmsVersionToModelPreviewConverter

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

      protected CMSVersionSessionContextProvider getCmsVersionSessionContextProvider()
    • setCmsVersionSessionContextProvider

      public void setCmsVersionSessionContextProvider(CMSVersionSessionContextProvider cmsVersionSessionContextProvider)
    • getCmsSessionSearchRestrictionsDisabler

      public SessionSearchRestrictionsDisabler getCmsSessionSearchRestrictionsDisabler()
    • setCmsSessionSearchRestrictionsDisabler

      public void setCmsSessionSearchRestrictionsDisabler(SessionSearchRestrictionsDisabler cmsSessionSearchRestrictionsDisabler)
    • getCmsVersionToModelRollbackConverter

      public Converter<CMSVersionModel,ItemModel> getCmsVersionToModelRollbackConverter()
    • setCmsVersionToModelRollbackConverter

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

      protected PermissionCRUDService getPermissionCRUDService()
    • setPermissionCRUDService

      public void setPermissionCRUDService(PermissionCRUDService permissionCRUDService)
    • getPageTypePredicate

      protected Predicate<ItemModel> getPageTypePredicate()
    • setPageTypePredicate

      public void setPageTypePredicate(Predicate<ItemModel> pageTypePredicate)
    • getContentPageTypePredicate

      protected Predicate<ItemModel> getContentPageTypePredicate()
    • setContentPageTypePredicate

      public void setContentPageTypePredicate(Predicate<ItemModel> contentPageTypePredicate)