Skip to content

Instantly share code, notes, and snippets.

@ilgrosso
Last active February 24, 2020 07:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ilgrosso/8abc6fd129d48441a40298213d098b77 to your computer and use it in GitHub Desktop.
Save ilgrosso/8abc6fd129d48441a40298213d098b77 to your computer and use it in GitHub Desktop.
AttributesEnrichingPropagationActions
public class AttributesEnrichingPropagationAction implements PropagationActions {
@Autowired
private UserDAO userDAO;
@Transactional(readonly = true)
@Override
public void before(final PropagationTask task, final ConnectorObject beforeObj) {
// do something only if propagating users
if (AnyTypeKind.USER == task.getAnyTypeKind()) {
// read the user being propagated
User user = userDAO.find(task.getEntityKey());
if (user != null) {
// get the propagation attributes preparared according to the mapping provided
Set<Attribute> attributes = new HashSet<>(task.getAttributes());
// add, replace of remove attributes
Set<String> groups = user.getMemberships().stream().
map(memb -> memb.getRightEnd().getName()).collect(Collectors.toSet());
attributes.add(AttributeBuilder.build("new_attribute_name", groups));
// store the updated attributes for actual propagation
task.setAttributes(attributes);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment