use of org.olat.admin.securitygroup.gui.IdentitiesAddEvent in project openolat by klemens.
the class CourseWebService method addAuthors.
@PUT
@Path("authors")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response addAuthors(UserVO[] authors, @Context HttpServletRequest httpRequest) {
if (!isAuthorEditor(course, httpRequest) && !isInstitutionalResourceManager(httpRequest)) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
BaseSecurity securityManager = BaseSecurityManager.getInstance();
List<Identity> authorList = loadIdentities(authors);
Identity identity = getIdentity(httpRequest);
SecurityGroup authorGroup = securityManager.findSecurityGroupByName(Constants.GROUP_AUTHORS);
for (Identity author : authorList) {
boolean hasBeenAuthor = securityManager.isIdentityInSecurityGroup(author, authorGroup);
if (!hasBeenAuthor) {
// not an author already, add this identity to the security group "authors"
securityManager.addIdentityToSecurityGroup(author, authorGroup);
log.audit("User::" + identity.getName() + " added system role::" + Constants.GROUP_AUTHORS + " to user::" + author.getName() + " via addAuthor method in course REST API", null);
}
}
// add the author as owner of the course
RepositoryEntry repositoryEntry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
IdentitiesAddEvent identitiesAddedEvent = new IdentitiesAddEvent(authorList);
RepositoryManager.getInstance().addOwners(identity, identitiesAddedEvent, repositoryEntry, new MailPackage(false));
return Response.ok().build();
}
use of org.olat.admin.securitygroup.gui.IdentitiesAddEvent in project openolat by klemens.
the class ProjectGroupController method handleProjectMemberGroupEvent.
private void handleProjectMemberGroupEvent(UserRequest urequest, Event event) {
if (event instanceof IdentitiesAddEvent) {
IdentitiesAddEvent identitiesAddedEvent = (IdentitiesAddEvent) event;
BusinessGroupAddResponse response = businessGroupService.addParticipants(urequest.getIdentity(), urequest.getUserSession().getRoles(), identitiesAddedEvent.getAddIdentities(), project.getProjectGroup(), null);
identitiesAddedEvent.setIdentitiesAddedEvent(response.getAddedIdentities());
identitiesAddedEvent.setIdentitiesWithoutPermission(response.getIdentitiesWithoutPermission());
identitiesAddedEvent.setIdentitiesAlreadyInGroup(response.getIdentitiesAlreadyInGroup());
getLogger().info("Add users as project-members");
fireEvent(urequest, Event.CHANGED_EVENT);
} else if (event instanceof IdentitiesRemoveEvent) {
businessGroupService.removeParticipants(urequest.getIdentity(), ((IdentitiesRemoveEvent) event).getRemovedIdentities(), project.getProjectGroup(), null);
getLogger().info("Remove users as account-managers");
fireEvent(urequest, Event.CHANGED_EVENT);
}
}
use of org.olat.admin.securitygroup.gui.IdentitiesAddEvent in project openolat by klemens.
the class ProjectGroupController method handleCandidateGroupEvent.
private void handleCandidateGroupEvent(UserRequest urequest, Event event) {
if (event instanceof IdentitiesAddEvent) {
IdentitiesAddEvent identitiesAddEvent = (IdentitiesAddEvent) event;
List<Identity> addedIdentities = projectGroupManager.addCandidates(identitiesAddEvent.getAddIdentities(), project);
identitiesAddEvent.setIdentitiesAddedEvent(addedIdentities);
fireEvent(urequest, Event.CHANGED_EVENT);
} else if (event instanceof IdentitiesRemoveEvent) {
projectGroupManager.removeCandidates(((IdentitiesRemoveEvent) event).getRemovedIdentities(), project);
fireEvent(urequest, Event.CHANGED_EVENT);
} else if (event instanceof IdentitiesMoveEvent) {
final IdentitiesMoveEvent identitiesMoveEvent = (IdentitiesMoveEvent) event;
// OLAT-6342: check identity not in group first!
List<Identity> moveIdents = identitiesMoveEvent.getChosenIdentities();
BusinessGroupAddResponse response = projectGroupManager.acceptCandidates(moveIdents, project, urequest.getIdentity(), projectBrokerModuleConfiguration.isAutoSignOut(), projectBrokerModuleConfiguration.isAcceptSelectionManually());
identitiesMoveEvent.setMovedIdentities(response.getAddedIdentities());
identitiesMoveEvent.setNotMovedIdentities(response.getIdentitiesAlreadyInGroup());
// send mail for all of them
MailTemplate mailTemplate = identitiesMoveEvent.getMailTemplate();
if (mailTemplate != null) {
MailContext context = new MailContextImpl(getWindowControl().getBusinessControl().getAsString());
String metaId = UUID.randomUUID().toString().replace("-", "");
MailerResult result = new MailerResult();
MailBundle[] bundles = mailManager.makeMailBundles(context, identitiesMoveEvent.getMovedIdentities(), mailTemplate, null, metaId, result);
result.append(mailManager.sendMessage(bundles));
if (mailTemplate.getCpfrom()) {
MailBundle ccBundle = mailManager.makeMailBundle(context, urequest.getIdentity(), mailTemplate, null, metaId, result);
result.append(mailManager.sendMessage(ccBundle));
}
MailHelper.printErrorsAndWarnings(result, getWindowControl(), urequest.getUserSession().getRoles().isOLATAdmin(), urequest.getLocale());
}
fireEvent(urequest, Event.CHANGED_EVENT);
// Participant and waiting-list were changed => reload both
projectMemberController.reloadData();
// Do only reload data in case of IdentitiesMoveEvent (IdentitiesAddEvent and reload data resulting in doublicate values)
projectCandidatesController.reloadData();
}
}
use of org.olat.admin.securitygroup.gui.IdentitiesAddEvent in project openolat by klemens.
the class ProjectGroupController method handleProjectLeaderGroupEvent.
private void handleProjectLeaderGroupEvent(UserRequest urequest, Event event) {
if (event instanceof IdentitiesAddEvent) {
IdentitiesAddEvent identitiesAddedEvent = (IdentitiesAddEvent) event;
BusinessGroupAddResponse response = businessGroupService.addOwners(urequest.getIdentity(), urequest.getUserSession().getRoles(), identitiesAddedEvent.getAddIdentities(), project.getProjectGroup(), null);
identitiesAddedEvent.setIdentitiesAddedEvent(response.getAddedIdentities());
identitiesAddedEvent.setIdentitiesWithoutPermission(response.getIdentitiesWithoutPermission());
identitiesAddedEvent.setIdentitiesAlreadyInGroup(response.getIdentitiesAlreadyInGroup());
getLogger().info("Add users as project-leader");
fireEvent(urequest, Event.CHANGED_EVENT);
} else if (event instanceof IdentitiesRemoveEvent) {
businessGroupService.removeOwners(urequest.getIdentity(), ((IdentitiesRemoveEvent) event).getRemovedIdentities(), project.getProjectGroup());
getLogger().info("Remove users as account-managers");
fireEvent(urequest, Event.CHANGED_EVENT);
}
}
Aggregations