ARoad0.gBase
Class UserIDImpl

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

public class UserIDImpl
extends GroupIDMemberImpl
implements java.io.Serializable, UserID

This class is responsible for modeling an account in an ACS, as a kind of GroupIDMember that owns some resources and a primary groupID. It has some current actors, that are programs starting their execution under it. It is a javabean with the following bound properties: 'l_UserIDCurrentActors', 'l_UserIDOwnResources', 'PrimGroup', 'Order'. The listeners are proper to this instance, outside gBase, transient (not serialized in this instance backup). They are called in any order. Excepted for 'PrimGroup', 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.

All variables are private to secure the white box inheritances from this 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 UserIDImpl EMPTY_INSTANCE
          A reusable empty instance for initialization, to avoid the use of 'new' for default values.
protected  Actor[] l_currentActors_
           
protected  Resource[] l_ownResources_
           
protected  int order_
           
protected  GroupID primGroup_
           
static java.io.ObjectStreamField[] serialPersistentFields
          variable for the JDK 2 serialization
private static long serialVersionUID__
           
 
Fields inherited from class ARoad0.gBase.GroupIDMemberImpl
isAdmin_, l_Groups_
 
Fields inherited from class ARoad0.gBase.EligiblePartyImpl
m_AclEntriesResources_
 
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
UserIDImpl()
          simple constructor
UserIDImpl(ImmutableName _name, ACS _acs, java.lang.String _epType, java.lang.Boolean _isAdmin)
          Constructor used in the beamer by the editor for the ACS EP list, from the 'New' button.
UserIDImpl(ImmutableName _name, ACS _acs, java.lang.String _epType, boolean _isAdmin, boolean _toRegisterInManager)
          Used for the creation of an UserID.
 
Method Summary
protected  void addCurrentActor(Actor _act)
          A current actor is running under this userID whatever its caller.
 void addGroupToGM(GroupID _grp)
          Overrides the super class method.
