diff --git a/src/main/java/com/ntlab/irisserver/resources/SettingsRest.java b/src/main/java/com/ntlab/irisserver/resources/SettingsRest.java index 241394a..344e615 100644 --- a/src/main/java/com/ntlab/irisserver/resources/SettingsRest.java +++ b/src/main/java/com/ntlab/irisserver/resources/SettingsRest.java @@ -14,6 +14,8 @@ RoomManager rm = RoomManager.getInstance(); +//------------------------------------------------------------------------------------ + //GET:設定情報の入手 @GET @Produces(MediaType.APPLICATION_JSON) @Path("/{rid}/settings") @@ -21,21 +23,22 @@ Room r = rm.getRoom(rid); - /* //部屋が存在しないとき var response = Response.status(Response.Status.NO_CONTENT); if(r == null) { response.status(404).entity("部屋が存在しません"); throw new WebApplicationException(response.build()); - }*/ - - return "drawingTime:" + r.isDrawingTimer()+ ",\n" + + } + else return + "drawingTime:" + r.isDrawingTimer()+ ",\n" + "drawingTimerTimes:" + r.getDrawingTimerTimes() + ",\n" + "gameTimer:" + r.isGameTimer() +",\n" + "gameTimerTimes:" + r.getGameTimerTimes() + ",\n" + "gameTimerInitializeTimes:" + r.getGameTimerFirstThinkingTimes(); } +//---------------------------------------------------------------------------------------------------- + //PUT:設定値の変更 @PUT @Path("/{rid}/settings") public void PutSettings(@PathParam("rid") String rid, @@ -47,11 +50,19 @@ Room r = rm.getRoom(rid); - r.setDrawingTimer(dTimer); - r.setDrawingTimerTimes(dTimerTimes); - r.setGameTimer(gTimer); - r.setGameTimerTimes(gTimerTimes); - r.setGameTimerFirstThinkingTimes(gTimerFTTimes); + //部屋がある時、値を変更 + if(r != null) { + r.setDrawingTimer(dTimer); + r.setDrawingTimerTimes(dTimerTimes); + r.setGameTimer(gTimer); + r.setGameTimerTimes(gTimerTimes); + r.setGameTimerFirstThinkingTimes(gTimerFTTimes); + }else{ + //部屋がなければエラー + var response = Response.status(Response.Status.NO_CONTENT); + response.status(404).entity("部屋が存在しません"); + throw new WebApplicationException(response.build()); + } } }