ARoad0.gBase
Class EligiblePartyImpl

java.lang.Object
  extended by ARoad0.gBase.BasicImpl
      extended by ARoad0.gBase.EligiblePartyImpl
All Implemented Interfaces:
ACSObject, BaseBeanManager, BaseObject, Basic, BoundBean, Copyable, EligibleParty, FinalizedObject, FinalizedObjectForUser, ImmutableBasic, ImmutableEligibleParty, ImmutablePrivilegeSource, ImmutableSource, PrivilegeSource, PrivilegeUser, java.io.Serializable, java.lang.Cloneable, java.lang.Comparable
Direct Known Subclasses:
GroupIDMemberImpl

public class EligiblePartyImpl
extends BasicImpl
implements EligibleParty

This class is responsible for modeling the simplest rights user for which an ACS grants access or denies access to some targets through AclEntries or Privileges. This kind of entity may be an account (UserID), a group (GroupID) or an actor (Actor). This class manages the resources connected to the EligibleParty through AclEntries, and it manages its Privileges. The constructor adds '<U>' or '<G>' after the ACS name, in the name components, if the new instance is an UserID or a GroupID, which are subclasses of this class. It is a javabean with the following bound properties: 'AclConnectedResources', 'OneSourceTypedPrivilege', 'OneSourceLinkedPrivilege'. The listeners are proper to this instance, outside gBase, transient (not serialized in this instance backup). They include ViewInBaseImpl, gWork.RightsMediatorImpl. They are called in any order. They receive only a copy of the new value, to protect the property. All the exceptions from the listeners are catched, and a dialog box is displayed to inform the user. finalizeForUser() uses the ARoad0.Gui1.DialogBox class.

This class has several subclasses in this package and in the AcsAddon packages. Most of the variables are protected.

See Also:
Serialized Form

Field Summary
static EligiblePartyImpl EMPTY_INSTANCE
          A reusable empty instance for initialization, to avoid the use of 'new' for temporary values.
protected  java.util.SortedMap<ImmutableName,ImmutableResource> m_AclEntriesResources_
          map(resource name, resource).
static java.io.ObjectStreamField[] serialPersistentFields
          Properties for the serialization.
private static long serialVersionUID__
           
 
Fields inherited from class ARoad0.gBase.BasicImpl
aCS_, aCS_Name_, aliasHandler_, changeSupport_, comment_, folderMember_, INCREMENT_CAPACITY, INITIAL_CAPACITY, INITIAL_CAPACITY_2, iS_Name_, m_ConstrainedChildACS_, name_, PRIME, privHandler_, type_
 
Constructor Summary
EligiblePartyImpl()
          Default constructor
EligiblePartyImpl(ImmutableName _name, ACS _acs, java.lang.String _epType)
          Constructor used in the beamer by the editor for the ACS EP list, from 'New'.
EligiblePartyImpl(ImmutableName _name, ACS _acs, java.lang.String _epType, boolean _toRegisterInManager)
          Used for the creation of an eligible party alias without base registration.
 
Method Summary
protected  void addAclEntryToEP(AclEntry _acl)
          CAUTION: any change in this method code MUST also be done in ActorImpl.
protected  void addEorPrivilegeForLinksToSource(PrivilegeForLinks _priv)
          Sets a privilege as applicable to this access source.
 void addEorPrivilegeForTypeToSource(PrivilegeForType _priv)
          Sets a privilege as applicable to this access source.
 void addPropertyChangeListener(java.lang.String _propertyName, java.beans.PropertyChangeListener _l)
          Adds a listener to the bean.
 java.lang.Object clone()
          Clone without register the new object in the ACSs.
 java.lang.Object copy(ImmutableName _name, ACS _acs, Directory _parent, java.lang.Boolean _toRegisterInManager)
          This method provides a copy of the instance with another name.
protected  EligiblePartyImpl copyOwnVariables(EligiblePartyImpl _result, boolean _withoutInternalAcl)
          This method provides a copy of the instance variables.
 java.lang.Object copyWithoutInternalAcl(ImmutableName _name, ACS _acs, Directory _parent, java.lang.Boolean _toRegisterInManager)
          This method provides a copy of the instance as Copyable.copy(), but without copying the internal aclEntries.
