Interface CMSVersionService

  • All Known Implementing Classes:
    DefaultCMSVersionService

    public interface CMSVersionService
    Service that provides helper methods for versioning items of type ItemModel.
    • Method Detail

      • createItemFromVersion

        ItemModel createItemFromVersion​(CMSVersionModel version)
        Creates a new ItemModel and populates the item model using the data saved in the CMSVersionModel.
        Parameters:
        version - The version used to create an ItemModel
        Returns:
        The new ItemModel created from the version payload
      • getItemFromVersion

        ItemModel getItemFromVersion​(CMSVersionModel version)
        Retrieves an existing ItemModel and populates the item model using the data saved in the CMSVersionModel.
        Parameters:
        version - The version used to retrieve an ItemModel
        Returns:
        The existing ItemModel updated with the data from the version payload
      • getVersionByUid

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

        java.util.Optional<CMSVersionModel> getVersionByLabel​(CMSItemModel itemModel,
                                                              java.lang.String label)
        Finds the {code CMSVersionModel} containing the provided label for a given item.
        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

        java.lang.String getTransactionId()
        Returns the version ID stored in the session attribute SessionService Cms2Constants.SESSION_VERSION_TRANSACTION_ID.
        Returns:
        The Version ID.
      • createRevisionForItem

        CMSVersionModel createRevisionForItem​(CMSItemModel itemModel)
        Creates a revision for the given item and updates its payload.

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

        Parameters:
        itemModel - The item model for versioning.
        Returns:
        The CMSVersion model.
      • createVersionForItem

        CMSVersionModel createVersionForItem​(CMSItemModel itemModel,
                                             java.lang.String label,
                                             java.lang.String description)
        Creates a version for the given item and updates its payload.

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

        Parameters:
        itemModel - The item model for versioning.
        label - The label for the version
        description - The description for the version
        Returns:
        The CMSVersion model.
      • rollbackVersionForUid

        java.util.Optional<ItemModel> rollbackVersionForUid​(java.lang.String uid)
        Rolls back an ItemModel to a specific version. If no version is found, an Optional#empty() is returned.
        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.
      • isVersionable

        boolean isVersionable​(CMSItemModel itemModel)
        Determines if an itemModel is versionable
        Parameters:
        itemModel - The item model.
        Returns:
        TRUE if the item is versionable; FALSE otherwise.
      • generateVersionUid

        java.lang.String generateVersionUid()
        Generates version uid using versionUidGenerator.
        Returns:
        The uid of the version.
      • deleteVersionsForItem

        void deleteVersionsForItem​(CMSItemModel itemModel)
        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.
        Parameters:
        itemModel - the item model for which all related tagged versions will be deleted
      • findPageVersionedByTransactionId

        java.util.Optional<AbstractPageModel> findPageVersionedByTransactionId​(java.lang.String transactionId)
        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.

        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.