myfavo,times,commentの修正
1 parent 98f8dcb commit f0768f1cd5c1fe0afbb84367fd636405a78fe448
m-horinouchi authored on 3 Jul 2020
Showing 1 changed file
View
190
src/main/java/org/ntlab/amaryllis/server/resources/VoicememosRest.java
}
throw new WebApplicationException(400);
}
 
//
// @Path("/{vid}")
// @PUT
// @Produces(MediaType.APPLICATION_JSON)
// public void addMyfavo(@PathParam("vid") String vid, @FormParam("token") String client_token, @FormParam("uid") String uid){
// if (vid == null || client_token == null || uid == null) {
// throw new WebApplicationException(400);
// }
// Account account = accounts.getAccount(uid);
// if(account == null){
// throw new WebApplicationException(400);
// }
// String server_token = account.getToken();
// if (client_token.equals(server_token)) {
// Voicememo v = voicememos.getVoicememo(vid);
// v.addFavolist(uid);
// }
// throw new WebApplicationException(400);
// }
//
// @Path("/{vid}")
// @DELETE
// @Produces(MediaType.APPLICATION_JSON)
// public void deleteMyfavo(@PathParam("vid") String vid, @FormParam("token") String client_token, @FormParam("uid") String uid){
// if (vid == null || client_token == null || uid == null) {
// throw new WebApplicationException(400);
// }
// Account account = accounts.getAccount(uid);
// if(account == null){
// throw new WebApplicationException(400);
// }
// String server_token = account.getToken();
// if (client_token.equals(server_token)) {
// Voicememo v = voicememos.getVoicememo(vid);
// v.removeFavolist(uid);
// }
// throw new WebApplicationException(400);
// }
//
// @Path("/{vid}")
// @POST
// @Produces(MediaType.APPLICATION_JSON)
// public void countTimes(@PathParam("vid") String vid, @FormParam("token") String client_token, @FormParam("uid") String uid){
// if (vid == null || client_token == null || uid == null) {
// throw new WebApplicationException(400);
// }
// Account account = accounts.getAccount(uid);
// if(account == null){
// throw new WebApplicationException(400);
// }
// String server_token = account.getToken();
// if (client_token.equals(server_token)) {
// Voicememo v = voicememos.getVoicememo(vid);
// v.addTimes();
// }
// throw new WebApplicationException(400);
// }
//
// @Path("/{vid}")
// @POST
// @Produces(MediaType.APPLICATION_JSON)
// public void addComment(@PathParam("vid") String vid, @FormParam("token") String client_token, @FormParam("uid") String uid, @FormParam("comment") String comment){
// if (vid == null || client_token == null || uid == null) {
// throw new WebApplicationException(400);
// }
// Account account = accounts.getAccount(uid);
// if(account == null){
// throw new WebApplicationException(400);
// }
// String server_token = account.getToken();
// if (client_token.equals(server_token)) {
// Voicememo v = voicememos.getVoicememo(vid);
// v.createComment(uid, comment);
// }
// throw new WebApplicationException(400);
// }
//
// @Path("/{vid}")
// @DELETE
// @Produces(MediaType.APPLICATION_JSON)
// public void deleteComment(@PathParam("vid") String vid, @FormParam("token") String client_token, @FormParam("uid") String uid, @FormParam("comment") String commentId){
// if (vid == null || client_token == null || uid == null || commentId == null) {
// throw new WebApplicationException(400);
// }
// Account account = accounts.getAccount(uid);
// if(account == null){
// throw new WebApplicationException(400);
// }
// String server_token = account.getToken();
// if (client_token.equals(server_token)) {
// Voicememo v = voicememos.getVoicememo(vid);
// v.removeComment(commentId);
// }
// throw new WebApplicationException(400);
// }
 
@Path("/{vid}/myfavo")
@PUT
@Produces(MediaType.APPLICATION_JSON)
public void addMyfavo(@PathParam("vid") String vid, @FormParam("token") String client_token, @FormParam("uid") String uid){
if (vid == null || client_token == null || uid == null) {
throw new WebApplicationException(400);
}
Account account = accounts.getAccount(uid);
if(account == null){
throw new WebApplicationException(400);
}
String server_token = account.getToken();
if (client_token.equals(server_token)) {
Voicememo v = voicememos.getVoicememo(vid);
v.addFavolist(uid);
}
throw new WebApplicationException(400);
}
 
@Path("/{vid}/myfavo")
@DELETE
@Produces(MediaType.APPLICATION_JSON)
public void deleteMyfavo(@PathParam("vid") String vid, @FormParam("token") String client_token, @FormParam("uid") String uid){
if (vid == null || client_token == null || uid == null) {
throw new WebApplicationException(400);
}
Account account = accounts.getAccount(uid);
if(account == null){
throw new WebApplicationException(400);
}
String server_token = account.getToken();
if (client_token.equals(server_token)) {
Voicememo v = voicememos.getVoicememo(vid);
v.removeFavolist(uid);
}
throw new WebApplicationException(400);
}
 
@Path("/{vid}/times")
@POST
@Produces(MediaType.APPLICATION_JSON)
public void countTimes(@PathParam("vid") String vid, @FormParam("token") String client_token, @FormParam("uid") String uid){
if (vid == null || client_token == null || uid == null) {
throw new WebApplicationException(400);
}
Account account = accounts.getAccount(uid);
if(account == null){
throw new WebApplicationException(400);
}
String server_token = account.getToken();
if (client_token.equals(server_token)) {
Voicememo v = voicememos.getVoicememo(vid);
v.addTimes();
}
throw new WebApplicationException(400);
}
 
@Path("/{vid}/comments")
@POST
@Produces(MediaType.APPLICATION_JSON)
public void addComment(@PathParam("vid") String vid, @FormParam("token") String client_token, @FormParam("uid") String uid, @FormParam("comment") String comment){
if (vid == null || client_token == null || uid == null) {
throw new WebApplicationException(400);
}
Account account = accounts.getAccount(uid);
if(account == null){
throw new WebApplicationException(400);
}
String server_token = account.getToken();
if (client_token.equals(server_token)) {
Voicememo v = voicememos.getVoicememo(vid);
v.createComment(uid, comment);
}
throw new WebApplicationException(400);
}
 
@Path("/{vid}/comments/{commentNo}")
@DELETE
@Produces(MediaType.APPLICATION_JSON)
public void deleteComment(@PathParam("vid") String vid, @FormParam("token") String client_token, @FormParam("uid") String uid, @PathParam("commentNo") String commentNo){
if (vid == null || client_token == null || uid == null || commentNo == null) {
throw new WebApplicationException(400);
}
Account account = accounts.getAccount(uid);
if(account == null){
throw new WebApplicationException(400);
}
String server_token = account.getToken();
if (client_token.equals(server_token)) {
Voicememo v = voicememos.getVoicememo(vid);
v.removeComment(commentNo);
}
throw new WebApplicationException(400);
}
 
}