protected static EligibleParty deleteAclEntries(EligibleParty _ep)
          Removes all the aclEntries.
 boolean equals(java.lang.Object _obj)
          Does not compare the comment.
 void finalizeForBase()
          This method removes the EligibleParty in the ACS list, and in the Resources, deletes any AclEntry having this instance as source.
protected  void finalizeFromDeserialization()
          NO USE.
 java.util.List<ImmutableResource> getEorL_AclConnectedResources()
          Gets the resources connected to this eligible party.
 java.util.List<PrivilegeForLinks> getEorL_SourcePrivilegeForLinks()
          Gets all the PrivilegeForLinks linked to this source.
 java.util.List<PrivilegeForType> getEorL_SourcePrivilegeForTypes()
          Gets all the PrivilegeForTypes of this source.
 java.util.List<Privilege> getEorL_SourcePrivileges()
          Gets all the privileges linked to this source.
 java.lang.String getEPType()
           
 java.beans.PropertyChangeListener[] getPropertyChangeListeners(java.lang.String _propertyName)
          Returns the change listeners for a property.
 long getSerialVersionUID()
          For the java serialization.
 int hashCode()
           
protected  void removeAclEntryToEP(AclEntry _acl)
          Removes the related resource of an aclEntry, if the argument is the single AclEntry for the resource.
 void removeEorPrivilegeToSource(Privilege _priv)
          Unregisters the privilege, and this instance in the linked privilege when it is no more used by this privilege source.
 void removePropertyChangeListener(java.lang.String _propertyName, java.beans.PropertyChangeListener _l)
          Removes a listener to the bean.
 void setEPType(java.lang.String _st)
          Sets the type which drives the immutablility and the allowed rights of the object.
 
Methods inherited from class ARoad0.gBase.BasicImpl
addAcsOfSoftReferences, addConstrainedChildACS, addEorSoftAlias, addInVFolderList, addInViewList, addPropertyChangeListener, compareTo, copyOwnVariables, finalize, finalizeForUser, firePropertyChange, getAcsName, getComment, getEorACS, getEorAliasAsInternalHardReference, getEorReferenceAsInternalHardAlias, getFullName, getHasSoftAlias, getImpliedViews, getIS_Name, getL_AcsOfSoftReferences, getL_SoftAlias, getM_ConstrainedChildACS, getName, getNickName, getType, getVirtualFolders, removeAcsOfSoftReferences, removeConstrainedChildACS, removeEorSoftAlias, removeInVFolderList, removeInViewList, removePropertyChangeListener, setComment, setEorAliasAsInternalHardReference, setEorReferenceAsInternalHardAlias, setType, toString
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface ARoad0.gBaseInterface.ImmutableEligibleParty
getM_ConstrainedChildACS
 
Methods inherited from interface ARoad0.gBaseInterface.Basic
finalizeForUser, setComment
 
Methods inherited from interface ARoad0.gBaseInterface.ImmutableBasic
getComment, getEorAliasAsInternalHardReference, getEorReferenceAsInternalHardAlias, getHasSoftAlias, getImpliedViews, getIS_Name, getL_AcsOfSoftReferences, getL_SoftAlias, getVirtualFolders
 
Methods inherited from interface ARoad0.gBaseInterface.BoundBean
addPropertyChangeListener, removePropertyChangeListener
 
Methods inherited from interface ARoad0.gBaseInterface.ImmutableSource
getEorAliasAsInternalHardReference, getEorReferenceAsInternalHardAlias, getHasSoftAlias, getL_AcsOfSoftReferences, getL_SoftAlias, getType
 
Methods inherited from interface ARoad0.gBaseInterface.ACSObject
getAcsName, getEorACS
 
Methods inherited from interface ARoad0.gBaseInterface.BaseObject
getFullName, getName, getNickName
 

Field Detail

serialVersionUID__

