Skip to content
Snippets Groups Projects
Commit 1fbef857 authored by vkovtun's avatar vkovtun
Browse files

SSDM-8405 Made error message correct when an HTTP error is returned when...

SSDM-8405 Made error message correct when an HTTP error is returned when requesting for possible submission types.
parent 0dfd2751
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment