| |
---|
| | import org.ntlab.acanthus_server.models.Accounts; |
---|
| | import org.ntlab.acanthus_server.models.Gallery; |
---|
| | import org.springframework.stereotype.Component; |
---|
| | |
---|
| | import javax.validation.constraints.Null; |
---|
| | import javax.ws.rs.*; |
---|
| | import javax.ws.rs.core.MediaType; |
---|
| | import java.util.Collection; |
---|
| | |
---|
| | @Component |
---|
| | @Path("/gallery") |
---|
| | public class EditorsRest { |
---|
| | private Accounts accounts = Accounts.getInstance(); |
---|
| | private Gallery gallery = Gallery.getInstance(); |
---|
| | |
---|
| | public class EditorsRest { |
---|
| | //private Accounts accounts = Accounts.getInstance(); |
---|
| | private Gallery gallery = Gallery.getInstance(); |
---|
| | /* |
---|
| | Editorに追加 |
---|
| | */ |
---|
| | @Path("{aid}/Editors") |
---|
| | @GET |
---|
| | @Produces(MediaType.APPLICATION_JSON) |
---|
| | public Collection<Editor> getEditors(@PathParam("aid")Integer aid, @QueryParam("uid") Integer uid) { |
---|
| | public EditorJson getEditors(@PathParam("aid")Integer aid, @QueryParam("uid") Integer uid) { |
---|
| | var atGallery = gallery.getAnimationInformation(aid); |
---|
| | |
---|
| | if(atGallery != null){ |
---|
| | //指定作成のエディターを表示 |
---|
| | Collection<Editor> editorList = atGallery.getEditors(); |
---|
| | return editorList; |
---|
| | return new EditorJson(editorList); |
---|
| | }else{ |
---|
| | //aid間違っている時のレスポンス |
---|
| | throw new WebApplicationException(401); |
---|
| | } |
---|
| |
---|
| | */ |
---|
| | @Path("/{aid}/Editors") |
---|
| | @PUT |
---|
| | @Produces(MediaType.APPLICATION_JSON) |
---|
| | public String addEditors(@PathParam("aid")Integer aid, @FormParam("uid")Integer uid, @FormParam("token") String token) { |
---|
| | /*var account = accounts.getAccountByUid(uid); |
---|
| | public void addEditors(@PathParam("aid")Integer aid, @FormParam("uid")Integer uid, @FormParam("token") String token) { |
---|
| | //招待された時のみの追加 |
---|
| | var account = accounts.getAccountByUid(uid); |
---|
| | var animation = gallery.getAnimationInformation(aid); |
---|
| | Editor editor = new Editor(account, false); |
---|
| | if (account != null && animation != null && account.getToken().equals(token)) { |
---|
| | return "ok"; |
---|
| | } else {*/ |
---|
| | //ユーザーID、トークンが間違っている時のレスポンス |
---|
| | throw new WebApplicationException(401); |
---|
| | // } |
---|
| | editor.setAccount(account); |
---|
| | animation.addEditors(editor); |
---|
| | if(!editor.checkOwner()){ |
---|
| | animation.removeAnimationInvites(account); |
---|
| | } |
---|
| | } else { |
---|
| | //ユーザーID、トークンが間違っている時のレスポンス |
---|
| | throw new WebApplicationException(401); |
---|
| | } |
---|
| | } |
---|
| | } |
---|
| | |
---|
| | |