Commit 841e66e4 authored by Matthias's avatar Matthias
Browse files

adapt to given json structure

parent d5dba036
Pipeline #24449 passed with stages
in 2 minutes and 45 seconds
......@@ -31,14 +31,51 @@ class WriteJobResultToDrupal(Resource):
items:
type: object
properties:
report:
type: string
example: reporting json...
description: The aggregated report of an import
status:
sessionId:
type: string
example: SUCCESS
description: The status of an import
example: "550e8400-e29b-11d4-a716-446655440000"
step:
type: string
example: "media-metadata-extractor"
total:
type: integer
example: 468
success:
type: integer
example: 413
ignore:
type: integer
example: 0
warning:
type: integer
example: 455
fatal:
type: integer
example: 0
earliest:
type: string
example: "2021-03-08T14:02:23.232"
latest:
type: string
example: "latest"
elapsedTime:
type: string
example: "00:03:11.219"
recordSetId:
type: string
example: "fss-001"
institutionId:
type: string
example: "fss"
messageId:
type: string
example: "1b7d8224-451a-4afb-b5d2-6537acb74051"
previousMessageId:
type: string
example: "04543477-3bb5-4d01-a318-52ded1ce5e1c"
version:
type: string
example: "3"
responses:
200:
description: It was successful
......@@ -48,8 +85,11 @@ class WriteJobResultToDrupal(Resource):
description: There was a problem
"""
try:
status = request.json[0]['status']
report = request.json[0]['report']
fatal = request.json[0]['fatal']
status = 'FAILED'
if fatal == 0:
status = 'SUCCESS'
report = json.dumps(request.json[0], indent=2)
return write_results(job_drupal_uuid, job_log_drupal_uuid, status, report)
except ImportApiError as e:
return {'error': e.message}, 500
......@@ -123,6 +163,10 @@ def write_results(job_drupal_uuid, job_log_drupal_uuid, status, report):
message = 'Not Found: ' + url
current_app.logger.error(message)
raise ImportApiError(message)
elif response.status_code == 500:
message = 'There was an internal server error: ' + url + '. Check the logs for details.'
current_app.logger.error(message)
raise ImportApiError(message)
else:
message = "Unknown response status code for drupal api for url " + url
current_app.logger.error(message)
......
Supports Markdown
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