refactor: add lombok to gcm module
This commit is contained in:
committed by
Arnold Gálovics
parent
ae71df17df
commit
5d1d20e577
+1
-1
@@ -212,7 +212,7 @@ public class ExternalServicesPropertiesReadPlatformServiceImpl implements Extern
|
|||||||
fcmEndPoint = rs.getString("value");
|
fcmEndPoint = rs.getString("value");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new NotificationConfigurationData(null, serverKey, gcmEndPoint, fcmEndPoint);
|
return new NotificationConfigurationData().setServerKey(serverKey).setGcmEndPoint(gcmEndPoint).setFcmEndPoint(fcmEndPoint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+11
-34
@@ -24,13 +24,21 @@ import javax.persistence.Entity;
|
|||||||
import javax.persistence.JoinColumn;
|
import javax.persistence.JoinColumn;
|
||||||
import javax.persistence.OneToOne;
|
import javax.persistence.OneToOne;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
|
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
|
||||||
import org.apache.fineract.infrastructure.core.service.DateUtils;
|
import org.apache.fineract.infrastructure.core.service.DateUtils;
|
||||||
import org.apache.fineract.portfolio.client.domain.Client;
|
import org.apache.fineract.portfolio.client.domain.Client;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "client_device_registration")
|
@Table(name = "client_device_registration")
|
||||||
public final class DeviceRegistration extends AbstractPersistableCustom {
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Accessors(chain = true)
|
||||||
|
public class DeviceRegistration extends AbstractPersistableCustom {
|
||||||
|
|
||||||
@OneToOne
|
@OneToOne
|
||||||
@JoinColumn(name = "client_id", nullable = false, unique = true)
|
@JoinColumn(name = "client_id", nullable = false, unique = true)
|
||||||
@@ -42,40 +50,9 @@ public final class DeviceRegistration extends AbstractPersistableCustom {
|
|||||||
@Column(name = "updatedon_date", nullable = false)
|
@Column(name = "updatedon_date", nullable = false)
|
||||||
private LocalDateTime updatedOnDate;
|
private LocalDateTime updatedOnDate;
|
||||||
|
|
||||||
private DeviceRegistration() {}
|
|
||||||
|
|
||||||
private DeviceRegistration(final Client client, final String registrationId) {
|
|
||||||
this.client = client;
|
|
||||||
this.registrationId = registrationId;
|
|
||||||
this.updatedOnDate = DateUtils.getLocalDateTimeOfTenant();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static DeviceRegistration instance(final Client client, final String registrationId) {
|
public static DeviceRegistration instance(final Client client, final String registrationId) {
|
||||||
return new DeviceRegistration(client, registrationId);
|
return new DeviceRegistration().setRegistrationId(registrationId).setClient(client)
|
||||||
}
|
.setUpdatedOnDate(DateUtils.getLocalDateTimeOfTenant());
|
||||||
|
|
||||||
public Client getClient() {
|
|
||||||
return this.client;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setClient(Client client) {
|
|
||||||
this.client = client;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRegistrationId() {
|
|
||||||
return this.registrationId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRegistrationId(String registrationId) {
|
|
||||||
this.registrationId = registrationId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public LocalDateTime getUpdatedOnDate() {
|
|
||||||
return this.updatedOnDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUpdatedOnDate(LocalDateTime updatedOnDate) {
|
|
||||||
this.updatedOnDate = updatedOnDate;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-10
@@ -19,26 +19,27 @@
|
|||||||
package org.apache.fineract.infrastructure.gcm.domain;
|
package org.apache.fineract.infrastructure.gcm.domain;
|
||||||
|
|
||||||
import java.time.OffsetDateTime;
|
import java.time.OffsetDateTime;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
import org.apache.fineract.portfolio.client.data.ClientData;
|
import org.apache.fineract.portfolio.client.data.ClientData;
|
||||||
|
|
||||||
public final class DeviceRegistrationData {
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Accessors(chain = true)
|
||||||
|
public class DeviceRegistrationData {
|
||||||
|
|
||||||
public Long id;
|
public Long id;
|
||||||
public ClientData clientData;
|
public ClientData clientData;
|
||||||
public String registrationId;
|
public String registrationId;
|
||||||
public OffsetDateTime updatedOnDate;
|
public OffsetDateTime updatedOnDate;
|
||||||
|
|
||||||
private DeviceRegistrationData(final Long id, final ClientData clientData, final String registrationId,
|
|
||||||
final OffsetDateTime updatedOnDate) {
|
|
||||||
this.id = id;
|
|
||||||
this.clientData = clientData;
|
|
||||||
this.registrationId = registrationId;
|
|
||||||
this.updatedOnDate = updatedOnDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static DeviceRegistrationData instance(final Long id, final ClientData clientData, final String registrationId,
|
public static DeviceRegistrationData instance(final Long id, final ClientData clientData, final String registrationId,
|
||||||
final OffsetDateTime updatedOnDate) {
|
final OffsetDateTime updatedOnDate) {
|
||||||
return new DeviceRegistrationData(id, clientData, registrationId, updatedOnDate);
|
return new DeviceRegistrationData().setId(id).setClientData(clientData).setRegistrationId(registrationId)
|
||||||
|
.setUpdatedOnDate(updatedOnDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+18
-72
@@ -22,6 +22,9 @@ import java.io.Serializable;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
import org.apache.fineract.infrastructure.gcm.GcmConstants;
|
import org.apache.fineract.infrastructure.gcm.GcmConstants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -72,17 +75,23 @@ import org.apache.fineract.infrastructure.gcm.GcmConstants;
|
|||||||
*
|
*
|
||||||
* </code>
|
* </code>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Accessors(chain = true)
|
||||||
public final class Message implements Serializable {
|
public final class Message implements Serializable {
|
||||||
|
|
||||||
private final String collapseKey;
|
private static final long serialVersionUID = 1L;
|
||||||
private final Boolean delayWhileIdle;
|
|
||||||
private final Integer timeToLive;
|
private String collapseKey;
|
||||||
private final Map<String, String> data;
|
private Boolean delayWhileIdle;
|
||||||
private final Boolean dryRun;
|
private Integer timeToLive;
|
||||||
private final String restrictedPackageName;
|
private Map<String, String> data;
|
||||||
private final String priority;
|
private Boolean dryRun;
|
||||||
private final Boolean contentAvailable;
|
private String restrictedPackageName;
|
||||||
private final Notification notification;
|
private String priority;
|
||||||
|
private Boolean contentAvailable;
|
||||||
|
private Notification notification;
|
||||||
|
|
||||||
public enum Priority {
|
public enum Priority {
|
||||||
NORMAL, HIGH
|
NORMAL, HIGH
|
||||||
@@ -203,69 +212,6 @@ public final class Message implements Serializable {
|
|||||||
notification = builder.notification;
|
notification = builder.notification;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the collapse key.
|
|
||||||
*/
|
|
||||||
public String getCollapseKey() {
|
|
||||||
return collapseKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the delayWhileIdle flag.
|
|
||||||
*/
|
|
||||||
public Boolean isDelayWhileIdle() {
|
|
||||||
return delayWhileIdle;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the time to live (in seconds).
|
|
||||||
*/
|
|
||||||
public Integer getTimeToLive() {
|
|
||||||
return timeToLive;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the dryRun flag.
|
|
||||||
*/
|
|
||||||
public Boolean isDryRun() {
|
|
||||||
return dryRun;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the restricted package name.
|
|
||||||
*/
|
|
||||||
public String getRestrictedPackageName() {
|
|
||||||
return restrictedPackageName;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the message priority value.
|
|
||||||
*/
|
|
||||||
public String getPriority() {
|
|
||||||
return priority;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the contentAvailable value
|
|
||||||
*/
|
|
||||||
public Boolean getContentAvailable() {
|
|
||||||
return contentAvailable;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the payload data, which is immutable.
|
|
||||||
*/
|
|
||||||
public Map<String, String> getData() {
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets notification payload, which is immutable.
|
|
||||||
*/
|
|
||||||
public Notification getNotification() {
|
|
||||||
return notification;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder builder = new StringBuilder("Message(");
|
StringBuilder builder = new StringBuilder("Message(");
|
||||||
|
|||||||
+15
-67
@@ -22,18 +22,27 @@ import java.io.Serializable;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Result of a GCM multicast message request .
|
* Result of a GCM multicast message request .
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Accessors(chain = true)
|
||||||
public final class MulticastResult implements Serializable {
|
public final class MulticastResult implements Serializable {
|
||||||
|
|
||||||
private final int success;
|
private static final long serialVersionUID = 1L;
|
||||||
private final int failure;
|
|
||||||
private final int canonicalIds;
|
private int success;
|
||||||
private final long multicastId;
|
private int failure;
|
||||||
private final List<Result> results;
|
private int canonicalIds;
|
||||||
private final List<Long> retryMulticastIds;
|
private long multicastId;
|
||||||
|
private List<Result> results;
|
||||||
|
private List<Long> retryMulticastIds;
|
||||||
|
|
||||||
public static final class Builder {
|
public static final class Builder {
|
||||||
|
|
||||||
@@ -82,65 +91,4 @@ public final class MulticastResult implements Serializable {
|
|||||||
}
|
}
|
||||||
retryMulticastIds = Collections.unmodifiableList(tmpList);
|
retryMulticastIds = Collections.unmodifiableList(tmpList);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the multicast id.
|
|
||||||
*/
|
|
||||||
public long getMulticastId() {
|
|
||||||
return multicastId;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the number of successful messages.
|
|
||||||
*/
|
|
||||||
public int getSuccess() {
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the total number of messages sent, regardless of the status.
|
|
||||||
*/
|
|
||||||
public int getTotal() {
|
|
||||||
return success + failure;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the number of failed messages.
|
|
||||||
*/
|
|
||||||
public int getFailure() {
|
|
||||||
return failure;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the number of successful messages that also returned a canonical registration id.
|
|
||||||
*/
|
|
||||||
public int getCanonicalIds() {
|
|
||||||
return canonicalIds;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the results of each individual message, which is immutable.
|
|
||||||
*/
|
|
||||||
public List<Result> getResults() {
|
|
||||||
return results;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets additional ids if more than one multicast message was sent.
|
|
||||||
*/
|
|
||||||
public List<Long> getRetryMulticastIds() {
|
|
||||||
return retryMulticastIds;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
StringBuilder builder = new StringBuilder("MulticastResult(").append("multicast_id=").append(multicastId).append(",")
|
|
||||||
.append("total=").append(getTotal()).append(",").append("success=").append(success).append(",").append("failure=")
|
|
||||||
.append(failure).append(",").append("canonical_ids=").append(canonicalIds).append(",");
|
|
||||||
if (!results.isEmpty()) {
|
|
||||||
builder.append("results: " + results);
|
|
||||||
}
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+19
-96
@@ -21,6 +21,9 @@ package org.apache.fineract.infrastructure.gcm.domain;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GCM message notification part.
|
* GCM message notification part.
|
||||||
@@ -49,20 +52,24 @@ import java.util.List;
|
|||||||
*
|
*
|
||||||
* </code>
|
* </code>
|
||||||
*/
|
*/
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Accessors(chain = true)
|
||||||
public final class Notification implements Serializable {
|
public final class Notification implements Serializable {
|
||||||
|
|
||||||
private final String title;
|
private static final long serialVersionUID = 1L;
|
||||||
private final String body;
|
private String title;
|
||||||
private final String icon;
|
private String body;
|
||||||
private final String sound;
|
private String icon;
|
||||||
private final Integer badge;
|
private String sound;
|
||||||
private final String tag;
|
private Integer badge;
|
||||||
private final String color;
|
private String tag;
|
||||||
private final String clickAction;
|
private String color;
|
||||||
private final String bodyLocKey;
|
private String clickAction;
|
||||||
private final List<String> bodyLocArgs;
|
private String bodyLocKey;
|
||||||
private final String titleLocKey;
|
private List<String> bodyLocArgs;
|
||||||
private final List<String> titleLocArgs;
|
private String titleLocKey;
|
||||||
|
private List<String> titleLocArgs;
|
||||||
|
|
||||||
public static final class Builder {
|
public static final class Builder {
|
||||||
|
|
||||||
@@ -196,90 +203,6 @@ public final class Notification implements Serializable {
|
|||||||
titleLocArgs = builder.titleLocArgs;
|
titleLocArgs = builder.titleLocArgs;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the title.
|
|
||||||
*/
|
|
||||||
public String getTitle() {
|
|
||||||
return title;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the body.
|
|
||||||
*/
|
|
||||||
public String getBody() {
|
|
||||||
return body;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the icon.
|
|
||||||
*/
|
|
||||||
public String getIcon() {
|
|
||||||
return icon;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the sound.
|
|
||||||
*/
|
|
||||||
public String getSound() {
|
|
||||||
return sound;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the badge.
|
|
||||||
*/
|
|
||||||
public Integer getBadge() {
|
|
||||||
return badge;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the tag.
|
|
||||||
*/
|
|
||||||
public String getTag() {
|
|
||||||
return tag;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the color.
|
|
||||||
*/
|
|
||||||
public String getColor() {
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the click action.
|
|
||||||
*/
|
|
||||||
public String getClickAction() {
|
|
||||||
return clickAction;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the body localization key.
|
|
||||||
*/
|
|
||||||
public String getBodyLocKey() {
|
|
||||||
return bodyLocKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the body localization values list, which is immutable.
|
|
||||||
*/
|
|
||||||
public List<String> getBodyLocArgs() {
|
|
||||||
return bodyLocArgs;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the title localization key.
|
|
||||||
*/
|
|
||||||
public String getTitleLocKey() {
|
|
||||||
return titleLocKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the title localization values list, which is immutable.
|
|
||||||
*/
|
|
||||||
public List<String> getTitleLocArgs() {
|
|
||||||
return titleLocArgs;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder builder = new StringBuilder("Notification(");
|
StringBuilder builder = new StringBuilder("Notification(");
|
||||||
|
|||||||
+11
-27
@@ -18,34 +18,18 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.fineract.infrastructure.gcm.domain;
|
package org.apache.fineract.infrastructure.gcm.domain;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Accessors(chain = true)
|
||||||
public class NotificationConfigurationData {
|
public class NotificationConfigurationData {
|
||||||
|
|
||||||
private final Long id;
|
private Long id;
|
||||||
private final String serverKey;
|
private String serverKey;
|
||||||
private final String gcmEndPoint;
|
private String gcmEndPoint;
|
||||||
private final String fcmEndPoint;
|
private String fcmEndPoint;
|
||||||
|
|
||||||
public NotificationConfigurationData(Long id, String serverKey, final String gcmEndPoint, final String fcmEndPoint) {
|
|
||||||
this.id = id;
|
|
||||||
this.serverKey = serverKey;
|
|
||||||
this.gcmEndPoint = gcmEndPoint;
|
|
||||||
this.fcmEndPoint = fcmEndPoint;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getServerKey() {
|
|
||||||
return serverKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getGcmEndPoint() {
|
|
||||||
return gcmEndPoint;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFcmEndPoint() {
|
|
||||||
return fcmEndPoint;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+18
-47
@@ -20,14 +20,17 @@ package org.apache.fineract.infrastructure.gcm.domain;
|
|||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Result of a GCM message request that returned HTTP status code 200.
|
* Result of a GCM message request that returned HTTP status code 200.
|
||||||
*
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* If the message is successfully created, the {@link #getMessageId()} returns the message id and
|
* If the message is successfully created, the {@link #getMessageId()} returns the message id and
|
||||||
* {@link #getErrorCodeName()} returns {@literal null}; otherwise, {@link #getMessageId()} returns {@literal null} and
|
* {@link #getErrorCode()} returns {@literal null}; otherwise, {@link #getMessageId()} returns {@literal null} and
|
||||||
* {@link #getErrorCodeName()} returns the code of the error.
|
* {@link #getErrorCode()} returns the code of the error.
|
||||||
*
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* There are cases when a request is accept and the message successfully created, but GCM has a canonical registration
|
* There are cases when a request is accept and the message successfully created, but GCM has a canonical registration
|
||||||
@@ -39,22 +42,27 @@ import java.util.List;
|
|||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* - Call {@link #getMessageId()}:
|
* - Call {@link #getMessageId()}:
|
||||||
* - {@literal null} means error, call {@link #getErrorCodeName()}
|
* - {@literal null} means error, call {@link #getErrorCode()}
|
||||||
* - non-{@literal null} means the message was created:
|
* - non-{@literal null} means the message was created:
|
||||||
* - Call {@link #getCanonicalRegistrationId()}
|
* - Call {@link #getCanonicalRegistrationId()}
|
||||||
* - if it returns {@literal null}, do nothing.
|
* - if it returns {@literal null}, do nothing.
|
||||||
* - otherwise, update the server datastore with the new id.
|
* - otherwise, update the server datastore with the new id.
|
||||||
* </pre>
|
* </pre>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Accessors(chain = true)
|
||||||
public final class Result implements Serializable {
|
public final class Result implements Serializable {
|
||||||
|
|
||||||
private final String messageId;
|
private static final long serialVersionUID = 1L;
|
||||||
private final String canonicalRegistrationId;
|
private String messageId;
|
||||||
private final String errorCode;
|
private String canonicalRegistrationId;
|
||||||
private final Integer success;
|
private String errorCode;
|
||||||
private final Integer failure;
|
private Integer success;
|
||||||
private final List<String> failedRegistrationIds;
|
private Integer failure;
|
||||||
private final int status;
|
private List<String> failedRegistrationIds;
|
||||||
|
private int status;
|
||||||
|
|
||||||
public static final class Builder {
|
public static final class Builder {
|
||||||
|
|
||||||
@@ -117,39 +125,6 @@ public final class Result implements Serializable {
|
|||||||
status = builder.status;
|
status = builder.status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the message id, if any.
|
|
||||||
*/
|
|
||||||
public String getMessageId() {
|
|
||||||
return messageId;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the canonical registration id, if any.
|
|
||||||
*/
|
|
||||||
public String getCanonicalRegistrationId() {
|
|
||||||
return canonicalRegistrationId;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the error code, if any.
|
|
||||||
*/
|
|
||||||
public String getErrorCodeName() {
|
|
||||||
return errorCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getSuccess() {
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getFailure() {
|
|
||||||
return failure;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> getFailedRegistrationIds() {
|
|
||||||
return failedRegistrationIds;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder builder = new StringBuilder("[");
|
StringBuilder builder = new StringBuilder("[");
|
||||||
@@ -174,8 +149,4 @@ public final class Result implements Serializable {
|
|||||||
return builder.append(" ]").toString();
|
return builder.append(" ]").toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getStatus() {
|
|
||||||
return this.status;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -416,7 +416,7 @@ public class Sender {
|
|||||||
String regId = unsentRegIds.get(i);
|
String regId = unsentRegIds.get(i);
|
||||||
Result result = results.get(i);
|
Result result = results.get(i);
|
||||||
allResults.put(regId, result);
|
allResults.put(regId, result);
|
||||||
String error = result.getErrorCodeName();
|
String error = result.getErrorCode();
|
||||||
if (error != null && (error.equals(GcmConstants.ERROR_UNAVAILABLE) || error.equals(GcmConstants.ERROR_INTERNAL_SERVER_ERROR))) {
|
if (error != null && (error.equals(GcmConstants.ERROR_UNAVAILABLE) || error.equals(GcmConstants.ERROR_INTERNAL_SERVER_ERROR))) {
|
||||||
newUnsentRegIds.add(regId);
|
newUnsentRegIds.add(regId);
|
||||||
}
|
}
|
||||||
@@ -537,8 +537,8 @@ public class Sender {
|
|||||||
setJsonField(mapRequest, PARAM_TIME_TO_LIVE, message.getTimeToLive());
|
setJsonField(mapRequest, PARAM_TIME_TO_LIVE, message.getTimeToLive());
|
||||||
setJsonField(mapRequest, PARAM_COLLAPSE_KEY, message.getCollapseKey());
|
setJsonField(mapRequest, PARAM_COLLAPSE_KEY, message.getCollapseKey());
|
||||||
setJsonField(mapRequest, PARAM_RESTRICTED_PACKAGE_NAME, message.getRestrictedPackageName());
|
setJsonField(mapRequest, PARAM_RESTRICTED_PACKAGE_NAME, message.getRestrictedPackageName());
|
||||||
setJsonField(mapRequest, PARAM_DELAY_WHILE_IDLE, message.isDelayWhileIdle());
|
setJsonField(mapRequest, PARAM_DELAY_WHILE_IDLE, message.getDelayWhileIdle());
|
||||||
setJsonField(mapRequest, PARAM_DRY_RUN, message.isDryRun());
|
setJsonField(mapRequest, PARAM_DRY_RUN, message.getDryRun());
|
||||||
Map<String, String> payload = message.getData();
|
Map<String, String> payload = message.getData();
|
||||||
if (!payload.isEmpty()) {
|
if (!payload.isEmpty()) {
|
||||||
mapRequest.put(JSON_PAYLOAD, payload);
|
mapRequest.put(JSON_PAYLOAD, payload);
|
||||||
|
|||||||
Reference in New Issue
Block a user