Interface CMSVersionService
-
- All Known Implementing Classes:
DefaultCMSVersionService
public interface CMSVersionServiceService that provides helper methods for versioning items of typeItemModel.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ItemModelcreateItemFromVersion(CMSVersionModel version)Creates a newItemModeland populates the item model using the data saved in theCMSVersionModel.CMSVersionModelcreateRevisionForItem(CMSItemModel itemModel)Creates a revision for the given item and updates its payload.CMSVersionModelcreateVersionForItem(CMSItemModel itemModel, java.lang.String label, java.lang.String description)Creates a version for the given item and updates its payload.voiddeleteVersionsForItem(CMSItemModel itemModel)Deletes all tagged versions for aCMSItemModel.java.util.Optional<AbstractPageModel>findPageVersionedByTransactionId(java.lang.String transactionId)Finds the page associated to a transaction ID.java.lang.StringgenerateVersionUid()Generates version uid using versionUidGenerator.ItemModelgetItemFromVersion(CMSVersionModel version)Retrieves an existingItemModeland populates the item model using the data saved in theCMSVersionModel.java.lang.StringgetTransactionId()Returns the version ID stored in the session attributeSessionServiceCms2Constants.SESSION_VERSION_TRANSACTION_ID.java.util.Optional<CMSVersionModel>getVersionByLabel(CMSItemModel itemModel, java.lang.String label)Finds the {code CMSVersionModel} containing the provided label for a given item.java.util.Optional<CMSVersionModel>getVersionByUid(java.lang.String uid)Finds the {code CMSVersionModel} by uid.booleanisVersionable(CMSItemModel itemModel)Determines if an itemModel is versionablejava.util.Optional<ItemModel>rollbackVersionForUid(java.lang.String uid)Rolls back anItemModelto a specific version.
-
-
-
Method Detail
-
createItemFromVersion
ItemModel createItemFromVersion(CMSVersionModel version)
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
ItemModel getItemFromVersion(CMSVersionModel version)
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
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 inlabel- 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 attributeSessionServiceCms2Constants.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
CMSVersionModelwithout 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
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
java.util.Optional<ItemModel> rollbackVersionForUid(java.lang.String uid)
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
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 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
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
Optionalcontaining the page associated to the given transactionId; can beOptional#empty()when the transactionId identifies a transaction where a page was not versioned.
-
-