freemarkerdor/src/main/java/cz/xelfi/quoridor/freemarkerdor/UI.java
changeset 73 b3165f3a9ad7
parent 72 5f081edc8502
child 75 6802034b7a6f
     1.1 --- a/freemarkerdor/src/main/java/cz/xelfi/quoridor/freemarkerdor/UI.java	Tue Sep 08 07:54:12 2009 +0200
     1.2 +++ b/freemarkerdor/src/main/java/cz/xelfi/quoridor/freemarkerdor/UI.java	Tue Sep 08 15:29:15 2009 +0200
     1.3 @@ -90,7 +90,7 @@
     1.4      public Response login(
     1.5          @FormParam("name") String name, @FormParam("password") String password
     1.6      ) throws Exception {
     1.7 -        File f = new File(new File(new File(System.getProperty("user.home")), ".quoridor"), "passwd");
     1.8 +        File f = new File(new File(System.getProperty("quoridor.dir")), "passwd");
     1.9          Properties p = new Properties();
    1.10          try {
    1.11              p.load(new FileInputStream(f));
    1.12 @@ -165,22 +165,23 @@
    1.13      @GET
    1.14      @Path("games/create")
    1.15      @Produces(MediaType.TEXT_HTML)
    1.16 -    public Viewable create(
    1.17 +    public Response create(
    1.18          @QueryParam("white") String white,
    1.19          @QueryParam("black") String black
    1.20      ) {
    1.21          Viewable v = checkLogin();
    1.22          if (v != null) {
    1.23 -            return v;
    1.24 +            return Response.status(Response.Status.FORBIDDEN).entity(v).build();
    1.25          }
    1.26  
    1.27          if (user.equals(white) || user.equals(black)) {
    1.28              Object obj =
    1.29                  base.path("games").queryParam("white", white).
    1.30 -                queryParam("black", black).post(Document.class);
    1.31 -            return welcomeImpl();
    1.32 +                queryParam("black", black).accept(MediaType.TEXT_XML).post(Document.class);
    1.33 +            return Response.ok(welcomeImpl()).build();
    1.34          } else {
    1.35 -            return welcomeImpl("message", "You (" + user + ") must be white or black!");
    1.36 +            return Response.status(Response.Status.NOT_FOUND).
    1.37 +                entity(welcomeImpl("message", "You (" + user + ") must be white or black!")).build();
    1.38          }
    1.39      }
    1.40  
    1.41 @@ -215,10 +216,12 @@
    1.42      }
    1.43  
    1.44      static Callable<Void> startServers(int port) throws Exception {
    1.45 -        File home = new File(System.getProperty("user.home"));
    1.46 -        File quoridor = new File(home, ".quoridor");
    1.47  
    1.48 -        System.setProperty("quoridor.dir", quoridor.getPath());
    1.49 +        if (System.getProperty("quoridor.dir") == null) {
    1.50 +            File home = new File(System.getProperty("user.home"));
    1.51 +            File quoridor = new File(home, ".quoridor");
    1.52 +            System.setProperty("quoridor.dir", quoridor.getPath());
    1.53 +        }
    1.54  
    1.55          ResourceConfig rc = new PackagesResourceConfig(
    1.56              "cz.xelfi.quoridor.webidor",