Search in sources :

Example 1 with RepositoryEntryMembershipModifiedEvent

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);
}
Also used : RepositoryEntryMembershipModifiedEvent(org.olat.repository.model.RepositoryEntryMembershipModifiedEvent) ArrayList(java.util.ArrayList) Identity(org.olat.core.id.Identity)

Example 2 with RepositoryEntryMembershipModifiedEvent

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;
}
Also used : ActionType(org.olat.core.logging.activity.ActionType) ResourceReservation(org.olat.resource.accesscontrol.ResourceReservation) RepositoryEntryMembershipModifiedEvent(org.olat.repository.model.RepositoryEntryMembershipModifiedEvent) ArrayList(java.util.ArrayList) Identity(org.olat.core.id.Identity)

Example 3 with RepositoryEntryMembershipModifiedEvent

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);
}
Also used : RepositoryEntryMembershipModifiedEvent(org.olat.repository.model.RepositoryEntryMembershipModifiedEvent) ArrayList(java.util.ArrayList) Identity(org.olat.core.id.Identity)

Example 4 with RepositoryEntryMembershipModifiedEvent

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;
}
Also used : ActionType(org.olat.core.logging.activity.ActionType) ResourceReservation(org.olat.resource.accesscontrol.ResourceReservation) RepositoryEntryMembershipModifiedEvent(org.olat.repository.model.RepositoryEntryMembershipModifiedEvent) ArrayList(java.util.ArrayList) Identity(org.olat.core.id.Identity)

Example 5 with RepositoryEntryMembershipModifiedEvent

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);
}
Also used : RepositoryEntryMembershipModifiedEvent(org.olat.repository.model.RepositoryEntryMembershipModifiedEvent) ArrayList(java.util.ArrayList) Identity(org.olat.core.id.Identity)

Aggregations

ArrayList (java.util.ArrayList)10 RepositoryEntryMembershipModifiedEvent (org.olat.repository.model.RepositoryEntryMembershipModifiedEvent)10 Identity (org.olat.core.id.Identity)8 ActionType (org.olat.core.logging.activity.ActionType)2 RepositoryEntryPermissionChangeEvent (org.olat.repository.model.RepositoryEntryPermissionChangeEvent)2 ResourceReservation (org.olat.resource.accesscontrol.ResourceReservation)2