blob: 46b0859aae52f97c4db89fea1e2f7d58e1b85d6a [file] [log] [blame]
Thomas Vachuska3553b302015-03-07 14:49:43 -08001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Thomas Vachuska3553b302015-03-07 14:49:43 -08003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.ui.impl;
17
18import com.fasterxml.jackson.databind.ObjectMapper;
Thomas Vachuskab6acc7b2015-03-11 09:11:21 -070019import com.fasterxml.jackson.databind.node.ArrayNode;
Thomas Vachuska3553b302015-03-07 14:49:43 -080020import com.fasterxml.jackson.databind.node.ObjectNode;
21import org.eclipse.jetty.websocket.WebSocket;
22import org.onlab.osgi.ServiceDirectory;
Thomas Vachuskafc52fec2015-05-18 19:13:56 -070023import org.onlab.osgi.ServiceNotFoundException;
Thomas Vachuskab6acc7b2015-03-11 09:11:21 -070024import org.onosproject.cluster.ClusterService;
25import org.onosproject.cluster.ControllerNode;
Simon Hunt8add9ee2016-09-20 17:05:07 -070026import org.onosproject.ui.GlyphConstants;
Thomas Vachuska3553b302015-03-07 14:49:43 -080027import org.onosproject.ui.UiConnection;
Simon Hunt2d7cd6f2017-05-04 13:04:50 -070028import org.onosproject.ui.UiExtension;
Thomas Vachuska3553b302015-03-07 14:49:43 -080029import org.onosproject.ui.UiExtensionService;
Simon Hunta0ddb022015-05-01 09:53:01 -070030import org.onosproject.ui.UiMessageHandler;
Simon Hunt7715e892016-04-12 19:55:32 -070031import org.onosproject.ui.UiMessageHandlerFactory;
Simon Hunt1169c952017-06-05 11:20:11 -070032import org.onosproject.ui.UiSessionToken;
33import org.onosproject.ui.UiTokenService;
Simon Hunt22c35df2017-04-26 17:28:42 -070034import org.onosproject.ui.UiTopo2OverlayFactory;
Thomas Vachuska92b016b2016-05-20 11:37:57 -070035import org.onosproject.ui.UiTopoLayoutService;
Simon Hunte05cae42015-07-23 17:35:24 -070036import org.onosproject.ui.UiTopoOverlayFactory;
Simon Hunt537bc762016-12-20 12:15:13 -080037import org.onosproject.ui.impl.topo.Topo2Jsonifier;
Simon Hunt22c35df2017-04-26 17:28:42 -070038import org.onosproject.ui.impl.topo.Topo2OverlayCache;
Simon Hunt2d7cd6f2017-05-04 13:04:50 -070039import org.onosproject.ui.impl.topo.Topo2TrafficMessageHandler;
Simon Hunt22c35df2017-04-26 17:28:42 -070040import org.onosproject.ui.impl.topo.Topo2ViewMessageHandler;
Thomas Vachuska92b016b2016-05-20 11:37:57 -070041import org.onosproject.ui.impl.topo.UiTopoSession;
42import org.onosproject.ui.impl.topo.model.UiSharedTopologyModel;
43import org.onosproject.ui.model.topo.UiTopoLayout;
Thomas Vachuska3553b302015-03-07 14:49:43 -080044import org.slf4j.Logger;
45import org.slf4j.LoggerFactory;
46
47import java.io.IOException;
48import java.util.HashMap;
49import java.util.Map;
50
51/**
Simon Hunt7092cc42016-04-06 18:40:17 -070052 * Web socket capable of interacting with the Web UI.
Thomas Vachuska3553b302015-03-07 14:49:43 -080053 */
54public class UiWebSocket
55 implements UiConnection, WebSocket.OnTextMessage, WebSocket.OnControl {
56
57 private static final Logger log = LoggerFactory.getLogger(UiWebSocket.class);
58
Simon Hunt7715e892016-04-12 19:55:32 -070059 private static final String EVENT = "event";
Simon Hunt7715e892016-04-12 19:55:32 -070060 private static final String PAYLOAD = "payload";
61 private static final String UNKNOWN = "unknown";
Simon Hunt1169c952017-06-05 11:20:11 -070062 private static final String AUTHENTICATION = "authentication";
63 private static final String TOKEN = "token";
64 private static final String ERROR = "error";
Simon Hunt7715e892016-04-12 19:55:32 -070065
66 private static final String ID = "id";
67 private static final String IP = "ip";
68 private static final String CLUSTER_NODES = "clusterNodes";
69 private static final String USER = "user";
70 private static final String BOOTSTRAP = "bootstrap";
71
Simon Huntd6d3ad32017-06-21 15:27:06 -070072 private static final String UBERLION = "uberlion";
73 private static final String LION = "lion";
74
Simon Huntd7395c82016-10-20 17:54:01 -070075 private static final String TOPO = "topo";
Thomas Vachuska92b016b2016-05-20 11:37:57 -070076
Thomas Vachuska1a989c12015-06-09 18:29:22 -070077 private static final long MAX_AGE_MS = 30_000;
Thomas Vachuska3553b302015-03-07 14:49:43 -080078
79 private static final byte PING = 0x9;
80 private static final byte PONG = 0xA;
81 private static final byte[] PING_DATA = new byte[]{(byte) 0xde, (byte) 0xad};
82
Simon Hunt7092cc42016-04-06 18:40:17 -070083 private final ObjectMapper mapper = new ObjectMapper();
Thomas Vachuska3553b302015-03-07 14:49:43 -080084 private final ServiceDirectory directory;
Thomas Vachuska92b016b2016-05-20 11:37:57 -070085 private final UiTopoSession topoSession;
Thomas Vachuska3553b302015-03-07 14:49:43 -080086
87 private Connection connection;
88 private FrameConnection control;
Thomas Vachuska0af26912016-03-21 21:37:30 -070089 private String userName;
Thomas Vachuska92b016b2016-05-20 11:37:57 -070090 private String currentView;
Thomas Vachuska3553b302015-03-07 14:49:43 -080091
Thomas Vachuska3553b302015-03-07 14:49:43 -080092 private long lastActive = System.currentTimeMillis();
93
Simon Hunta0ddb022015-05-01 09:53:01 -070094 private Map<String, UiMessageHandler> handlers;
Simon Hunte05cae42015-07-23 17:35:24 -070095 private TopoOverlayCache overlayCache;
Simon Hunt22c35df2017-04-26 17:28:42 -070096 private Topo2OverlayCache overlay2Cache;
Thomas Vachuska3553b302015-03-07 14:49:43 -080097
Simon Hunt1169c952017-06-05 11:20:11 -070098 private UiSessionToken sessionToken;
99
100
Thomas Vachuska3553b302015-03-07 14:49:43 -0800101 /**
Simon Huntcda9c032016-04-11 10:32:54 -0700102 * Creates a new web-socket for serving data to the Web UI.
Thomas Vachuska3553b302015-03-07 14:49:43 -0800103 *
104 * @param directory service directory
Simon Hunt7715e892016-04-12 19:55:32 -0700105 * @param userName user name of the logged-in user
Thomas Vachuska3553b302015-03-07 14:49:43 -0800106 */
Thomas Vachuska0af26912016-03-21 21:37:30 -0700107 public UiWebSocket(ServiceDirectory directory, String userName) {
Thomas Vachuska3553b302015-03-07 14:49:43 -0800108 this.directory = directory;
Thomas Vachuska0af26912016-03-21 21:37:30 -0700109 this.userName = userName;
Simon Hunt537bc762016-12-20 12:15:13 -0800110
Simon Hunt95f4b422017-03-03 13:49:05 -0800111 Topo2Jsonifier t2json = new Topo2Jsonifier(directory, userName);
Simon Hunt537bc762016-12-20 12:15:13 -0800112 UiSharedTopologyModel sharedModel = directory.get(UiSharedTopologyModel.class);
113 UiTopoLayoutService layoutService = directory.get(UiTopoLayoutService.class);
Simon Huntbbd0f462017-01-10 14:50:22 -0800114
Simon Hunt8eac4ae2017-01-20 12:56:45 -0800115 sharedModel.injectJsonifier(t2json);
Simon Huntbbd0f462017-01-10 14:50:22 -0800116 topoSession = new UiTopoSession(this, t2json, sharedModel, layoutService);
Simon Hunt1169c952017-06-05 11:20:11 -0700117 sessionToken = null;
Thomas Vachuska0af26912016-03-21 21:37:30 -0700118 }
119
120 @Override
121 public String userName() {
122 return userName;
Thomas Vachuska3553b302015-03-07 14:49:43 -0800123 }
124
Thomas Vachuska92b016b2016-05-20 11:37:57 -0700125 @Override
126 public UiTopoLayout currentLayout() {
127 return topoSession.currentLayout();
128 }
129
130 @Override
131 public void setCurrentLayout(UiTopoLayout topoLayout) {
132 topoSession.setCurrentLayout(topoLayout);
133 }
134
135 @Override
136 public String currentView() {
137 return currentView;
138 }
139
140 @Override
141 public void setCurrentView(String viewId) {
142 currentView = viewId;
143 topoSession.enableEvent(viewId.equals(TOPO));
144 }
145
Simon Huntd6d3ad32017-06-21 15:27:06 -0700146 private ObjectNode objectNode() {
147 return mapper.createObjectNode();
148 }
149
150 private ArrayNode arrayNode() {
151 return mapper.createArrayNode();
152 }
153
Thomas Vachuska3553b302015-03-07 14:49:43 -0800154 /**
Simon Huntd5b96732016-07-08 13:22:27 -0700155 * Provides a reference to the topology session.
156 *
157 * @return topo session reference
158 */
159 public UiTopoSession topoSession() {
160 return topoSession;
161 }
162
163 /**
Thomas Vachuska3553b302015-03-07 14:49:43 -0800164 * Issues a close on the connection.
165 */
166 synchronized void close() {
Simon Hunte05cae42015-07-23 17:35:24 -0700167 destroyHandlersAndOverlays();
Thomas Vachuska3553b302015-03-07 14:49:43 -0800168 if (connection.isOpen()) {
169 connection.close();
170 }
171 }
172
173 /**
174 * Indicates if this connection is idle.
175 *
176 * @return true if idle or closed
177 */
178 synchronized boolean isIdle() {
Simon Huntda580882015-05-12 20:58:18 -0700179 long quietFor = System.currentTimeMillis() - lastActive;
180 boolean idle = quietFor > MAX_AGE_MS;
Thomas Vachuska3553b302015-03-07 14:49:43 -0800181 if (idle || (connection != null && !connection.isOpen())) {
Simon Huntda580882015-05-12 20:58:18 -0700182 log.debug("IDLE (or closed) websocket [{} ms]", quietFor);
Thomas Vachuska3553b302015-03-07 14:49:43 -0800183 return true;
184 } else if (connection != null) {
185 try {
186 control.sendControl(PING, PING_DATA, 0, PING_DATA.length);
187 } catch (IOException e) {
188 log.warn("Unable to send ping message due to: ", e);
189 }
190 }
191 return false;
192 }
193
194 @Override
Satish K598c28d2015-11-24 17:20:40 +0530195 public synchronized void onOpen(Connection connection) {
Thomas Vachuska3553b302015-03-07 14:49:43 -0800196 this.connection = connection;
197 this.control = (FrameConnection) connection;
Thomas Vachuskafc52fec2015-05-18 19:13:56 -0700198 try {
Thomas Vachuska92b016b2016-05-20 11:37:57 -0700199 topoSession.init();
Simon Hunte05cae42015-07-23 17:35:24 -0700200 createHandlersAndOverlays();
Simon Hunt7715e892016-04-12 19:55:32 -0700201 sendBootstrapData();
Simon Huntd6d3ad32017-06-21 15:27:06 -0700202 sendUberLionBundle();
Simon Hunt7715e892016-04-12 19:55:32 -0700203 log.info("GUI client connected -- user <{}>", userName);
Thomas Vachuskafc52fec2015-05-18 19:13:56 -0700204
205 } catch (ServiceNotFoundException e) {
Brian O'Connor75deea62015-06-24 16:09:17 -0400206 log.warn("Unable to open GUI connection; services have been shut-down", e);
Thomas Vachuskafc52fec2015-05-18 19:13:56 -0700207 this.connection.close();
208 this.connection = null;
209 this.control = null;
210 }
Thomas Vachuska3553b302015-03-07 14:49:43 -0800211 }
212
213 @Override
214 public synchronized void onClose(int closeCode, String message) {
Simon Hunt1169c952017-06-05 11:20:11 -0700215 tokenService().revokeToken(sessionToken);
216 log.info("Session token revoked");
217
218 sessionToken = null;
219
Thomas Vachuska92b016b2016-05-20 11:37:57 -0700220 topoSession.destroy();
Simon Hunte05cae42015-07-23 17:35:24 -0700221 destroyHandlersAndOverlays();
Simon Huntda580882015-05-12 20:58:18 -0700222 log.info("GUI client disconnected [close-code={}, message={}]",
Simon Hunt22c35df2017-04-26 17:28:42 -0700223 closeCode, message);
Thomas Vachuska3553b302015-03-07 14:49:43 -0800224 }
225
226 @Override
227 public boolean onControl(byte controlCode, byte[] data, int offset, int length) {
228 lastActive = System.currentTimeMillis();
229 return true;
230 }
231
232 @Override
233 public void onMessage(String data) {
234 lastActive = System.currentTimeMillis();
235 try {
236 ObjectNode message = (ObjectNode) mapper.reader().readTree(data);
Simon Hunt7715e892016-04-12 19:55:32 -0700237 String type = message.path(EVENT).asText(UNKNOWN);
Simon Hunt1169c952017-06-05 11:20:11 -0700238
239 if (sessionToken == null) {
240 authenticate(type, message);
241
Thomas Vachuska3553b302015-03-07 14:49:43 -0800242 } else {
Simon Hunt1169c952017-06-05 11:20:11 -0700243 UiMessageHandler handler = handlers.get(type);
244 if (handler != null) {
245 log.debug("RX message: {}", message);
246 handler.process(message);
247 } else {
248 log.warn("No GUI message handler for type {}", type);
249 }
Thomas Vachuska3553b302015-03-07 14:49:43 -0800250 }
Simon Hunt1169c952017-06-05 11:20:11 -0700251
Thomas Vachuska3553b302015-03-07 14:49:43 -0800252 } catch (Exception e) {
253 log.warn("Unable to parse GUI message {} due to {}", data, e);
254 log.debug("Boom!!!", e);
255 }
256 }
257
258 @Override
Thomas Vachuska35fa3d42015-04-30 10:11:47 -0700259 public synchronized void sendMessage(ObjectNode message) {
Thomas Vachuska3553b302015-03-07 14:49:43 -0800260 try {
261 if (connection.isOpen()) {
262 connection.sendMessage(message.toString());
Simon Huntd5b96732016-07-08 13:22:27 -0700263 log.debug("TX message: {}", message);
Thomas Vachuska3553b302015-03-07 14:49:43 -0800264 }
265 } catch (IOException e) {
266 log.warn("Unable to send message {} to GUI due to {}", message, e);
267 log.debug("Boom!!!", e);
268 }
269 }
270
Thomas Vachuskab6acc7b2015-03-11 09:11:21 -0700271 @Override
Simon Huntc5368182017-01-10 13:32:04 -0800272 public synchronized void sendMessage(String type, ObjectNode payload) {
Simon Huntd6d3ad32017-06-21 15:27:06 -0700273 ObjectNode message = objectNode();
Simon Hunt7715e892016-04-12 19:55:32 -0700274 message.put(EVENT, type);
Simon Huntd6d3ad32017-06-21 15:27:06 -0700275 message.set(PAYLOAD, payload != null ? payload : objectNode());
Thomas Vachuskab6acc7b2015-03-11 09:11:21 -0700276 sendMessage(message);
Thomas Vachuskab6acc7b2015-03-11 09:11:21 -0700277 }
278
Thomas Vachuska3553b302015-03-07 14:49:43 -0800279 // Creates new message handlers.
Simon Hunte05cae42015-07-23 17:35:24 -0700280 private synchronized void createHandlersAndOverlays() {
Simon Hunt7715e892016-04-12 19:55:32 -0700281 log.debug("Creating handlers and overlays...");
Thomas Vachuska3553b302015-03-07 14:49:43 -0800282 handlers = new HashMap<>();
Simon Hunte05cae42015-07-23 17:35:24 -0700283 overlayCache = new TopoOverlayCache();
Simon Hunt22c35df2017-04-26 17:28:42 -0700284 overlay2Cache = new Topo2OverlayCache();
Simon Hunte05cae42015-07-23 17:35:24 -0700285
Simon Hunt2d7cd6f2017-05-04 13:04:50 -0700286 Map<Class<?>, UiMessageHandler> handlerInstances = new HashMap<>();
287
Thomas Vachuska3553b302015-03-07 14:49:43 -0800288 UiExtensionService service = directory.get(UiExtensionService.class);
Thomas Vachuska329af532015-03-10 02:08:33 -0700289 service.getExtensions().forEach(ext -> {
290 UiMessageHandlerFactory factory = ext.messageHandlerFactory();
291 if (factory != null) {
292 factory.newHandlers().forEach(handler -> {
Thomas Vachuskac4178cc2015-12-10 11:43:32 -0800293 try {
294 handler.init(this, directory);
295 handler.messageTypes().forEach(type -> handlers.put(type, handler));
Simon Hunt2d7cd6f2017-05-04 13:04:50 -0700296 handlerInstances.put(handler.getClass(), handler);
Simon Hunte05cae42015-07-23 17:35:24 -0700297
Thomas Vachuskac4178cc2015-12-10 11:43:32 -0800298 } catch (Exception e) {
299 log.warn("Unable to setup handler {} due to", handler, e);
Simon Hunte05cae42015-07-23 17:35:24 -0700300 }
Thomas Vachuska329af532015-03-10 02:08:33 -0700301 });
302 }
Simon Hunte05cae42015-07-23 17:35:24 -0700303
Simon Hunt2d7cd6f2017-05-04 13:04:50 -0700304 registerOverlays(ext);
Thomas Vachuska329af532015-03-10 02:08:33 -0700305 });
Simon Hunt2d7cd6f2017-05-04 13:04:50 -0700306
307 handlerCrossConnects(handlerInstances);
308
309 log.debug("#handlers = {}, #overlays = {}", handlers.size(), overlayCache.size());
310 }
311
Simon Hunt1169c952017-06-05 11:20:11 -0700312 private void authenticate(String type, ObjectNode message) {
313 if (!AUTHENTICATION.equals(type)) {
314 log.warn("Non-Authenticated Web Socket: {}", message);
315 return;
316 }
317
318 String tokstr = message.path(PAYLOAD).path(TOKEN).asText(UNKNOWN);
319 UiSessionToken token = new UiSessionToken(tokstr);
320
321 if (tokenService().isTokenValid(token)) {
322 sessionToken = token;
323 log.info("Session token authenticated");
324 log.debug("WebSocket authenticated: {}", message);
325 } else {
326 log.warn("Invalid Authentication Token: {}", message);
327 sendMessage(ERROR, notAuthorized(token));
328 }
329 }
330
331 private ObjectNode notAuthorized(UiSessionToken token) {
Simon Huntd6d3ad32017-06-21 15:27:06 -0700332 return objectNode()
Simon Hunt1169c952017-06-05 11:20:11 -0700333 .put("message", "invalid authentication token")
334 .put("badToken", token.toString());
335 }
336
Simon Hunt2d7cd6f2017-05-04 13:04:50 -0700337 private void registerOverlays(UiExtension ext) {
338 UiTopoOverlayFactory overlayFactory = ext.topoOverlayFactory();
339 if (overlayFactory != null) {
340 overlayFactory.newOverlays().forEach(overlayCache::add);
341 }
342
343 UiTopo2OverlayFactory overlay2Factory = ext.topo2OverlayFactory();
344 if (overlay2Factory != null) {
345 overlay2Factory.newOverlays().forEach(overlay2Cache::add);
346 }
347 }
348
349 private void handlerCrossConnects(Map<Class<?>, UiMessageHandler> handlers) {
350 TopologyViewMessageHandler topomh = (TopologyViewMessageHandler)
351 handlers.get(TopologyViewMessageHandler.class);
352 if (topomh != null) {
353 topomh.setOverlayCache(overlayCache);
354 }
355
356 Topo2ViewMessageHandler topo2mh = (Topo2ViewMessageHandler)
357 handlers.get(Topo2ViewMessageHandler.class);
358 if (topo2mh != null) {
359 topo2mh.setOverlayCache(overlay2Cache);
360
361 // We also need a link to Topo2Traffic
362 Topo2TrafficMessageHandler topo2traffic = (Topo2TrafficMessageHandler)
363 handlers.get(Topo2TrafficMessageHandler.class);
364 if (topo2traffic != null) {
365 topo2mh.setTrafficHandler(topo2traffic);
366 } else {
367 log.error("No topo2 traffic handler found");
368 }
369 }
Thomas Vachuska3553b302015-03-07 14:49:43 -0800370 }
371
372 // Destroys message handlers.
Simon Hunte05cae42015-07-23 17:35:24 -0700373 private synchronized void destroyHandlersAndOverlays() {
Simon Hunt7715e892016-04-12 19:55:32 -0700374 log.debug("Destroying handlers and overlays...");
Thomas Vachuska3553b302015-03-07 14:49:43 -0800375 handlers.forEach((type, handler) -> handler.destroy());
376 handlers.clear();
Simon Hunte05cae42015-07-23 17:35:24 -0700377
378 if (overlayCache != null) {
379 overlayCache.destroy();
380 overlayCache = null;
381 }
Simon Hunte6f64612017-04-28 00:01:48 -0700382 if (overlay2Cache != null) {
383 overlay2Cache.destroy();
384 overlay2Cache = null;
385 }
Thomas Vachuska3553b302015-03-07 14:49:43 -0800386 }
Thomas Vachuskab6acc7b2015-03-11 09:11:21 -0700387
Simon Hunt7715e892016-04-12 19:55:32 -0700388 // Sends initial information (username and cluster member information)
389 // to allow GUI to display logged-in user, and to be able to
390 // fail-over to an alternate cluster member if necessary.
391 private void sendBootstrapData() {
Thomas Vachuskab6acc7b2015-03-11 09:11:21 -0700392 ClusterService service = directory.get(ClusterService.class);
Simon Huntd6d3ad32017-06-21 15:27:06 -0700393 ArrayNode instances = arrayNode();
Thomas Vachuskab6acc7b2015-03-11 09:11:21 -0700394
395 for (ControllerNode node : service.getNodes()) {
Simon Huntd6d3ad32017-06-21 15:27:06 -0700396 ObjectNode instance = objectNode()
Simon Hunt7715e892016-04-12 19:55:32 -0700397 .put(ID, node.id().toString())
398 .put(IP, node.ip().toString())
Simon Hunt8add9ee2016-09-20 17:05:07 -0700399 .put(GlyphConstants.UI_ATTACHED,
Simon Hunt22c35df2017-04-26 17:28:42 -0700400 node.equals(service.getLocalNode()));
Thomas Vachuskab6acc7b2015-03-11 09:11:21 -0700401 instances.add(instance);
402 }
403
Simon Huntd6d3ad32017-06-21 15:27:06 -0700404 ObjectNode payload = objectNode();
Simon Hunt7715e892016-04-12 19:55:32 -0700405 payload.set(CLUSTER_NODES, instances);
406 payload.put(USER, userName);
Simon Huntc5368182017-01-10 13:32:04 -0800407 sendMessage(BOOTSTRAP, payload);
Thomas Vachuskab6acc7b2015-03-11 09:11:21 -0700408 }
409
Simon Hunt1169c952017-06-05 11:20:11 -0700410 private UiTokenService tokenService() {
411 UiTokenService service = directory.get(UiTokenService.class);
412 if (service == null) {
413 log.error("Unable to reference UiTokenService");
414 }
415 return service;
416 }
Simon Huntd6d3ad32017-06-21 15:27:06 -0700417
418 // sends the collated localization bundle data up to the client.
419 private void sendUberLionBundle() {
420 UiExtensionService service = directory.get(UiExtensionService.class);
421 ObjectNode lion = objectNode();
422
423 service.getExtensions().forEach(ext -> {
424 ext.lionBundles().forEach(lb -> {
425 ObjectNode lionMap = objectNode();
426 lb.getItems().forEach(item -> {
427 lionMap.put(item.key(), item.value());
428 });
429 lion.set(lb.id(), lionMap);
430 });
431 });
432
433 ObjectNode payload = objectNode();
434 payload.set(LION, lion);
435 sendMessage(UBERLION, payload);
436 }
Thomas Vachuska3553b302015-03-07 14:49:43 -0800437}