Interface CMSVersionService
- All Known Implementing Classes:
DefaultCMSVersionService
public interface CMSVersionService
Service that provides helper methods for versioning items of type
ItemModel.-
Method Summary
Modifier and TypeMethodDescriptioncreateItemFromVersion(CMSVersionModel version) Creates a newItemModeland populates the item model using the data saved in theCMSVersionModel.createRevisionForItem(CMSItemModel itemModel) Creates a revision for the given item and updates its payload.createVersionForItem(CMSItemModel itemModel, String label, String description) Creates a version for the given item and updates its payload.voiddeleteVersionsForItem(CMSItemModel itemModel) Deletes all tagged versions for aCMSItemModel.findPageVersionedByTransactionId(String transactionId) Finds the page associated to a transaction ID.Generates version uid using versionUidGenerator.getItemFromVersion(CMSVersionModel version) Retrieves an existingItemModeland populates the item model using the data saved in theCMSVersionModel.Returns the version ID stored in the session attributeSessionServiceCms2Constants.SESSION_VERSION_TRANSACTION_ID.getVersionByLabel(CMSItemModel itemModel, String label) Finds the {code CMSVersionModel} containing the provided label for a given item.getVersionByUid(String uid) Finds the {code CMSVersionModel} by uid.booleanisVersionable(CMSItemModel itemModel) Determines if an itemModel is versionableRolls back anItemModelto a specific version.
-
Method Details
-
createItemFromVersion
Creates a newItemModeland populates the item model using the data saved in theCMSVersionModel.- Parameters:
version- The version used to create anItemModel- Returns:
- The new
ItemModelcreated from the version payload
-
getItemFromVersion
Retrieves an existingItemModeland populates the item model using the data saved in theCMSVersionModel.- Parameters:
version- The version used to retrieve anItemModel- Returns:
- The existing
ItemModelupdated with the data from the version payload
-
getVersionByUid
Finds the {code CMSVersionModel} by uid.- Parameters:
uid- The uid of the CMSVersion model- Returns:
- The CMSVersion model; can be
Optional#empty()
-
getVersionByLabel
Finds the {code CMSVersionModel} containing the provided label for a given item.- Parameters:
itemModel- the item model containing all the versions to search inlabel- the label on the cms version to search for- Returns:
- The CMSVersion model; can be
Optional#empty()
-
getTransactionId
String getTransactionId()Returns the version ID stored in the session attributeSessionServiceCms2Constants.SESSION_VERSION_TRANSACTION_ID.- Returns:
- The Version ID.
-
createRevisionForItem
Creates a revision for the given item and updates its payload.Note that a "revision" is a
CMSVersionModelwithout a label.- Parameters:
itemModel- The item model for versioning.- Returns:
- The CMSVersion model.
-
createVersionForItem
Creates a version for the given item and updates its payload.Note that a "version" is a
CMSVersionModelwith an existing label.- Parameters:
itemModel- The item model for versioning.label- The label for the versiondescription- The description for the version- Returns:
- The CMSVersion model.
-
rollbackVersionForUid
Rolls back anItemModelto a specific version. If no version is found, anOptional#empty()is returned.- Parameters:
uid- The uid of theCMSVersionModelwhich theItemModelwill be rolled back to- Returns:
- an
Optionalcontaining the updatedItemModelafter it was rolled back; can beOptional#empty()when no version is found to perform the rollback operation.
-
isVersionable
Determines if an itemModel is versionable- Parameters:
itemModel- The item model.- Returns:
- TRUE if the item is versionable; FALSE otherwise.
-
generateVersionUid
String generateVersionUid()Generates version uid using versionUidGenerator.- Returns:
- The uid of the version.
-
deleteVersionsForItem
Deletes all tagged versions for aCMSItemModel. 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
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
Optionalcontaining the page associated to the given transactionId; can beOptional#empty()when the transactionId identifies a transaction where a page was not versioned.
-