webidor/src/main/java/cz/xelfi/quoridor/webidor/resources/Users.java
changeset 145 ac9bd9be5263
parent 144 cc04ede4cb5e
child 146 0b889d9e4ee1
     1.1 --- a/webidor/src/main/java/cz/xelfi/quoridor/webidor/resources/Users.java	Sat Nov 07 18:31:47 2009 +0100
     1.2 +++ b/webidor/src/main/java/cz/xelfi/quoridor/webidor/resources/Users.java	Sat Nov 07 23:26:03 2009 +0100
     1.3 @@ -63,6 +63,13 @@
     1.4      }
     1.5  
     1.6      @GET
     1.7 +    @Produces({MediaType.APPLICATION_JSON, MediaType.TEXT_XML})
     1.8 +    public User getOwnInfo(
     1.9 +            @QueryParam("loginID") String loginId
    1.10 +    ) throws IOException {
    1.11 +        return getUserInfo(loginId, null);
    1.12 +    }
    1.13 +    @GET
    1.14      @Path("{id}")
    1.15      @Produces({ MediaType.APPLICATION_JSON, MediaType.TEXT_XML })
    1.16      public User getUserInfo(
    1.17 @@ -70,6 +77,9 @@
    1.18          @PathParam("id") String id
    1.19      ) throws IOException {
    1.20          String  myid = quoridor.isLoggedIn(loginId);
    1.21 +        if (id == null) {
    1.22 +            id = myid;
    1.23 +        }
    1.24          Properties myp = getProp(myid);
    1.25          Properties p = getProp(id);
    1.26          User user = new User(id);
    1.27 @@ -114,9 +124,11 @@
    1.28          Properties p = new Properties();
    1.29          if (id != null && id.length() > 0) {
    1.30              File f = new File(dir, id);
    1.31 -            FileInputStream is = new FileInputStream(f);
    1.32 -            p.load(is);
    1.33 -            is.close();
    1.34 +            if (f.exists()) {
    1.35 +                FileInputStream is = new FileInputStream(f);
    1.36 +                p.load(is);
    1.37 +                is.close();
    1.38 +            }
    1.39          }
    1.40          return p;
    1.41      }