Skip to content
Snippets Groups Projects
Commit dc0c1dfb authored by Daniel Gerhardt's avatar Daniel Gerhardt
Browse files

Make deletion of user profiles cascading

The deletion of users now triggers a cascading deletion for rooms owned
by the user.
parent c7320813
1 merge request!156Make deletion of user profiles cascading
Pipeline #30199 passed with warnings with stages
in 1 minute and 23 seconds
......@@ -34,14 +34,17 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.cache.annotation.Caching;
import org.springframework.context.event.EventListener;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.security.access.annotation.Secured;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Service;
import org.springframework.validation.Validator;
import de.thm.arsnova.connector.client.ConnectorClient;
import de.thm.arsnova.connector.model.Course;
import de.thm.arsnova.event.BeforeDeletionEvent;
import de.thm.arsnova.event.FlipFlashcardsEvent;
import de.thm.arsnova.model.Room;
import de.thm.arsnova.model.UserProfile;
......@@ -149,6 +152,13 @@ public class RoomServiceImpl extends DefaultEntityServiceImpl<Room> implements R
this.connectorClient = connectorClient;
}
@EventListener
@Secured({"ROLE_USER", "RUN_AS_SYSTEM"})
public void handleUserDeletion(final BeforeDeletionEvent<UserProfile> event) {
final Iterable<Room> rooms = roomRepository.findByOwnerId(event.getEntity().getId(), -1, -1);
delete(rooms);
}
@Scheduled(fixedDelay = ROOM_INACTIVITY_CHECK_INTERVAL_MS)
public void deleteInactiveRooms() {
if (guestRoomInactivityThresholdDays > 0) {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment