@POST @Path("/monitoring/check-for-updates") public void execute(@FormParam("clientId") String clientId, @FormParam("trackId") String trackId) throws Exception { Monitoring monitoring = MonitoringManager.load(clientId, trackId); if (monitoring != null) { Date date = new Date(); Tracking tracking = TrackingManager.search(monitoring.getTrackId()); String hash = tracking != null ? tracking.getHash() : null; if (hash != null && (monitoring.getHash() == null || !monitoring.getHash().equals(hash))) { monitoring.setHash(hash); monitoring.setUpdated(date); monitoring.setUnread(true); if (tracking.isCompleted()) { monitoring.setCompleted(date); } MonitoringPersistence.update(monitoring); NotificationManager.send(monitoring, tracking); } } }
@GET @Path("/monitoring/check-for-updates") public void execute() throws Exception { TaskOptions taskOptions; Queue queue = QueueFactory.getQueue("monitoring"); for (Monitoring monitoring : MonitoringManager.findAll()) { if (!monitoring.isCompleted()) { taskOptions = Builder.withUrl("/admin/monitoring/check-for-updates"); taskOptions = taskOptions.param("clientId", monitoring.getClientId()); taskOptions = taskOptions.param("trackId", monitoring.getTrackId()); taskOptions.method(POST); queue.add(taskOptions); } } }