airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sma...@apache.org
Subject [1/2] airavata git commit: Resolving User storage preference bugs
Date Wed, 26 Oct 2016 13:52:51 GMT
Repository: airavata
Updated Branches:
  refs/heads/develop ccc708b1b -> 1d710c9d8


Resolving User storage preference bugs


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

Branch: refs/heads/develop
Commit: 8422d23752dbf490c7c0a2f54fa13d6c2d617381
Parents: 76c9eaf
Author: Anuj Bhandar <bhandar.anuj@gmail.com>
Authored: Tue Oct 25 00:46:48 2016 -0400
Committer: Anuj Bhandar <bhandar.anuj@gmail.com>
Committed: Tue Oct 25 00:46:48 2016 -0400

----------------------------------------------------------------------
 .../catalog/impl/UsrResourceProfileImpl.java    |  2 +-
 .../UserStoragePreferenceResource.java          |  4 ++--
 .../app/catalog/UserResourceProfileTest.java    | 21 +++++++++++++++++++-
 3 files changed, 23 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/8422d237/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/impl/UsrResourceProfileImpl.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/impl/UsrResourceProfileImpl.java
b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/impl/UsrResourceProfileImpl.java
index 8d2e42a..ca35727 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/impl/UsrResourceProfileImpl.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/impl/UsrResourceProfileImpl.java
@@ -218,7 +218,7 @@ public class UsrResourceProfileImpl implements UsrResourceProfile {
     public boolean removeUserDataStoragePreferenceFromGateway(String userId, String gatewayId,
String preferenceId) throws AppCatalogException {
         try {
             UserStoragePreferenceResource resource = new UserStoragePreferenceResource();
-            CompositeIdentifier ids = new CompositeIdentifier(userId,gatewayId);
+            CompositeIdentifier ids = new CompositeIdentifier(preferenceId,userId);
             resource.remove(ids);
             return true;
         }catch (Exception e) {

http://git-wip-us.apache.org/repos/asf/airavata/blob/8422d237/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/UserStoragePreferenceResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/UserStoragePreferenceResource.java
b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/UserStoragePreferenceResource.java
index b43dfbd..491436f 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/UserStoragePreferenceResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/UserStoragePreferenceResource.java
@@ -302,7 +302,7 @@ public class UserStoragePreferenceResource extends AppCatAbstractResource
{
             UserResourceProfile userResourceProfile = em.find(UserResourceProfile.class,
userId);
             if (existingPreference != null) {
                 existingPreference.setStorageResourceId(storageResourceId);
-                existingPreference.setGatewayID(userId);
+                existingPreference.setUserId(userId);
                 existingPreference.setGatewayID(gatewayID);
                 existingPreference.setUserResourceProfile(userResourceProfile);
                 existingPreference.setLoginUserName(loginUserName);
@@ -313,7 +313,7 @@ public class UserStoragePreferenceResource extends AppCatAbstractResource
{
                 UserStoragePreference resourcePreference = new UserStoragePreference();
                 resourcePreference.setStorageResourceId(storageResourceId);
                 resourcePreference.setGatewayID(gatewayID);
-                resourcePreference.setGatewayID(userId);
+                resourcePreference.setUserId(userId);
                 resourcePreference.setUserResourceProfile(userResourceProfile);
                 resourcePreference.setLoginUserName(loginUserName);
                 resourcePreference.setComputeResourceCSToken(resourceCSToken);

http://git-wip-us.apache.org/repos/asf/airavata/blob/8422d237/modules/registry/registry-core/src/test/java/org/apache/airavata/app/catalog/UserResourceProfileTest.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/test/java/org/apache/airavata/app/catalog/UserResourceProfileTest.java
b/modules/registry/registry-core/src/test/java/org/apache/airavata/app/catalog/UserResourceProfileTest.java
index 6453066..d85d24c 100644
--- a/modules/registry/registry-core/src/test/java/org/apache/airavata/app/catalog/UserResourceProfileTest.java
+++ b/modules/registry/registry-core/src/test/java/org/apache/airavata/app/catalog/UserResourceProfileTest.java
@@ -25,6 +25,7 @@ import org.apache.airavata.app.catalog.util.Initialize;
 import org.apache.airavata.model.appcatalog.computeresource.ComputeResourceDescription;
 import org.apache.airavata.model.appcatalog.userresourceprofile.UserComputeResourcePreference;
 import org.apache.airavata.model.appcatalog.userresourceprofile.UserResourceProfile;
+import org.apache.airavata.model.appcatalog.userresourceprofile.UserStoragePreference;
 import org.apache.airavata.registry.core.experiment.catalog.impl.RegistryFactory;
 import org.apache.airavata.registry.cpi.AppCatalog;
 import org.apache.airavata.registry.cpi.AppCatalogException;
@@ -90,13 +91,21 @@ public class UserResourceProfileTest {
         preference2.setScratchLocation("/tmp");
         preference2.setAllocationProjectNumber("project2");
 
+        UserStoragePreference storagePreference = new UserStoragePreference();
+        storagePreference.setStorageResourceId("st3");
+        storagePreference.setLoginUserName("Anuj");
+        storagePreference.setFileSystemRootLocation("/home/Anuj/scratch/");
+
         List<UserComputeResourcePreference> list = new ArrayList<UserComputeResourcePreference>();
         list.add(preference1);
         list.add(preference2);
-        System.out.println("input list size : " + list.size());
+        List<UserStoragePreference> stList = new ArrayList<>();
+        stList.add(storagePreference);
+
         uf.setUserComputeResourcePreferences(list);
         uf.setGatewayID("airavataPGA");
         uf.setUserId("Anuj");
+        uf.setUserStoragePreferences(stList);
 
         String gwId = userProfile.addUserResourceProfile(uf);
         UserResourceProfile retrievedProfile = null;
@@ -118,6 +127,16 @@ public class UserResourceProfileTest {
                     System.out.println("Compute Preference removed : " + userProfile.removeUserComputeResourcePreferenceFromGateway(retrievedProfile.getUserId(),retrievedProfile.getGatewayID(),cm.getComputeResourceId()));
                 }
             }
+            List<UserStoragePreference> storagePreferences = userProfile.getAllUserStoragePreferences(retrievedProfile.getUserId(),retrievedProfile.getGatewayID());
+            System.out.println("storage preferences size : " + storagePreferences.size());
+            if (storagePreferences != null && !storagePreferences.isEmpty()){
+                for (UserStoragePreference cm : storagePreferences){
+                    System.out.println("******** storage id ********* : " + cm.getStorageResourceId());
+                    System.out.println(cm.getFileSystemRootLocation());
+                    // this statement will remove all the compute resources created
+                    System.out.println("Storage Preference removed : " + userProfile.removeUserDataStoragePreferenceFromGateway(retrievedProfile.getUserId(),retrievedProfile.getGatewayID(),cm.getStorageResourceId()));
+                }
+            }
             //remove the user resource profile created.
             System.out.println("User Resource profile removed : " + userProfile.removeUserResourceProfile(retrievedProfile.getUserId(),retrievedProfile.getGatewayID()));
         }else{


Mime
View raw message