Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
memoriav
Memobase 2020
services
Import Process
Import API
Commits
841e66e4
Commit
841e66e4
authored
Apr 12, 2021
by
Matthias
Browse files
adapt to given json structure
parent
d5dba036
Pipeline
#24449
passed with stages
in 2 minutes and 45 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
import_api_app/resources/WriteJobResultsToDrupal.py
View file @
841e66e4
...
...
@@ -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
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment