ARoad0.gBase
Class EPRViewInBaseImpl

java.lang.Object
  extended by ARoad0.gBase.FolderAbst
      extended by ARoad0.gBase.ViewInBaseImpl
          extended by ARoad0.gBase.EPRViewInBaseImpl
All Implemented Interfaces:
BaseObject, BoundBean, EPRViewInBase, Folder, ImmutableFolder, ViewInBase, java.beans.PropertyChangeListener, java.io.Serializable, java.util.EventListener
Direct Known Subclasses:
NoThanViewInBaseImpl, SketchViewInBaseImpl

public class EPRViewInBaseImpl
extends ViewInBaseImpl
implements EPRViewInBase, java.io.Serializable

This class is responsible for modeling in the base, a view about access control issues between eligible parties (EP of EPRViewInBase) or virtual folders as access sources, and resources (R of EPRViewInBase) or virtual folders as access targets. It is used by the full views in the GUI to display all the rights between any couple of view objects, since an access source may also be an access target in some precise cases. It registers its sources and its targets from one or several open ACS. It is closed when any of its objects belongs to a closing ACS. It is not closed when one of its objects is referenced in the AclEntry of a closing ACS, or when the object is deleted from its ACS. The EPRViewInBase adds automatically in the view the reference of an alias and the alias of a reference. This is not done in its two subclasses. It is a javabean with the following bound properties (see also the super class): 'OnePropertyInView'. Caution: no equals() nor clone() methods.

See Also:
GraphicEPRView, Serialized Form

Field Summary
static EPRViewInBase EMPTY_INSTANCE
           
protected  java.beans.PropertyChangeEvent lastEvent_
           
protected  java.util.SortedMap<ImmutableName,ImmutableTarget> m_NoSourceTargets_
           
protected  java.util.SortedMap<ImmutableName,ImmutableSource> m_Sources_
           
protected  java.util.SortedMap<ImmutableName,ImmutableTarget> m_Targets_
           
 
Fields inherited from class ARoad0.gBase.ViewInBaseImpl
ARCHI_VIEW_NAME, ARCHI_VIEW_STRING
 
Fields inherited from class ARoad0.gBase.FolderAbst
baseError_, changeSupport_, comment_, connectedToSeveralACS_, INITIAL_CAPACITY, INITIAL_CAPACITY_5, l_connectedACSNames_, m_BaseObjects_, m_ObjectsNames_, name_, PRIME, serialPersistentFields, type_
 
Constructor Summary
EPRViewInBaseImpl()
          Default constructor
EPRViewInBaseImpl(ImmutableName _name)
           
EPRViewInBaseImpl(ImmutableName _name, java.util.Map _m_BaseObjects, boolean _toRegisterInManager)
          This constructor is used by BaseManagerImpl.openView() to create every instance.
 
Method Summary
 void addEorBaseObject(BaseObject _obj)
          Adds a baseObject to the base.
protected  void addEorHardAliasOrReference(ACSObject _obj)
          If an added ACSObject in the view is an alias or an alias reference, adds to the view its associated object.
 void addEorSource(ImmutableSource _sour)
          Updates all the internal maps after a test of the parameter type.
 void addEorTarget(ImmutableTarget _targ)
          Updates all the internal maps after a test of the parameter type.
protected  void addOwnListening(boolean _callSuper)
          Registers the instance as a property event listener on the EligibleParties, and on the no-Actor Resources and their parents, to follow the AG/PRI/ACL inherited rights.
 void addPropertyChangeListener(java.lang.String _propertyName, java.beans.PropertyChangeListener _l)
          Adds a listener to the bean for the property 'OnePropertyInView', or for any superclass property.
 boolean containsSource(ImmutableSource _sour)
           
 boolean containsTarget(ImmutableTarget _targ)
           
protected static ViewInBase copy(ImmutableName _name, EPRViewInBase _view, boolean _toRegisterInManager)
          Creates a copy with another name, and may register it.
 EPRViewInBase copyAndSave(ImmutableName _name)
          Creates, registers in the base and saves a view copy with another name.
 void finalizeForBase()
          The view is removed as a listener and the internal maps are set to null.
 void finalizeForCopy()
          The internal maps are set to null.
protected  void finalizeForGUI()
          This method is reserved to the sketch view.
protected  void finalizeFromDeserialization()
          This method does not clear all the view objects maps, since they are transient.
protected  void firePropertyChange(java.beans.PropertyChangeEvent _evt)
          Fires an event to every registered listener, in any order, for a view object bound property.
 java.util.SortedMap<ImmutableName,ImmutableTarget> getEorM_NoSourceTargets()
          Gets the targets in this view which are not eligible parties (actors, accounts, groups) nor virtual folders.
 java.util.SortedMap<ImmutableName,ImmutableSource> getEorM_Sources()
          Gets all the sources in this view, and this covers the actors, accounts, groups and virtual folders.
 java.util.SortedMap<ImmutableName,ImmutableTarget> getEorM_Targets()
          Gets all the access targets in this view, and this covers simple resources, actors, directories, executables, accounts, groups and virtual folders.
protected  java.lang.String prepareAfterRestoring()
          This method must be called by BaseManagerImpl after the opening of the view, to update the transient maps, and to check the open ACS and their objects which are in the restored view.
 void propertyChange(java.beans.PropertyChangeEvent _evt)
          Observer of the changes on the objects set in addOwnListening().
 void removeEorBaseObject(BaseObject _obj)
          Overrides ViewInBaseImpl.removeEorBaseObject() to update sources and targets maps.
protected  void removeEorHardAliasOrReference(ACSObject _obj)
          If a removed ACSObject in the view is an alias or an alias reference, removes from the view its associated object.
 void removeEorSource(ImmutableSource _sour)
          Updates all the internal maps after a test of the parameter type.
 void removeEorTarget(ImmutableTarget _targ)
          Updates all the internal maps after a test of the parameter type.
protected  void removeOwnListening(boolean _callSuper)
          Unregisters the instance as a property event listener on BaseManagerImpl.
 void removePropertyChangeListener(java.lang.String _propertyName, java.beans.PropertyChangeListener _l)
          Removes a listener to the bean for the property 'OnePropertyInView', or for any superclass property.
 
Methods inherited from class ARoad0.gBase.ViewInBaseImpl
addOwnListening, copy, getCompleteResults, getNickName, getSerialVersionUID, removeOwnListening
 
Methods inherited from class ARoad0.gBase.FolderAbst
addPropertyChangeListener, containsBaseObject, finalize, firePropertyChange, getComment, getConnectedToSeveralACS, getEorBaseError, getEorL_ConnectedACSNames, getEorM_BaseObjects, getFullName, getName, getType, hashCode, isEmpty, prepareBeforeSaving, prepareDataAfterRestoring, removePropertyChangeListener, setComment, toString
 
Methods inherited from class java.lang.Object
clone, equals, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface ARoad0.gBaseInterface.ViewInBase
getCompleteResults
 
Methods inherited from interface ARoad0.gBaseInterface.Folder
addPropertyChangeListener, removePropertyChangeListener, setComment
 
Methods inherited from interface ARoad0.gBaseInterface.ImmutableFolder
containsBaseObject, getComment, getConnectedToSeveralACS, getEorL_ConnectedACSNames, getEorM_BaseObjects, getType, isEmpty
 
Methods inherited from interface ARoad0.gBaseInterface.BaseObject
equals, getFullName, getName, getNickName, hashCode
 

Field Detail

m_Sources_

protected transient java.util.SortedMap<ImmutableName,ImmutableSource> m_Sources_

m_Targets_

protected transient java.util.SortedMap<ImmutableName,ImmutableTarget> m_Targets_

m_NoSourceTargets_

