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

machristie pushed a commit to branch airavata-3016
in repository https://gitbox.apache.org/repos/asf/airavata-django-portal.git

commit 4ace7f4cb15c3aaf4696398335d34ee18f618387
Author: Marcus Christie <[email protected]>
AuthorDate: Sun May 26 08:24:50 2019 -0400

    AIRAVATA-3016 Adding data_products_helper.user_file_exists
---
 django_airavata/apps/api/data_products_helper.py | 10 ++++++++++
 django_airavata/apps/workspace/views.py          | 11 ++++-------
 2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/django_airavata/apps/api/data_products_helper.py 
b/django_airavata/apps/api/data_products_helper.py
index 88d9f4e..785bb68 100644
--- a/django_airavata/apps/api/data_products_helper.py
+++ b/django_airavata/apps/api/data_products_helper.py
@@ -42,6 +42,16 @@ def dir_exists(request, path):
     return datastore.exists(request.user.username, path)
 
 
+def user_file_exists(request, path):
+    """If file exists, return data product URI, else None."""
+    if datastore.user_file_exists(request.user.username, path):
+        full_path = datastore.path(request.user.username, path)
+        data_product_uri = _get_data_product_uri(request, full_path)
+        return data_product_uri
+    else:
+        return None
+
+
 def delete_dir(request, path):
     return datastore.delete_dir(request.user.username, path)
 
diff --git a/django_airavata/apps/workspace/views.py 
b/django_airavata/apps/workspace/views.py
index 2c018e9..ad9bc6c 100644
--- a/django_airavata/apps/workspace/views.py
+++ b/django_airavata/apps/workspace/views.py
@@ -19,7 +19,7 @@ from airavata.model.data.replica.ttypes import (
     ReplicaLocationCategory,
     ReplicaPersistentType
 )
-from django_airavata.apps.api import datastore
+from django_airavata.apps.api import data_products_helper
 from django_airavata.apps.api.views import (
     ApplicationModuleViewSet,
     ExperimentSearchViewSet,
@@ -87,12 +87,9 @@ def create_experiment(request, app_module_id):
         if (app_input['type'] ==
                 DataType.URI and app_input['name'] in request.GET):
             user_file_path = request.GET[app_input['name']]
-            if datastore.user_file_exists(
-                    request.user.username, user_file_path):
-                data_product = datastore.get_data_product(
-                    request.user.username, user_file_path)
-                data_product_uri = request.airavata_client.registerDataProduct(
-                    request.authz_token, data_product)
+            data_product_uri = data_products_helper.user_file_exists(
+                request, user_file_path)
+            if data_product_uri is not None:
                 user_input_files[app_input['name']] = data_product_uri
     context = {
         'bundle_name': 'create-experiment',

Reply via email to