EditorsRestを変更しました。
1 parent 9e6a032 commit b3cb1e8f78b9893e94ec9b48cb367958a352132a
yugo-asano authored on 28 May 2021
Showing 1 changed file
View
36
src/main/java/org/ntlab/acanthus_server/resources/gallery/EditorsRest.java
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);
}
}
}