mirror of
https://github.com/corda/corda.git
synced 2025-06-18 15:18:16 +00:00
Retire FileUploader and subtypes (#1154)
This commit is contained in:
@ -17,7 +17,6 @@ class DataUploadServlet : HttpServlet() {
|
||||
|
||||
@Throws(IOException::class)
|
||||
override fun doPost(req: HttpServletRequest, resp: HttpServletResponse) {
|
||||
@Suppress("DEPRECATION") // Bogus warning due to superclass static method being deprecated.
|
||||
val isMultipart = ServletFileUpload.isMultipartContent(req)
|
||||
val rpc = servletContext.getAttribute("rpc") as CordaRPCOps
|
||||
|
||||
@ -34,20 +33,25 @@ class DataUploadServlet : HttpServlet() {
|
||||
resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "Got an upload request with no files")
|
||||
return
|
||||
}
|
||||
|
||||
fun reportError(message: String) {
|
||||
println(message) // Show in webserver window.
|
||||
resp.sendError(HttpServletResponse.SC_BAD_REQUEST, message)
|
||||
}
|
||||
while (iterator.hasNext()) {
|
||||
val item = iterator.next()
|
||||
log.info("Receiving ${item.name}")
|
||||
|
||||
try {
|
||||
val dataType = req.pathInfo.substring(1).substringBefore('/')
|
||||
@Suppress("DEPRECATION") // TODO: Replace the use of uploadFile
|
||||
messages += rpc.uploadFile(dataType, item.name, item.openStream())
|
||||
log.info("${item.name} successfully accepted: ${messages.last()}")
|
||||
} catch(e: RuntimeException) {
|
||||
println(e)
|
||||
resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "Got a file upload request for an unknown data type")
|
||||
val dataType = req.pathInfo.substring(1).substringBefore('/')
|
||||
if (dataType != "attachment") {
|
||||
reportError("Got a file upload request for an unknown data type $dataType")
|
||||
continue
|
||||
}
|
||||
try {
|
||||
messages += rpc.uploadAttachment(item.openStream()).toString()
|
||||
} catch (e: RuntimeException) {
|
||||
reportError(e.toString())
|
||||
continue
|
||||
}
|
||||
log.info("${item.name} successfully accepted: ${messages.last()}")
|
||||
}
|
||||
|
||||
// Send back the hashes as a convenience for the user.
|
||||
|
Reference in New Issue
Block a user