Skip to content
Snippets Groups Projects
Commit dea40303 authored by Alinga Yeung's avatar Alinga Yeung
Browse files

Story ac2 rework. We now expose getUserGroups() in GroupPersistence instead of in UserPersistence.

parent b6be3715
No related branches found
No related tags found
No related merge requests found
......@@ -72,6 +72,8 @@ import java.security.AccessControlException;
import java.security.Principal;
import java.util.Collection;
import com.unboundid.ldap.sdk.DN;
import ca.nrc.cadc.ac.Group;
import ca.nrc.cadc.ac.GroupAlreadyExistsException;
import ca.nrc.cadc.ac.GroupNotFoundException;
......@@ -106,6 +108,24 @@ public abstract interface GroupPersistence<T extends Principal>
throws GroupNotFoundException, TransientException,
AccessControlException;
/**
* Get all groups the user, specified by userID, belongs to.
*
* @param userID The userID.
* @param isAdmin return only admin Groups when true, else return non-admin
* Groups.
*
* @return Collection of group DN.
*
* @throws UserNotFoundException when the user is not found.
* @throws TransientException If an temporary, unexpected problem occurred.
* @throws AccessControlException If the operation is not permitted.
*/
Collection<DN> getUserGroups(T userID, boolean isAdmin)
throws UserNotFoundException, TransientException,
AccessControlException;
/**
* Creates the group.
*
......
......@@ -70,14 +70,11 @@ package ca.nrc.cadc.ac.server;
import java.security.AccessControlException;
import java.security.Principal;
import java.util.Collection;
import java.util.Map;
import ca.nrc.cadc.ac.*;
import ca.nrc.cadc.net.TransientException;
import com.unboundid.ldap.sdk.DN;
public interface UserPersistence<T extends Principal>
{
......@@ -179,23 +176,6 @@ public interface UserPersistence<T extends Principal>
throws UserNotFoundException, TransientException,
AccessControlException;
/**
* Get all groups the user specified by userID belongs to.
*
* @param userID The userID.
* @param isAdmin return only admin Groups when true, else return non-admin
* Groups.
*
* @return Collection of group DN.
*
* @throws UserNotFoundException when the user is not found.
* @throws TransientException If an temporary, unexpected problem occurred.
* @throws AccessControlException If the operation is not permitted.
*/
Collection<DN> getUserGroups(T userID, boolean isAdmin)
throws UserNotFoundException, TransientException,
AccessControlException;
/**
* Check whether the user is a member of the group.
*
......
......@@ -74,6 +74,8 @@ import java.util.Collection;
import org.apache.log4j.Logger;
import com.unboundid.ldap.sdk.DN;
import ca.nrc.cadc.ac.Group;
import ca.nrc.cadc.ac.GroupAlreadyExistsException;
import ca.nrc.cadc.ac.GroupNotFoundException;
......@@ -144,6 +146,14 @@ public class LdapGroupPersistence<T extends Principal>
}
}
}
public Collection<DN> getUserGroups(T userID, boolean isAdmin)
throws UserNotFoundException, TransientException,
AccessControlException
{
return (new LdapUserPersistence<T>()).getUserGroups(userID, isAdmin);
}
public Group addGroup(Group group)
throws GroupAlreadyExistsException, TransientException,
......
......@@ -693,7 +693,8 @@ public class LdapUserDAO<T extends Principal> extends LdapDAO
}
/**
* Get all groups the user specified by userID belongs to.
* Get all groups the user specified by userID belongs to. This method is created
* to provide optimization for the LDAP server.
*
* @param userID The userID.
* @param isAdmin
......@@ -702,7 +703,7 @@ public class LdapUserDAO<T extends Principal> extends LdapDAO
* @throws TransientException If an temporary, unexpected problem occurred., e.getMessage(
* @throws AccessControlException If the operation is not permitted.
*/
public Collection<DN> getUserGroups(final T userID, final boolean isAdmin)
protected Collection<DN> getUserGroups(final T userID, final boolean isAdmin)
throws UserNotFoundException, TransientException,
AccessControlException
{
......
......@@ -319,7 +319,8 @@ public class LdapUserPersistence<T extends Principal>
}
/**
* Get all groups the user specified by userID belongs to.
* Get all groups the user specified by userID belongs to. This method is created
* to provide optimization for the LDAP server.
*
* @param userID The userID.
* @param isAdmin return only admin Groups when true, else return non-admin
......@@ -331,7 +332,7 @@ public class LdapUserPersistence<T extends Principal>
* @throws TransientException If an temporary, unexpected problem occurred.
* @throws AccessControlException If the operation is not permitted.
*/
public Collection<DN> getUserGroups(T userID, boolean isAdmin)
protected Collection<DN> getUserGroups(T userID, boolean isAdmin)
throws UserNotFoundException, TransientException, AccessControlException
{
LdapUserDAO<T> userDAO = null;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment