/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package web.servlets;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.scotlandyard.engine.GameException;
import org.scotlandyard.engine.constants.LoginStatus;
import org.scotlandyard.engine.json.LoginStatusJsonContainer;
import org.scotlandyard.impl.engine.GameEngine;
/**
* TODO add a description for this class
*
*
* @author Hussain Al-Mutawa
* @version 2.0
* @since Sun Sep 23, 2011
*/
public class Logout extends AbstractServlet implements IRequestProcessor{
//TODO add documentation about the action performed by getting the output of this servlet
@Override
public Object getOutput(
final HttpServletRequest request,
final GameEngine engine) throws GameException {
engine.logoutUser(engine.getUsers().get(getSessionId()).getEmail());
return (new LoginStatusJsonContainer(LoginStatus.LoggedOut).toJson());
}
@Override
public void validateRequest(
final HttpServletRequest request,
final GameEngine engine) throws GameException {
if(engine.getUsers().get(getSessionId())==null){
throw new GameException("user could not be found in the engine");
}
}
}