This is an automated email from the ASF dual-hosted git repository.

machristie pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/airavata.git


The following commit(s) were added to refs/heads/develop by this push:
     new 6019b23  AIRAVATA-3003 Don't return any GroupResourceProfiles is none 
accessible
6019b23 is described below

commit 6019b23fcf3a8aaee582c5f0e85ef058093064d2
Author: Marcus Christie <[email protected]>
AuthorDate: Wed Apr 10 16:21:35 2019 -0400

    AIRAVATA-3003 Don't return any GroupResourceProfiles is none accessible
---
 .../core/repositories/appcatalog/GroupResourceProfileRepository.java | 5 +++--
 .../java/org/apache/airavata/registry/core/utils/QueryConstants.java | 2 --
 .../repositories/appcatalog/GroupResourceProfileRepositoryTest.java  | 4 +++-
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git 
a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/repositories/appcatalog/GroupResourceProfileRepository.java
 
b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/repositories/appcatalog/GroupResourceProfileRepository.java
index 07709b2..7266b3d 100644
--- 
a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/repositories/appcatalog/GroupResourceProfileRepository.java
+++ 
b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/repositories/appcatalog/GroupResourceProfileRepository.java
@@ -29,6 +29,7 @@ import 
org.apache.airavata.registry.core.entities.appcatalog.GroupResourceProfil
 import org.apache.airavata.registry.core.utils.DBConstants;
 import org.apache.airavata.registry.core.utils.QueryConstants;
 
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -107,9 +108,9 @@ public class GroupResourceProfileRepository extends 
AppCatAbstractRepository<Gro
         if (accessibleGroupResProfileIds != null && 
!accessibleGroupResProfileIds.isEmpty()) {
             
queryParameters.put(DBConstants.GroupResourceProfile.ACCESSIBLE_GROUP_RESOURCE_IDS,
 accessibleGroupResProfileIds);
             return 
select(QueryConstants.FIND_ACCESSIBLE_GROUP_RESOURCE_PROFILES, -1, 0, 
queryParameters);
+        } else {
+            return Collections.emptyList();
         }
-        List<GroupResourceProfile> groupResourceProfileList = 
select(QueryConstants.FIND_ALL_GROUP_RESOURCE_PROFILES, -1, 0, queryParameters);
-        return groupResourceProfileList;
     }
 
     public boolean removeGroupComputeResourcePreference(String 
computeResourceId, String groupResourceProfileId) {
diff --git 
a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/utils/QueryConstants.java
 
b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/utils/QueryConstants.java
index 1fe4c46..7fa29cd 100644
--- 
a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/utils/QueryConstants.java
+++ 
b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/utils/QueryConstants.java
@@ -97,8 +97,6 @@ public interface QueryConstants {
     String FIND_ACCESSIBLE_GROUP_RESOURCE_PROFILES = "SELECT G FROM " + 
GroupResourceProfileEntity.class.getSimpleName() + " G " +
             "WHERE G.gatewayId LIKE :" + 
DBConstants.GroupResourceProfile.GATEWAY_ID + " AND G.groupResourceProfileId IN 
:"
             + DBConstants.GroupResourceProfile.ACCESSIBLE_GROUP_RESOURCE_IDS;
-    String FIND_ALL_GROUP_RESOURCE_PROFILES = "SELECT G FROM " + 
GroupResourceProfileEntity.class.getSimpleName() + " G " +
-            "WHERE G.gatewayId LIKE :" + 
DBConstants.GroupResourceProfile.GATEWAY_ID;
     String FIND_ALL_GROUP_COMPUTE_PREFERENCES = "SELECT GC FROM "+ 
GroupComputeResourcePrefEntity.class.getSimpleName() + " GC " +
             "WHERE GC.groupResourceProfileId LIKE :" + 
DBConstants.GroupResourceProfile.GROUP_RESOURCE_PROFILE_ID;
     String FIND_ALL_GROUP_BATCH_QUEUE_RESOURCE_POLICY = "SELECT BQ FROM "+ 
BatchQueueResourcePolicyEntity.class.getSimpleName() + " BQ " +
diff --git 
a/modules/registry/registry-core/src/test/java/org/apache/airavata/registry/core/repositories/appcatalog/GroupResourceProfileRepositoryTest.java
 
b/modules/registry/registry-core/src/test/java/org/apache/airavata/registry/core/repositories/appcatalog/GroupResourceProfileRepositoryTest.java
index 2489094..4a871ce 100644
--- 
a/modules/registry/registry-core/src/test/java/org/apache/airavata/registry/core/repositories/appcatalog/GroupResourceProfileRepositoryTest.java
+++ 
b/modules/registry/registry-core/src/test/java/org/apache/airavata/registry/core/repositories/appcatalog/GroupResourceProfileRepositoryTest.java
@@ -29,6 +29,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 
 import static org.junit.Assert.assertEquals;
@@ -203,7 +204,8 @@ public class GroupResourceProfileRepositoryTest extends 
TestBase {
         assertTrue(getBatchQueuePolicy.getMaxAllowedCores() == 3);
         assertTrue(getBatchQueuePolicy.getMaxAllowedWalltime() == 12);
 
-        
assertTrue(groupResourceProfileRepository.getAllGroupResourceProfiles(gatewayId,
 null).size() == 1);
+        
assertTrue(groupResourceProfileRepository.getAllGroupResourceProfiles(gatewayId,
 null).size() == 0);
+        
assertTrue(groupResourceProfileRepository.getAllGroupResourceProfiles(gatewayId,
 Collections.emptyList()).size() == 0);
         
assertTrue(groupResourceProfileRepository.getAllGroupComputeResourcePreferences(groupResourceProfileId).size()
 == 2);
         
assertTrue(groupResourceProfileRepository.getAllGroupComputeResourcePolicies(groupResourceProfileId).size()
 == 2);
         
assertTrue(groupResourceProfileRepository.getAllGroupBatchQueueResourcePolicies(groupResourceProfileId).size()
 == 2);

Reply via email to