You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sm...@apache.org on 2016/10/26 13:46:22 UTC

airavata git commit: AIRAVATA-2156 Add isNull field to UserResourceProfile

Repository: airavata
Updated Branches:
  refs/heads/develop 76c9eaf90 -> ccc708b1b


AIRAVATA-2156 Add isNull field to UserResourceProfile


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

Branch: refs/heads/develop
Commit: ccc708b1bf99594500ec14c83707d13fa9245f9b
Parents: 76c9eaf
Author: Marcus Christie <ma...@iu.edu>
Authored: Fri Oct 21 16:33:19 2016 -0400
Committer: Marcus Christie <ma...@iu.edu>
Committed: Fri Oct 21 16:33:19 2016 -0400

----------------------------------------------------------------------
 .../UserResourceProfile.java                    | 116 ++++++++++++++++++-
 .../catalog/impl/UsrResourceProfileImpl.java    |   2 +-
 .../util/AppCatalogThriftConversion.java        |   5 +
 .../app/catalog/UserResourceProfileTest.java    |  10 +-
 .../user_resource_profile_model.thrift          |   6 +-
 5 files changed, 132 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/ccc708b1/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/appcatalog/userresourceprofile/UserResourceProfile.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/appcatalog/userresourceprofile/UserResourceProfile.java b/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/appcatalog/userresourceprofile/UserResourceProfile.java
index bab4802..5ac614d 100644
--- a/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/appcatalog/userresourceprofile/UserResourceProfile.java
+++ b/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/appcatalog/userresourceprofile/UserResourceProfile.java
@@ -70,6 +70,9 @@ import org.slf4j.LoggerFactory;
  * 
  *  identityServerPwdCredToken:
  * 
+ * isNull:
+ *  Indicates that this instance is just a container for a null value.
+ * 
  */
 @Generated(value = "Autogenerated by Thrift Compiler (0.9.3)")
 public class UserResourceProfile implements org.apache.thrift.TBase<UserResourceProfile, UserResourceProfile._Fields>, java.io.Serializable, Cloneable, Comparable<UserResourceProfile> {
@@ -82,6 +85,7 @@ public class UserResourceProfile implements org.apache.thrift.TBase<UserResource
   private static final org.apache.thrift.protocol.TField USER_STORAGE_PREFERENCES_FIELD_DESC = new org.apache.thrift.protocol.TField("userStoragePreferences", org.apache.thrift.protocol.TType.LIST, (short)5);
   private static final org.apache.thrift.protocol.TField IDENTITY_SERVER_TENANT_FIELD_DESC = new org.apache.thrift.protocol.TField("identityServerTenant", org.apache.thrift.protocol.TType.STRING, (short)6);
   private static final org.apache.thrift.protocol.TField IDENTITY_SERVER_PWD_CRED_TOKEN_FIELD_DESC = new org.apache.thrift.protocol.TField("identityServerPwdCredToken", org.apache.thrift.protocol.TType.STRING, (short)7);
+  private static final org.apache.thrift.protocol.TField IS_NULL_FIELD_DESC = new org.apache.thrift.protocol.TField("isNull", org.apache.thrift.protocol.TType.BOOL, (short)8);
 
   private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
   static {
@@ -96,6 +100,7 @@ public class UserResourceProfile implements org.apache.thrift.TBase<UserResource
   private List<UserStoragePreference> userStoragePreferences; // optional
   private String identityServerTenant; // optional
   private String identityServerPwdCredToken; // optional
+  private boolean isNull; // optional
 
   /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
   public enum _Fields implements org.apache.thrift.TFieldIdEnum {
@@ -105,7 +110,8 @@ public class UserResourceProfile implements org.apache.thrift.TBase<UserResource
     USER_COMPUTE_RESOURCE_PREFERENCES((short)4, "userComputeResourcePreferences"),
     USER_STORAGE_PREFERENCES((short)5, "userStoragePreferences"),
     IDENTITY_SERVER_TENANT((short)6, "identityServerTenant"),
-    IDENTITY_SERVER_PWD_CRED_TOKEN((short)7, "identityServerPwdCredToken");
+    IDENTITY_SERVER_PWD_CRED_TOKEN((short)7, "identityServerPwdCredToken"),
+    IS_NULL((short)8, "isNull");
 
     private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
 
@@ -134,6 +140,8 @@ public class UserResourceProfile implements org.apache.thrift.TBase<UserResource
           return IDENTITY_SERVER_TENANT;
         case 7: // IDENTITY_SERVER_PWD_CRED_TOKEN
           return IDENTITY_SERVER_PWD_CRED_TOKEN;
+        case 8: // IS_NULL
+          return IS_NULL;
         default:
           return null;
       }
@@ -174,7 +182,9 @@ public class UserResourceProfile implements org.apache.thrift.TBase<UserResource
   }
 
   // isset id assignments
-  private static final _Fields optionals[] = {_Fields.CREDENTIAL_STORE_TOKEN,_Fields.USER_COMPUTE_RESOURCE_PREFERENCES,_Fields.USER_STORAGE_PREFERENCES,_Fields.IDENTITY_SERVER_TENANT,_Fields.IDENTITY_SERVER_PWD_CRED_TOKEN};
+  private static final int __ISNULL_ISSET_ID = 0;
+  private byte __isset_bitfield = 0;
+  private static final _Fields optionals[] = {_Fields.CREDENTIAL_STORE_TOKEN,_Fields.USER_COMPUTE_RESOURCE_PREFERENCES,_Fields.USER_STORAGE_PREFERENCES,_Fields.IDENTITY_SERVER_TENANT,_Fields.IDENTITY_SERVER_PWD_CRED_TOKEN,_Fields.IS_NULL};
   public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
   static {
     Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
@@ -194,11 +204,15 @@ public class UserResourceProfile implements org.apache.thrift.TBase<UserResource
         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
     tmpMap.put(_Fields.IDENTITY_SERVER_PWD_CRED_TOKEN, new org.apache.thrift.meta_data.FieldMetaData("identityServerPwdCredToken", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+    tmpMap.put(_Fields.IS_NULL, new org.apache.thrift.meta_data.FieldMetaData("isNull", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL)));
     metaDataMap = Collections.unmodifiableMap(tmpMap);
     org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(UserResourceProfile.class, metaDataMap);
   }
 
   public UserResourceProfile() {
+    this.isNull = false;
+
   }
 
   public UserResourceProfile(
@@ -214,6 +228,7 @@ public class UserResourceProfile implements org.apache.thrift.TBase<UserResource
    * Performs a deep copy on <i>other</i>.
    */
   public UserResourceProfile(UserResourceProfile other) {
+    __isset_bitfield = other.__isset_bitfield;
     if (other.isSetUserId()) {
       this.userId = other.userId;
     }
@@ -243,6 +258,7 @@ public class UserResourceProfile implements org.apache.thrift.TBase<UserResource
     if (other.isSetIdentityServerPwdCredToken()) {
       this.identityServerPwdCredToken = other.identityServerPwdCredToken;
     }
+    this.isNull = other.isNull;
   }
 
   public UserResourceProfile deepCopy() {
@@ -258,6 +274,8 @@ public class UserResourceProfile implements org.apache.thrift.TBase<UserResource
     this.userStoragePreferences = null;
     this.identityServerTenant = null;
     this.identityServerPwdCredToken = null;
+    this.isNull = false;
+
   }
 
   public String getUserId() {
@@ -451,6 +469,28 @@ public class UserResourceProfile implements org.apache.thrift.TBase<UserResource
     }
   }
 
+  public boolean isIsNull() {
+    return this.isNull;
+  }
+
+  public void setIsNull(boolean isNull) {
+    this.isNull = isNull;
+    setIsNullIsSet(true);
+  }
+
+  public void unsetIsNull() {
+    __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __ISNULL_ISSET_ID);
+  }
+
+  /** Returns true if field isNull is set (has been assigned a value) and false otherwise */
+  public boolean isSetIsNull() {
+    return EncodingUtils.testBit(__isset_bitfield, __ISNULL_ISSET_ID);
+  }
+
+  public void setIsNullIsSet(boolean value) {
+    __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __ISNULL_ISSET_ID, value);
+  }
+
   public void setFieldValue(_Fields field, Object value) {
     switch (field) {
     case USER_ID:
@@ -509,6 +549,14 @@ public class UserResourceProfile implements org.apache.thrift.TBase<UserResource
       }
       break;
 
+    case IS_NULL:
+      if (value == null) {
+        unsetIsNull();
+      } else {
+        setIsNull((Boolean)value);
+      }
+      break;
+
     }
   }
 
@@ -535,6 +583,9 @@ public class UserResourceProfile implements org.apache.thrift.TBase<UserResource
     case IDENTITY_SERVER_PWD_CRED_TOKEN:
       return getIdentityServerPwdCredToken();
 
+    case IS_NULL:
+      return isIsNull();
+
     }
     throw new IllegalStateException();
   }
@@ -560,6 +611,8 @@ public class UserResourceProfile implements org.apache.thrift.TBase<UserResource
       return isSetIdentityServerTenant();
     case IDENTITY_SERVER_PWD_CRED_TOKEN:
       return isSetIdentityServerPwdCredToken();
+    case IS_NULL:
+      return isSetIsNull();
     }
     throw new IllegalStateException();
   }
@@ -640,6 +693,15 @@ public class UserResourceProfile implements org.apache.thrift.TBase<UserResource
         return false;
     }
 
+    boolean this_present_isNull = true && this.isSetIsNull();
+    boolean that_present_isNull = true && that.isSetIsNull();
+    if (this_present_isNull || that_present_isNull) {
+      if (!(this_present_isNull && that_present_isNull))
+        return false;
+      if (this.isNull != that.isNull)
+        return false;
+    }
+
     return true;
   }
 
@@ -682,6 +744,11 @@ public class UserResourceProfile implements org.apache.thrift.TBase<UserResource
     if (present_identityServerPwdCredToken)
       list.add(identityServerPwdCredToken);
 
+    boolean present_isNull = true && (isSetIsNull());
+    list.add(present_isNull);
+    if (present_isNull)
+      list.add(isNull);
+
     return list.hashCode();
   }
 
@@ -763,6 +830,16 @@ public class UserResourceProfile implements org.apache.thrift.TBase<UserResource
         return lastComparison;
       }
     }
+    lastComparison = Boolean.valueOf(isSetIsNull()).compareTo(other.isSetIsNull());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetIsNull()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.isNull, other.isNull);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
     return 0;
   }
 
@@ -848,6 +925,12 @@ public class UserResourceProfile implements org.apache.thrift.TBase<UserResource
       }
       first = false;
     }
+    if (isSetIsNull()) {
+      if (!first) sb.append(", ");
+      sb.append("isNull:");
+      sb.append(this.isNull);
+      first = false;
+    }
     sb.append(")");
     return sb.toString();
   }
@@ -875,6 +958,8 @@ public class UserResourceProfile implements org.apache.thrift.TBase<UserResource
 
   private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
     try {
+      // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
+      __isset_bitfield = 0;
       read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
     } catch (org.apache.thrift.TException te) {
       throw new java.io.IOException(te);
@@ -977,6 +1062,14 @@ public class UserResourceProfile implements org.apache.thrift.TBase<UserResource
               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
             }
             break;
+          case 8: // IS_NULL
+            if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) {
+              struct.isNull = iprot.readBool();
+              struct.setIsNullIsSet(true);
+            } else { 
+              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+            }
+            break;
           default:
             org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
         }
@@ -1049,6 +1142,11 @@ public class UserResourceProfile implements org.apache.thrift.TBase<UserResource
           oprot.writeFieldEnd();
         }
       }
+      if (struct.isSetIsNull()) {
+        oprot.writeFieldBegin(IS_NULL_FIELD_DESC);
+        oprot.writeBool(struct.isNull);
+        oprot.writeFieldEnd();
+      }
       oprot.writeFieldStop();
       oprot.writeStructEnd();
     }
@@ -1084,7 +1182,10 @@ public class UserResourceProfile implements org.apache.thrift.TBase<UserResource
       if (struct.isSetIdentityServerPwdCredToken()) {
         optionals.set(4);
       }
-      oprot.writeBitSet(optionals, 5);
+      if (struct.isSetIsNull()) {
+        optionals.set(5);
+      }
+      oprot.writeBitSet(optionals, 6);
       if (struct.isSetCredentialStoreToken()) {
         oprot.writeString(struct.credentialStoreToken);
       }
@@ -1112,6 +1213,9 @@ public class UserResourceProfile implements org.apache.thrift.TBase<UserResource
       if (struct.isSetIdentityServerPwdCredToken()) {
         oprot.writeString(struct.identityServerPwdCredToken);
       }
+      if (struct.isSetIsNull()) {
+        oprot.writeBool(struct.isNull);
+      }
     }
 
     @Override
@@ -1121,7 +1225,7 @@ public class UserResourceProfile implements org.apache.thrift.TBase<UserResource
       struct.setUserIdIsSet(true);
       struct.gatewayID = iprot.readString();
       struct.setGatewayIDIsSet(true);
-      BitSet incoming = iprot.readBitSet(5);
+      BitSet incoming = iprot.readBitSet(6);
       if (incoming.get(0)) {
         struct.credentialStoreToken = iprot.readString();
         struct.setCredentialStoreTokenIsSet(true);
@@ -1162,6 +1266,10 @@ public class UserResourceProfile implements org.apache.thrift.TBase<UserResource
         struct.identityServerPwdCredToken = iprot.readString();
         struct.setIdentityServerPwdCredTokenIsSet(true);
       }
+      if (incoming.get(5)) {
+        struct.isNull = iprot.readBool();
+        struct.setIsNullIsSet(true);
+      }
     }
   }
 

http://git-wip-us.apache.org/repos/asf/airavata/blob/ccc708b1/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..948400b 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
@@ -180,7 +180,7 @@ public class UsrResourceProfileImpl implements UsrResourceProfile {
             if(uResource != null){
                 return AppCatalogThriftConversion.getUserResourceProfile(uResource, userComputeResourcePreferences, dataStoragePreferences);
             }else{
-                return null;
+                return AppCatalogThriftConversion.createNullUserResourceProfile(userId, gatewayId);
             }
         }catch (Exception e) {
             logger.error("Error while retrieving user resource profile...", e);

http://git-wip-us.apache.org/repos/asf/airavata/blob/ccc708b1/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogThriftConversion.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogThriftConversion.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogThriftConversion.java
index ca9549a..8ddf4f6 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogThriftConversion.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogThriftConversion.java
@@ -948,4 +948,9 @@ public class AppCatalogThriftConversion {
         return userResourceProfile;
     }
 
+    public static UserResourceProfile createNullUserResourceProfile(String userId, String gatewayId){
+        UserResourceProfile userResourceProfile = new UserResourceProfile(userId, gatewayId);
+        userResourceProfile.setIsNull(true);
+        return userResourceProfile;
+    }
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/ccc708b1/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..6764377 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
@@ -39,7 +39,7 @@ import org.slf4j.LoggerFactory;
 import java.util.ArrayList;
 import java.util.List;
 
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
 
 public class UserResourceProfileTest {
     private static Initialize initialize;
@@ -98,11 +98,19 @@ public class UserResourceProfileTest {
         uf.setGatewayID("airavataPGA");
         uf.setUserId("Anuj");
 
+        // Check if UserResourceProfile exists (should not exist)
+        // This tests the mechanism that PGA will use to figure out if a user doesn't already have a UserResourceProfile
+        UserResourceProfile checkUserResourceProfile = userProfile.getUserResourceProfile(uf.getUserId(), uf.getGatewayID());
+        assertNotNull(checkUserResourceProfile.getUserId());
+        assertNotNull(checkUserResourceProfile.getGatewayID());
+        assertTrue(checkUserResourceProfile.isIsNull());
+
         String gwId = userProfile.addUserResourceProfile(uf);
         UserResourceProfile retrievedProfile = null;
         //retrievedProfile = userProfile.getUserResourceProfile("hello",uf.getGatewayID());
         if (userProfile.isUserResourceProfileExists(uf.getUserId(),uf.getGatewayID())){
             retrievedProfile = userProfile.getUserResourceProfile(uf.getUserId(),uf.getGatewayID());
+            assertFalse(retrievedProfile.isIsNull());
             System.out.println("gateway ID :" + retrievedProfile.getGatewayID());
             System.out.println("user ID : " + retrievedProfile.getUserId());
             System.out.println("compute resource size : " + retrievedProfile.getUserComputeResourcePreferencesSize());

http://git-wip-us.apache.org/repos/asf/airavata/blob/ccc708b1/thrift-interface-descriptions/data-models/resource-catalog-models/user_resource_profile_model.thrift
----------------------------------------------------------------------
diff --git a/thrift-interface-descriptions/data-models/resource-catalog-models/user_resource_profile_model.thrift b/thrift-interface-descriptions/data-models/resource-catalog-models/user_resource_profile_model.thrift
index 57053cb..fd4784d 100644
--- a/thrift-interface-descriptions/data-models/resource-catalog-models/user_resource_profile_model.thrift
+++ b/thrift-interface-descriptions/data-models/resource-catalog-models/user_resource_profile_model.thrift
@@ -93,6 +93,9 @@ struct UserStoragePreference {
  *
  *  identityServerPwdCredToken:
  *
+ * isNull:
+ *  Indicates that this instance is just a container for a null value.
+ *
 */
 struct UserResourceProfile {
     1: required string userId,
@@ -101,5 +104,6 @@ struct UserResourceProfile {
     4: optional list<UserComputeResourcePreference> userComputeResourcePreferences,
     5: optional list<UserStoragePreference> userStoragePreferences,
     6: optional string identityServerTenant,
-    7: optional string identityServerPwdCredToken
+    7: optional string identityServerPwdCredToken,
+    8: optional bool isNull = false
 }
\ No newline at end of file