use of org.olat.core.logging.activity.ActionType in project OpenOLAT by OpenOLAT.
the class RepositoryManager method removeParticipant.
private void removeParticipant(Identity ureqIdentity, Identity identity, RepositoryEntry re, MailPackage mailing, boolean sendMail) {
repositoryEntryRelationDao.removeRole(identity, re, GroupRoles.participant.name());
if (sendMail) {
RepositoryMailing.sendEmail(ureqIdentity, identity, re, RepositoryMailing.Type.removeParticipant, mailing);
}
ActionType actionType = ThreadLocalUserActivityLogger.getStickyActionType();
ThreadLocalUserActivityLogger.setStickyActionType(ActionType.admin);
try {
ThreadLocalUserActivityLogger.log(GroupLoggingAction.GROUP_OWNER_REMOVED, getClass(), LoggingResourceable.wrap(re, OlatResourceableType.genRepoEntry), LoggingResourceable.wrap(identity));
} finally {
ThreadLocalUserActivityLogger.setStickyActionType(actionType);
}
log.audit("Identity(.key):" + ureqIdentity.getKey() + " removed identity '" + identity.getName() + "' from repositoryentry with key " + re.getKey());
}
use of org.olat.core.logging.activity.ActionType 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.core.logging.activity.ActionType in project OpenOLAT by OpenOLAT.
the class RepositoryManager method removeOwner.
private void removeOwner(Identity ureqIdentity, Identity identity, RepositoryEntry re, MailPackage mailing) {
repositoryEntryRelationDao.removeRole(identity, re, GroupRoles.owner.name());
RepositoryMailing.sendEmail(ureqIdentity, identity, re, RepositoryMailing.Type.removeTutor, mailing);
ActionType actionType = ThreadLocalUserActivityLogger.getStickyActionType();
ThreadLocalUserActivityLogger.setStickyActionType(ActionType.admin);
try {
ThreadLocalUserActivityLogger.log(GroupLoggingAction.GROUP_OWNER_REMOVED, getClass(), LoggingResourceable.wrap(re, OlatResourceableType.genRepoEntry), LoggingResourceable.wrap(identity));
} finally {
ThreadLocalUserActivityLogger.setStickyActionType(actionType);
}
log.audit("Identity(.key):" + ureqIdentity.getKey() + " removed identity '" + identity.getName() + "' from repositoryentry with key " + re.getKey());
}
use of org.olat.core.logging.activity.ActionType in project OpenOLAT by OpenOLAT.
the class BusinessGroupServiceImpl method transferFirstIdentityFromWaitingToParticipant.
/**
* Don't forget to lock the business group before calling this method.
* @param ureqIdentity
* @param group
* @param mailing
* @param syncIM
*/
private void transferFirstIdentityFromWaitingToParticipant(Identity ureqIdentity, BusinessGroup group, MailPackage mailing, List<BusinessGroupModifiedEvent.Deferred> events) {
// Check if waiting-list is enabled and auto-rank-up
if (group.getWaitingListEnabled() != null && group.getWaitingListEnabled().booleanValue() && group.getAutoCloseRanksEnabled() != null && group.getAutoCloseRanksEnabled().booleanValue()) {
// Check if participant is not full
Integer maxSize = group.getMaxParticipants();
int reservations = reservationDao.countReservations(group.getResource());
int partipiciantSize = businessGroupRelationDAO.countRoles(group, GroupRoles.participant.name());
if (maxSize != null && (partipiciantSize + reservations) < maxSize.intValue()) {
// ok it has free places => get first identities from waiting list
List<Identity> identities = businessGroupRelationDAO.getMembersOrderByDate(group, GroupRoles.waiting.name());
int counter = 0;
int freeSlot = maxSize - (partipiciantSize + reservations);
for (Identity firstWaitingListIdentity : identities) {
if (counter >= freeSlot) {
break;
}
// Check if firstWaitingListIdentity is not allready in participant-group
if (!businessGroupRelationDAO.hasRole(firstWaitingListIdentity, group, GroupRoles.participant.name())) {
// move the identity from the waitinglist to the participant group
ActionType formerStickyActionType = ThreadLocalUserActivityLogger.getStickyActionType();
try {
// OLAT-4955: force add-participant and remove-from-waitinglist logging actions
// that get triggered in the next two methods to be of ActionType admin
// This is needed to make sure the targetIdentity ends up in the o_loggingtable
ThreadLocalUserActivityLogger.setStickyActionType(ActionType.admin);
// Don't send mails for the sub-actions "adding to group" and "remove from waiting list", instead
// send a specific "graduate from waiting list" mailing a few lines below
MailPackage subMailing = new MailPackage(false);
addParticipant(ureqIdentity, null, firstWaitingListIdentity, group, subMailing, events);
removeFromWaitingList(ureqIdentity, firstWaitingListIdentity, group, subMailing, events);
} finally {
ThreadLocalUserActivityLogger.setStickyActionType(formerStickyActionType);
}
// Send mail to let user know he is now in group
if (mailing == null) {
mailing = new MailPackage(true);
}
BusinessGroupMailing.sendEmail(null, firstWaitingListIdentity, group, MailType.graduateFromWaitingListToParticpant, mailing);
counter++;
}
}
}
}
}
use of org.olat.core.logging.activity.ActionType in project openolat by klemens.
the class RepositoryManager method addInternalTutors.
/**
* Internal method to add tutors, it makes no check.
* @param ureqIdentity
* @param identity
* @param re
* @param reallyAddedId
*/
private void addInternalTutors(Identity ureqIdentity, Identity identity, RepositoryEntry re, List<Identity> reallyAddedId) {
repositoryEntryRelationDao.addRole(identity, re, GroupRoles.coach.name());
reallyAddedId.add(identity);
ActionType actionType = ThreadLocalUserActivityLogger.getStickyActionType();
ThreadLocalUserActivityLogger.setStickyActionType(ActionType.admin);
try {
ThreadLocalUserActivityLogger.log(GroupLoggingAction.GROUP_OWNER_ADDED, getClass(), LoggingResourceable.wrap(re, OlatResourceableType.genRepoEntry), LoggingResourceable.wrap(identity));
} finally {
ThreadLocalUserActivityLogger.setStickyActionType(actionType);
}
log.audit("Identity(.key):" + ureqIdentity.getKey() + " added identity '" + identity.getName() + "' to repositoryentry with key " + re.getKey());
}
Aggregations