false-start of doing admin via ajax, would require a lot more work on the admin client to actually do it this way

This commit is contained in:
Andy Janata 2012-01-29 17:14:17 -08:00
parent 9a476e4f81
commit e3ac81705e
6 changed files with 53 additions and 2 deletions

View File

@ -14,6 +14,7 @@ cah.$.AjaxOperation.GAME_LIST = "games";
cah.$.AjaxOperation.GET_GAME_INFO = "get_game_info";
cah.$.AjaxOperation.PLAY_CARD = "play_card";
cah.$.AjaxOperation.CREATE_GAME = "create_game";
cah.$.AjaxOperation.ADMIN_SET_VERBOSE_LOG = "set_verbose_log";
cah.$.AjaxOperation.GET_CARDS = "get_cards";
cah.$.AjaxOperation.JOIN_GAME = "join_game";
cah.$.AjaxOperation.REGISTER = "register";
@ -76,6 +77,7 @@ cah.$.ErrorCode = function() {
cah.$.ErrorCode.prototype.dummyForAutocomplete = undefined;
cah.$.ErrorCode.TOO_MANY_GAMES = "too_many_games";
cah.$.ErrorCode.NO_CARD_SPECIFIED = "no_card_spec";
cah.$.ErrorCode.ACCESS_DENIED = "access_denied";
cah.$.ErrorCode.NOT_GAME_HOST = "not_game_host";
cah.$.ErrorCode.CANNOT_JOIN_ANOTHER_GAME = "cannot_join_another_game";
cah.$.ErrorCode.INVALID_CARD = "invalid_card";
@ -120,6 +122,7 @@ cah.$.ErrorCode_msg['not_in_that_game'] = "You are not in that game.";
cah.$.ErrorCode_msg['msg_too_long'] = "Messages cannot be longer than 200 characters.";
cah.$.ErrorCode_msg['do_not_have_card'] = "You don't have that card.";
cah.$.ErrorCode_msg['no_game_spec'] = "No game specified.";
cah.$.ErrorCode_msg['access_denied'] = "Access denied.";
cah.$.ErrorCode_msg['invalid_nick'] = "Nickname must contain only upper and lower case letters, numbers, or underscores, must be 3 to 30 characters long, and must not start with a number.";
cah.$.ErrorCode_msg['no_nick_spec'] = "No nickname specified.";
cah.$.ErrorCode_msg['nick_in_use'] = "Nickname is already in use.";

View File

@ -63,6 +63,7 @@ public class Constants {
}
public enum AjaxOperation {
ADMIN_SET_VERBOSE_LOG("set_verbose_log"),
CHAT("chat"),
CREATE_GAME("create_game"),
FIRST_LOAD("firstload"),
@ -141,6 +142,7 @@ public class Constants {
}
public enum ErrorCode implements Localizable {
ACCESS_DENIED("access_denied", "Access denied."),
ALREADY_STARTED("already_started", "The game has already started."),
BAD_OP("bad_op", "Invalid operation."),
BAD_REQUEST("bad_req", "Bad request."),

View File

@ -8,8 +8,8 @@ import java.util.List;
public class UpdateHandlerList {
private static final List<String> EXCLUDE = Arrays.asList("GameHandler", "GameWithPlayerHandler",
"Handler", "Handlers");
private static final List<String> EXCLUDE = Arrays.asList("AdminHandler", "GameHandler",
"GameWithPlayerHandler", "Handler", "Handlers");
/**
* @param args

View File

@ -0,0 +1,25 @@
package net.socialgamer.cah.handlers;
import java.util.Map;
import javax.servlet.http.HttpSession;
import net.socialgamer.cah.Constants.ErrorCode;
import net.socialgamer.cah.Constants.ReturnableData;
import net.socialgamer.cah.RequestWrapper;
public abstract class AdminHandler extends Handler {
@Override
public Map<ReturnableData, Object> handle(final RequestWrapper request, final HttpSession session) {
final String remoteAddr = request.getRemoteAddr();
if (!(remoteAddr.equals("0:0:0:0:0:0:0:1") || remoteAddr.equals("127.0.0.1"))) {
return error(ErrorCode.ACCESS_DENIED);
}
return handle(request);
}
public abstract Map<ReturnableData, Object> handle(RequestWrapper request);
}

View File

@ -0,0 +1,20 @@
package net.socialgamer.cah.handlers;
import java.util.Map;
import net.socialgamer.cah.Constants.AjaxOperation;
import net.socialgamer.cah.Constants.ReturnableData;
import net.socialgamer.cah.RequestWrapper;
public class AdminSetVerboseLog extends AdminHandler {
public static final String OP = AjaxOperation.ADMIN_SET_VERBOSE_LOG.toString();
@Override
public Map<ReturnableData, Object> handle(final RequestWrapper request) {
// TODO Auto-generated method stub
return null;
}
}

View File

@ -10,6 +10,7 @@ public class Handlers {
static {
LIST = new HashMap<String, Class<? extends Handler>>();
LIST.put(AdminSetVerboseLog.OP, AdminSetVerboseLog.class);
LIST.put(ChatHandler.OP, ChatHandler.class);
LIST.put(CreateGameHandler.OP, CreateGameHandler.class);
LIST.put(FirstLoadHandler.OP, FirstLoadHandler.class);