Class ElementPermissionsManager


  • @OpenApi
    public final class ElementPermissionsManager
    extends java.lang.Object
    Class responsible for managing permissions of element : readonly, can add children. This manager does not contains any logic, external ElementPermissions should be registered to this manager to handle permissions.
    • Field Detail

      • useCache

        private boolean useCache
      • editableCache

        private final com.nomagic.utils.CacheMap<BaseElement,​java.lang.Boolean> editableCache
      • canCreateChildCache

        private final com.nomagic.utils.CacheMap<BaseElement,​java.lang.Boolean> canCreateChildCache
      • mUseEditionHandlers

        private boolean mUseEditionHandlers
        Flag which enables or disables usage of edition handlers. It is used in situations when edition handlers should not be used.
    • Constructor Detail

      • ElementPermissionsManager

        private ElementPermissionsManager()
    • Method Detail

      • getElementPermissionsManager

        @OpenApi
        public static ElementPermissionsManager getElementPermissionsManager()
        Singleton getter
        Returns:
        instance
      • addPermisionsHandler

        @OpenApi
        @Deprecated
        public void addPermisionsHandler​(ElementPermissions permissions)
        Deprecated.
        spelling error. Use #addPermissionsHandler
        Register custom permission handler
        Parameters:
        permissions - permissions handler
      • addPermissionsHandler

        @OpenApi
        public void addPermissionsHandler​(ElementPermissions permissions)
        Register custom permission handler
        Parameters:
        permissions - permissions handler
      • removePermisionsHandler

        @OpenApi
        @Deprecated
        public void removePermisionsHandler​(ElementPermissions permissions)
        Deprecated.
        spelling error. Use #removePermissionsHandler
        Unregister custom permission handler
        Parameters:
        permissions - permissions handler
      • removePermissionsHandler

        @OpenApi
        public void removePermissionsHandler​(ElementPermissions permissions)
        Unregister custom permission handler
        Parameters:
        permissions - permissions handler
      • isElementEditable

        public boolean isElementEditable​(BaseElement el)
      • isElementEditableNoCacheCheck

        public boolean isElementEditableNoCacheCheck​(BaseElement el)
        Forces isElementEditable check without cache. Does not clear or update cache if one is in use. To be used with element permission handlers that can become disabled.
        Parameters:
        el - element to check
        Returns:
        returns true if element is editable
      • canCreateChildIn

        public boolean canCreateChildIn​(BaseElement el)
      • canDelete

        public boolean canDelete​(BaseElement el)
      • setUseCache

        public void setUseCache​(boolean useCache)
        For better performance manager is able to cache editable results in case state of elements does not change at some point of some action, but clients do lots of checking.
        Parameters:
        useCache - use cache flag
      • setUseEditionHandlers

        public void setUseEditionHandlers​(boolean useEditionHandlers)
        Sets flag which enables or disables usage of edition handlers. Use try/finally block to ensure that flag will be restored if error occurred.
        Parameters:
        useEditionHandlers - true if version edition should be used.
      • isUseEditionHandlers

        public boolean isUseEditionHandlers()
        Checks if edition handlers is used while managing permissions of element.
        Returns:
        true if edition handlers is used while managing permissions of element.
      • isHandlerShouldBeUsed

        private boolean isHandlerShouldBeUsed​(ElementPermissions handler)
        Checks if given handler should be used while managing permissions of element.
        Parameters:
        handler - handler which is checked.
        Returns:
        true if given handler should be used while managing permissions of element.
      • runWithCacheEnabled

        public static void runWithCacheEnabled​(java.lang.Runnable runnable)
        Enable cache and run runnable, then cache is disabled.
        Parameters:
        runnable - runnable to run