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

Merge branch 'code-cleanup' into 'master'

Code cleanup

See merge request !48
parents 84116434 685695a6
1 merge request!48Code cleanup
Pipeline #7924 passed with stages
in 4 minutes and 13 seconds
Showing
with 114 additions and 118 deletions
......@@ -295,6 +295,11 @@
<artifactId>metrics-annotation</artifactId>
<version>3.0.2</version>
</dependency>
<dependency>
<groupId>org.checkerframework</groupId>
<artifactId>checker-qual</artifactId>
<version>2.1.9</version>
</dependency>
</dependencies>
<build>
......
......@@ -34,7 +34,7 @@ import java.io.IOException;
*/
public class CASLogoutSuccessHandler implements LogoutSuccessHandler {
public static final Logger LOGGER = LoggerFactory.getLogger(CASLogoutSuccessHandler.class);
private static final Logger logger = LoggerFactory.getLogger(CASLogoutSuccessHandler.class);
private String casUrl;
private String defaultTarget;
......@@ -50,7 +50,7 @@ public class CASLogoutSuccessHandler implements LogoutSuccessHandler {
/* Typo in "referer" intended. It is in the spec. */
String referrer = request.getHeader("referer");
if (response.isCommitted()) {
LOGGER.info("Response has already been committed. Unable to redirect to target");
logger.info("Response has already been committed. Unable to redirect to target");
return;
}
redirectStrategy.sendRedirect(
......
......@@ -56,7 +56,7 @@ public class ImageUtils {
/* default value is 200 pixel in height, set the value in the configuration file */
static final int THUMB_HEIGHT_DEFAULT = 200;
public static final Logger LOGGER = LoggerFactory.getLogger(ImageUtils.class);
private static final Logger logger = LoggerFactory.getLogger(ImageUtils.class);
@Value("${imageupload.thumbnail.width}")
private int thumbWidth = THUMB_WIDTH_DEFAULT;
......@@ -200,7 +200,7 @@ public class ImageUtils {
return result.toString();
} catch (IOException e) {
LOGGER.error(e.getLocalizedMessage());
logger.error(e.getLocalizedMessage());
return null;
}
}
......@@ -248,7 +248,7 @@ public class ImageUtils {
return baos.toByteArray();
} catch (IOException e) {
LOGGER.error(e.getLocalizedMessage());
logger.error(e.getLocalizedMessage());
}
return null;
......
......@@ -17,8 +17,6 @@
*/
package de.thm.arsnova;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.DefaultRedirectStrategy;
import org.springframework.security.web.RedirectStrategy;
......@@ -40,8 +38,6 @@ public class LoginAuthenticationFailureHandler extends
private final RedirectStrategy redirectStrategy = new DefaultRedirectStrategy();
private String failureUrl;
public static final Logger LOGGER = LoggerFactory.getLogger(LoginAuthenticationFailureHandler.class);
@Override
public void onAuthenticationFailure(
final HttpServletRequest request,
......
......@@ -17,8 +17,6 @@
*/
package de.thm.arsnova;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler;
import javax.servlet.http.HttpServletRequest;
......@@ -33,8 +31,6 @@ public class LoginAuthenticationSucessHandler extends
private String targetUrl;
public static final Logger LOGGER = LoggerFactory.getLogger(LoginAuthenticationSucessHandler.class);
@Override
protected String determineTargetUrl(
final HttpServletRequest request,
......
......@@ -87,7 +87,7 @@ import java.util.List;
@EnableWebSecurity
@Profile("!test")
public class SecurityConfig extends WebSecurityConfigurerAdapter implements ServletContextAware {
private final Logger logger = LoggerFactory.getLogger(SecurityConfig.class);
private static final Logger logger = LoggerFactory.getLogger(SecurityConfig.class);
private ServletContext servletContext;
......
......@@ -28,8 +28,6 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.PathVariable;
......@@ -50,8 +48,6 @@ import java.util.List;
@Api(value = "/audiencequestion", description = "the Audience Question API")
public class AudienceQuestionController extends PaginationController {
public static final Logger LOGGER = LoggerFactory.getLogger(AudienceQuestionController.class);
@Autowired
private IQuestionService questionService;
......
......@@ -27,6 +27,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;
/**
* The ConfigurationController provides frontend clients with information necessary to correctly interact with the
......@@ -36,7 +37,7 @@ import java.util.HashMap;
@Controller
@RequestMapping({"/configuration", "/arsnova-config"})
public class ConfigurationController extends AbstractController {
public static final Logger LOGGER = LoggerFactory
private static final Logger logger = LoggerFactory
.getLogger(ConfigurationController.class);
@Value("${api.path:}")
......@@ -161,11 +162,11 @@ public class ConfigurationController extends AbstractController {
@RequestMapping(method = RequestMethod.GET)
@ResponseBody
public HashMap<String, Object> getConfiguration(HttpServletRequest request) {
HashMap<String, Object> config = new HashMap<>();
HashMap<String, Boolean> features = new HashMap<>();
HashMap<String, String> publicPool = new HashMap<>();
HashMap<String, Object> splashscreen = new HashMap<>();
public Map<String, Object> getConfiguration(HttpServletRequest request) {
Map<String, Object> config = new HashMap<>();
Map<String, Boolean> features = new HashMap<>();
Map<String, String> publicPool = new HashMap<>();
Map<String, Object> splashscreen = new HashMap<>();
/* The API path could be unknown to the client in case the request was forwarded */
if ("".equals(apiPath)) {
......@@ -268,7 +269,7 @@ public class ConfigurationController extends AbstractController {
}
if (!"".equals(trackingTrackerUrl)) {
HashMap<String, String> tracking = new HashMap<>();
Map<String, String> tracking = new HashMap<>();
config.put("tracking", tracking);
tracking.put("provider", trackingProvider);
......
......@@ -45,7 +45,7 @@ import java.util.List;
@RestController
public class CourseController extends AbstractController {
public static final Logger LOGGER = LoggerFactory.getLogger(CourseController.class);
private static final Logger logger = LoggerFactory.getLogger(CourseController.class);
@Autowired(required = false)
private ConnectorClient connectorClient;
......
......@@ -43,7 +43,7 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
public class FeedbackController extends AbstractController {
public static final Logger LOGGER = LoggerFactory.getLogger(FeedbackController.class);
private static final Logger logger = LoggerFactory.getLogger(FeedbackController.class);
@Autowired
private IFeedbackService feedbackService;
......
......@@ -56,7 +56,7 @@ import java.util.List;
@Api(value = "/lecturerquestion", description = "Operations for Lecture Questions")
public class LecturerQuestionController extends PaginationController {
public static final Logger LOGGER = LoggerFactory.getLogger(LecturerQuestionController.class);
private static final Logger logger = LoggerFactory.getLogger(LecturerQuestionController.class);
@Autowired
private IQuestionService questionService;
......
......@@ -19,8 +19,6 @@ package de.thm.arsnova.controller;
import de.thm.arsnova.services.IQuestionService;
import de.thm.arsnova.web.DeprecatedApi;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
......@@ -34,8 +32,6 @@ import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class LegacyController extends AbstractController {
public static final Logger LOGGER = LoggerFactory.getLogger(LegacyController.class);
@Autowired
private IQuestionService questionService;
......
......@@ -141,7 +141,7 @@ public class LoginController extends AbstractController {
@Autowired
private UserSessionService userSessionService;
public static final Logger LOGGER = LoggerFactory.getLogger(LoginController.class);
private static final Logger logger = LoggerFactory.getLogger(LoginController.class);
@RequestMapping(value = { "/auth/login", "/doLogin" }, method = { RequestMethod.POST, RequestMethod.GET })
public void doLogin(
......@@ -174,7 +174,7 @@ public class LoginController extends AbstractController {
return;
}
} catch (AuthenticationException e) {
LOGGER.info("Authentication failed: {}", e.getMessage());
logger.info("Authentication failed: {}", e.getMessage());
}
userService.increaseFailedLoginCount(addr);
......@@ -197,9 +197,9 @@ public class LoginController extends AbstractController {
return;
}
LOGGER.info("LDAPLOGIN: {}", auth.isAuthenticated());
logger.info("LDAPLOGIN: {}", auth.isAuthenticated());
} catch (AuthenticationException e) {
LOGGER.info("No LDAP login: {}", e);
logger.info("No LDAP login: {}", e);
}
userService.increaseFailedLoginCount(addr);
......
......@@ -25,8 +25,6 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.PathVariable;
......@@ -49,8 +47,6 @@ import java.util.List;
@Api(value = "/motd", description = "the Motd Controller API")
public class MotdController extends AbstractController {
private static final Logger LOGGER = LoggerFactory.getLogger(MotdController.class);
@Autowired
private IMotdService motdService;
......@@ -72,7 +68,7 @@ public class MotdController extends AbstractController {
client.setTime(Long.parseLong(clientdate));
}
if (adminview) {
if (sessionkey.equals("null")) {
if ("null".equals(sessionkey)) {
motds = motdService.getAdminMotds();
} else {
motds = motdService.getAllSessionMotds(sessionkey);
......@@ -96,7 +92,7 @@ public class MotdController extends AbstractController {
) {
if (motd != null) {
Motd newMotd;
if (motd.getAudience().equals("session") && motd.getSessionkey() != null) {
if ("session".equals(motd.getAudience()) && motd.getSessionkey() != null) {
newMotd = motdService.saveSessionMotd(motd.getSessionkey(), motd);
} else {
newMotd = motdService.saveMotd(motd);
......@@ -118,7 +114,7 @@ public class MotdController extends AbstractController {
@ApiParam(value = "motdkey from current motd", required = true) @PathVariable final String motdkey,
@ApiParam(value = "current motd", required = true) @RequestBody final Motd motd
) {
if (motd.getAudience().equals("session") && motd.getSessionkey() != null) {
if ("session".equals(motd.getAudience()) && motd.getSessionkey() != null) {
return motdService.updateSessionMotd(motd.getSessionkey(), motd);
} else {
return motdService.updateMotd(motd);
......@@ -129,7 +125,7 @@ public class MotdController extends AbstractController {
@RequestMapping(value = "/{motdkey}", method = RequestMethod.DELETE)
public void deleteMotd(@ApiParam(value = "Motd-key from the message that shall be deleted", required = true) @PathVariable final String motdkey) {
Motd motd = motdService.getMotd(motdkey);
if (motd.getAudience().equals("session")) {
if ("session".equals(motd.getAudience())) {
motdService.deleteSessionMotd(motd.getSessionkey(), motd);
} else {
motdService.deleteMotd(motd);
......
......@@ -62,16 +62,19 @@ public class SecurityExceptionControllerAdvice {
@ResponseStatus(HttpStatus.NOT_FOUND)
@ExceptionHandler(NotFoundException.class)
public void handleNotFoundException(final Exception e, final HttpServletRequest request) {
/* No implementation - handled solely by annotations */
}
@ResponseStatus(HttpStatus.UNAUTHORIZED)
@ExceptionHandler(UnauthorizedException.class)
public void handleUnauthorizedException(final Exception e, final HttpServletRequest request) {
/* No implementation - handled solely by annotations */
}
@ResponseStatus(HttpStatus.UNAUTHORIZED)
@ExceptionHandler(AuthenticationCredentialsNotFoundException.class)
public void handleAuthenticationCredentialsNotFoundException(final Exception e, final HttpServletRequest request) {
/* No implementation - handled solely by annotations */
}
@ExceptionHandler(AccessDeniedException.class)
......@@ -95,30 +98,36 @@ public class SecurityExceptionControllerAdvice {
@ResponseStatus(HttpStatus.FORBIDDEN)
@ExceptionHandler(ForbiddenException.class)
public void handleForbiddenException(final Exception e, final HttpServletRequest request) {
/* No implementation - handled solely by annotations */
}
@ResponseStatus(HttpStatus.NO_CONTENT)
@ExceptionHandler(NoContentException.class)
public void handleNoContentException(final Exception e, final HttpServletRequest request) {
/* No implementation - handled solely by annotations */
}
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler(BadRequestException.class)
public void handleBadRequestException(final Exception e, final HttpServletRequest request) {
/* No implementation - handled solely by annotations */
}
@ResponseStatus(HttpStatus.PRECONDITION_FAILED)
@ExceptionHandler(PreconditionFailedException.class)
public void handlePreconditionFailedException(final Exception e, final HttpServletRequest request) {
/* No implementation - handled solely by annotations */
}
@ResponseStatus(HttpStatus.NOT_IMPLEMENTED)
@ExceptionHandler(NotImplementedException.class)
public void handleNotImplementedException(final Exception e, final HttpServletRequest request) {
/* No implementation - handled solely by annotations */
}
@ResponseStatus(HttpStatus.PAYLOAD_TOO_LARGE)
@ExceptionHandler(PayloadTooLargeException.class)
public void handlePayloadTooLargeException(final Exception e, final HttpServletRequest request) {
/* No implementation - handled solely by annotations */
}
}
......@@ -63,7 +63,7 @@ import java.util.List;
@Api(value = "/session", description = "the Session Controller API")
public class SessionController extends PaginationController {
public static final Logger LOGGER = LoggerFactory.getLogger(SessionController.class);
private static final Logger logger = LoggerFactory.getLogger(SessionController.class);
@Autowired
private ISessionService sessionService;
......@@ -172,7 +172,7 @@ public class SessionController extends PaginationController {
) {
List<Session> sessions;
if (!username.equals("")) {
if (!"".equals(username)) {
try {
if (ownedOnly && !visitedOnly) {
sessions = sessionService.getUserSessions(username);
......@@ -206,7 +206,7 @@ public class SessionController extends PaginationController {
return null;
}
if (sortby != null && sortby.equals("shortname")) {
if ("shortname".equals(sortby)) {
Collections.sort(sessions, new SessionShortNameComparator());
} else {
Collections.sort(sessions, new SessionNameComparator());
......@@ -242,7 +242,7 @@ public class SessionController extends PaginationController {
return null;
}
if (sortby != null && sortby.equals("shortname")) {
if ("shortname".equals(sortby)) {
Collections.sort(sessions, new SessionInfoShortNameComparator());
} else {
Collections.sort(sessions, new SessionInfoNameComparator());
......
......@@ -57,7 +57,7 @@ public class SocketController extends AbstractController {
@Autowired
private ARSnovaSocket server;
private static final Logger LOGGER = LoggerFactory.getLogger(SocketController.class);
private static final Logger logger = LoggerFactory.getLogger(SocketController.class);
@ApiOperation(value = "requested to assign Websocket session",
nickname = "authorize")
......@@ -70,13 +70,13 @@ public class SocketController extends AbstractController {
public void authorize(@ApiParam(value = "sessionMap", required = true) @RequestBody final Map <String, String> sessionMap, @ApiParam(value = "response", required = true) final HttpServletResponse response) {
String socketid = sessionMap.get("session");
if (null == socketid) {
LOGGER.debug("Expected property 'session' missing");
logger.debug("Expected property 'session' missing");
response.setStatus(HttpStatus.BAD_REQUEST.value());
return;
}
User u = userService.getCurrentUser();
if (null == u) {
LOGGER.debug("Client {} requested to assign Websocket session but has not authenticated", socketid);
logger.debug("Client {} requested to assign Websocket session but has not authenticated", socketid);
response.setStatus(HttpStatus.FORBIDDEN.value());
return;
}
......
......@@ -48,7 +48,7 @@ public class UserController extends AbstractController {
@Autowired
private UserSessionService userSessionService;
public static final Logger LOGGER = LoggerFactory
private static final Logger logger = LoggerFactory
.getLogger(UserController.class);
@RequestMapping(value = "/register", method = RequestMethod.POST)
......
This diff is collapsed.
......@@ -41,7 +41,7 @@ public class LearningProgressFactory implements NovaEventVisitor, ILearningProgr
@Override
public LearningProgress create(String progressType, String questionVariant) {
VariantLearningProgress learningProgress;
if (progressType.equals("questions")) {
if ("questions".equals(progressType)) {
learningProgress = new QuestionBasedLearningProgress(databaseDao);
} else {
learningProgress = new PointBasedLearningProgress(databaseDao);
......
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