Skip to content

Instantly share code, notes, and snippets.

View wgthom's full-sized avatar
🙂
copacetic

William G. Thompson, Jr. wgthom

🙂
copacetic
View GitHub Profile
// request is an implicit Portlet object available in view.jsp
long userid = PortalUtil.getUserId(request);
String username = PortalUtil.getUserName(userid,null,"user.login.id");
String password = PortalUtil.getUserPassword(request);
Verifying myself: My Bitcoin username is +wgthom. https://onename.io/wgthom

Keybase proof

I hereby claim:

  • I am wgthom on github.
  • I am wgthom (https://keybase.io/wgthom) on keybase.
  • I have a public key whose fingerprint is BAA4 0099 7EED CA15 A31F 5242 C3EB 61CD 0A65 679E

To claim this, I am signing this object:

/**
* Example change log consumer based on ChangeLogConsumerBaseImpl. ChangeLogConsumerBaseImpl handles
* the mapping of change log event to methods, the processing loop, and exception handling.
*/
public class PrintChangeLogConsumer extends ChangeLogConsumerBaseImpl {
private static final Logger LOG = LoggerFactory.getLogger(PrintChangeLogConsumer.class);
@Override
protected void addGroup(ChangeLogEntry changeLogEntry, String consumerName) {
package edu.internet2.middleware.grouper.changeLog;
import edu.internet2.middleware.grouper.*;
import edu.internet2.middleware.grouper.app.loader.GrouperLoaderConfig;
import edu.internet2.middleware.grouper.attr.AttributeDef;
import edu.internet2.middleware.grouper.attr.AttributeDefName;
import edu.internet2.middleware.grouper.attr.AttributeDefType;
import edu.internet2.middleware.grouper.attr.finder.AttributeDefFinder;
import edu.internet2.middleware.grouper.attr.finder.AttributeDefNameFinder;
import edu.internet2.middleware.grouper.changeLog.ChangeLogConsumerBase;
/**
* If syncAttribute was applied to the group or one of the parent folders return true
* Method keeps an internal cache of results per run in markedFoldersAndGroups
* Will also check the PIT for recently deleted groups
*/
private boolean isGroupMarkedForSync(String groupName) {
// have we seen this group already in this run
if (markedFoldersAndGroups.containsKey(groupName)) {
return markedFoldersAndGroups.get(groupName).equals(MARKED);
attributeAssign_addAttributeAssign {
/**
* On assignment of the syncAttribute marker, create all the groups or group (if directly assigned)
* and any current memberships at the target.
*/
public void process(ChangeLogEntry changeLogEntry, ChangeLogConsumerBaseImpl consumer) {
// check if this is our syncAttribute, otherwise nothing to do.
final String attributeDefNameName = changeLogEntry.retrieveValueForLabel(ChangeLogLabels.ATTRIBUTE_ASSIGN_ADD.attributeDefNameName);
if (consumer.syncAttribute.getName().equals(attributeDefNameName)) {
// syncAttribute applied to a group, then create the group at the target
Grouper action: 1.0 Place a marker on a folder
Target outcome: add all the groups under that folder and any subfolder, and all the group memberships
Test 1.0.1: Marking a parent folder
1) setup folder structure with groups, sub folders, and groups in sub folders
2) place syncAttribute marker on parent folder
Outcome:
1) all groups within folder structure added to the target
Grouper action: 1.1 Remove a marker from a folder
/**
* These methods are expected to be overriden in a subclass that is specific to a provisioning target. (e.g. Google Apps)
*/
protected void addGroup(Group group, ChangeLogEntry changeLogEntry, ChangeLogConsumerBaseImpl consumer) {
LOG.debug("{} addGroup {} dispatched but not implemented in subclass {}", consumerName, consumerClassName);
}
protected void updateGroup(Group group, ChangeLogEntry changeLogEntry, ChangeLogConsumerBaseImpl consumer) {
LOG.debug("{} updateGroup {} dispatched but not implemented in subclass {}", consumerName, consumerClassName);
}
Grouper action: 1.0 Place a marker on a folder
Target outcome: add all the groups under that folder and any subfolder, and all the group memberships
Test 1.0.1: Marking a parent folder
1) setup folder structure with groups, sub folders, and groups in sub folders
2) place syncAttribute marker on parent folder
Outcome:
1) all groups within folder structure added to the target
GSH:
// Test 1.0.1 Marking a parent folder
gs = GrouperSession.startRootSession();