private static final long serialVersionUID__
See Also:
Constant Field Values

m_AclEntriesResources_

protected java.util.SortedMap<ImmutableName,ImmutableResource> m_AclEntriesResources_
map(resource name, resource). Is set to null when it is empty.


EMPTY_INSTANCE

public static final EligiblePartyImpl EMPTY_INSTANCE
A reusable empty instance for initialization, to avoid the use of 'new' for temporary values. Caution: never change the state of the returned instance.


serialPersistentFields

public static final java.io.ObjectStreamField[] serialPersistentFields
Properties for the serialization.

Constructor Detail

EligiblePartyImpl

public EligiblePartyImpl()
Default constructor


EligiblePartyImpl

public EligiblePartyImpl(ImmutableName _name,
                         ACS _acs,
                         java.lang.String _epType)
                  throws CreateError
Constructor used in the beamer by the editor for the ACS EP list, from 'New'. Adds '<U>' or '<G>' between the ACS name and the end of _name if it is an UserID or a GroupID. This '<G>' adding is used in AclEntryImpl.setRight().

Parameters:
_name - of the eligible party
_acs - main ACS of the eligible party
_epType - the eligible party type which drives the rights and the immutability of the instance. If null, the value is set to '<undefined>'.
Throws:
CreateError - if ACSImpl.newEorEligibleParty() throws it - the instance must then be deleted!
See Also:
must apply the same UserID and GroupID naming policy

EligiblePartyImpl

public EligiblePartyImpl(ImmutableName _name,
                         ACS _acs,
                         java.lang.String _epType,
                         boolean _toRegisterInManager)
                  throws CreateError
Used for the creation of an eligible party alias without base registration. Adds a prefix in the name, following the effective class of the created object: UserID or GroupID. Calls setType().

Parameters:
_name - of the eligible party to create, before the adding of the component 'G' if it is a GroupID or 'U' if it is an UserID
_acs - is the ACS of the eligible party to create
_epType - is the eligible party type which drives the rights and the immutability of the instance. If null, the value is set to '<undefined>'.
_toRegisterInManager - false if this method must not register the instance in its ACS.
Throws:
CreateError - if ACSImpl.newEorEligibleParty() or setType() throws it - the instance must then be deleted!
Method Detail

copy

public java.lang.Object copy(ImmutableName _name,
                             ACS _acs,
                             Directory _parent,
                             java.lang.Boolean _toRegisterInManager)
                      throws CreateError
This method provides a copy of the instance with another name. Each internal variable that is an external object reference have a shallow copy (no deep copy). Comments are not copied, nor the aclEntry resources. Call copyOwnVariables(). This method is overridden by the subclasses.

Specified by:
copy in interface Copyable
Overrides:
copy in class BasicImpl
Parameters:
_name - copy name. Usually creates as an extension of _parent name.
_acs - main ACS of the copy to create. May not be the ACS of this instance.
_parent - is not used, wathever the value.
_toRegisterInManager - false if this method must not register the instance in the ACS.
Returns:
a new instance of ResourceImpl
Throws:
CreateError - of the constructor with the same parameters, or if _parent ACS is not _acs, or addAclEntry() exceptions.

copyWithoutInternalAcl

public java.lang.Object copyWithoutInternalAcl(ImmutableName _name,
                                               ACS _acs,
                                               Directory _parent,
                                               java.lang.Boolean _toRegisterInManager)
                                        throws CreateError
This method provides a copy of the instance as Copyable.copy(), but without copying the internal aclEntries. It is used for ACSImpl.copy(), because all the EP must be copied first before the copy of all the resources with their aclEntries. Each internal variable that is an external object reference has a shallow copy (no deep copy), but without copy for the internal aclEntry nor the list of ViewInBase that contains this instance. Called from BaseUtilitiesImpl.copyDirectoriesAndActors(). Calls copyOwnVariables().

