aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/server/api/activity/model
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-11-08 21:38:27 +0300
committerGravatar Vitaly Takmazov2018-11-08 21:38:27 +0300
commit7aaa3f9a29c280f01c677c918932620be45cdbd7 (patch)
tree39947b2c889afd08f9c73ba54fab91159d2af258 /src/main/java/com/juick/server/api/activity/model
parent3ea9770d0d43fbe45449ac4531ec4b0a374d98ea (diff)
Merge everything into single Spring Boot application
Diffstat (limited to 'src/main/java/com/juick/server/api/activity/model')
-rw-r--r--src/main/java/com/juick/server/api/activity/model/Activity.java23
-rw-r--r--src/main/java/com/juick/server/api/activity/model/Context.java123
-rw-r--r--src/main/java/com/juick/server/api/activity/model/activities/Accept.java6
-rw-r--r--src/main/java/com/juick/server/api/activity/model/activities/Announce.java6
-rw-r--r--src/main/java/com/juick/server/api/activity/model/activities/Block.java6
-rw-r--r--src/main/java/com/juick/server/api/activity/model/activities/Create.java6
-rw-r--r--src/main/java/com/juick/server/api/activity/model/activities/Delete.java6
-rw-r--r--src/main/java/com/juick/server/api/activity/model/activities/Follow.java6
-rw-r--r--src/main/java/com/juick/server/api/activity/model/activities/Like.java6
-rw-r--r--src/main/java/com/juick/server/api/activity/model/activities/Undo.java6
-rw-r--r--src/main/java/com/juick/server/api/activity/model/objects/Hashtag.java6
-rw-r--r--src/main/java/com/juick/server/api/activity/model/objects/Image.java15
-rw-r--r--src/main/java/com/juick/server/api/activity/model/objects/Key.java24
-rw-r--r--src/main/java/com/juick/server/api/activity/model/objects/Link.java15
-rw-r--r--src/main/java/com/juick/server/api/activity/model/objects/Mention.java12
-rw-r--r--src/main/java/com/juick/server/api/activity/model/objects/Note.java64
-rw-r--r--src/main/java/com/juick/server/api/activity/model/objects/OrderedCollection.java25
-rw-r--r--src/main/java/com/juick/server/api/activity/model/objects/OrderedCollectionPage.java58
-rw-r--r--src/main/java/com/juick/server/api/activity/model/objects/Person.java87
19 files changed, 500 insertions, 0 deletions
diff --git a/src/main/java/com/juick/server/api/activity/model/Activity.java b/src/main/java/com/juick/server/api/activity/model/Activity.java
new file mode 100644
index 00000000..ec126b88
--- /dev/null
+++ b/src/main/java/com/juick/server/api/activity/model/Activity.java
@@ -0,0 +1,23 @@
+package com.juick.server.api.activity.model;
+
+public abstract class Activity extends Context {
+
+ private String actor;
+ private Object object;
+
+ public String getActor() {
+ return actor;
+ }
+
+ public void setActor(String actor) {
+ this.actor = actor;
+ }
+
+ public Object getObject() {
+ return object;
+ }
+
+ public void setObject(Object object) {
+ this.object = object;
+ }
+}
diff --git a/src/main/java/com/juick/server/api/activity/model/Context.java b/src/main/java/com/juick/server/api/activity/model/Context.java
new file mode 100644
index 00000000..0df8f8c7
--- /dev/null
+++ b/src/main/java/com/juick/server/api/activity/model/Context.java
@@ -0,0 +1,123 @@
+package com.juick.server.api.activity.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonSubTypes;
+import com.fasterxml.jackson.annotation.JsonTypeInfo;
+import com.juick.server.api.activity.model.activities.*;
+import com.juick.server.api.activity.model.objects.*;
+
+import java.time.Instant;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property="type")
+@JsonSubTypes({
+ @JsonSubTypes.Type(value = Create.class, name = "Create"),
+ @JsonSubTypes.Type(value = Delete.class, name = "Delete"),
+ @JsonSubTypes.Type(value = Follow.class, name = "Follow"),
+ @JsonSubTypes.Type(value = Accept.class, name = "Accept"),
+ @JsonSubTypes.Type(value = Undo.class, name = "Undo"),
+ @JsonSubTypes.Type(value = Like.class, name = "Like"),
+ @JsonSubTypes.Type(value = Block.class, name = "Block"),
+ @JsonSubTypes.Type(value = Announce.class, name = "Announce"),
+ @JsonSubTypes.Type(value = Activity.class, name = "Activity"),
+ @JsonSubTypes.Type(value = Image.class, name = "Image"),
+ @JsonSubTypes.Type(value = Key.class, name = "Key"),
+ @JsonSubTypes.Type(value = Link.class, name = "Link"),
+ @JsonSubTypes.Type(value = Hashtag.class, name = "Hashtag"),
+ @JsonSubTypes.Type(value = Mention.class, name = "Mention"),
+ @JsonSubTypes.Type(value = Note.class, name = "Note"),
+ @JsonSubTypes.Type(value = OrderedCollection.class, name = "OrderedCollection"),
+ @JsonSubTypes.Type(value = OrderedCollectionPage.class, name = "OrderedCollectionPage"),
+ @JsonSubTypes.Type(value = Person.class, name = "Person")
+})
+public abstract class Context {
+
+ private List<Object> context;
+
+ private String id;
+
+ private String name;
+
+ private Instant published;
+
+ private String url;
+
+ private List<String> to;
+
+ private List<Context> tags;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getType() {
+ return getClass().getSimpleName();
+ }
+
+ @JsonProperty("@context")
+ public List<Object> getContext() {
+ return context;
+ }
+
+ public final static String ACTIVITY_STREAMS_URI = "https://www.w3.org/ns/activitystreams";
+ public final static String SECURITY_URI = "https://w3id.org/security/v1";
+ public final static String LD_JSON_MEDIA_TYPE = "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"";
+ public final static String ACTIVITY_MEDIA_TYPE = "application/activity+json";
+ public final static String ACTIVITYSTREAMS_PROFILE_MEDIA_TYPE = ACTIVITY_MEDIA_TYPE + "; profile=\"https://www.w3.org/ns/activitystreams\"";
+
+ public Instant getPublished() {
+ return published;
+ }
+
+ public void setPublished(Instant published) {
+ this.published = published;
+ }
+
+ public List<String> getTo() {
+ return to;
+ }
+
+ public void setTo(List<String> to) {
+ this.to = to;
+ }
+
+ public static Context build(Context response) {
+ response.context = new ArrayList(Arrays.asList(ACTIVITY_STREAMS_URI, SECURITY_URI));
+ response.context.add(Collections.singletonMap("Hashtag", "as:Hashtag"));
+ return response;
+ }
+
+ public String getUrl() {
+ return url;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+ @JsonProperty("tag")
+ public List<Context> getTags() {
+ return tags;
+ }
+
+ public void setTags(List<Context> tags) {
+ this.tags = tags;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
diff --git a/src/main/java/com/juick/server/api/activity/model/activities/Accept.java b/src/main/java/com/juick/server/api/activity/model/activities/Accept.java
new file mode 100644
index 00000000..1e0a9968
--- /dev/null
+++ b/src/main/java/com/juick/server/api/activity/model/activities/Accept.java
@@ -0,0 +1,6 @@
+package com.juick.server.api.activity.model.activities;
+
+import com.juick.server.api.activity.model.Activity;
+
+public class Accept extends Activity {
+}
diff --git a/src/main/java/com/juick/server/api/activity/model/activities/Announce.java b/src/main/java/com/juick/server/api/activity/model/activities/Announce.java
new file mode 100644
index 00000000..f2859404
--- /dev/null
+++ b/src/main/java/com/juick/server/api/activity/model/activities/Announce.java
@@ -0,0 +1,6 @@
+package com.juick.server.api.activity.model.activities;
+
+import com.juick.server.api.activity.model.Activity;
+
+public class Announce extends Activity {
+}
diff --git a/src/main/java/com/juick/server/api/activity/model/activities/Block.java b/src/main/java/com/juick/server/api/activity/model/activities/Block.java
new file mode 100644
index 00000000..0e5a02d4
--- /dev/null
+++ b/src/main/java/com/juick/server/api/activity/model/activities/Block.java
@@ -0,0 +1,6 @@
+package com.juick.server.api.activity.model.activities;
+
+import com.juick.server.api.activity.model.Activity;
+
+public class Block extends Activity {
+}
diff --git a/src/main/java/com/juick/server/api/activity/model/activities/Create.java b/src/main/java/com/juick/server/api/activity/model/activities/Create.java
new file mode 100644
index 00000000..52507373
--- /dev/null
+++ b/src/main/java/com/juick/server/api/activity/model/activities/Create.java
@@ -0,0 +1,6 @@
+package com.juick.server.api.activity.model.activities;
+
+import com.juick.server.api.activity.model.Activity;
+
+public class Create extends Activity {
+}
diff --git a/src/main/java/com/juick/server/api/activity/model/activities/Delete.java b/src/main/java/com/juick/server/api/activity/model/activities/Delete.java
new file mode 100644
index 00000000..f4392020
--- /dev/null
+++ b/src/main/java/com/juick/server/api/activity/model/activities/Delete.java
@@ -0,0 +1,6 @@
+package com.juick.server.api.activity.model.activities;
+
+import com.juick.server.api.activity.model.Activity;
+
+public class Delete extends Activity {
+}
diff --git a/src/main/java/com/juick/server/api/activity/model/activities/Follow.java b/src/main/java/com/juick/server/api/activity/model/activities/Follow.java
new file mode 100644
index 00000000..573ecc6e
--- /dev/null
+++ b/src/main/java/com/juick/server/api/activity/model/activities/Follow.java
@@ -0,0 +1,6 @@
+package com.juick.server.api.activity.model.activities;
+
+import com.juick.server.api.activity.model.Activity;
+
+public class Follow extends Activity {
+}
diff --git a/src/main/java/com/juick/server/api/activity/model/activities/Like.java b/src/main/java/com/juick/server/api/activity/model/activities/Like.java
new file mode 100644
index 00000000..3670293d
--- /dev/null
+++ b/src/main/java/com/juick/server/api/activity/model/activities/Like.java
@@ -0,0 +1,6 @@
+package com.juick.server.api.activity.model.activities;
+
+import com.juick.server.api.activity.model.Activity;
+
+public class Like extends Activity {
+}
diff --git a/src/main/java/com/juick/server/api/activity/model/activities/Undo.java b/src/main/java/com/juick/server/api/activity/model/activities/Undo.java
new file mode 100644
index 00000000..4e87e9d0
--- /dev/null
+++ b/src/main/java/com/juick/server/api/activity/model/activities/Undo.java
@@ -0,0 +1,6 @@
+package com.juick.server.api.activity.model.activities;
+
+import com.juick.server.api.activity.model.Activity;
+
+public class Undo extends Activity {
+}
diff --git a/src/main/java/com/juick/server/api/activity/model/objects/Hashtag.java b/src/main/java/com/juick/server/api/activity/model/objects/Hashtag.java
new file mode 100644
index 00000000..34e73be6
--- /dev/null
+++ b/src/main/java/com/juick/server/api/activity/model/objects/Hashtag.java
@@ -0,0 +1,6 @@
+package com.juick.server.api.activity.model.objects;
+
+import com.juick.server.api.activity.model.Context;
+
+public class Hashtag extends Context {
+}
diff --git a/src/main/java/com/juick/server/api/activity/model/objects/Image.java b/src/main/java/com/juick/server/api/activity/model/objects/Image.java
new file mode 100644
index 00000000..e067f729
--- /dev/null
+++ b/src/main/java/com/juick/server/api/activity/model/objects/Image.java
@@ -0,0 +1,15 @@
+package com.juick.server.api.activity.model.objects;
+
+import com.juick.server.api.activity.model.Context;
+
+public class Image extends Context {
+ private String mediaType;
+
+ public String getMediaType() {
+ return mediaType;
+ }
+
+ public void setMediaType(String mediaType) {
+ this.mediaType = mediaType;
+ }
+}
diff --git a/src/main/java/com/juick/server/api/activity/model/objects/Key.java b/src/main/java/com/juick/server/api/activity/model/objects/Key.java
new file mode 100644
index 00000000..075c51dd
--- /dev/null
+++ b/src/main/java/com/juick/server/api/activity/model/objects/Key.java
@@ -0,0 +1,24 @@
+package com.juick.server.api.activity.model.objects;
+
+import com.juick.server.api.activity.model.Context;
+
+public class Key extends Context {
+ private String owner;
+ private String publicKeyPem;
+
+ public String getOwner() {
+ return owner;
+ }
+
+ public void setOwner(String owner) {
+ this.owner = owner;
+ }
+
+ public String getPublicKeyPem() {
+ return publicKeyPem;
+ }
+
+ public void setPublicKeyPem(String publicKeyPem) {
+ this.publicKeyPem = publicKeyPem;
+ }
+}
diff --git a/src/main/java/com/juick/server/api/activity/model/objects/Link.java b/src/main/java/com/juick/server/api/activity/model/objects/Link.java
new file mode 100644
index 00000000..0c4f26dc
--- /dev/null
+++ b/src/main/java/com/juick/server/api/activity/model/objects/Link.java
@@ -0,0 +1,15 @@
+package com.juick.server.api.activity.model.objects;
+
+import com.juick.server.api.activity.model.Context;
+
+public class Link extends Context {
+ private String href;
+
+ public String getHref() {
+ return href;
+ }
+
+ public void setHref(String href) {
+ this.href = href;
+ }
+}
diff --git a/src/main/java/com/juick/server/api/activity/model/objects/Mention.java b/src/main/java/com/juick/server/api/activity/model/objects/Mention.java
new file mode 100644
index 00000000..bcb52d37
--- /dev/null
+++ b/src/main/java/com/juick/server/api/activity/model/objects/Mention.java
@@ -0,0 +1,12 @@
+package com.juick.server.api.activity.model.objects;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class Mention extends Link {
+ @JsonCreator
+ public Mention(@JsonProperty("href") String href, @JsonProperty("name") String name) {
+ this.setHref(href);
+ this.setName(name);
+ }
+}
diff --git a/src/main/java/com/juick/server/api/activity/model/objects/Note.java b/src/main/java/com/juick/server/api/activity/model/objects/Note.java
new file mode 100644
index 00000000..baad2d3b
--- /dev/null
+++ b/src/main/java/com/juick/server/api/activity/model/objects/Note.java
@@ -0,0 +1,64 @@
+package com.juick.server.api.activity.model.objects;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.juick.server.api.activity.model.Context;
+
+import java.util.List;
+
+public class Note extends Context {
+ private String content;
+ private String attributedTo;
+ private String inReplyTo;
+ private List<Image> attachment;
+ private List<String> to;
+ private List<String> cc;
+
+ public String getContent() {
+ return content;
+ }
+
+ public void setContent(String content) {
+ this.content = content;
+ }
+
+ public String getAttributedTo() {
+ return attributedTo;
+ }
+
+ public void setAttributedTo(String attributedTo) {
+ this.attributedTo = attributedTo;
+ }
+
+ @JsonFormat(with = JsonFormat.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY)
+ public List<Image> getAttachment() {
+ return attachment;
+ }
+
+ public void setAttachment(List<Image> attachment) {
+ this.attachment = attachment;
+ }
+
+ public List<String> getTo() {
+ return to;
+ }
+
+ public void setTo(List<String> to) {
+ this.to = to;
+ }
+
+ public List<String> getCc() {
+ return cc;
+ }
+
+ public void setCc(List<String> cc) {
+ this.cc = cc;
+ }
+
+ public String getInReplyTo() {
+ return inReplyTo;
+ }
+
+ public void setInReplyTo(String inReplyTo) {
+ this.inReplyTo = inReplyTo;
+ }
+}
diff --git a/src/main/java/com/juick/server/api/activity/model/objects/OrderedCollection.java b/src/main/java/com/juick/server/api/activity/model/objects/OrderedCollection.java
new file mode 100644
index 00000000..426cf331
--- /dev/null
+++ b/src/main/java/com/juick/server/api/activity/model/objects/OrderedCollection.java
@@ -0,0 +1,25 @@
+package com.juick.server.api.activity.model.objects;
+
+import com.juick.server.api.activity.model.Context;
+
+public class OrderedCollection extends Context {
+
+ private int totalItems;
+
+ public int getTotalItems() {
+ return totalItems;
+ }
+
+ public void setTotalItems(int totalItems) {
+ this.totalItems = totalItems;
+ }
+ private String first;
+
+ public String getFirst() {
+ return first;
+ }
+
+ public void setFirst(String first) {
+ this.first = first;
+ }
+}
diff --git a/src/main/java/com/juick/server/api/activity/model/objects/OrderedCollectionPage.java b/src/main/java/com/juick/server/api/activity/model/objects/OrderedCollectionPage.java
new file mode 100644
index 00000000..601919ba
--- /dev/null
+++ b/src/main/java/com/juick/server/api/activity/model/objects/OrderedCollectionPage.java
@@ -0,0 +1,58 @@
+package com.juick.server.api.activity.model.objects;
+
+import com.juick.server.api.activity.model.Context;
+
+import java.util.List;
+
+public class OrderedCollectionPage extends Context {
+
+ private String partOf;
+
+ private String first;
+
+ private String next;
+
+ private String last;
+
+ private List<? extends Context> orderedItems;
+
+ public String getNext() {
+ return next;
+ }
+
+ public void setNext(String next) {
+ this.next = next;
+ }
+
+ public List<? extends Context> getOrderedItems() {
+ return orderedItems;
+ }
+
+ public void setOrderedItems(List<? extends Context> orderedItems) {
+ this.orderedItems = orderedItems;
+ }
+
+ public String getPartOf() {
+ return partOf;
+ }
+
+ public void setPartOf(String partOf) {
+ this.partOf = partOf;
+ }
+
+ public String getFirst() {
+ return first;
+ }
+
+ public void setFirst(String first) {
+ this.first = first;
+ }
+
+ public String getLast() {
+ return last;
+ }
+
+ public void setLast(String last) {
+ this.last = last;
+ }
+}
diff --git a/src/main/java/com/juick/server/api/activity/model/objects/Person.java b/src/main/java/com/juick/server/api/activity/model/objects/Person.java
new file mode 100644
index 00000000..2d3a45d7
--- /dev/null
+++ b/src/main/java/com/juick/server/api/activity/model/objects/Person.java
@@ -0,0 +1,87 @@
+package com.juick.server.api.activity.model.objects;
+
+import com.fasterxml.jackson.annotation.JsonTypeInfo;
+import com.juick.server.api.activity.model.Context;
+
+public class Person extends Context {
+
+ private String name;
+ private String preferredUsername;
+ private Image icon;
+ private String inbox;
+ private String outbox;
+ private String following;
+ private String followers;
+ private Key publicKey;
+
+ @Override
+ public String getType() {
+ return "Person";
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @JsonTypeInfo(use = JsonTypeInfo.Id.NONE)
+ public Image getIcon() {
+ return icon;
+ }
+
+ public void setIcon(Image icon) {
+ this.icon = icon;
+ }
+
+ public String getOutbox() {
+ return outbox;
+ }
+
+ public void setOutbox(String outbox) {
+ this.outbox = outbox;
+ }
+
+ public String getInbox() {
+ return inbox;
+ }
+
+ public void setInbox(String inbox) {
+ this.inbox = inbox;
+ }
+
+ public String getFollowing() {
+ return following;
+ }
+
+ public void setFollowing(String following) {
+ this.following = following;
+ }
+
+ public String getFollowers() {
+ return followers;
+ }
+
+ public void setFollowers(String followers) {
+ this.followers = followers;
+ }
+
+ @JsonTypeInfo(use = JsonTypeInfo.Id.NONE)
+ public Key getPublicKey() {
+ return publicKey;
+ }
+
+ public void setPublicKey(Key publicKey) {
+ this.publicKey = publicKey;
+ }
+
+ public String getPreferredUsername() {
+ return preferredUsername;
+ }
+
+ public void setPreferredUsername(String preferredUsername) {
+ this.preferredUsername = preferredUsername;
+ }
+}