Class DefaultCMSPermissionCachedCRUDService
java.lang.Object
de.hybris.platform.cms2.permissions.impl.DefaultCMSPermissionCachedCRUDService
- All Implemented Interfaces:
PermissionCachedCRUDService,PermissionCRUDService
public class DefaultCMSPermissionCachedCRUDService
extends Object
implements PermissionCachedCRUDService
Implementation of
PermissionCRUDService that supports caching.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddAttributePermissionToCache(String permissionName, String typeCode, String qualifier, boolean hasPermission) Adds attribute permission to the cache.protected voidaddTypePermissionToCache(String permissionName, String typeCode, boolean hasPermission) Adds type permission to the cache.booleancanChangeAttribute(AttributeDescriptorModel attributeDescriptor) Returns true if the current user is grantedPermissionsConstants.CHANGEpermission to the given attribute descriptor.booleancanChangeAttribute(String typeCode, String attributeQualifier) Returns true if the current user is grantedPermissionsConstants.CHANGEpermission to the given attribute descriptor.booleancanChangeAttributePermission(AttributeDescriptorModel attributeDescriptor) Returns true if the current user is grantedPermissionsConstants.CHANGE_PERMISSIONSpermission to the given attribute descriptor.booleancanChangeAttributePermission(String typeCode, String attributeQualifier) Returns true if the current user is grantedPermissionsConstants.CHANGE_PERMISSIONSpermission to the given attribute descriptor.booleanReturns true if the current user is grantedPermissionsConstants.CHANGEpermission to the given type.booleancanChangeType(String typeCode) Returns true if the current user is grantedPermissionsConstants.CHANGEpermission to the given type.booleanReturns true if the current user is grantedPermissionsConstants.CHANGE_PERMISSIONSpermission to the given type.booleancanChangeTypePermission(String typeCode) Returns true if the current user is grantedPermissionsConstants.CHANGE_PERMISSIONSpermission to the given type.booleanReturns true if the current user is grantedPermissionsConstants.CREATEpermission to the given type.booleancanCreateTypeInstance(String typeCode) Returns true if the current user is grantedPermissionsConstants.CREATEpermission to the given type.booleancanReadAttribute(AttributeDescriptorModel attributeDescriptor) Returns true if the current user is grantedPermissionsConstants.READpermission to the given attribute descriptor.booleancanReadAttribute(String typeCode, String attributeQualifier) Returns true if the current user is grantedPermissionsConstants.READpermission to the given attribute descriptor.booleancanReadType(ComposedTypeModel type) Returns true if the current user is grantedPermissionsConstants.READpermission to the given type.booleancanReadType(String typeCode) Returns true if the current user is grantedPermissionsConstants.READpermission to the given type.booleanReturns true if the current user is grantedPermissionsConstants.REMOVEpermission to the given type.booleancanRemoveTypeInstance(String typeCode) Returns true if the current user is grantedPermissionsConstants.REMOVEpermission to the given type.protected booleangetOrSetCachedAttributePermission(String permissionName, AttributeDescriptorModel attributeDescriptor, BiFunction<String, String, Boolean> permissionChecker) protected booleangetOrSetCachedAttributePermission(String permissionName, String typeCode, String qualifier, BiFunction<String, String, Boolean> permissionChecker) Returns attribute permission from the cache if it exists, calculates the permission and puts to the cache otherwise.protected booleangetOrSetCachedTypePermission(String permissionName, ComposedTypeModel composedType, Function<String, Boolean> permissionChecker) protected booleangetOrSetCachedTypePermission(String permissionName, String typeCode, Function<String, Boolean> permissionChecker) Returns type permission from the cache if it exists, calculates the permission and puts to the cache otherwise.protected PermissionCRUDServiceprotected PermissionEnablerServiceprotected SessionCachedContextProviderprotected StringgetUniqueAttributeKey(String permissionName, String typeCode, String qualifier) Generates a unique name to store attribute permission in the cacheprotected StringgetUniqueTypeKey(String permissionName, String typeCode) voidInitialize the cache, it creates cache objects in current session.voidsetPermissionCRUDService(PermissionCRUDService permissionCRUDService) voidsetPermissionEnablerService(PermissionEnablerService permissionEnablerService) voidsetSessionCachedContextProvider(SessionCachedContextProvider sessionCachedContextProvider)
-
Field Details
-
KEY_DELIMITER
- See Also:
-
-
Constructor Details
-
DefaultCMSPermissionCachedCRUDService
public DefaultCMSPermissionCachedCRUDService()
-
-
Method Details
-
initCache
public void initCache()Description copied from interface:PermissionCachedCRUDServiceInitialize the cache, it creates cache objects in current session.- Specified by:
initCachein interfacePermissionCachedCRUDService
-
canReadAttribute
Description copied from interface:PermissionCRUDServiceReturns true if the current user is grantedPermissionsConstants.READpermission to the given attribute descriptor. Returns false otherwise.- Specified by:
canReadAttributein interfacePermissionCRUDService
-
canReadAttribute
Description copied from interface:PermissionCRUDServiceReturns true if the current user is grantedPermissionsConstants.READpermission to the given attribute descriptor. Returns false otherwise.- Specified by:
canReadAttributein interfacePermissionCRUDService
-
canChangeAttribute
Description copied from interface:PermissionCRUDServiceReturns true if the current user is grantedPermissionsConstants.CHANGEpermission to the given attribute descriptor. Returns false otherwise.- Specified by:
canChangeAttributein interfacePermissionCRUDService
-
canChangeAttribute
Description copied from interface:PermissionCRUDServiceReturns true if the current user is grantedPermissionsConstants.CHANGEpermission to the given attribute descriptor. Returns false otherwise.- Specified by:
canChangeAttributein interfacePermissionCRUDService
-
canReadType
Description copied from interface:PermissionCRUDServiceReturns true if the current user is grantedPermissionsConstants.READpermission to the given type. Returns false otherwise.- Specified by:
canReadTypein interfacePermissionCRUDService
-
canReadType
Description copied from interface:PermissionCRUDServiceReturns true if the current user is grantedPermissionsConstants.READpermission to the given type. Returns false otherwise.- Specified by:
canReadTypein interfacePermissionCRUDService
-
canChangeType
Description copied from interface:PermissionCRUDServiceReturns true if the current user is grantedPermissionsConstants.CHANGEpermission to the given type. Returns false otherwise.- Specified by:
canChangeTypein interfacePermissionCRUDService
-
canChangeType
Description copied from interface:PermissionCRUDServiceReturns true if the current user is grantedPermissionsConstants.CHANGEpermission to the given type. Returns false otherwise.- Specified by:
canChangeTypein interfacePermissionCRUDService
-
canCreateTypeInstance
Description copied from interface:PermissionCRUDServiceReturns true if the current user is grantedPermissionsConstants.CREATEpermission to the given type. Returns false otherwise.- Specified by:
canCreateTypeInstancein interfacePermissionCRUDService
-
canCreateTypeInstance
Description copied from interface:PermissionCRUDServiceReturns true if the current user is grantedPermissionsConstants.CREATEpermission to the given type. Returns false otherwise.- Specified by:
canCreateTypeInstancein interfacePermissionCRUDService
-
canRemoveTypeInstance
Description copied from interface:PermissionCRUDServiceReturns true if the current user is grantedPermissionsConstants.REMOVEpermission to the given type. Returns false otherwise.- Specified by:
canRemoveTypeInstancein interfacePermissionCRUDService
-
canRemoveTypeInstance
Description copied from interface:PermissionCRUDServiceReturns true if the current user is grantedPermissionsConstants.REMOVEpermission to the given type. Returns false otherwise.- Specified by:
canRemoveTypeInstancein interfacePermissionCRUDService
-
canChangeTypePermission
Description copied from interface:PermissionCRUDServiceReturns true if the current user is grantedPermissionsConstants.CHANGE_PERMISSIONSpermission to the given type. Returns false otherwise.- Specified by:
canChangeTypePermissionin interfacePermissionCRUDService
-
canChangeTypePermission
Description copied from interface:PermissionCRUDServiceReturns true if the current user is grantedPermissionsConstants.CHANGE_PERMISSIONSpermission to the given type. Returns false otherwise.- Specified by:
canChangeTypePermissionin interfacePermissionCRUDService
-
canChangeAttributePermission
Description copied from interface:PermissionCRUDServiceReturns true if the current user is grantedPermissionsConstants.CHANGE_PERMISSIONSpermission to the given attribute descriptor. Returns false otherwise.- Specified by:
canChangeAttributePermissionin interfacePermissionCRUDService
-
canChangeAttributePermission
Description copied from interface:PermissionCRUDServiceReturns true if the current user is grantedPermissionsConstants.CHANGE_PERMISSIONSpermission to the given attribute descriptor. Returns false otherwise.- Specified by:
canChangeAttributePermissionin interfacePermissionCRUDService
-
getOrSetCachedTypePermission
protected boolean getOrSetCachedTypePermission(String permissionName, String typeCode, Function<String, Boolean> permissionChecker) Returns type permission from the cache if it exists, calculates the permission and puts to the cache otherwise.- Parameters:
permissionName- permission nametypeCode- type codepermissionChecker- theFunctionto verify permission if it does not exist in the cache.- Returns:
- true if current user has permission, false otherwise.
-
getOrSetCachedTypePermission
protected boolean getOrSetCachedTypePermission(String permissionName, ComposedTypeModel composedType, Function<String, Boolean> permissionChecker) -
getOrSetCachedAttributePermission
protected boolean getOrSetCachedAttributePermission(String permissionName, String typeCode, String qualifier, BiFunction<String, String, Boolean> permissionChecker) Returns attribute permission from the cache if it exists, calculates the permission and puts to the cache otherwise.- Parameters:
permissionName- permission nametypeCode- type codequalifier- attribute qualifierpermissionChecker- theBiFunctionto verify permission if it does not exist in the cache.- Returns:
- true if current user has permission, false otherwise.
-
getOrSetCachedAttributePermission
protected boolean getOrSetCachedAttributePermission(String permissionName, AttributeDescriptorModel attributeDescriptor, BiFunction<String, String, Boolean> permissionChecker) -
addAttributePermissionToCache
protected void addAttributePermissionToCache(String permissionName, String typeCode, String qualifier, boolean hasPermission) Adds attribute permission to the cache.- Parameters:
permissionName- permission nametypeCode- type codequalifier- attribute qualifierhasPermission- true if current user has permission, false otherwise.
-
addTypePermissionToCache
protected void addTypePermissionToCache(String permissionName, String typeCode, boolean hasPermission) Adds type permission to the cache.- Parameters:
permissionName- permission nametypeCode- type codehasPermission- true if current user has permission, false otherwise.
-
getUniqueAttributeKey
Generates a unique name to store attribute permission in the cache- Parameters:
permissionName- permission nametypeCode- type codequalifier- attribute qualifier- Returns:
- the unique name for an attribute permission
-
getUniqueTypeKey
-
getSessionCachedContextProvider
-
setSessionCachedContextProvider
public void setSessionCachedContextProvider(SessionCachedContextProvider sessionCachedContextProvider) -
getPermissionCRUDService
-
setPermissionCRUDService
-
getPermissionEnablerService
-
setPermissionEnablerService
-