|
@@ -17,7 +17,6 @@ import java.text.SimpleDateFormat
|
|
|
import java.util.*
|
|
|
import kotlin.Any
|
|
|
import kotlin.Boolean
|
|
|
-import kotlin.ByteArray
|
|
|
import kotlin.RuntimeException
|
|
|
import kotlin.String
|
|
|
import kotlin.Throws
|
|
@@ -46,12 +45,7 @@ class MaintenanceController(
|
|
|
@GetMapping("/maintenance", produces = ["text/csv;charset=utf8;"])
|
|
|
@Throws(IOException::class)
|
|
|
fun exportToCSV(response: HttpServletResponse, @RequestParam tableName: String): ResponseEntity<*> {
|
|
|
-// val userId = userRepository.getUserByUsername(SecurityContextHolder.getContext().authentication.name)
|
|
|
-// val valid = memberRepository.validAdmin(userId.id.toString())
|
|
|
val tableList = listOf("project", "platform", "user", "project_member", "bug", "comment")
|
|
|
-// if (valid == 0) {
|
|
|
-// ResponseEntity<Any>(HttpStatus.FORBIDDEN)
|
|
|
-// } else {
|
|
|
if (!tableList.contains(tableName) || tableName.isEmpty()) {
|
|
|
return ResponseEntity<Any>(HttpStatus.BAD_REQUEST)
|
|
|
} else {
|
|
@@ -99,13 +93,7 @@ class MaintenanceController(
|
|
|
csvContent.append("${csvHeader.joinToString("")}\n")
|
|
|
csvContent.append(list.joinToString("\n"))
|
|
|
val headers = HttpHeaders()
|
|
|
-// headers.contentType = MediaType.APPLICATION_OCTET_STREAM
|
|
|
-// headers.setContentDispositionFormData("attachment", "$tableName.csv")
|
|
|
-// val fileName = String(tableName.toByteArray(), charset("ISO8859-1"))
|
|
|
-// headers["content-disposition"] = "attachment;filename=$fileName.csv"
|
|
|
-// response.addHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=$tableName.csv")
|
|
|
response.contentType = MediaType.APPLICATION_OCTET_STREAM.toString()
|
|
|
-// response.addHeade
|
|
|
response.addHeader(
|
|
|
HttpHeaders.CONTENT_DISPOSITION,
|
|
|
"attachment; filename=$tableName.csv"
|
|
@@ -115,28 +103,7 @@ class MaintenanceController(
|
|
|
response.outputStream.close()
|
|
|
|
|
|
return ResponseEntity("ok", HttpStatus.OK)
|
|
|
-// return ResponseEntity(csvContent, headers, HttpStatus.OK)
|
|
|
-
|
|
|
-// val cacheResultHandler = CacheDataManager()
|
|
|
-// val inputStream: InputStream
|
|
|
-// val byteArray: ByteArray
|
|
|
-// val httpHeaders = HttpHeaders()
|
|
|
-// val inputStreamResource: InputStreamResource = cacheResultHandler.exportCacheResults(response)
|
|
|
-// httpHeaders[HttpHeaders.CONTENT_DISPOSITION] = "attachment; filename=$tableName.csv"
|
|
|
- //convert inputStream to bytes
|
|
|
-// inputStream = inputStreamResource.inputStream
|
|
|
-// val buffer = ByteArrayOutputStream()
|
|
|
-// var nRead: Int
|
|
|
-// val data = ByteArray(1024)
|
|
|
-// while ((inputStream.read(data, 0, data.size).also { nRead = it }) != -1) {
|
|
|
-// buffer.write(data, 0, nRead)
|
|
|
-// }
|
|
|
-// buffer.flush()
|
|
|
-// byteArray = buffer.toByteArray()
|
|
|
-// httpHeaders.contentLength = byteArray.size.toLong()
|
|
|
-// return ResponseEntity(byteArray, httpHeaders, HttpStatus.OK)
|
|
|
}
|
|
|
-// return ResponseEntity<Any>(HttpStatus.INTERNAL_SERVER_ERROR)
|
|
|
}
|
|
|
|
|
|
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
|
@@ -146,12 +113,7 @@ class MaintenanceController(
|
|
|
fun import(
|
|
|
@RequestParam file: MultipartFile, @RequestParam tableName: String, @RequestParam overwrite: Boolean
|
|
|
): ResponseEntity<Any> {
|
|
|
-// val userId = userRepository.getUserByUsername(SecurityContextHolder.getContext().authentication.name)
|
|
|
-// val valid = memberRepository.validAdmin(userId.id.toString())
|
|
|
val tableList = listOf("project", "platform", "user", "project_member", "bug", "comment")
|
|
|
-// if (valid == 0) {
|
|
|
-// ResponseEntity<Any>(HttpStatus.FORBIDDEN)
|
|
|
-// } else {
|
|
|
var found = 0
|
|
|
val mapData: MutableList<MutableMap<String, Any>> = mutableListOf()
|
|
|
if (!tableList.contains(tableName) || tableName.isEmpty()) {
|