Outlook Cal Sync Token revocation error

Added code to manage and let user know
that token was revoked on Outlook cal Sync

Change-Id: I16ba807cbfebb9ef63bb799489cb1f2b1bdfd22c
This commit is contained in:
Sebastian Marcet 2018-06-04 10:36:53 -07:00
parent cb0d0c2618
commit d9b79b3bac

View File

@ -11,6 +11,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
**/ **/
use App\Services\Apis\CalendarSync\Exceptions\RevokedAccessException;
use models\summit\CalendarSync\CalendarSyncInfo; use models\summit\CalendarSync\CalendarSyncInfo;
use models\summit\CalendarSync\CalendarSyncInfoOAuth2; use models\summit\CalendarSync\CalendarSyncInfoOAuth2;
use models\summit\CalendarSync\ScheduleCalendarSyncInfo; use models\summit\CalendarSync\ScheduleCalendarSyncInfo;
@ -145,6 +146,7 @@ final class OutlookCalendarSyncRemoteFacade
/** /**
* @param MemberEventScheduleSummitActionSyncWorkRequest $request * @param MemberEventScheduleSummitActionSyncWorkRequest $request
* @return ScheduleCalendarSyncInfo * @return ScheduleCalendarSyncInfo
* @throws RevokedAccessException
*/ */
public function addEvent(MemberEventScheduleSummitActionSyncWorkRequest $request) public function addEvent(MemberEventScheduleSummitActionSyncWorkRequest $request)
{ {
@ -166,6 +168,10 @@ final class OutlookCalendarSyncRemoteFacade
$sync_info->setLocationId($summit_event->getLocationId()); $sync_info->setLocationId($summit_event->getLocationId());
return $sync_info; return $sync_info;
} }
catch (LogicException $ex1){
Log::warning($ex1);
throw new RevokedAccessException($ex1->getMessage());
}
catch (Exception $ex){ catch (Exception $ex){
Log::error($ex); Log::error($ex);
return null; return null;
@ -176,6 +182,7 @@ final class OutlookCalendarSyncRemoteFacade
* @param MemberEventScheduleSummitActionSyncWorkRequest $request * @param MemberEventScheduleSummitActionSyncWorkRequest $request
* @param ScheduleCalendarSyncInfo $schedule_sync_info * @param ScheduleCalendarSyncInfo $schedule_sync_info
* @return bool * @return bool
* @throws RevokedAccessException
*/ */
public function deleteEvent public function deleteEvent
( (
@ -187,6 +194,10 @@ final class OutlookCalendarSyncRemoteFacade
$res = $this->client->deleteEvent($schedule_sync_info->getExternalId()); $res = $this->client->deleteEvent($schedule_sync_info->getExternalId());
return !($res instanceof ErrorResponse); return !($res instanceof ErrorResponse);
} }
catch (LogicException $ex1){
Log::warning($ex1);
throw new RevokedAccessException($ex1->getMessage());
}
catch (Exception $ex){ catch (Exception $ex){
Log::error($ex); Log::error($ex);
return false; return false;
@ -197,6 +208,7 @@ final class OutlookCalendarSyncRemoteFacade
* @param MemberEventScheduleSummitActionSyncWorkRequest $request * @param MemberEventScheduleSummitActionSyncWorkRequest $request
* @param ScheduleCalendarSyncInfo $schedule_sync_info * @param ScheduleCalendarSyncInfo $schedule_sync_info
* @return bool * @return bool
* @throws RevokedAccessException
*/ */
public function updateEvent public function updateEvent
( (
@ -216,6 +228,10 @@ final class OutlookCalendarSyncRemoteFacade
$schedule_sync_info->setLocationId($summit_event->getLocationId()); $schedule_sync_info->setLocationId($summit_event->getLocationId());
return true; return true;
} }
catch (LogicException $ex1){
Log::warning($ex1);
throw new RevokedAccessException($ex1->getMessage());
}
catch (Exception $ex){ catch (Exception $ex){
Log::error($ex); Log::error($ex);
return false; return false;