Interface CMSVersionService
-
- All Known Implementing Classes:
DefaultCMSVersionService
public interface CMSVersionService
Service that provides helper methods for versioning items of typeItemModel
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ItemModel
createItemFromVersion(CMSVersionModel version)
Creates a newItemModel
and populates the item model using the data saved in theCMSVersionModel
.CMSVersionModel
createRevisionForItem(CMSItemModel itemModel)
Creates a revision for the given item and updates its payload.CMSVersionModel
createVersionForItem(CMSItemModel itemModel, java.lang.String label, java.lang.String description)
Creates a version for the given item and updates its payload.void
deleteVersionsForItem(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.String
generateVersionUid()
Generates version uid using versionUidGenerator.ItemModel
getItemFromVersion(CMSVersionModel version)
Retrieves an existingItemModel
and populates the item model using the data saved in theCMSVersionModel
.java.lang.String
getTransactionId()
Returns the version ID stored in the session attributeSessionService
Cms2Constants.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.boolean
isVersionable(CMSItemModel itemModel)
Determines if an itemModel is versionablejava.util.Optional<ItemModel>
rollbackVersionForUid(java.lang.String uid)
Rolls back anItemModel
to a specific version.
-
-
-
Method Detail
-
createItemFromVersion
ItemModel createItemFromVersion(CMSVersionModel version)
Creates a newItemModel
and populates the item model using the data saved in theCMSVersionModel
.- Parameters:
version
- The version used to create anItemModel
- Returns:
- The new
ItemModel
created from the version payload
-
getItemFromVersion
ItemModel getItemFromVersion(CMSVersionModel version)
Retrieves an existingItemModel
and populates the item model using the data saved in theCMSVersionModel
.- Parameters:
version
- The version used to retrieve anItemModel
- 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 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 attributeSessionService
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 versiondescription
- The description for the version- Returns:
- The CMSVersion model.
-
rollbackVersionForUid
java.util.Optional<ItemModel> rollbackVersionForUid(java.lang.String uid)
Rolls back anItemModel
to a specific version. If no version is found, anOptional#empty()
is returned.- Parameters:
uid
- The uid of theCMSVersionModel
which theItemModel
will be rolled back to- Returns:
- an
Optional
containing the updatedItemModel
after 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
Optional
containing the page associated to the given transactionId; can beOptional#empty()
when the transactionId identifies a transaction where a page was not versioned.
-
-