use of org.cometd.bayeux.server.BayeuxContext in project ddf by codice.
the class SearchService method processQuery.
/**
* Service method called by Cometd when something arrives on the service channel
*
* @param remote
* - Client session
* @param message
* - JSON message
*/
@Listener("/service/query")
public void processQuery(final ServerSession remote, Message message) {
ServerMessage.Mutable reply = new ServerMessageImpl();
Map<String, Object> queryMessage = message.getDataAsMap();
if (queryMessage != null && queryMessage.containsKey(Search.ID)) {
bayeux.createChannelIfAbsent("/" + queryMessage.get(Search.ID), new ConfigurableServerChannel.Initializer() {
public void configureChannel(ConfigurableServerChannel channel) {
channel.setPersistent(true);
}
});
BayeuxContext context = bayeux.getContext();
Subject subject = null;
if (context != null) {
subject = (Subject) context.getRequestAttribute(SecurityConstants.SECURITY_SUBJECT);
}
// kick off the query
executeQuery(queryMessage, subject);
reply.put(Search.SUCCESSFUL, true);
remote.deliver(serverSession, reply);
} else {
reply.put(Search.SUCCESSFUL, false);
reply.put("status", "ERROR: unable to return results, no id in query request");
remote.deliver(serverSession, reply);
}
}
Aggregations