Commit bbf2464e authored by Daniel Gerhardt's avatar Daniel Gerhardt

Refactor package and class hierarchy

* Moved classes from `de.thm.arsnova` root package.
* New util package
* Do not start interface names with `I`. Appended `Impl` to the
  implementing class instead.
* Renamed learning progress classes to score and move them from
  `.domain` to a new `.services.score` package.
* Do not capitalize acronyms in class names:
    * CASLogoutSuccessHandler -> CasLogoutSuccessHandler
    * SocketIO* -> Socketio*
* Renamed `.socket` package to `.websocket`
parent e4268386
......@@ -17,7 +17,7 @@
*/
package de.thm.arsnova.aop;
import de.thm.arsnova.PaginationListDecorator;
import de.thm.arsnova.util.PaginationListDecorator;
import de.thm.arsnova.controller.PaginationController;
import de.thm.arsnova.services.ResponseProviderService;
import org.aspectj.lang.ProceedingJoinPoint;
......
......@@ -17,114 +17,7 @@
*/
package de.thm.arsnova.cache;
import de.thm.arsnova.events.*;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.stereotype.Component;
/**
* This class is used to evict caches based on events. The events carry all necessary information to clear the
* caches, e.g, for a specific session.
* This interface is used as a tag to make Spring dependency injection happy...
*/
@Component
public class CacheBuster implements ICacheBuster, NovaEventVisitor {
@CacheEvict(value = "statistics", allEntries = true)
@Override
public void visit(NewCommentEvent event) { }
@CacheEvict(value = "statistics", allEntries = true)
@Override
public void visit(DeleteCommentEvent event) { }
@Override
public void visit(NewQuestionEvent event) { }
@Override
public void visit(UnlockQuestionEvent event) { }
@Override
public void visit(UnlockQuestionsEvent newQuestionsEvent) { }
@Override
public void visit(LockQuestionEvent lockQuestionEvent) { }
@Override
public void visit(LockQuestionsEvent lockQuestionsEvent) { }
@CacheEvict(value = "answers", key = "#event.content")
@Override
public void visit(NewAnswerEvent event) { }
@Override
public void visit(DeleteAnswerEvent event) { }
@Override
public void visit(DeleteQuestionEvent event) { }
@Override
public void visit(DeleteAllQuestionsEvent event) { }
@Override
public void visit(DeleteAllQuestionsAnswersEvent event) { }
@Override
public void visit(DeleteAllPreparationAnswersEvent event) { }
@Override
public void visit(DeleteAllLectureAnswersEvent event) { }
@Override
public void visit(NewFeedbackEvent event) { }
@Override
public void visit(DeleteFeedbackForSessionsEvent event) { }
@Override
public void visit(StatusSessionEvent event) { }
@CacheEvict(value = "statistics", allEntries = true)
@Override
public void visit(ChangeLearningProgressEvent changeLearningProgress) { }
@Override
public void visit(PiRoundDelayedStartEvent piRoundDelayedStartEvent) { }
@Override
public void visit(PiRoundEndEvent piRoundEndEvent) { }
@Override
public void visit(PiRoundCancelEvent piRoundCancelEvent) { }
@Override
public void visit(PiRoundResetEvent piRoundResetEvent) { }
@CacheEvict(value = "statistics", allEntries = true)
@Override
public void visit(NewSessionEvent newSessionEvent) { }
@CacheEvict(value = "statistics", allEntries = true)
@Override
public void visit(DeleteSessionEvent deleteSessionEvent) { }
@Override
public void visit(LockVoteEvent lockVoteEvent) { }
@Override
public void visit(LockVotesEvent lockVotesEvent) { }
@Override
public void visit(UnlockVoteEvent unlockVoteEvent) { }
@Override
public void visit(UnlockVotesEvent unlockVotesEvent) { }
@Override
public void visit(FeatureChangeEvent featureChangeEvent) { }
@Override
public void visit(LockFeedbackEvent lockFeedbackEvent) { }
@Override
public void visit(FlipFlashcardsEvent flipFlashcardsEvent) { }
}
public interface CacheBuster { }
/*
* This file is part of ARSnova Backend.
* Copyright (C) 2012-2017 The ARSnova Team
*
* ARSnova Backend is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ARSnova Backend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.thm.arsnova.cache;
import de.thm.arsnova.events.*;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.stereotype.Component;
/**
* This class is used to evict caches based on events. The events carry all necessary information to clear the
* caches, e.g, for a specific session.
*/
@Component
public class CacheBusterImpl implements CacheBuster, ArsnovaEventVisitor {
@CacheEvict(value = "statistics", allEntries = true)
@Override
public void visit(NewCommentEvent event) { }
@CacheEvict(value = "statistics", allEntries = true)
@Override
public void visit(DeleteCommentEvent event) { }
@Override
public void visit(NewQuestionEvent event) { }
@Override
public void visit(UnlockQuestionEvent event) { }
@Override
public void visit(UnlockQuestionsEvent newQuestionsEvent) { }
@Override
public void visit(LockQuestionEvent lockQuestionEvent) { }
@Override
public void visit(LockQuestionsEvent lockQuestionsEvent) { }
@CacheEvict(value = "answers", key = "#event.content")
@Override
public void visit(NewAnswerEvent event) { }
@Override
public void visit(DeleteAnswerEvent event) { }
@Override
public void visit(DeleteQuestionEvent event) { }
@Override
public void visit(DeleteAllQuestionsEvent event) { }
@Override
public void visit(DeleteAllQuestionsAnswersEvent event) { }
@Override
public void visit(DeleteAllPreparationAnswersEvent event) { }
@Override
public void visit(DeleteAllLectureAnswersEvent event) { }
@Override
public void visit(NewFeedbackEvent event) { }
@Override
public void visit(DeleteFeedbackForSessionsEvent event) { }
@Override
public void visit(StatusSessionEvent event) { }
@CacheEvict(value = "statistics", allEntries = true)
@Override
public void visit(ChangeScoreEvent changeLearningProgress) { }
@Override
public void visit(PiRoundDelayedStartEvent piRoundDelayedStartEvent) { }
@Override
public void visit(PiRoundEndEvent piRoundEndEvent) { }
@Override
public void visit(PiRoundCancelEvent piRoundCancelEvent) { }
@Override
public void visit(PiRoundResetEvent piRoundResetEvent) { }
@CacheEvict(value = "statistics", allEntries = true)
@Override
public void visit(NewSessionEvent newSessionEvent) { }
@CacheEvict(value = "statistics", allEntries = true)
@Override
public void visit(DeleteSessionEvent deleteSessionEvent) { }
@Override
public void visit(LockVoteEvent lockVoteEvent) { }
@Override
public void visit(LockVotesEvent lockVotesEvent) { }
@Override
public void visit(UnlockVoteEvent unlockVoteEvent) { }
@Override
public void visit(UnlockVotesEvent unlockVotesEvent) { }
@Override
public void visit(FeatureChangeEvent featureChangeEvent) { }
@Override
public void visit(LockFeedbackEvent lockFeedbackEvent) { }
@Override
public void visit(FlipFlashcardsEvent flipFlashcardsEvent) { }
}
......@@ -17,8 +17,8 @@
*/
package de.thm.arsnova.cache;
import de.thm.arsnova.events.NovaEvent;
import de.thm.arsnova.events.NovaEventVisitor;
import de.thm.arsnova.events.ArsnovaEvent;
import de.thm.arsnova.events.ArsnovaEventVisitor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;
......@@ -29,14 +29,14 @@ import org.springframework.stereotype.Component;
* Note that this class is necessary in order for the annotations to work.
*/
@Component
public class CacheBustListener implements ApplicationListener<NovaEvent> {
public class CacheBusterListener implements ApplicationListener<ArsnovaEvent> {
@Autowired
private ICacheBuster cacheBuster;
private CacheBuster cacheBuster;
@Override
public void onApplicationEvent(NovaEvent event) {
event.accept((NovaEventVisitor) cacheBuster);
public void onApplicationEvent(ArsnovaEvent event) {
event.accept((ArsnovaEventVisitor) cacheBuster);
}
}
/*
* This file is part of ARSnova Backend.
* Copyright (C) 2012-2017 The ARSnova Team
*
* ARSnova Backend is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ARSnova Backend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.thm.arsnova.cache;
/**
* This interface is used as a tag to make Spring dependency injection happy...
*/
public interface ICacheBuster { }
......@@ -20,26 +20,18 @@ package de.thm.arsnova.config;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import de.thm.arsnova.ImageUtils;
import de.thm.arsnova.util.ImageUtils;
import de.thm.arsnova.connector.client.ConnectorClient;
import de.thm.arsnova.connector.client.ConnectorClientImpl;
import de.thm.arsnova.entities.*;
import de.thm.arsnova.entities.serialization.CouchDbDocumentModule;
import de.thm.arsnova.entities.serialization.CouchDbObjectMapperFactory;
import de.thm.arsnova.entities.serialization.View;
import de.thm.arsnova.persistance.*;
import de.thm.arsnova.persistance.couchdb.*;
import de.thm.arsnova.persistance.couchdb.InitializingCouchDbConnector;
import de.thm.arsnova.socket.ARSnovaSocket;
import de.thm.arsnova.socket.ARSnovaSocketIOServer;
import de.thm.arsnova.socket.ARSnovaSocketListener;
import de.thm.arsnova.websocket.ArsnovaSocketioServer;
import de.thm.arsnova.websocket.ArsnovaSocketioServerImpl;
import de.thm.arsnova.websocket.ArsnovaSocketioServerListener;
import de.thm.arsnova.web.CacheControlInterceptorHandler;
import de.thm.arsnova.web.CorsFilter;
import de.thm.arsnova.web.DeprecatedApiInterceptorHandler;
import de.thm.arsnova.web.ResponseInterceptorHandler;
import org.ektorp.CouchDbConnector;
import org.ektorp.impl.StdCouchDbInstance;
import org.ektorp.spring.HttpClientFactoryBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.config.PropertiesFactoryBean;
......@@ -88,7 +80,6 @@ import java.util.List;
"de.thm.arsnova.aop",
"de.thm.arsnova.cache",
"de.thm.arsnova.controller",
"de.thm.arsnova.domain",
"de.thm.arsnova.dao",
"de.thm.arsnova.events",
"de.thm.arsnova.security",
......@@ -261,19 +252,19 @@ public class AppConfig extends WebMvcConfigurerAdapter {
@Profile("!test")
@Bean(name = "socketServer", initMethod = "startServer", destroyMethod = "stopServer")
public ARSnovaSocket socketServer() {
final ARSnovaSocketIOServer socketServer = new ARSnovaSocketIOServer();
socketServer.setHostIp(socketAddress);
socketServer.setPortNumber(socketPort);
socketServer.setUseSSL(!socketKeystore.isEmpty());
socketServer.setKeystore(socketKeystore);
socketServer.setStorepass(socketKeystorePassword);
return socketServer;
public ArsnovaSocketioServer socketServer() {
final ArsnovaSocketioServerImpl socketioServer = new ArsnovaSocketioServerImpl();
socketioServer.setHostIp(socketAddress);
socketioServer.setPortNumber(socketPort);
socketioServer.setUseSSL(!socketKeystore.isEmpty());
socketioServer.setKeystore(socketKeystore);
socketioServer.setStorepass(socketKeystorePassword);
return socketioServer;
}
@Bean
public ARSnovaSocketListener arsnovaSocketListener() {
return new ARSnovaSocketListener();
public ArsnovaSocketioServerListener arsnovaSocketListener() {
return new ArsnovaSocketioServerListener();
}
@Bean
......
......@@ -17,10 +17,10 @@
*/
package de.thm.arsnova.config;
import de.thm.arsnova.CASLogoutSuccessHandler;
import de.thm.arsnova.CasUserDetailsService;
import de.thm.arsnova.LoginAuthenticationFailureHandler;
import de.thm.arsnova.LoginAuthenticationSucessHandler;
import de.thm.arsnova.security.CasLogoutSuccessHandler;
import de.thm.arsnova.security.CasUserDetailsService;
import de.thm.arsnova.security.LoginAuthenticationFailureHandler;
import de.thm.arsnova.security.LoginAuthenticationSucessHandler;
import de.thm.arsnova.security.ApplicationPermissionEvaluator;
import de.thm.arsnova.security.CustomLdapUserDetailsMapper;
import de.thm.arsnova.security.DbUserDetailsService;
......@@ -364,7 +364,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Bean
public LogoutSuccessHandler casLogoutSuccessHandler() {
CASLogoutSuccessHandler handler = new CASLogoutSuccessHandler();
CasLogoutSuccessHandler handler = new CasLogoutSuccessHandler();
handler.setCasUrl(casUrl);
handler.setDefaultTarget(rootUrl);
......
......@@ -20,7 +20,7 @@ package de.thm.arsnova.controller;
import de.thm.arsnova.entities.CommentReadingCount;
import de.thm.arsnova.entities.transport.Comment;
import de.thm.arsnova.exceptions.BadRequestException;
import de.thm.arsnova.services.IContentService;
import de.thm.arsnova.services.ContentService;
import de.thm.arsnova.web.DeprecatedApi;
import de.thm.arsnova.web.Pagination;
import io.swagger.annotations.Api;
......@@ -49,7 +49,7 @@ import java.util.List;
public class CommentController extends PaginationController {
@Autowired
private IContentService contentService;
private ContentService contentService;
@ApiOperation(value = "Count all the comments in current session",
nickname = "getAudienceQuestionCount")
......
......@@ -17,14 +17,14 @@
*/
package de.thm.arsnova.controller;
import de.thm.arsnova.PaginationListDecorator;
import de.thm.arsnova.util.PaginationListDecorator;
import de.thm.arsnova.entities.Answer;
import de.thm.arsnova.entities.Content;
import de.thm.arsnova.exceptions.BadRequestException;
import de.thm.arsnova.exceptions.ForbiddenException;
import de.thm.arsnova.exceptions.NoContentException;
import de.thm.arsnova.exceptions.NotFoundException;
import de.thm.arsnova.services.IContentService;
import de.thm.arsnova.services.ContentService;
import de.thm.arsnova.web.DeprecatedApi;
import de.thm.arsnova.web.Pagination;
import io.swagger.annotations.Api;
......@@ -54,7 +54,7 @@ import java.util.List;
@Api(value = "/lecturerquestion", description = "Operations for Lecture Questions")
public class ContentController extends PaginationController {
@Autowired
private IContentService contentService;
private ContentService contentService;
@ApiOperation(value = "Get question with provided question Id",
nickname = "getQuestion")
......
......@@ -23,7 +23,7 @@ import de.thm.arsnova.connector.model.UserRole;
import de.thm.arsnova.entities.User;
import de.thm.arsnova.exceptions.NotImplementedException;
import de.thm.arsnova.exceptions.UnauthorizedException;
import de.thm.arsnova.services.IUserService;
import de.thm.arsnova.services.UserService;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -46,7 +46,7 @@ public class CourseController extends AbstractController {
private ConnectorClient connectorClient;
@Autowired
private IUserService userService;
private UserService userService;
@RequestMapping(value = "/mycourses", method = RequestMethod.GET)
public List<Course> myCourses(
......
......@@ -20,8 +20,9 @@ package de.thm.arsnova.controller;
import de.thm.arsnova.entities.Feedback;
import de.thm.arsnova.entities.User;
import de.thm.arsnova.exceptions.NotFoundException;
import de.thm.arsnova.services.IFeedbackService;
import de.thm.arsnova.services.IUserService;
import de.thm.arsnova.services.FeedbackService;
import de.thm.arsnova.services.UserService;
import de.thm.arsnova.websocket.ArsnovaSocketioServerImpl;
import de.thm.arsnova.web.DeprecatedApi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
......@@ -36,15 +37,15 @@ import org.springframework.web.bind.annotation.RestController;
* Handles requests concerning the user's feedback, i.e., "too fast" or "faster, please". This HTTP API is
* deprecated in favor of the socket implementation.
*
* @see de.thm.arsnova.socket.ARSnovaSocketIOServer
* @see ArsnovaSocketioServerImpl
*/
@RestController
public class FeedbackController extends AbstractController {
@Autowired
private IFeedbackService feedbackService;
private FeedbackService feedbackService;
@Autowired
private IUserService userService;
private UserService userService;
@DeprecatedApi
@Deprecated
......
......@@ -17,7 +17,7 @@
*/
package de.thm.arsnova.controller;
import de.thm.arsnova.services.IContentService;
import de.thm.arsnova.services.ContentService;
import de.thm.arsnova.web.DeprecatedApi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
......@@ -33,7 +33,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
public class LegacyController extends AbstractController {
@Autowired
private IContentService contentService;
private ContentService contentService;
/* specific routes */
......
......@@ -21,7 +21,7 @@ import de.thm.arsnova.entities.ServiceDescription;
import de.thm.arsnova.entities.Session;
import de.thm.arsnova.entities.User;
import de.thm.arsnova.exceptions.UnauthorizedException;
import de.thm.arsnova.services.IUserService;
import de.thm.arsnova.services.UserService;
import de.thm.arsnova.services.UserSessionService;
import org.pac4j.core.context.J2EContext;
import org.pac4j.core.exception.HttpAction;
......@@ -142,7 +142,7 @@ public class LoginController extends AbstractController {
private CasAuthenticationEntryPoint casEntryPoint;
@Autowired
private IUserService userService;
private UserService userService;
@Autowired
private UserSessionService userSessionService;
......
......@@ -19,7 +19,7 @@ package de.thm.arsnova.controller;
import de.thm.arsnova.entities.Motd;
import de.thm.arsnova.entities.MotdList;
import de.thm.arsnova.services.IMotdService;
import de.thm.arsnova.services.MotdService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
......@@ -48,7 +48,7 @@ import java.util.List;
public class MotdController extends AbstractController {
@Autowired
private IMotdService motdService;
private MotdService motdService;
@ApiOperation(value = "get messages. if adminview=false, only messages with startdate<clientdate<enddate are returned")
@RequestMapping(value = "/", method = RequestMethod.GET)
......
......@@ -22,14 +22,14 @@ import de.thm.arsnova.entities.Session;
import de.thm.arsnova.entities.SessionFeature;
import de.thm.arsnova.entities.SessionInfo;
import de.thm.arsnova.entities.transport.ImportExportSession;
import de.thm.arsnova.entities.transport.LearningProgressValues;
import de.thm.arsnova.entities.transport.ScoreStatistics;
import de.thm.arsnova.exceptions.UnauthorizedException;
import de.thm.arsnova.services.ISessionService;
import de.thm.arsnova.services.IUserService;
import de.thm.arsnova.services.SessionService.SessionInfoNameComparator;
import de.thm.arsnova.services.SessionService.SessionInfoShortNameComparator;
import de.thm.arsnova.services.SessionService.SessionNameComparator;
import de.thm.arsnova.services.SessionService.SessionShortNameComparator;
import de.thm.arsnova.services.SessionService;
import de.thm.arsnova.services.UserService;
import de.thm.arsnova.services.SessionServiceImpl.SessionInfoNameComparator;
import de.thm.arsnova.services.SessionServiceImpl.SessionInfoShortNameComparator;
import de.thm.arsnova.services.SessionServiceImpl.SessionNameComparator;
import de.thm.arsnova.services.SessionServiceImpl.SessionShortNameComparator;
import de.thm.arsnova.web.DeprecatedApi;
import de.thm.arsnova.web.Pagination;
import io.swagger.annotations.Api;
......@@ -61,10 +61,10 @@ import java.util.List;
@Api(value = "/session", description = "the Session Controller API")
public class SessionController extends PaginationController {
@Autowired
private ISessionService sessionService;
private SessionService sessionService;
@Autowired
private IUserService userService;
private UserService userService;
@ApiOperation(value = "join a session",
nickname = "joinSession")
......@@ -345,28 +345,28 @@ public class SessionController extends PaginationController {
return null;
}
@ApiOperation(value = "retrieves a value for the learning progress",
@ApiOperation(value = "retrieves a value for the score",
nickname = "getLearningProgress")
@RequestMapping(value = "/{sessionkey}/learningprogress", method = RequestMethod.GET)
public LearningProgressValues getLearningProgress(
public ScoreStatistics getLearningProgress(
@ApiParam(value = "session-key from current session", required = true) @PathVariable final String sessionkey,
@ApiParam(value = "progress type", required = false) @RequestParam(value = "type", defaultValue = "questions") final String progressType,
@ApiParam(value = "type", required = false) @RequestParam(value = "type", defaultValue = "questions") final String type,
@ApiParam(value = "question variant", required = false) @RequestParam(value = "questionVariant", required = false) final String questionVariant,
final HttpServletResponse response
) {
return sessionService.getLearningProgress(sessionkey, progressType, questionVariant);
return sessionService.getLearningProgress(sessionkey, type, questionVariant);
}
@ApiOperation(value = "retrieves a value for the learning progress for the current user",
nickname = "getMyLearningProgress")
@RequestMapping(value = "/{sessionkey}/mylearningprogress", method = RequestMethod.GET)
public LearningProgressValues getMyLearningProgress(
public ScoreStatistics getMyLearningProgress(
@ApiParam(value = "session-key from current session", required = true) @PathVariable final String sessionkey,
@RequestParam(value = "type", defaultValue = "questions") final String progressType,
@RequestParam(value = "type", defaultValue = "questions") final String type,
@RequestParam(value = "questionVariant", required = false) final String questionVariant,
final HttpServletResponse response
) {
return sessionService.getMyLearningProgress(sessionkey, progressType, questionVariant);
return sessionService.getMyLearningProgress(sessionkey, type, questionVariant);
}
@ApiOperation(value = "retrieves all session features",
......
......@@ -18,9 +18,9 @@
package de.thm.arsnova.controller;
import de.thm.arsnova.entities.User;
import de.thm.arsnova.services.IUserService;
import de.thm.arsnova.services.UserService;
import de.thm.arsnova.services.UserSessionService;
import de.thm.arsnova.socket.ARSnovaSocket;
import de.thm.arsnova.websocket.ArsnovaSocketioServer;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
......@@ -49,13 +49,13 @@ import java.util.UUID;
public class SocketController extends AbstractController {
@Autowired
private IUserService userService;
private UserService userService;
@Autowired
private UserSessionService userSessionService;
@Autowired
private ARSnovaSocket server;
private ArsnovaSocketioServer server;
private static final Logger logger = LoggerFactory.getLogger(SocketController.class);
......
......@@ -18,7 +18,7 @@
package de.thm.arsnova.controller;
import de.thm.arsnova.entities.Statistics;
import