Specified by:
copyWithoutInternalAcl in interface EligibleParty
Parameters:
_name - copy name. Usually creates as an extension of _parent name.
_acs - main ACS of the copy to create. May not be the ACS of this instance.
_parent - is not used, wathever the value.
_toRegisterInManager - false if this method must not register the instance in the ACS.
Returns:
a new instance of EligiblePartyImpl
Throws:
CreateError - of the constructor with the same parameters, or if _parent ACS is not _acs, or addAclEntry() exceptions.

setEPType

public void setEPType(java.lang.String _st)
               throws UpDateError
Sets the type which drives the immutablility and the allowed rights of the object. If _st is allowed by the ACS, set the type of this eligible party. This method is used to switch from an '<immutable>' type which forbids the updates of a protected property, and to return to this protecting type. Then , it is possible to switch for example from 'actor' to '<immutable> actor', but not to '<immutable> group'. From the default value '<undefined>', any first update may be done. '<12345678901234567890>' is a program-reserved value. Even if not allowed by the ACS, '<12345678901234567890>' is the only new value for which a type starting with '<byAcsCreator' may be changed. From '<12345678901234567890>', any new value may be set from the allowed ones, and this starting value is the only one which allow to set a value containing '<byAcsCreator>'. Calls ACSImpl.getM_SpecializedTypesAndExplorer(). Called by the constructor. This is just a wrapper of super.setType() and it fires the event 'EPType'.

Specified by:
setEPType in interface EligibleParty
Parameters:
_st - type of the resource.
Throws:
UpDateError - if the type is null, or does not comply to the criteria.

getEPType

public java.lang.String getEPType()
Specified by:
getEPType in interface ImmutableEligibleParty
Returns:
String type of the eligible party. May be null.

getEorL_AclConnectedResources

public final java.util.List<ImmutableResource> getEorL_AclConnectedResources()
Gets the resources connected to this eligible party. The resources may belong to differents ACS, as the aclEntries. One resource may have differents aclEntries (of different ACS) which connect it to this eligible party; then, the returned list contains only one reference to this resource.

Specified by:
getEorL_AclConnectedResources in interface ImmutableEligibleParty
Returns:
the unmodifiable list of references on resources. May be empty, but not null.

addEorPrivilegeForTypeToSource

public void addEorPrivilegeForTypeToSource(PrivilegeForType _priv)
                                    throws BaseError
Sets a privilege as applicable to this access source. This method is called only by PrivilegeForTypeImpl. For PrivilegeForTypes, only the TYPED and TYPED_CLASSED privilege may be argument. This is false for TYPED_CLASSED_SPECIFIC and TYPED_FOR_SEED privileges, for which an InternalError is thrown. The gBase classes are the only caller of this method at any creation/deletion of a typed privilege or an access source. Fires 'OneSourceTypedPrivilege' events.

Specified by:
addEorPrivilegeForTypeToSource in interface PrivilegeSource
Parameters:
_priv - is a Privilege to register in the source
Throws:
BaseError - if this instance is not a privilege source, if the privilege second type is not authorized for this source.

addEorPrivilegeForLinksToSource

protected void addEorPrivilegeForLinksToSource(PrivilegeForLinks _priv)
                                        throws BaseError
Sets a privilege as applicable to this access source. Called by PrivilegeForLinksImpl.addEorPrivilegeSourceLink(). Caution: a role-to-one privilege is added even if this instance is immutable, ahile the other linked privileges are not added in this case. Fires 'OneSourceLinkedPrivilege' events.

Parameters:
_priv - to register in the source
Throws:
BaseError - if this instance is not a privilege source or is immutable, if the privilege second type is not authorized for this source.

removeEorPrivilegeToSource

public void removeEorPrivilegeToSource(Privilege _priv)
                                throws BaseError
Unregisters the privilege, and this instance in the linked privilege when it is no more used by this privilege source. Called by PrivilegeForTypeImpl.finalizeForBase() and PrivilegeForLinksImpl. Fires 'OneSourceTypedPrivilege' and 'OneSourceLinkedPrivilege' events.

Specified by:
removeEorPrivilegeToSource in interface PrivilegeSource
Parameters:
_priv - to unregister
Throws:
BaseError - if the privilege is unknown.