protected  void addOwnResource(Resource _res)
          Invoked by Resource.setEorUserID().
 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  UserIDImpl copyOwnVariables(UserIDImpl _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 copy() but without copying the internal AclEntries.
 boolean equals(java.lang.Object _obj)
          Does not compare the comment.
protected  void finalize()
          This method removes the userID from the ACS lists, but there is no guaranee that the JVM calls this method before the end of the application.
 void finalizeForBase()
          super.finalizeForBase() removes the userID in the ACS lists (main and controllers), and removes it in the resources connected through an aclEntry.
protected  void finalizeFromDeserialization()
          This method finalizes each group in the groups set, since it is used after a deserialization.
 Actor[] getEorL_UserIDCurrentActors()
          A current actor is running under this userID whatever its caller.
 Resource[] getEorL_UserIDOwnResources()
          An own resource is a same-ACS resource that have this as userID.
 GroupID getEorPrimGroup()
          The primary group is used by an Actor that has a current UserID, to set the primary group as current GroupID of the Actor.
 int getOrder()
           
 java.beans.PropertyChangeListener[] getPropertyChangeListeners(java.lang.String _propertyName)
          Returns the change listeners for a property.
 long getSerialVersionUID()
          For the java serialization.
 int hashCode()
           
 boolean ownsResource(Resource _res)
           
protected  void removeCurrentActor(Actor _act)
          Invoked by Actor.finalizeForBase(), Actor.setEorCurrentUserID() or by gWork.
 void removeGroupToGM(ImmutableGroupID _grp)
          Remove a group for which this GroupIDMember is a member, and remove it as primary group.
protected  void removeOwnResource(Resource _res)
          Invoked by Resource.setEorUserID(), Resource.finalizeForBase() Fires an event on "l_UserIDOwnResources".
protected  void removePrimGroup()
          Removes the current primary group in the current actors which have it as their current group.
 void removePropertyChangeListener(java.lang.String _propertyName, java.beans.PropertyChangeListener _l)
          Removes a listener to the bean.
 void setEorPrimGroup(GroupID _g)
          Sets a primary group, and it must have this instance as member.
 void setOrder(int _i)
          Sets the strengh of the UserID which determines its priority order in access control decisions.
 java.lang.String toString()
          Gets the name last component of the instance.
 
Methods inherited from class ARoad0.gBase.GroupIDMemberImpl
copy, copyOwnVariables, copyWithoutAcl, getEorL_GroupID, isAdmin
 
Methods inherited from class ARoad0.gBase.EligiblePartyImpl
addAclEntryToEP, addEorPrivilegeForLinksToSource, addEorPrivilegeForTypeToSource, copyOwnVariables, deleteAclEntries, getEorL_AclConnectedResources, getEorL_SourcePrivilegeForLinks, getEorL_SourcePrivilegeForTypes, getEorL_SourcePrivileges, getEPType, removeAclEntryToEP, removeEorPrivilegeToSource, setEPType
 
Methods inherited from class ARoad0.gBase.BasicImpl
addAcsOfSoftReferences, addConstrainedChildACS, addEorSoftAlias, addInVFolderList, addInViewList, addPropertyChangeListener, compareTo, copyOwnVariables, 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
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface ARoad0.gBaseInterface.UserID
finalizeForUser
 
Methods inherited from interface ARoad0.gBaseInterface.EligibleParty
setEPType
 
Methods inherited from interface ARoad0.gBaseInterface.Basic
setComment
 
Methods inherited from interface ARoad0.gBaseInterface.PrivilegeSource
addEorPrivilegeForTypeToSource, removeEorPrivilegeToSource
 
Methods inherited from interface ARoad0.gBaseInterface.ImmutableGroupIDMember
getEorL_GroupID, isAdmin
 
Methods inherited from interface ARoad0.gBaseInterface.ImmutableEligibleParty
getEorL_AclConnectedResources, getEPType, getM_ConstrainedChildACS
 
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.ImmutablePrivilegeSource
getEorL_SourcePrivilegeForLinks, getEorL_SourcePrivilegeForTypes, getEorL_SourcePrivileges
 
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
 
Methods inherited from interface ARoad0.gBaseInterface.BaseBeanManager
addPropertyChangeListener, removePropertyChangeListener
 
Methods inherited from interface ARoad0.gBaseInterface.ImmutableTarget
getEorAliasAsInternalHardReference, getEorReferenceAsInternalHardAlias, getHasSoftAlias, getL_AcsOfSoftReferences, getL_SoftAlias, getType
 

Field Detail

serialVersionUID__

private static final long serialVersionUID__
See Also:
Constant Field Values

primGroup_

protected GroupID primGroup_

order_

protected int order_

l_ownResources_

protected Resource[] l_ownResources_

l_currentActors_

protected Actor[] l_currentActors_

EMPTY_INSTANCE

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


serialPersistentFields

public static final java.io.ObjectStreamField[] serialPersistentFields
variable for the JDK 2 serialization

Constructor Detail

UserIDImpl

public UserIDImpl()
simple constructor


UserIDImpl

public UserIDImpl(ImmutableName _name,
                  ACS _acs,
                  java.lang.String _epType,
                  java.lang.Boolean _isAdmin)
           throws CreateError
Constructor used in the beamer by the editor for the ACS EP list, from the 'New' button.

Parameters:
_name - ImmutableName of the userID as a kind of eligible party
_acs - ACS owning the userID
_epType - is the eligible party type, and may be null if the ACS allows it.
_isAdmin - true only if the instance has an administrative role in the ACS, for the technical administration or the users
Throws:
CreateError - if ACS.newEorEligibleParty() throws it - the instance must then be deleted !

UserIDImpl

public UserIDImpl(ImmutableName _name,
                  ACS _acs,
                  java.lang.String _epType,
                  boolean _isAdmin,
                  boolean _toRegisterInManager)
           throws CreateError
Used for the creation of an UserID.

Parameters:
_name - ImmutableName of the eligible party to create
_acs - Main ACS of the eligible party to create
_epType - is the eligible party type, and may be null if the ACS allows it.
_isAdmin - true only if the instance has an administrative role in the ACS, for the technical administration or the users
_toRegisterInManager - false if this method must not register the instance in its ACS.
Throws:
CreateError - if ACS.newEorEligibleParty() 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. Do not copy the own resources or the current actors. The copy order is 3 times the source order. Caution: do not copy the user and the group if _result does not belong to aCS_ and if there are no user or group in the _result ACS which have similar names - that is that are ended by the same Strings in this instance user or group names. Call copyOwnVariables(). This method is overridden by the subclasses.

Specified by:
copy in interface Copyable
Overrides:
copy in class EligiblePartyImpl
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 UserIDImpl
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 copy() but without copying the internal AclEntries. Does not copy the own resources or the current actors. The copy order is 3 times the source order. Caution: does not copy the user and the group if _result does not belong to aCS_ and if there are no user or group in the _result ACS which have similar names - that is that are ended by the same Strings in this instance user or group names. Calls copyOwnVariables().

Specified by:
copyWithoutInternalAcl in interface EligibleParty
Overrides:
copyWithoutInternalAcl in class EligiblePartyImpl
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 UserIDImpl
Throws:
CreateError - of the constructor with the same parameters, or if _parent ACS is not _acs, or addAclEntry() exceptions.

setEorPrimGroup

public void setEorPrimGroup(GroupID _g)
                     throws UpDateError
Sets a primary group, and it must have this instance as member. The primary group is used by an Actor that has a current UserID, to set the primary group as current GroupID of the Actor. If the resource parent does not enforce the child GID, the primary group is the group of any new resource owned by this UserID. Updates the own actors which have the previous primary group as current group. Removes the current primary group in the current actors which have it as their current group. Fire the PropertyChange 'PrimGroup'. Noop and error mesage to the user if the instance type starts with 'byAcsCreator' or 'immutable' after the creation. To do it in that case, remove this instance from all its groups, and then, the first registered group will be the primary group. Reads the ACS 'GroupID.NoPrimaryGroup' values to check if the argument may be a primary group.

Specified by:
setEorPrimGroup in interface UserID
Parameters:
_g - GroupID that is the primary group of the userID. May be null.
Throws:
UpDateError - if _g does not belong to the main ACS of this resource or cannot be a primary group, or does not contain this instance, or if the type is immutable after the first creation.

getEorPrimGroup

public GroupID getEorPrimGroup()
The primary group is used by an Actor that has a current UserID, to set the primary group as current GroupID of the Actor. If the resource parent does not enforce the child GID, the primary group is the group of any new resource owned by this UserID.

Specified by:
getEorPrimGroup in interface ImmutableUserID
Returns:
the primary group of the userID. May be null.

setOrder

public void setOrder(int _i)
              throws UpDateError
Sets the strengh of the UserID which determines its priority order in access control decisions. Noop without error message if the ep type starts with 'byAcsCreator' or 'immutable', with a current order that is different to the initial value '-1'.

Specified by:
setOrder in interface UserID
Parameters:
_i - order of the userID
Throws:
UpDateError - if immutable

getOrder

public int getOrder()
Specified by:
getOrder in interface ImmutableUserID
Returns:
the UID of the userID

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: 'l_UserIDCurrentActors', 'l_UserIDOwnResources', 'PrimGroup', 'Order'. Calls the super method.

Specified by:
addPropertyChangeListener in interface BaseBeanManager
Specified by:
addPropertyChangeListener in interface BoundBean
Overrides:
addPropertyChangeListener in class GroupIDMemberImpl
Parameters:
_propertyName - 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: 'l_UserIDCurrentActors', 'l_UserIDOwnResources', 'PrimGroup', 'Order'. 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 GroupIDMemberImpl
Parameters:
_propertyName - 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 GroupIDMemberImpl
Parameters:
_propertyName - name of the listened property.
Returns:
the change listeners. May be null or empty.

getSerialVersionUID

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

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

addOwnResource

protected void addOwnResource(Resource _res)
Invoked by Resource.setEorUserID(). Fires an event on 'l_UserIDOwnResources'.

Parameters:
_res - owned by this userID.

addCurrentActor

protected void addCurrentActor(Actor _act)
A current actor is running under this userID whatever its caller. Invoked by Actor.setEorCurrentUserID(). Fire an event on "l_UserIDCurrentActors".

Parameters:
_act - currently attached to this userID.

addGroupToGM

public void addGroupToGM(GroupID _grp)
Overrides the super class method. Calls setEorPrimGroup(_grp) if no primary group.

Specified by:
addGroupToGM in interface GroupIDMember
Overrides:
addGroupToGM in class GroupIDMemberImpl
Parameters:
_grp - to add. No action if it is null, or with null name.

removePrimGroup

protected void removePrimGroup()
Removes the current primary group in the current actors which have it as their current group. Called by GroupID.finalizeForBase() and removeGroupToGM(). Calls ActorImpl.removeEorCurrentGroupID(). Fire the Propertychange 'PrimGroup'.


getEorL_UserIDCurrentActors

public Actor[] getEorL_UserIDCurrentActors()
A current actor is running under this userID whatever its caller. It may be an own resource of this userID or not.

Specified by:
getEorL_UserIDCurrentActors in interface ImmutableUserID
Returns:
array of the current actors attached to this userID. May be empty, but never null.

getEorL_UserIDOwnResources

public Resource[] getEorL_UserIDOwnResources()
An own resource is a same-ACS resource that have this as userID. If it is an Actor, it may be a current actor of this userID or not.

Specified by:
getEorL_UserIDOwnResources in interface ImmutableUserID
Returns:
array of the own resources. May be empty, but never null.

ownsResource

public boolean ownsResource(Resource _res)
Specified by:
ownsResource in interface ImmutableUserID
Returns:
true if it owns the resource.

finalize

protected void finalize()
                 throws java.lang.Throwable
This method removes the userID from the ACS lists, but there is no guaranee that the JVM calls this method before the end of the application.

Overrides:
finalize in class GroupIDMemberImpl
Throws:
java.lang.Throwable
java.lang.Throwable

finalizeForBase

public void finalizeForBase()
                     throws UpDateError
super.finalizeForBase() removes the userID in the ACS lists (main and controllers), and removes it in the resources connected through an aclEntry. This method removes (this) in own resources and in current actors, so they have no more UserID connected to them. Overrides the super method and calls it. This method HAS TO BE USED before deleting the userID. Note: when this method is called by the EligiblePartyImpl constructor, the proper variables of this class are not still initialized.

Specified by:
finalizeForBase in interface FinalizedObject
Overrides:
finalizeForBase in class GroupIDMemberImpl
Throws:
UpDateError - if the userID is unknown of the main ACS (if it is a clone, typically), or if a linked immutable object fires an exception

finalizeFromDeserialization

protected void finalizeFromDeserialization()
This method finalizes each group in the groups set, 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 GroupIDMemberImpl

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.

Overrides:
clone in class GroupIDMemberImpl
Returns:
Object is not registred in the ACSs. The names, the type, the comment, the alias, the order are cloned. The external object references are not cloned (see "Eor" in get method).

equals

public boolean equals(java.lang.Object _obj)
Description copied from class: EligiblePartyImpl
Does not compare the comment.

Specified by:
equals in interface BaseObject
Overrides:
equals in class GroupIDMemberImpl
Parameters:
_obj - Object to compare
Returns:
true if _obj is an instance of UserIDImpl (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 GroupIDMemberImpl
Returns:
the hashcode derived from the name of the primary groupID, the first groupID, the type and folder member hashcodes

toString

public java.lang.String toString()
Description copied from class: BasicImpl
Gets the name last component of the instance. Used in the explorer to display the element. Never null.

Overrides:
toString in class GroupIDMemberImpl
Returns:
String: the variables of the instance : name (last component). May be null.

copyOwnVariables

protected UserIDImpl copyOwnVariables(UserIDImpl _result,
                                      boolean _withoutInternalAcl)
                               throws CreateError
This method provides a copy of the instance variables. Copies the result as groupIDMember (done by GroupIDMemberImpl.copyOwnVariables()). Does not copy the own resources and the current actors, but the resource and actor copies do the job. The copy order is 3 times the source order. 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

removeOwnResource

protected void removeOwnResource(Resource _res)
                          throws UpDateError
Invoked by Resource.setEorUserID(), Resource.finalizeForBase() Fires an event on "l_UserIDOwnResources".

Parameters:
_res - Resource to remove in this userID
Throws:
UpDateError - if _res is null or unknown

removeCurrentActor

protected void removeCurrentActor(Actor _act)
                           throws UpDateError
Invoked by Actor.finalizeForBase(), Actor.setEorCurrentUserID() or by gWork. Fires an event on "l_UserIDCurrentActors".

Parameters:
_act - to remove in this userID
Throws:
UpDateError - if _act is null or unknown

removeGroupToGM

public final void removeGroupToGM(ImmutableGroupID _grp)
Remove a group for which this GroupIDMember is a member, and remove it as primary group. Fire changes on 'AssociatedGroups'. No exception if _grp is not registered. Used only by GroupIDImpl. Call removePrimGroup(). Overriddes the GroupIDMemberImpl method.

Specified by:
removeGroupToGM in interface GroupIDMember
Overrides:
removeGroupToGM in class GroupIDMemberImpl
Parameters:
_grp - to remove
Throws:
java.lang.InternalError - if _grp is not found.