From c9d67837cbcaae84a03b7bd14e508ca62880f87f Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Sat, 7 Mar 2020 13:20:45 +0300 Subject: Reorganize project layout --- src/main/java/com/juick/model/AnonymousUser.java | 2 - src/main/java/com/juick/model/Attachment.java | 77 ++++ src/main/java/com/juick/model/Chat.java | 44 +++ src/main/java/com/juick/model/CommandResult.java | 2 - src/main/java/com/juick/model/ExternalToken.java | 64 ++++ src/main/java/com/juick/model/Message.java | 389 +++++++++++++++++++++ src/main/java/com/juick/model/Photo.java | 55 +++ src/main/java/com/juick/model/PrivateChats.java | 1 - src/main/java/com/juick/model/Reaction.java | 64 ++++ src/main/java/com/juick/model/Status.java | 49 +++ src/main/java/com/juick/model/Tag.java | 74 ++++ src/main/java/com/juick/model/TagStats.java | 1 - src/main/java/com/juick/model/User.java | 272 ++++++++++++++ .../java/com/juick/model/ext/facebook/User.java | 55 +++ .../java/com/juick/model/ext/twitter/User.java | 34 ++ src/main/java/com/juick/model/ext/vk/Token.java | 46 +++ src/main/java/com/juick/model/ext/vk/User.java | 51 +++ .../java/com/juick/model/ext/vk/UsersResponse.java | 34 ++ src/main/java/com/juick/model/facebook/User.java | 55 --- src/main/java/com/juick/model/package-info.java | 35 ++ src/main/java/com/juick/model/twitter/User.java | 34 -- src/main/java/com/juick/model/vk/Token.java | 46 --- src/main/java/com/juick/model/vk/User.java | 51 --- .../java/com/juick/model/vk/UsersResponse.java | 34 -- 24 files changed, 1343 insertions(+), 226 deletions(-) create mode 100644 src/main/java/com/juick/model/Attachment.java create mode 100644 src/main/java/com/juick/model/Chat.java create mode 100644 src/main/java/com/juick/model/ExternalToken.java create mode 100644 src/main/java/com/juick/model/Message.java create mode 100644 src/main/java/com/juick/model/Photo.java create mode 100644 src/main/java/com/juick/model/Reaction.java create mode 100644 src/main/java/com/juick/model/Status.java create mode 100644 src/main/java/com/juick/model/Tag.java create mode 100644 src/main/java/com/juick/model/User.java create mode 100644 src/main/java/com/juick/model/ext/facebook/User.java create mode 100644 src/main/java/com/juick/model/ext/twitter/User.java create mode 100644 src/main/java/com/juick/model/ext/vk/Token.java create mode 100644 src/main/java/com/juick/model/ext/vk/User.java create mode 100644 src/main/java/com/juick/model/ext/vk/UsersResponse.java delete mode 100644 src/main/java/com/juick/model/facebook/User.java create mode 100644 src/main/java/com/juick/model/package-info.java delete mode 100644 src/main/java/com/juick/model/twitter/User.java delete mode 100644 src/main/java/com/juick/model/vk/Token.java delete mode 100644 src/main/java/com/juick/model/vk/User.java delete mode 100644 src/main/java/com/juick/model/vk/UsersResponse.java (limited to 'src/main/java/com/juick/model') diff --git a/src/main/java/com/juick/model/AnonymousUser.java b/src/main/java/com/juick/model/AnonymousUser.java index 9d05ae19..855b6eb5 100644 --- a/src/main/java/com/juick/model/AnonymousUser.java +++ b/src/main/java/com/juick/model/AnonymousUser.java @@ -17,8 +17,6 @@ package com.juick.model; -import com.juick.User; - /** * Created by aalexeev on 12/11/16. */ diff --git a/src/main/java/com/juick/model/Attachment.java b/src/main/java/com/juick/model/Attachment.java new file mode 100644 index 00000000..485c69bc --- /dev/null +++ b/src/main/java/com/juick/model/Attachment.java @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2008-2020, Juick + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package com.juick.model; + +import java.io.Serializable; + +public class Attachment implements Serializable { + private String url; + private Integer height; + private Integer width; + private Attachment small; + private Attachment medium; + private Attachment thumbnail; + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public Integer getHeight() { + return height; + } + + public void setHeight(Integer height) { + this.height = height; + } + + public Integer getWidth() { + return width; + } + + public void setWidth(Integer width) { + this.width = width; + } + + public Attachment getSmall() { + return small; + } + + public void setSmall(Attachment small) { + this.small = small; + } + + public Attachment getMedium() { + return medium; + } + + public void setMedium(Attachment medium) { + this.medium = medium; + } + + public Attachment getThumbnail() { + return thumbnail; + } + + public void setThumbnail(Attachment thumbnail) { + this.thumbnail = thumbnail; + } +} diff --git a/src/main/java/com/juick/model/Chat.java b/src/main/java/com/juick/model/Chat.java new file mode 100644 index 00000000..e72afb30 --- /dev/null +++ b/src/main/java/com/juick/model/Chat.java @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2008-2020, Juick + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package com.juick.model; + +import com.fasterxml.jackson.annotation.JsonFormat; + +import java.time.Instant; + +public class Chat extends User { + private Instant lastMessageTimestamp; + private String lastMessageText; + + public Instant getLastMessageTimestamp() { + return lastMessageTimestamp; + } + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "UTC") + public void setLastMessageTimestamp(Instant lastMessageTimestamp) { + this.lastMessageTimestamp = lastMessageTimestamp; + } + + public String getLastMessageText() { + return lastMessageText; + } + + public void setLastMessageText(String lastMessageText) { + this.lastMessageText = lastMessageText; + } +} diff --git a/src/main/java/com/juick/model/CommandResult.java b/src/main/java/com/juick/model/CommandResult.java index c1a2bea1..e2dcc742 100644 --- a/src/main/java/com/juick/model/CommandResult.java +++ b/src/main/java/com/juick/model/CommandResult.java @@ -17,8 +17,6 @@ package com.juick.model; -import com.juick.Message; - import java.util.Optional; public class CommandResult { diff --git a/src/main/java/com/juick/model/ExternalToken.java b/src/main/java/com/juick/model/ExternalToken.java new file mode 100644 index 00000000..f2eac8de --- /dev/null +++ b/src/main/java/com/juick/model/ExternalToken.java @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2008-2020, Juick + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package com.juick.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Created by vitalyster on 22.11.2016. + */ +public class ExternalToken { + private String name; + private String type; + private String token; + private String secret; + + @JsonCreator + public ExternalToken(@JsonProperty("name") String name, + @JsonProperty("type") String type, + @JsonProperty("token") String token, + @JsonProperty("secret") String secret) { + this.name = name; + this.type = type; + this.token = token; + this.secret = secret; + if (this.type == null) { + throw new IllegalStateException("Token must have type"); + } + if (this.token == null) { + throw new IllegalStateException("Token must have value"); + } + } + + public String getType() { + return type; + } + + public String getToken() { + return token; + } + + public String getName() { + return name; + } + + public String getSecret() { + return secret; + } +} diff --git a/src/main/java/com/juick/model/Message.java b/src/main/java/com/juick/model/Message.java new file mode 100644 index 00000000..b1460957 --- /dev/null +++ b/src/main/java/com/juick/model/Message.java @@ -0,0 +1,389 @@ +/* + * Copyright (C) 2008-2020, Juick + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package com.juick.model; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.juick.adapters.SimpleDateAdapter; +import org.apache.commons.lang3.builder.ToStringBuilder; + +import javax.annotation.Nonnull; +import javax.xml.bind.annotation.*; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import java.io.Serializable; +import java.net.URI; +import java.time.Instant; +import java.util.HashSet; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Objects; +import java.util.Set; + +/** + * @author Ugnich Anton + */ +@XmlRootElement(name = "juick", namespace = "http://juick.com/message") +@XmlAccessorType() +public class Message implements Comparable, Serializable { + private int mid = 0; + private int rid = 0; + private int replyto = 0; + private String text = null; + private User user = null; + private Set tags; + private Instant created; + private Instant updated; + private Instant updatedAt; + private boolean unread; + @JsonIgnore + private int privacy = 1; + @XmlTransient + @JsonIgnore + public boolean FriendsOnly = false; + @XmlTransient + @JsonIgnore + public boolean ReadOnly = false; + @XmlTransient + @JsonIgnore + public boolean Hidden = false; + @JsonIgnore + @XmlTransient + public boolean VisitorCanComment = true; + private int replies = 0; + private String repliesBy; + private String attachmentType; + @XmlTransient + private Photo photo; + @XmlTransient + private Attachment attachment; + private int likes; + private User to; + private String replyQuote; + @XmlTransient + private Set reactions; + private boolean service; + private URI replyUri; + private URI replyToUri; + private boolean html; + + private Set recommendations; + + private List entities; + + public Message() { + tags = new LinkedHashSet<>(); + reactions = new HashSet<>(); + } + + @Override + public String toString() { + return new ToStringBuilder(this) + .append("mid", mid) + .append("rid", rid) + .append("replyto", replyto) + .append("privacy", privacy) + .append("FriendsOnly", FriendsOnly) + .append("ReadOnly", ReadOnly) + .append("Hidden", Hidden) + .append("VisitorCanComment", VisitorCanComment) + .append("replies", replies) + .append("likes", likes) + .append("reactions", reactions) + .toString(); + } + + @Override + public boolean equals(Object obj) { + if (obj == this) + return true; + + if (!(obj instanceof Message)) + return false; + + Message jmsg = (Message) obj; + return (this.getMid() == jmsg.getMid() && this.getRid() == jmsg.getRid()); + } + + @Override + public int compareTo(@Nonnull Object obj) throws ClassCastException { + if (obj == this) + return 0; + + if (!(obj instanceof Message)) + throw new ClassCastException(); + + Message jmsg = (Message) obj; + + int cmp = Integer.compare(jmsg.getMid(), getMid()); + + if (cmp == 0) + cmp = Integer.compare(getRid(), jmsg.getRid()); + + return cmp; + } + + @JsonProperty("mid") + @XmlAttribute(name = "mid") + public int getMid() { + return mid; + } + + public void setMid(int mid) { + this.mid = mid; + } + + @JsonProperty("rid") + @XmlAttribute(name = "rid") + public int getRid() { + return rid; + } + + public void setRid(int rid) { + this.rid = rid; + } + + @XmlElement(name = "user", namespace = "http://juick.com/user") + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + + @JsonProperty("body") + @XmlElement(name = "body") + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + @JsonProperty("timestamp") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "UTC") + @XmlAttribute(name = "ts") + @XmlJavaTypeAdapter(SimpleDateAdapter.class) + public Instant getCreated() { + return created; + } + + public void setCreated(Instant timestamp) { + this.created = timestamp; + } + + @XmlTransient + public User getTo() { + return to; + } + + public void setTo(User to) { + this.to = to; + } + + @XmlAttribute(name = "quote") + public String getReplyQuote() { + return replyQuote; + } + + public void setReplyQuote(String quote) { + replyQuote = quote; + } + + @JsonProperty("replyto") + @XmlAttribute(name = "replyto") + public int getReplyto() { + return replyto; + } + + public void setReplyto(int replyto) { + this.replyto = replyto; + } + + @JsonProperty("tags") + @XmlElement(name = "tag") + public Set getTags() { + return tags; + } + + public void setTags(Set tags) { + this.tags = tags; + } + + @XmlAttribute + public int getPrivacy() { + return privacy; + } + + public void setPrivacy(int privacy) { + this.privacy = privacy; + } + + public Photo getPhoto() { + return photo; + } + + public void setPhoto(Photo photo) { + this.photo = photo; + } + + @XmlAttribute(name = "attach") + @JsonProperty("attach") + public String getAttachmentType() { + return attachmentType; + } + + public void setAttachmentType(String attachmentType) { + this.attachmentType = attachmentType; + } + + @XmlTransient + public int getReplies() { + return replies; + } + + public void setReplies(int replies) { + this.replies = replies; + } + + @XmlTransient + public int getLikes() { + return likes; + } + + public void setLikes(int likes) { + this.likes = likes; + } + + @JsonProperty("repliesby") + public String getRepliesBy() { + return repliesBy; + } + + public void setRepliesBy(String repliesBy) { + this.repliesBy = repliesBy; + } + + public Attachment getAttachment() { + return attachment; + } + public void setAttachment(Attachment attachment) { + this.attachment = attachment; + } + + /** + * @return timestamp of the last comment + */ + @XmlTransient + public Instant getUpdated() { + return updated; + } + + public void setUpdated(Instant updated) { + this.updated = updated; + } + + @XmlTransient + public boolean isUnread() { + return unread; + } + + public void setUnread(boolean unread) { + this.unread = unread; + } + + + @XmlTransient + public Set getReactions() { + return reactions; + } + + public void setReactions(Set reactions) { + this.reactions = reactions; + } + + @Override + public int hashCode() { + return Objects.hash(mid, rid); + } + + public boolean isService() { + return service; + } + + public void setService(boolean service) { + this.service = service; + } + + public Set getRecommendations() { + return recommendations; + } + + public void setRecommendations(Set recommendations) { + this.recommendations = recommendations; + } + + /** + * @return timestamp of the last edit + */ + @XmlTransient + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "UTC") + @JsonProperty("updated_at") + public Instant getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Instant updatedAt) { + this.updatedAt = updatedAt; + } + + public URI getReplyUri() { + return replyUri; + } + + public void setReplyUri(URI replyUri) { + this.replyUri = replyUri; + } + + @XmlAttribute(name = "html") + public boolean isHtml() { + return html; + } + + public void setHtml(boolean html) { + this.html = html; + } + + @XmlTransient + public URI getReplyToUri() { + return replyToUri; + } + + public void setReplyToUri(URI replyToUri) { + this.replyToUri = replyToUri; + } + + public List getEntities() { + return entities; + } + + public void setEntities(List entities) { + this.entities = entities; + } +} diff --git a/src/main/java/com/juick/model/Photo.java b/src/main/java/com/juick/model/Photo.java new file mode 100644 index 00000000..e759f70d --- /dev/null +++ b/src/main/java/com/juick/model/Photo.java @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2008-2020, Juick + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package com.juick.model; + +import java.io.Serializable; + +/** + * Created by vitalyster on 30.11.2016. + */ +// used for compatibility +@Deprecated +public class Photo implements Serializable { + private String small; + private String medium; + private String thumbnail; + + public String getSmall() { + return small; + } + + public void setSmall(String small) { + this.small = small; + } + + public String getMedium() { + return medium; + } + + public void setMedium(String medium) { + this.medium = medium; + } + + public String getThumbnail() { + return thumbnail; + } + + public void setThumbnail(String thumbnail) { + this.thumbnail = thumbnail; + } +} diff --git a/src/main/java/com/juick/model/PrivateChats.java b/src/main/java/com/juick/model/PrivateChats.java index c3a443f6..eb39b22c 100644 --- a/src/main/java/com/juick/model/PrivateChats.java +++ b/src/main/java/com/juick/model/PrivateChats.java @@ -18,7 +18,6 @@ package com.juick.model; import com.fasterxml.jackson.annotation.JsonProperty; -import com.juick.Chat; import java.util.Collections; import java.util.List; diff --git a/src/main/java/com/juick/model/Reaction.java b/src/main/java/com/juick/model/Reaction.java new file mode 100644 index 00000000..4b3501d4 --- /dev/null +++ b/src/main/java/com/juick/model/Reaction.java @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2008-2020, Juick + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package com.juick.model; + +import org.apache.commons.lang3.builder.ToStringBuilder; + +import java.io.Serializable; + +public class Reaction implements Serializable { + + public static final int LIKE = 1; + + private final int id; + private String description; + private int count; + + public Reaction(int id) { + this.id = id; + } + + @Override + public String toString() { + return new ToStringBuilder(this) + .append("id", getId()) + .append("description", description) + .append("count", count) + .build(); + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public int getCount() { + return count; + } + + public void setCount(int count) { + this.count = count; + } + + public int getId() { + return id; + } +} diff --git a/src/main/java/com/juick/model/Status.java b/src/main/java/com/juick/model/Status.java new file mode 100644 index 00000000..15904f17 --- /dev/null +++ b/src/main/java/com/juick/model/Status.java @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2008-2020, Juick + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package com.juick.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Created by vitalyster on 25.07.2016. + */ +public class Status { + private final String value; + + public static final Status OK = new Status("ok"); + public static final Status FAIL = new Status("Fail"); + public static final Status ERROR = new Status("Error"); + + public static Status getStatus(final String stringStatus) { + return new Status(stringStatus); + } + + private Status(String value) { + this.value = value; + } + + @JsonProperty("status") + public String getValue() { + return value; + } + + @Override + public String toString() { + return "value = " + value; + } +} diff --git a/src/main/java/com/juick/model/Tag.java b/src/main/java/com/juick/model/Tag.java new file mode 100644 index 00000000..75266303 --- /dev/null +++ b/src/main/java/com/juick/model/Tag.java @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2008-2020, Juick + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package com.juick.model; + +import com.fasterxml.jackson.annotation.JsonValue; + +import javax.xml.bind.annotation.*; +import java.io.Serializable; +import java.util.Comparator; +import java.util.Objects; + +/** + * @author Ugnich Anton + */ +@XmlRootElement(name = "tag", namespace = "http://juick.com/message") +@XmlAccessorType(XmlAccessType.FIELD) +public class Tag implements Comparable, Serializable { + @XmlValue + private String name; + + @XmlTransient + public int TID = 0; + @XmlTransient + public int SynonymID = 0; + + public Tag() { + // required for (de)serialization + } + + public Tag(String name) { + this.name = name; + } + + @Override + public boolean equals(Object o) { + return o == this || + (o instanceof Tag) && Objects.equals(name, ((Tag) o).name); + } + + @XmlTransient + @JsonValue + public String getName() { + return name; + } + + @Override + public int hashCode() { + return Objects.hash(name); + } + + @Override + public String toString() { + return name; + } + + @Override + public int compareTo(Tag o) { + return Objects.compare(name, o.getName(), Comparator.naturalOrder()); + } +} diff --git a/src/main/java/com/juick/model/TagStats.java b/src/main/java/com/juick/model/TagStats.java index 027341e0..f8392402 100644 --- a/src/main/java/com/juick/model/TagStats.java +++ b/src/main/java/com/juick/model/TagStats.java @@ -18,7 +18,6 @@ package com.juick.model; import com.fasterxml.jackson.annotation.JsonProperty; -import com.juick.Tag; /** * Created by vitalyster on 01.12.2016. diff --git a/src/main/java/com/juick/model/User.java b/src/main/java/com/juick/model/User.java new file mode 100644 index 00000000..7a84b115 --- /dev/null +++ b/src/main/java/com/juick/model/User.java @@ -0,0 +1,272 @@ +/* + * Copyright (C) 2008-2020, Juick + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package com.juick.model; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.builder.ToStringBuilder; + +import javax.annotation.Nonnull; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlTransient; +import java.io.Serializable; +import java.net.URI; +import java.time.Instant; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** + * @author Ugnich Anton + */ +@XmlRootElement(name = "user", namespace = "http://juick.com/user") +@XmlAccessorType() +public class User implements Serializable { + private int uid; + private String name; + private String avatar; + private String fullName; + private int messagesCount; + private String authHash; + private boolean banned; + private String credentials; + private List tokens; + private List read; + private List readers; + private List unread; + private URI uri; + private Instant seen; + private boolean verified; + private String country; + private String url; + private String description; + private List tagStats; + + public User() { + tokens = new ArrayList<>(); + tagStats = new ArrayList<>(); + uri = URI.create(StringUtils.EMPTY); + } + + @Override + public boolean equals(Object obj) { + return obj == this || + (obj instanceof User && ((User) obj).getUid() == this.getUid() + && ((User) obj).getUri().toString().equals(this.getUri().toString())); + } + + @Override + public int hashCode() { + return Objects.hash(uid, uri); + } + + @Override + public String toString() { + return new ToStringBuilder(this) + .append("uid", uid) + .append("name", name) + .append("fullName", fullName) + .append("messagesCount", messagesCount) + .append("banned", banned) + .toString(); + } + + @JsonProperty("uid") + @XmlAttribute(name = "uid") + public int getUid() { + return uid; + } + + public void setUid(int uid) { + this.uid = uid; + } + + @JsonProperty("uname") + @XmlAttribute(name = "uname") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @JsonProperty("fullname") + @XmlTransient + public String getFullName() { + return fullName; + } + + public void setFullName(String fullName) { + this.fullName = fullName; + } + + @XmlTransient + @JsonIgnore + public String getAuthHash() { + return authHash; + } + + public void setAuthHash(String authHash) { + this.authHash = authHash; + } + + @JsonProperty("unreadCount") + @XmlTransient + public Integer getUnreadCount() { + return messagesCount; + } + + public void setUnreadCount(Integer count) { + this.messagesCount = count; + } + + @XmlTransient + public boolean isBanned() { + return banned; + } + + public void setBanned(boolean banned) { + this.banned = banned; + } + + public String getAvatar() { + return avatar; + } + + public void setAvatar(String avatarUri) { + this.avatar = avatarUri; + } + + @XmlTransient + @JsonIgnore + public String getCredentials() { + return credentials; + } + + public void setCredentials(String credentials) { + this.credentials = credentials; + } + + @XmlTransient + public int getMessagesCount() { + return messagesCount; + } + + public void setMessagesCount(int messagesCount) { + this.messagesCount = messagesCount; + } + + @XmlTransient + @JsonIgnore + public boolean isAnonymous() { + return uid == 0; + } + + @Nonnull + public List getTokens() { + return tokens; + } + + public void setTokens(List tokens) { + this.tokens = tokens; + } + + public List getRead() { + return read; + } + public List getReaders() { + return readers; + } + + public void setRead(List read) { + this.read = read; + } + + public void setReaders(List readers) { + this.readers = readers; + } + + public List getUnread() { + return unread; + } + + public void setUnread(List unread) { + this.unread = unread; + } + + @Nonnull + @XmlTransient + public URI getUri() { + if (uri == null) { + uri = URI.create(StringUtils.EMPTY); + } + return uri; + } + + public void setUri(URI uri) { + this.uri = uri; + } + + public Instant getSeen() { + return seen; + } + + public void setSeen(Instant seen) { + this.seen = seen; + } + + @XmlTransient + public boolean isVerified() { + return verified; + } + + public void setVerified(boolean verified) { + this.verified = verified; + } + + public String getCountry() { + return country; + } + + public void setCountry(String country) { + this.country = country; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public List getTagStats() { + return tagStats; + } +} diff --git a/src/main/java/com/juick/model/ext/facebook/User.java b/src/main/java/com/juick/model/ext/facebook/User.java new file mode 100644 index 00000000..5dee4d9e --- /dev/null +++ b/src/main/java/com/juick/model/ext/facebook/User.java @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2008-2019, Juick + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package com.juick.model.ext.facebook; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Created by vitalyster on 28.11.2016. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class User { + private String id; + private String name; + private String firstName; + private String lastName; + private String email; + + public String getId() { + return id; + } + + public String getName() { + return name; + } + + @JsonProperty("first_name") + public String getFirstName() { + return firstName; + } + + @JsonProperty("last_name") + public String getLastName() { + return lastName; + } + + public String getEmail() { + return email; + } +} diff --git a/src/main/java/com/juick/model/ext/twitter/User.java b/src/main/java/com/juick/model/ext/twitter/User.java new file mode 100644 index 00000000..27ae652c --- /dev/null +++ b/src/main/java/com/juick/model/ext/twitter/User.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2008-2019, Juick + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package com.juick.model.ext.twitter; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Created by vitalyster on 28.11.2016. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class User { + private String screenName; + + @JsonProperty("screen_name") + public String getScreenName() { + return screenName; + } +} diff --git a/src/main/java/com/juick/model/ext/vk/Token.java b/src/main/java/com/juick/model/ext/vk/Token.java new file mode 100644 index 00000000..1d8c2372 --- /dev/null +++ b/src/main/java/com/juick/model/ext/vk/Token.java @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2008-2019, Juick + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package com.juick.model.ext.vk; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Created by vitalyster on 28.11.2016. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class Token { + private Long userId; + private String accessToken; + private String expiresIn; + + @JsonProperty("user_id") + public Long getUserId() { + return userId; + } + + @JsonProperty("access_token") + public String getAccessToken() { + return accessToken; + } + + @JsonProperty("expires_in") + public String getExpiresIn() { + return expiresIn; + } +} diff --git a/src/main/java/com/juick/model/ext/vk/User.java b/src/main/java/com/juick/model/ext/vk/User.java new file mode 100644 index 00000000..b6b0efd0 --- /dev/null +++ b/src/main/java/com/juick/model/ext/vk/User.java @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2008-2019, Juick + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package com.juick.model.ext.vk; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Created by vitalyster on 28.11.2016. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class User { + private String id; + private String firstName; + private String lastName; + private String screenName; + + @JsonProperty("first_name") + public String getFirstName() { + return firstName; + } + + @JsonProperty("last_name") + public String getLastName() { + return lastName; + } + + @JsonProperty("screen_name") + public String getScreenName() { + return screenName; + } + + public String getId() { + return id; + } +} diff --git a/src/main/java/com/juick/model/ext/vk/UsersResponse.java b/src/main/java/com/juick/model/ext/vk/UsersResponse.java new file mode 100644 index 00000000..f3dc116b --- /dev/null +++ b/src/main/java/com/juick/model/ext/vk/UsersResponse.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2008-2019, Juick + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package com.juick.model.ext.vk; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.List; + +/** + * Created by vitalyster on 28.11.2016. + */ +public class UsersResponse { + private List users; + + @JsonProperty("response") + public List getUsers() { + return users; + } +} diff --git a/src/main/java/com/juick/model/facebook/User.java b/src/main/java/com/juick/model/facebook/User.java deleted file mode 100644 index 49fc81f9..00000000 --- a/src/main/java/com/juick/model/facebook/User.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2008-2019, Juick - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package com.juick.model.facebook; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * Created by vitalyster on 28.11.2016. - */ -@JsonIgnoreProperties(ignoreUnknown = true) -public class User { - private String id; - private String name; - private String firstName; - private String lastName; - private String email; - - public String getId() { - return id; - } - - public String getName() { - return name; - } - - @JsonProperty("first_name") - public String getFirstName() { - return firstName; - } - - @JsonProperty("last_name") - public String getLastName() { - return lastName; - } - - public String getEmail() { - return email; - } -} diff --git a/src/main/java/com/juick/model/package-info.java b/src/main/java/com/juick/model/package-info.java new file mode 100644 index 00000000..be9e6c2b --- /dev/null +++ b/src/main/java/com/juick/model/package-info.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2008-2020, Juick + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +/** + * Created by vitalyster on 15.11.2016. + */ +@XmlSchema( + namespace="http://juick.com/message", + elementFormDefault = XmlNsForm.QUALIFIED, + xmlns={ + @XmlNs(prefix= StringUtils.EMPTY, namespaceURI="http://juick.com/message"), + @XmlNs(prefix="user", namespaceURI="http://juick.com/user") + } +) +package com.juick.model; + +import org.apache.commons.lang3.StringUtils; + +import javax.xml.bind.annotation.XmlNs; +import javax.xml.bind.annotation.XmlNsForm; +import javax.xml.bind.annotation.XmlSchema; \ No newline at end of file diff --git a/src/main/java/com/juick/model/twitter/User.java b/src/main/java/com/juick/model/twitter/User.java deleted file mode 100644 index 7325a7c0..00000000 --- a/src/main/java/com/juick/model/twitter/User.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2008-2019, Juick - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package com.juick.model.twitter; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * Created by vitalyster on 28.11.2016. - */ -@JsonIgnoreProperties(ignoreUnknown = true) -public class User { - private String screenName; - - @JsonProperty("screen_name") - public String getScreenName() { - return screenName; - } -} diff --git a/src/main/java/com/juick/model/vk/Token.java b/src/main/java/com/juick/model/vk/Token.java deleted file mode 100644 index 56d6e476..00000000 --- a/src/main/java/com/juick/model/vk/Token.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2008-2019, Juick - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package com.juick.model.vk; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * Created by vitalyster on 28.11.2016. - */ -@JsonIgnoreProperties(ignoreUnknown = true) -public class Token { - private Long userId; - private String accessToken; - private String expiresIn; - - @JsonProperty("user_id") - public Long getUserId() { - return userId; - } - - @JsonProperty("access_token") - public String getAccessToken() { - return accessToken; - } - - @JsonProperty("expires_in") - public String getExpiresIn() { - return expiresIn; - } -} diff --git a/src/main/java/com/juick/model/vk/User.java b/src/main/java/com/juick/model/vk/User.java deleted file mode 100644 index 5a4c4721..00000000 --- a/src/main/java/com/juick/model/vk/User.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2008-2019, Juick - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package com.juick.model.vk; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * Created by vitalyster on 28.11.2016. - */ -@JsonIgnoreProperties(ignoreUnknown = true) -public class User { - private String id; - private String firstName; - private String lastName; - private String screenName; - - @JsonProperty("first_name") - public String getFirstName() { - return firstName; - } - - @JsonProperty("last_name") - public String getLastName() { - return lastName; - } - - @JsonProperty("screen_name") - public String getScreenName() { - return screenName; - } - - public String getId() { - return id; - } -} diff --git a/src/main/java/com/juick/model/vk/UsersResponse.java b/src/main/java/com/juick/model/vk/UsersResponse.java deleted file mode 100644 index cec47ea7..00000000 --- a/src/main/java/com/juick/model/vk/UsersResponse.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2008-2019, Juick - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package com.juick.model.vk; - -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -/** - * Created by vitalyster on 28.11.2016. - */ -public class UsersResponse { - private List users; - - @JsonProperty("response") - public List getUsers() { - return users; - } -} -- cgit v1.2.3