protected transient java.util.SortedMap<ImmutableName,ImmutableTarget> m_NoSourceTargets_

lastEvent_

protected transient java.beans.PropertyChangeEvent lastEvent_

EMPTY_INSTANCE

public static final EPRViewInBase EMPTY_INSTANCE
Constructor Detail

EPRViewInBaseImpl

public EPRViewInBaseImpl()
Default constructor


EPRViewInBaseImpl

public EPRViewInBaseImpl(ImmutableName _name)
                  throws CreateError
Parameters:
_name - of the view. it is copied.
Throws:
CreateError - if the view name is already known in BaseManagerImpl.

EPRViewInBaseImpl

public EPRViewInBaseImpl(ImmutableName _name,
                         java.util.Map _m_BaseObjects,
                         boolean _toRegisterInManager)
                  throws CreateError
This constructor is used by BaseManagerImpl.openView() to create every instance. So, all the objects to listen (ACS...) receive a registration from this instance. It would not be the case in a simple deserialization of an EPRViewInBase. Called by RightsFactory_Facade.detectNoThanRights() with _toRegisterInManager false, in a NoThan view worker thread. Calls addEorHardAliasOrReference() and may complements the list of BaseObjects. Calls the super constructor with the same arguments.

Parameters:
_name - of the view. It is copied.
_m_BaseObjects - is the map (name, object) of the view objects. It is copied. May be null.
_toRegisterInManager - false if this constructor must not register the instance in BaseManagerImpl and in its view objects.
Throws:
BaseError - if the constructor of ViewInBaseImpl fires it, or if _m_BaseObjects contains an object that is not an eligible party, nor a resource.
CreateError
Method Detail

copyAndSave

public EPRViewInBase copyAndSave(ImmutableName _name)
                          throws BaseError
Creates, registers in the base and saves a view copy with another name. Each internal variable that is an external object reference have a shallow copy (no deep copy): baseError_, m_BaseObjects_, m_NoSourceTargets_, m_Sources_. Overridden by NoThanViewInBaseImpl.

Specified by:
copyAndSave in interface EPRViewInBase
Parameters:
_name - of the copy. It is copied without test.
Returns:
the copied view, which may be a NoThan view
Throws:
BaseError - if _name is null or already known in BaseManagerImpl, or if _view is null or not known.

containsTarget

public boolean containsTarget(ImmutableTarget _targ)
Specified by:
containsTarget in interface EPRViewInBase
Parameters:
_targ - to test
Returns:
true if the view contains it

containsSource

public boolean containsSource(ImmutableSource _sour)
Specified by:
containsSource in interface EPRViewInBase
Parameters:
_sour - to test
Returns:
true if the view contains it

getEorM_Targets

public java.util.SortedMap<ImmutableName,ImmutableTarget> getEorM_Targets()
Gets all the access targets in this view, and this covers simple resources, actors, directories, executables, accounts, groups and virtual folders.

Specified by:
getEorM_Targets in interface EPRViewInBase
Returns:
unmodifiableSortedMap of the view targets

getEorM_NoSourceTargets

public java.util.SortedMap<ImmutableName,ImmutableTarget> getEorM_NoSourceTargets()
Gets the targets in this view which are not eligible parties (actors, accounts, groups) nor virtual folders.

Specified by:
getEorM_NoSourceTargets in interface EPRViewInBase
Returns:
unmodifiableSortedMap of the view targets

getEorM_Sources

public java.util.SortedMap<ImmutableName,ImmutableSource> getEorM_Sources()
Gets all the sources in this view, and this covers the actors, accounts, groups and virtual folders.

Specified by:
getEorM_Sources in interface EPRViewInBase
Returns:
unmodifiableSortedMap of the view sources

addEorBaseObject

public void addEorBaseObject(BaseObject _obj)
                      throws CreateError
Adds a baseObject to the base. If it is both a source and an access target, adds it in all the relevant maps. Calls addEorHardAliasOrReference(), addEorTarget() and addEorSource(). Overrides the super method but calls it indirectly through addEorTarget() and addEorSource(). Caution: ImmutableGroupIDMember extends ImmutableTarget.

Specified by:
addEorBaseObject in interface Folder
Overrides:
addEorBaseObject in class FolderAbst
Parameters:
_obj - non-null BaseObject to add in the view
Throws:
CreateError - if the object is already known by the view, or is not a source nor an target.

removeEorBaseObject

public void removeEorBaseObject(BaseObject _obj)
                         throws CreateError
Overrides ViewInBaseImpl.removeEorBaseObject() to update sources and targets maps. If it is both a source and a target, removes in all the relevant maps. Calls removeEorAlias(), removeEorTarget() and removeEorSource(). Overrides the super method but calls it indirectly through removeEorTarget() and removeEorSource()

Specified by:
removeEorBaseObject in interface Folder
Overrides:
removeEorBaseObject in class FolderAbst
Parameters:
_obj - non-null BaseObject to remove in the view
Throws:
CreateError - if the object is null or not known by the view, or if the object is not a source nor a target, or if the object name is empty.

addEorTarget

public void addEorTarget(ImmutableTarget _targ)
                  throws CreateError
Updates all the internal maps after a test of the parameter type. So, an Actor is also added to the Sources internal map. Invokes super.addEorBaseObject(_res). No operation if _res is null or already known. Registers this instance as a listener of the argument and, for all its indirect parents, a listener of the AGO inherited rights. But the 'AclRights' events are not processed by propertyChange(), since this is the responsability of the Gui2.GraphicViewBaseListenerImpl of the view. Calls BasicImpl.addInViewList() or VirtualFolderImpl.addInViewList(). Overridden and called by the NoThanViewInBaseImpl subclass. Called by addEorBaseObject() and calls FolderAbst.addEorBaseObject() which fires an event.

Specified by:
addEorTarget in interface EPRViewInBase
Parameters:
_targ - to add to the view
Throws:
CreateError - if the target is already known by the view, if the name is null, or the object name is null or empty.

removeEorTarget

public void removeEorTarget(ImmutableTarget _targ)
                     throws CreateError
Updates all the internal maps after a test of the parameter type. Unregisters this instance as a listener of the argument and, for all its indirect parents, a listener of the AGO inherited rights. Calls BasicImpl.removeInViewList() Invokes super.removeEorBaseObject(_targ). Overridden and called by the NoThanViewInBaseImpl subclass. Called by removeEorBaseObject() and calls FolderAbst.removeEorBaseObject().

Specified by:
removeEorTarget in interface EPRViewInBase
Parameters:
_targ - to remove in the view
Throws:
CreateError - if the target is not known by the view, or if the object name is empty.

addEorSource

public void addEorSource(ImmutableSource _sour)
                  throws CreateError
Updates all the internal maps after a test of the parameter type. So, an Actor is also added to the Targets internal map. Registers this instance as a listener of the argument. Called by addEorBaseObject(). Calls BasicImpl.addInViewList() and super.addEorBaseObject() which fires an event. Overridden and called by the NoThanViewInBaseImpl subclass.

Specified by:
addEorSource in interface EPRViewInBase
Parameters:
_sour - to add to the view. No operation if null or already known.
Throws:
CreateError - if the source is already known by the view, if the name is null, or the object name is null or empty.

removeEorSource

public void removeEorSource(ImmutableSource _sour)
                     throws CreateError
Updates all the internal maps after a test of the parameter type. Unregisters this instance as a listener of the argument. Called by removeEorBaseObject(). Calls BasicImpl.removeInViewList() and super.removeEorBaseObject() which fires an event. Overridden and called by the NoThanViewInBaseImpl subclass.

Specified by:
removeEorSource in interface EPRViewInBase
Parameters:
_sour - to remove in the view
Throws:
CreateError - if the source is null or not known by the view, or if the object name is empty.

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent _evt)
Observer of the changes on the objects set in addOwnListening(). Overrides the super method, and calls it at the first line. Does not listen 'AclRights' from Resource (this event from AclEntry is not listened), nor 'AclConnectedResources' from EligibleParty, which are handled by Gui2.GraphicViewBaseListenerImpl. Does not listen 'ResourceType' from Resource, 'EPType' from EligibleParty, 'VirtualFolderType' from VirtualFolder. Does not fire a 'InheritedOwnerRights' event after a 'FromTheParentAccount' event from the same source, and so on for the group events. Does not fire a 'InheritedTargetPrivileges' or a 'InheritedTargetAclEntries' event if the last event is from the parent. Fires all the base objects changes to the 'OnePropertyInView' listeners, and the events from AcsAddon objects, without any processing.

Specified by:
propertyChange in interface Folder
Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Overrides:
propertyChange in class ViewInBaseImpl
Parameters:
_evt - PropertyChangeEvent

addPropertyChangeListener

public void addPropertyChangeListener(java.lang.String _propertyName,
                                      java.beans.PropertyChangeListener _l)
Adds a listener to the bean for the property 'OnePropertyInView', or for any superclass property.

Specified by:
addPropertyChangeListener in interface BoundBean
Specified by:
addPropertyChangeListener in interface Folder
Overrides:
addPropertyChangeListener in class FolderAbst
Parameters:
_propertyName - is the name of the property
_l - to add. Caution: the listener must NOT have specific hashCode() and equals() methods, to work with HashSet in the removing operations.

removePropertyChangeListener

public void removePropertyChangeListener(java.lang.String _propertyName,
                                         java.beans.PropertyChangeListener _l)
Removes a listener to the bean for the property 'OnePropertyInView', or for any superclass property.

Specified by:
removePropertyChangeListener in interface BoundBean
Specified by:
removePropertyChangeListener in interface Folder
Overrides:
removePropertyChangeListener in class FolderAbst
Parameters:
_propertyName - String is the name of the property
_l - to remove

copy

protected static ViewInBase copy(ImmutableName _name,
                                 EPRViewInBase _view,
                                 boolean _toRegisterInManager)
                          throws BaseError
Creates a copy with another name, and may register it. Each internal variable that is an external object reference have a shallow copy (no deep copy): baseError_, m_BaseObjects_, m_NoSourceTargets_, m_Sources_. Called by copyAndSave(). Overridden by NoThanViewInBaseImpl.

Parameters:
_name - of the view. It is copied.
_view - to copy.
_toRegisterInManager - false if this method must not register the instance in BaseManagerImpl.
Returns:
a copy
Throws:
BaseError - if _name is null or already known in BaseManagerImpl, or if _view is null or not known.

addOwnListening

protected void addOwnListening(boolean _callSuper)
Registers the instance as a property event listener on the EligibleParties, and on the no-Actor Resources and their parents, to follow the AG/PRI/ACL inherited rights. Called by the constructor, copy() and prepareAfterRestoring() methods. It does not override the super method to avoid to call it from super.prepareAfterRestoring(), which has to be called by prepareAfterRestoring() before the updating of the transiant maps and the call to this method. Adds the listening of the specific events from any AcsAddon ACS or any of its objects, and BaseUtilityImpl.addAddonParentPropertyChangeListener() is called for that. Calls super.addOwnListening().

Parameters:
_callSuper - false if this instance must not listen the open ACS events in BaseManagerImpl and the objects events in ACSImpl; if true, calls super.addOwnListening().

removeOwnListening

protected void removeOwnListening(boolean _callSuper)
Unregisters the instance as a property event listener on BaseManagerImpl. Called by finalizeForBase/Copy/GUI(), and the removeOwnListening() methods of the subclass. Removes the listening of the specific events from any AcsAddon ACS or any of its objects, and BaseUtilityImpl.removeAddonParentPropertyChangeListener() is called for that. Calls super.removeOwnListening().

