use of org.olat.repository.model.RepositoryEntryMembershipModifiedEvent in project OpenOLAT by OpenOLAT.
the class RepositoryManager method removeTutors.
/**
* remove list of identities as tutor of given repository entry.
* @param ureqIdentity
* @param removeIdentities
* @param re
* @param logger
*/
public void removeTutors(Identity ureqIdentity, List<Identity> removeIdentities, RepositoryEntry re, MailPackage mailing) {
List<RepositoryEntryMembershipModifiedEvent> deferredEvents = new ArrayList<>();
for (Identity identity : removeIdentities) {
removeTutor(ureqIdentity, identity, re, mailing);
deferredEvents.add(RepositoryEntryMembershipModifiedEvent.removed(identity, re));
}
dbInstance.commit();
sendDeferredEvents(deferredEvents, re);
}
use of org.olat.repository.model.RepositoryEntryMembershipModifiedEvent in project OpenOLAT by OpenOLAT.
the class RepositoryManager method removeMembers.
/**
* Remove the identities as members of the repository and from
* all connected business groups.
*
* @param members
* @param re
*/
public boolean removeMembers(Identity ureqIdentity, List<Identity> members, RepositoryEntry re, MailPackage mailing) {
// log the action
ActionType actionType = ThreadLocalUserActivityLogger.getStickyActionType();
ThreadLocalUserActivityLogger.setStickyActionType(ActionType.admin);
for (Identity identity : members) {
try {
ThreadLocalUserActivityLogger.log(GroupLoggingAction.GROUP_MEMBER_REMOVED, getClass(), LoggingResourceable.wrap(re, OlatResourceableType.genRepoEntry), LoggingResourceable.wrap(identity));
} finally {
ThreadLocalUserActivityLogger.setStickyActionType(actionType);
}
}
List<ResourceReservation> reservations = reservationDao.loadReservations(Collections.singletonList(re.getOlatResource()));
for (ResourceReservation reservation : reservations) {
if (members.contains(reservation.getIdentity())) {
reservationDao.deleteReservation(reservation);
}
}
boolean allOk = repositoryEntryRelationDao.removeMembers(re, members);
if (allOk) {
int count = 0;
List<RepositoryEntryMembershipModifiedEvent> deferredEvents = new ArrayList<>();
for (Identity identity : members) {
deferredEvents.add(RepositoryEntryMembershipModifiedEvent.removed(identity, re));
if (++count % 100 == 0) {
dbInstance.commitAndCloseSession();
}
}
dbInstance.commit();
sendDeferredEvents(deferredEvents, re);
}
if (allOk) {
// do logging - not optimal but
StringBuilder sb = new StringBuilder();
sb.append("Identity(.key):").append(ureqIdentity.getKey()).append("removed multiple identities from security groups. Identities:: ");
for (Identity member : members) {
sb.append(member.getName()).append(", ");
}
log.audit(sb.toString());
}
for (Identity identity : members) {
RepositoryMailing.sendEmail(ureqIdentity, identity, re, RepositoryMailing.Type.removeParticipant, mailing);
}
return allOk;
}
use of org.olat.repository.model.RepositoryEntryMembershipModifiedEvent in project openolat by klemens.
the class RepositoryManager method removeOwners.
/**
* remove list of identities as owners of given repository entry.
* @param ureqIdentity
* @param removeIdentities
* @param re
* @param logger
*/
public void removeOwners(Identity ureqIdentity, List<Identity> removeIdentities, RepositoryEntry re, MailPackage mailing) {
List<RepositoryEntryMembershipModifiedEvent> deferredEvents = new ArrayList<>();
for (Identity identity : removeIdentities) {
removeOwner(ureqIdentity, identity, re, mailing);
deferredEvents.add(RepositoryEntryMembershipModifiedEvent.removed(identity, re));
}
dbInstance.commit();
sendDeferredEvents(deferredEvents, re);
}
use of org.olat.repository.model.RepositoryEntryMembershipModifiedEvent in project openolat by klemens.
the class RepositoryManager method removeMembers.
/**
* Remove the identities as members of the repository and from
* all connected business groups.
*
* @param members
* @param re
*/
public boolean removeMembers(Identity ureqIdentity, List<Identity> members, RepositoryEntry re, MailPackage mailing) {
// log the action
ActionType actionType = ThreadLocalUserActivityLogger.getStickyActionType();
ThreadLocalUserActivityLogger.setStickyActionType(ActionType.admin);
for (Identity identity : members) {
try {
ThreadLocalUserActivityLogger.log(GroupLoggingAction.GROUP_MEMBER_REMOVED, getClass(), LoggingResourceable.wrap(re, OlatResourceableType.genRepoEntry), LoggingResourceable.wrap(identity));
} finally {
ThreadLocalUserActivityLogger.setStickyActionType(actionType);
}
}
List<ResourceReservation> reservations = reservationDao.loadReservations(Collections.singletonList(re.getOlatResource()));
for (ResourceReservation reservation : reservations) {
if (members.contains(reservation.getIdentity())) {
reservationDao.deleteReservation(reservation);
}
}
boolean allOk = repositoryEntryRelationDao.removeMembers(re, members);
if (allOk) {
int count = 0;
List<RepositoryEntryMembershipModifiedEvent> deferredEvents = new ArrayList<>();
for (Identity identity : members) {
deferredEvents.add(RepositoryEntryMembershipModifiedEvent.removed(identity, re));
if (++count % 100 == 0) {
dbInstance.commitAndCloseSession();
}
}
dbInstance.commit();
sendDeferredEvents(deferredEvents, re);
}
if (allOk) {
// do logging - not optimal but
StringBuilder sb = new StringBuilder();
sb.append("Identity(.key):").append(ureqIdentity.getKey()).append("removed multiple identities from security groups. Identities:: ");
for (Identity member : members) {
sb.append(member.getName()).append(", ");
}
log.audit(sb.toString());
}
for (Identity identity : members) {
RepositoryMailing.sendEmail(ureqIdentity, identity, re, RepositoryMailing.Type.removeParticipant, mailing);
}
return allOk;
}
use of org.olat.repository.model.RepositoryEntryMembershipModifiedEvent in project OpenOLAT by OpenOLAT.
the class RepositoryManager method removeOwners.
/**
* remove list of identities as owners of given repository entry.
* @param ureqIdentity
* @param removeIdentities
* @param re
* @param logger
*/
public void removeOwners(Identity ureqIdentity, List<Identity> removeIdentities, RepositoryEntry re, MailPackage mailing) {
List<RepositoryEntryMembershipModifiedEvent> deferredEvents = new ArrayList<>();
for (Identity identity : removeIdentities) {
removeOwner(ureqIdentity, identity, re, mailing);
deferredEvents.add(RepositoryEntryMembershipModifiedEvent.removed(identity, re));
}
dbInstance.commit();
sendDeferredEvents(deferredEvents, re);
}
Aggregations