1.1 --- a/freemarkerdor/src/main/java/cz/xelfi/quoridor/freemarkerdor/UI.java Thu Jan 07 22:34:17 2010 +0100
1.2 +++ b/freemarkerdor/src/main/java/cz/xelfi/quoridor/freemarkerdor/UI.java Thu Jan 07 22:51:17 2010 +0100
1.3 @@ -38,6 +38,7 @@
1.4 import cz.xelfi.quoridor.IllegalPositionException;
1.5 import java.io.IOException;
1.6 import java.io.InputStream;
1.7 +import java.io.StringWriter;
1.8 import java.net.URI;
1.9 import java.util.Date;
1.10 import java.util.HashMap;
1.11 @@ -233,17 +234,27 @@
1.12 }
1.13 String bCode = null;
1.14 try{
1.15 - bCode = stat.path("openings").path(Board.board2HashCode(b)+".check").queryParam("loginID", user.getId()).accept(MediaType.TEXT_PLAIN).get(String.class);
1.16 + bCode = stat.path("openings").path(b.getCode()+".check").queryParam("loginID", user.getId()).accept(MediaType.TEXT_PLAIN).get(String.class);
1.17 }catch(Exception e){
1.18 bCode = null;
1.19 }
1.20 if(bCode == null || "".equals(bCode))
1.21 - v = viewable("game.fmt", doc, "message", msg, "format", format, "board", b,"textPicture",b.boardToPicture());
1.22 + v = viewable("game.fmt", doc, "message", msg, "format", format, "board", b,"textPicture", boardToPicture(b));
1.23 else
1.24 - v = viewable("game.fmt", doc, "message", msg, "format", format, "board", b,"textPicture",b.boardToPicture(),"bCode", bCode);
1.25 + v = viewable("game.fmt", doc, "message", msg, "format", format, "board", b,"textPicture", boardToPicture(b),"bCode", bCode);
1.26 return resp.entity(v).build();
1.27 }
1.28
1.29 + private static String boardToPicture(Board b) {
1.30 + StringWriter w = new StringWriter();
1.31 + try {
1.32 + b.write(w);
1.33 + } catch (IOException ex) {
1.34 + return ex.toString();
1.35 + }
1.36 + return w.toString();
1.37 + }
1.38 +
1.39 @GET
1.40 @Path("games/{id}/move")
1.41 @Produces(MediaType.TEXT_HTML)
1.42 @@ -418,7 +429,7 @@
1.43 @PathParam("code") String code,
1.44 @QueryParam("fieldSize") @DefaultValue("40") int fieldSize
1.45 ) throws IllegalPositionException {
1.46 - Board b = new Board(code);
1.47 + Board b = Board.valueOf(code);
1.48 ResponseBuilder resp = Response.ok();
1.49 CacheControl cc = new CacheControl();
1.50 cc.setNoCache(true);