From 1fbef857d8c2e6057c1834435b19e6ce22ca6b21 Mon Sep 17 00:00:00 2001 From: Viktor Kovtun <viktor.kovtun@id.ethz.ch> Date: Mon, 5 Aug 2019 16:45:51 +0200 Subject: [PATCH] SSDM-8405 Made error message correct when an HTTP error is returned when requesting for possible submission types. --- .../reporting-plugins/rc-exports-api/rcExports.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/dss/reporting-plugins/rc-exports-api/rcExports.py b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/dss/reporting-plugins/rc-exports-api/rcExports.py index e354f38dcdd..99f41ac9578 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/dss/reporting-plugins/rc-exports-api/rcExports.py +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/dss/reporting-plugins/rc-exports-api/rcExports.py @@ -140,10 +140,7 @@ def sendToDSpace(params, tr, tempZipFileName, tempZipFilePath): for key, value in headers.iteritems(): request.header(key, str(value)) response = request.method(HttpMethod.POST).file(Paths.get(tempZipFilePath), 'application/zip').send() - status = response.getStatus() - if status >= 300: - reason = response.getReason() - raise ValueError('Unsuccessful response from the server: %s %s' % (status, reason)) + checkResponseStatus(response) xmlText = response.getContentAsString().encode('utf-8') xmlRoot = ET.fromstring(xmlText) @@ -177,6 +174,7 @@ def authenticateUserJava(url, tr): def fetchServiceDocument(url, httpClient): response = httpClient.newRequest(url).method(HttpMethod.GET).send() + checkResponseStatus(response) xmlText = response.getContentAsString().encode('utf-8') xmlRoot = ET.fromstring(xmlText) @@ -191,6 +189,13 @@ def fetchServiceDocument(url, httpClient): return json.dumps(map(collectionToDictionaryMapper, collections)) +def checkResponseStatus(response): + status = response.getStatus() + if status >= 300: + reason = response.getReason() + raise ValueError('Unsuccessful response from the server: %s %s' % (status, reason)) + + def generateInternalZipFile(entities, params, tempDirPath, tempZipFilePath): # Generates ZIP file with selected item for export -- GitLab