diff --git a/src/main/java/com/ntlab/irisserver/resources/MemberRest.java b/src/main/java/com/ntlab/irisserver/resources/MemberRest.java index 51f62e8..730dd04 100644 --- a/src/main/java/com/ntlab/irisserver/resources/MemberRest.java +++ b/src/main/java/com/ntlab/irisserver/resources/MemberRest.java @@ -14,12 +14,22 @@ @Path("/{rid}/members/{nickname}") @PUT public String putMember(@PathParam("rid") String rid, @PathParam("nickname") String nickname, - @FormParam("belongs") String belongs, @FormParam("is-master") boolean is_master) { + @FormParam("belongs") String belongs, @FormParam("is-master") boolean isMaster) { RoomManager rm = RoomManager.getInstance(); Room room = rm.getRoom(rid); - if(room != null && room.getMember(nickname) != null) { - room.changeTeamAndMaster(nickname, belongs, is_master); - }else{ + + //部屋の確認 + if (room != null) { + //ニックネームの確認 + if (room.getMember(nickname) != null) { + room.changeTeamAndMaster(nickname, belongs, isMaster); + } else { + //ニックネームがなければエラー + var response = Response.status(Response.Status.NO_CONTENT); + response.status(404).entity("ニックネームが存在しません"); + throw new WebApplicationException(response.build()); + } + } else { //部屋がなければエラー var response = Response.status(Response.Status.NO_CONTENT); response.status(404).entity("部屋が存在しません"); @@ -35,13 +45,8 @@ public String deleteMember(@PathParam("rid") String rid, @PathParam("nickname") String nickname) { RoomManager rm = RoomManager.getInstance(); Room room = rm.getRoom(rid); - if(room != null && room.getMember(nickname) != null) { + if (room != null && room.getMember(nickname) != null) { room.deleteMember(nickname); - }else{ - //部屋がなければエラー - var response = Response.status(Response.Status.NO_CONTENT); - response.status(404).entity("部屋が存在しません"); - throw new WebApplicationException(response.build()); } return "退出しました";