}
@Override
public void handleLongPoll(LongPollData data, Map<String, Object> response, User user) {
if (data.getRequest().hasHandler(key) && user != null) {
LongPollState state = data.getState();
List<WatchListState> watchListStates = WatchListCommon.getWatchListStates(data);
synchronized (state) {
List<WatchListState> newStates = watchListDwr.getPointData();
List<WatchListState> differentStates = new ArrayList<WatchListState>();
for (WatchListState newState : newStates) {
WatchListState oldState = getWatchListState(newState.getId(), watchListStates);
if (oldState == null)
differentStates.add(newState);
else {
WatchListState copy = newState.clone();
copy.removeEqualValue(oldState);
if (!copy.isEmpty())
differentStates.add(copy);
}
}
if (!differentStates.isEmpty()) {
response.put("watchListStates", differentStates);
state.setAttribute("watchListStates", newStates);
}
}
}
}