us.openinternet.luge.service
Class GroupFacade

java.lang.Object
  |
  +--us.openinternet.luge.service.LugeFacade
        |
        +--us.openinternet.luge.service.GroupFacade

public class GroupFacade
extends LugeFacade

GroupFacade is used to search, add, delete and modify Groups.


Field Summary
 
Fields inherited from class us.openinternet.luge.service.LugeFacade
grpTransformer, lugeTransformer, personTransformer
 
Constructor Summary
GroupFacade(LugeFacade lf)
           
GroupFacade(LugeTransformer lt)
           
GroupFacade(java.lang.String cn, java.lang.String key)
          Use this constructor to establish your connection to the ldap server.
 
Method Summary
 boolean addAttributeToGroup(java.lang.String grpCN, java.lang.String attr, java.util.ArrayList values)
          This method will add an attribute with mutliple values to the group.
 boolean addAttributeToGroup(java.lang.String grpCN, java.lang.String attr, java.lang.String value)
          This method will add an attribute with single value to the group.
 boolean addGroup(GroupVO gvo)
          This method adds a GroupOfNames object with the attributes supplied in the GroupVO object.
 boolean addGroup(java.lang.String grpCN)
          This method adds a GroupOfNames object .
 boolean addMemberAndAttribute(java.lang.String grpCN, java.lang.String uid, java.lang.String attrName, java.lang.String attrValue)
          This method is a shortcut if you want to add a Person to a Group and set a related attribute in the Person object.
 GroupVO addMembersAndAttributesBulk(java.lang.String grpCN, java.util.ArrayList uids, java.lang.String attrName, java.lang.String attrValue)
          This method adds an ArrayList of People to the Group, and sets the given attribute name for each user.
 GroupVO addPeopleToGroup(java.util.ArrayList uids, java.lang.String grpCN)
          This method is the same as addMemberToGroup method except it adds multiple persons.
 boolean addPersonToGroup(java.lang.String uid, java.lang.String grpCN)
          Same as addMemberToGroup, added for semantic consistency.
 boolean deleteAttributeFromGroup(java.lang.String grpCN, java.lang.String attr)
          This method allows all values of an attribute to be deleted.
 boolean deleteAttributeValueFromGroup(java.lang.String grpCN, java.lang.String attr, java.lang.String val)
          This method allows a particular value to be deleted from an attribute.
 boolean deleteGroup(java.lang.String grpCN)
          This method deletes a group object.
