Skip to content
Snippets Groups Projects
Commit 986ede41 authored by Julian Hochstetter's avatar Julian Hochstetter
Browse files

Merge branch 'master' of gitorious@scm.thm.de:arsnova/arsnova-war.git

Conflicts:
	src/main/java/de/thm/arsnova/controller/QuestionController.java
	src/main/java/de/thm/arsnova/dao/CouchDBDao.java
	src/main/java/de/thm/arsnova/dao/IDatabaseDao.java
	src/main/java/de/thm/arsnova/entities/Question.java
	src/main/java/de/thm/arsnova/entities/User.java
	src/main/java/de/thm/arsnova/services/IQuestionService.java
	src/test/java/de/thm/arsnova/controller/LoginControllerTest.java
parents 26a359bf 427a1873
Branches
Tags
No related merge requests found
Showing
with 633 additions and 304 deletions
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.2//EN"
"http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
<!--
Checkstyle configuration that checks the sun coding conventions from:
- the Java Language Specification at
http://java.sun.com/docs/books/jls/second_edition/html/index.html
- the Sun Code Conventions at http://java.sun.com/docs/codeconv/
- the Javadoc guidelines at
http://java.sun.com/j2se/javadoc/writingdoccomments/index.html
- the JDK Api documentation http://java.sun.com/j2se/docs/api/index.html
- some best practices
Checkstyle is very configurable. Be sure to read the documentation at
http://checkstyle.sf.net (or in your downloaded distribution).
Most Checks are configurable, be sure to consult the documentation.
To completely disable a check, just comment it out or delete it from the file.
Finally, it is worth reading the documentation.
-->
<module name="Checker">
<!--
If you set the basedir property below, then all reported file
names will be relative to the specified directory. See
http://checkstyle.sourceforge.net/5.x/config.html#Checker
<property name="basedir" value="${basedir}"/>
-->
<!-- Checks that each Java package has a Javadoc file used for commenting. -->
<!-- See http://checkstyle.sf.net/config_javadoc.html#JavadocPackage -->
<module name="JavadocPackage">
<property name="allowLegacy" value="true"/>
</module>
<!-- Checks whether files end with a new line. -->
<!-- See http://checkstyle.sf.net/config_misc.html#NewlineAtEndOfFile -->
<module name="NewlineAtEndOfFile"/>
<!-- Checks that property files contain the same keys. -->
<!-- See http://checkstyle.sf.net/config_misc.html#Translation -->
<module name="Translation"/>
<module name="FileLength"/>
<!-- Following interprets the header file as regular expressions. -->
<!-- <module name="RegexpHeader"/> -->
<!--module name="FileTabCharacter">
<property name="eachLine" value="true"/>
</module-->
<module name="RegexpSingleline">
<!-- \s matches whitespace character, $ matches end of line. -->
<property name="format" value="\s+$"/>
<property name="message" value="Line has trailing spaces."/>
</module>
<module name="TreeWalker">
<property name="cacheFile" value="${checkstyle.cache.file}"/>
<!-- Checks for Javadoc comments. -->
<!-- See http://checkstyle.sf.net/config_javadoc.html -->
<!-- module name="JavadocMethod">
<property name="allowMissingJavadoc" value="true"/>
</module>
<module name="JavadocType"/>
<module name="JavadocVariable"/>
<module name="JavadocStyle"/-->
<!-- Checks for Naming Conventions. -->
<!-- See http://checkstyle.sf.net/config_naming.html -->
<module name="ConstantName"/>
<module name="LocalFinalVariableName"/>
<module name="LocalVariableName"/>
<module name="MemberName"/>
<module name="MethodName"/>
<module name="PackageName"/>
<module name="ParameterName"/>
<module name="StaticVariableName"/>
<module name="TypeName"/>
<!-- Checks for Headers -->
<!-- See http://checkstyle.sf.net/config_header.html -->
<!-- <module name="Header"> -->
<!-- The follow property value demonstrates the ability -->
<!-- to have access to ANT properties. In this case it uses -->
<!-- the ${basedir} property to allow Checkstyle to be run -->
<!-- from any directory within a project. See property -->
<!-- expansion, -->
<!-- http://checkstyle.sf.net/config.html#properties -->
<!-- <property -->
<!-- name="headerFile" -->
<!-- value="${basedir}/java.header"/> -->
<!-- </module> -->
<!-- Checks for imports -->
<!-- See http://checkstyle.sf.net/config_import.html -->
<module name="AvoidStarImport"/>
<module name="IllegalImport"/> <!-- defaults to sun.* packages -->
<module name="RedundantImport"/>
<module name="UnusedImports"/>
<!-- Checks for Size Violations. -->
<!-- See http://checkstyle.sf.net/config_sizes.html -->
<module name="LineLength">
<property name="max" value="120" />
</module>
<module name="MethodLength"/>
<module name="ParameterNumber"/>
<!-- Checks for whitespace -->
<!-- See http://checkstyle.sf.net/config_whitespace.html -->
<module name="EmptyForIteratorPad"/>
<module name="MethodParamPad"/>
<module name="NoWhitespaceAfter"/>
<module name="NoWhitespaceBefore"/>
<module name="OperatorWrap"/>
<module name="ParenPad"/>
<module name="TypecastParenPad"/>
<module name="WhitespaceAfter"/>
<module name="WhitespaceAround"/>
<!-- Modifier Checks -->
<!-- See http://checkstyle.sf.net/config_modifiers.html -->
<module name="ModifierOrder"/>
<module name="RedundantModifier"/>
<!-- Checks for blocks. You know, those {}'s -->
<!-- See http://checkstyle.sf.net/config_blocks.html -->
<module name="AvoidNestedBlocks"/>
<module name="EmptyBlock"/>
<module name="LeftCurly"/>
<module name="NeedBraces"/>
<module name="RightCurly"/>
<!-- Checks for common coding problems -->
<!-- See http://checkstyle.sf.net/config_coding.html -->
<module name="AvoidInlineConditionals"/>
<module name="DoubleCheckedLocking"/> <!-- MY FAVOURITE -->
<module name="EmptyStatement"/>
<module name="EqualsHashCode"/>
<module name="HiddenField"/>
<module name="IllegalInstantiation"/>
<module name="InnerAssignment"/>
<module name="MagicNumber"/>
<module name="MissingSwitchDefault"/>
<module name="RedundantThrows"/>
<module name="SimplifyBooleanExpression"/>
<module name="SimplifyBooleanReturn"/>
<!-- Checks for class design -->
<!-- See http://checkstyle.sf.net/config_design.html -->
<module name="DesignForExtension"/>
<module name="FinalClass"/>
<module name="HideUtilityClassConstructor"/>
<module name="InterfaceIsType"/>
<module name="VisibilityModifier"/>
<!-- Miscellaneous other checks. -->
<!-- See http://checkstyle.sf.net/config_misc.html -->
<module name="ArrayTypeStyle"/>
<module name="FinalParameters"/>
<module name="TodoComment"/>
<module name="UpperEll"/>
</module>
</module>
......@@ -92,6 +92,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9</version>
<configuration></configuration>
</plugin>
<plugin>
......@@ -100,6 +101,14 @@
<version>2.5.2</version>
<configuration></configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.9.1</version>
<configuration>
<configLocation>ARSnova-checkstyle-checker.xml</configLocation>
</configuration>
</plugin>
</plugins>
</reporting>
......@@ -339,6 +348,14 @@
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.4</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.9.1</version>
<configuration>
<configLocation>ARSnova-checkstyle-checker.xml</configLocation>
</configuration>
</plugin>
</plugins>
</build>
......
......@@ -15,33 +15,36 @@ import org.springframework.security.web.authentication.logout.LogoutSuccessHandl
public class CASLogoutSuccessHandler implements LogoutSuccessHandler {
public static final Logger logger = LoggerFactory.getLogger(CASLogoutSuccessHandler.class);
public static final Logger LOGGER = LoggerFactory.getLogger(CASLogoutSuccessHandler.class);
private String casUrl;
private String defaultTarget;
private RedirectStrategy redirectStrategy = new DefaultRedirectStrategy();
@Override
public void onLogoutSuccess(HttpServletRequest request,
HttpServletResponse response, Authentication authentication)
throws IOException, ServletException {
public final void onLogoutSuccess(
final HttpServletRequest request,
final HttpServletResponse response,
final Authentication authentication
) throws IOException, ServletException {
String referer = request.getHeader("referer");
if (response.isCommitted()) {
logger.info("Response has already been committed. Unable to redirect to target");
return;
}
redirectStrategy.sendRedirect(request, response,
(casUrl + "/logout?url=") + (referer != null ? referer : defaultTarget));
if (response.isCommitted()) {
LOGGER.info("Response has already been committed. Unable to redirect to target");
return;
}
redirectStrategy.sendRedirect(
request,
response,
(casUrl + "/logout?url=") + (referer != null ? referer : defaultTarget)
);
}
public void setCasUrl(String casUrl) {
this.casUrl = casUrl;
public final void setCasUrl(final String newCasUrl) {
casUrl = newCasUrl;
}
public void setDefaultTarget(String defaultTarget) {
this.defaultTarget = defaultTarget;
public final void setDefaultTarget(final String newDefaultTarget) {
defaultTarget = newDefaultTarget;
}
}
/*
* Copyright (C) 2012 THM webMedia
*
*
* This file is part of ARSnova.
*
* ARSnova is free software: you can redistribute it and/or modify
......@@ -30,13 +30,22 @@ import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.stereotype.Service;
@Service
public class CasUserDetailsService extends AbstractCasAssertionUserDetailsService {
public class CasUserDetailsService extends
AbstractCasAssertionUserDetailsService {
@Override
protected UserDetails loadUserDetails(Assertion assertion) {
protected final UserDetails loadUserDetails(final Assertion assertion) {
final List<GrantedAuthority> grantedAuthorities = new ArrayList<GrantedAuthority>();
grantedAuthorities.add(new GrantedAuthorityImpl("ROLE_USER"));
return new User(assertion.getPrincipal().getName(), "", true, true, true, true, grantedAuthorities);
return new User(
assertion.getPrincipal().getName(),
"",
true,
true,
true,
true,
grantedAuthorities
);
}
}
/*
* Copyright (C) 2012 THM webMedia
*
*
* This file is part of ARSnova.
*
* ARSnova is free software: you can redistribute it and/or modify
......@@ -30,25 +30,27 @@ import org.springframework.security.web.DefaultRedirectStrategy;
import org.springframework.security.web.RedirectStrategy;
import org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler;
public class LoginAuthenticationFailureHandler extends SimpleUrlAuthenticationFailureHandler {
public class LoginAuthenticationFailureHandler extends
SimpleUrlAuthenticationFailureHandler {
private RedirectStrategy redirectStrategy = new DefaultRedirectStrategy();
private String defaultFailureUrl;
@Override
public void onAuthenticationFailure(HttpServletRequest request,
HttpServletResponse response, AuthenticationException exception)
throws IOException, ServletException {
public final void onAuthenticationFailure(
final HttpServletRequest request,
final HttpServletResponse response,
final AuthenticationException exception
) throws IOException, ServletException {
HttpSession session = request.getSession();
if (session != null && session.getAttribute("ars-referer") != null) {
defaultFailureUrl = (String) session.getAttribute("ars-referer");
}
redirectStrategy.sendRedirect(request, response, defaultFailureUrl);
}
public void setDefaultFailureUrl(String defaultFailureUrl) {
public final void setDefaultFailureUrl(final String defaultFailureUrl) {
this.defaultFailureUrl = defaultFailureUrl;
}
......
......@@ -24,13 +24,16 @@ import javax.servlet.http.HttpSession;
import org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler;
public class LoginAuthenticationSucessHandler extends SimpleUrlAuthenticationSuccessHandler {
public class LoginAuthenticationSucessHandler extends
SimpleUrlAuthenticationSuccessHandler {
private String targetUrl;
@Override
protected String determineTargetUrl(HttpServletRequest request,
HttpServletResponse response) {
protected final String determineTargetUrl(
final HttpServletRequest request,
final HttpServletResponse response
) {
HttpSession session = request.getSession();
if (session == null || session.getAttribute("ars-referer") == null) {
return targetUrl;
......@@ -38,8 +41,8 @@ public class LoginAuthenticationSucessHandler extends SimpleUrlAuthenticationSuc
String referer = (String) session.getAttribute("ars-referer");
return referer + targetUrl;
}
public void setTargetUrl(String targetUrl) {
public final void setTargetUrl(final String targetUrl) {
this.targetUrl = targetUrl;
}
}
/*
* Copyright (C) 2012 THM webMedia
*
*
* This file is part of ARSnova.
*
* ARSnova is free software: you can redistribute it and/or modify
......@@ -30,11 +30,19 @@ import org.springframework.stereotype.Service;
@Service
public class OpenidUserDetailsService implements UserDetailsService {
public UserDetails loadUserByUsername(String openIdIdentifier) {
public final UserDetails loadUserByUsername(final String openIdIdentifier) {
final List<GrantedAuthority> grantedAuthorities = new ArrayList<GrantedAuthority>();
grantedAuthorities.add(new GrantedAuthorityImpl("ROLE_USER"));
return new User(openIdIdentifier, "", true, true, true, true, grantedAuthorities);
}
}
\ No newline at end of file
return new User(
openIdIdentifier,
"",
true,
true,
true,
true,
grantedAuthorities
);
}
}
package de.thm.arsnova.annotation;
......@@ -11,32 +11,38 @@ import de.thm.arsnova.services.IUserService;
@Aspect
public class AuthorizationAdviser {
static IUserService userService;
public void setUserService(IUserService uService) {
private static IUserService userService;
public final void setUserService(final IUserService uService) {
userService = uService;
}
/** This method checks if the user has a valid authorization from security context
*
/**
* This method checks if the user has a valid authorization from security
* context
*
* @param authenticated
* @param object
*/
@Before("execution(public * de.thm.arsnova.services.*.*(..)) && @annotation(authenticated) && this(object)")
public void checkAuthorization(Authenticated authenticated, Object object) {
public final void checkAuthorization(final Authenticated authenticated, final Object object) {
User u = userService.getCurrentUser();
if (u == null) throw new UnauthorizedException();
// TODO: For unauthorized users e.g. after logout there is still a user object with username 'anonymous'
if (u.getUsername().equals("anonymous")) throw new UnauthorizedException();
if (u == null) {
throw new UnauthorizedException();
}
if (u.getUsername().equals("anonymous")) {
throw new UnauthorizedException();
}
}
/** This method checks if the user is enlisted in current ARSnova session
/**
* This method checks if the user is enlisted in current ARSnova session
*
* @param authenticated
* @param object
*/
@Before("execution(public * de.thm.arsnova.services.*.*(..)) && @annotation(authenticated) && this(object)")
public void checkSessionMembership(Authenticated authenticated, Object object) {
//TODO: Implement check based on session membership lists
public final void checkSessionMembership(final Authenticated authenticated, final Object object) {
/// TODO: Implement check based on session membership lists
}
}
package de.thm.arsnova.aop;
......@@ -13,19 +13,21 @@ import de.thm.arsnova.exceptions.UnauthorizedException;
public class AbstractController {
@ResponseStatus(HttpStatus.NOT_FOUND)
@ExceptionHandler(NotFoundException.class)
public void handleNotFoundException(Exception e, HttpServletRequest request) {
public void handleNotFoundException(final Exception e, HttpServletRequest request) {
}
@ResponseStatus(HttpStatus.FORBIDDEN)
@ExceptionHandler(ForbiddenException.class)
public void handleForbiddenException(Exception e, HttpServletRequest request) {
public void handleForbiddenException(final Exception e, HttpServletRequest request) {
}
@ResponseStatus(HttpStatus.UNAUTHORIZED)
@ExceptionHandler(UnauthorizedException.class)
public void handleUnauthorizedException(Exception e, HttpServletRequest request) {
public void handleUnauthorizedException(final Exception e, HttpServletRequest request) {
}
@ResponseStatus(HttpStatus.NO_CONTENT)
@ExceptionHandler(UnauthorizedException.class)
public void handleNoContentException(final Exception e, HttpServletRequest request) {
}
}
......@@ -39,37 +39,58 @@ import de.thm.arsnova.socket.ARSnovaSocketIOServer;
@Controller
public class FeedbackController extends AbstractController {
public static final Logger logger = LoggerFactory.getLogger(FeedbackController.class);
@Autowired
IFeedbackService feedbackService;
@Autowired
IUserService userService;
@Autowired
ARSnovaSocketIOServer server;
@RequestMapping(value="/session/{sessionkey}/feedback", method=RequestMethod.GET)
@RequestMapping(value = "/session/{sessionkey}/feedback", method = RequestMethod.GET)
@ResponseBody
public Feedback getFeedback(@PathVariable String sessionkey) {
return feedbackService.getFeedback(sessionkey);
}
@RequestMapping(value="/session/{sessionkey}/feedbackcount", method=RequestMethod.GET)
@RequestMapping(value = "/session/{sessionkey}/myfeedback", method = RequestMethod.GET)
@ResponseBody
public Integer getMyFeedback(@PathVariable String sessionkey, HttpServletResponse response) {
Integer value = feedbackService.getMyFeedback(sessionkey, userService.getCurrentUser());
if (value != null && value >= 0 && value <= 3) {
return value;
}
response.setStatus(HttpStatus.NOT_FOUND.value());
return null;
}
@RequestMapping(value = "/session/{sessionkey}/feedbackcount", method = RequestMethod.GET)
@ResponseBody
public int getFeedbackCount(@PathVariable String sessionkey) {
return feedbackService.getFeedbackCount(sessionkey);
}
@RequestMapping(value = "/session/{sessionkey}/roundedaveragefeedback", method = RequestMethod.GET)
@ResponseBody
public long getAverageFeedbackRounded(
@PathVariable String sessionkey
) {
return feedbackService.getAverageFeedbackRounded(sessionkey);
}
@RequestMapping(value="/session/{sessionkey}/averagefeedback", method=RequestMethod.GET)
@RequestMapping(value = "/session/{sessionkey}/averagefeedback", method = RequestMethod.GET)
@ResponseBody
public long getAverageFeedback(@PathVariable String sessionkey) {
public double getAverageFeedback(
@PathVariable String sessionkey
) {
return feedbackService.getAverageFeedback(sessionkey);
}
@RequestMapping(value="/session/{sessionkey}/feedback", method=RequestMethod.POST)
@RequestMapping(value = "/session/{sessionkey}/feedback", method = RequestMethod.POST)
@ResponseBody
public Feedback postFeedback(@PathVariable String sessionkey, @RequestBody int value, HttpServletResponse response) {
User user = userService.getCurrentUser();
......@@ -80,11 +101,11 @@ public class FeedbackController extends AbstractController {
response.setStatus(HttpStatus.CREATED.value());
return feedback;
}
response.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
return null;
}
response.setStatus(HttpStatus.BAD_REQUEST.value());
return null;
}
......
......@@ -58,53 +58,68 @@ public class LoginController extends AbstractController {
@Autowired
TwitterProvider twitterProvider;
@Autowired
Google2Provider googleProvider;
@Autowired
FacebookProvider facebookProvider;
@Autowired
CasAuthenticationEntryPoint casEntryPoint;
@Autowired
IUserService userService;
public static final Logger logger = LoggerFactory.getLogger(LoginController.class);
public static final Logger logger = LoggerFactory
.getLogger(LoginController.class);
@RequestMapping(method = RequestMethod.GET, value = "/doLogin")
public View doLogin(@RequestParam("type") String type, @RequestParam(value="user", required=false) String guestName, HttpServletRequest request, HttpServletResponse response)
public View doLogin(@RequestParam("type") String type,
@RequestParam(value = "user", required = false) String guestName,
HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
String referer = request.getHeader("referer");
request.getSession().setAttribute("ars-referer", referer);
if("cas".equals(type)) {
if ("cas".equals(type)) {
casEntryPoint.commence(request, response, null);
} else if("twitter".equals(type)) {
String authUrl = twitterProvider.getAuthorizationUrl(new HttpUserSession(request));
} else if ("twitter".equals(type)) {
String authUrl = twitterProvider
.getAuthorizationUrl(new HttpUserSession(request));
return new RedirectView(authUrl);
} else if("facebook".equals(type)) {
String authUrl = facebookProvider.getAuthorizationUrl(new HttpUserSession(request));
} else if ("facebook".equals(type)) {
String authUrl = facebookProvider
.getAuthorizationUrl(new HttpUserSession(request));
return new RedirectView(authUrl);
} else if("google".equals(type)) {
String authUrl = googleProvider.getAuthorizationUrl(new HttpUserSession(request));
} else if ("google".equals(type)) {
String authUrl = googleProvider
.getAuthorizationUrl(new HttpUserSession(request));
return new RedirectView(authUrl);
} else if("guest".equals(type)) {
} else if ("guest".equals(type)) {
List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>();
authorities.add(new SimpleGrantedAuthority("ROLE_GUEST"));
String username = "";
if(guestName != null && guestName.startsWith("Guest") && guestName.length() == 15) {
if (guestName != null && guestName.startsWith("Guest")
&& guestName.length() == 15) {
username = guestName;
} else {
username = "Guest" + Sha512DigestUtils.shaHex(request.getSession().getId()).substring(0, 10);
}
org.springframework.security.core.userdetails.User user =
new org.springframework.security.core.userdetails.User(username, "", true, true, true, true, authorities);
Authentication token = new UsernamePasswordAuthenticationToken(user, null, authorities);
username = "Guest"
+ Sha512DigestUtils
.shaHex(request.getSession().getId())
.substring(0, 10);
}
org.springframework.security.core.userdetails.User user = new org.springframework.security.core.userdetails.User(
username, "", true, true, true, true, authorities);
Authentication token = new UsernamePasswordAuthenticationToken(
user, null, authorities);
SecurityContextHolder.getContext().setAuthentication(token);
request.getSession(true).setAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY, SecurityContextHolder.getContext());
return new RedirectView((referer != null ? referer : "/") + "#auth/checkLogin");
request.getSession(true)
.setAttribute(
HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY,
SecurityContextHolder.getContext());
return new RedirectView((referer != null ? referer : "/")
+ "#auth/checkLogin");
}
return null;
}
......@@ -117,12 +132,15 @@ public class LoginController extends AbstractController {
@RequestMapping(method = RequestMethod.GET, value = "/logout")
public View doLogout(final HttpServletRequest request) {
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
Authentication auth = SecurityContextHolder.getContext()
.getAuthentication();
request.getSession().invalidate();
SecurityContextHolder.clearContext();
if (auth instanceof CasAuthenticationToken) {
return new RedirectView("/j_spring_cas_security_logout");
}
return new RedirectView(request.getHeader("referer") != null ? request.getHeader("referer") : "/" );
return new RedirectView(
request.getHeader("referer") != null ? request
.getHeader("referer") : "/");
}
}
......@@ -31,6 +31,7 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
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 de.thm.arsnova.entities.Question;
......@@ -39,60 +40,60 @@ import de.thm.arsnova.services.IQuestionService;
import de.thm.arsnova.services.IUserService;
import de.thm.arsnova.socket.ARSnovaSocketIOServer;
@Controller
public class QuestionController extends AbstractController {
public static final Logger logger = LoggerFactory.getLogger(QuestionController.class);
public static final Logger logger = LoggerFactory
.getLogger(QuestionController.class);
@Autowired
IQuestionService questionService;
@Autowired
IUserService userService;
@Autowired
ARSnovaSocketIOServer server;
@RequestMapping(value="/session/{sessionkey}/question/{questionId}", method=RequestMethod.GET)
@RequestMapping(value = "/session/{sessionkey}/question/{questionId}", method = RequestMethod.GET)
@ResponseBody
public Question getQuestion(@PathVariable String sessionkey, @PathVariable String questionId, HttpServletResponse response) {
public Question getQuestion(@PathVariable String sessionkey,
@PathVariable String questionId, HttpServletResponse response) {
Question question = questionService.getQuestion(questionId, sessionkey);
if (question != null) {
return question;
}
}
response.setStatus(HttpStatus.NOT_FOUND.value());
return null;
}
@RequestMapping(value="/session/{sessionkey}/question", method=RequestMethod.POST)
@RequestMapping(value = "/session/{sessionkey}/question", method = RequestMethod.POST)
@ResponseBody
public void postQuestion(@PathVariable String sessionkey, @RequestBody Question question, HttpServletResponse response) {
if (! sessionkey.equals(question.getSession())) {
public void postQuestion(@PathVariable String sessionkey,
@RequestBody Question question, HttpServletResponse response) {
if (!sessionkey.equals(question.getSession())) {
response.setStatus(HttpStatus.PRECONDITION_FAILED.value());
return;
}
if (questionService.saveQuestion(question)) {
response.setStatus(HttpStatus.CREATED.value());
return;
}
response.setStatus(HttpStatus.BAD_REQUEST.value());
return;
}
@RequestMapping(
value={
"/getSkillQuestions/{sessionkey}",
"/session/{sessionkey}/skillquestions"
},
method=RequestMethod.GET
)
@RequestMapping(value = { "/getSkillQuestions/{sessionkey}",
"/session/{sessionkey}/skillquestions" }, method = RequestMethod.GET)
@ResponseBody
public List<Question> getSkillQuestions(@PathVariable String sessionkey, HttpServletResponse response) {
List<Question> questions = questionService.getSkillQuestions(sessionkey);
if(questions == null || questions.isEmpty()) {
public List<Question> getSkillQuestions(@PathVariable String sessionkey,
HttpServletResponse response) {
List<Question> questions = questionService
.getSkillQuestions(sessionkey);
if (questions == null || questions.isEmpty()) {
response.setStatus(HttpStatus.NOT_FOUND.value());
return null;
}
......
......@@ -47,53 +47,60 @@ import de.thm.arsnova.socket.ARSnovaSocketIOServer;
@Controller
public class SessionController extends AbstractController {
public static final Logger logger = LoggerFactory.getLogger(SessionController.class);
public static final Logger logger = LoggerFactory
.getLogger(SessionController.class);
@Autowired
ISessionService sessionService;
@Autowired
IUserService userService;
@Autowired
ARSnovaSocketIOServer server;
@RequestMapping(method = RequestMethod.POST, value = "/authorize")
public void authorize(@RequestBody Object sessionObject, HttpServletResponse response) {
String socketid = (String) JSONObject.fromObject(sessionObject).get("session");
if(socketid == null) {
public void authorize(@RequestBody Object sessionObject,
HttpServletResponse response) {
String socketid = (String) JSONObject.fromObject(sessionObject).get(
"session");
if (socketid == null) {
return;
}
}
User u = userService.getCurrentUser();
logger.info("authorize session: " + socketid + ", user is: " + u);
response.setStatus(u != null ? HttpStatus.CREATED.value() : HttpStatus.UNAUTHORIZED.value());
response.setStatus(u != null ? HttpStatus.CREATED.value()
: HttpStatus.UNAUTHORIZED.value());
userService.putUser2SessionID(UUID.fromString(socketid), u);
}
@RequestMapping(value="/session/{sessionkey}", method=RequestMethod.GET)
@RequestMapping(value = "/session/{sessionkey}", method = RequestMethod.GET)
@ResponseBody
public Session joinSession(@PathVariable String sessionkey) {
return sessionService.joinSession(sessionkey);
}
@RequestMapping(value="/session/{sessionkey}/online", method=RequestMethod.POST)
@RequestMapping(value = "/session/{sessionkey}/online", method = RequestMethod.POST)
@ResponseBody
public LoggedIn registerAsOnlineUser(@PathVariable String sessionkey, HttpServletResponse response) {
public LoggedIn registerAsOnlineUser(@PathVariable String sessionkey,
HttpServletResponse response) {
User user = userService.getCurrentUser();
LoggedIn loggedIn = sessionService.registerAsOnlineUser(user, sessionkey);
LoggedIn loggedIn = sessionService.registerAsOnlineUser(user,
sessionkey);
if (loggedIn != null) {
response.setStatus(HttpStatus.CREATED.value());
return loggedIn;
}
response.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
return null;
}
@RequestMapping(value="/session", method=RequestMethod.POST)
@RequestMapping(value = "/session", method = RequestMethod.POST)
@ResponseBody
public Session postNewSession(@RequestBody Session session, HttpServletResponse response) {
public Session postNewSession(@RequestBody Session session,
HttpServletResponse response) {
Session newSession = sessionService.saveSession(session);
if (session != null) {
response.setStatus(HttpStatus.CREATED.value());
......@@ -104,22 +111,22 @@ public class SessionController extends AbstractController {
return null;
}
@RequestMapping(value="/socketurl", method=RequestMethod.GET)
@RequestMapping(value = "/socketurl", method = RequestMethod.GET)
@ResponseBody
public String getSocketUrl() {
StringBuilder url = new StringBuilder();
url.append(server.isUseSSL() ? "https://" : "http://");
url.append(server.getHostIp() + ":" + server.getPortNumber());
return url.toString();
}
@RequestMapping(value={"/mySessions","/session/mysessions"}, method=RequestMethod.GET)
@RequestMapping(value = { "/mySessions", "/session/mysessions" }, method = RequestMethod.GET)
@ResponseBody
public List<Session> getMySession(HttpServletResponse response) {
String username = userService.getCurrentUser().getUsername();
if(username == null) {
if (username == null) {
response.setStatus(HttpStatus.NOT_FOUND.value());
return null;
}
......
package de.thm.arsnova.controller;
......@@ -70,21 +70,21 @@ import de.thm.arsnova.services.IUserService;
public class CouchDBDao implements IDatabaseDao {
@Autowired
IUserService userService;
@Autowired
IFeedbackService feedbackService;
@Autowired
ISessionService sessionService;
private String databaseHost;
private int databasePort;
private String databaseName;
private Database database;
//
public static final Logger logger = LoggerFactory.getLogger(CouchDBDao.class);
@Value("${couchdb.host}")
......@@ -92,19 +92,19 @@ public class CouchDBDao implements IDatabaseDao {
logger.info(databaseHost);
this.databaseHost = databaseHost;
}
@Value("${couchdb.port}")
public final void setDatabasePort(String databasePort) {
logger.info(databasePort);
this.databasePort = Integer.parseInt(databasePort);
}
@Value("${couchdb.name}")
public final void setDatabaseName(String databaseName) {
logger.info(databaseName);
this.databaseName = databaseName;
}
/**
* This method cleans up old feedback votes at the scheduled interval.
*/
......@@ -112,10 +112,10 @@ public class CouchDBDao implements IDatabaseDao {
public void cleanFeedbackVotes(int cleanupFeedbackDelay) {
final long timelimitInMillis = 60000 * (long) cleanupFeedbackDelay;
final long maxAllowedTimeInMillis = System.currentTimeMillis() - timelimitInMillis;
Map<String, Set<String>> affectedUsers = new HashMap<String, Set<String>>();
Set<String> allAffectedSessions = new HashSet<String>();
List<Document> results = findFeedbackForDeletion(maxAllowedTimeInMillis);
for (Document d : results) {
try {
......@@ -123,8 +123,9 @@ public class CouchDBDao implements IDatabaseDao {
Document feedback = this.getDatabase().getDocument(d.getId());
String arsInternalSessionId = feedback.getString("sessionId");
String user = feedback.getString("user");
// Store user and session data for later. We need this to communicate the changes back to the users.
// Store user and session data for later. We need this to
// communicate the changes back to the users.
Set<String> affectedArsSessions = affectedUsers.get(user);
if (affectedArsSessions == null) {
affectedArsSessions = new HashSet<String>();
......@@ -132,21 +133,19 @@ public class CouchDBDao implements IDatabaseDao {
affectedArsSessions.add(getSessionKeyword(arsInternalSessionId));
affectedUsers.put(user, affectedArsSessions);
allAffectedSessions.addAll(affectedArsSessions);
this.database.deleteDocument(feedback);
logger.debug("Cleaning up Feedback document " + d.getId());
} catch (IOException e) {
logger.error("Could not delete Feedback document " + d.getId());
} catch (JSONException e) {
logger.error("Could not delete Feedback document {}, error is: {} ", new Object[] {d.getId(), e});
logger.error("Could not delete Feedback document {}, error is: {} ", new Object[] { d.getId(), e });
}
}
if (!results.isEmpty()) {
feedbackService.broadcastFeedbackChanges(affectedUsers, allAffectedSessions);
}
}
private List<Document> findFeedbackForDeletion(final long maxAllowedTimeInMillis) {
View cleanupFeedbackView = new View("understanding/cleanup");
......@@ -155,26 +154,20 @@ public class CouchDBDao implements IDatabaseDao {
ViewResults feedbackForCleanup = this.getDatabase().view(cleanupFeedbackView);
return feedbackForCleanup.getResults();
}
@Override
public Session getSession(String keyword) {
Session result = this.getSessionFromKeyword(keyword);
if(result == null) {
if (result == null) {
throw new NotFoundException();
}
if (
result.isActive()
|| result.getCreator().equals(userService.getCurrentUser().getUsername())
) {
if (result.isActive() || result.getCreator().equals(userService.getCurrentUser().getUsername())) {
return result;
}
throw new ForbiddenException();
}
@Override
public List<Session> getMySessions(String username) {
try {
......@@ -183,7 +176,7 @@ public class CouchDBDao implements IDatabaseDao {
view.setEndKey("[" + URLEncoder.encode("\"" + username + "\",{}", "UTF-8") + "]");
ViewResults sessions = this.getDatabase().view(view);
List<Session> result = new ArrayList<Session>();
for (Document d : sessions.getResults()) {
Session session = (Session) JSONObject.toBean(d.getJSONObject().getJSONObject("value"), Session.class);
......@@ -195,82 +188,81 @@ public class CouchDBDao implements IDatabaseDao {
return null;
}
}
@Override
public List<Question> getSkillQuestions(String sessionKeyword) {
Session session = this.getSessionFromKeyword(sessionKeyword);
if (session == null) {
return null;
}
if (session == null)
throw new NotFoundException();
try {
View 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") + "]");
ViewResults questions = this.getDatabase().view(view);
if(questions == null || questions.isEmpty()) {
if (questions == null || questions.isEmpty()) {
return null;
}
List<Question> result = new ArrayList<Question>();
MorpherRegistry morpherRegistry = JSONUtils.getMorpherRegistry();
Morpher dynaMorpher = new BeanMorpher(PossibleAnswer.class, morpherRegistry);
morpherRegistry.registerMorpher(dynaMorpher);
for (Document d : questions.getResults()) {
Question q = (Question) JSONObject.toBean(d.getJSONObject().getJSONObject("value"), Question.class);
Collection<PossibleAnswer> answers = JSONArray.toCollection(d.getJSONObject().getJSONObject("value").getJSONArray("possibleAnswers"), PossibleAnswer.class);
Collection<PossibleAnswer> answers = JSONArray.toCollection(d.getJSONObject().getJSONObject("value")
.getJSONArray("possibleAnswers"), PossibleAnswer.class);
q.setPossibleAnswers(new ArrayList<PossibleAnswer>(answers));
result.add(q);
}
return result;
} catch (UnsupportedEncodingException e) {
return null;
}
}
@Override
public int getSkillQuestionCount(String sessionkey) {
try {
View view = new View("skill_question/count_by_session");
view.setKey(URLEncoder.encode("\"" + sessionkey + "\"", "UTF-8"));
ViewResults results = this.getDatabase().view(view);
if (results.getJSONArray("rows").optJSONObject(0) == null) {
return 0;
}
return results.getJSONArray("rows").optJSONObject(0).optInt("value");
} catch (UnsupportedEncodingException e) {
return 0;
}
}
@Override
public Session getSessionFromKeyword(String keyword) {
try {
View view = new View("session/by_keyword");
view.setKey(URLEncoder.encode("\"" + keyword + "\"", "UTF-8"));
ViewResults results = this.getDatabase().view(view);
if (results.getJSONArray("rows").optJSONObject(0) == null) {
if (results.getJSONArray("rows").optJSONObject(0) == null)
return null;
}
return (Session) JSONObject.toBean(
results.getJSONArray("rows").optJSONObject(0).optJSONObject("value"), Session.class);
return (Session) JSONObject.toBean(results.getJSONArray("rows").optJSONObject(0).optJSONObject("value"),
Session.class);
} catch (UnsupportedEncodingException e) {
return null;
}
}
@Override
public Session saveSession(Session session) {
Document sessionDocument = new Document();
sessionDocument.put("type","session");
sessionDocument.put("type", "session");
sessionDocument.put("name", session.getName());
sessionDocument.put("shortName", session.getShortName());
sessionDocument.put("keyword", sessionService.generateKeyword());
......@@ -281,16 +273,15 @@ public class CouchDBDao implements IDatabaseDao {
} catch (IOException e) {
return null;
}
return this.getSession(sessionDocument.getString("keyword"));
}
@Override
public Feedback getFeedback(String keyword) {
String sessionId = this.getSessionId(keyword);
if (sessionId == null) throw new NotFoundException();
logger.info("Time: {}", this.currentTimestamp());
if (sessionId == null)
throw new NotFoundException();
View view = new View("understanding/by_session");
view.setGroup(true);
......@@ -300,52 +291,46 @@ public class CouchDBDao implements IDatabaseDao {
logger.info("Feedback: {}", results.getJSONArray("rows"));
return this.createFeedbackObject(results);
}
private Feedback createFeedbackObject(ViewResults results) {
int values[] = { 0, 0, 0, 0 };
JSONArray rows = results.getJSONArray("rows");
try {
for (int i = 0; i <= 3; i++) {
String key = results.getJSONArray("rows").optJSONObject(i)
.optJSONArray("key").getString(1);
String key = rows.optJSONObject(i).optJSONArray("key").getString(1);
JSONObject feedback = rows.optJSONObject(i);
if (key.equals("Bitte schneller"))
values[0] = results.getJSONArray("rows").optJSONObject(i)
.getInt("value");
values[0] = feedback.getInt("value");
if (key.equals("Kann folgen"))
values[1] = results.getJSONArray("rows").optJSONObject(i)
.getInt("value");
values[1] = feedback.getInt("value");
if (key.equals("Zu schnell"))
values[2] = results.getJSONArray("rows").optJSONObject(i)
.getInt("value");
values[2] = feedback.getInt("value");
if (key.equals("Nicht mehr dabei"))
values[3] = results.getJSONArray("rows").optJSONObject(i)
.getInt("value");
values[3] = feedback.getInt("value");
}
} catch (Exception e) {
return new Feedback(
values[0],
values[1],
values[2],
values[3]
);
return new Feedback(values[0], values[1], values[2], values[3]);
}
return new Feedback(
values[0],
values[1],
values[2],
values[3]
);
return new Feedback(values[0], values[1], values[2], values[3]);
}
@Override
public boolean saveFeedback(String keyword, int value, de.thm.arsnova.entities.User user) {
String sessionId = this.getSessionId(keyword);
if (sessionId == null) return false;
if (!(value >= 0 && value <= 3)) return false;
if (sessionId == null)
return false;
if (!(value >= 0 && value <= 3))
return false;
Document feedback = new Document();
List<Document> postedFeedback = findPreviousFeedback(sessionId, user);
// Feedback can only be posted once. If there already is some feedback, we need to update it.
// Feedback can only be posted once. If there already is some feedback,
// we need to update it.
if (!postedFeedback.isEmpty()) {
for (Document f : postedFeedback) {
// Use the first found feedback and update value and timestamp
......@@ -365,51 +350,63 @@ public class CouchDBDao implements IDatabaseDao {
feedback.put("timestamp", System.currentTimeMillis());
feedback.put("value", feedbackValueToString(value));
}
try {
this.getDatabase().saveDocument(feedback);
} catch (IOException e) {
return false;
}
return true;
}
private List<Document> findPreviousFeedback(String sessionId, de.thm.arsnova.entities.User user) {
View view = new View("understanding/by_user");
try {
view.setKey(URLEncoder.encode("[\"" + sessionId + "\", \"" + user.getUsername() + "\"]", "UTF-8"));
} catch(UnsupportedEncodingException e) {
return Collections.<Document>emptyList();
} catch (UnsupportedEncodingException e) {
return Collections.<Document> emptyList();
}
ViewResults results = this.getDatabase().view(view);
return results.getResults();
}
private String feedbackValueToString(int value) {
switch (value) {
case 0:
return "Bitte schneller";
case 1:
return "Kann folgen";
case 2:
return "Zu schnell";
case 3:
return "Nicht mehr dabei";
default:
return null;
case 0:
return "Bitte schneller";
case 1:
return "Kann folgen";
case 2:
return "Zu schnell";
case 3:
return "Nicht mehr dabei";
default:
return null;
}
}
private int feedbackValueFromString(String value) {
if (value.equals("Bitte schneller"))
return 0;
if (value.equals("Kann folgen"))
return 1;
if (value.equals("Zu schnell"))
return 2;
if (value.equals("Nicht mehr dabei"))
return 3;
return Integer.MIN_VALUE;
}
@Override
@Transactional(isolation=Isolation.READ_COMMITTED)
@Transactional(isolation = Isolation.READ_COMMITTED)
public boolean sessionKeyAvailable(String keyword) {
View view = new View("session/by_keyword");
ViewResults results = this.getDatabase().view(view);
return ! results.containsKey(keyword);
return !results.containsKey(keyword);
}
private String getSessionId(String keyword) {
View view = new View("session/by_keyword");
view.setKey(URLEncoder.encode("\"" + keyword + "\""));
......@@ -418,10 +415,9 @@ public class CouchDBDao implements IDatabaseDao {
if (results.getJSONArray("rows").optJSONObject(0) == null)
return null;
return results.getJSONArray("rows").optJSONObject(0)
.optJSONObject("value").getString("_id");
return results.getJSONArray("rows").optJSONObject(0).optJSONObject("value").getString("_id");
}
private String getSessionKeyword(String internalSessionId) {
try {
View view = new View("session/by_id");
......@@ -442,34 +438,25 @@ public class CouchDBDao implements IDatabaseDao {
private String currentTimestamp() {
return Long.toString(System.currentTimeMillis());
}
private String actualUserName() {
User user = userService.getCurrentUser();
if(user == null) return null;
if (user == null)
return null;
return user.getUsername();
}
private Database getDatabase() {
if (database == null) {
try {
com.fourspaces.couchdb.Session session = new com.fourspaces.couchdb.Session(
databaseHost,
databasePort
);
com.fourspaces.couchdb.Session session = new com.fourspaces.couchdb.Session(databaseHost, databasePort);
database = session.getDatabase(databaseName);
} catch (Exception e) {
logger.error(
"Cannot connect to CouchDB database '"
+ databaseName
+"' on host '"
+ databaseHost
+ "' using port "
+ databasePort
);
logger.error("Cannot connect to CouchDB database '" + databaseName + "' on host '" + databaseHost
+ "' using port " + databasePort);
}
}
return database;
}
......@@ -482,7 +469,8 @@ public class CouchDBDao implements IDatabaseDao {
q.put("subject", question.getSubject());
q.put("text", question.getText());
q.put("active", question.isActive());
q.put("number", 0); // TODO: This number has to get incremented automatically
q.put("number", 0); // TODO: This number has to get incremented
// automatically
q.put("releasedFor", question.getReleasedFor());
q.put("possibleAnswers", question.getPossibleAnswers());
q.put("noCorrect", question.isNoCorrect());
......@@ -493,8 +481,7 @@ public class CouchDBDao implements IDatabaseDao {
}
return false;
}
@Override
public Question getQuestion(String id, String sessionKey) {
Session s = this.getSessionFromKeyword(sessionKey);
......@@ -505,7 +492,7 @@ public class CouchDBDao implements IDatabaseDao {
View view = new View("skill_question/by_id");
view.setKey(URLEncoder.encode("\"" + id + "\"", "UTF-8"));
ViewResults results = this.getDatabase().view(view);
if (results.getJSONArray("rows").optJSONObject(0) == null) {
return null;
}
......@@ -525,40 +512,44 @@ public class CouchDBDao implements IDatabaseDao {
}
return null;
}
@Override
public LoggedIn registerAsOnlineUser(User u, Session s) {
try {
View view = new View("logged_in/all");
view.setKey(URLEncoder.encode("\"" + u.getUsername() + "\"", "UTF-8"));
ViewResults results = this.getDatabase().view(view);
LoggedIn loggedIn = new LoggedIn();
if (results.getJSONArray("rows").optJSONObject(0) != null) {
JSONObject json = results.getJSONArray("rows").optJSONObject(0).optJSONObject("value");
loggedIn = (LoggedIn) JSONObject.toBean(json, LoggedIn.class);
Collection<VisitedSession> visitedSessions = JSONArray.toCollection(json.getJSONArray("visitedSessions"), VisitedSession.class);
Collection<VisitedSession> visitedSessions = JSONArray.toCollection(
json.getJSONArray("visitedSessions"), VisitedSession.class);
loggedIn.setVisitedSessions(new ArrayList<VisitedSession>(visitedSessions));
}
loggedIn.setUser(u.getUsername());
loggedIn.setSessionId(s.get_id());
loggedIn.addVisitedSession(s);
loggedIn.updateTimestamp();
JSONObject json = JSONObject.fromObject(loggedIn);
Document doc = new Document(json);
if (doc.getId().isEmpty()) {
// If this is a new user without a logged_in document, we have to remove the following
// pre-filled fields. Otherwise, CouchDB will take these empty fields as genuine
// If this is a new user without a logged_in document, we have
// to remove the following
// pre-filled fields. Otherwise, CouchDB will take these empty
// fields as genuine
// identifiers, and will throw errors afterwards.
doc.remove("_id");
doc.remove("_rev");
}
this.getDatabase().saveDocument(doc);
LoggedIn l = (LoggedIn) JSONObject.toBean(doc.getJSONObject(), LoggedIn.class);
Collection<VisitedSession> visitedSessions = JSONArray.toCollection(doc.getJSONObject().getJSONArray("visitedSessions"), VisitedSession.class);
Collection<VisitedSession> visitedSessions = JSONArray.toCollection(
doc.getJSONObject().getJSONArray("visitedSessions"), VisitedSession.class);
l.setVisitedSessions(new ArrayList<VisitedSession>(visitedSessions));
return l;
} catch (UnsupportedEncodingException e) {
......@@ -579,7 +570,30 @@ public class CouchDBDao implements IDatabaseDao {
return;
}
}
@Override
public Integer getMyFeedback(String keyword, User user) {
try {
String sessionId = this.getSessionId(keyword);
if (sessionId == null)
throw new NotFoundException();
View view = new View("understanding/by_user");
view.setKey(URLEncoder.encode("[\"" + sessionId + "\", \"" + user.getUsername() + "\"]", "UTF-8"));
ViewResults results = this.getDatabase().view(view);
JSONArray rows = results.getJSONArray("rows");
if (rows.size() == 0) {
return null;
}
JSONObject json = rows.optJSONObject(0).optJSONObject("value");
return this.feedbackValueFromString(json.getString("value"));
} catch (UnsupportedEncodingException e) {
return null;
}
}
@Override
public List<String> getQuestionIds(String sessionKey) {
User u = userService.getCurrentUser();
......
......@@ -22,29 +22,46 @@ package de.thm.arsnova.dao;
import java.util.List;
import de.thm.arsnova.entities.Feedback;
import de.thm.arsnova.entities.LoggedIn;
import de.thm.arsnova.entities.Question;
import de.thm.arsnova.entities.LoggedIn;
import de.thm.arsnova.entities.Session;
import de.thm.arsnova.entities.User;
public interface IDatabaseDao {
public void cleanFeedbackVotes(int cleanupFeedbackDelay);
public Session getSessionFromKeyword(String keyword);
public Session getSession(String keyword);
public List<Session> getMySessions(String username);
public Session saveSession(Session session);
public Feedback getFeedback(String keyword);
public boolean saveFeedback(String keyword, int value, User user);
public boolean sessionKeyAvailable(String keyword);
public boolean saveQuestion(Session session, Question question);
public Question getQuestion(String id, String sessionKey);
List<Question> getSkillQuestions(String session);
public int getSkillQuestionCount(String sessionkey);
public LoggedIn registerAsOnlineUser(User u, Session s);
public void updateSessionOwnerActivity(Session session);
public Integer getMyFeedback(String keyword, User user);
public List<String> getQuestionIds(String sessionKey);
public void deleteQuestion(String sessionKey, String questionId);
public List<String> getUnAnsweredQuestions(String sessionKey);
}
\ No newline at end of file
package de.thm.arsnova.dao;
\ No newline at end of file
......@@ -3,22 +3,26 @@ package de.thm.arsnova.entities;
public class Authorize {
private String user;
private String socketid;
public String getUser() {
return user;
}
public void setUser(String user) {
this.user = user;
}
public String getSocketid() {
return socketid;
}
public void setSocketid(String socketid) {
this.socketid = socketid;
}
@Override
public String toString() {
return "user: " + user + ", socketid: " + socketid;
}
}
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