Class ElementPermissionsManager
- java.lang.Object
-
- com.nomagic.magicdraw.uml.permissions.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 Summary
Fields Modifier and Type Field Description private com.nomagic.utils.CacheMap<BaseElement,java.lang.Boolean>
canCreateChildCache
private com.nomagic.utils.CacheMap<BaseElement,java.lang.Boolean>
editableCache
private java.util.Collection<ElementPermissions>
handlers
private static ElementPermissionsManager
instance
private boolean
mUseEditionHandlers
Flag which enables or disables usage of edition handlers.private boolean
useCache
-
Constructor Summary
Constructors Modifier Constructor Description private
ElementPermissionsManager()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addPermisionsHandler(ElementPermissions permissions)
Deprecated.spelling error.void
addPermissionsHandler(ElementPermissions permissions)
Register custom permission handlerboolean
canAddChild(BaseElement parent, BaseElement child)
boolean
canCreateChildIn(BaseElement el)
boolean
canDelete(BaseElement el)
static ElementPermissionsManager
getElementPermissionsManager()
Singleton getterboolean
isElementEditable(BaseElement el)
boolean
isElementEditableNoCacheCheck(BaseElement el)
Forces isElementEditable check without cache.private boolean
isHandlerShouldBeUsed(ElementPermissions handler)
Checks if given handler should be used while managing permissions of element.boolean
isUseEditionHandlers()
Checks if edition handlers is used while managing permissions of element.void
removePermisionsHandler(ElementPermissions permissions)
Deprecated.spelling error.void
removePermissionsHandler(ElementPermissions permissions)
Unregister custom permission handlerstatic void
runWithCacheEnabled(java.lang.Runnable runnable)
Enable cache and run runnable, then cache is disabled.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.void
setUseEditionHandlers(boolean useEditionHandlers)
Sets flag which enables or disables usage of edition handlers.
-
-
-
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
-
handlers
private java.util.Collection<ElementPermissions> handlers
-
instance
private static ElementPermissionsManager instance
-
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.
-
-
Method Detail
-
getElementPermissionsManager
@OpenApi public static ElementPermissionsManager getElementPermissionsManager()
Singleton getter- Returns:
- instance
-
addPermisionsHandler
@OpenApi @Deprecated public void addPermisionsHandler(ElementPermissions permissions)
Deprecated.spelling error. Use #addPermissionsHandlerRegister 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 #removePermissionsHandlerUnregister 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)
-
canAddChild
public boolean canAddChild(BaseElement parent, BaseElement child)
-
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
-
-