getEorL_SourcePrivileges

public java.util.List<Privilege> getEorL_SourcePrivileges()
Gets all the privileges linked to this source. There is two types of privilege links (allowed or not by the ACS):

- PrivilegeForLinks: linked privilege established for a couple (ACSObject, privilege),

- PrivilegeForType: typed privilege, where the ACSObject and the privilege has a common type, but without the TYPED_FOR_SEED and TYPED_CLASSED_SPECIFIC privileges.

Specified by:
getEorL_SourcePrivileges in interface ImmutablePrivilegeSource
Returns:
List of Privileges. May be empty, but never null.

getEorL_SourcePrivilegeForTypes

public java.util.List<PrivilegeForType> getEorL_SourcePrivilegeForTypes()
Gets all the PrivilegeForTypes of this source. Does not include the TYPED_FOR_SEED and TYPED_CLASSED_SPECIFIC privileges.

Specified by:
getEorL_SourcePrivilegeForTypes in interface ImmutablePrivilegeSource
Returns:
List of PrivilegeForType. May be empty, but never null.

getEorL_SourcePrivilegeForLinks

public java.util.List<PrivilegeForLinks> getEorL_SourcePrivilegeForLinks()
Gets all the PrivilegeForLinks linked to this source. Note: for LINKED_IF_ALL linked privileges, the presence of the privilege does not mean that the master has the privilege rights. Returns an immutable empty list if getIsSource() is false.

Specified by:
getEorL_SourcePrivilegeForLinks in interface ImmutablePrivilegeSource
Returns:
List of PrivilegeForLinks. May be empty, but never null.

addPropertyChangeListener

public void addPropertyChangeListener(java.lang.String _propertyName,
                                      java.beans.PropertyChangeListener _l)
Adds a listener to the bean. Used by Gui1.CommonPropertyEditor for the properties: 'AclConnectedResources', 'OneSourceTypedPrivilege', 'OneSourceLinkedPrivilege'. Overrides the super method and calls it.

Specified by:
addPropertyChangeListener in interface BaseBeanManager
Specified by:
addPropertyChangeListener in interface BoundBean
Overrides:
addPropertyChangeListener in class BasicImpl
Parameters:
_propertyName - String is the name of the property
_l - PropertyChangeListener 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. Used by Gui1.CommonPropertyEditor for the properties: 'AclConnectedResources', 'OneSourcePrivilege'. Note: using this method does not remove a listener which has been registered through addPropertyChangeListener(PropertyChangeListener _l). Overrides the super method and calls it.

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

getPropertyChangeListeners

public java.beans.PropertyChangeListener[] getPropertyChangeListeners(java.lang.String _propertyName)
Returns the change listeners for a property. Used by the AcsAddons.

Specified by:
getPropertyChangeListeners in interface ImmutableBasic
Overrides:
getPropertyChangeListeners in class BasicImpl
Parameters:
_propertyName - name of the listened property.
Returns:
the change listeners. May be null or empty.

finalizeForBase

public void finalizeForBase()
                     throws UpDateError
This method removes the EligibleParty in the ACS list, and in the Resources, deletes any AclEntry having this instance as source. Then, it removes this instance in every group. UserID.finalizeForBase() removes in resources through a variable userID_ and currentUserID_ (for Actors). GroupID.finalizeForBase() removes in resources through the variable groupID_ and, for Actors, currentGroupID_ and l_SecondaryGroup_. GroupID.finalizeForBase() removes also in userIDs the primary group if it is this. An unused object has to be deleted to inform the others objects, and this method HAS TO BE USED before deleting the eligible party. Calls ACSImpl.removeEorEligibleParty() only if the object is known by the ACS. Called by the ACSImpl.finalizeForBase() and setAcsRelationsInIS(), and by finalizeForUser(). This method does not raise PropertyChangeEvents since the BeanInfo for this class specifies that the ACS informs the listeners when this instance is finalized. Caution: The listeners may use the groups list since it is not still deleted.

Specified by:
finalizeForBase in interface FinalizedObject
Overrides:
finalizeForBase in class BasicImpl
Throws:
UpDateError - if the eligible party is unknown by the main ACS (if it is a clone, typically) or if the ACS of an aclEntry is closed or unknown, or if a linked immutable object fires an exception, or from ACSFactoryUtilityImpl.removeAssociatesAfterDeletion().

clone

public java.lang.Object clone()
Clone without register the new object in the ACSs. Caution: don't use any modifying method that may altere the integrity of the base. A finalized instance returns a clone with getEorACS() which returns null, but getName() and getAcsName() operates.

Overrides:
clone in class BasicImpl
Returns:
not registred in the ACSs. The names, the type, the comment are cloned. The external object references are not cloned (see "Eor" in get method).
Throws:
java.lang.CloneNotSupportedException

equals

public boolean equals(java.lang.Object _obj)
Does not compare the comment.

Specified by:
equals in interface BaseObject
Overrides:
equals in class BasicImpl
Parameters:
_obj - object to compare
Returns:
true if _obj is an instance of EligiblePartyImpl (or a derived class) equals to this instance (with the same class)

hashCode

public int hashCode()
Specified by:
hashCode in interface BaseObject
Overrides:
hashCode in class BasicImpl
Returns:
the hashcode derived from the names of the ACL-connected resources, the type and folder member hashcodes
Since:
0.7.0

getSerialVersionUID

public long getSerialVersionUID()
Description copied from class: BasicImpl
For the java serialization.

Specified by:
getSerialVersionUID in interface ImmutableBasic
Overrides:
getSerialVersionUID in class BasicImpl
Returns:
the static serialVersionUID__ of this class

copyOwnVariables

protected EligiblePartyImpl copyOwnVariables(EligiblePartyImpl _result,
                                             boolean _withoutInternalAcl)
                                      throws CreateError
This method provides a copy of the instance variables. Copy the aclEntries which have different resources ACS than this instance, and copy the others following _withoutIntResAcl. Comments are not copied. Called by copy() and by the copyOwnVariables() methods of the subclasses.

Parameters:
_result - to update with this instance variables copies
_withoutInternalAcl - true if the internal aclEntries - that is with a resource having the same ACS - must not be copied
Returns:
updated _result
Throws:
CreateError - if _result is null or if Resource.addAclEntry() throws it.

addAclEntryToEP

protected void addAclEntryToEP(AclEntry _acl)
CAUTION: any change in this method code MUST also be done in ActorImpl. Called by the ResourceImpl.addAclEntry(). There, the AclEntry ACS knowns the AclEntry.

Parameters:
_acl - appplied to this EP. The resource connected to _acl must have a name following the pattern IS_name / ACS_name / resource_name, to allow the unicity of the name. The aclEntry ACS may be different to the eligible party ACS.

removeAclEntryToEP

protected void removeAclEntryToEP(AclEntry _acl)
Removes the related resource of an aclEntry, if the argument is the single AclEntry for the resource. This condition is handled by the calling method. Called from AclEntryImpl.finalizeForUser(). The related resource is unrecorded in L_AclConnectedResources since _acl is the last one connected to its Resource in this EligibleParty. CAUTION: any update of this method must be also done in ActorImpl and any other EligibleParty direct implementation.

Parameters:
_acl - to remove

deleteAclEntries

protected static final EligibleParty deleteAclEntries(EligibleParty _ep)
Removes all the aclEntries. Called from copyWithoutAcl() from this class and each of its subclasses, and from ActorImpl and each of its subclasses.

Parameters:
_ep - is an EligibleParty
Returns:
_ep.

finalizeFromDeserialization

protected void finalizeFromDeserialization()
NO USE. This method finalizes all the attributes, since it is used after a deserialization. There, the attributes have been deserialized but are not 'true' objects of the base. The instance is NOT removed as a listener, since there is no listener. The internal maps are set to null. Does not call finalizeForBase(). Called only by EPRViewInBaseImpl.

Overrides:
finalizeFromDeserialization in class BasicImpl