/** * Creates a group if it does not exist, removes all its members otherwise . * * @param definition The definition of the group. * @see * org.esco.dynamicgroups.dao.grouper.IGroupsDAOService#resetGroupMembers(DynamicGroupDefinition) */ public void resetGroupMembers(final DynamicGroupDefinition definition) { GrouperSession session = null; try { session = GrouperSession.start(SubjectFinder.findRootSubject(), false); GrouperSession.callbackGrouperSession( session, new ResetGroupMembersCallback(this, definition.getGroupUUID())); } catch (SessionException e) { LOGGER.error(e, e); } finally { GrouperSession.stopQuietly(session); } }
/** * @param action is the action on the assignment (null means default action) * @param attributeDefName * @param assign true to assign, false to unassign * @param attributeAssignDelegateOptions if there are more options, null if not * @return the result including if added or already there */ public AttributeAssignResult delegateAttribute( final String action, final AttributeDefName attributeDefName, final boolean assign, final AttributeAssignDelegateOptions attributeAssignDelegateOptions) { AttributeDef attributeDef = attributeDefName.getAttributeDef(); if (attributeDef.isMultiAssignable()) { throw new RuntimeException( "This attribute must not be multi-assignable to call " + "this method, use the multi-assign methods: " + attributeDefName.getName()); } this.assertCanDelegateAttributeDefName(action, attributeDefName); if (attributeAssignDelegateOptions != null && attributeAssignDelegateOptions.isAssignAttributeAssignDelegatable()) { if (attributeAssignDelegateOptions.getAttributeAssignDelegatable() == AttributeAssignDelegatable.GRANT || attributeAssignDelegateOptions.getAttributeAssignDelegatable() == AttributeAssignDelegatable.TRUE) { this.assertCanGrantAttributeDefName(action, attributeDefName); } } AttributeAssignResult attributeAssignResult = (AttributeAssignResult) GrouperSession.callbackGrouperSession( GrouperSession.staticGrouperSession().internal_getRootSession(), new GrouperSessionHandler() { public Object callback(GrouperSession grouperSession) throws GrouperSessionException { if (assign) { // do the same thing that an assign would do // do this as root since the user who can delegate might not be able to // assign... AttributeAssignResult attributeAssignResult2 = AttributeAssignBaseDelegate.this.internal_assignAttributeHelper( action, attributeDefName, false, null, null); if (attributeAssignDelegateOptions != null) { AttributeAssign attributeAssign = attributeAssignResult2.getAttributeAssign(); if (attributeAssignDelegateOptions.isAssignAttributeAssignDelegatable()) { attributeAssign.setAttributeAssignDelegatable( attributeAssignDelegateOptions.getAttributeAssignDelegatable()); } if (attributeAssignDelegateOptions.isAssignDisabledDate()) { attributeAssign.setDisabledTime( attributeAssignDelegateOptions.getDisabledTime()); } if (attributeAssignDelegateOptions.isAssignEnabledDate()) { attributeAssign.setDisabledTime( attributeAssignDelegateOptions.getEnabledTime()); } attributeAssign.saveOrUpdate(true); } return attributeAssignResult2; } return AttributeAssignBaseDelegate.this.removeAttributeHelper( action, attributeDefName, false); } }); return attributeAssignResult; }