Package edu.internet2.middleware.grouper
Class GroupSave
java.lang.Object
edu.internet2.middleware.grouper.GroupSave
The GroupSave class is the recommended and support way to insert/update/delete a group. This class was introduced in v1.4+ , some options added later.
Sample call
Group groupAbc = new GroupSave().assignName("a:b:c").assignCreateParentStemsIfNotExist(true).save();
Sample using GroupSave results
GroupSave groupSave = new GroupSave().assignName("a:b:c").assignCreateParentStemsIfNotExist(true); Group groupAbc = groupSave.save(); System.out.println(groupSave.getSaveResultType()); // DELETE, INSERT, NO_CHANGE, or UPDATE
Sample to delete
new GroupSave().assignName("a:b:c").assignSaveMode("DELETE").save();
To edit just one field (the description) for existing group a:b:c
new GroupSave().assignName("a:b:c").assignDescription("new description").assignReplaceAllSettings(false).save();
To edit just one field (the idIndex) for existing group a:b:c
Note, that new idIndex cant be in use by another group (query grouper_groups_v for the id_index col) and should not be above the current pointer (which you can adjust in the table grouper_table_index)
new GroupSave().assignName("a:b:c").assignIdIndex(12345).assignReplaceAllSettings(false).save();
Rename a group to same parent folder
new GroupSave().assignGroupNameToEdit("folder:oldName").assignName("folder:newName").assignReplaceAllSettings(false).save();
-
Field Summary
-
Constructor Summary
ConstructorDescriptioncreate a new group saveGroupSave
(GrouperSession theGrouperSession) create a new group save -
Method Summary
Modifier and TypeMethodDescriptionassignAlternateName
(String theAlternateName) Will save or remove an alternate name for the group e.g.assignCreateParentStemsIfNotExist
(boolean theCreateParentStemsIfNotExist) assign create parents if not existassignDescription
(String theDescription) assign descriptionassignDisabledTime
(Long theDisabledTime) if there is a date here, and it is in the past, this group is disabledassignDisabledTimestamp
(Timestamp theDisabledTimestamp) if there is a date here, and it is in the past, this group is disabledassignDisplayExtension
(String theDisplayExtension) display extensionassignDisplayName
(String theDisplayName) assignEnabledTime
(Long theEnabledTimeDb) if there is a date here, and it is in the future, this group is disabled until that timeassignEnabledTimestamp
(Timestamp theEnabledTimestamp) if there is a date here, and it is in the future, this group is disabled until that timeassignGroupNameToEdit
(String theGroupNameToEdit) group name to editassignIdIndex
(Long theIdIndex) assign id_indexassignName
(String name1) nameassignPrivAllAdmin
(boolean thePrivAllAdmin) assign priv admin to be different than the defaults for grouperAllassignPrivAllAttrRead
(boolean thePrivAllAttrRead) assign priv attr read to be different than the defaults for grouperAllassignPrivAllAttrUpdate
(boolean thePrivAllAttrUpdate) assign priv attr update to be different than the defaults for grouperAllassignPrivAllOptin
(boolean thePrivAllOptin) assign priv optin to be different than the defaults for grouperAllassignPrivAllOptout
(boolean thePrivAllOptout) assign priv optout to be different than the defaults for grouperAllassignPrivAllRead
(boolean thePrivAllRead) assign priv read to be different than the defaults for grouperAllassignPrivAllUpdate
(boolean thePrivAllUpdate) assign priv update to be different than the defaults for grouperAllassignPrivAllView
(boolean thePrivAllView) assign priv view to be different than the defaults for grouperAllassignReplaceAllSettings
(boolean theReplaceAllSettings) if you want to replace all the settings for the object, send true (that's the default).assignRunAsRoot
(boolean runAsRoot) set this to true to run as a root sessionassignSaveMode
(SaveMode theSaveMode) assign save modeassignSaveMode
(String theSaveMode) assign save modeassignSetAlternateNameIfRename
(boolean theSetAlternateNameIfRename) whether an alternate name should automatically be assigned if doing a renameassignTypeOfGroup
(TypeOfGroup theTypeOfGroup) assign save modeassignTypeOfGroup
(String theTypeOfGroup) assign save modeassignUuid
(String theUuid) uuidgroup name to edit if there is a movegetName()
group name of the group (eventual name if there is a move)get the save typesave()
create or update a group.Deprecated.use save() instead
-
Field Details
-
PERFORMANCE_LOG_LABEL
use this for performance log label- See Also:
-
-
Constructor Details
-
GroupSave
public GroupSave()create a new group save- Parameters:
theGrouperSession
-
-
GroupSave
create a new group save- Parameters:
theGrouperSession
-
-
-
Method Details
-
getGroupNameToEdit
group name to edit if there is a move- Returns:
-
getName
group name of the group (eventual name if there is a move)- Returns:
-
assignRunAsRoot
set this to true to run as a root session- Parameters:
runAsRoot
-- Returns:
-
assignPrivAllAdmin
assign priv admin to be different than the defaults for grouperAll- Parameters:
thePrivAllAdmin
-- Returns:
- this for chaining
-
assignPrivAllView
assign priv view to be different than the defaults for grouperAll- Parameters:
thePrivAllView
-- Returns:
- this for chaining
-
assignPrivAllRead
assign priv read to be different than the defaults for grouperAll- Parameters:
thePrivAllRead
-- Returns:
- this for chaining
-
assignPrivAllUpdate
assign priv update to be different than the defaults for grouperAll- Parameters:
thePrivAllUpdate
-- Returns:
- this for chaining
-
assignPrivAllOptin
assign priv optin to be different than the defaults for grouperAll- Parameters:
thePrivAllOptin
-- Returns:
- this for chaining
-
assignPrivAllOptout
assign priv optout to be different than the defaults for grouperAll- Parameters:
thePrivAllOptout
-- Returns:
- this for chaining
-
assignPrivAllAttrRead
assign priv attr read to be different than the defaults for grouperAll- Parameters:
thePrivAllAttrRead
-- Returns:
- this for chaining
-
assignPrivAllAttrUpdate
assign priv attr update to be different than the defaults for grouperAll- Parameters:
thePrivAllAttrUpdate
-- Returns:
- this for chaining
-
assignGroupNameToEdit
group name to edit- Parameters:
theGroupNameToEdit
-- Returns:
- the group name to edit
-
assignUuid
uuid- Parameters:
theUuid
-- Returns:
- uuid
-
assignDisplayName
- Parameters:
theDisplayName
-- Returns:
- this for chaining
-
assignName
name- Parameters:
name1
-- Returns:
- name
-
assignDisplayExtension
display extension- Parameters:
theDisplayExtension
-- Returns:
- this for chaining
-
assignDescription
assign description- Parameters:
theDescription
-- Returns:
- this for chaining
-
assignAlternateName
Will save or remove an alternate name for the group e.g.assignAlternateName("x:y:z")
- Parameters:
theAlternateName
-- Returns:
- this for chaining
-
assignSetAlternateNameIfRename
whether an alternate name should automatically be assigned if doing a rename- Parameters:
theSetAlternateNameIfRename
-- Returns:
- this for chaining
-
assignDisabledTime
if there is a date here, and it is in the past, this group is disabled- Parameters:
theDisabledTime
-- Returns:
- this for chaining
-
assignDisabledTimestamp
if there is a date here, and it is in the past, this group is disabled- Parameters:
theDisabledTimestamp
-- Returns:
- this for chaining
-
assignEnabledTime
if there is a date here, and it is in the future, this group is disabled until that time- Parameters:
theEnabledTimeDb
-- Returns:
- this for chaining
-
assignEnabledTimestamp
if there is a date here, and it is in the future, this group is disabled until that time- Parameters:
theEnabledTimestamp
-- Returns:
- this for chaining
-
assignIdIndex
assign id_index- Parameters:
theIdIndex
-- Returns:
- this for chaining
-
assignSaveMode
assign save mode- Parameters:
theSaveMode
-- Returns:
- this for chaining
-
assignSaveMode
assign save mode- Parameters:
theSaveMode
-- Returns:
- this for chaining
-
assignTypeOfGroup
assign save mode- Parameters:
theTypeOfGroup
-- Returns:
- this for chaining
-
assignTypeOfGroup
assign save mode- Parameters:
theTypeOfGroup
-- Returns:
- this for chaining
-
assignCreateParentStemsIfNotExist
assign create parents if not exist- Parameters:
theCreateParentStemsIfNotExist
-- Returns:
- this for chaining
-
getTypeOfGroup
-
getSaveResultType
get the save type- Returns:
- save type
-
saveUnchecked
Deprecated.use save() insteadcreate or update a group. Do not throw checked exceptions, wrap in unchecked Note this will not rename a group at this time (might in future) This is a static method since setters to Group objects persist to the DB Steps: 1. Find the group by groupNameToEdit 2. Internally set all the fields of the stem (no need to reset if already the same) 3. Store the group (insert or update) if needed 4. Return the group object This runs in a tx so that if part of it fails the whole thing fails, and potentially the outer transaction too
- Returns:
- the group
-
save
public Group save() throws StemNotFoundException, InsufficientPrivilegeException, StemAddException, GroupModifyException, GroupNotFoundException, GroupAddExceptioncreate or update a group. Note this will not rename a group at this time (might in future) This is a static method since setters to Group objects persist to the DB Steps: 1. Find the group by groupNameToEdit 2. Internally set all the fields of the stem (no need to reset if already the same) 3. Store the group (insert or update) if needed 4. Return the group object This runs in a tx so that if part of it fails the whole thing fails, and potentially the outer transaction too
- Returns:
- the group
- Throws:
StemNotFoundException
InsufficientPrivilegeException
StemAddException
GroupModifyException
GroupNotFoundException
GroupAddException
-
assignReplaceAllSettings
if you want to replace all the settings for the object, send true (that's the default). If you want to update certain fields, send false.- Returns:
- this for chaining
-