Class ItemSynchronizationValidator
- java.lang.Object
-
- de.hybris.platform.cmsfacades.synchronization.validator.ItemSynchronizationValidator
-
- All Implemented Interfaces:
org.springframework.validation.Validator
public class ItemSynchronizationValidator extends java.lang.Object implements org.springframework.validation.ValidatorValidates that the items inSynchronizationDatacan be synchronized.Rules to determine if an item can be synchronized:
- If the CmsItem is a page then it must be approved.
- If the CmsItem is a slot it must be a shared slot or used within a page that is approved.
- Otherwise, the CmsItem must only be used in shared slots or within a page that is approved.
-
-
Constructor Summary
Constructors Constructor Description ItemSynchronizationValidator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleanareAllRelatedSlotsApproved(java.util.List<CMSItemModel> items)This method checks if all the slots in the given list are allowed to be synchronized.protected ContentSlotPredicategetCmsContentSlotPredicate()protected ItemModelgetItem(ItemSynchronizationData itemSynchronizationData)This method is used to retrieve theItemModelreferenced by the givenItemSynchronizationData.protected AbstractPageTypePredicategetPageTypePredicate()protected RelatedItemsServicegetRelatedItemsService()protected UniqueItemIdentifierServicegetUniqueItemIdentifierService()protected booleanhasNoRelatedPages(java.util.List<CMSItemModel> items)This method is used to ensure there are no pages in the given list.protected booleanisAnyRelatedPageApproved(java.util.List<CMSItemModel> items)This method is used to check if there is at least one page approved to be synchronized in the given list.protected booleanisCmsItemApproved(ItemModel itemModel)This method is called to determine if the givenCMSItemModelis approved to be synchronized.protected booleanisPage(CMSItemModel itemModel)This method is used to determine if the givenCMSItemModelis a page (is an instance ofAbstractPageModelor one of its subclasses).protected booleanisPageApproved(CMSItemModel itemModel)This method is used to determine if a given page has been approved to be synchronized.protected booleanisSlot(CMSItemModel itemModel)This method is used to determine if the givenCMSItemModelis a slot.protected booleanisSlotApproved(CMSItemModel cmsItem)This method is used to determine if a given slot can be synchronized.voidsetCmsContentSlotPredicate(ContentSlotPredicate cmsContentSlotPredicate)voidsetPageTypePredicate(AbstractPageTypePredicate pageTypePredicate)voidsetRelatedItemsService(RelatedItemsService relatedItemsService)voidsetUniqueItemIdentifierService(UniqueItemIdentifierService uniqueItemIdentifierService)booleansupports(java.lang.Class<?> clazz)voidvalidate(java.lang.Object objToValidate, org.springframework.validation.Errors errors)
-
-
-
Method Detail
-
supports
public boolean supports(java.lang.Class<?> clazz)
- Specified by:
supportsin interfaceorg.springframework.validation.Validator
-
validate
public void validate(java.lang.Object objToValidate, org.springframework.validation.Errors errors)- Specified by:
validatein interfaceorg.springframework.validation.Validator
-
isCmsItemApproved
protected boolean isCmsItemApproved(ItemModel itemModel)
This method is called to determine if the givenCMSItemModelis approved to be synchronized.- Parameters:
itemModel- The item to check if it has been approved to be synchronized.- Returns:
- boolean True if the item is approved to be synchronized. False, otherwise.
-
isPage
protected boolean isPage(CMSItemModel itemModel)
This method is used to determine if the givenCMSItemModelis a page (is an instance ofAbstractPageModelor one of its subclasses).- Parameters:
itemModel- The item to check if it is a page- Returns:
- boolean True if the item is a page. False, otherwise.
-
isSlot
protected boolean isSlot(CMSItemModel itemModel)
This method is used to determine if the givenCMSItemModelis a slot.- Parameters:
itemModel- The item to check if it is a slot- Returns:
- boolean True if the item is a slot. False, otherwise.
-
isPageApproved
protected boolean isPageApproved(CMSItemModel itemModel)
This method is used to determine if a given page has been approved to be synchronized.- Parameters:
itemModel- The page to check if it has been approved.- Returns:
- boolean True if the page has been approved. False, otherwise.
-
isSlotApproved
protected boolean isSlotApproved(CMSItemModel cmsItem)
This method is used to determine if a given slot can be synchronized. This can only happen if the slot is a shared slot or if it's related to at least one page that is approved to be synchronized.- Parameters:
cmsItem- The slot to check if it can be synchronized.- Returns:
- boolean True if the slot can be synchronized. False, otherwise.
-
isAnyRelatedPageApproved
protected boolean isAnyRelatedPageApproved(java.util.List<CMSItemModel> items)
This method is used to check if there is at least one page approved to be synchronized in the given list.- Parameters:
items- The items where to look for pages.- Returns:
- boolean True if at least one page is approved. False, otherwise.
-
areAllRelatedSlotsApproved
protected boolean areAllRelatedSlotsApproved(java.util.List<CMSItemModel> items)
This method checks if all the slots in the given list are allowed to be synchronized. A slot can be synchronized if it is a shared slot or if it's related to at least one page that is approved to be synchronized.- Parameters:
items- The items where to look for the slots to check.- Returns:
- boolean True if all the slots are approved. False, otherwise.
-
hasNoRelatedPages
protected boolean hasNoRelatedPages(java.util.List<CMSItemModel> items)
This method is used to ensure there are no pages in the given list.- Parameters:
items- The items where to look for pages.- Returns:
- boolean True if no pages were found in the given list. False, otherwise.
-
getItem
protected ItemModel getItem(ItemSynchronizationData itemSynchronizationData)
This method is used to retrieve theItemModelreferenced by the givenItemSynchronizationData.- Parameters:
itemSynchronizationData- The object that contains the data that identifies the itemModel to retrieve- Returns:
- the retrieved ItemModel.
-
getUniqueItemIdentifierService
protected UniqueItemIdentifierService getUniqueItemIdentifierService()
-
setUniqueItemIdentifierService
public void setUniqueItemIdentifierService(UniqueItemIdentifierService uniqueItemIdentifierService)
-
getRelatedItemsService
protected RelatedItemsService getRelatedItemsService()
-
setRelatedItemsService
public void setRelatedItemsService(RelatedItemsService relatedItemsService)
-
getCmsContentSlotPredicate
protected ContentSlotPredicate getCmsContentSlotPredicate()
-
setCmsContentSlotPredicate
public void setCmsContentSlotPredicate(ContentSlotPredicate cmsContentSlotPredicate)
-
getPageTypePredicate
protected AbstractPageTypePredicate getPageTypePredicate()
-
setPageTypePredicate
public void setPageTypePredicate(AbstractPageTypePredicate pageTypePredicate)
-
-