use of org.opencastproject.index.service.impl.index.group.Group in project opencast by opencast.
the class GroupMessageReceiverImpl method execute.
@Override
protected void execute(GroupItem groupItem) {
String organization = getSecurityService().getOrganization().getId();
User user = getSecurityService().getUser();
switch(groupItem.getType()) {
case Update:
org.opencastproject.security.api.Group jaxbGroup = groupItem.getGroup();
logger.debug("Update the group with id '{}', name '{}', description '{}', organization '{}', roles '{}', members '{}'", jaxbGroup.getGroupId(), jaxbGroup.getName(), jaxbGroup.getDescription(), jaxbGroup.getOrganization(), jaxbGroup.getRoles(), jaxbGroup.getMembers());
try {
Group group = GroupIndexUtils.getOrCreate(jaxbGroup.getGroupId(), organization, user, getSearchIndex());
group.setName(jaxbGroup.getName());
group.setDescription(jaxbGroup.getDescription());
group.setMembers(jaxbGroup.getMembers());
Set<String> roles = new HashSet<>();
for (Role role : jaxbGroup.getRoles()) {
roles.add(role.getName());
}
group.setRoles(roles);
getSearchIndex().addOrUpdate(group);
} catch (SearchIndexException e) {
logger.error("Error storing the group {} to the search index: {}", jaxbGroup.getGroupId(), ExceptionUtils.getStackTrace(e));
return;
}
break;
case Delete:
logger.debug("Received Delete Group Event {}", groupItem.getGroupId());
// Remove the group from the search index
try {
getSearchIndex().delete(Group.DOCUMENT_TYPE, groupItem.getGroupId().concat(organization));
logger.debug("Group {} removed from external search index", groupItem.getGroupId());
} catch (SearchIndexException e) {
logger.error("Error deleting the group {} from the search index: {}", groupItem.getGroupId(), ExceptionUtils.getStackTrace(e));
return;
}
return;
default:
throw new IllegalArgumentException("Unhandled type of GroupItem");
}
}
Aggregations