|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectARoad0.gBase.UtilityImpl
public final class UtilityImpl
This class is an utility class for BaseObjects, StringRights, the BeanInfo and the AcsAddon management. It cannot be subclassed in an AcsAddon. As a CoreAlgorithm, each worker thread of a GraphicView uses a dedicated instance of this class. It applies the ACS rules:
- 'AGO right: no denying rights'
- 'bridge right: no denying rights'
- 'sens metarule: ACS denyings are superior to ACS grantings (there are + and - operations), for each right type'
- 'right type order: default order: root, A in AGO, all other right types'
It is used by gBase and the AcsAddon gBase packages. It also implements some core algorithms that gWork uses in the access paths search.
ARoad0.gWork.RightsMediatorImpl uses this class to create view instances in the view worker thread, while the first instance is used by the gBase consumers in the main thread.
The direct calls to ACS in the core algorithms are for the methods getL_Rights(), getFirstRightFromMeta(), getEorM_EligibleParties(), getEorL_VirtualFolders(), getEorL_Resources(). The direct calls to BaseManagerImpl in the core algorithms are for the method getMetaRight() and in getBaseObject(), isOpenACS(), isOpenView(), getMetaRightFromName() getEorM_OpenACS().
The methods have to be fast in the access paths search. Some private sets are created at the instance construction to avoid the creation of sets at each method call. Nonetheless, this class is stateless, since each method clears all its sets at its starting.
For the event management of the ACS Addons, the 4 ACSObjectAddon methods add/removeAddonInnerPropertyChangeListener() and add/removeAddonParentPropertyChangeListener() allow the views to listen the specific events from their nodes, when they belong to an AcsAddon.
Field Summary | |
---|---|
private static int |
INITIAL_CAPACITY
|
private static UtilityImpl |
instance__
the first instance of the class, used by gBase and the GUI, not by the GraphicView worker threads |
private java.util.Set<StringRight> |
l_headers_
used to speed up selectHeaders() |
private java.util.LinkedList |
l_methodResult_
used to speed up getFirstIncreasingRightsChain() |
private java.util.Set |
l_PathsUpFromLesser_
|
private java.util.Set<StringRight> |
l_removed_
used to speed up selectHeaders() and subtractNotRemovingCommonLowerNodes() |
private java.util.Set |
l_rightsUpFromCurrent_
|
private java.util.Set<StringRight> |
l_test_
used to speed up subtractNotRemovingCommonLowerNodes() and subtractInOneSetInOneACS() |
private java.util.Set<StringRight> |
l_to_next_test_
used to speed up subtractNotRemovingCommonLowerNodes() |
private java.util.Set<StringRight> |
l_to_retain_
used to speed up subtractNegativeHeadersNotRemovingInOneACS() |
private java.util.Set |
l_toAddTol_PathsUpFromLesser_
|
Constructor Summary | |
---|---|
UtilityImpl()
Called by gWork.RightsMediatorImpl to be used in the GraphicView worker thread. |
Method Summary | |
---|---|
void |
addAddonInnerPropertyChangeListener(java.beans.PropertyChangeListener _listener,
ACSObjectAddon _obj)
Registers for the specific events to listen, because these events should change the rights of an ACSObject in an ACS Addon. |
void |
addAddonParentPropertyChangeListener(java.beans.PropertyChangeListener _listener,
ACSObject _obj)
Registers the specific events to listen on a Resource or a VirtualFolder, and its direct and indirect parents, because these events should change the rights of the Resource or VirtualFolder in an ACS Addon. |
private void |
changeAddonInnerPropertyChangeListener(java.beans.PropertyChangeListener _listener,
ACSObjectAddon _obj,
boolean _toAdd)
Registers or unregisters for the specific events to listen, because these events should change the rights of an ACSObject in an ACS Addon. |
private void |
changeAddonParentPropertyChangeListener(java.beans.PropertyChangeListener _listener,
ACSObject _obj,
boolean _toAdd)
Registers or unregisters the specific events to listen on a Resource or a VirtualFolder, and its direct and indirect parents, because these events should change the rights of the Resource or VirtualFolder in an ACS Addon. |
void |
finalizeForProcess()
Finalizes the instance. |
java.util.Map<java.lang.String,java.lang.String[]> |
getACSVocabularyFromArrayOrInterface(java.lang.String _text)
Gets the map of the ACS vocabulary from the right ACSFactory, following the pattern of packages and class names in Access Road. |
BaseObject |
getBaseObject(ImmutableName _name)
Gets the BaseObject from the names of an open entity. |
java.lang.String |
getBeanInfoNameFromClass(java.lang.String _text)
Get the name of the BeanInfo class from the operational class. |
java.lang.String |
getClassNameFromArrayOrInterface(java.util.Map<java.lang.String,java.lang.String[]> _m_vocabulary,
java.lang.String _text)
Gets the name of the operational class from the interface name, with 'Immutable' or not, as an array or not, following the pattern of packages and class names in Access Road. |
java.lang.String |
getEffectiveClassName(java.util.Map _m_vocabulary,
java.lang.String _className)
Returns the name of the effective class to use. |
private java.util.LinkedList |
getFirstIncreasingRightsChain(StringRight _rightOne,
StringRight _rightTwo,
StringRight _upperToAvoid)
Gets a StringRights increasing chain where the two arguments are at the two ends, if the chain exists. |
static UtilityImpl |
getFirstInstance()
Method to obtain the first instance of UtilityImpl, for the gBase consumers and generally the main thread and the event dispatch thread. |
java.lang.String |
getObjectTypeWithoutImmutable(java.lang.String _type)
Returns the argument without the key word 'immutable ' at the start or the end of the string. |
java.lang.String |
getParentOrder(ImmutableLeaf _leaf,
ImmutableNode _node)
Gets the order of a node from a leaf. |
void |
removeAddonInnerPropertyChangeListener(java.beans.PropertyChangeListener _listener,
ACSObjectAddon _obj)
Unregisters for the specific events to listen, because these events should change the rights of an ACSObject in an ACS Addon. |
void |
removeAddonParentPropertyChangeListener(java.beans.PropertyChangeListener _listener,
ACSObject _obj)
Unregisters the specific events to listen on a Resource or a VirtualFolder, and its direct and indirect parents, because these events should change the rights of the Resource or VirtualFolder in an ACS Addon. |
BeanInfoPattern |
selectBeanInfo(BaseObject _objectInBeamer)
Analyzes the BaseObject to select the right BeanInfo in gBase. |
void |
selectHeaders(java.util.Set<StringRight> _l_updatedRights)
Selects the stronguest rights, in removing all the rights in the argument which have a direct or indirect upper rights in the argument. |
java.util.Set<StringRight>[] |
separateRightsFromSens(StringRight[] _l_right)
UNUSED. |
java.util.Set<StringRight> |
substractNegativeFromPositiveRights(java.util.Set<StringRight> _l_upd_rights)
Wrapper and caller of subtractNegativeNotRemovingInOneACS(). |
java.util.Set<StringRight> |
subtractDeleteRightsInOneACS(java.util.Set<StringRight> _l_posRights,
ImmutableACS _acs,
boolean _forNode)
UNUSED. |
java.util.Set<StringRight> |
subtractInOneSetInOneACS(StringRight[] _l_right,
ImmutableACS _acs,
boolean _forNode)
Operates the reduction of each positive right by all the negative rights. |
java.util.Set<StringRight> |
subtractNegativeHeadersNotRemovingInOneACS(java.util.Set _l_headPosRights,
java.util.Set _l_headNegRights,
ImmutableACS _acs,
boolean _forNode)
Operates the reduction of each positive right by all the negative rights. |
java.util.Set<StringRight> |
subtractNegativeNotRemovingInOneACS(java.util.Set<StringRight> _l_posRights,
java.util.Set<StringRight> _l_negRights,
ImmutableACS _acs,
boolean _forNode)
Operates the reduction of each positive right by all the negative rights, afer a filtering of the headers for each sens. |
java.util.Set<StringRight> |
subtractNotRemovingCommonLowerNodes(StringRight _rightOne,
StringRight _rightTwo,
ImmutableACS _acs,
boolean _forNode)
Substracts the second right to the first right. |
boolean |
withAssociatedDirectoryRight(StringRight _right)
Tests if the metaright of the argument is 'goto', 'read', 'write' or 'execute'. |
boolean |
withDenyExecuteRight(StringRight[] _l_rights)
Detects the rights which are directly or indirectly linked to the metaright 'deny_execute'. |
boolean |
withDirectExecuteRight(StringRight[] _l_rights)
Detects the rights which are directly linked to the metaright 'execute', as 'read & execute' for instance. |
boolean |
withExecuteRight(StringRight[] _l_rights,
boolean _forNode)
Detects the rights which are directly or indirectly linked to the metaright 'execute', as 'read & execute' for instance. |
StringRight |
withInverseRight(StringRight _right)
Detect the inverse right, if any, that it is defined, if _right is positive, as the negative right which as the same semantic and strenght. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final UtilityImpl instance__
private static final int INITIAL_CAPACITY
private final java.util.Set<StringRight> l_test_
private final java.util.Set<StringRight> l_to_next_test_
private final java.util.Set<StringRight> l_to_retain_
private final java.util.Set<StringRight> l_removed_
private final java.util.Set<StringRight> l_headers_
private final java.util.LinkedList l_methodResult_
private final java.util.Set l_rightsUpFromCurrent_
private final java.util.Set l_PathsUpFromLesser_
private final java.util.Set l_toAddTol_PathsUpFromLesser_
Constructor Detail |
---|
public UtilityImpl()
Method Detail |
---|
public static UtilityImpl getFirstInstance()
private final java.util.LinkedList getFirstIncreasingRightsChain(StringRight _rightOne, StringRight _rightTwo, StringRight _upperToAvoid) throws BaseError
_rightOne
- is one end of the chain of rights to get. Not null._rightTwo
- is the second end of the chain of rights to get. Not null._upperToAvoid
- a direct upper right of the lesser right among the two arguments.
No action if it is not a direct upper right of the lesser right, or
if it is the greater right among the two arguments.
The result will never include this right. May be null.
BaseError
- if an argument is null,
if there are more than 20 increasing chains to analyze from the lesser rightpublic final java.util.Set<StringRight> substractNegativeFromPositiveRights(java.util.Set<StringRight> _l_upd_rights)
_l_upd_rights
- to analyze. Not null. Updated by the method.
public final java.util.Set<StringRight> subtractNotRemovingCommonLowerNodes(StringRight _rightOne, StringRight _rightTwo, ImmutableACS _acs, boolean _forNode) throws BaseError
_rightTwo and all the upper rights of _rightTwo are removed in _rightOne. For the lower rights, if a _rightOne (direct or indirect) lower right, say R, is also a _rightTwo (direct or indirect) lower right, the common node R is put in the result.
Returns, if any, all the lower rights of _rightOne if it is equal to _rightTwo. If _rightOne is not equal to _rightTwo, return _rightOne if getFirstIncreasingRightsChain(_rightOne, _rightTwo) is null or starts with _rightOne. If _rightOne and _rightTwo are acs rights from different ACS, returns _rightOne. Called by subtractNegativeHeadersNotRemovingInOneACS(), so this method has to be fast. Calls getFirstIncreasingRightsChain(). Calls withAssociatedDirectoryRight() to detect the 'directory' rights, that have 'read', 'write' or 'execute' as metaright. Does not call selectHeaders(), so l_removed_ may be used by the two methods independantly. Uses the instance properties l_test_, l_to_next_test_ and l_removed_.
_rightOne
- first right. Not null._rightTwo
- second right to subtract. Must have the same class and the same sens
that _rightOne. Not null._acs
- uses all the rights in the two first arguments. May be null._forNode
- true if these rights are for a Node (Directory or VirtualFolder);
the 'directory' rights are not removed, and their equivallent like 'read' is removed
BaseError
- if an argument is null,
if there is a positive right and a negative one, or an acsright and a metaright,
or if there are more than 20 increasing chains to analyze from the lesser rightsubtractNegativeHeadersNotRemovingInOneACS(java.util.Set, java.util.Set, ARoad0.gBaseInterface.ImmutableACS, boolean)
public final void selectHeaders(java.util.Set<StringRight> _l_updatedRights) throws BaseError
_l_updatedRights
- metarights and acsrights to filter, which may be granting
or denying ones. Not null and no null item. Is updated by this method.
BaseError
- if an item is null in the argument,
if there are more than 20 increasing chains to analyze from the lesser rightpublic final boolean withAssociatedDirectoryRight(StringRight _right)
_right
- acsright or metaright to analyze
public final boolean withExecuteRight(StringRight[] _l_rights, boolean _forNode)
_l_rights
- to analyze. May be null or empty._forNode
- true if these rights are for a node, and so the 'directory'
rights are not removed
public final boolean withDenyExecuteRight(StringRight[] _l_rights)
_l_rights
- to analyze
public final boolean withDirectExecuteRight(StringRight[] _l_rights)
_l_rights
- to analyze
public final StringRight withInverseRight(StringRight _right)
_right
- acsright or metaright to analyze
public final java.util.Set<StringRight> subtractNegativeNotRemovingInOneACS(java.util.Set<StringRight> _l_posRights, java.util.Set<StringRight> _l_negRights, ImmutableACS _acs, boolean _forNode)
_l_posRights
- positive rights in an HashSet. Not null and no null item.
No update._l_negRights
- negative rights in an HashSet. Not null and no null item.
No update._acs
- uses all the rights in the two right sets. May be null._forNode
- true if these rights are for a Node (Directory or VirtualFolder):
the 'directory' rights are not removed if applicable
selectHeaders(java.util.Set)
public final java.util.Set<StringRight> subtractInOneSetInOneACS(StringRight[] _l_right, ImmutableACS _acs, boolean _forNode)
_l_right
- rights array not null nor empty._acs
- uses all the rights in the two right sets. May be null._forNode
- true if these rights are for a node, and so the 'directory'
rights are not removed
selectHeaders(java.util.Set)
public final java.util.Set<StringRight> subtractNegativeHeadersNotRemovingInOneACS(java.util.Set _l_headPosRights, java.util.Set _l_headNegRights, ImmutableACS _acs, boolean _forNode)
Applies the ACS rules:
- 'AGO right: no denying rights'
- 'bridge right: no denying rights'
- 'sens metarule: ACS denyings are superior to ACS grantings (there are + and - operations), for each right type'
- 'right type order: default order: root, A in AGO, all other right types'
Uses the instance property l_to_retain_. Called by subtractNegativeNotRemovingInOneACS() and subtractInOneSetInOneACS(). Calls StringRightImpl.selectHeaders() and subtractNotRemovingCommonLowerNodes(), withInverseRight().
_l_headPosRights
- positive rights with only headers. Not null and no null item.
No update in this method, but the method may return it._l_headNegRights
- negative rights with only headers. Not null and no null item.
No update._acs
- uses all the rights in the two right sets. May be null._forNode
- true if these rights are for a node, and so the 'directory'
rights are not removed
selectHeaders(java.util.Set)
public final java.util.Set<StringRight>[] separateRightsFromSens(StringRight[] _l_right)
_l_right
- array of acsrights or metarights to analyze
public final java.util.Set<StringRight> subtractDeleteRightsInOneACS(java.util.Set<StringRight> _l_posRights, ImmutableACS _acs, boolean _forNode)
_l_posRights
- positive metarights. Not null and no null item._acs
- uses all the rights in the two right sets. May be null._forNode
- true if these rights are for a node, and so the 'directory'
rights are not removed
public java.lang.String getObjectTypeWithoutImmutable(java.lang.String _type)
_type
- of a BaseObject
public BeanInfoPattern selectBeanInfo(BaseObject _objectInBeamer)
_objectInBeamer
- is the object to display in the beamer
public java.lang.String getBeanInfoNameFromClass(java.lang.String _text)
_text
- a gBase class name
public final java.lang.String getClassNameFromArrayOrInterface(java.util.Map<java.lang.String,java.lang.String[]> _m_vocabulary, java.lang.String _text)
Works for the generic gBase and for the AcsAddon gBase packages. For instance, with the '[LARoad0.gBaseInterface.ImmutableResource' argument, this method returns the value 'ARoad0.gBase.Resource'. Returns the argument if it is the name of a class. Follows the gBase pattern for classes and interface names, and the AcsAddon pattern. Searches in gBase from interfaces in gBaseInterface. Called by BeamerManager.getElementaryPropertyType(), BaseObjectHandler, DialogBox and most of the PropertyEditors. Calls ACSFactoryUtilityImpl.getEffectiveClassName().
_m_vocabulary
- from getACSVocabularyFromArrayOrInterface(). Never null.
For a class or an interface which is not managed in the AcsAddon framework,
like for StringRight, this property has to be empty._text
- an interface or a class name in a gBase or a gBaseInterface package.
Never null.
public final java.util.Map<java.lang.String,java.lang.String[]> getACSVocabularyFromArrayOrInterface(java.lang.String _text)
Works for the generic gBase and for the AcsAddon gBase packages. For instance, with the '[LARoad0.gBaseInterface.ImmutableResource' argument, this method returns the vocabulary from the constructor of ARoad0.gBase.ACSFactoryImpl. With 'ARoad0.AcsAddon.Accbee.Ubuntu.gBaseInterface.ResourceUbuntu' as parameter, this method returns the vocabulary from the constructor of ARoad0.AcsAddon.Accbee.Ubuntu.gBase.ACSFactoryUbuntuImpl. Follows the gBase pattern for class and interface names, and the AcsAddon pattern. Called by selectBeanInfo(), BaseUtilityImpl.getL_AcsRestrictedRights(), BaseObjectHandler, DialogBox and most of the PropertyEditors, often to be used with getClassNameFromArrayOrInterface().
Gets the ACSFactoryImpl empty constructor or one of its subclass constructor, to call getM_AcsVocabulary(). For a generic gBaseInterface that is not managed in the AcsAddon framework, returns always an empty map. These generic gBaseInterface interfaces are ACSObject, BaseObject, Leaf, Node, NameTree, NameISTree, Source, Target, DetailledName, StringRight, StringMetaRight. Only the two last interfaces have an implementation in the generic gBase package, and StringMetaRightImpl is not a subclass of StringRightImpl.
_text
- an interface or a class name in a gBase or a gBaseInterface package,
from the generic packages or from an AcsAddon package. Never null.
public final java.lang.String getEffectiveClassName(java.util.Map _m_vocabulary, java.lang.String _className)
In this second case, it may be an AcsAddon classic class that subclass and replace a generic gBase class, or it may be an extension class which is defined at the key ACSADDON_EXTENSION_CLASSES in the vocabulary map.
It is possible to replace a generic class, in a package named 'yyyy', by a classic class from a package 'zzzz'. On the other hand, this is not authorized for the extension classes, since they must be in the same AcsAddon gBase package. Furthermore, an extension class must be the subclass of a generic gBase class or of an AcsAddon classic class.
Called by getClassNameFromArrayOrInterface(), AssociateUtilityImpl, ACSFactoryImpl, ActionNewResource, ActionNewEligibleParty.
_m_vocabulary
- from ACSRun.getM_AcsVocabulary() or
getACSVocabularyFromArrayOrInterface().
For a class or an interface which is not managed in the AcsAddon framework,
like for StringRight, this property has to be empty._className
- one of the constants in L_CLASSIC_CLASS_KEYS, or
an AcsAddon extension class which is described with the key ACSADDON_EXTENSION_CLASSES
in _m_vocabulary, with the format _className/is/one_classic_class_name
public void addAddonInnerPropertyChangeListener(java.beans.PropertyChangeListener _listener, ACSObjectAddon _obj)
_listener
- to register_obj
- the basic object for which some ACS events or ACSObject events have
to be listened, to catch the changings in its rights.
Noop if _obj is null, or if _obj is not from an AcsAddon ACS.public void addAddonParentPropertyChangeListener(java.beans.PropertyChangeListener _listener, ACSObject _obj)
_listener
- to register_obj
- the basic object of an AcsAddon ACS, for which some ACS events or
ACSObject events have to be listened, to catch the changings in its rights.
Noop if _obj is null, not a Resource or a VirtualFolder, or if
_obj is not from an AcsAddon ACS.public void removeAddonInnerPropertyChangeListener(java.beans.PropertyChangeListener _listener, ACSObjectAddon _obj)
_listener
- to register_obj
- the basic object for which some ACS events or ACSObject events have
to be listened, to catch the changings in its rights.
Noop if _obj is null, or if _obj is not from an AcsAddon ACS.public void removeAddonParentPropertyChangeListener(java.beans.PropertyChangeListener _listener, ACSObject _obj)
_listener
- to register_obj
- the basic object for which some ACS events or ACSObject events have
to be listened, to catch the changings in its rights.
Noop if _obj is null, is not a Resource or a VirtualFolder,
or if _obj is not from an AcsAddon ACS.private final void changeAddonInnerPropertyChangeListener(java.beans.PropertyChangeListener _listener, ACSObjectAddon _obj, boolean _toAdd)
_listener
- to register_obj
- the basic object for which some ACS events or ACSObject events have
to be listened, to catch the changings in its rights.
Noop if _obj is null, or if _obj is not from an AcsAddon ACS._toAdd
- true for adding the listeners, false to remove themACSObjectAddon.getAddonInnerPropertiesToListen()
private final void changeAddonParentPropertyChangeListener(java.beans.PropertyChangeListener _listener, ACSObject _obj, boolean _toAdd)
_listener
- to register_obj
- the basic object of an AcsAddon ACS, for which some ACS events or
ACSObject events have to be listened, to catch the changings in its rights.
Noop if _obj is null, not a Resource or a VirtualFolder, or if
_obj is not from an AcsAddon ACS._toAdd
- true for adding the listeners, false to remove themAcsAddon.getAddonParentPropertiesToListen()
public final java.lang.String getParentOrder(ImmutableLeaf _leaf, ImmutableNode _node)
_leaf
- is never null_node
- is never null. Cannot be _leaf.
public final BaseObject getBaseObject(ImmutableName _name)
_name
- object name
public void finalizeForProcess()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |