use of org.eclipse.che.ide.websocket.rest.Pair in project che by eclipse.
the class AbstractMessageBus method onMessageReceived.
/** {@inheritDoc} */
@Override
public void onMessageReceived(MessageReceivedEvent event) {
Message message = parseMessage(event.getMessage());
// as it might be disallowed when processing actually takes place.
if (message.getResponseCode() == 202) {
return;
}
//TODO Should be revised to remove
List<Pair> headers = message.getHeaders().toList();
if (headers != null) {
for (Pair header : headers) {
if (HTTPHeader.LOCATION.equals(header.getName()) && header.getValue().contains("async/")) {
return;
}
}
}
if (getChannel(message) != null) {
// this is a message received by subscription
processSubscriptionMessage(message);
} else {
String uuid = message.getStringField(MessageBuilder.UUID_FIELD);
ReplyHandler replyCallback = replyCallbackMap.remove(uuid);
if (replyCallback != null) {
replyCallback.onReply(message.getBody());
} else {
RequestCallback requestCallback = requestCallbackMap.remove(uuid);
if (requestCallback != null) {
requestCallback.onReply(message);
}
}
}
}
use of org.eclipse.che.ide.websocket.rest.Pair in project che by eclipse.
the class MessageBuilder method header.
/**
* Sets a request header with the given name and value. If a header with the
* specified name has already been set then the new value overwrites the
* current value.
*
* @param name
* the name of the header
* @param value
* the value of the header
* @return this {@link MessageBuilder}
*/
public final MessageBuilder header(String name, String value) {
JsoArray<Pair> headers = message.getHeaders();
if (headers == null) {
headers = JsoArray.create();
}
for (int i = 0; i < headers.size(); i++) {
Pair header = headers.get(i);
if (name.equals(header.getName())) {
header.setValue(value);
return this;
}
}
Pair header = Pair.create();
header.setName(name);
header.setValue(value);
headers.add(header);
message.setHeaders(headers);
return this;
}
Aggregations