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 e354f38dcdd770f6a8b98b765556fc936ad5dfab..99f41ac9578a20a317c6af933a733e5e6b407d00 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