use of cz.metacentrum.perun.core.bl.PerunBl 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.core.bl.PerunBl 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.core.bl.PerunBl 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.core.bl.PerunBl 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.core.bl.PerunBl in project perun by CESNET.
the class FacilityAttributeProcessor method processVirtualAttributeChanged.
public void processVirtualAttributeChanged(String msg, MessageBeans beans) {
PerunBl perun = (PerunBl) ldapcManager.getPerunBl();
if (beans.getAttribute() == null || beans.getFacility() == null) {
return;
}
try {
Attribute virtAttr = perun.getAttributesManagerBl().getAttribute(ldapcManager.getPerunSession(), beans.getFacility(), beans.getAttribute().getName());
log.debug("Changing virtual attribute {} for facility {}", virtAttr, beans.getFacility());
perunFacility.modifyEntry(beans.getFacility(), virtAttr);
} catch (InternalErrorException | AttributeNotExistsException | WrongAttributeAssignmentException | NamingException e) {
log.error("Error changing virtual attribute:", e);
}
}
Aggregations