Repository: usergrid
Updated Branches:
  refs/heads/master 6dfbb23c9 -> 3e7be17f9


Update the default behavior of the new notification priority.


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

Branch: refs/heads/master
Commit: 3e7be17f95cdd1dc12f3726d3c6a34ad3c0e9de5
Parents: 6dfbb23
Author: Michael Russo <[email protected]>
Authored: Thu Jan 7 15:20:31 2016 -0800
Committer: Michael Russo <[email protected]>
Committed: Thu Jan 7 15:20:31 2016 -0800

----------------------------------------------------------------------
 .../persistence/entities/Notification.java      | 25 ++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/3e7be17f/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 e87b045..34c7758 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
@@ -37,6 +37,11 @@ public class Notification extends TypedEntity {
 
     public static final String RECEIPTS_COLLECTION = "receipts";
 
+    public enum Priority {
+        NORMAL, HIGH
+    }
+
+
     /** Total count of notifications sent based on the API path/query */
     @EntityProperty
     protected int expectedCount;
@@ -180,8 +185,24 @@ public class Notification extends TypedEntity {
 
     @JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
     public String getPriority() {
-        // default the priority to normal if not provided
-        return priority != null ? priority : "normal";
+
+        // simply default the priority to normal so it's never null
+        if (priority == null || priority.isEmpty()){
+            priority = "normal";
+        }
+
+        // validate that the priority available is a valid Usergrid 
notification priority
+        String notificationPriority;
+        try{
+            notificationPriority = 
Priority.valueOf(priority.toUpperCase()).toString();
+        }catch(IllegalArgumentException e){
+            // it's not a valid Usergrid notification priority, default to 
normal
+            notificationPriority = Priority.NORMAL.toString();
+        }
+
+        setPriority(notificationPriority.toLowerCase());
+
+        return priority;
     }
 
     public void setPriority(String priority) {

Reply via email to