diff --git a/src/main/java/org/ntlab/acanthus_server/entities/Account.java b/src/main/java/org/ntlab/acanthus_server/entities/Account.java index ce7d2b2..1b17fd1 100644 --- a/src/main/java/org/ntlab/acanthus_server/entities/Account.java +++ b/src/main/java/org/ntlab/acanthus_server/entities/Account.java @@ -24,17 +24,10 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import jdk.jshell.execution.LoaderDelegate; -import org.ntlab.acanthus_server.models.Gallery; -import javax.xml.crypto.Data; -import java.text.DateFormat; import java.time.Duration; import java.time.LocalDateTime; -import java.util.Calendar; -import java.util.Date; -import java.util.HashMap; -import java.util.UUID; +import java.util.*; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonPropertyOrder({ @@ -64,7 +57,7 @@ @JsonIgnore private LocalDateTime lastAccess; - + public Account() {} //----------------------------------------------------------------- //コンストラクト public Account(Integer idMargin) { @@ -185,9 +178,9 @@ // 時刻比較 var duration = Duration.between(lastAccess, nowDateTime).toHours(); - if (duration > timeoutThreshold) return false; + if (duration > timeoutThreshold) return true; - return token.equals(this.token); + return !token.equals(this.token); } //----------------------------------------------------------------- diff --git a/src/main/java/org/ntlab/acanthus_server/entities/Animation.java b/src/main/java/org/ntlab/acanthus_server/entities/Animation.java index 30034be..7985270 100644 --- a/src/main/java/org/ntlab/acanthus_server/entities/Animation.java +++ b/src/main/java/org/ntlab/acanthus_server/entities/Animation.java @@ -6,6 +6,12 @@ import org.ntlab.acanthus_server.models.Gallery; import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean; +import org.ntlab.acanthus_server.resources.gallery.StrokesRest; +import org.ntlab.acanthus_server.entities.Page; +import org.ntlab.acanthus_server.entities.Layer; +import org.ntlab.acanthus_server.entities.Position; +import org.ntlab.acanthus_server.entities.Stroke; + import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.ArrayList; @@ -43,6 +49,8 @@ @JsonIgnore private boolean isDummy; + + public Animation(Integer aid, String name, Account owner) { LocalDateTime date = LocalDateTime.now(); @@ -65,6 +73,12 @@ //private Gallery gallery = Gallery.getInstance(); //private Accounts accounts = Accounts.getInstance(); + // page情報 + private ArrayList pages = new ArrayList<>(); + public ArrayList getPages() { + return (this.pages); + } + //----------------------------------------------------------------- // setter @@ -203,6 +217,10 @@ //this.lastAccess = LocalDateTime.of(2015, 12, 15, 0, 0); + // pageとlayerを1枚ずつ追加 + this.pages.add(new Page()); + this.pages.get(0).getLayers().add(new Layer()); + var newWork = new Work(); //ユーザーの制作作品の作成 newWork.setWork(); diff --git a/src/main/java/org/ntlab/acanthus_server/resources/accounts/AccountsRest.java b/src/main/java/org/ntlab/acanthus_server/resources/accounts/AccountsRest.java index 672636c..09dc341 100644 --- a/src/main/java/org/ntlab/acanthus_server/resources/accounts/AccountsRest.java +++ b/src/main/java/org/ntlab/acanthus_server/resources/accounts/AccountsRest.java @@ -1,6 +1,5 @@ package org.ntlab.acanthus_server.resources.accounts; -import org.apache.catalina.loader.WebappClassLoader; import org.ntlab.acanthus_server.entities.Account; import org.ntlab.acanthus_server.entities.AccountJson; import org.ntlab.acanthus_server.entities.AccountUidJson; @@ -74,7 +73,7 @@ } // トークンを検証し, 発見したユーザーを返却 - if (!searchAccount.isCollectToken(token)){ + if (searchAccount.isCollectToken(token)){ response = Response.status(400).entity("トークンが違います。"); throw new WebApplicationException(response.build()); } @@ -126,7 +125,7 @@ */ private boolean isCorrectEmailAddress(String emailAddress) { - var aText = "[a-zA-Z0-9_!#¥¥$¥¥%&'*+/=?¥¥^`{}~|¥¥-]+"; + var aText = "[a-zA-Z0-9_!#¥$%&'*+/=?^`{}~|-]+"; var dotAtom = aText + "(?:\\." + aText + "+)*"; var regularExpression = "^" + dotAtom + "@" + dotAtom + "$"; diff --git a/src/main/java/org/ntlab/acanthus_server/resources/accounts/LoginRest.java b/src/main/java/org/ntlab/acanthus_server/resources/accounts/LoginRest.java index d47c361..807d36e 100644 --- a/src/main/java/org/ntlab/acanthus_server/resources/accounts/LoginRest.java +++ b/src/main/java/org/ntlab/acanthus_server/resources/accounts/LoginRest.java @@ -34,7 +34,7 @@ response.status(404).entity(false); throw new WebApplicationException(response.build()); } - if (!searchAccount.isCollectToken(token)) response.status(400).entity(false); + if (searchAccount.isCollectToken(token)) response.status(400).entity(false); else return true; throw new WebApplicationException(response.build()); diff --git a/src/main/java/org/ntlab/acanthus_server/resources/gallery/GalleryRest.java b/src/main/java/org/ntlab/acanthus_server/resources/gallery/GalleryRest.java index a652326..064396f 100644 --- a/src/main/java/org/ntlab/acanthus_server/resources/gallery/GalleryRest.java +++ b/src/main/java/org/ntlab/acanthus_server/resources/gallery/GalleryRest.java @@ -63,7 +63,7 @@ } //トークン認証 これもクリアするとcreateAnimationが返され作品が作られる。 - if(!searchAccounts.isCollectToken(token)){ + if(searchAccounts.isCollectToken(token)){ response = Response.status(400).entity("トークンが違います。"); throw new WebApplicationException(response.build()); } @@ -96,4 +96,4 @@ return searchAnimation; } -} \ No newline at end of file +} diff --git a/src/main/java/org/ntlab/acanthus_server/resources/gallery/StrokesRest.java b/src/main/java/org/ntlab/acanthus_server/resources/gallery/StrokesRest.java index fff98bd..7f2e71e 100644 --- a/src/main/java/org/ntlab/acanthus_server/resources/gallery/StrokesRest.java +++ b/src/main/java/org/ntlab/acanthus_server/resources/gallery/StrokesRest.java @@ -1,11 +1,9 @@ package org.ntlab.acanthus_server.resources.gallery; -import org.ntlab.acanthus_server.entities.Page; -import org.ntlab.acanthus_server.entities.Layer; -import org.ntlab.acanthus_server.entities.Position; -import org.ntlab.acanthus_server.entities.Stroke; -import org.ntlab.acanthus_server.entities.Work; +import org.ntlab.acanthus_server.entities.*; import org.ntlab.acanthus_server.models.Gallery; +import org.ntlab.acanthus_server.entities.Animation; +import org.ntlab.acanthus_server.entities.Account; import org.springframework.stereotype.Component; import javax.ws.rs.*; @@ -15,7 +13,7 @@ @Component @Path("/gallery") public class StrokesRest { - private ArrayList pages = new ArrayList<>(); + private ArrayList pages = new Animation(new Account(0)).getPages(); private Gallery gallery = Gallery.getInstance();