Commit 8c71e57a authored by Roque Porchetto's avatar Roque Porchetto

erp5_wendelin_telecom_ingestion: handling special chars in urls, ids and references

parent 3014e80e
...@@ -10,6 +10,13 @@ if (length < 7): ...@@ -10,6 +10,13 @@ if (length < 7):
context.logEntry("[ERROR] Data Ingestion reference is not well formated") context.logEntry("[ERROR] Data Ingestion reference is not well formated")
raise ValueError("Data Ingestion reference is not well formated.") raise ValueError("Data Ingestion reference is not well formated.")
invalid_chars = ["&", ";", "#", "%", '"', "+"]
for char in invalid_chars:
if char in reference:
context.logEntry("[ERROR] Data Ingestion reference contains chars that are not allowed")
raise ValueError("Data Ingestion reference contains chars that are not allowed.")
supplier = record[0] supplier = record[0]
dataset_reference = record[1] dataset_reference = record[1]
filename = '/'.join(record[2:-4]) filename = '/'.join(record[2:-4])
......
...@@ -18,8 +18,8 @@ try: ...@@ -18,8 +18,8 @@ try:
supplier = movement_dict.get('supplier', None) supplier = movement_dict.get('supplier', None)
extension = movement_dict.get('extension', None) extension = movement_dict.get('extension', None)
dataset_reference = movement_dict.get('dataset_reference', None) dataset_reference = movement_dict.get('dataset_reference', None)
data_ingestion_id = '%s_%s_%s_%s' %(supplier, data_ingestion_reference.replace("/","_").replace(" ","_"), now_string, eof) data_ingestion_id = '%s_%s_%s_%s' %(supplier, dataset_reference, now_string, eof)
context.logEntry("Data Ingestion ID: %s" % reference) context.logEntry("Data Ingestion ID: %s" % data_ingestion_id)
size = movement_dict.get('size', None) if movement_dict.get('size', None) != "" else None size = movement_dict.get('size', None) if movement_dict.get('size', None) != "" else None
hash_value = movement_dict.get('hash', None) if movement_dict.get('hash', None) != "" else None hash_value = movement_dict.get('hash', None) if movement_dict.get('hash', None) != "" else None
......
import re import re
import json
from Products.ERP5Type.Log import log from Products.ERP5Type.Log import log
from Products.ZSQLCatalog.SQLCatalog import Query, SimpleQuery, ComplexQuery from Products.ZSQLCatalog.SQLCatalog import Query, SimpleQuery, ComplexQuery
...@@ -28,9 +29,10 @@ data_stream_list = [] ...@@ -28,9 +29,10 @@ data_stream_list = []
for stream in portal_catalog(**query_dict): for stream in portal_catalog(**query_dict):
if stream.getVersion() == "": if stream.getVersion() == "":
return { "status_code": 2, "result": [] } return { "status_code": 2, "result": [] }
data_stream_list.append({ "id": "data_stream_module/"+stream.getId(), data_stream_list.append({ 'id': 'data_stream_module/'+stream.getId(),
"reference": stream.getReference(), 'reference': stream.getReference(),
"size": stream.getSize(), 'size': stream.getSize(),
"hash": stream.getVersion() }) 'hash': stream.getVersion() })
return { "status_code": 0, "result": data_stream_list } dict = { 'status_code': 0, 'result': data_stream_list }
return json.dumps(dict)
...@@ -15,7 +15,7 @@ ingestions = portal_catalog(**ing_dict) ...@@ -15,7 +15,7 @@ ingestions = portal_catalog(**ing_dict)
if len(ingestions) == 1: if len(ingestions) == 1:
data_ingestion = ingestions[0] data_ingestion = ingestions[0]
else: else:
context.logEntry("ERROR getting Data Ingestion of file %s. The file does not have a unique data ingestion in correct state.") context.logEntry("ERROR getting Data Ingestion of file %s. The file does not have a unique data ingestion in correct state." % reference)
return '{"metadata":"No metadata available for this type of file yet"}' return '{"metadata":"No metadata available for this type of file yet"}'
try: try:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment