Search in sources :

Example 1 with NoSuchSocketException

use of won.protocol.exception.NoSuchSocketException in project webofneeds by researchstudio-sat.

the class SocketTypeExtractor method process.

@Override
public void process(Exchange exchange) throws Exception {
    WonMessage msg = getMessageRequired(exchange);
    WonMessageDirection direction = getDirectionRequired(exchange);
    Optional<URI> socketURI = Optional.empty();
    if (direction.isFromExternal()) {
        socketURI = Optional.ofNullable(msg.getRecipientSocketURI());
    } else {
        socketURI = Optional.ofNullable(msg.getSenderSocketURI());
    }
    if (socketURI.isPresent()) {
        Optional<Socket> socket = socketService.getSocket(socketURI.get());
        if (socket.isPresent()) {
            putSocketTypeURI(exchange, socket.get().getTypeURI());
        } else {
            throw new NoSuchSocketException(socketURI.get());
        }
    }
}
Also used : NoSuchSocketException(won.protocol.exception.NoSuchSocketException) WonMessage(won.protocol.message.WonMessage) WonMessageDirection(won.protocol.message.WonMessageDirection) URI(java.net.URI) Socket(won.protocol.model.Socket)

Aggregations

URI (java.net.URI)1 NoSuchSocketException (won.protocol.exception.NoSuchSocketException)1 WonMessage (won.protocol.message.WonMessage)1 WonMessageDirection (won.protocol.message.WonMessageDirection)1 Socket (won.protocol.model.Socket)1