All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.simiacryptus.skyenet.webui.servlet.SessionFileServlet.kt Maven / Gradle / Ivy

There is a newer version: 1.2.21
Show newest version
package com.simiacryptus.skyenet.webui.servlet

import com.simiacryptus.skyenet.core.platform.ApplicationServices
import com.simiacryptus.skyenet.core.platform.Session
import com.simiacryptus.skyenet.core.platform.StorageInterface
import com.simiacryptus.skyenet.webui.application.ApplicationServer.Companion.getCookie
import jakarta.servlet.http.HttpServletRequest
import java.io.File

class SessionFileServlet(val dataStorage: StorageInterface) : FileServlet() {
    override fun getDir(
        req: HttpServletRequest,
    ): File {
        val pathSegments = parsePath(req.pathInfo ?: "/")
        val session = Session(pathSegments.first())
        return dataStorage.getSessionDir(ApplicationServices.authenticationManager.getUser(req.getCookie()), session)
    }

    override fun getZipLink(req: HttpServletRequest, filePath: String): String {
        val pathSegments = parsePath(req.pathInfo ?: "/")
        val session = Session(pathSegments.first())
        return "${req.contextPath}/fileZip?session=$session&path=$filePath"
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy