From 3960e9f61a53d930697cd2e6166b1adb15bf19a1 Mon Sep 17 00:00:00 2001 From: randomdan Date: Wed, 12 Mar 2014 22:57:57 +0000 Subject: Expose more of the interface Gracefully handle not found problems --- p2pvr/ice/p2pvr.ice | 18 +++++++++++++++--- p2pvr/lib/schedules.cpp | 1 + p2pvr/lib/si.cpp | 2 ++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/p2pvr/ice/p2pvr.ice b/p2pvr/ice/p2pvr.ice index 61c0e32..bd79cb1 100644 --- a/p2pvr/ice/p2pvr.ice +++ b/p2pvr/ice/p2pvr.ice @@ -6,7 +6,11 @@ #include "dvbsi.ice" module P2PVR { + ["project2:type"] + exception NotFound { }; + // Something that we have recorded. + ["project2:type"] class Recording { int RecordingId; string StorageAddress; @@ -21,6 +25,7 @@ module P2PVR { sequence RecordingList; // Something that defines what we would like to record. + ["project2:type"] class Schedule { int ScheduleId; optional(1) int ServiceId; @@ -35,6 +40,7 @@ module P2PVR { sequence ScheduleList; // Ids for something to record + ["project2:type"] class ScheduledToRecord { int ScheduleId; int ServiceId; @@ -51,6 +57,7 @@ module P2PVR { idempotent void UpdateEvents(short type); }; + ["project2:type"] exception StorageException { string path; string message; @@ -67,14 +74,18 @@ module P2PVR { idempotent int NewRecording(Recording rec); ["project2:task"] idempotent void DeleteRecording(int recordingId); + ["project2:rows"] idempotent RecordingList GetRecordings(); }; interface Schedules { ["project2:task"] idempotent void DeleteSchedule(int scheduleId); - idempotent Schedule GetSchedule(int scheduleId); + ["project2:rows"] + idempotent Schedule GetSchedule(int scheduleId) throws NotFound; + ["project2:rows"] idempotent ScheduleList GetSchedules(); + ["project2:rows"] idempotent ScheduledToRecordList GetScheduledToRecord(); idempotent int UpdateSchedule(Schedule newSchedule); ["project2:task"] @@ -92,10 +103,10 @@ module P2PVR { ["project2:rows"] idempotent DVBSI::ServiceList GetServices(); ["project2:rows"] - idempotent DVBSI::Service GetService(int id); + idempotent DVBSI::Service GetService(int id) throws NotFound; // Get events ["project2:rows"] - idempotent DVBSI::Event GetEvent(int serviceId, int eventId); + idempotent DVBSI::Event GetEvent(int serviceId, int eventId) throws NotFound; ["project2:rows"] idempotent DVBSI::Events EventsOnNow(); ["project2:rows"] @@ -103,6 +114,7 @@ module P2PVR { }; interface Recorder { + ["project2:task"] idempotent void RefreshSchedules(); }; }; diff --git a/p2pvr/lib/schedules.cpp b/p2pvr/lib/schedules.cpp index d13b231..99d4983 100644 --- a/p2pvr/lib/schedules.cpp +++ b/p2pvr/lib/schedules.cpp @@ -452,6 +452,7 @@ Schedules::GetSchedule(int id, const Ice::Current &) P2PVR::ScheduleList schedules; SqlContainerCreator cct(schedules); cct.populate(Select(Schedules_selectById, id).second); + if (schedules.empty()) throw P2PVR::NotFound(); return schedules.front(); } diff --git a/p2pvr/lib/si.cpp b/p2pvr/lib/si.cpp index 5640fe8..b358f72 100644 --- a/p2pvr/lib/si.cpp +++ b/p2pvr/lib/si.cpp @@ -93,6 +93,7 @@ SI::GetService(int id, const Ice::Current&) DVBSI::ServiceList rtn; SqlContainerCreator cc(rtn); cc.populate(Select(SI_servicesSelectById, id).second); + if (rtn.empty()) throw P2PVR::NotFound(); return rtn.front(); } @@ -102,6 +103,7 @@ SI::GetEvent(int serviceId, int eventId, const Ice::Current &) DVBSI::Events rtn; SqlContainerCreator cc(rtn); cc.populate(Select(SI_eventById, serviceId, eventId).second); + if (rtn.empty()) throw P2PVR::NotFound(); return rtn.front(); } -- cgit v1.2.3