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):
context.logEntry("[ERROR] 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]
dataset_reference = record[1]
filename = '/'.join(record[2:-4])
......
......@@ -18,8 +18,8 @@ try:
supplier = movement_dict.get('supplier', None)
extension = movement_dict.get('extension', 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)
context.logEntry("Data Ingestion ID: %s" % reference)
data_ingestion_id = '%s_%s_%s_%s' %(supplier, dataset_reference, now_string, eof)
context.logEntry("Data Ingestion ID: %s" % data_ingestion_id)
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
......
import re
import json
from Products.ERP5Type.Log import log
from Products.ZSQLCatalog.SQLCatalog import Query, SimpleQuery, ComplexQuery
......@@ -28,9 +29,10 @@ data_stream_list = []
for stream in portal_catalog(**query_dict):
if stream.getVersion() == "":
return { "status_code": 2, "result": [] }
data_stream_list.append({ "id": "data_stream_module/"+stream.getId(),
"reference": stream.getReference(),
"size": stream.getSize(),
"hash": stream.getVersion() })
data_stream_list.append({ 'id': 'data_stream_module/'+stream.getId(),
'reference': stream.getReference(),
'size': stream.getSize(),
'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)
if len(ingestions) == 1:
data_ingestion = ingestions[0]
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"}'
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