# HG changeset patch
# User fabio
# Date 1496336842 14400
# Node ID 3eabece82abb4e9f18d313bb91ced664cc50d087
# Parent  78bd202e8687f28447350db117d348c0ce983411
Uploaded 20170601
diff -r 78bd202e8687 -r 3eabece82abb ._gdcwebapp.xml
Binary file ._gdcwebapp.xml has changed
diff -r 78bd202e8687 -r 3eabece82abb ._json_data_source_mod.py
Binary file ._json_data_source_mod.py has changed
diff -r 78bd202e8687 -r 3eabece82abb gdcwebapp.xml
--- a/gdcwebapp.xml	Tue May 30 15:56:33 2017 -0400
+++ b/gdcwebapp.xml	Thu Jun 01 13:07:22 2017 -0400
@@ -21,7 +21,7 @@
     
         
         
-            
+            
         
     
     
diff -r 78bd202e8687 -r 3eabece82abb json_data_source_mod.py
--- a/json_data_source_mod.py	Tue May 30 15:56:33 2017 -0400
+++ b/json_data_source_mod.py	Thu Jun 01 13:07:22 2017 -0400
@@ -105,7 +105,7 @@
     return "%s\n" % json.dumps( meta_dict )
 
 
-def walk_on_archive(target_output_filename, check_ext, archive_name, appdata_path):
+def walk_on_archive(target_output_filename, check_ext, archive_name, appdata_path, db_key="?"):
     archive_name = archive_name.replace("_", "-").replace(".", "-")
     with tarfile.open( target_output_filename, check_ext ) as tf:
         for entry in tf:
@@ -114,12 +114,12 @@
                 # reserve the underscore for the collection searator
                 filename = os.path.basename( entry.name ).replace("_", "-")
                 extension = splitext( filename )[1]
-                # pattern: (?P<identifier_0>[^_]+)_(?P<identifier_1>[^_]+)
+                # pattern: (?P[^_]+)_(?P[^_]+)_(?P[^_]+)_(?P[^_]+)
                 if (len(extension) > 0):
-                    filename = (filename[0:len(filename)-(len(extension)+1)]).replace(".", "-") + "." + extension
+                    filename = (filename[0:len(filename)-(len(extension)+1)]).replace(".", "-") + "_" + extension
                 else:
                     extension = "auto"
-                filename_with_collection_prefix = archive_name + "_" + filename
+                filename_with_collection_prefix = archive_name + "_" + filename + "_" + db_key
                 target_entry_output_filename = os.path.join(appdata_path, filename_with_collection_prefix)
                 store_file_from_archive( fileobj, target_entry_output_filename )
     return True
@@ -175,7 +175,14 @@
 
     """ the following code handles archives and decompress them in a collection """
     if ( isArchive ):
-        walk_on_archive(target_output_path, check_ext, filename, appdata_path)
+        db_key = "?"
+        archive_metadata = query_item.get( 'metadata', None )
+        if archive_metadata is not None:
+            try:
+                db_key = archive_metadata.get( 'db_key' )
+            except:
+                pass
+        walk_on_archive(target_output_path, check_ext, filename, appdata_path, db_key)
 
     return True