use of cz.metacentrum.perun.ldapc.model.PerunVirtualAttribute in project perun by CESNET.
the class VirtualAttributeEventProcessor method processGroupAttributeChange.
public void processGroupAttributeChange(String msg, MessageBeans beans) {
// ensure we have the correct beans available
if (beans.getAttribute() == null || beans.getGroup() == null) {
return;
}
try {
PerunBl perun = (PerunBl) ldapcManager.getPerunBl();
/* get list of dependent attributes */
Collection<PerunVirtualAttribute<User>> attrDefs = dependencyManager.getAttributeDependants(beans.getAttribute().getName());
log.debug("Processing group {} attribute {} change, affected attributes {}", beans.getGroup(), beans.getAttribute(), attrDefs);
if (attrDefs != null) {
/* for each concerned user */
for (User user : perun.getGroupsManagerBl().getGroupUsers(ldapcManager.getPerunSession(), beans.getGroup())) {
/* get attribute value for each dependent attribute */
Collection<Pair<PerunAttribute<User>, AttributeDefinition>> userAttrs = this.getAttributeValues(perun, user, attrDefs);
log.debug("Modifying user {} entry with the new values {}", user.getId(), userAttrs);
perunUser.modifyEntry(user, userAttrs);
}
}
} catch (InternalErrorException e) {
log.error("Error processing group {} attribute {} change: {}", beans.getGroup(), beans.getAttribute(), e.getMessage());
}
}
use of cz.metacentrum.perun.ldapc.model.PerunVirtualAttribute in project perun by CESNET.
the class VirtualAttributeEventProcessor method processGroupAttributeRemoval.
public void processGroupAttributeRemoval(String msg, MessageBeans beans) {
// ensure we have the correct beans available
if (beans.getGroup() == null || beans.getAttributeDef() == null) {
return;
}
try {
PerunBl perun = (PerunBl) ldapcManager.getPerunBl();
Collection<PerunVirtualAttribute<User>> attrDefs = dependencyManager.getAttributeDependants(beans.getAttributeDef().getName());
log.debug("Processing group {} attribute {} removal, affected attributes {}", beans.getGroup(), beans.getAttributeDef(), attrDefs);
if (attrDefs != null) {
for (User user : perun.getGroupsManagerBl().getGroupUsers(ldapcManager.getPerunSession(), beans.getGroup())) {
/* get attribute value for each dependent attribute */
Collection<Pair<PerunAttribute<User>, AttributeDefinition>> userAttrs = this.getAttributeValues(perun, user, attrDefs);
log.debug("Modifying user {} entry with the new values {}", user.getId(), userAttrs);
perunUser.modifyEntry(user, userAttrs);
}
}
} catch (InternalErrorException e) {
log.error("Error processing group {} attribute {} removal: {}", beans.getGroup(), beans.getAttributeDef(), e.getMessage());
}
}
use of cz.metacentrum.perun.ldapc.model.PerunVirtualAttribute in project perun by CESNET.
the class VirtualAttributeEventProcessor method processMemberChange.
public void processMemberChange(String msg, MessageBeans beans) {
// ensure we have the correct beans available
if (beans.getMember() == null) {
return;
}
try {
PerunBl perun = (PerunBl) ldapcManager.getPerunBl();
User user = perun.getUsersManagerBl().getUserByMember(ldapcManager.getPerunSession(), beans.getMember());
Collection<PerunVirtualAttribute<User>> attrDefs = dependencyManager.getAllAttributeDependants();
log.debug("Processing member {} status change with attributes {}", user, attrDefs);
Collection<Pair<PerunAttribute<User>, AttributeDefinition>> userAttrs = this.getAttributeValues(perun, user, attrDefs);
log.debug("Modifying user {} entry with the new values {}", user.getId(), userAttrs);
perunUser.modifyEntry(user, userAttrs);
} catch (InternalErrorException e) {
log.error("Error processing member {} status change: {}", beans.getMember(), e.getMessage());
}
}
use of cz.metacentrum.perun.ldapc.model.PerunVirtualAttribute in project perun by CESNET.
the class VirtualAttributeEventProcessor method processGroupMemberChange.
public void processGroupMemberChange(String msg, MessageBeans beans) {
// ensure we have the correct beans available
if (beans.getMember() == null || beans.getGroup() == null) {
return;
}
try {
PerunBl perun = (PerunBl) ldapcManager.getPerunBl();
User user = perun.getUsersManagerBl().getUserByMember(ldapcManager.getPerunSession(), beans.getMember());
List<String> registeredAttrs = dependencyManager.getRegisteredAttributes();
List<Attribute> groupAttrs = perun.getAttributesManagerBl().getAttributes(ldapcManager.getPerunSession(), beans.getGroup(), registeredAttrs);
log.debug("Processing member {} status change in group {} with attributes {}", user, beans.getGroup(), groupAttrs);
if (!groupAttrs.isEmpty()) {
List<PerunVirtualAttribute<User>> attrDefs = new ArrayList<>();
groupAttrs.forEach(attr -> attrDefs.addAll(dependencyManager.getAttributeDependants(attr.getName())));
log.debug("Found attributes: {}", attrDefs);
Collection<Pair<PerunAttribute<User>, AttributeDefinition>> userAttrs = this.getAttributeValues(perun, user, attrDefs);
log.debug("Modifying user {} entry with the new values {}", user.getId(), userAttrs);
perunUser.modifyEntry(user, userAttrs);
}
} catch (InternalErrorException e) {
log.error("Error processing member {} change in group {}: {}", beans.getMember(), beans.getGroup(), e.getMessage());
}
}
use of cz.metacentrum.perun.ldapc.model.PerunVirtualAttribute in project perun by CESNET.
the class VirtualAttributeEventProcessor method processAllGroupAttributesRemoval.
public void processAllGroupAttributesRemoval(String msg, MessageBeans beans) {
// ensure we have the correct beans available
if (beans.getGroup() == null) {
return;
}
try {
PerunBl perun = (PerunBl) ldapcManager.getPerunBl();
Collection<PerunVirtualAttribute<User>> attrDefs = dependencyManager.getAllAttributeDependants();
log.debug("Processing group {} all attribute removal, affected attributes {}", beans.getGroup(), attrDefs);
if (attrDefs != null) {
for (User user : perun.getGroupsManagerBl().getGroupUsers(ldapcManager.getPerunSession(), beans.getGroup())) {
/* get attribute value for each dependent attribute */
Collection<Pair<PerunAttribute<User>, AttributeDefinition>> userAttrs = this.getAttributeValues(perun, user, attrDefs);
log.debug("Modifying user {} entry with the new values {}", user.getId(), userAttrs);
perunUser.modifyEntry(user, userAttrs);
}
}
} catch (InternalErrorException e) {
log.error("Error processing group {} attributes removal: {}", beans.getGroup(), e.getMessage());
}
}
Aggregations