Class DefaultCMSPermissionCachedCRUDService
- java.lang.Object
-
- de.hybris.platform.cms2.permissions.impl.DefaultCMSPermissionCachedCRUDService
-
- All Implemented Interfaces:
PermissionCachedCRUDService,PermissionCRUDService
public class DefaultCMSPermissionCachedCRUDService extends java.lang.Object implements PermissionCachedCRUDService
Implementation ofPermissionCRUDServicethat supports caching.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringKEY_DELIMITER
-
Constructor Summary
Constructors Constructor Description DefaultCMSPermissionCachedCRUDService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddAttributePermissionToCache(java.lang.String permissionName, java.lang.String typeCode, java.lang.String qualifier, boolean hasPermission)Adds attribute permission to the cache.protected voidaddTypePermissionToCache(java.lang.String permissionName, java.lang.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(java.lang.String typeCode, java.lang.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(java.lang.String typeCode, java.lang.String attributeQualifier)Returns true if the current user is grantedPermissionsConstants.CHANGE_PERMISSIONSpermission to the given attribute descriptor.booleancanChangeType(ComposedTypeModel type)Returns true if the current user is grantedPermissionsConstants.CHANGEpermission to the given type.booleancanChangeType(java.lang.String typeCode)Returns true if the current user is grantedPermissionsConstants.CHANGEpermission to the given type.booleancanChangeTypePermission(ComposedTypeModel type)Returns true if the current user is grantedPermissionsConstants.CHANGE_PERMISSIONSpermission to the given type.booleancanChangeTypePermission(java.lang.String typeCode)Returns true if the current user is grantedPermissionsConstants.CHANGE_PERMISSIONSpermission to the given type.booleancanCreateTypeInstance(ComposedTypeModel type)Returns true if the current user is grantedPermissionsConstants.CREATEpermission to the given type.booleancanCreateTypeInstance(java.lang.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(java.lang.String typeCode, java.lang.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(java.lang.String typeCode)Returns true if the current user is grantedPermissionsConstants.READpermission to the given type.booleancanRemoveTypeInstance(ComposedTypeModel type)Returns true if the current user is grantedPermissionsConstants.REMOVEpermission to the given type.booleancanRemoveTypeInstance(java.lang.String typeCode)Returns true if the current user is grantedPermissionsConstants.REMOVEpermission to the given type.protected booleangetOrSetCachedAttributePermission(java.lang.String permissionName, AttributeDescriptorModel attributeDescriptor, java.util.function.BiFunction<java.lang.String,java.lang.String,java.lang.Boolean> permissionChecker)protected booleangetOrSetCachedAttributePermission(java.lang.String permissionName, java.lang.String typeCode, java.lang.String qualifier, java.util.function.BiFunction<java.lang.String,java.lang.String,java.lang.Boolean> permissionChecker)Returns attribute permission from the cache if it exists, calculates the permission and puts to the cache otherwise.protected booleangetOrSetCachedTypePermission(java.lang.String permissionName, ComposedTypeModel composedType, java.util.function.Function<java.lang.String,java.lang.Boolean> permissionChecker)protected booleangetOrSetCachedTypePermission(java.lang.String permissionName, java.lang.String typeCode, java.util.function.Function<java.lang.String,java.lang.Boolean> permissionChecker)Returns type permission from the cache if it exists, calculates the permission and puts to the cache otherwise.protected PermissionCRUDServicegetPermissionCRUDService()protected PermissionEnablerServicegetPermissionEnablerService()protected SessionCachedContextProvidergetSessionCachedContextProvider()protected java.lang.StringgetUniqueAttributeKey(java.lang.String permissionName, java.lang.String typeCode, java.lang.String qualifier)Generates a unique name to store attribute permission in the cacheprotected java.lang.StringgetUniqueTypeKey(java.lang.String permissionName, java.lang.String typeCode)voidinitCache()Initialize the cache, it creates cache objects in current session.voidsetPermissionCRUDService(PermissionCRUDService permissionCRUDService)voidsetPermissionEnablerService(PermissionEnablerService permissionEnablerService)voidsetSessionCachedContextProvider(SessionCachedContextProvider sessionCachedContextProvider)
-
-
-
Field Detail
-
KEY_DELIMITER
public static final java.lang.String KEY_DELIMITER
- See Also:
- Constant Field Values
-
-
Method Detail
-
initCache
public void initCache()
Description copied from interface:PermissionCachedCRUDServiceInitialize the cache, it creates cache objects in current session.- Specified by:
initCachein interfacePermissionCachedCRUDService
-
canReadAttribute
public boolean canReadAttribute(AttributeDescriptorModel attributeDescriptor)
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
public boolean canReadAttribute(java.lang.String typeCode, java.lang.String attributeQualifier)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
public boolean canChangeAttribute(AttributeDescriptorModel attributeDescriptor)
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
public boolean canChangeAttribute(java.lang.String typeCode, java.lang.String attributeQualifier)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
public boolean canReadType(ComposedTypeModel type)
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
public boolean canReadType(java.lang.String typeCode)
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
public boolean canChangeType(ComposedTypeModel type)
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
public boolean canChangeType(java.lang.String typeCode)
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
public boolean canCreateTypeInstance(ComposedTypeModel type)
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
public boolean canCreateTypeInstance(java.lang.String typeCode)
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
public boolean canRemoveTypeInstance(ComposedTypeModel type)
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
public boolean canRemoveTypeInstance(java.lang.String typeCode)
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
public boolean canChangeTypePermission(ComposedTypeModel type)
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
public boolean canChangeTypePermission(java.lang.String typeCode)
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
public boolean canChangeAttributePermission(AttributeDescriptorModel attributeDescriptor)
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
public boolean canChangeAttributePermission(java.lang.String typeCode, java.lang.String attributeQualifier)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(java.lang.String permissionName, java.lang.String typeCode, java.util.function.Function<java.lang.String,java.lang.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(java.lang.String permissionName, ComposedTypeModel composedType, java.util.function.Function<java.lang.String,java.lang.Boolean> permissionChecker)
-
getOrSetCachedAttributePermission
protected boolean getOrSetCachedAttributePermission(java.lang.String permissionName, java.lang.String typeCode, java.lang.String qualifier, java.util.function.BiFunction<java.lang.String,java.lang.String,java.lang.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(java.lang.String permissionName, AttributeDescriptorModel attributeDescriptor, java.util.function.BiFunction<java.lang.String,java.lang.String,java.lang.Boolean> permissionChecker)
-
addAttributePermissionToCache
protected void addAttributePermissionToCache(java.lang.String permissionName, java.lang.String typeCode, java.lang.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(java.lang.String permissionName, java.lang.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
protected java.lang.String getUniqueAttributeKey(java.lang.String permissionName, java.lang.String typeCode, java.lang.String qualifier)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
protected java.lang.String getUniqueTypeKey(java.lang.String permissionName, java.lang.String typeCode)
-
getSessionCachedContextProvider
protected SessionCachedContextProvider getSessionCachedContextProvider()
-
setSessionCachedContextProvider
public void setSessionCachedContextProvider(SessionCachedContextProvider sessionCachedContextProvider)
-
getPermissionCRUDService
protected PermissionCRUDService getPermissionCRUDService()
-
setPermissionCRUDService
public void setPermissionCRUDService(PermissionCRUDService permissionCRUDService)
-
getPermissionEnablerService
protected PermissionEnablerService getPermissionEnablerService()
-
setPermissionEnablerService
public void setPermissionEnablerService(PermissionEnablerService permissionEnablerService)
-
-