falcon-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From venkat...@apache.org
Subject [2/4] incubator-falcon git commit: FALCON-862 Falcon entity Rest API - filter by tags also returns entities that do not have tags. Contributed by Balu Vellanki
Date Fri, 07 Nov 2014 20:39:23 GMT
FALCON-862 Falcon entity Rest API - filter by tags also returns entities that do not have tags.
Contributed by Balu Vellanki


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

Branch: refs/heads/master
Commit: e9b12f47eb16edb1b21930876cfe7b809a1cfd96
Parents: 75d0aeb
Author: Venkatesh Seetharam <venkatesh@apache.org>
Authored: Fri Nov 7 11:23:55 2014 -0800
Committer: Venkatesh Seetharam <venkatesh@apache.org>
Committed: Fri Nov 7 11:23:55 2014 -0800

----------------------------------------------------------------------
 CHANGES.txt                                     |  3 ++
 .../falcon/resource/AbstractEntityManager.java  |  7 +++--
 .../EntityManagerPaginationJerseyIT.java        | 31 ++++++++++++++++++++
 3 files changed, 39 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/e9b12f47/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 42b1337..e021bec 100755
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -129,6 +129,9 @@ Trunk (Unreleased)
   OPTIMIZATIONS
 
   BUG FIXES
+   FALCON-862 Falcon entity Rest API - filter by tags also returns entities
+   that do not have tags (Balu Vellanki via Venkatesh Seetharam)
+
    FALCON-795 Maven Enforcer plugin is throwing error while building Falcon
    (Peeyush Bishnoi via Venkatesh Seetharam)
 

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/e9b12f47/prism/src/main/java/org/apache/falcon/resource/AbstractEntityManager.java
----------------------------------------------------------------------
diff --git a/prism/src/main/java/org/apache/falcon/resource/AbstractEntityManager.java b/prism/src/main/java/org/apache/falcon/resource/AbstractEntityManager.java
index 80b2429..3308d72 100644
--- a/prism/src/main/java/org/apache/falcon/resource/AbstractEntityManager.java
+++ b/prism/src/main/java/org/apache/falcon/resource/AbstractEntityManager.java
@@ -663,8 +663,8 @@ public abstract class AbstractEntityManager {
             return true;
         }
 
-        return !((filterByTags.size() == 0 || tags.size() == 0 || !filterEntityByTags(filterByTags,
tags))
-                && (filterByFieldsValues.size() == 0
+        return !((filterByTags.isEmpty() || !filterEntityByTags(filterByTags, tags))
+                && (filterByFieldsValues.isEmpty()
                 || !filterEntityByFields(entity, filterByFieldsValues, entityStatus, pipelines)));
 
     }
@@ -684,6 +684,9 @@ public abstract class AbstractEntityManager {
 
     private boolean filterEntityByTags(List<String> filterTagsList, List<String>
tags) {
         boolean filterEntity = false;
+        if (!filterTagsList.isEmpty() && tags.isEmpty()) {
+            return true;
+        }
         for (String tag : filterTagsList) {
             if (!tags.contains(tag)) {
                 filterEntity = true;

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/e9b12f47/webapp/src/test/java/org/apache/falcon/resource/EntityManagerPaginationJerseyIT.java
----------------------------------------------------------------------
diff --git a/webapp/src/test/java/org/apache/falcon/resource/EntityManagerPaginationJerseyIT.java
b/webapp/src/test/java/org/apache/falcon/resource/EntityManagerPaginationJerseyIT.java
index faf7b86..fd78b4b 100644
--- a/webapp/src/test/java/org/apache/falcon/resource/EntityManagerPaginationJerseyIT.java
+++ b/webapp/src/test/java/org/apache/falcon/resource/EntityManagerPaginationJerseyIT.java
@@ -83,6 +83,37 @@ public class EntityManagerPaginationJerseyIT {
     }
 
     @Test
+    public void testFilterTags() {
+        ClientResponse response = context.service
+                .path("api/entities/list/process/")
+                .queryParam("tags", "owner=producer@xyz.com, department=forecasting")
+                .queryParam("orderBy", "name").queryParam("sortOrder", "desc").queryParam("offset",
"2")
+                .queryParam("numResults", "2").queryParam("fields", "status,tags")
+                .header("Cookie", context.getAuthenticationToken())
+                .type(MediaType.TEXT_XML)
+                .accept(MediaType.TEXT_XML)
+                .get(ClientResponse.class);
+        Assert.assertEquals(response.getStatus(), 200);
+        EntityList result = response.getEntity(EntityList.class);
+        Assert.assertNotNull(result);
+        Assert.assertEquals(result.getElements().length, 2);
+
+        response = context.service
+                .path("api/entities/list/feed/")
+                .queryParam("tags", "owner=producer@xyz.com, department=forecasting")
+                .queryParam("fields", "status,tags")
+                .header("Cookie", context.getAuthenticationToken())
+                .type(MediaType.TEXT_XML)
+                .accept(MediaType.TEXT_XML)
+                .get(ClientResponse.class);
+        Assert.assertEquals(response.getStatus(), 200);
+        result = response.getEntity(EntityList.class);
+        Assert.assertNotNull(result);
+        Assert.assertNull(result.getElements());
+
+    }
+
+    @Test
     public void testPaginationHugeOffset() throws Exception {
         ClientResponse response = context.service
                 .path("api/entities/list/process/")


Mime
View raw message