You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sh...@apache.org on 2016/10/07 20:52:30 UTC

[03/31] airavata git commit: Feature request: User Compute Preference

http://git-wip-us.apache.org/repos/asf/airavata/blob/81c6ea84/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/UserStoragePreference.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/UserStoragePreference.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/UserStoragePreference.java
new file mode 100644
index 0000000..49915b5
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/UserStoragePreference.java
@@ -0,0 +1,106 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.registry.core.app.catalog.model;
+
+
+import javax.persistence.*;
+
+@Entity
+@Table(name = "USER_STORAGE_PREFERENCE")
+@IdClass(StoragePreferencePK.class)
+public class UserStoragePreference {
+    @Id
+    @Column(name = "USER_ID")
+    private String userId;
+    @Id
+    @Column(name = "GATEWAY_ID")
+    private String gatewayId;
+    @Id
+    @Column(name = "STORAGE_RESOURCE_ID")
+    private String storageResourceId;
+    @Column(name = "LOGIN_USERNAME")
+    private String loginUserName;
+    @Column(name = "FS_ROOT_LOCATION")
+    private String fsRootLocation;
+    @Column(name = "RESOURCE_CS_TOKEN")
+    private String computeResourceCSToken;
+
+    @ManyToOne(cascade= CascadeType.MERGE)
+    @JoinColumn(name = "GATEWAY_ID")
+    private UserResourceProfile userResourceProfile;
+
+    public String getUserId() {
+        return userId;
+    }
+
+    public void setUserId(String userId) {
+        this.userId = userId;
+    }
+
+    public String getGatewayId() {
+        return gatewayId;
+    }
+
+    public void setGatewayId(String gatewayId) {
+        this.gatewayId = gatewayId;
+    }
+
+    public UserResourceProfile getUserResourceProfile() {
+        return userResourceProfile;
+    }
+
+    public void setUserResourceProfile(UserResourceProfile userResourceProfile) {
+        this.userResourceProfile = userResourceProfile;
+    }
+
+    public String getLoginUserName() {
+        return loginUserName;
+    }
+
+    public void setLoginUserName(String loginUserName) {
+        this.loginUserName = loginUserName;
+    }
+
+    public String getComputeResourceCSToken() {
+        return computeResourceCSToken;
+    }
+
+    public void setComputeResourceCSToken(String computeResourceCSToken) {
+        this.computeResourceCSToken = computeResourceCSToken;
+    }
+
+    public String getFsRootLocation() {
+        return fsRootLocation;
+    }
+
+    public void setFsRootLocation(String fsRootLocation) {
+        this.fsRootLocation = fsRootLocation;
+    }
+
+    public String getStorageResourceId() {
+        return storageResourceId;
+    }
+
+    public void setStorageResourceId(String storageResourceId) {
+        this.storageResourceId = storageResourceId;
+    }
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/81c6ea84/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/UserStoragePreferencePK.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/UserStoragePreferencePK.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/UserStoragePreferencePK.java
new file mode 100644
index 0000000..35a6f42
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/UserStoragePreferencePK.java
@@ -0,0 +1,73 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.registry.core.app.catalog.model;
+
+import java.io.Serializable;
+
+public class UserStoragePreferencePK implements Serializable {
+
+    private String userId;
+    private String gatewayId;
+    private String storageResourceId;
+
+    public UserStoragePreferencePK(String userId, String storageResourceId) {
+        this.userId = userId;
+        this.storageResourceId = storageResourceId;
+    }
+
+    public UserStoragePreferencePK() {
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        return false;
+    }
+
+    @Override
+    public int hashCode() {
+        return 1;
+    }
+
+    public String getUserId() {
+        return userId;
+    }
+
+    public void setUserId(String userId) {
+        this.userId = userId;
+    }
+
+    public String getGatewayId() {
+        return gatewayId;
+    }
+
+    public void setGatewayId(String gatewayId) {
+        this.gatewayId = gatewayId;
+    }
+
+    public String getStorageResourceId() {
+        return storageResourceId;
+    }
+
+    public void setStorageResourceId(String storageResourceId) {
+        this.storageResourceId = storageResourceId;
+    }
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/81c6ea84/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppCatAbstractResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppCatAbstractResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppCatAbstractResource.java
index 2fb4a77..0846a47 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppCatAbstractResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppCatAbstractResource.java
@@ -54,8 +54,11 @@ public abstract class AppCatAbstractResource implements AppCatalogResource {
     public static final String APPLICATION_OUTPUT = "ApplicationIntOutput";
     public static final String WORKFLOW_OUTPUT = "WorkflowOutput";
     public static final String GATEWAY_PROFILE = "GatewayProfile";
+    public static final String USER_RESOURCE_PROFILE = "userResourceProfile";
     public static final String COMPUTE_RESOURCE_PREFERENCE = "ComputeResourcePreference";
+    public static final String USER_COMPUTE_RESOURCE_PREFERENCE = "UserComputeResourcePreference";
     public static final String STORAGE_PREFERENCE = "StoragePreference";
+    public static final String USER_STORAGE_PREFERENCE = "UserStoragePreference";
 	public static final String BATCH_QUEUE = "BatchQueue";
 	public static final String COMPUTE_RESOURCE_FILE_SYSTEM = "ComputeResourceFileSystem";
 	public static final String JOB_SUBMISSION_INTERFACE = "JobSubmissionInterface";
@@ -285,6 +288,12 @@ public abstract class AppCatAbstractResource implements AppCatalogResource {
         public static final String GATEWAY_DESC = "gatewayDesc";
     }
 
+    public final class UserResourceProfileConstants {
+        public static final String GATEWAY_ID = "gatewayID";
+        public static final String USER_ID = "userId";
+        public static final String GATEWAY_DESC = "gatewayDesc";
+    }
+
     public final class ComputeResourcePreferenceConstants {
         public static final String GATEWAY_ID = "gatewayId";
         public static final String RESOURCE_ID = "resourceId";
@@ -296,6 +305,15 @@ public abstract class AppCatAbstractResource implements AppCatalogResource {
         public static final String ALLOCATION_PROJECT_NUMBER = "projectNumber";
     }
 
+    public final class UserComputeResourcePreferenceConstants {
+        public static final String GATEWAY_ID = "gatewayId";
+        public static final String USER_ID = "userId";
+        public static final String RESOURCE_ID = "resourceId";
+        public static final String PREFERED_BATCH_QUEUE = "batchQueue";
+        public static final String SCRATCH_LOCATION = "scratchLocation";
+        public static final String ALLOCATION_PROJECT_NUMBER = "projectNumber";
+    }
+
     // Batch Queue Table
  	public final class BatchQueueConstants {
  		public static final String COMPUTE_RESOURCE_ID = "computeResourceId";
@@ -342,6 +360,12 @@ public abstract class AppCatAbstractResource implements AppCatalogResource {
         public static final String STORAGE_ID = "storageResourceId";
     }
 
+    public final class UserStoragePreferenceConstants {
+        public static final String GATEWAY_ID = "gatewayId";
+        public static final String USER_ID = "userId";
+        public static final String STORAGE_ID = "storageResourceId";
+    }
+
     public final class StorageInterfaceConstants {
         public static final String STORAGE_RESOURCE_ID = "storageResourceId";
         public static final String DATA_MOVEMENT_PROTOCOL = "dataMovementProtocol";

http://git-wip-us.apache.org/repos/asf/airavata/blob/81c6ea84/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ComputeHostPreferenceResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ComputeHostPreferenceResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ComputeHostPreferenceResource.java
index 67dd77c..bad90a2 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ComputeHostPreferenceResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ComputeHostPreferenceResource.java
@@ -142,6 +142,10 @@ public class ComputeHostPreferenceResource extends AppCatAbstractResource {
         this.gatewayProfile = gatewayProfile;
     }
 
+    public void setUserResourceProfile(GatewayProfileResource gatewayProfile) {
+        this.gatewayProfile = gatewayProfile;
+    }
+
     public ComputeResourceResource getComputeHostResource() {
         return computeHostResource;
     }

http://git-wip-us.apache.org/repos/asf/airavata/blob/81c6ea84/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/UserComputeHostPreferenceResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/UserComputeHostPreferenceResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/UserComputeHostPreferenceResource.java
new file mode 100644
index 0000000..180625b
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/UserComputeHostPreferenceResource.java
@@ -0,0 +1,451 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.registry.core.app.catalog.resources;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.registry.core.app.catalog.model.ComputeResource;
+import org.apache.airavata.registry.core.app.catalog.model.UserResourceProfile;
+import org.apache.airavata.registry.core.app.catalog.model.UserComputeResourcePreference;
+import org.apache.airavata.registry.core.app.catalog.model.UserComputeResourcePreferencePK;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
+import org.apache.airavata.registry.cpi.AppCatalogException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class UserComputeHostPreferenceResource extends AppCatAbstractResource {
+    private final static Logger logger = LoggerFactory.getLogger(UserComputeHostPreferenceResource.class);
+    private String gatewayId;
+    private String resourceId;
+    private String userId;
+    private String batchQueue;
+    private String scratchLocation;
+    private String projectNumber;
+    private String loginUserName;
+    private String resourceCSToken;
+    private String qualityOfService;
+    private String reservation;
+    private Timestamp reservationStartTime;
+    private Timestamp reservationEndTime;
+
+    private UserResourceProfileResource userResourceProfileResource;
+    private ComputeResourceResource computeHostResource;
+
+    public String getUserId() {
+        return userId;
+    }
+
+    public void setUserId(String userId) {
+        this.userId = userId;
+    }
+
+    public String getLoginUserName() {
+        return loginUserName;
+    }
+
+    public void setLoginUserName(String loginUserName) {
+        this.loginUserName = loginUserName;
+    }
+
+    public String getGatewayId() {
+        return gatewayId;
+    }
+
+    public void setGatewayId(String gatewayId) {
+        this.gatewayId = gatewayId;
+    }
+
+    public String getResourceId() {
+        return resourceId;
+    }
+
+    public void setResourceId(String resourceId) {
+        this.resourceId = resourceId;
+    }
+
+    public String getBatchQueue() {
+        return batchQueue;
+    }
+
+    public void setBatchQueue(String batchQueue) {
+        this.batchQueue = batchQueue;
+    }
+
+    public String getScratchLocation() {
+        return scratchLocation;
+    }
+
+    public void setScratchLocation(String scratchLocation) {
+        this.scratchLocation = scratchLocation;
+    }
+
+    public String getProjectNumber() {
+        return projectNumber;
+    }
+
+    public void setProjectNumber(String projectNumber) {
+        this.projectNumber = projectNumber;
+    }
+
+    public ComputeResourceResource getComputeHostResource() {
+        return computeHostResource;
+    }
+
+    public void setComputeHostResource(ComputeResourceResource computeHostResource) {
+        this.computeHostResource = computeHostResource;
+    }
+
+    public UserResourceProfileResource getUserResourceProfileResource() {
+        return userResourceProfileResource;
+    }
+
+    public void setUserResourceProfileResource(UserResourceProfileResource userResourceProfileResource) {
+        this.userResourceProfileResource = userResourceProfileResource;
+    }
+
+    public String getResourceCSToken() {
+        return resourceCSToken;
+    }
+
+    public void setResourceCSToken(String resourceCSToken) {
+        this.resourceCSToken = resourceCSToken;
+    }
+
+
+    public String getQualityOfService() {
+        return qualityOfService;
+    }
+
+    public void setQualityOfService(String qualityOfService) {
+        this.qualityOfService = qualityOfService;
+    }
+
+    public String getReservation() {
+        return reservation;
+    }
+
+    public void setReservation(String reservation) {
+        this.reservation = reservation;
+    }
+
+    public Timestamp getReservationStartTime() {
+        return reservationStartTime;
+    }
+
+    public void setReservationStartTime(Timestamp reservationStartTime) {
+        this.reservationStartTime = reservationStartTime;
+    }
+
+    public Timestamp getReservationEndTime() {
+        return reservationEndTime;
+    }
+
+    public void setReservationEndTime(Timestamp reservationEndTime) {
+        this.reservationEndTime = reservationEndTime;
+    }
+
+    @Override
+    public void remove(Object identifier) throws AppCatalogException {
+        HashMap<String, String> ids;
+        if (identifier instanceof Map) {
+            ids = (HashMap) identifier;
+        } else {
+            logger.error("Identifier should be a map with the field name and it's value");
+            throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+        }
+
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(USER_COMPUTE_RESOURCE_PREFERENCE);
+            generator.setParameter(UserComputeResourcePreferenceConstants.RESOURCE_ID, ids.get(UserComputeResourcePreferenceConstants.RESOURCE_ID));
+            generator.setParameter(UserComputeResourcePreferenceConstants.USER_ID, ids.get(UserComputeResourcePreferenceConstants.USER_ID));
+
+            Query q = generator.deleteQuery(em);
+            q.executeUpdate();
+            em.getTransaction().commit();
+            if (em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        } catch (ApplicationSettingsException e) {
+            logger.error(e.getMessage(), e);
+            throw new AppCatalogException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()) {
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+    }
+
+    @Override
+    public AppCatalogResource get(Object identifier) throws AppCatalogException {
+        HashMap<String, String> ids;
+        if (identifier instanceof Map) {
+            ids = (HashMap) identifier;
+        } else {
+            logger.error("Identifier should be a map with the field name and it's value");
+            throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+        }
+
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(USER_COMPUTE_RESOURCE_PREFERENCE);
+            generator.setParameter(UserComputeResourcePreferenceConstants.RESOURCE_ID, ids.get(UserComputeResourcePreferenceConstants.RESOURCE_ID));
+            generator.setParameter(UserComputeResourcePreferenceConstants.USER_ID, ids.get(UserComputeResourcePreferenceConstants.USER_ID));
+            Query q = generator.selectQuery(em);
+            UserComputeResourcePreference preference = (UserComputeResourcePreference) q.getSingleResult();
+            UserComputeHostPreferenceResource preferenceResource =
+                    (UserComputeHostPreferenceResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.USER_COMPUTE_RESOURCE_PREFERENCE, preference);
+            em.getTransaction().commit();
+            if (em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+            return preferenceResource;
+        } catch (ApplicationSettingsException e) {
+            logger.error(e.getMessage(), e);
+            throw new AppCatalogException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()) {
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+    }
+
+    @Override
+    public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
+        List<AppCatalogResource> preferenceResourceList = new ArrayList<AppCatalogResource>();
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            Query q;
+            AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(USER_COMPUTE_RESOURCE_PREFERENCE);
+            List results;
+            if (fieldName.equals(UserComputeResourcePreferenceConstants.RESOURCE_ID)) {
+                generator.setParameter(UserComputeResourcePreferenceConstants.RESOURCE_ID, value);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        UserComputeResourcePreference preference = (UserComputeResourcePreference) result;
+                        if (preference.getComputeHostResource()!=null) {
+							UserComputeHostPreferenceResource preferenceResource = (UserComputeHostPreferenceResource) AppCatalogJPAUtils
+									.getResource(
+											AppCatalogResourceType.USER_COMPUTE_RESOURCE_PREFERENCE,
+											preference);
+							preferenceResourceList.add(preferenceResource);
+						}
+                    }
+                }
+            } else if (fieldName.equals(UserComputeResourcePreferenceConstants.USER_ID)) {
+                generator.setParameter(UserComputeResourcePreferenceConstants.USER_ID, value);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        UserComputeResourcePreference preference = (UserComputeResourcePreference) result;
+                        if (preference.getComputeHostResource()!=null) {
+	                        UserComputeHostPreferenceResource preferenceResource =
+	                                (UserComputeHostPreferenceResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.USER_COMPUTE_RESOURCE_PREFERENCE, preference);
+	                        preferenceResourceList.add(preferenceResource);
+                        }
+                    }
+                }
+            } else {
+                em.getTransaction().commit();
+                if (em.isOpen()) {
+                    if (em.getTransaction().isActive()){
+                        em.getTransaction().rollback();
+                    }
+                    em.close();
+                }
+                logger.error("Unsupported field name for Compute host preference Resource.", new IllegalArgumentException());
+                throw new IllegalArgumentException("Unsupported field name for Compute host preference Resource.");
+            }
+            em.getTransaction().commit();
+            if (em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new AppCatalogException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()) {
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+        return preferenceResourceList;
+    }
+
+    @Override
+    public List<AppCatalogResource> getAll() throws AppCatalogException {
+        return null;
+    }
+
+    @Override
+    public List<String> getAllIds() throws AppCatalogException {
+        return null;
+    }
+
+    @Override
+    public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
+        logger.error("Unsupported for objects with a composite identifier");
+        throw new AppCatalogException("Unsupported for objects with a composite identifier");
+    }
+
+    @Override
+    public void save() throws AppCatalogException {
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            UserComputeResourcePreference existingPreference = em.find(UserComputeResourcePreference.class, new UserComputeResourcePreferencePK(userId, gatewayId, resourceId));
+            if (em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            ComputeResource computeResource = em.find(ComputeResource.class, resourceId);
+            UserResourceProfile userResourceProfile = em.find(UserResourceProfile.class, userId);
+            if (existingPreference != null) {
+                existingPreference.setResourceId(resourceId);
+                existingPreference.setGatewayId(userId);
+                existingPreference.setGatewayId(gatewayId);
+                existingPreference.setComputeHostResource(computeResource);
+                existingPreference.setUserResouceProfile(userResourceProfile);
+                existingPreference.setScratchLocation(scratchLocation);
+                existingPreference.setProjectNumber(projectNumber);
+                existingPreference.setBatchQueue(batchQueue);
+                existingPreference.setLoginUserName(loginUserName);
+                existingPreference.setComputeResourceCSToken(resourceCSToken);
+                existingPreference.setQualityOfService(qualityOfService);
+                existingPreference.setReservation(reservation);
+                existingPreference.setReservationStartTime(reservationStartTime);
+                existingPreference.setReservationEndTime(reservationEndTime);
+                em.merge(existingPreference);
+            } else {
+                UserComputeResourcePreference resourcePreference = new UserComputeResourcePreference();
+                resourcePreference.setResourceId(resourceId);
+                resourcePreference.setGatewayId(gatewayId);
+                resourcePreference.setGatewayId(userId);
+                resourcePreference.setComputeHostResource(computeResource);
+                resourcePreference.setScratchLocation(scratchLocation);
+                resourcePreference.setProjectNumber(projectNumber);
+                resourcePreference.setBatchQueue(batchQueue);
+                resourcePreference.setLoginUserName(loginUserName);
+                resourcePreference.setComputeResourceCSToken(resourceCSToken);
+                resourcePreference.setQualityOfService(qualityOfService);
+                resourcePreference.setReservation(reservation);
+                resourcePreference.setReservationStartTime(reservationStartTime);
+                resourcePreference.setReservationEndTime(reservationEndTime);
+                em.persist(resourcePreference);
+            }
+            em.getTransaction().commit();
+            if (em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new AppCatalogException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()) {
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+    }
+
+    @Override
+    public boolean isExists(Object identifier) throws AppCatalogException {
+        HashMap<String, String> ids;
+        if (identifier instanceof Map) {
+            ids = (HashMap) identifier;
+        } else {
+            logger.error("Identifier should be a map with the field name and it's value");
+            throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+        }
+
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            UserComputeResourcePreference existingPreference = em.find(UserComputeResourcePreference.class,
+                    new UserComputeResourcePreferencePK(ids.get(UserComputeResourcePreferenceConstants.USER_ID),
+                            ids.get(UserComputeResourcePreferenceConstants.GATEWAY_ID),
+                            ids.get(UserComputeResourcePreferenceConstants.RESOURCE_ID)));
+            if (em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+            return existingPreference != null;
+        }catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new AppCatalogException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()) {
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/81c6ea84/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/UserResourceProfileResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/UserResourceProfileResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/UserResourceProfileResource.java
new file mode 100644
index 0000000..208c835
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/UserResourceProfileResource.java
@@ -0,0 +1,425 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.airavata.registry.core.app.catalog.resources;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.common.utils.AiravataUtils;
+import org.apache.airavata.registry.core.app.catalog.model.UserResourceProfile;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
+import org.apache.airavata.registry.cpi.AppCatalogException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class UserResourceProfileResource extends AppCatAbstractResource {
+    private final static Logger logger = LoggerFactory.getLogger(UserResourceProfileResource.class);
+
+    private String userId;
+    private String gatewayID;
+    private Timestamp createdTime;
+    private Timestamp updatedTime;
+    private String credentialStoreToken;
+    private String identityServerTenant;
+    private String identityServerPwdCredToken;
+
+    public String getUserId() {
+        return userId;
+    }
+
+    public void setUserId(String userId) {
+        this.userId = userId;
+    }
+
+    public String getGatewayID() {
+        return gatewayID;
+    }
+
+    public void setGatewayID(String gatewayID) {
+        this.gatewayID = gatewayID;
+    }
+
+    public Timestamp getCreatedTime() {
+        return createdTime;
+    }
+
+    public void setCreatedTime(Timestamp createdTime) {
+        this.createdTime = createdTime;
+    }
+
+    public Timestamp getUpdatedTime() {
+        return updatedTime;
+    }
+
+    public void setUpdatedTime(Timestamp updatedTime) {
+        this.updatedTime = updatedTime;
+    }
+
+    public String getCredentialStoreToken() {
+        return credentialStoreToken;
+    }
+
+    public void setCredentialStoreToken(String credentialStoreToken) {
+        this.credentialStoreToken = credentialStoreToken;
+    }
+
+    public String getIdentityServerTenant() {
+        return identityServerTenant;
+    }
+
+    public void setIdentityServerTenant(String identityServerTenant) {
+        this.identityServerTenant = identityServerTenant;
+    }
+
+    public String getIdentityServerPwdCredToken() {
+        return identityServerPwdCredToken;
+    }
+
+    public void setIdentityServerPwdCredToken(String identityServerPwdCredToken) {
+        this.identityServerPwdCredToken = identityServerPwdCredToken;
+    }
+
+    public void remove(Object identifier) throws AppCatalogException {
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(USER_RESOURCE_PROFILE);
+            generator.setParameter(UserResourceProfileConstants.GATEWAY_ID, identifier);
+            generator.setParameter(UserResourceProfileConstants.USER_ID, identifier);
+            Query q = generator.deleteQuery(em);
+            q.executeUpdate();
+            em.getTransaction().commit();
+            if (em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        } catch (ApplicationSettingsException e) {
+            logger.error(e.getMessage(), e);
+            throw new AppCatalogException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()) {
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+    }
+
+    public AppCatalogResource get(Object identifier) throws AppCatalogException {
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(USER_RESOURCE_PROFILE);
+            generator.setParameter(UserResourceProfileConstants.USER_ID, identifier);
+            Query q = generator.selectQuery(em);
+            UserResourceProfile userResourceProfile = (UserResourceProfile) q.getSingleResult();
+            UserResourceProfileResource userResourceProfileResource =
+                    (UserResourceProfileResource) AppCatalogJPAUtils.getResource(
+                            AppCatalogResourceType.USER_RESOURCE_PROFILE, userResourceProfile);
+            em.getTransaction().commit();
+            if (em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+            return userResourceProfileResource;
+        } catch (ApplicationSettingsException e) {
+            logger.error(e.getMessage(), e);
+            throw new AppCatalogException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()) {
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+    }
+
+    public List<AppCatalogResource> get(String userId, Object value) throws AppCatalogException {
+        List<AppCatalogResource> userResourceProfileResources = new ArrayList<AppCatalogResource>();
+        EntityManager em = null;
+        HashMap<String, String> ids;
+        if (value instanceof Map) {
+            ids = (HashMap) value;
+        } else {
+            logger.error("Identifier should be a map with the field name and it's value");
+            throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+        }
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            Query q;
+            AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(USER_RESOURCE_PROFILE);
+            List results;
+            if (userId.equals(UserResourceProfileConstants.USER_ID)) {
+                generator.setParameter(UserResourceProfileConstants.USER_ID, ids.get(UserResourceProfileConstants.USER_ID));
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        UserResourceProfile userResourceProfile = (UserResourceProfile) result;
+                        UserResourceProfileResource userResourceProfileResource =
+                                (UserResourceProfileResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.USER_RESOURCE_PROFILE, userResourceProfile);
+                        userResourceProfileResources.add(userResourceProfileResource);
+                    }
+                }
+            } else {
+                em.getTransaction().commit();
+                if (em.isOpen()) {
+                    if (em.getTransaction().isActive()){
+                        em.getTransaction().rollback();
+                    }
+                    em.close();
+                }
+                logger.error("Unsupported field name for User Resource Profile resource.", new IllegalArgumentException());
+                throw new IllegalArgumentException("Unsupported field name for User Resource Profile resource.");
+            }
+            em.getTransaction().commit();
+            if (em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new AppCatalogException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()) {
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+        return userResourceProfileResources;
+    }
+
+    @Override
+    public List<AppCatalogResource> getAll() throws AppCatalogException {
+        List<AppCatalogResource> resourceList = new ArrayList<AppCatalogResource>();
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(USER_RESOURCE_PROFILE);
+            Query q = generator.selectQuery(em);
+            List results = q.getResultList();
+            if (results.size() != 0) {
+                for (Object result : results) {
+                    UserResourceProfile userResourceProfile = (UserResourceProfile) result;
+                    UserResourceProfileResource userResourceProfileResource =
+                            (UserResourceProfileResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.USER_RESOURCE_PROFILE, userResourceProfile);
+                    resourceList.add(userResourceProfileResource);
+                }
+            }
+            em.getTransaction().commit();
+            if (em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new AppCatalogException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()) {
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+        return resourceList;
+    }
+
+    @Override
+    public List<String> getAllIds() throws AppCatalogException {
+        return null;
+    }
+
+    public List<String> getIds(String userId, Object value) throws AppCatalogException {
+        List<String> userResourceProfileResourceIDs = new ArrayList<String>();
+        EntityManager em = null;
+        HashMap<String, String> ids;
+        if (value instanceof Map) {
+            ids = (HashMap) value;
+        } else {
+            logger.error("Identifier should be a map with the field name and it's value");
+            throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+        }
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            Query q;
+            AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(USER_RESOURCE_PROFILE);
+            List results;
+            if (userId.equals(UserResourceProfileConstants.USER_ID)) {
+                generator.setParameter(UserResourceProfileConstants.USER_ID, ids.get(UserResourceProfileConstants.USER_ID));
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        UserResourceProfile userResourceProfile = (UserResourceProfile) result;
+                        userResourceProfileResourceIDs.add(userResourceProfile.getUserID());
+                    }
+                }
+            } else {
+                em.getTransaction().commit();
+                if (em.isOpen()) {
+                    if (em.getTransaction().isActive()){
+                        em.getTransaction().rollback();
+                    }
+                    em.close();
+                }
+                logger.error("Unsupported field name for User Resource Profile resource.", new IllegalArgumentException());
+                throw new IllegalArgumentException("Unsupported field name for User Resource Profile resource.");
+            }
+            em.getTransaction().commit();
+            if (em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new AppCatalogException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()) {
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+        return userResourceProfileResourceIDs;
+    }
+
+    public void save() throws AppCatalogException {
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            UserResourceProfile existingUserResourceProfile = em.find(UserResourceProfile.class, userId);
+            if (em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            if (existingUserResourceProfile != null) {
+                existingUserResourceProfile.setUpdateTime(AiravataUtils.getCurrentTimestamp());
+                if (credentialStoreToken != null){
+                    existingUserResourceProfile.setCredentialStoreToken(credentialStoreToken);
+                }
+                if (identityServerTenant != null){
+                    existingUserResourceProfile.setIdentityServerTenant(identityServerTenant);
+                }
+                if (identityServerPwdCredToken != null){
+                    existingUserResourceProfile.setIdentityServerPwdCredToken(identityServerPwdCredToken);
+                }
+                em.merge(existingUserResourceProfile);
+            } else {
+                UserResourceProfile userResourceProfile = new UserResourceProfile();
+                userResourceProfile.setGatewayID(gatewayID);
+                userResourceProfile.setGatewayID(userId);
+                userResourceProfile.setCreationTime(AiravataUtils.getCurrentTimestamp());
+                if (credentialStoreToken != null){
+                    userResourceProfile.setCredentialStoreToken(credentialStoreToken);
+                }
+                if (identityServerTenant != null){
+                    userResourceProfile.setIdentityServerTenant(identityServerTenant);
+                }
+                if (identityServerPwdCredToken != null){
+                    userResourceProfile.setIdentityServerPwdCredToken(identityServerPwdCredToken);
+                }
+                em.persist(userResourceProfile);
+            }
+            em.getTransaction().commit();
+            if (em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new AppCatalogException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()) {
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+    }
+
+    public boolean isExists(Object identifier) throws AppCatalogException {
+        EntityManager em = null;
+        HashMap<String, String> ids;
+        if (identifier instanceof Map) {
+            ids = (HashMap) identifier;
+        } else {
+            logger.error("Identifier should be a map with the field name and it's value");
+            throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+        }
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            UserResourceProfile userResourceProfile = em.find(UserResourceProfile.class, ids.get(UserResourceProfileConstants.USER_ID));
+            if (em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+            return userResourceProfile != null;
+        } catch (ApplicationSettingsException e) {
+            logger.error(e.getMessage(), e);
+            throw new AppCatalogException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()) {
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/81c6ea84/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
new file mode 100644
index 0000000..37dadc6
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/UserStoragePreferenceResource.java
@@ -0,0 +1,371 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.registry.core.app.catalog.resources;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.registry.core.app.catalog.model.UserResourceProfile;
+import org.apache.airavata.registry.core.app.catalog.model.UserStoragePreference;
+import org.apache.airavata.registry.core.app.catalog.model.UserStoragePreferencePK;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
+import org.apache.airavata.registry.cpi.AppCatalogException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class UserStoragePreferenceResource extends AppCatAbstractResource {
+    private final static Logger logger = LoggerFactory.getLogger(UserStoragePreferenceResource.class);
+    private String gatewayId;
+    private String userId;
+    private String storageResourceId;
+    private String loginUserName;
+    private String fsRootLocation;
+    private String resourceCSToken;
+
+
+    private UserResourceProfileResource userResourceProfileResource;
+
+    public String getUserId() {
+        return userId;
+    }
+
+    public void setUserId(String userId) {
+        this.userId = userId;
+    }
+
+    public String getLoginUserName() {
+        return loginUserName;
+    }
+
+    public void setLoginUserName(String loginUserName) {
+        this.loginUserName = loginUserName;
+    }
+
+    public String getGatewayId() {
+        return gatewayId;
+    }
+
+    public void setGatewayId(String gatewayId) {
+        this.gatewayId = gatewayId;
+    }
+
+    public UserResourceProfileResource getUserResourceProfileResource() {
+        return userResourceProfileResource;
+    }
+
+    public void setUserResourceProfileResource(UserResourceProfileResource userResourceProfileResource) {
+        this.userResourceProfileResource = userResourceProfileResource;
+    }
+
+    public String getResourceCSToken() {
+        return resourceCSToken;
+    }
+
+    public void setResourceCSToken(String resourceCSToken) {
+        this.resourceCSToken = resourceCSToken;
+    }
+
+    public String getFsRootLocation() {
+        return fsRootLocation;
+    }
+
+    public void setFsRootLocation(String fsRootLocation) {
+        this.fsRootLocation = fsRootLocation;
+    }
+
+    public String getStorageResourceId() {
+        return storageResourceId;
+    }
+
+    public void setStorageResourceId(String storageResourceId) {
+        this.storageResourceId = storageResourceId;
+    }
+
+    @Override
+    public void remove(Object identifier) throws AppCatalogException {
+        HashMap<String, String> ids;
+        if (identifier instanceof Map) {
+            ids = (HashMap) identifier;
+        } else {
+            logger.error("Identifier should be a map with the field name and it's value");
+            throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+        }
+
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(USER_STORAGE_PREFERENCE);
+            generator.setParameter(UserStoragePreferenceConstants.STORAGE_ID, ids.get(UserStoragePreferenceConstants.STORAGE_ID));
+            generator.setParameter(UserStoragePreferenceConstants.USER_ID, ids.get(UserStoragePreferenceConstants.USER_ID));
+
+            Query q = generator.deleteQuery(em);
+            q.executeUpdate();
+            em.getTransaction().commit();
+            if (em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        } catch (ApplicationSettingsException e) {
+            logger.error(e.getMessage(), e);
+            throw new AppCatalogException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()) {
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+    }
+
+    @Override
+    public AppCatalogResource get(Object identifier) throws AppCatalogException {
+        HashMap<String, String> ids;
+        if (identifier instanceof Map) {
+            ids = (HashMap) identifier;
+        } else {
+            logger.error("Identifier should be a map with the field name and it's value");
+            throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+        }
+
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(USER_STORAGE_PREFERENCE);
+            generator.setParameter(UserStoragePreferenceConstants.USER_ID, ids.get(UserStoragePreferenceConstants.USER_ID));
+            generator.setParameter(UserStoragePreferenceConstants.STORAGE_ID, ids.get(UserStoragePreferenceConstants.STORAGE_ID));
+            Query q = generator.selectQuery(em);
+            UserStoragePreference preference = (UserStoragePreference) q.getSingleResult();
+            UserStoragePreferenceResource preferenceResource =
+                    (UserStoragePreferenceResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.USER_STORAGE_PREFERENCE, preference);
+            em.getTransaction().commit();
+            if (em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+            return preferenceResource;
+        } catch (ApplicationSettingsException e) {
+            logger.error(e.getMessage(), e);
+            throw new AppCatalogException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()) {
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+    }
+
+    @Override
+    public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
+        List<AppCatalogResource> preferenceResourceList = new ArrayList<AppCatalogResource>();
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            Query q;
+            AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(USER_STORAGE_PREFERENCE);
+            List results;
+            if (fieldName.equals(UserStoragePreferenceConstants.STORAGE_ID)) {
+                generator.setParameter(UserStoragePreferenceConstants.STORAGE_ID, value);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        UserStoragePreference preference = (UserStoragePreference) result;
+                        if (preference.getStorageResourceId()!=null) {
+							UserStoragePreferenceResource preferenceResource = (UserStoragePreferenceResource) AppCatalogJPAUtils
+									.getResource(
+											AppCatalogResourceType.USER_STORAGE_PREFERENCE,
+											preference);
+							preferenceResourceList.add(preferenceResource);
+						}
+                    }
+                }
+            } else if (fieldName.equals(UserStoragePreferenceConstants.USER_ID)) {
+                generator.setParameter(UserStoragePreferenceConstants.USER_ID, value);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        UserStoragePreference preference = (UserStoragePreference) result;
+                        if (preference.getStorageResourceId()!=null) {
+	                        UserStoragePreferenceResource preferenceResource =
+	                                (UserStoragePreferenceResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.USER_STORAGE_PREFERENCE, preference);
+	                        preferenceResourceList.add(preferenceResource);
+                        }
+                    }
+                }
+            } else {
+                em.getTransaction().commit();
+                if (em.isOpen()) {
+                    if (em.getTransaction().isActive()){
+                        em.getTransaction().rollback();
+                    }
+                    em.close();
+                }
+                logger.error("Unsupported field name for data storage preference Resource.", new IllegalArgumentException());
+                throw new IllegalArgumentException("Unsupported field name for data storage preference Resource.");
+            }
+            em.getTransaction().commit();
+            if (em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new AppCatalogException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()) {
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+        return preferenceResourceList;
+    }
+
+    @Override
+    public List<AppCatalogResource> getAll() throws AppCatalogException {
+        return null;
+    }
+
+    @Override
+    public List<String> getAllIds() throws AppCatalogException {
+        return null;
+    }
+
+    @Override
+    public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
+        logger.error("Unsupported for objects with a composite identifier");
+        throw new AppCatalogException("Unsupported for objects with a composite identifier");
+    }
+
+    @Override
+    public void save() throws AppCatalogException {
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            UserStoragePreference existingPreference = em.find(UserStoragePreference.class, new UserStoragePreferencePK(userId, storageResourceId));
+            if (em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            UserResourceProfile userResourceProfile = em.find(UserResourceProfile.class, userId);
+            if (existingPreference != null) {
+                existingPreference.setStorageResourceId(storageResourceId);
+                existingPreference.setGatewayId(userId);
+                existingPreference.setGatewayId(gatewayId);
+                existingPreference.setUserResourceProfile(userResourceProfile);
+                existingPreference.setLoginUserName(loginUserName);
+                existingPreference.setComputeResourceCSToken(resourceCSToken);
+                existingPreference.setFsRootLocation(fsRootLocation);
+                em.merge(existingPreference);
+            } else {
+                UserStoragePreference resourcePreference = new UserStoragePreference();
+                resourcePreference.setStorageResourceId(storageResourceId);
+                resourcePreference.setGatewayId(gatewayId);
+                resourcePreference.setGatewayId(userId);
+                resourcePreference.setUserResourceProfile(userResourceProfile);
+                resourcePreference.setLoginUserName(loginUserName);
+                resourcePreference.setComputeResourceCSToken(resourceCSToken);
+                resourcePreference.setFsRootLocation(fsRootLocation);
+                em.persist(resourcePreference);
+            }
+            em.getTransaction().commit();
+            if (em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new AppCatalogException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()) {
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+    }
+
+    @Override
+    public boolean isExists(Object identifier) throws AppCatalogException {
+        HashMap<String, String> ids;
+        if (identifier instanceof Map) {
+            ids = (HashMap) identifier;
+        } else {
+            logger.error("Identifier should be a map with the field name and it's value");
+            throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+        }
+
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            UserStoragePreference existingPreference = em.find(UserStoragePreference.class,
+                    new UserStoragePreferencePK(ids.get(UserStoragePreferenceConstants.USER_ID),
+                            ids.get(UserStoragePreferenceConstants.STORAGE_ID)));
+            if (em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+            return existingPreference != null;
+        }catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new AppCatalogException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()) {
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/81c6ea84/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogResourceType.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogResourceType.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogResourceType.java
index b26560a..ddad27d 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogResourceType.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogResourceType.java
@@ -49,8 +49,11 @@ public enum AppCatalogResourceType {
     APPLICATION_INPUT,
     APPLICATION_OUTPUT,
     GATEWAY_PROFILE,
+    USER_RESOURCE_PROFILE,
     COMPUTE_RESOURCE_PREFERENCE,
+    USER_COMPUTE_RESOURCE_PREFERENCE,
     STORAGE_PREFERENCE,
+    USER_STORAGE_PREFERENCE,
     STORAGE_RESOURCE,
     STORAGE_INTERFACE,
 	BATCH_QUEUE,

http://git-wip-us.apache.org/repos/asf/airavata/blob/81c6ea84/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 8b40d62..3d86635 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
@@ -31,6 +31,9 @@ import org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePrefer
 import org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile;
 import org.apache.airavata.model.appcatalog.gatewayprofile.StoragePreference;
 import org.apache.airavata.model.appcatalog.storageresource.StorageResourceDescription;
+import org.apache.airavata.model.appcatalog.userresourceprofile.UserComputeResourcePreference;
+import org.apache.airavata.model.appcatalog.userresourceprofile.UserStoragePreference;
+import org.apache.airavata.model.appcatalog.userresourceprofile.UserResourceProfile;
 import org.apache.airavata.model.application.io.DataType;
 import org.apache.airavata.model.application.io.InputDataObjectType;
 import org.apache.airavata.model.application.io.OutputDataObjectType;
@@ -844,6 +847,26 @@ public class AppCatalogThriftConversion {
         return preference;
     }
 
+    public static UserComputeResourcePreference getUserComputeResourcePreference (UserComputeHostPreferenceResource resource){
+        UserComputeResourcePreference preference = new UserComputeResourcePreference();
+        preference.setComputeResourceId(resource.getResourceId());
+        preference.setPreferredBatchQueue(resource.getBatchQueue());
+        preference.setScratchLocation(resource.getScratchLocation());
+        preference.setAllocationProjectNumber(resource.getProjectNumber());
+        preference.setLoginUserName(resource.getLoginUserName());
+        preference.setResourceSpecificCredentialStoreToken(resource.getResourceCSToken());
+        preference.setQualityOfService(resource.getQualityOfService());
+        preference.setReservation(resource.getReservation());
+        if (resource.getReservationStartTime() != null) {
+            preference.setReservationStartTime(resource.getReservationStartTime().getTime());
+        }
+
+        if (resource.getReservationEndTime() != null) {
+            preference.setReservationEndTime(resource.getReservationEndTime().getTime());
+        }
+        return preference;
+    }
+
     public static List<ComputeResourcePreference> getComputeResourcePreferences (List<AppCatalogResource> resources){
         List<ComputeResourcePreference> preferences = new ArrayList<ComputeResourcePreference>();
         if (resources != null && !resources.isEmpty()){
@@ -854,6 +877,16 @@ public class AppCatalogThriftConversion {
         return preferences;
     }
 
+    public static List<UserComputeResourcePreference> getUserComputeResourcePreferences (List<AppCatalogResource> resources){
+        List<UserComputeResourcePreference> preferences = new ArrayList<UserComputeResourcePreference>();
+        if (resources != null && !resources.isEmpty()){
+            for (AppCatalogResource resource : resources){
+                preferences.add(getUserComputeResourcePreference((UserComputeHostPreferenceResource)resource));
+            }
+        }
+        return preferences;
+    }
+
     public static StoragePreference getDataStoragePreference (StoragePreferenceResource resource){
         StoragePreference preference = new StoragePreference();
         preference.setStorageResourceId(resource.getStorageResourceId());
@@ -872,6 +905,24 @@ public class AppCatalogThriftConversion {
         }
         return preferences;
     }
+    public static UserStoragePreference getUserDataStoragePreference (UserStoragePreferenceResource resource){
+        UserStoragePreference preference = new UserStoragePreference();
+        preference.setStorageResourceId(resource.getStorageResourceId());
+        preference.setFileSystemRootLocation(resource.getFsRootLocation());
+        preference.setLoginUserName(resource.getLoginUserName());
+        preference.setResourceSpecificCredentialStoreToken(resource.getResourceCSToken());
+        return preference;
+    }
+
+    public static List<UserStoragePreference> getUserDataStoragePreferences (List<AppCatalogResource> resources){
+        List<UserStoragePreference> preferences = new ArrayList<UserStoragePreference>();
+        if (resources != null && !resources.isEmpty()){
+            for (AppCatalogResource resource : resources){
+                preferences.add(getUserDataStoragePreference((UserStoragePreferenceResource)resource));
+            }
+        }
+        return preferences;
+    }
 
     public static GatewayResourceProfile getGatewayResourceProfile(GatewayProfileResource gw, List<ComputeResourcePreference> preferences, List<StoragePreference> storagePreferences){
         GatewayResourceProfile gatewayProfile = new GatewayResourceProfile();
@@ -884,4 +935,16 @@ public class AppCatalogThriftConversion {
         return gatewayProfile;
     }
 
+    public static UserResourceProfile getUserResourceProfile(UserResourceProfileResource gw, List<UserComputeResourcePreference> preferences, List<UserStoragePreference> storagePreferences){
+        UserResourceProfile userResourceProfile = new UserResourceProfile();
+        userResourceProfile.setGatewayID(gw.getGatewayID());
+        userResourceProfile.setUserId(gw.getUserId());
+        userResourceProfile.setCredentialStoreToken(gw.getCredentialStoreToken());
+        userResourceProfile.setIdentityServerTenant(gw.getIdentityServerTenant());
+        userResourceProfile.setIdentityServerPwdCredToken(gw.getIdentityServerPwdCredToken());
+        userResourceProfile.setUserComputeResourcePreferences(preferences);
+        userResourceProfile.setUserStoragePreferences(storagePreferences);
+        return userResourceProfile;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/81c6ea84/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/AppCatalog.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/AppCatalog.java b/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/AppCatalog.java
index 0f7c2c9..f00a2df 100644
--- a/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/AppCatalog.java
+++ b/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/AppCatalog.java
@@ -52,6 +52,13 @@ public interface AppCatalog {
     GwyResourceProfile getGatewayProfile() throws AppCatalogException;
 
     /**
+     * Get Gateway profile interface
+     * @return User Resource profile interface
+     * @throws AppCatalogException
+     */
+    UsrResourceProfile getUserResourceProfile() throws AppCatalogException;
+
+    /**
      * Get workflow catalog interface
      * @return workflow catalog interface
      * @throws AppCatalogException

http://git-wip-us.apache.org/repos/asf/airavata/blob/81c6ea84/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/UsrResourceProfile.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/UsrResourceProfile.java b/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/UsrResourceProfile.java
new file mode 100644
index 0000000..ec04c7b
--- /dev/null
+++ b/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/UsrResourceProfile.java
@@ -0,0 +1,87 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.airavata.registry.cpi;
+
+import org.apache.airavata.model.appcatalog.userresourceprofile.UserResourceProfile;
+import org.apache.airavata.model.appcatalog.userresourceprofile.UserComputeResourcePreference;
+import org.apache.airavata.model.appcatalog.userresourceprofile.UserStoragePreference;
+import java.util.List;
+
+public interface UsrResourceProfile {
+    /**
+     * This method will add a gateway profile
+     * @param userResourceProfile object of User resource profile
+     * @return gateway id
+     */
+    String addUserResourceProfile(UserResourceProfile userResourceProfile) throws AppCatalogException;
+
+    /**
+     * This method will update a gateway profile
+     * @param userId unique User id
+     * @param gatewayId unique gateway id
+     * @param updatedProfile updated profile
+     */
+    void updateUserResourceProfile(String userId, String gatewayId, UserResourceProfile updatedProfile) throws AppCatalogException;
+
+    /**
+     * @param userId
+     * @param gatewayId
+     * @return
+     */
+    UserResourceProfile getUserResourceProfile(String userId, String gatewayId) throws AppCatalogException;
+
+    /**
+     * This method will remove a gateway profile
+     * @param userId
+     * @param gatewayId unique gateway id
+     * @return true or false
+     */
+    boolean removeUserResourceProfile(String userId, String gatewayId) throws AppCatalogException;
+    boolean removeUserComputeResourcePreferenceFromGateway(String userId, String gatewayId, String preferenceId) throws AppCatalogException;
+    boolean removeUserDataStoragePreferenceFromGateway(String userId, String gatewayId, String preferenceId) throws AppCatalogException;
+
+    /**
+     * This method will check whether gateway profile exists
+     * @param userId
+     * @param gatewayId unique gateway id
+     * @return true or false
+     */
+    boolean isUserResourceProfileExists(String userId, String gatewayId) throws AppCatalogException;
+
+    /**
+     *
+     * @param userId
+     * @param gatewayId
+     * @param hostId
+     * @return ComputeResourcePreference
+     */
+    UserComputeResourcePreference getUserComputeResourcePreference(String userId, String gatewayId, String hostId) throws AppCatalogException;
+    UserStoragePreference getUserStoragePreference(String userId, String gatewayId, String storageId) throws AppCatalogException;
+
+
+    List<String> getGatewayProfileIds(String gatewayName) throws AppCatalogException;
+
+    /* Implementing this method is critical to validate User Resource Profile
+     *
+     */
+    String getUserNamefromID(String userId, String gatewayID) throws AppCatalogException;
+
+    List<UserResourceProfile> getAllUserResourceProfiles() throws AppCatalogException;
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/81c6ea84/modules/registry/registry-server/registry-api-service/src/main/java/org/apache/airavata/registry/api/service/handler/RegistryServerHandler.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-server/registry-api-service/src/main/java/org/apache/airavata/registry/api/service/handler/RegistryServerHandler.java b/modules/registry/registry-server/registry-api-service/src/main/java/org/apache/airavata/registry/api/service/handler/RegistryServerHandler.java
index 3ca024c..c26380d 100644
--- a/modules/registry/registry-server/registry-api-service/src/main/java/org/apache/airavata/registry/api/service/handler/RegistryServerHandler.java
+++ b/modules/registry/registry-server/registry-api-service/src/main/java/org/apache/airavata/registry/api/service/handler/RegistryServerHandler.java
@@ -3262,7 +3262,7 @@ public class RegistryServerHandler implements RegistryService.Iface {
             throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
         }
         try {
-            if (!ExpCatResourceUtils.isUserExist(userName, gatewayId)){
+                if (!ExpCatResourceUtils.isUserExist(userName, gatewayId)){
                 logger.error("User does not exist in the system. Please provide a valid user..");
                 AiravataSystemException exception = new AiravataSystemException();
                 exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);