Skip to content

Commit c44a6f4

Browse files
committed
fix Serializable
1 parent 6c8918d commit c44a6f4

File tree

13 files changed

+77
-17
lines changed

13 files changed

+77
-17
lines changed

src/main/java/cn/jpush/api/common/resp/BaseResult.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,18 @@
33
import com.google.gson.Gson;
44
import com.google.gson.GsonBuilder;
55

6-
public abstract class BaseResult implements IRateLimiting {
6+
import java.io.Serializable;
7+
8+
public abstract class BaseResult implements IRateLimiting, Serializable {
79
public static final int ERROR_CODE_NONE = -1;
810
public static final int ERROR_CODE_OK = 0;
911
public static final String ERROR_MESSAGE_NONE = "None error message.";
1012

1113
protected static final int RESPONSE_OK = 200;
1214
protected static Gson _gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
13-
15+
16+
private static final long serialVersionUID = 4810924314887130678L;
17+
1418
private ResponseWrapper responseWrapper;
1519

1620
public void setResponseWrapper(ResponseWrapper responseWrapper) {

src/main/java/cn/jpush/api/common/resp/ResponseWrapper.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,14 @@
99
import org.slf4j.Logger;
1010
import org.slf4j.LoggerFactory;
1111

12-
public class ResponseWrapper {
12+
import java.io.Serializable;
13+
14+
public class ResponseWrapper implements Serializable {
15+
1316
private static final Logger LOG = LoggerFactory.getLogger(ResponseWrapper.class);
1417
private static final int RESPONSE_CODE_NONE = -1;
15-
18+
private static final long serialVersionUID = -4227962073448507865L;
19+
1620
private static Gson _gson = new Gson();
1721
private static JsonParser jsonParser = new JsonParser();
1822

src/main/java/cn/jpush/api/device/OnlineStatus.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
package cn.jpush.api.device;
22

3-
public class OnlineStatus {
3+
import java.io.Serializable;
44

5-
Boolean online;
6-
String last_online_time;
5+
public class OnlineStatus implements Serializable {
6+
7+
private static final long serialVersionUID = -5436655826293828109L;
8+
9+
private Boolean online;
10+
private String last_online_time;
711

812
public Boolean getOnline() {
913
return online;

src/main/java/cn/jpush/api/device/TagAliasResult.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package cn.jpush.api.device;
22

3-
import java.util.List;
4-
53
import cn.jpush.api.common.resp.BaseResult;
6-
74
import com.google.gson.annotations.Expose;
85

6+
import java.util.List;
7+
98
public class TagAliasResult extends BaseResult {
109

10+
private static final long serialVersionUID = -4765083329495728276L;
1111
@Expose public List<String> tags;
1212
@Expose public String alias;
1313

src/main/java/cn/jpush/api/device/TagListResult.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
package cn.jpush.api.device;
22

3-
import java.util.ArrayList;
4-
import java.util.List;
5-
63
import cn.jpush.api.common.resp.BaseResult;
7-
84
import com.google.gson.annotations.Expose;
95

6+
import java.util.ArrayList;
7+
import java.util.List;
8+
109
public class TagListResult extends BaseResult {
11-
10+
11+
private static final long serialVersionUID = -5395153728332839175L;
1212
@Expose public List<String> tags = new ArrayList<String>();
1313

1414
}

src/main/java/cn/jpush/api/push/PushResult.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package cn.jpush.api.push;
22

33
import cn.jpush.api.common.resp.BaseResult;
4-
54
import com.google.gson.annotations.Expose;
65

76
public class PushResult extends BaseResult {
8-
7+
8+
private static final long serialVersionUID = 93783137655776743L;
9+
910
@Expose public long msg_id;
1011
@Expose public int sendno;
1112

src/main/java/cn/jpush/api/report/MessagesResult.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
public class MessagesResult extends BaseResult {
1313
private static final Type MESSAGE_TYPE = new TypeToken<List<Message>>() {}.getType();
14+
private static final long serialVersionUID = -1582895355000647292L;
1415

1516
@Expose
1617
public List<Message> messages = new ArrayList<Message>();

src/main/java/cn/jpush/api/report/ReceivedsResult.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
public class ReceivedsResult extends BaseResult {
1313
private static final Type RECEIVED_TYPE = new TypeToken<List<Received>>() {}.getType();
14+
private static final long serialVersionUID = 1761456104618847304L;
1415

1516
@Expose
1617
public List<Received> received_list = new ArrayList<Received>();

src/main/java/cn/jpush/api/report/UsersResult.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
public class UsersResult extends BaseResult {
1313

14+
private static final long serialVersionUID = -963296929272770550L;
1415
@Expose public TimeUnit time_unit;
1516
@Expose public String start;
1617
@Expose public int duration;

src/main/java/cn/jpush/api/schedule/ScheduleClient.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ public class ScheduleClient {
2121
private String hostName;
2222
private String schedulePath;
2323

24+
// If not present, true by default.
25+
private int apnsProduction;
26+
27+
// If not present, the default value is 86400(s) (one day)
28+
private long timeToLive;
29+
2430
public ScheduleClient(String masterSecret, String appkey) {
2531
this(masterSecret, appkey, null, ClientConfig.getInstance());
2632
}
@@ -47,6 +53,8 @@ public ScheduleClient(String masterSecret, String appKey, int maxRetryTimes, Htt
4753

4854
hostName = (String) conf.get(ClientConfig.SCHEDULE_HOST_NAME);
4955
schedulePath = (String) conf.get(ClientConfig.SCHEDULE_PATH);
56+
apnsProduction = (Integer) conf.get(ClientConfig.APNS_PRODUCTION);
57+
timeToLive = (Long) conf.get(ClientConfig.TIME_TO_LIVE);
5058

5159
String authCode = ServiceHelper.getBasicAuthorization(appKey, masterSecret);
5260
this._httpClient = new NativeHttpClient(authCode, proxy, conf);
@@ -63,6 +71,8 @@ public ScheduleClient(String masterSecret, String appKey, HttpProxy proxy, Clien
6371
ServiceHelper.checkBasic(appKey, masterSecret);
6472
hostName = (String) conf.get(ClientConfig.SCHEDULE_HOST_NAME);
6573
schedulePath = (String) conf.get(ClientConfig.SCHEDULE_PATH);
74+
apnsProduction = (Integer) conf.get(ClientConfig.APNS_PRODUCTION);
75+
timeToLive = (Long) conf.get(ClientConfig.TIME_TO_LIVE);
6676

6777
String authCode = ServiceHelper.getBasicAuthorization(appKey, masterSecret);
6878
this._httpClient = new NativeHttpClient(authCode, proxy, conf);
@@ -72,6 +82,16 @@ public ScheduleResult createSchedule(SchedulePayload payload) throws APIConnecti
7282

7383
Preconditions.checkArgument(null != payload, "payload should not be null");
7484

85+
if (apnsProduction > 0) {
86+
payload.resetPushApnsProduction(true);
87+
} else if(apnsProduction == 0) {
88+
payload.resetPushApnsProduction(false);
89+
}
90+
91+
if (timeToLive >= 0) {
92+
payload.resetPushTimeToLive(timeToLive);
93+
}
94+
7595
ResponseWrapper response = _httpClient.sendPost(hostName + schedulePath, payload.toString());
7696
return ScheduleResult.fromResponse(response, ScheduleResult.class);
7797
}
@@ -97,6 +117,16 @@ public ScheduleResult updateSchedule(String scheduleId, SchedulePayload payload)
97117
Preconditions.checkArgument(StringUtils.isNotEmpty(scheduleId), "scheduleId should not be empty");
98118
Preconditions.checkArgument(null != payload, "payload should not be null");
99119

120+
if (apnsProduction > 0) {
121+
payload.resetPushApnsProduction(true);
122+
} else if(apnsProduction == 0) {
123+
payload.resetPushApnsProduction(false);
124+
}
125+
126+
if (timeToLive >= 0) {
127+
payload.resetPushTimeToLive(timeToLive);
128+
}
129+
100130
ResponseWrapper response = _httpClient.sendPut(hostName + schedulePath + "/" + scheduleId,
101131
payload.toString());
102132
return ScheduleResult.fromResponse(response, ScheduleResult.class);

0 commit comments

Comments
 (0)