diff --git a/src/main/java/org/ntlab/amaryllis/server/resources/VoicememosRest.java b/src/main/java/org/ntlab/amaryllis/server/resources/VoicememosRest.java index bb92a52..dd496e2 100644 --- a/src/main/java/org/ntlab/amaryllis/server/resources/VoicememosRest.java +++ b/src/main/java/org/ntlab/amaryllis/server/resources/VoicememosRest.java @@ -26,6 +26,15 @@ Voicememos voicememos = Voicememos.getInstance(); Accounts accounts = Accounts.getInstance(); + //ใƒ†ใ‚นใƒˆ็”จ + { + Account a = accounts.getAccount("test"); + a.setToken("a"); + } + { + voicememos.createVoicememo("vid","test",1,"url",3,3,"a","a"); + } + @GET @Produces(MediaType.APPLICATION_JSON) public ArrayList getVoicememos(@QueryParam("latmax") Double latmax, @QueryParam("latmin") Double latmin, @QueryParam("longmax") Double longmax, @QueryParam("longmin") Double longmin) { @@ -150,7 +159,11 @@ String server_token = account.getToken(); if (client_token.equals(server_token)) { Voicememo v = voicememos.getVoicememo(vid); + if(v == null){ + throw new WebApplicationException(400); + } v.addFavolist(uid); + return; } throw new WebApplicationException(400); } @@ -169,7 +182,11 @@ String server_token = account.getToken(); if (client_token.equals(server_token)) { Voicememo v = voicememos.getVoicememo(vid); + if(v == null){ + throw new WebApplicationException(400); + } v.removeFavolist(uid); + return; } throw new WebApplicationException(400); } @@ -188,7 +205,11 @@ String server_token = account.getToken(); if (client_token.equals(server_token)) { Voicememo v = voicememos.getVoicememo(vid); + if(v == null){ + throw new WebApplicationException(400); + } v.addTimes(); + return; } throw new WebApplicationException(400); } @@ -207,7 +228,11 @@ String server_token = account.getToken(); if (client_token.equals(server_token)) { Voicememo v = voicememos.getVoicememo(vid); + if(v == null){ + throw new WebApplicationException(400); + } v.createComment(uid, comment); + return; } throw new WebApplicationException(400); } @@ -226,7 +251,11 @@ String server_token = account.getToken(); if (client_token.equals(server_token)) { Voicememo v = voicememos.getVoicememo(vid); + if(v == null){ + throw new WebApplicationException(400); + } v.removeComment(commentNo); + return; } throw new WebApplicationException(400); }