aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--juick-api/src/main/java/com/juick/api/TGBot.java10
-rw-r--r--juick-notifications/src/main/java/com/juick/components/Notifications.java7
-rw-r--r--juick-server/src/main/java/com/juick/server/protocol/JuickProtocol.java4
-rw-r--r--juick-www/src/main/java/com/juick/www/FacebookLogin.java4
-rw-r--r--juick-www/src/main/java/com/juick/www/TwitterAuth.java4
-rw-r--r--juick-www/src/main/java/com/juick/www/VKontakteLogin.java9
6 files changed, 36 insertions, 2 deletions
diff --git a/juick-api/src/main/java/com/juick/api/TGBot.java b/juick-api/src/main/java/com/juick/api/TGBot.java
index 882dc821..e0ab3e1e 100644
--- a/juick-api/src/main/java/com/juick/api/TGBot.java
+++ b/juick-api/src/main/java/com/juick/api/TGBot.java
@@ -1,5 +1,6 @@
package com.juick.api;
+import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.juick.service.MessagesService;
import com.juick.service.TelegramService;
@@ -35,19 +36,26 @@ public class TGBot implements AutoCloseable {
TelegramBot bot;
WebSocket ws;
- ObjectMapper ms = new ObjectMapper();
+ private ObjectMapper ms;
@Inject
TelegramService telegramService;
@Inject
MessagesService messagesService;
+ private TGBot() {
+ throw new IllegalStateException();
+ }
public TGBot(String token) {
if (StringUtils.isBlank(token)) {
return;
}
bot = TelegramBotAdapter.build(token);
+ ms = new ObjectMapper();
+ ms.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
+ ms.setSerializationInclusion(JsonInclude.Include.NON_NULL);
+ ms.setSerializationInclusion(JsonInclude.Include.NON_DEFAULT);
try {
SetWebhook webhook = new SetWebhook().url("https://api.juick.com/tlgmbtwbhk");
if (!bot.execute(webhook).isOk()) {
diff --git a/juick-notifications/src/main/java/com/juick/components/Notifications.java b/juick-notifications/src/main/java/com/juick/components/Notifications.java
index e0155a0a..dac4d22e 100644
--- a/juick-notifications/src/main/java/com/juick/components/Notifications.java
+++ b/juick-notifications/src/main/java/com/juick/components/Notifications.java
@@ -17,6 +17,7 @@
*/
package com.juick.components;
+import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.android.gcm.server.*;
import com.juick.components.mpns.MPNSError;
@@ -88,6 +89,9 @@ public class Notifications implements AutoCloseable {
xmppPort = NumberUtils.toInt(env.getProperty("xmpp_port"), 5347);
xmppPushPassword = env.getProperty("push_xmpp_password", "");
mapper = new ObjectMapper();
+ mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
+ mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
+ mapper.setSerializationInclusion(JsonInclude.Include.NON_DEFAULT);
}
@PostConstruct
@@ -120,6 +124,9 @@ public class Notifications implements AutoCloseable {
if (!regids.isEmpty()) {
try {
ObjectMapper messageSerializer = new ObjectMapper();
+ messageSerializer.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
+ messageSerializer.setSerializationInclusion(JsonInclude.Include.NON_NULL);
+ messageSerializer.setSerializationInclusion(JsonInclude.Include.NON_DEFAULT);
String json = messageSerializer.writeValueAsString(jmsg);
logger.info(json);
Message message = new Message.Builder().addData("message", json).build();
diff --git a/juick-server/src/main/java/com/juick/server/protocol/JuickProtocol.java b/juick-server/src/main/java/com/juick/server/protocol/JuickProtocol.java
index 6bd8e11f..1bac9fce 100644
--- a/juick-server/src/main/java/com/juick/server/protocol/JuickProtocol.java
+++ b/juick-server/src/main/java/com/juick/server/protocol/JuickProtocol.java
@@ -1,5 +1,6 @@
package com.juick.server.protocol;
+import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.juick.Message;
@@ -30,6 +31,9 @@ public class JuickProtocol {
public JuickProtocol(JdbcTemplate sql, String baseUri) {
this.sql = sql;
this.baseUri = baseUri;
+ json.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
+ json.setSerializationInclusion(JsonInclude.Include.NON_NULL);
+ json.setSerializationInclusion(JsonInclude.Include.NON_DEFAULT);
}
/**
diff --git a/juick-www/src/main/java/com/juick/www/FacebookLogin.java b/juick-www/src/main/java/com/juick/www/FacebookLogin.java
index b42bb23b..34385a3d 100644
--- a/juick-www/src/main/java/com/juick/www/FacebookLogin.java
+++ b/juick-www/src/main/java/com/juick/www/FacebookLogin.java
@@ -17,6 +17,7 @@
*/
package com.juick.www;
+import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.juick.server.UserQueries;
import com.juick.www.facebook.Graph;
@@ -52,6 +53,9 @@ public class FacebookLogin {
this.FACEBOOK_APPID = ApplicationID;
this.FACEBOOK_SECRET = secret;
mapper = new ObjectMapper();
+ mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
+ mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
+ mapper.setSerializationInclusion(JsonInclude.Include.NON_DEFAULT);
}
protected void doGet(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
diff --git a/juick-www/src/main/java/com/juick/www/TwitterAuth.java b/juick-www/src/main/java/com/juick/www/TwitterAuth.java
index c6aaf9a1..65998ece 100644
--- a/juick-www/src/main/java/com/juick/www/TwitterAuth.java
+++ b/juick-www/src/main/java/com/juick/www/TwitterAuth.java
@@ -1,5 +1,6 @@
package com.juick.www;
+import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.scribejava.apis.TwitterApi;
import com.github.scribejava.core.builder.ServiceBuilder;
@@ -32,6 +33,9 @@ public class TwitterAuth {
this.consumerKey = consumerKey;
this.consumerSecret = consumerSecret;
mapper = new ObjectMapper();
+ mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
+ mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
+ mapper.setSerializationInclusion(JsonInclude.Include.NON_DEFAULT);
}
protected void doGet(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response)
diff --git a/juick-www/src/main/java/com/juick/www/VKontakteLogin.java b/juick-www/src/main/java/com/juick/www/VKontakteLogin.java
index 83619b2a..1ccf36b6 100644
--- a/juick-www/src/main/java/com/juick/www/VKontakteLogin.java
+++ b/juick-www/src/main/java/com/juick/www/VKontakteLogin.java
@@ -17,6 +17,7 @@
*/
package com.juick.www;
+import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.juick.server.UserQueries;
import com.juick.www.vk.*;
@@ -43,7 +44,13 @@ public class VKontakteLogin {
private static final String VK_SECRET = "z2afNI8jA5lIpZ2jsTm1";
private static final String VK_REDIRECT = "http://juick.com/_vklogin";
- private final ObjectMapper mapper = new ObjectMapper();
+ public VKontakteLogin() {
+ mapper = new ObjectMapper();
+ mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
+ mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
+ mapper.setSerializationInclusion(JsonInclude.Include.NON_DEFAULT);
+ }
+ private final ObjectMapper mapper;
protected void doGet(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String code = request.getParameter("code");