|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.springframework.dao.support.DaoSupport
org.springframework.orm.hibernate.support.HibernateDaoSupport
com.atlassian.user.impl.hibernate.HibernateGroupManager
public class HibernateGroupManager
A HibernateGroupManager which handles membership for local and external entities.
| Field Summary | |
|---|---|
static String |
ENTITYID_FIELD
|
static String |
EXTERNAL_ENTITY_NAME_FIELD
|
protected ExternalEntityDAO |
externalEntityDao
|
static String |
GROUPID_FIELD
|
static String |
GROUPNAME_FIELD
|
protected HibernateRepository |
repository
|
protected UserManager |
userManager
|
| Fields inherited from class org.springframework.dao.support.DaoSupport |
|---|
logger |
| Constructor Summary | |
|---|---|
HibernateGroupManager(RepositoryIdentifier identifier,
HibernateRepository repository,
UserManager userManager,
ExternalEntityDAO externalEntityDao)
|
|
| Method Summary | |
|---|---|
void |
addMembership(Group group,
User user)
Adds the user to the specified group. |
Group |
createGroup(String groupname)
Create a new group with the specified name. |
protected Collection<Group> |
getAllGroupsForUser(User user)
|
protected ExternalEntity |
getCorrespondingExternalEntity(User user)
|
Pager<String> |
getExternalMemberNames(Group group)
Retrieves the names of those members of the specified group which are stored in another repository. |
DefaultHibernateGroup |
getGroup(Group group)
|
DefaultHibernateGroup |
getGroup(String groupname)
Retrieves the group with the given name. |
Pager<Group> |
getGroups()
Retrieves all groups in this repository. |
Pager<Group> |
getGroups(User user)
Retrieves the groups to which the given user belongs. |
RepositoryIdentifier |
getIdentifier()
|
Pager<String> |
getLocalMemberNames(Group group)
Retrieves the names of those members of the specified group which are also stored in this repository. |
Pager<User> |
getLocalMembers(Group group)
|
Pager<String> |
getMemberNames(Group group)
Retrieves the names of all members of the specified group. |
RepositoryIdentifier |
getRepository(Entity entity)
|
List<Group> |
getWritableGroups()
Gets all editable groups. |
protected boolean |
hasExternalMembership(DefaultHibernateGroup defGroup,
User user)
|
protected boolean |
hasLocalMembership(DefaultHibernateGroup defGroup,
DefaultHibernateUser defUser)
|
boolean |
hasMembership(Group group,
User user)
Returns true if the user is a member of the specified group. |
boolean |
isCreative()
Used to detemine whether an entity can be added (eg, can call UserManager.createUser(String) or
GroupManager.createGroup(String) |
boolean |
isReadOnly(Group group)
Returns true if the specified group and membership of the
specified group cannot be modified in the repository. |
protected boolean |
isUserExternal(User user)
for the time being, lets define an internal user as a hibernate user. |
void |
removeGroup(Group group)
Removes the specified group, if it is present. |
void |
removeMembership(Group group,
User user)
Removes the user from the specified group. |
boolean |
supportsExternalMembership()
Returns true if the repository supports users in other
repositories being members of groups in this repository. |
protected void |
validateGroup(Group group)
|
protected void |
validateGroupAndUser(Group group,
User user)
|
| Methods inherited from class org.springframework.orm.hibernate.support.HibernateDaoSupport |
|---|
checkDaoConfig, convertHibernateAccessException, createHibernateTemplate, getHibernateTemplate, getSession, getSession, getSessionFactory, releaseSession, setHibernateTemplate, setSessionFactory |
| Methods inherited from class org.springframework.dao.support.DaoSupport |
|---|
afterPropertiesSet, initDao |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String GROUPNAME_FIELD
public static final String GROUPID_FIELD
public static final String ENTITYID_FIELD
public static final String EXTERNAL_ENTITY_NAME_FIELD
protected final HibernateRepository repository
protected final UserManager userManager
protected final ExternalEntityDAO externalEntityDao
| Constructor Detail |
|---|
public HibernateGroupManager(RepositoryIdentifier identifier,
HibernateRepository repository,
UserManager userManager,
ExternalEntityDAO externalEntityDao)
| Method Detail |
|---|
public Pager<Group> getGroups()
throws EntityException
GroupManager
getGroups in interface GroupManagerPager containing a Group for each group managed
by the repository. An empty pager will be returned if the repository does
not contain any groups.
EntityExceptionpublic List<Group> getWritableGroups()
GroupManager
getWritableGroups in interface GroupManagerGroups that can be edited.
public Pager<Group> getGroups(User user)
throws EntityException
GroupManager
getGroups in interface GroupManagerPager containing a Group for each group the user
belongs to. An empty pager will be returned if the user does not belong to
any groups that this manager knows about.
EntityException
protected Collection<Group> getAllGroupsForUser(User user)
throws RepositoryException
RepositoryExceptionprotected boolean isUserExternal(User user)
public Pager<String> getMemberNames(Group group)
throws EntityException
GroupManagerCollator.getInstance().
getMemberNames in interface GroupManagerPager instance which can hold User and ExternalEntity objects.
EntityExceptionprotected void validateGroup(Group group)
public Pager<String> getLocalMemberNames(Group group)
throws EntityException
GroupManagerCollator.getInstance().
If GroupManager.supportsExternalMembership() returns false, this
call is equivalent to GroupManager.getMemberNames(Group).
getLocalMemberNames in interface GroupManagerPager containing a String with the name of each
member of the group which is stored in the same repository. An empty pager
will be returned if the group has no local members.
EntityException
public Pager<User> getLocalMembers(Group group)
throws RepositoryException
RepositoryException
public Pager<String> getExternalMemberNames(Group group)
throws EntityException
GroupManagerCollator.getInstance().
If GroupManager.supportsExternalMembership() returns false, this
method throws UnsupportedOperationException.
getExternalMemberNames in interface GroupManagerPager containing a String with the name of each
member of the group which is stored in a different repository. An empty pager
will be returned if the group has no external members.
EntityException
public DefaultHibernateGroup getGroup(Group group)
throws EntityException
EntityException
public DefaultHibernateGroup getGroup(String groupname)
throws EntityException
GroupManagernull if the
group does not exist in this repository.
getGroup in interface GroupManagerGroup or null if the group does not exist.
EntityException
public Group createGroup(String groupname)
throws EntityException
GroupManager
createGroup in interface GroupManagerDuplicateEntityException - if a group with the provided name already exists.
EntityException - if the Group could not be created.
public void removeGroup(Group group)
throws EntityException
removeGroup in interface GroupManagerEntityException - - representing the exception which prohibited removal
public void addMembership(Group group,
User user)
throws EntityException
GroupManagerGroupManager.supportsExternalMembership()
returns true, the user will be added as an external user.
addMembership in interface GroupManagerEntityException
protected ExternalEntity getCorrespondingExternalEntity(User user)
throws RepositoryException
RepositoryException
public boolean hasMembership(Group group,
User user)
throws EntityException
GroupManagerGroupManager.supportsExternalMembership()
returns true, external members will be checked as well.
If the group is not handled by this manager, returns false.
hasMembership in interface GroupManagerEntityException
protected void validateGroupAndUser(Group group,
User user)
throws EntityException
EntityException
protected boolean hasExternalMembership(DefaultHibernateGroup defGroup,
User user)
throws EntityException
EntityException
protected boolean hasLocalMembership(DefaultHibernateGroup defGroup,
DefaultHibernateUser defUser)
throws EntityException
EntityException
public void removeMembership(Group group,
User user)
throws EntityException
GroupManager
removeMembership in interface GroupManagerEntityException - if the membership could not be removed.
public boolean isReadOnly(Group group)
throws EntityException
GroupManagertrue if the specified group and membership of the
specified group cannot be modified in the repository.
If this returns true, invoking methods which attempt to
modify the group or membership of the group will fail with
UnsupportedOperationException.
isReadOnly in interface GroupManagerEntityException
public boolean supportsExternalMembership()
throws EntityException
GroupManagertrue if the repository supports users in other
repositories being members of groups in this repository.
Typically this is true of an application-specific Hibernate repository, but
not of a company's LDAP server. It is designed to allow the LDAP users to
be members of the application's groups for flexible application-level
security.
supportsExternalMembership in interface GroupManagerEntityExceptionpublic RepositoryIdentifier getIdentifier()
getIdentifier in interface EntityManagerRepositoryIdentifier which is managed by this instance.
public RepositoryIdentifier getRepository(Entity entity)
throws EntityException
getRepository in interface EntityManagerRepositoryIdentifier of the repository in which the entity is stored, or null
if the entity cannot be found.
EntityException - if the entity cannot be found, or trying to retrieve it results in an errorpublic boolean isCreative()
UserManager.createUser(String) or
GroupManager.createGroup(String)
isCreative in interface EntityManagerEntity objects can be created by this manager, or false to indicate
not.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||