| 25 |
25 |
| 26 package de.uapcore.lightpit |
26 package de.uapcore.lightpit |
| 27 |
27 |
| 28 import de.uapcore.lightpit.dao.DataAccessObject |
28 import de.uapcore.lightpit.dao.DataAccessObject |
| 29 import de.uapcore.lightpit.entities.HasNode |
29 import de.uapcore.lightpit.entities.HasNode |
| |
30 import de.uapcore.lightpit.entities.User |
| 30 import de.uapcore.lightpit.viewmodel.NavMenu |
31 import de.uapcore.lightpit.viewmodel.NavMenu |
| 31 import de.uapcore.lightpit.viewmodel.View |
32 import de.uapcore.lightpit.viewmodel.View |
| 32 import jakarta.servlet.http.HttpServletRequest |
33 import jakarta.servlet.http.HttpServletRequest |
| 33 import jakarta.servlet.http.HttpServletResponse |
34 import jakarta.servlet.http.HttpServletResponse |
| 34 import jakarta.servlet.http.HttpSession |
35 import jakarta.servlet.http.HttpSession |
| 50 sealed interface ValidationResult<T> |
51 sealed interface ValidationResult<T> |
| 51 class ValidationError<T>(val message: String): ValidationResult<T> |
52 class ValidationError<T>(val message: String): ValidationResult<T> |
| 52 class ValidatedValue<T>(val result: T): ValidationResult<T> |
53 class ValidatedValue<T>(val result: T): ValidationResult<T> |
| 53 |
54 |
| 54 class HttpRequest( |
55 class HttpRequest( |
| |
56 val user: User?, |
| 55 val request: HttpServletRequest, |
57 val request: HttpServletRequest, |
| 56 val response: HttpServletResponse, |
58 val response: HttpServletResponse, |
| 57 val pathParams: PathParameters = emptyMap() |
59 val pathParams: PathParameters = emptyMap() |
| 58 ) { |
60 ) { |
| 59 val session: HttpSession = request.session |
61 val session: HttpSession = request.session |
| 60 |
62 |
| 61 val remoteUser: String? = request.remoteUser |
|
| 62 |
|
| 63 /** |
63 /** |
| 64 * The name of the content page. |
64 * The name of the content page. |
| 65 * |
65 * |
| 66 * @see Constants#REQ_ATTR_CONTENT_PAGE |
66 * @see Constants#REQ_ATTR_CONTENT_PAGE |
| 67 */ |
67 */ |
| 150 |
150 |
| 151 /** |
151 /** |
| 152 * The base path of this application. |
152 * The base path of this application. |
| 153 */ |
153 */ |
| 154 val baseHref get() = "${request.scheme}://${request.serverName}$portInfo${request.contextPath}/" |
154 val baseHref get() = "${request.scheme}://${request.serverName}$portInfo${request.contextPath}/" |
| |
155 |
| |
156 init { |
| |
157 request.setAttribute(Constants.REQ_ATTR_BASE_HREF, baseHref) |
| |
158 } |
| 155 |
159 |
| 156 private fun String.withExt(ext: String) = if (endsWith(ext)) this else plus(ext) |
160 private fun String.withExt(ext: String) = if (endsWith(ext)) this else plus(ext) |
| 157 private fun jspPath(name: String) = Constants.JSP_PATH_PREFIX.plus(name).withExt(".jsp") |
161 private fun jspPath(name: String) = Constants.JSP_PATH_PREFIX.plus(name).withExt(".jsp") |
| 158 |
162 |
| 159 fun paramIndexed(prefix: String): Map<Int, String> = buildMap { |
163 fun paramIndexed(prefix: String): Map<Int, String> = buildMap { |