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());
}
}
}
Aggregations