Class DefaultCMSVersionService
java.lang.Object
de.hybris.platform.cms2.version.service.impl.DefaultCMSVersionService
- All Implemented Interfaces:
CMSVersionService
Default implementation of the
CMSVersionService-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanbelongsToPage(CMSItemModel itemModel) Determines if the item is a content slot defined for the page (ContentSlotForPage relation) or the page template (ContentSlotForTemplate relation).protected voidcheckChangeTypePermission(String typeCode) Checks whether current user has CHANGE type permission for typeCode;protected voidcheckCreateTypePermission(String typeCode) Checks whether current user has CREATE type permission for typeCode;protected voidcheckReadTypePermission(String typeCode) Checks whether current user has READ type permission for typeCode;protected voidcheckRemoveTypePermission(String typeCode) Checks whether current user has REMOVE type permission for typeCode;createItemFromVersion(CMSVersionModel version) Creates a newItemModeland populates the item model using the data saved in theCMSVersionModel.protected CMSVersionModelcreatePartialVersionForItem(CMSItemModel itemModel) Generates a partial version for ItemModel.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.protected StringgeneratePayloadForVersion(CMSVersionModel version) Generates a payload for a version.protected StringGenerates transaction id using transactionIdGenerator.Generates version uid using versionUidGenerator.protected CMSAdminItemServiceprotected CMSAdminSiteServiceprotected CMSItemModelgetCMSItemByVersion(CMSVersionModel version) protected CMSVersionDaoprotected CMSVersionSessionContextProviderprotected Converter<CMSVersionModel,ItemModel> getItemFromVersion(CMSVersionModel version) Retrieves an existingItemModeland populates the item model using the data saved in theCMSVersionModel.protected ModelServiceprotected PermissionCRUDServiceprotected SessionServiceReturns the version ID stored in the session attributeSessionServiceCms2Constants.SESSION_VERSION_TRANSACTION_ID.protected PersistentKeyGeneratorprotected TypeServicegetVersionByLabel(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.protected List<CMSVersionModel>getVersionsForItem(CMSItemModel itemModel) Finds allCMSVersionModelversions for a givenCMSItemModelprotected PersistentKeyGeneratorprotected booleanisInActiveSessionCatalog(CMSItemModel itemModel) Determines if the item is defined in the current (active session) catalog version or in a parent catalog (multi-country).protected booleanprotected booleanisTaggedVersion(CMSVersionModel cmsVersionModel) Determines if the cms version is taggedbooleanisVersionable(CMSItemModel itemModel) Determines if an itemModel is versionableprotected voidrestoreHomepageAttribute(ItemModel itemModel) Restore homepage attribute for Content pages to use the value from the original page.Rolls back anItemModelto a specific version.voidsetCmsAdminContentSlotService(CMSAdminContentSlotService cmsAdminContentSlotService) voidsetCmsAdminItemService(CMSAdminItemService cmsAdminItemService) voidsetCmsAdminSiteService(CMSAdminSiteService cmsAdminSiteService) voidsetCmsSessionSearchRestrictionsDisabler(SessionSearchRestrictionsDisabler cmsSessionSearchRestrictionsDisabler) voidsetCmsVersionDao(CMSVersionDao cmsVersionDao) voidsetCmsVersionSessionContextProvider(CMSVersionSessionContextProvider cmsVersionSessionContextProvider) voidsetCmsVersionToDataConverter(Converter<ItemModel, String> cmsVersionToDataConverter) voidsetCmsVersionToModelPreviewConverter(Converter<CMSVersionModel, ItemModel> cmsVersionToModelPreviewConverter) voidsetCmsVersionToModelRollbackConverter(Converter<CMSVersionModel, ItemModel> cmsVersionToModelRollbackConverter) voidsetContentPageTypePredicate(Predicate<ItemModel> contentPageTypePredicate) voidsetModelService(ModelService modelService) voidsetPageTypePredicate(Predicate<ItemModel> pageTypePredicate) voidsetPermissionCRUDService(PermissionCRUDService permissionCRUDService) voidsetSessionService(SessionService sessionService) voidsetTransactionIdGenerator(PersistentKeyGenerator transactionIdGenerator) voidsetTypeService(TypeService typeService) voidsetVersionUidGenerator(PersistentKeyGenerator versionUidGenerator) protected voidthrowTypePermissionException(String permissionName, String typeCode) ThrowsTypePermissionExceptionif current user does not have permission for typeCode.protected voidupdatePageApprovalStatus(ItemModel itemModel) Updates the approval status attribute for any pages toCHECK, to indicate that the page was modified.
-
Constructor Details
-
DefaultCMSVersionService
public DefaultCMSVersionService()
-
-
Method Details
-
generatePayloadForVersion
Generates a payload for a version.- Parameters:
version- The CMSVersion model.- Returns:
- The payload for a version.
-
createItemFromVersion
Creates a newItemModeland populates the item model using the data saved in theCMSVersionModel.
Primary key field values will be created on saving theItemModelto the persistence store, including anyItemModel's that are in relationship with the targetItemModel.- Specified by:
createItemFromVersionin interfaceCMSVersionService- 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.
Primary keys will be preserved for the retrievedItemModeland anyItemModel's that are in relationship with the target.- Specified by:
getItemFromVersionin interfaceCMSVersionService- Parameters:
version- The version used to retrieve anItemModel- Returns:
- The existing
ItemModelupdated with the data from the version payload
-
getVersionByUid
Description copied from interface:CMSVersionServiceFinds the {code CMSVersionModel} by uid.- Specified by:
getVersionByUidin interfaceCMSVersionService- Parameters:
uid- The uid of the CMSVersion model- Returns:
- The CMSVersion model; can be
Optional#empty()
-
getVersionByLabel
Description copied from interface:CMSVersionServiceFinds the {code CMSVersionModel} containing the provided label for a given item.- Specified by:
getVersionByLabelin interfaceCMSVersionService- 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()
-
getVersionsForItem
Finds allCMSVersionModelversions for a givenCMSItemModel- Parameters:
itemModel- the item model for which to return all versions- Returns:
- A List of
CMSVersionModel
-
getTransactionId
Description copied from interface:CMSVersionServiceReturns the version ID stored in the session attributeSessionServiceCms2Constants.SESSION_VERSION_TRANSACTION_ID.- Specified by:
getTransactionIdin interfaceCMSVersionService- Returns:
- The Version ID.
-
createRevisionForItem
Description copied from interface:CMSVersionServiceCreates a revision for the given item and updates its payload.Note that a "revision" is a
CMSVersionModelwithout a label.- Specified by:
createRevisionForItemin interfaceCMSVersionService- 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:CMSVersionServiceCreates a version for the given item and updates its payload.Note that a "version" is a
CMSVersionModelwith an existing label.- Specified by:
createVersionForItemin interfaceCMSVersionService- Parameters:
itemModel- The item model for versioning.label- The label for the versiondescription- The description for the version- Returns:
- The CMSVersion model.
-
rollbackVersionForUid
Description copied from interface:CMSVersionServiceRolls back anItemModelto a specific version. If no version is found, anOptional#empty()is returned.- Specified by:
rollbackVersionForUidin interfaceCMSVersionService- 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.
-
isPreview
protected boolean isPreview() -
restoreHomepageAttribute
Restore homepage attribute for Content pages to use the value from the original page.- Parameters:
itemModel- the item model.
-
updatePageApprovalStatus
Updates the approval status attribute for any pages toCHECK, to indicate that the page was modified.- Parameters:
itemModel- the item model.
-
createPartialVersionForItem
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
Generates version uid using versionUidGenerator.- Specified by:
generateVersionUidin interfaceCMSVersionService- Returns:
- The uid of the version.
-
isVersionable
Determines if an itemModel is versionable An item is versionable when:- ItemModel is a CMSItemModel
- CMSItemModel is in the currently active CatalogVersion
- CMSItemModel is not a shared content slot
- Specified by:
isVersionablein interfaceCMSVersionService- Parameters:
itemModel- The item model.- Returns:
- TRUE if the item is versionable; FALSE otherwise.
-
deleteVersionsForItem
Description copied from interface:CMSVersionServiceDeletes 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.- Specified by:
deleteVersionsForItemin interfaceCMSVersionService- Parameters:
itemModel- the item model for which all related tagged versions will be deleted
-
findPageVersionedByTransactionId
Description copied from interface:CMSVersionServiceFinds 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:
findPageVersionedByTransactionIdin interfaceCMSVersionService- 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.
-
isTaggedVersion
Determines if the cms version is tagged- Parameters:
cmsVersionModel- the cms version- Returns:
- true if the cms version has a valid label
-
isInActiveSessionCatalog
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
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
Generates transaction id using transactionIdGenerator. -
getCMSItemByVersion
-
checkReadTypePermission
Checks whether current user has READ type permission for typeCode;- Parameters:
typeCode- the type code
-
checkCreateTypePermission
Checks whether current user has CREATE type permission for typeCode;- Parameters:
typeCode- the type code
-
checkRemoveTypePermission
Checks whether current user has REMOVE type permission for typeCode;- Parameters:
typeCode- the type code
-
checkChangeTypePermission
Checks whether current user has CHANGE type permission for typeCode;- Parameters:
typeCode- the type code
-
throwTypePermissionException
ThrowsTypePermissionExceptionif current user does not have permission for typeCode.- Parameters:
permissionName-typeCode-
-
getVersionUidGenerator
-
setVersionUidGenerator
-
getTransactionIdGenerator
-
setTransactionIdGenerator
-
getSessionService
-
setSessionService
-
getModelService
-
setModelService
-
getTypeService
-
setTypeService
-
getCmsAdminItemService
-
setCmsAdminItemService
-
getCmsVersionDao
-
setCmsVersionDao
-
getCmsAdminContentSlotService
-
setCmsAdminContentSlotService
-
getCmsAdminSiteService
-
setCmsAdminSiteService
-
getCmsVersionToDataConverter
-
setCmsVersionToDataConverter
-
getCmsVersionToModelPreviewConverter
-
setCmsVersionToModelPreviewConverter
public void setCmsVersionToModelPreviewConverter(Converter<CMSVersionModel, ItemModel> cmsVersionToModelPreviewConverter) -
getCmsVersionSessionContextProvider
-
setCmsVersionSessionContextProvider
public void setCmsVersionSessionContextProvider(CMSVersionSessionContextProvider cmsVersionSessionContextProvider) -
getCmsSessionSearchRestrictionsDisabler
-
setCmsSessionSearchRestrictionsDisabler
public void setCmsSessionSearchRestrictionsDisabler(SessionSearchRestrictionsDisabler cmsSessionSearchRestrictionsDisabler) -
getCmsVersionToModelRollbackConverter
-
setCmsVersionToModelRollbackConverter
public void setCmsVersionToModelRollbackConverter(Converter<CMSVersionModel, ItemModel> cmsVersionToModelRollbackConverter) -
getPermissionCRUDService
-
setPermissionCRUDService
-
getPageTypePredicate
-
setPageTypePredicate
-
getContentPageTypePredicate
-
setContentPageTypePredicate
-