Parameters:
_callSuper - false if this method must not unregister the open ACS events in BaseManagerImpl and the objects events in ACSImpl; if true, call super.removeOwnListening().

firePropertyChange

protected void firePropertyChange(java.beans.PropertyChangeEvent _evt)
Fires an event to every registered listener, in any order, for a view object bound property. Called by propertyChange() of this class and subclass, which send all the base objects events to the listeners of the property 'OnePropertyInView', to update the GraphicView. No link with the ViewInBaseImpl bound properties and firePropertyChange() method.

Parameters:
_evt - is fired by a view object

addEorHardAliasOrReference

protected void addEorHardAliasOrReference(ACSObject _obj)
                                   throws CreateError
If an added ACSObject in the view is an alias or an alias reference, adds to the view its associated object. No adding of the alias or reference of the associated object, to avoid to add a chain of aliasings. The test of an alias relation has to be done in the caller method. Called by the constructor and addEorBaseObject(). Calls addEorTarget() and addEorSource(). Overridden by the NoThanViewInBaseImpl subclass to provide an empty method.

Parameters:
_obj - with an alias relation to process
Throws:
CreateError - if the name is null, or the object name is null or empty.

removeEorHardAliasOrReference

protected void removeEorHardAliasOrReference(ACSObject _obj)
                                      throws CreateError
If a removed ACSObject in the view is an alias or an alias reference, removes from the view its associated object. The test of an alias relation has to be done in the caller method. Called by removeEorBaseObject(). Calls removeEorTarget() and removeEorSource(). Overridden by the NoThanViewInBaseImpl subclass to provide an empty method.

Parameters:
_obj - with an alias relation to process
Throws:
CreateError - if the name is null, or the object name is null or empty.

finalizeForBase

public void finalizeForBase()
                     throws UpDateError
The view is removed as a listener and the internal maps are set to null. The view is NOT still closed in BaseManager. Called by BaseManagerImpl.closeOpenView() and, indirectly, by propertyChange().

Overrides:
finalizeForBase in class FolderAbst
Throws:
UpDateError - from the super class

finalizeFromDeserialization

protected void finalizeFromDeserialization()
This method does not clear all the view objects maps, since they are transient. It does not finalizes the view objects, since there are objects from open ACS (see FolderAbst.prepareAfterRestoring()). The view is NOT removed as a listener, since there is no listener. The internal maps are set to null. Only calls the super method. Called by BaseManager.openView() when prepareAfterRestoring() throws an exception.

Overrides:
finalizeFromDeserialization in class FolderAbst

finalizeForCopy

public void finalizeForCopy()
The internal maps are set to null. The view is NOT open in BaseManager. Called by copy(), RightsFactory_Facade.detectNoThanRights() and BaseManagerImpl.getElementsOfOneView().

Overrides:
finalizeForCopy in class FolderAbst

finalizeForGUI

protected void finalizeForGUI()
This method is reserved to the sketch view. This view is removed as a listener and the internal maps are set to null. The sketch view is never registered in BaseManager. Called by BaseManagerImpl.closeSketchView(). Calls removeOwnListening() and super.finalizeForCopy().


prepareAfterRestoring

protected java.lang.String prepareAfterRestoring()
                                          throws DialogError
This method must be called by BaseManagerImpl after the opening of the view, to update the transient maps, and to check the open ACS and their objects which are in the restored view. Noop if the folder objects has been restored, having a non-empty BaseObjects map. Calls the super method at the first line. Overrides the super method.

Overrides:
prepareAfterRestoring in class FolderAbst
Returns:
a non-null message if some objects has been removed from the view, or null.
Throws:
DialogError - by the super class if the view contains an object from a closed ACS, before the registering of the view as listener; the exception message should be shown to the user
java.lang.InternalError - if an object is not a Resource nor an EligibleParty.