}
@Override
public void processMessage(WebSocketMessage webSocketData) {
final App app = StructrApp.getInstance(getWebSocket().getSecurityContext());
final String id = webSocketData.getId();
final Map<String, Object> nodeData = webSocketData.getNodeData();
final String source = (String) nodeData.get("source");
final String name = (String) nodeData.get("name");
// check for ID
if (id == null) {
getWebSocket().send(MessageBuilder.status().code(422).message("Cannot create widget without id").build(), true);
return;
}
// check if parent node with given ID exists
DOMNode node = getDOMNode(id);
if (node == null) {
getWebSocket().send(MessageBuilder.status().code(404).message("Node not found").build(), true);
return;
}
try {
// convertFromInput
PropertyMap properties = new PropertyMap();
properties.put(AbstractNode.type, Widget.class.getSimpleName());
properties.put(AbstractNode.name, name);
properties.put(Widget.source, source);
app.create(Widget.class, properties);
} catch (Throwable t) {
logger.log(Level.WARNING, t.toString());