protected  void finalize()
           
 java.util.ArrayList getAllGroupNames()
          This method returns the names of the groups your application has permission to see.
 java.util.ArrayList getGroupAttributeMultiValue(java.lang.String grpCn, java.lang.String attr)
          This method is intended to be used as a quick method for retrieving a multi-valued attribute.
 java.lang.String getGroupAttributeSingleValue(java.lang.String grpCn, java.lang.String attr)
          This method is provided as a convenience.
 java.util.ArrayList getMembers(java.lang.String grpCN)
          This method returns an ArrayList all the members(uids) for the specified group.
 java.util.ArrayList getMemberships(java.lang.String uid)
          This method returns an ArrayList of the names of the groups a user belongs to that your application has permission to see.
 boolean groupExists(java.lang.String grpCN)
          This method verifies that a group exists in the directory.
 GroupVO groupLookup(java.lang.String groupCN)
          Returns a Hashtable of actual ldap attribute names as the keys and String[] as the values.
 java.util.Hashtable groupLookup(java.lang.String grpCn, java.lang.String[] attrs)
          This method returns specific attributes of a group in a Hashtable with the actual ldap attribute names as keys and the values returned as String arrays to accomodate multi-valued attributes.
 boolean isMember(java.lang.String uid, java.lang.String grpCN)
          This method verifies if the user is a member of the specified group.
 boolean modifyGroup(java.lang.String grpCN, GroupVO gvo, boolean AppendAttributes)
          This method allows bulk attribute modifications.
 boolean removeMemberAndAttribute(java.lang.String grpCN, java.lang.String uid, java.lang.String attrName, java.lang.String attrValue)
          This method is a shortcut if you want to remove a Person from a Group and delete a related attribute in the Person object.
 GroupVO removeMembersAndAttributesBulk(java.lang.String grpCN, java.util.ArrayList uids, java.lang.String attrName, java.lang.String attrValue)
          This method removes an ArrayList of People from a Group, and removes the given attribute for each user.
 GroupVO removePeopleFromGroup(java.util.ArrayList uids, java.lang.String grpCN)
          This method is the same as removePersonFromGroup method except it removes multiple Persons .
 boolean removePersonFromGroup(java.lang.String uid, java.lang.String grpCN)
          This method removes the specified Person from the specified Group.
 boolean renameGroup(java.lang.String oldName, java.lang.String newName)
          This method changes the Group Name.
 boolean replaceAttributeForGroup(java.lang.String grpCN, java.lang.String attr, java.util.ArrayList values)
          This method is the same as replaceAttributeForGroup except it accepts an ArrayList of values to accomodate multi-valued attributes.If you call this method on attr "cn", this method calls renameGroup--but make sure your ArrayList only has one value or LugeException will be thrown.
 boolean replaceAttributeForGroup(java.lang.String grpCN, java.lang.String attr, java.lang.String value)
          This method replaces an attribute.
 boolean replaceAttributeForGroup(java.lang.String grpCN, java.lang.String attr, java.lang.String oldValue, java.lang.String newValue)
          This method allows a single value of a multi-vauled attribute to be replaced.
 SearchVO searchGroups(SearchVO svo)
          The preferred method to search the directory, see SearchVO documentation for setting serach criteria and extracting the results.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GroupFacade

public GroupFacade(java.lang.String cn,
                   java.lang.String key)
            throws LugeException
Use this constructor to establish your connection to the ldap server.

Parameters:
cn - - This is an id assigned to your application
key - - Each id is also assigned a key for authentication purposes. The key is not the LDAP server password.
Throws:
LugeException

GroupFacade

public GroupFacade(LugeTransformer lt)
            throws LugeException

GroupFacade

public GroupFacade(LugeFacade lf)
            throws LugeException
Method Detail

addGroup

public boolean addGroup(java.lang.String grpCN)
                 throws LugeException
This method adds a GroupOfNames object .

Parameters:
grpCN - The unique name of the group.
Returns:
true if successful else throws LugeException
LugeException

addGroup

public boolean addGroup(GroupVO gvo)
                 throws LugeException
This method adds a GroupOfNames object with the attributes supplied in the GroupVO object. It is not recommended that you add members to the Group here (ie, specifying attribute "member". It is better to first add the group, then add members. However, if you do chose to add members here, watch the result. A false result indicates that not all the members were added.

GroupVO gvo = new GroupVO();
gvo.setGroupName("myGroup");
gvo.setDescription("This is the Group of people authorized to access my application.");
ArrayList categories = new ArrayList();
categories.add("Marketing");
categories.add("Sales");
categories.add("Finance");
gvo.setAttributeValues("businessCategory", categories);
gvo.addValueToAttribute("businessCategory", "One_More_Category");
try{
          GroupFacade gf = new AdminFacade("myApp", "myKey");
          gf.addGroup(gvo);
} catch (LugeException lugeEx) {
          lugeEx.printStackTrace();
}

LugeException

deleteGroup

public boolean deleteGroup(java.lang.String grpCN)
                    throws LugeException
This method deletes a group object.

Parameters:
grpCN - - the unique name of the group.
LugeException

addPersonToGroup

public boolean addPersonToGroup(java.lang.String uid,
                                java.lang.String grpCN)
                         throws LugeException
Same as addMemberToGroup, added for semantic consistency.

Parameters:
uid - The userID of the person to be added.
grpCN - The name of the group.
Returns:
TRUE if successful, else throws LugeException
LugeException

addPeopleToGroup

public GroupVO addPeopleToGroup(java.util.ArrayList uids,
                                java.lang.String grpCN)
                         throws LugeException
This method is the same as addMemberToGroup method except it adds multiple persons.

Parameters:
uids - ArrayList of userIDs of persons to be added.
grpCN - The name of the group.
Returns:
Group Value Object with the users successfully added, redundant members, non-existant people.
LugeException

removePersonFromGroup

public boolean removePersonFromGroup(java.lang.String uid,
                                     java.lang.String grpCN)
                              throws LugeException
This method removes the specified Person from the specified Group.

Parameters:
uid - The userID of the person to be removed.
grpCN - The name of the group.
Returns:
TRUE if user removed from group successfully else throws LugeException
LugeException

removePeopleFromGroup

public GroupVO removePeopleFromGroup(java.util.ArrayList uids,
                                     java.lang.String grpCN)
                              throws LugeException
This method is the same as removePersonFromGroup method except it removes multiple Persons .

Parameters:
uids - ArrayList of userIDs of persons to be removed.
grpCN - The name of the group.
Returns:
GroupVO object with the users successfully removed, already not members, nonexistant people, etc. See the GroupVO javadoc for method information.
LugeException

renameGroup

public boolean renameGroup(java.lang.String oldName,
                           java.lang.String newName)
                    throws LugeException
This method changes the Group Name. In ldap, this is a more complicated than changing a typical attribute, because it involves changing how the object itself is referenced.

Returns:
true if it worked else throws LugeException
LugeException

addAttributeToGroup

public boolean addAttributeToGroup(java.lang.String grpCN,
                                   java.lang.String attr,
                                   java.lang.String value)
                            throws LugeException
This method will add an attribute with single value to the group. Don't try to add another cn or an error will be thrown. Groups are only allowed to have one name.

Parameters:
grpCN - The name of the group.
attr - The valid LDAP attribute name.
value - The value to be added to the attribute.
LugeException

addAttributeToGroup

public boolean addAttributeToGroup(java.lang.String grpCN,
                                   java.lang.String attr,
                                   java.util.ArrayList values)
                            throws LugeException
This method will add an attribute with mutliple values to the group. Don't try to add another cn or an error will be thrown. Groups are only allowed to have one name.

Parameters:
grpCN - The name of the group.
attr - The valid LDAP attribute name.
values - An ArrayList of values to be added to the attribute.
LugeException

replaceAttributeForGroup

public boolean replaceAttributeForGroup(java.lang.String grpCN,
                                        java.lang.String attr,
                                        java.lang.String value)
                                 throws LugeException
This method replaces an attribute. If the attribute does not exist, it will create a new attribute. If the attribute already exists, the old value will be deleted and replaced with the new value.

Parameters:
grpCN - The ldap cn of the group
attr - The valid LDAP attribute name.
value - The value of the attribute.
LugeException

replaceAttributeForGroup

public boolean replaceAttributeForGroup(java.lang.String grpCN,
                                        java.lang.String attr,
                                        java.util.ArrayList values)
                                 throws LugeException
This method is the same as replaceAttributeForGroup except it accepts an ArrayList of values to accomodate multi-valued attributes.If you call this method on attr "cn", this method calls renameGroup--but make sure your ArrayList only has one value or LugeException will be thrown.

Parameters:
grpCN - The ldap cn of the group
attr - The valid LDAP attribute name.
values - An ArrayList of values of the attribute.
LugeException

replaceAttributeForGroup

public boolean replaceAttributeForGroup(java.lang.String grpCN,
                                        java.lang.String attr,
                                        java.lang.String oldValue,
                                        java.lang.String newValue)
                                 throws LugeException
This method allows a single value of a multi-vauled attribute to be replaced. If you call this method on attr "cn", this method calls renameGroup.

Parameters:
grpCN - The ldap cn of the group
attr - The valid LDAP attribute name.
oldValue - The current value of the attribute.
newValue - The new value of the attribute.
LugeException

deleteAttributeFromGroup

public boolean deleteAttributeFromGroup(java.lang.String grpCN,
                                        java.lang.String attr)
                                 throws LugeException
This method allows all values of an attribute to be deleted. Note, you cannot delete the Group name (cn attribute).

Parameters:
grpCN - The ldap cn of the group
attr - The valid LDAP attribute name.
LugeException

deleteAttributeValueFromGroup

public boolean deleteAttributeValueFromGroup(java.lang.String grpCN,
                                             java.lang.String attr,
                                             java.lang.String val)
                                      throws LugeException
This method allows a particular value to be deleted from an attribute. Note, you cannot delete the Group name (cn attribute).

Parameters:
grpCN - The ldap cn of the group
attr - The valid LDAP attribute name.
val - The value of the attribute to be deleted.
LugeException

modifyGroup

public boolean modifyGroup(java.lang.String grpCN,
                           GroupVO gvo,
                           boolean AppendAttributes)
                    throws LugeException
This method allows bulk attribute modifications. Use the ValueObject GroupVO to set single and multi-vaule attributes, and then post the GroupVO object to this method. Note: if you set the AppendAttributes boolean parameter to true and any atribute value is already present, a LugeException will be thrown. Best to use false (and replace), or go through and do the modifications one attribute at a time. If you post the "cn" attribute or post the group with a name, renameGroup will be called. Make sure cn is not multivalued because a Group can only have one name.

Parameters:
grpCN - The ldap cn of the group
LugeException

addMemberAndAttribute

public boolean addMemberAndAttribute(java.lang.String grpCN,
                                     java.lang.String uid,
                                     java.lang.String attrName,
                                     java.lang.String attrValue)
                              throws LugeException
This method is a shortcut if you want to add a Person to a Group and set a related attribute in the Person object. Errors are suppressed here. The method simply returns true if both operations worked, and false if both operations didn't work. A false result could indicate that either one or both of the operations failed.

Parameters:
grpCN - - the actual ldap Group name
uid - - the Person's name
attrName - - the actual ldap attribute name
LugeException

removeMemberAndAttribute

public boolean removeMemberAndAttribute(java.lang.String grpCN,
                                        java.lang.String uid,
                                        java.lang.String attrName,
                                        java.lang.String attrValue)
                                 throws LugeException
This method is a shortcut if you want to remove a Person from a Group and delete a related attribute in the Person object. Errors are suppressed here. The method simply returns true if both operations worked, and false if both operations didn't work. A false result could indicate that either one or both of the operations failed.

Parameters:
grpCN - - the actual ldap Group name
uid - - the Person's name
attrName - - the actual ldap attribute name
LugeException

addMembersAndAttributesBulk

public GroupVO addMembersAndAttributesBulk(java.lang.String grpCN,
                                           java.util.ArrayList uids,
                                           java.lang.String attrName,
                                           java.lang.String attrValue)
                                    throws LugeException
This method adds an ArrayList of People to the Group, and sets the given attribute name for each user.

Check the myGroupVO.getOkPeople() for an ArrayList of users successfully added.

If the user is redundant (already a member of this Group) or if the user is nonexistant, this will also be recorded in the GroupVO as with any other Group. In the case of redundant people, this method will still try to add the attribute to the Person. If an error is thrown during the attribute update phase, the username will be recorded in the GroupVO problem_members. If the Person's attribute is updated succesfully, the uid will be listed in myGroupVO.getUpdatedPeople().

Parameters:
grpCN - - the name of the Group
uids - - an ArrayList of uids that correspond to the people to be added to the Group.
attrName - - the actual ldap attribute name to update for each Person entry
attrValue - - the value to be set for each Person
Returns:
GroupVO with the users posted, ok, redundant, non-existant, updated and problem
LugeException

removeMembersAndAttributesBulk

public GroupVO removeMembersAndAttributesBulk(java.lang.String grpCN,
                                              java.util.ArrayList uids,
                                              java.lang.String attrName,
                                              java.lang.String attrValue)
                                       throws LugeException
This method removes an ArrayList of People from a Group, and removes the given attribute for each user.

Check the myGroupVO.getOkPeople() for an ArrayList of users successfully deleted from the Group.

If the user is a non-member (already not a member of this Group) or if the user is nonexistant, this will also be recorded in the GroupVO as with any other Group. In the case of non-members, this method will still try to remove the attribute from the Person entry. If an error is thrown during the attribute update phase, the uid will be recorded in the GroupVO problem_members. If the Person's attribute is removed succesfully, the uid will be listed in myGroupVO.getUpdatedPeople().

Parameters:
grpCN - - the name of the Group
uids - - an ArrayList of uids that correspond to the people to be removed from the Group.
attrName - - the actual ldap attribute name to update for each Person entry
attrValue - - the value to be removed for each Person
Returns:
GroupVO with the users posted, ok, redundant, non-existant, updated and problem
LugeException

groupExists

public boolean groupExists(java.lang.String grpCN)
This method verifies that a group exists in the directory.

Parameters:
grpCN - - The groupName
Returns:
TRUE if group exists, FALSE otherwise.

getMemberships

public java.util.ArrayList getMemberships(java.lang.String uid)
                                   throws LugeException
This method returns an ArrayList of the names of the groups a user belongs to that your application has permission to see. This calls the getGroupsForUser() method.

LugeException

isMember

public boolean isMember(java.lang.String uid,
                        java.lang.String grpCN)
                 throws LugeException
This method verifies if the user is a member of the specified group.

Parameters:
uid - - The userName of the person
grpCN - - The name of the group
Returns:
TRUE if user is a member of the group, FALSE otherwise.
LugeException

searchGroups

public SearchVO searchGroups(SearchVO svo)
                      throws LugeException
The preferred method to search the directory, see SearchVO documentation for setting serach criteria and extracting the results. When you call this method, the group flag is set on the SeachVO object (use mySearchVO.getGroupFlag() to retrieve this attribute). This method also &'s the search filter with (objectclass=groupofnames).

LugeException

getMembers

public java.util.ArrayList getMembers(java.lang.String grpCN)
                               throws LugeException
This method returns an ArrayList all the members(uids) for the specified group.

LugeException

getAllGroupNames

public java.util.ArrayList getAllGroupNames()
                                     throws LugeException
This method returns the names of the groups your application has permission to see.

LugeException

groupLookup

public GroupVO groupLookup(java.lang.String groupCN)
                    throws LugeException
Returns a Hashtable of actual ldap attribute names as the keys and String[] as the values.

Parameters:
groupCN - - The ldap name (cn) of the group
LugeException

groupLookup

public java.util.Hashtable groupLookup(java.lang.String grpCn,
                                       java.lang.String[] attrs)
                                throws LugeException
This method returns specific attributes of a group in a Hashtable with the actual ldap attribute names as keys and the values returned as String arrays to accomodate multi-valued attributes.

Parameters:
grpCn - - The ldap name of the Group
LugeException

getGroupAttributeSingleValue

public java.lang.String getGroupAttributeSingleValue(java.lang.String grpCn,
                                                     java.lang.String attr)
                                              throws LugeException
This method is provided as a convenience. It returns the first value of an attributes of a group. It is intended to be used for attributes that are String and single valued. If the attribute is multi-valued, it will return only one value (chosen at random), so it is recommended that you use the groupLookup(String grpCn, String[] attrs) method. method instead. If the value is not String, or if there is no value for this attribute, this method returns an empty String.

Parameters:
grpCn - - The ldap name of the group
Returns:
value of attribute or empty String.
LugeException

getGroupAttributeMultiValue

public java.util.ArrayList getGroupAttributeMultiValue(java.lang.String grpCn,
                                                       java.lang.String attr)
                                                throws LugeException
This method is intended to be used as a quick method for retrieving a multi-valued attribute.

Parameters:
grpCn - - The ldap name of the group
LugeException

finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class LugeFacade
java.lang.Throwable

Copyright 2003, Michael Schwartz All Rights Reserved.