bypass ES for push notification devices specified by UUID

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

Branch: refs/heads/master
Commit: e8dc09bb3961ae91f5631b14344c7bcd62539263
Parents: 455bdde
Author: Mike Dunker <[email protected]>
Authored: Sat Feb 24 15:59:39 2018 -0800
Committer: Keyur Karnik <[email protected]>
Committed: Tue Aug 28 16:41:43 2018 -0700

----------------------------------------------------------------------
 .../apache/usergrid/persistence/PathQuery.java  | 34 ++++++++++++++++++--
 1 file changed, 32 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/e8dc09bb/stack/core/src/main/java/org/apache/usergrid/persistence/PathQuery.java
----------------------------------------------------------------------
diff --git 
a/stack/core/src/main/java/org/apache/usergrid/persistence/PathQuery.java 
b/stack/core/src/main/java/org/apache/usergrid/persistence/PathQuery.java
index c5833af..51b20c6 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/PathQuery.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/PathQuery.java
@@ -23,10 +23,14 @@ import java.util.UUID;
 
 import org.apache.usergrid.persistence.Query.Level;
 import org.apache.usergrid.utils.InflectionUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
 public class PathQuery<E> {
 
+    private static final Logger logger = LoggerFactory.getLogger( 
PathQuery.class );
+
     private PathQuery source;
     private Query query;
     private UUID uuid;
@@ -122,10 +126,30 @@ public class PathQuery<E> {
 
         EntityRef ref = new SimpleEntityRef(type,uuid);
 
-        // if it's a single name identifier, just directly fetch that
-        if ( !query.getQl().isPresent() && 
query.getSingleNameOrEmailIdentifier() != null){
+        if ( !query.getQl().isPresent() && query.getSingleUuidIdentifier() != 
null) {
+
+            // fetch entity by UUID directly
+            UUID entityUUID = query.getSingleUuidIdentifier();
+
+            if (logger.isTraceEnabled()) {
+                logger.trace("getHeadResults(): identified path uuid: 
appid={}, collection={}, entityUUID={}",
+                    uuid.toString(), query.getCollection(), 
entityUUID.toString());
+            }
+
+            String entityType = 
InflectionUtils.singularize(query.getCollection());
+
+            return em.getEntities(Collections.singletonList(entityUUID), 
entityType);
 
+        } else if ( !query.getQl().isPresent() && 
query.getSingleNameOrEmailIdentifier() != null){
+
+            // if it's a single name identifier, just directly fetch that
             String name = query.getSingleNameOrEmailIdentifier();
+
+            if (logger.isTraceEnabled()) {
+                logger.trace("getHeadResults(): identified path name/email: 
appid={}, collection={}, name={}",
+                    uuid.toString(), query.getCollection(), name);
+            }
+
             String entityType = 
InflectionUtils.singularize(query.getCollection());
 
             // don't use unique index repair on read only logic
@@ -140,6 +164,12 @@ public class PathQuery<E> {
             return em.getEntities(Collections.singletonList(entityId), 
entityType);
         }
 
+        if (logger.isTraceEnabled()) {
+            logger.trace("getHeadResults(): sending query to ES: appid={}, 
collection={}, query=[{}]",
+                uuid.toString(), query.getCollection(),
+                query.getQl().isPresent() ? query.getQl().get() : "NONE");
+        }
+
         return ( query.getCollection() != null ) ?
                em.searchCollection( ref, query.getCollection(), query ) :
                em.searchTargetEntities(ref, query);

Reply via email to