Skip to content
Snippets Groups Projects
Commit 2b18d0a5 authored by Christoph Thelen's avatar Christoph Thelen
Browse files

Checkstyle changes

parent b25d951f
Branches
Tags
No related merge requests found
Showing
with 39 additions and 42 deletions
......@@ -57,7 +57,7 @@ import de.thm.arsnova.services.IUserService;
public class LoginController extends AbstractController {
private static final int MAX_USERNAME_LENGTH = 15;
@Autowired
private TwitterProvider twitterProvider;
......
......@@ -35,7 +35,6 @@ import org.springframework.web.bind.annotation.ResponseBody;
import de.thm.arsnova.entities.Answer;
import de.thm.arsnova.entities.Question;
import de.thm.arsnova.exceptions.ForbiddenException;
import de.thm.arsnova.exceptions.NotFoundException;
import de.thm.arsnova.services.IQuestionService;
......@@ -84,7 +83,10 @@ public class QuestionController extends AbstractController {
return;
}
@RequestMapping(value = { "/getSkillQuestions/{sessionkey}", "/session/{sessionkey}/skillquestions" }, method = RequestMethod.GET)
@RequestMapping(
value = { "/getSkillQuestions/{sessionkey}", "/session/{sessionkey}/skillquestions" },
method = RequestMethod.GET
)
@ResponseBody
public final List<Question> getSkillQuestions(
@PathVariable final String sessionkey,
......@@ -219,7 +221,7 @@ public class QuestionController extends AbstractController {
) {
return questionService.getAnswerCount(sessionKey, questionId);
}
@RequestMapping(value = "/session/{sessionKey}/question/{questionId}/freetextanswers", method = RequestMethod.GET)
@ResponseBody
public final List<Answer> getFreetextAnswers(
......@@ -229,7 +231,7 @@ public class QuestionController extends AbstractController {
) {
return questionService.getFreetextAnswers(sessionKey, questionId);
}
@RequestMapping(value = "/session/{sessionKey}/myanswers", method = RequestMethod.GET)
@ResponseBody
public final List<Answer> getMyAnswers(
......@@ -238,7 +240,7 @@ public class QuestionController extends AbstractController {
) {
return questionService.getMytAnswers(sessionKey);
}
@RequestMapping(value = "/session/{sessionKey}/answercount", method = RequestMethod.GET)
@ResponseBody
public final int getTotalAnswerCount(
......@@ -247,7 +249,7 @@ public class QuestionController extends AbstractController {
) {
return questionService.getTotalAnswerCount(sessionKey);
}
@RequestMapping(value = "/session/{sessionKey}/interposedcount", method = RequestMethod.GET)
@ResponseBody
public final int getInterposedCount(
......@@ -256,7 +258,7 @@ public class QuestionController extends AbstractController {
) {
return questionService.getInterposedCount(sessionKey);
}
@RequestMapping(value = "/session/{sessionKey}/interposed", method = RequestMethod.GET)
@ResponseBody
public final List<Question> getInterposedQuestions(
......
......@@ -204,18 +204,18 @@ public class CouchDBDao implements IDatabaseDao {
if (session == null) {
throw new NotFoundException();
}
User user = this.userService.getCurrentUser();
View view = null;
try {
if(session.getCreator().equals(user.getUsername())) {
if (session.getCreator().equals(user.getUsername())) {
view = new View("skill_question/by_session_sorted_by_subject_and_text");
view.setStartKey("[" + URLEncoder.encode("\"" + session.get_id() + "\"", "UTF-8") + "]");
view.setEndKey("[" + URLEncoder.encode("\"" + session.get_id() + "\",{}", "UTF-8") + "]");
} else {
if(user.getType().equals(User.THM)) {
if (user.getType().equals(User.THM)) {
view = new View("skill_question/by_session_for_thm");
} else {
view = new View("skill_question/by_session_for_all");
......@@ -891,7 +891,9 @@ public class CouchDBDao implements IDatabaseDao {
public final int countActiveUsers(Session session, long since) {
try {
View view = new View("logged_in/count");
view.setStartKey(URLEncoder.encode("[\"" + session.get_id() + "\", " + String.valueOf(since) + "]", "UTF-8"));
view.setStartKey(
URLEncoder.encode("[\"" + session.get_id() + "\", " + String.valueOf(since) + "]", "UTF-8")
);
view.setEndKey(URLEncoder.encode("[\"" + session.get_id() + "\", {}]", "UTF-8"));
ViewResults results = this.getDatabase().view(view);
if (isEmptyResults(results)) {
......@@ -934,19 +936,19 @@ public class CouchDBDao implements IDatabaseDao {
}
return null;
}
@Override
public List<Answer> getMyAnswers(String sessionKey) {
Session s = this.getSessionFromKeyword(sessionKey);
if (s == null) {
throw new NotFoundException();
}
User user = userService.getCurrentUser();
if(user == null) {
if (user == null) {
throw new UnauthorizedException();
}
try {
View view = new View("answer/by_user_and_session");
view.setKey("[" + URLEncoder.encode("\"" + user.getUsername() + "\",\"" + s.get_id() + "\"", "UTF-8") + "]");
......@@ -962,15 +964,12 @@ public class CouchDBDao implements IDatabaseDao {
answers.add(a);
}
return answers;
} catch (UnsupportedEncodingException e) {
LOGGER.error("Error while retrieving user answers", e);
}
return null;
}
@Override
public int getTotalAnswerCount(String sessionKey) {
Session s = this.getSessionFromKeyword(sessionKey);
......@@ -982,7 +981,7 @@ public class CouchDBDao implements IDatabaseDao {
View view = new View("skill_question/count_answers_by_session");
view.setKey(URLEncoder.encode("\"" + s.get_id() + "\"", "UTF-8"));
ViewResults results = this.getDatabase().view(view);
if(results.size() == 0) {
if (results.size() == 0) {
return 0;
}
return results.getJSONArray("rows").optJSONObject(0).optInt("value");
......@@ -991,7 +990,7 @@ public class CouchDBDao implements IDatabaseDao {
}
return 0;
}
@Override
public int getInterposedCount(String sessionKey) {
Session s = this.getSessionFromKeyword(sessionKey);
......@@ -1004,7 +1003,7 @@ public class CouchDBDao implements IDatabaseDao {
view.setKey(URLEncoder.encode("\"" + s.get_id() + "\"", "UTF-8"));
view.setGroup(true);
ViewResults results = this.getDatabase().view(view);
if(results.size() == 0 || results.getResults().size() == 0) {
if (results.size() == 0 || results.getResults().size() == 0) {
return 0;
}
return results.getJSONArray("rows").optJSONObject(0).optInt("value");
......@@ -1013,14 +1012,14 @@ public class CouchDBDao implements IDatabaseDao {
}
return 0;
}
@Override
public List<Question> getInterposedQuestions(String sessionKey) {
Session s = this.getSessionFromKeyword(sessionKey);
if (s == null) {
throw new NotFoundException();
}
try {
View view = new View("interposed_question/by_session");
view.setKey(URLEncoder.encode("\"" + s.get_id() + "\"", "UTF-8"));
......@@ -1038,7 +1037,6 @@ public class CouchDBDao implements IDatabaseDao {
question.setSession(s.get_id());
result.add(question);
}
return result;
} catch (UnsupportedEncodingException e) {
LOGGER.error("Error while retrieving interposed questions", e);
......
......@@ -2,7 +2,7 @@ package de.thm.arsnova.entities;
public class Answer {
private String _id;
private String _rev;
private String type;
......@@ -17,7 +17,7 @@ public class Answer {
public Answer() {
this.type = "skill_question_answer";
}
public final String get_id() {
return _id;
}
......@@ -74,7 +74,7 @@ public class Answer {
this.answerText = answerText;
}
public final String getAnswerSubject() {
return answerSubject;
}
......@@ -82,7 +82,7 @@ public class Answer {
public final void setAnswerSubject(final String answerSubject) {
this.answerSubject = answerSubject;
}
public final String getSubject() {
return answerSubject;
}
......@@ -118,7 +118,7 @@ public class Answer {
@Override
public final String toString() {
return "Answer type:'" + type + "'"
+ ", session: " + sessionId
+ ", session: " + sessionId
+ ", question: " + questionId
+ ", subject: " + answerSubject
+ ", answerCount: " + answerCount
......
/*
* Copyright (C) 2012 THM webMedia
*
*
* This file is part of ARSnova.
*
* ARSnova is free software: you can redistribute it and/or modify
......
/*
* Copyright (C) 2012 THM webMedia
*
*
* This file is part of ARSnova.
*
* ARSnova is free software: you can redistribute it and/or modify
......
/*
* Copyright (C) 2012 THM webMedia
*
*
* This file is part of ARSnova.
*
* ARSnova is free software: you can redistribute it and/or modify
......
......@@ -16,9 +16,7 @@ public class User implements Serializable {
public static final String THM = "thm";
public static final String LDAP = "ldap";
public static final String ANONYMOUS = "anonymous";
private static final long serialVersionUID = 1L;
private String username;
private String type;
......@@ -60,7 +58,7 @@ public class User implements Serializable {
public void setUsername(String username) {
this.username = username;
}
public String getType() {
return type;
}
......
/*
* Copyright (C) 2012 THM webMedia
*
*
* This file is part of ARSnova.
*
* ARSnova is free software: you can redistribute it and/or modify
......
......@@ -25,5 +25,4 @@ public class Feedback {
public String toString() {
return "Feedback, sessionkey: " + sessionkey + ", value: " + value;
}
}
\ No newline at end of file
}
package de.thm.arsnova.socket.message;
\ No newline at end of file
package de.thm.arsnova.socket.message;
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