Package edu.internet2.middleware.grouper
Class StemSave
java.lang.Object
edu.internet2.middleware.grouper.StemSave
Use this class to insert or update a stem
Sample call
StemSave stemSave = new StemSave(grouperSession).assignName("test") .assignCreateParentStemsIfNotExist(true).assignDisplayName("test") .assignDescription("testDescription"); Stem stem = stemSave.save(); System.out.println(stemSave.getSaveResultType()); // DELETE, INSERT, NO_CHANGE, or UPDATE
Sample to delete
new StemSave(grouperSession).assignUuid(stem.getId()).assignSaveMode(SaveMode.DELETE).save();
To edit just one field (the description) for existing stem
new StemSave(grouperSession).assignUuid(stem.getId()) .assignDisplayExtension("test1") .assignAlternateName("newAlternateName") .assignReplaceAllSettings(false).save();
Sample to delete folders in a folder, and be failsafe (log on which ones error)
String parentStemName = "test:poc"; GrouperSession grouperSession = GrouperSession.startRootSession(); Stem parentStem = StemFinder.findByName(grouperSession, parentStemName, true); for (Stem stem : parentStem.getChildStems()) { try { new StemSave(grouperSession).assignUuid(stem.getId()).assignSaveMode(SaveMode.DELETE).save(); } catch (Exception e) { e.printStackTrace(); } }
-
Constructor Summary
ConstructorDescriptionStemSave()
create a new stem saveStemSave
(GrouperSession theGrouperSession) create a new stem save -
Method Summary
Modifier and TypeMethodDescriptionassignAlternateName
(String theAlternateName) assign alternateNameassignCreateParentStemsIfNotExist
(boolean theCreateParentStemsIfNotExist) assign create parents if not existassignDescription
(String theDescription) assign descriptionassignDisplayExtension
(String theDisplayExtension) display extensionassignDisplayName
(String theDisplayName) assignIdIndex
(Long theIdIndex) assign id_indexassignName
(String name1) nameassignReplaceAllSettings
(boolean theReplaceAllSettings) replace all existing settings.assignRunAsRoot
(boolean runAsRoot) set this to true to run as a root sessionassignSaveMode
(SaveMode theSaveMode) asssign save modeassignSetAlternateNameIfRename
(boolean theSetAlternateNameIfRename) whether an alternate name should automatically be assigned if doing a renameassignStemNameToEdit
(String theStemNameToEdit) stem name to editassignUuid
(String theUuid) uuidgetName()
new stem nameget the save typestem name to edit if renamingsave()
create or update a stem.Deprecated.
-
Constructor Details
-
StemSave
public StemSave()create a new stem save- Parameters:
theGrouperSession
-
-
StemSave
create a new stem save- Parameters:
theGrouperSession
-
-
-
Method Details
-
getName
new stem name- Returns:
-
getStemNameToEdit
stem name to edit if renaming- Returns:
-
assignReplaceAllSettings
replace all existing settings. defaults to true.- Returns:
- this for chaining
-
assignRunAsRoot
set this to true to run as a root session- Parameters:
runAsRoot
-- Returns:
-
assignIdIndex
assign id_index- Parameters:
theIdIndex
-- Returns:
- this for chaining
-
assignStemNameToEdit
stem name to edit- Parameters:
theStemNameToEdit
-- Returns:
- the stem name to edit
-
assignUuid
uuid- Parameters:
theUuid
-- Returns:
- uuid
-
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
assign alternateName- 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
-
assignSaveMode
asssign save mode- Parameters:
theSaveMode
-- Returns:
- this for chaining
-
assignCreateParentStemsIfNotExist
assign create parents if not exist- Parameters:
theCreateParentStemsIfNotExist
-- Returns:
- this for chaining
-
getSaveResultType
get the save type- Returns:
- save type
-
saveUnchecked
Deprecated.create or update a stem. Note this will not move a stem at this time (might in future) This is a static method since setters to Stem objects persist to the DB Steps: 1. Find the stem by stemNameToEdit (if not there then its an insert) 2. Internally set all the fields of the stem (no need to reset if already the same) 3. Store the stem (insert or update) if needed 4. Return the stem object This occurs in a transaction, so if a part of it fails, it rolls back, and potentially rolls back outer transactions too
- Returns:
- the stem saved
-
save
public Stem save() throws StemNotFoundException, InsufficientPrivilegeException, StemAddException, StemModifyExceptioncreate or update a stem. Note this will not move a stem at this time (might in future) This is a static method since setters to Stem objects persist to the DB Steps: 1. Find the stem by stemNameToEdit (if not there then its an insert) 2. Internally set all the fields of the stem (no need to reset if already the same) 3. Store the stem (insert or update) if needed 4. Return the stem object This occurs in a transaction, so if a part of it fails, it rolls back, and potentially rolls back outer transactions too
- Returns:
- the stem that was updated or created
- Throws:
StemNotFoundException
InsufficientPrivilegeException
StemAddException
StemModifyException
-
assignDisplayName
- Parameters:
theDisplayName
-- Returns:
- this for chaining
-