use of org.onebusaway.api.services.AlarmDetails in project onebusaway-application-modules by camsys.
the class AlarmServiceImpl method fireAlarm.
@Override
public void fireAlarm(String alarmId) {
AlarmDetails details = _alarmsById.remove(alarmId);
if (details == null)
return;
if (details instanceof ApnsAlarmDetails) {
ApnsAlarmDetails apnsDetails = (ApnsAlarmDetails) details;
JSONObject data = getDataAsJson(apnsDetails.getData());
String payload = getDataAsApnsPayload(alarmId, data);
boolean isProduction = isProduction(data);
for (ApplePushNotificationService service : _applePushNotificationServices) {
if (service.isProduction() == isProduction) {
service.pushNotification(apnsDetails.getDeviceToken(), payload);
return;
}
}
_log.warn("no appropriate ApplePushNotificationService found for alarm: production=" + isProduction);
}
}
use of org.onebusaway.api.services.AlarmDetails in project onebusaway-application-modules by camsys.
the class RegisterAlarmForArrivalAndDepartureAtStopAction method show.
public DefaultHttpHeaders show() throws ServiceException {
if (hasErrors())
return setValidationErrorsResponse();
if (_query.getTime() == 0)
_query.setTime(SystemTime.currentTimeMillis());
AlarmDetails details = _alarmService.alterAlarmQuery(_alarm, _data);
String alarmId = _service.registerAlarmForArrivalAndDepartureAtStop(_query, _alarm);
if (alarmId == null)
return setResourceNotFoundResponse();
if (details != null) {
_alarmService.registerAlarm(alarmId, details);
}
if (isVersion(V2)) {
RegisteredAlarmV2Bean bean = new RegisteredAlarmV2Bean();
bean.setAlarmId(alarmId);
BeanFactoryV2 factory = getBeanFactoryV2();
return setOkResponse(factory.entry(bean));
} else {
return setUnknownVersionResponse();
}
}
Aggregations