usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mru...@apache.org
Subject [5/5] usergrid git commit: Add receipts property to the notification entity so it gets persisted.
Date Thu, 14 Apr 2016 23:01:23 GMT
Add receipts property to the notification entity so it gets persisted.


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/8dce5ed8
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/8dce5ed8
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/8dce5ed8

Branch: refs/heads/release-2.1.1
Commit: 8dce5ed8c26a27cd991375803327407f12efc3ca
Parents: 226cb62
Author: Michael Russo <mrusso@apigee.com>
Authored: Fri Apr 15 01:00:58 2016 +0200
Committer: Michael Russo <mrusso@apigee.com>
Committed: Fri Apr 15 01:00:58 2016 +0200

----------------------------------------------------------------------
 .../persistence/entities/Notification.java      | 13 +++++++++
 .../notifications/NotificationsService.java     |  2 ++
 .../impl/ApplicationQueueManagerImpl.java       | 30 ++++++--------------
 3 files changed, 24 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/8dce5ed8/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Notification.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Notification.java
b/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Notification.java
index 1350593..6a6e3fa 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Notification.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Notification.java
@@ -93,6 +93,10 @@ public class Notification extends TypedEntity {
     @EntityProperty
     protected String errorMessage;
 
+    /** Flag to disable the creation, saving, connecting of receipt entities for a notification.
 */
+    @EntityProperty
+    protected boolean saveReceipts;
+
     @EntityCollection(type = "receipt")
     protected List<UUID> receipts;
 
@@ -178,6 +182,15 @@ public class Notification extends TypedEntity {
     }
 
     @JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+    public boolean getSaveReceipts() {
+        return saveReceipts;
+    }
+
+    public void setSaveReceipts(boolean saveReceipts) {
+        this.saveReceipts = saveReceipts;
+    }
+
+    @JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
     public boolean getDebug() {
         return debug;
     }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/8dce5ed8/stack/services/src/main/java/org/apache/usergrid/services/notifications/NotificationsService.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/NotificationsService.java
b/stack/services/src/main/java/org/apache/usergrid/services/notifications/NotificationsService.java
index bbdec7a..824089a 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/NotificationsService.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/NotificationsService.java
@@ -139,6 +139,8 @@ public class NotificationsService extends AbstractCollectionService {
         try {
             validate(null, context.getPayload());
             Notification.PathTokens pathTokens = getPathTokens(context.getRequest().getOriginalParameters());
+            context.getProperties().put("saveReceipts", true); // default saving of receipts
+            context.getProperties().put("processingFinished", 0L); // defaulting processing
finished to 0
             context.getProperties().put("state", Notification.State.CREATED);
             context.getProperties().put("pathQuery", pathTokens);
             context.setOwner(sm.getApplication());

http://git-wip-us.apache.org/repos/asf/usergrid/blob/8dce5ed8/stack/services/src/main/java/org/apache/usergrid/services/notifications/impl/ApplicationQueueManagerImpl.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/impl/ApplicationQueueManagerImpl.java
b/stack/services/src/main/java/org/apache/usergrid/services/notifications/impl/ApplicationQueueManagerImpl.java
index 8b908ee..faa9a02 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/impl/ApplicationQueueManagerImpl.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/impl/ApplicationQueueManagerImpl.java
@@ -329,33 +329,21 @@ public class ApplicationQueueManagerImpl implements ApplicationQueueManager
{
                     String notifierName = message.getNotifierKey().toLowerCase();
                     ProviderAdapter providerAdapter = notifierMap.get(notifierName.toLowerCase());
                     Object payload = translatedPayloads.get(notifierName);
-                    Map dynamicNotificationProperties =notification.getDynamicProperties();
-                    //do additional error checking to make sure other values will work.
-                    Boolean receiptsField = true;
-
-                    Object typelessReceiptsField = dynamicNotificationProperties.getOrDefault(
"receipts",true );
-                    if(typelessReceiptsField instanceof Boolean) {
-                        receiptsField = ( boolean ) typelessReceiptsField;
-                    }
-                    else if(typelessReceiptsField instanceof String){
-                        String booleanString = ( String ) typelessReceiptsField;
-                        if(booleanString.toLowerCase().equals( "false" )){
-                            receiptsField=false;
-                        }
-                    }
 
                     TaskTracker tracker = null;
-                    if(receiptsField==false){
-//                        Receipt receipt =
-//                            new Receipt( notification.getUuid(), message.getNotifierId(),
payload, deviceUUID );
+
+                    if(notification.getSaveReceipts()){
+
+                        final Receipt receipt =
+                            new Receipt( notification.getUuid(), message.getNotifierId(),
payload, deviceUUID );
                         tracker =
-                            new TaskTracker( providerAdapter.getNotifier(), taskManager,
null, deviceUUID );
+                            new TaskTracker( providerAdapter.getNotifier(), taskManager,
receipt, deviceUUID );
+
                     }
                     else {
-                        Receipt receipt =
-                            new Receipt( notification.getUuid(), message.getNotifierId(),
payload, deviceUUID );
+
                         tracker =
-                            new TaskTracker( providerAdapter.getNotifier(), taskManager,
receipt, deviceUUID );
+                            new TaskTracker( providerAdapter.getNotifier(), taskManager,
null, deviceUUID );
                     }
                     if (!isOkToSend(notification)) {
                         tracker.failed(0, "Notification is duplicate/expired/cancelled.");


Mime
View raw message