Commit 4b212dd9 authored by Daniel Gerhardt's avatar Daniel Gerhardt

Merge branch 'qa' into 'master'

Fix multiple bugs and code smells

See merge request arsnova/arsnova-backend!147
parents 9bbff2ed e3c8caa1
Pipeline #29814 passed with stages
in 2 minutes and 47 seconds
......@@ -39,36 +39,36 @@ public class CacheBusterImpl implements CacheBuster {
@CacheEvict(value = "statistics", allEntries = true)
@EventListener
public void handleAfterCommentCreation(final AfterCreationEvent<Comment> event) {
/* Implementation provided by caching aspect. */
}
@CacheEvict(value = "statistics", allEntries = true)
@EventListener
public void handleAfterCommentDeletion(final AfterDeletionEvent<Comment> event) {
/* Implementation provided by caching aspect. */
}
@CacheEvict(value = "answerlists", key = "#event.content.id")
@EventListener
public void handleAfterAnswerCreation(final AfterCreationEvent<Answer> event) {
/* Implementation provided by caching aspect. */
}
@CacheEvict(value = "statistics", allEntries = true)
@EventListener
public void handleChangeScore(final ChangeScoreEvent event) {
/* Implementation provided by caching aspect. */
}
@CacheEvict(value = "statistics", allEntries = true)
@EventListener
public void handleAfterRoomCreation(final AfterCreationEvent<Room> event) {
/* Implementation provided by caching aspect. */
}
@CacheEvict(value = "statistics", allEntries = true)
@EventListener
public void handleAfterRoomDeletion(final AfterDeletionEvent<Room> event) {
/* Implementation provided by caching aspect. */
}
}
......@@ -41,49 +41,49 @@ public class ScheduledCacheBuster {
@CacheEvict(value = "rooms", allEntries = true)
@Scheduled(initialDelay = 1000 * 25, fixedRate = 1000 * 60 * 60 * 6)
private void clearSessionCache() {
/* Implementation provided by caching aspect. */
}
@CacheEvict(value = "contents", allEntries = true)
@Scheduled(initialDelay = 1000 * 50, fixedRate = 1000 * 60 * 30)
private void clearQuestionCache() {
/* Implementation provided by caching aspect. */
}
@CacheEvict(value = "contentlists", allEntries = true)
@Scheduled(initialDelay = 1000 * 75, fixedRate = 1000 * 60 * 30)
private void clearSkillQuestionCache() {
/* Implementation provided by caching aspect. */
}
@CacheEvict(value = "lecturecontentlists", allEntries = true)
@Scheduled(initialDelay = 1000 * 100, fixedRate = 1000 * 60 * 30)
private void clearLectureQuestionCache() {
/* Implementation provided by caching aspect. */
}
@CacheEvict(value = "preparationcontentlists", allEntries = true)
@Scheduled(initialDelay = 1000 * 125, fixedRate = 1000 * 60 * 30)
private void clearPreparationQuestionCache() {
/* Implementation provided by caching aspect. */
}
@CacheEvict(value = "flashcardcontentlists", allEntries = true)
@Scheduled(initialDelay = 1000 * 150, fixedRate = 1000 * 60 * 30)
private void clearFlashcardQuestionCache() {
/* Implementation provided by caching aspect. */
}
@CacheEvict(value = "answerlists", allEntries = true)
@Scheduled(initialDelay = 1000 * 175, fixedRate = 1000 * 60 * 15)
private void clearAnswerCache() {
/* Implementation provided by caching aspect. */
}
@CacheEvict(value = "score", allEntries = true)
@Scheduled(initialDelay = 1000 * 200, fixedRate = 1000 * 60 * 15)
private void clearLearningProgressCache() {
/* Implementation provided by caching aspect. */
}
}
......@@ -22,9 +22,10 @@ import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import io.micrometer.core.instrument.MeterRegistry;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang.CharEncoding;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.PropertiesFactoryBean;
import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties;
......@@ -116,7 +117,7 @@ import de.thm.arsnova.websocket.ArsnovaSocketioServerImpl;
"classpath:config/actuator.yml",
"file:${arsnova.config-dir:.}/application.yml"},
ignoreResourceNotFound = true,
encoding = "UTF-8",
encoding = CharEncoding.UTF_8,
factory = YamlPropertySourceFactory.class
)
@EnableConfigurationProperties(SystemProperties.class)
......@@ -209,7 +210,7 @@ public class AppConfig implements WebMvcConfigurer {
@Bean
public StringHttpMessageConverter stringMessageConverter() {
final StringHttpMessageConverter messageConverter = new StringHttpMessageConverter();
messageConverter.setDefaultCharset(Charset.forName("UTF-8"));
messageConverter.setDefaultCharset(StandardCharsets.UTF_8);
messageConverter.setWriteAcceptCharset(false);
final List<MediaType> mediaTypes = new ArrayList<>();
mediaTypes.add(MediaType.TEXT_PLAIN);
......
......@@ -116,6 +116,13 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
public static final String CAS_LOGIN_PATH_SUFFIX = "/auth/login/cas";
public static final String CAS_LOGOUT_PATH_SUFFIX = "/auth/logout/cas";
public static final String RUN_AS_KEY_PREFIX = "RUN_AS_KEY";
public static final String INTERNAL_PROVIDER_ID = "user-db";
public static final String LDAP_PROVIDER_ID = "ldap";
public static final String OIDC_PROVIDER_ID = "oidc";
public static final String CAS_PROVIDER_ID = "cas";
public static final String GOOGLE_PROVIDER_ID = "google";
public static final String TWITTER_PROVIDER_ID = "twitter";
public static final String FACEBOOK_PROVIDER_ID = "facebook";
private static final Logger logger = LoggerFactory.getLogger(SecurityConfig.class);
private ServletContext servletContext;
......@@ -250,32 +257,32 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
auth.authenticationProvider(jwtAuthenticationProvider());
logger.info("oauthProps: {}", providerProperties.getOauth());
if (providerProperties.getLdap().stream().anyMatch(p -> p.isEnabled())) {
providers.add("ldap");
providers.add(LDAP_PROVIDER_ID);
auth.authenticationProvider(ldapAuthenticationProvider());
}
if (providerProperties.getCas().isEnabled()) {
providers.add("cas");
providers.add(CAS_PROVIDER_ID);
auth.authenticationProvider(casAuthenticationProvider());
}
if (providerProperties.getRegistered().isEnabled()) {
providers.add("user-db");
providers.add(INTERNAL_PROVIDER_ID);
auth.authenticationProvider(daoAuthenticationProvider());
}
if (providerProperties.getOidc().stream().anyMatch(p -> p.isEnabled())) {
providers.add("oidc");
providers.add(OIDC_PROVIDER_ID);
}
if (providerProperties.getOauth().values().stream().anyMatch(p -> p.isEnabled())) {
if (providerProperties.getOauth().containsKey("google")
&& providerProperties.getOauth().get("google").isEnabled()) {
providers.add("google");
if (providerProperties.getOauth().containsKey(GOOGLE_PROVIDER_ID)
&& providerProperties.getOauth().get(GOOGLE_PROVIDER_ID).isEnabled()) {
providers.add(GOOGLE_PROVIDER_ID);
}
if (providerProperties.getOauth().containsKey("facebook")
&& providerProperties.getOauth().get("facebook").isEnabled()) {
providers.add("facebook");
if (providerProperties.getOauth().containsKey(FACEBOOK_PROVIDER_ID)
&& providerProperties.getOauth().get(FACEBOOK_PROVIDER_ID).isEnabled()) {
providers.add(FACEBOOK_PROVIDER_ID);
}
if (providerProperties.getOauth().containsKey("twitter")
&& providerProperties.getOauth().get("twitter").isEnabled()) {
providers.add("twitter");
if (providerProperties.getOauth().containsKey(TWITTER_PROVIDER_ID)
&& providerProperties.getOauth().get(TWITTER_PROVIDER_ID).isEnabled()) {
providers.add(TWITTER_PROVIDER_ID);
}
auth.authenticationProvider(oauthAuthenticationProvider());
}
......@@ -513,16 +520,16 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
if (providerProperties.getOidc().stream().anyMatch(p -> p.isEnabled())) {
clients.add(oidcClient());
}
if (providerProperties.getOauth().containsKey("facebook")
&& providerProperties.getOauth().get("facebook").isEnabled()) {
if (providerProperties.getOauth().containsKey(FACEBOOK_PROVIDER_ID)
&& providerProperties.getOauth().get(FACEBOOK_PROVIDER_ID).isEnabled()) {
clients.add(facebookClient());
}
if (providerProperties.getOauth().containsKey("google")
&& providerProperties.getOauth().get("google").isEnabled()) {
if (providerProperties.getOauth().containsKey(GOOGLE_PROVIDER_ID)
&& providerProperties.getOauth().get(GOOGLE_PROVIDER_ID).isEnabled()) {
clients.add(googleClient());
}
if (providerProperties.getOauth().containsKey("twitter")
&& providerProperties.getOauth().get("twitter").isEnabled()) {
if (providerProperties.getOauth().containsKey(TWITTER_PROVIDER_ID)
&& providerProperties.getOauth().get(TWITTER_PROVIDER_ID).isEnabled()) {
clients.add(twitterClient());
}
......@@ -559,7 +566,8 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Bean
public FacebookClient facebookClient() {
final AuthenticationProviderProperties.Oauth oauthProperties = providerProperties.getOauth().get("facebook");
final AuthenticationProviderProperties.Oauth oauthProperties =
providerProperties.getOauth().get(FACEBOOK_PROVIDER_ID);
final FacebookClient client = new FacebookClient(oauthProperties.getKey(), oauthProperties.getSecret());
client.setCallbackUrl(rootUrl + apiPath + OAUTH_CALLBACK_PATH_SUFFIX + "?client_name=FacebookClient");
......@@ -568,7 +576,8 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Bean
public TwitterClient twitterClient() {
final AuthenticationProviderProperties.Oauth oauthProperties = providerProperties.getOauth().get("twitter");
final AuthenticationProviderProperties.Oauth oauthProperties =
providerProperties.getOauth().get(TWITTER_PROVIDER_ID);
final TwitterClient client = new TwitterClient(oauthProperties.getKey(), oauthProperties.getSecret());
client.setCallbackUrl(rootUrl + apiPath + OAUTH_CALLBACK_PATH_SUFFIX + "?client_name=TwitterClient");
......@@ -577,7 +586,8 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Bean
public GoogleOidcClient googleClient() {
final AuthenticationProviderProperties.Oauth oauthProperties = providerProperties.getOauth().get("google");
final AuthenticationProviderProperties.Oauth oauthProperties =
providerProperties.getOauth().get(GOOGLE_PROVIDER_ID);
final OidcConfiguration config = new OidcConfiguration();
config.setClientId(oauthProperties.getKey());
config.setSecret(oauthProperties.getSecret());
......
......@@ -25,6 +25,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
......@@ -164,7 +165,7 @@ public class ConfigurationController extends AbstractController {
socketioPath = systemProperties.getSocketio().getProxyPath();
}
@RequestMapping(method = RequestMethod.GET)
@GetMapping
@ResponseBody
public Map<String, Object> getConfiguration(final HttpServletRequest request) {
final Map<String, Object> config = new HashMap<>();
......
......@@ -101,7 +101,7 @@ public class UserController extends AbstractEntityController<UserProfile> {
}
}
@RequestMapping(value = ACTIVATE_MAPPING, method = RequestMethod.POST)
@PostMapping(ACTIVATE_MAPPING)
public void activate(
@PathVariable final String id,
@RequestParam final String key) {
......@@ -113,7 +113,7 @@ public class UserController extends AbstractEntityController<UserProfile> {
userService.update(userProfile);
}
@RequestMapping(value = RESET_PASSWORD_MAPPING, method = RequestMethod.POST)
@PostMapping(RESET_PASSWORD_MAPPING)
public void resetPassword(
@PathVariable final String id,
@RequestBody final PasswordReset passwordReset) {
......
......@@ -30,8 +30,8 @@ import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
......@@ -56,18 +56,18 @@ public class WelcomeController extends AbstractController {
@Autowired
private VersionInfoContributor versionInfoContributor;
@RequestMapping(value = "/", method = RequestMethod.GET)
@GetMapping("/")
public View home() {
return new RedirectView(mobileContextPath + "/", false);
}
@RequestMapping(value = "/", method = RequestMethod.GET, produces = "application/json")
@GetMapping(value = "/", produces = "application/json")
@ResponseBody
public Map<String, Object> jsonHome() {
return versionInfoContributor.getInfoDetails();
}
@RequestMapping(value = "/checkframeoptionsheader", method = RequestMethod.POST)
@PostMapping("/checkframeoptionsheader")
@ResponseStatus(HttpStatus.OK)
public void checkFrameOptionsHeader(
@RequestParam final String url,
......
......@@ -50,8 +50,9 @@ import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.web.util.UrlUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.View;
......@@ -124,7 +125,7 @@ public class AuthenticationController extends AbstractController {
oauthProperties = authenticationProviderProperties.getOauth();
}
@RequestMapping(value = { "/login", "/doLogin" }, method = { RequestMethod.POST, RequestMethod.GET })
@PostMapping({ "/login", "/doLogin" })
public void doLogin(
@RequestParam("type") final String type,
@RequestParam(value = "user", required = false) final String username,
......@@ -170,7 +171,7 @@ public class AuthenticationController extends AbstractController {
}
}
@RequestMapping(value = { "/dialog" }, method = RequestMethod.GET)
@GetMapping("/dialog")
@ResponseBody
public View dialog(
@RequestParam("type") final String type,
......@@ -231,7 +232,7 @@ public class AuthenticationController extends AbstractController {
return result;
}
@RequestMapping(value = { "/", "/whoami" }, method = RequestMethod.GET)
@GetMapping({ "/", "/whoami" })
@ResponseBody
public ClientAuthentication whoami(@AuthenticationPrincipal final User user) {
if (user == null) {
......@@ -240,7 +241,7 @@ public class AuthenticationController extends AbstractController {
return new ClientAuthentication(user);
}
@RequestMapping(value = { "/logout" }, method = { RequestMethod.POST, RequestMethod.GET })
@PostMapping("/logout")
public String doLogout(final HttpServletRequest request) {
final Authentication auth = SecurityContextHolder.getContext().getAuthentication();
userService.removeUserIdFromMaps(userService.getCurrentUser().getId());
......@@ -249,10 +250,10 @@ public class AuthenticationController extends AbstractController {
if (auth instanceof CasAuthenticationToken) {
return "redirect:" + apiPath + SecurityConfig.CAS_LOGOUT_PATH_SUFFIX;
}
return "redirect:" + request.getHeader("referer") != null ? request.getHeader("referer") : "/";
return "redirect:" + (request.getHeader("referer") != null ? request.getHeader("referer") : "/");
}
@RequestMapping(value = { "/services" }, method = RequestMethod.GET)
@GetMapping("/services")
@ResponseBody
public List<ServiceDescription> getServices(final HttpServletRequest request) {
final List<ServiceDescription> services = new ArrayList<>();
......@@ -284,9 +285,9 @@ public class AuthenticationController extends AbstractController {
if (ldapProperties.get(0).isEnabled()) {
final ServiceDescription sdesc = new ServiceDescription(
"ldap",
SecurityConfig.LDAP_PROVIDER_ID,
ldapProperties.get(0).getTitle(),
customizationPath + "/login?provider=ldap&redirect={0}",
customizationPath + "/login?provider=" + SecurityConfig.LDAP_PROVIDER_ID + "&redirect={0}",
ldapProperties.get(0).getAllowedRoles()
);
sdesc.setOrder(ldapProperties.get(0).getOrder());
......@@ -295,9 +296,9 @@ public class AuthenticationController extends AbstractController {
if (casProperties.isEnabled()) {
final ServiceDescription sdesc = new ServiceDescription(
"cas",
SecurityConfig.CAS_PROVIDER_ID,
casProperties.getTitle(),
MessageFormat.format(dialogUrl, "cas"),
MessageFormat.format(dialogUrl, SecurityConfig.CAS_PROVIDER_ID),
casProperties.getAllowedRoles()
);
sdesc.setOrder(casProperties.getOrder());
......@@ -306,45 +307,48 @@ public class AuthenticationController extends AbstractController {
if (oidcProperties.get(0).isEnabled()) {
final ServiceDescription sdesc = new ServiceDescription(
"oidc",
SecurityConfig.OIDC_PROVIDER_ID,
oidcProperties.get(0).getTitle(),
MessageFormat.format(dialogUrl, "oidc"),
MessageFormat.format(dialogUrl, SecurityConfig.OIDC_PROVIDER_ID),
oidcProperties.get(0).getAllowedRoles()
);
sdesc.setOrder(oidcProperties.get(0).getOrder());
services.add(sdesc);
}
final AuthenticationProviderProperties.Oauth facebookProperties = oauthProperties.get("facebook");
final AuthenticationProviderProperties.Oauth facebookProperties =
oauthProperties.get(SecurityConfig.FACEBOOK_PROVIDER_ID);
if (facebookProperties != null && facebookProperties.isEnabled()) {
final ServiceDescription sdesc = new ServiceDescription(
"facebook",
SecurityConfig.FACEBOOK_PROVIDER_ID,
"Facebook",
MessageFormat.format(dialogUrl, "facebook"),
MessageFormat.format(dialogUrl, SecurityConfig.FACEBOOK_PROVIDER_ID),
facebookProperties.getAllowedRoles()
);
sdesc.setOrder(facebookProperties.getOrder());
services.add(sdesc);
}
final AuthenticationProviderProperties.Oauth googleProperties = oauthProperties.get("google");
final AuthenticationProviderProperties.Oauth googleProperties =
oauthProperties.get(SecurityConfig.GOOGLE_PROVIDER_ID);
if (googleProperties != null && googleProperties.isEnabled()) {
final ServiceDescription sdesc = new ServiceDescription(
"google",
SecurityConfig.GOOGLE_PROVIDER_ID,
"Google",
MessageFormat.format(dialogUrl, "google"),
MessageFormat.format(dialogUrl, SecurityConfig.GOOGLE_PROVIDER_ID),
googleProperties.getAllowedRoles()
);
sdesc.setOrder(googleProperties.getOrder());
services.add(sdesc);
}
final AuthenticationProviderProperties.Oauth twitterProperties = oauthProperties.get("twitter");
final AuthenticationProviderProperties.Oauth twitterProperties =
oauthProperties.get(SecurityConfig.TWITTER_PROVIDER_ID);
if (twitterProperties != null && twitterProperties.isEnabled()) {
final ServiceDescription sdesc = new ServiceDescription(
"twitter",
SecurityConfig.TWITTER_PROVIDER_ID,
"Twitter",
MessageFormat.format(dialogUrl, "twitter"),
MessageFormat.format(dialogUrl, SecurityConfig.TWITTER_PROVIDER_ID),
twitterProperties.getAllowedRoles()
);
sdesc.setOrder(twitterProperties.getOrder());
......
......@@ -29,7 +29,10 @@ import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
......@@ -74,7 +77,7 @@ public class CommentController extends PaginationController {
@ApiOperation(value = "Count all the comments in current room",
nickname = "getCommentCount")
@RequestMapping(value = "/count", method = RequestMethod.GET, produces = MediaType.TEXT_PLAIN_VALUE)
@GetMapping(value = "/count", produces = MediaType.TEXT_PLAIN_VALUE)
@DeprecatedApi
@Deprecated
public String getCommentCount(
......@@ -86,7 +89,7 @@ public class CommentController extends PaginationController {
@ApiOperation(value = "count all unread comments",
nickname = "getUnreadCommentCount")
@RequestMapping(value = "/readcount", method = RequestMethod.GET)
@GetMapping("/readcount")
@DeprecatedApi
@Deprecated
public CommentReadingCount getUnreadCommentCount(
......@@ -97,7 +100,7 @@ public class CommentController extends PaginationController {
@ApiOperation(value = "Retrieves all Comments for a Room",
nickname = "getComments")
@RequestMapping(value = "/", method = RequestMethod.GET)
@GetMapping("/")
@Pagination
public List<Comment> getComments(
@ApiParam(value = "Room-Key from current room", required = true)
......@@ -109,7 +112,7 @@ public class CommentController extends PaginationController {
@ApiOperation(value = "Retrieves an Comment",
nickname = "getComment")
@RequestMapping(value = "/{commentId}", method = RequestMethod.GET)
@GetMapping("/{commentId}")
public Comment getComment(
@ApiParam(value = "ID of the Comment that needs to be deleted", required = true)
@PathVariable
......@@ -123,7 +126,7 @@ public class CommentController extends PaginationController {
@ApiResponses(value = {
@ApiResponse(code = 400, message = HTML_STATUS_400)
})
@RequestMapping(value = "/", method = RequestMethod.POST)
@PostMapping("/")
@ResponseStatus(HttpStatus.CREATED)
public void postComment(
@ApiParam(value = "Room-Key from current room", required = true)
......@@ -140,7 +143,7 @@ public class CommentController extends PaginationController {
@ApiOperation(value = "Deletes a Comment",
nickname = "deleteComment")
@RequestMapping(value = "/{commentId}", method = RequestMethod.DELETE)
@DeleteMapping("/{commentId}")
public void deleteComment(
@ApiParam(value = "ID of the comment that needs to be deleted", required = true)
@PathVariable
......
......@@ -25,8 +25,7 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
......@@ -50,7 +49,7 @@ public class CourseController extends AbstractController {
@Autowired
private UserService userService;
@RequestMapping(value = "/v2/mycourses", method = RequestMethod.GET)
@GetMapping("/v2/mycourses")
public List<Course> myCourses(
@ApiParam(value = "sort my courses by name", required = true)
@RequestParam(value = "sortby", defaultValue = "name") final String sortby) {
......
......@@ -21,7 +21,9 @@ package de.thm.arsnova.controller.v2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
......@@ -58,14 +60,14 @@ public class FeedbackController extends AbstractController {
@DeprecatedApi
@Deprecated
@RequestMapping(value = "/feedback", method = RequestMethod.GET)
@GetMapping("/feedback")
public Feedback getFeedback(@PathVariable final String shortId) {
return feedbackService.getByRoomId(roomService.getIdByShortId(shortId));
}
@DeprecatedApi
@Deprecated
@RequestMapping(value = "/myfeedback", method = RequestMethod.GET, produces = MediaType.TEXT_PLAIN_VALUE)
@GetMapping(value = "/myfeedback", produces = MediaType.TEXT_PLAIN_VALUE)
public String getMyFeedback(@PathVariable final String shortId) {
final String roomId = roomService.getIdByShortId(shortId);
final Integer value = feedbackService.getByRoomIdAndUserId(roomId, userService.getCurrentUser().getId());
......@@ -77,28 +79,28 @@ public class FeedbackController extends AbstractController {
@DeprecatedApi
@Deprecated
@RequestMapping(value = "/feedbackcount", method = RequestMethod.GET, produces = MediaType.TEXT_PLAIN_VALUE)
@GetMapping(value = "/feedbackcount", produces = MediaType.TEXT_PLAIN_VALUE)
public String getFeedbackCount(@PathVariable final String shortId) {
return String.valueOf(feedbackService.countFeedbackByRoomId(roomService.getIdByShortId(shortId)));
}
@DeprecatedApi
@Deprecated
@RequestMapping(value = "/roundedaveragefeedback", method = RequestMethod.GET, produces = MediaType.TEXT_PLAIN_VALUE)
@GetMapping(value = "/roundedaveragefeedback", produces = MediaType.TEXT_PLAIN_VALUE)
public String getAverageFeedbackRounded(@PathVariable final String shortId) {
return String.valueOf(feedbackService.calculateRoundedAverageFeedback(roomService.getIdByShortId(shortId)));
}
@DeprecatedApi
@Deprecated
@RequestMapping(value = "/averagefeedback", method = RequestMethod.GET, produces = MediaType.TEXT_PLAIN_VALUE)
@GetMapping(value = "/averagefeedback", produces = MediaType.TEXT_PLAIN_VALUE)
public String getAverageFeedback(@PathVariable final String shortId) {
return String.valueOf(feedbackService.calculateAverageFeedback(roomService.getIdByShortId(shortId)));
}
@DeprecatedApi
@Deprecated
@RequestMapping(value = "/feedback", method = RequestMethod.POST)
@PostMapping("/feedback")
@ResponseStatus(HttpStatus.CREATED)
public Feedback postFeedback(
@PathVariable final String shortId,
......
......@@ -20,7 +20,10 @@ package de.thm.arsnova.controller.v2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
......@@ -46,13 +49,13 @@ public class LegacyController extends AbstractController {
/* specific routes */
@DeprecatedApi
@RequestMapping(value = "/session/mysessions", method = RequestMethod.GET)
@GetMapping("/session/mysessions")
public String redirectSessionMy() {
return "forward:/v2/session/?ownedonly=true";
}
@DeprecatedApi
@RequestMapping(value = "/session/visitedsessions", method = RequestMethod.GET)
@GetMapping("/session/visitedsessions")
public String redirectSessionVisited() {
return "forward:/v2/session/?visitedonly=true";
}
......@@ -64,31 +67,31 @@ public class LegacyController extends AbstractController {
}
@DeprecatedApi
@RequestMapping(value = "/session/{shortId}/skillquestions", method = RequestMethod.GET)
@GetMapping("/session/{shortId}/skillquestions")
public String redirectQuestionByLecturerList(@PathVariable final String shortId) {
return String.format("forward:/v2/lecturerquestion/?sessionkey=%s", shortId);
}
@DeprecatedApi
@RequestMapping(value = "/session/{shortId}/skillquestioncount", method = RequestMethod.GET)
@GetMapping("/session/{shortId}/skillquestioncount")
public String redirectQuestionByLecturerCount(@PathVariable final String shortId) {
return String.format("forward:/v2/lecturerquestion/count?sessionkey=%s", shortId);
}
@DeprecatedApi
@RequestMapping(value = "/session/{shortId}/answercount", method = RequestMethod.GET)
@GetMapping("/session/{shortId}/answercount")
public String redirectQuestionByLecturerAnswerCount(@PathVariable final String shortId) {
return String.format("forward:/v2/lecturerquestion/answercount?sessionkey=%s", shortId);
}
@DeprecatedApi
@RequestMapping(value = "/session/{shortId}/unanswered", method = RequestMethod.GET)
@GetMapping("/session/{shortId}/unanswered")
public String redirectQuestionByLecturerUnnsweredCount(@PathVariable final String shortId) {
return String.format("forward:/v2/lecturerquestion/answercount?sessionkey=%s", shortId);
}
@DeprecatedApi
@RequestMapping(value = "/session/{shortId}/myanswers", method = RequestMethod.GET)
@GetMapping("/session/{shortId}/myanswers")
public String redirectQuestionByLecturerMyAnswers(@PathVariable final String shortId) {
return String.format("forward:/v2/lecturerquestion/myanswers?sessionkey=%s", shortId);
}
......@@ -100,24 +103,36 @@ public class LegacyController extends AbstractController {
}
@DeprecatedApi
@RequestMapping(value = "/session/{shortId}/interposed", method = RequestMethod.DELETE)
@DeleteMapping("/session/{shortId}/interposed")
@ResponseBody
public void deleteAllInterposedQuestions(@PathVariable final String shortId) {