/* * Copyright (c) 2017-present Robert Jaros * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package pl.treksoft.kvision.remote import org.reactivestreams.Publisher import org.springframework.core.ParameterizedTypeReference import org.springframework.core.io.buffer.DataBuffer import org.springframework.core.io.buffer.DataBufferFactory import org.springframework.http.HttpCookie import org.springframework.http.codec.HttpMessageReader import org.springframework.http.codec.multipart.Part import org.springframework.http.server.reactive.ServerHttpRequest import org.springframework.util.MultiValueMap import org.springframework.web.reactive.function.BodyExtractor import org.springframework.web.reactive.function.server.ServerRequest import org.springframework.web.reactive.socket.CloseStatus import org.springframework.web.reactive.socket.HandshakeInfo import org.springframework.web.reactive.socket.WebSocketMessage import org.springframework.web.reactive.socket.WebSocketSession import org.springframework.web.server.ServerWebExchange import org.springframework.web.server.WebSession import org.springframework.web.util.UriBuilder import reactor.core.publisher.Flux import reactor.core.publisher.Mono import java.net.InetSocketAddress import java.net.URI import java.security.Principal import java.util.* import java.util.function.Function /** * Empty implementation of the ServerRequest interface */ internal class KVServerRequest : ServerRequest { override fun body(extractor: BodyExtractor): T { throw IllegalStateException("Empty implementation") } override fun body(extractor: BodyExtractor, hints: MutableMap): T { throw IllegalStateException("Empty implementation") } override fun remoteAddress(): Optional { throw IllegalStateException("Empty implementation") } override fun attributes(): MutableMap { throw IllegalStateException("Empty implementation") } override fun session(): Mono { throw IllegalStateException("Empty implementation") } override fun principal(): Mono { throw IllegalStateException("Empty implementation") } override fun multipartData(): Mono> { throw IllegalStateException("Empty implementation") } override fun messageReaders(): MutableList> { throw IllegalStateException("Empty implementation") } override fun uri(): URI { throw IllegalStateException("Empty implementation") } override fun exchange(): ServerWebExchange { throw IllegalStateException("Empty implementation") } override fun bodyToFlux(elementClass: Class): Flux { throw IllegalStateException("Empty implementation") } override fun bodyToFlux(typeReference: ParameterizedTypeReference): Flux { throw IllegalStateException("Empty implementation") } override fun formData(): Mono> { throw IllegalStateException("Empty implementation") } override fun queryParams(): MultiValueMap { throw IllegalStateException("Empty implementation") } override fun pathVariables(): MutableMap { throw IllegalStateException("Empty implementation") } override fun localAddress(): Optional { throw IllegalStateException("Empty implementation") } override fun uriBuilder(): UriBuilder { throw IllegalStateException("Empty implementation") } override fun methodName(): String { throw IllegalStateException("Empty implementation") } override fun bodyToMono(elementClass: Class): Mono { throw IllegalStateException("Empty implementation") } override fun bodyToMono(typeReference: ParameterizedTypeReference): Mono { throw IllegalStateException("Empty implementation") } override fun cookies(): MultiValueMap { throw IllegalStateException("Empty implementation") } override fun headers(): ServerRequest.Headers { throw IllegalStateException("Empty implementation") } } /** * Empty implementation of the WebSocketSession interface */ internal class KVWebSocketSession : WebSocketSession { override fun getId(): String { throw IllegalStateException("Empty implementation") } override fun binaryMessage(payloadFactory: Function): WebSocketMessage { throw IllegalStateException("Empty implementation") } override fun pingMessage(payloadFactory: Function): WebSocketMessage { throw IllegalStateException("Empty implementation") } override fun bufferFactory(): DataBufferFactory { throw IllegalStateException("Empty implementation") } override fun getAttributes(): MutableMap { throw IllegalStateException("Empty implementation") } override fun receive(): Flux { throw IllegalStateException("Empty implementation") } override fun pongMessage(payloadFactory: Function): WebSocketMessage { throw IllegalStateException("Empty implementation") } override fun getHandshakeInfo(): HandshakeInfo { throw IllegalStateException("Empty implementation") } override fun send(messages: Publisher): Mono { throw IllegalStateException("Empty implementation") } override fun close(status: CloseStatus): Mono { throw IllegalStateException("Empty implementation") } override fun textMessage(payload: String): WebSocketMessage { throw IllegalStateException("Empty implementation") } }