CAlDav 409 error handling
Added code to handle 409 error ( non existent parent) on caldav Change-Id: I66e31518ec991ddbf9031d98dca0f04c755432fd
This commit is contained in:
parent
b08fd3c4fa
commit
cb0d0c2618
@ -11,30 +11,14 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
use App\Services\Apis\CalendarSync\ICalendarSyncRemoteFacadeFactory;
|
||||
use models\summit\CalendarSync\CalendarSyncInfo;
|
||||
|
||||
/**
|
||||
* Class CalendarSyncRemoteFacadeFactory
|
||||
* @package services\apis\CalendarSync
|
||||
*/
|
||||
final class CalendarSyncRemoteFacadeFactory
|
||||
final class CalendarSyncRemoteFacadeFactory implements ICalendarSyncRemoteFacadeFactory
|
||||
{
|
||||
private function __construct(){}
|
||||
|
||||
private function __clone(){}
|
||||
|
||||
private static $instance = null;
|
||||
|
||||
/**
|
||||
* @return CalendarSyncRemoteFacadeFactory
|
||||
*/
|
||||
public static function getInstance(){
|
||||
if(self::$instance == null)
|
||||
self::$instance = new CalendarSyncRemoteFacadeFactory();
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CalendarSyncInfo $sync_calendar_info
|
||||
* @return ICalendarSyncRemoteFacade|null
|
||||
|
@ -0,0 +1,27 @@
|
||||
<?php namespace App\Services\Apis\CalendarSync;
|
||||
/**
|
||||
* Copyright 2018 OpenStack Foundation
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
use models\summit\CalendarSync\CalendarSyncInfo;
|
||||
use services\apis\CalendarSync\ICalendarSyncRemoteFacade;
|
||||
/**
|
||||
* Interface ICalendarSyncRemoteFacadeFactory
|
||||
* @package App\Services\Apis\CalendarSync
|
||||
*/
|
||||
interface ICalendarSyncRemoteFacadeFactory
|
||||
{
|
||||
/**
|
||||
* @param CalendarSyncInfo $sync_calendar_info
|
||||
* @return ICalendarSyncRemoteFacade|null
|
||||
*/
|
||||
public function build(CalendarSyncInfo $sync_calendar_info);
|
||||
}
|
@ -13,6 +13,7 @@
|
||||
**/
|
||||
use App\Services\Apis\CalendarSync\Exceptions\RevokedAccessException;
|
||||
use CalDAVClient\Facade\CalDavClient;
|
||||
use CalDAVClient\Facade\Exceptions\ConflictException;
|
||||
use CalDAVClient\Facade\Exceptions\ForbiddenException;
|
||||
use CalDAVClient\Facade\Exceptions\UserUnAuthorizedException;
|
||||
use CalDAVClient\Facade\Requests\EventRequestVO;
|
||||
@ -29,7 +30,6 @@ use models\summit\SummitVenueRoom;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Class ICloudCalendarSyncRemoteFacade
|
||||
* @package services\apis\CalendarSync
|
||||
@ -37,6 +37,8 @@ use Exception;
|
||||
final class ICloudCalendarSyncRemoteFacade
|
||||
extends AbstractCalendarSyncRemoteFacade
|
||||
{
|
||||
const NonExistParentConflict = 'non-existent parent';
|
||||
|
||||
/**
|
||||
* @var ICalDavClient
|
||||
*/
|
||||
@ -139,6 +141,7 @@ final class ICloudCalendarSyncRemoteFacade
|
||||
* @param MemberEventScheduleSummitActionSyncWorkRequest $request
|
||||
* @return ScheduleCalendarSyncInfo|null
|
||||
* @throws RevokedAccessException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function addEvent(MemberEventScheduleSummitActionSyncWorkRequest $request)
|
||||
{
|
||||
@ -175,6 +178,11 @@ final class ICloudCalendarSyncRemoteFacade
|
||||
Log::warning($ex1);
|
||||
throw new RevokedAccessException($ex1->getMessage());
|
||||
}
|
||||
catch (ConflictException $ex2){
|
||||
Log::warning($ex2);
|
||||
if(strpos($ex2->getMessage(), self::NonExistParentConflict) != false)
|
||||
throw new RevokedAccessException($ex2->getMessage());
|
||||
}
|
||||
catch (Exception $ex){
|
||||
Log::error($ex);
|
||||
return null;
|
||||
@ -186,6 +194,7 @@ final class ICloudCalendarSyncRemoteFacade
|
||||
* @param ScheduleCalendarSyncInfo $schedule_sync_info
|
||||
* @return bool
|
||||
* @throws RevokedAccessException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function updateEvent
|
||||
(
|
||||
@ -221,6 +230,11 @@ final class ICloudCalendarSyncRemoteFacade
|
||||
Log::warning($ex1);
|
||||
throw new RevokedAccessException($ex1->getMessage());
|
||||
}
|
||||
catch (ConflictException $ex2){
|
||||
Log::warning($ex2);
|
||||
if(strpos($ex2->getMessage(), self::NonExistParentConflict) != false)
|
||||
throw new RevokedAccessException($ex2->getMessage());
|
||||
}
|
||||
catch (Exception $ex){
|
||||
Log::error($ex);
|
||||
return false;
|
||||
@ -232,6 +246,7 @@ final class ICloudCalendarSyncRemoteFacade
|
||||
* @param ScheduleCalendarSyncInfo $schedule_sync_info
|
||||
* @return bool
|
||||
* @throws RevokedAccessException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function deleteEvent(MemberEventScheduleSummitActionSyncWorkRequest $request, ScheduleCalendarSyncInfo $schedule_sync_info)
|
||||
{
|
||||
@ -250,6 +265,11 @@ final class ICloudCalendarSyncRemoteFacade
|
||||
Log::warning($ex1);
|
||||
throw new RevokedAccessException($ex1->getMessage());
|
||||
}
|
||||
catch (ConflictException $ex2){
|
||||
Log::warning($ex2);
|
||||
if(strpos($ex2->getMessage(), self::NonExistParentConflict) != false)
|
||||
throw new RevokedAccessException($ex2->getMessage());
|
||||
}
|
||||
catch (Exception $ex){
|
||||
Log::error($ex);
|
||||
return false;
|
||||
@ -261,6 +281,7 @@ final class ICloudCalendarSyncRemoteFacade
|
||||
* @param CalendarSyncInfo $calendar_sync_info
|
||||
* @return bool
|
||||
* @throws RevokedAccessException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function createCalendar(MemberCalendarScheduleSummitActionSyncWorkRequest $request, CalendarSyncInfo $calendar_sync_info)
|
||||
{
|
||||
@ -324,6 +345,7 @@ final class ICloudCalendarSyncRemoteFacade
|
||||
* @param CalendarSyncInfo $calendar_sync_info
|
||||
* @return bool
|
||||
* @throws RevokedAccessException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function deleteCalendar(MemberCalendarScheduleSummitActionSyncWorkRequest $request, CalendarSyncInfo $calendar_sync_info)
|
||||
{
|
||||
|
@ -13,24 +13,24 @@
|
||||
**/
|
||||
use App\Services\Apis\CalendarSync\Exceptions\RateLimitExceededException;
|
||||
use App\Services\Apis\CalendarSync\Exceptions\RevokedAccessException;
|
||||
use App\Services\Apis\CalendarSync\ICalendarSyncRemoteFacadeFactory;
|
||||
use CalDAVClient\Facade\Exceptions\ConflictException;
|
||||
use CalDAVClient\Facade\Exceptions\ForbiddenException;
|
||||
use CalDAVClient\Facade\Exceptions\NotFoundResourceException;
|
||||
use CalDAVClient\Facade\Exceptions\ServerErrorException;
|
||||
use CalDAVClient\Facade\Exceptions\UserUnAuthorizedException;
|
||||
use models\main\CalendarSyncErrorEmailRequest;
|
||||
use models\main\IEmailCreationRequestRepository;
|
||||
use models\summit\CalendarSync\CalendarSyncInfo;
|
||||
use models\summit\CalendarSync\WorkQueue\AbstractCalendarSyncWorkRequest;
|
||||
use models\summit\CalendarSync\WorkQueue\MemberCalendarScheduleSummitActionSyncWorkRequest;
|
||||
use models\summit\CalendarSync\WorkQueue\MemberEventScheduleSummitActionSyncWorkRequest;
|
||||
use models\summit\CalendarSync\WorkQueue\MemberScheduleSummitActionSyncWorkRequest;
|
||||
use models\summit\IAbstractCalendarSyncWorkRequestRepository;
|
||||
use models\summit\ICalendarSyncInfoRepository;
|
||||
use services\apis\CalendarSync\CalendarSyncRemoteFacadeFactory;
|
||||
use utils\PagingInfo;
|
||||
use libs\utils\ITransactionService;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Class MemberActionsCalendarSyncProcessingService
|
||||
* @package App\Services\Model
|
||||
@ -38,7 +38,6 @@ use Exception;
|
||||
final class MemberActionsCalendarSyncProcessingService
|
||||
implements IMemberActionsCalendarSyncProcessingService
|
||||
{
|
||||
|
||||
const FailedAddSummitEventTxFileFormatName = '/tmp/failed_insert_member_%s_calendar_%s_summit_event_%s.json';
|
||||
/**
|
||||
* @var IAbstractCalendarSyncWorkRequestRepository
|
||||
@ -65,12 +64,18 @@ implements IMemberActionsCalendarSyncProcessingService
|
||||
*/
|
||||
private $email_creation_request_repository;
|
||||
|
||||
/**
|
||||
* @var ICalendarSyncRemoteFacadeFactory
|
||||
*/
|
||||
private $facade_factory;
|
||||
|
||||
/**
|
||||
* MemberActionsCalendarSyncProcessingService constructor.
|
||||
* @param IAbstractCalendarSyncWorkRequestRepository $work_request_repository
|
||||
* @param ICalendarSyncInfoRepository $calendar_sync_repository
|
||||
* @param IEmailCreationRequestRepository $email_creation_request_repository
|
||||
* @param ICalendarSyncWorkRequestPreProcessor $preprocessor_requests
|
||||
* @param ICalendarSyncRemoteFacadeFactory $facade_factory
|
||||
* @param ITransactionService $tx_manager
|
||||
*/
|
||||
public function __construct
|
||||
@ -79,6 +84,7 @@ implements IMemberActionsCalendarSyncProcessingService
|
||||
ICalendarSyncInfoRepository $calendar_sync_repository,
|
||||
IEmailCreationRequestRepository $email_creation_request_repository,
|
||||
ICalendarSyncWorkRequestPreProcessor $preprocessor_requests,
|
||||
ICalendarSyncRemoteFacadeFactory $facade_factory,
|
||||
ITransactionService $tx_manager
|
||||
)
|
||||
{
|
||||
@ -86,14 +92,28 @@ implements IMemberActionsCalendarSyncProcessingService
|
||||
$this->calendar_sync_repository = $calendar_sync_repository;
|
||||
$this->email_creation_request_repository = $email_creation_request_repository;
|
||||
$this->preprocessor_requests = $preprocessor_requests;
|
||||
$this->facade_factory = $facade_factory;
|
||||
$this->tx_manager = $tx_manager;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param CalendarSyncInfo|null $calendar_sync_info
|
||||
*/
|
||||
private function sendReSyncCalendarEmail(CalendarSyncInfo $calendar_sync_info){
|
||||
if(!is_null($calendar_sync_info) && !$calendar_sync_info->isRevoked()){
|
||||
// revoke it ...
|
||||
$calendar_sync_info->setRevoked(true);
|
||||
// create email request
|
||||
$email_request = new CalendarSyncErrorEmailRequest();
|
||||
$email_request->setSyncInfo($calendar_sync_info);
|
||||
$this->email_creation_request_repository->add($email_request);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @param string $provider
|
||||
* @param int $batch_size
|
||||
* @return int
|
||||
* @return int|mixed
|
||||
* @throws Exception
|
||||
*/
|
||||
public function processActions($provider = 'ALL', $batch_size = 1000)
|
||||
{
|
||||
@ -105,6 +125,7 @@ implements IMemberActionsCalendarSyncProcessingService
|
||||
$provider,
|
||||
new PagingInfo(1, $batch_size)
|
||||
);
|
||||
|
||||
$requests = $this->preprocessor_requests->preProcessActions($res->getItems());
|
||||
log::info(sprintf("provider %s got %s request to process ...", $provider, count($requests)));
|
||||
|
||||
@ -113,7 +134,7 @@ implements IMemberActionsCalendarSyncProcessingService
|
||||
log::debug(sprintf("iteration # %s", $count+1));
|
||||
if (!$request instanceof MemberScheduleSummitActionSyncWorkRequest) continue;
|
||||
$calendar_sync_info = $request->getCalendarSyncInfo();
|
||||
$remote_facade = CalendarSyncRemoteFacadeFactory::getInstance()->build($calendar_sync_info);
|
||||
$remote_facade = $this->facade_factory->build($calendar_sync_info);
|
||||
if (is_null($remote_facade)) continue;
|
||||
$member = $request->getOwner();
|
||||
$request_type = $request->getType();
|
||||
@ -128,7 +149,7 @@ implements IMemberActionsCalendarSyncProcessingService
|
||||
$request_type,
|
||||
$member->getIdentifier(),
|
||||
$calendar_sync_info->getId(),
|
||||
$calendar_sync_info->isRevoked()? 1:0
|
||||
$calendar_sync_info->isRevoked()? 1 : 0
|
||||
));
|
||||
|
||||
switch ($request_sub_type) {
|
||||
@ -228,28 +249,20 @@ implements IMemberActionsCalendarSyncProcessingService
|
||||
}
|
||||
catch(RevokedAccessException $ex2){
|
||||
Log::warning($ex2);
|
||||
|
||||
if(!is_null($calendar_sync_info) && !$calendar_sync_info->isRevoked()){
|
||||
// revoke it ...
|
||||
$calendar_sync_info->setRevoked(true);
|
||||
// create email request
|
||||
$email_request = new CalendarSyncErrorEmailRequest();
|
||||
$email_request->setSyncInfo($calendar_sync_info);
|
||||
$this->email_creation_request_repository->add($email_request);
|
||||
}
|
||||
$this->sendReSyncCalendarEmail($calendar_sync_info);
|
||||
}
|
||||
catch(NotFoundResourceException $ex3){
|
||||
Log::error($ex3);
|
||||
Log::warning($ex3);
|
||||
}
|
||||
catch(ServerErrorException $ex4){
|
||||
Log::error($ex4);
|
||||
catch(ServerErrorException $ex5){
|
||||
Log::error($ex5);
|
||||
}
|
||||
catch (RateLimitExceededException $ex5){
|
||||
Log::critical($ex5);
|
||||
catch (RateLimitExceededException $ex6){
|
||||
Log::critical($ex6);
|
||||
break;
|
||||
}
|
||||
catch(Exception $ex6){
|
||||
Log::error($ex6);
|
||||
catch(Exception $ex7){
|
||||
Log::error($ex7);
|
||||
}
|
||||
}
|
||||
return $count;
|
||||
|
@ -11,6 +11,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
use App\Services\Apis\CalendarSync\ICalendarSyncRemoteFacadeFactory;
|
||||
use App\Services\Apis\GoogleGeoCodingAPI;
|
||||
use App\Services\Apis\IGeoCodingAPI;
|
||||
use App\Services\Model\AttendeeService;
|
||||
@ -39,6 +40,7 @@ use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use ModelSerializers\BaseSerializerTypeSelector;
|
||||
use ModelSerializers\ISerializerTypeSelector;
|
||||
use services\apis\CalendarSync\CalendarSyncRemoteFacadeFactory;
|
||||
use services\apis\EventbriteAPI;
|
||||
use services\apis\FireBaseGCMApi;
|
||||
use services\apis\IEventbriteAPI;
|
||||
@ -114,6 +116,12 @@ final class ServicesProvider extends ServiceProvider
|
||||
AttendeeService::class
|
||||
);
|
||||
|
||||
App::singleton
|
||||
(
|
||||
ICalendarSyncRemoteFacadeFactory::class,
|
||||
CalendarSyncRemoteFacadeFactory::class
|
||||
);
|
||||
|
||||
// work request pre processors
|
||||
|
||||
App::singleton
|
||||
@ -130,7 +138,6 @@ final class ServicesProvider extends ServiceProvider
|
||||
->needs('App\Services\Model\ICalendarSyncWorkRequestQueueManager')
|
||||
->give('App\Services\Model\AdminScheduleWorkQueueManager');
|
||||
|
||||
|
||||
// work request process services
|
||||
|
||||
App::when('App\Services\Model\MemberActionsCalendarSyncProcessingService')
|
||||
|
@ -18,7 +18,7 @@
|
||||
"cocur/slugify": "^2.3",
|
||||
"guzzlehttp/guzzle": "^6.3",
|
||||
"google/apiclient": "^2.2",
|
||||
"smarcet/caldavclient": "1.1.2",
|
||||
"smarcet/caldavclient": "1.1.4",
|
||||
"smarcet/outlook-rest-client": "dev-master",
|
||||
"idct/sftp-client": "dev-master"
|
||||
},
|
||||
|
103
composer.lock
generated
103
composer.lock
generated
@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "853937ac9f7c02f94071930ac2e4a463",
|
||||
"content-hash": "89ace9898e00e4f6da81552b53a33c0f",
|
||||
"packages": [
|
||||
{
|
||||
"name": "classpreloader/classpreloader",
|
||||
@ -633,12 +633,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/doctrine/lexer.git",
|
||||
"reference": "b4f2b2fe5d5726e08a7d46fe3149b577e738463a"
|
||||
"reference": "c0970c7889bfd33504c4fa54f35451c27897381d"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/doctrine/lexer/zipball/b4f2b2fe5d5726e08a7d46fe3149b577e738463a",
|
||||
"reference": "b4f2b2fe5d5726e08a7d46fe3149b577e738463a",
|
||||
"url": "https://api.github.com/repos/doctrine/lexer/zipball/c0970c7889bfd33504c4fa54f35451c27897381d",
|
||||
"reference": "c0970c7889bfd33504c4fa54f35451c27897381d",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -682,7 +682,7 @@
|
||||
"lexer",
|
||||
"parser"
|
||||
],
|
||||
"time": "2018-04-24T03:37:48+00:00"
|
||||
"time": "2018-05-14T15:49:16+00:00"
|
||||
},
|
||||
{
|
||||
"name": "doctrine/orm",
|
||||
@ -1004,16 +1004,16 @@
|
||||
},
|
||||
{
|
||||
"name": "google/apiclient-services",
|
||||
"version": "v0.58",
|
||||
"version": "v0.61",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/google/google-api-php-client-services.git",
|
||||
"reference": "e21760a34daea7bc29e2866b62f8c8db4e91228d"
|
||||
"reference": "f7221039fda179b3f5096a6272b38706f2a6fcd0"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/google/google-api-php-client-services/zipball/e21760a34daea7bc29e2866b62f8c8db4e91228d",
|
||||
"reference": "e21760a34daea7bc29e2866b62f8c8db4e91228d",
|
||||
"url": "https://api.github.com/repos/google/google-api-php-client-services/zipball/f7221039fda179b3f5096a6272b38706f2a6fcd0",
|
||||
"reference": "f7221039fda179b3f5096a6272b38706f2a6fcd0",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -1037,7 +1037,7 @@
|
||||
"keywords": [
|
||||
"google"
|
||||
],
|
||||
"time": "2018-05-06T00:22:52+00:00"
|
||||
"time": "2018-05-26T00:23:39+00:00"
|
||||
},
|
||||
{
|
||||
"name": "google/auth",
|
||||
@ -1208,12 +1208,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/guzzle/psr7.git",
|
||||
"reference": "239912a01c502f2d8f3c642eb2fcd4e58cf82a72"
|
||||
"reference": "7fa8852adec06dabfbde1b028c4c9d9087558256"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/guzzle/psr7/zipball/239912a01c502f2d8f3c642eb2fcd4e58cf82a72",
|
||||
"reference": "239912a01c502f2d8f3c642eb2fcd4e58cf82a72",
|
||||
"url": "https://api.github.com/repos/guzzle/psr7/zipball/7fa8852adec06dabfbde1b028c4c9d9087558256",
|
||||
"reference": "7fa8852adec06dabfbde1b028c4c9d9087558256",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -1230,7 +1230,7 @@
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.4-dev"
|
||||
"dev-master": "1.5-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
@ -1266,7 +1266,7 @@
|
||||
"uri",
|
||||
"url"
|
||||
],
|
||||
"time": "2018-04-24T00:35:57+00:00"
|
||||
"time": "2018-05-27T22:46:05+00:00"
|
||||
},
|
||||
{
|
||||
"name": "idct/sftp-client",
|
||||
@ -1770,12 +1770,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/thephpleague/flysystem.git",
|
||||
"reference": "c6560c72107e9a7ef6341f35fc87d42c7b71f972"
|
||||
"reference": "454d6534e2efa6e299003e101d4f54412688e73f"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/thephpleague/flysystem/zipball/c6560c72107e9a7ef6341f35fc87d42c7b71f972",
|
||||
"reference": "c6560c72107e9a7ef6341f35fc87d42c7b71f972",
|
||||
"url": "https://api.github.com/repos/thephpleague/flysystem/zipball/454d6534e2efa6e299003e101d4f54412688e73f",
|
||||
"reference": "454d6534e2efa6e299003e101d4f54412688e73f",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -1846,7 +1846,7 @@
|
||||
"sftp",
|
||||
"storage"
|
||||
],
|
||||
"time": "2018-05-08T07:29:35+00:00"
|
||||
"time": "2018-05-28T11:40:13+00:00"
|
||||
},
|
||||
{
|
||||
"name": "league/oauth2-client",
|
||||
@ -2039,16 +2039,16 @@
|
||||
},
|
||||
{
|
||||
"name": "nesbot/carbon",
|
||||
"version": "1.27.0",
|
||||
"version": "1.29.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/briannesbitt/Carbon.git",
|
||||
"reference": "ef81c39b67200dcd7401c24363dcac05ac3a4fe9"
|
||||
"reference": "ed6aa898982f441ccc9b2acdec51490f2bc5d337"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/ef81c39b67200dcd7401c24363dcac05ac3a4fe9",
|
||||
"reference": "ef81c39b67200dcd7401c24363dcac05ac3a4fe9",
|
||||
"url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/ed6aa898982f441ccc9b2acdec51490f2bc5d337",
|
||||
"reference": "ed6aa898982f441ccc9b2acdec51490f2bc5d337",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -2083,7 +2083,7 @@
|
||||
"datetime",
|
||||
"time"
|
||||
],
|
||||
"time": "2018-04-23T09:02:57+00:00"
|
||||
"time": "2018-05-29T15:23:46+00:00"
|
||||
},
|
||||
{
|
||||
"name": "nikic/php-parser",
|
||||
@ -2190,12 +2190,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/phpseclib/phpseclib.git",
|
||||
"reference": "8c299f865f02fb1355002d32d925a343c55a840c"
|
||||
"reference": "6b275cdcd51f37d284c54a8931ef2ee6a18be825"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/8c299f865f02fb1355002d32d925a343c55a840c",
|
||||
"reference": "8c299f865f02fb1355002d32d925a343c55a840c",
|
||||
"url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/6b275cdcd51f37d284c54a8931ef2ee6a18be825",
|
||||
"reference": "6b275cdcd51f37d284c54a8931ef2ee6a18be825",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -2274,7 +2274,7 @@
|
||||
"x.509",
|
||||
"x509"
|
||||
],
|
||||
"time": "2018-04-25T20:18:51+00:00"
|
||||
"time": "2018-05-27T16:33:37+00:00"
|
||||
},
|
||||
{
|
||||
"name": "predis/predis",
|
||||
@ -2777,16 +2777,16 @@
|
||||
},
|
||||
{
|
||||
"name": "smarcet/caldavclient",
|
||||
"version": "1.1.2",
|
||||
"version": "1.1.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/smarcet/CalDAVClient.git",
|
||||
"reference": "08d1d94cf9b2b3ba363212a2e5f417625e9c2ec4"
|
||||
"reference": "d37d2403f2283f1332e8cb8d05847df3482f08a8"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/smarcet/CalDAVClient/zipball/08d1d94cf9b2b3ba363212a2e5f417625e9c2ec4",
|
||||
"reference": "08d1d94cf9b2b3ba363212a2e5f417625e9c2ec4",
|
||||
"url": "https://api.github.com/repos/smarcet/CalDAVClient/zipball/d37d2403f2283f1332e8cb8d05847df3482f08a8",
|
||||
"reference": "d37d2403f2283f1332e8cb8d05847df3482f08a8",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -2822,7 +2822,7 @@
|
||||
"icloud",
|
||||
"synchronization"
|
||||
],
|
||||
"time": "2018-05-03T21:49:20+00:00"
|
||||
"time": "2018-06-01T22:00:49+00:00"
|
||||
},
|
||||
{
|
||||
"name": "smarcet/outlook-rest-client",
|
||||
@ -3297,17 +3297,20 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/polyfill-ctype.git",
|
||||
"reference": "7cc359f1b7b80fc25ed7796be7d96adc9b354bae"
|
||||
"reference": "9d31bef82d2e9b033f335d60b96611757f98c605"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/7cc359f1b7b80fc25ed7796be7d96adc9b354bae",
|
||||
"reference": "7cc359f1b7b80fc25ed7796be7d96adc9b354bae",
|
||||
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/9d31bef82d2e9b033f335d60b96611757f98c605",
|
||||
"reference": "9d31bef82d2e9b033f335d60b96611757f98c605",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-ctype": "For best performance"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
@ -3344,7 +3347,7 @@
|
||||
"polyfill",
|
||||
"portable"
|
||||
],
|
||||
"time": "2018-04-30T19:57:29+00:00"
|
||||
"time": "2018-05-17T18:32:56+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/polyfill-mbstring",
|
||||
@ -3352,12 +3355,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/polyfill-mbstring.git",
|
||||
"reference": "3296adf6a6454a050679cde90f95350ad604b171"
|
||||
"reference": "25b83a5050c6607e2dfa814ffb15388caf7ce690"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/3296adf6a6454a050679cde90f95350ad604b171",
|
||||
"reference": "3296adf6a6454a050679cde90f95350ad604b171",
|
||||
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/25b83a5050c6607e2dfa814ffb15388caf7ce690",
|
||||
"reference": "25b83a5050c6607e2dfa814ffb15388caf7ce690",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -3403,7 +3406,7 @@
|
||||
"portable",
|
||||
"shim"
|
||||
],
|
||||
"time": "2018-04-26T10:06:28+00:00"
|
||||
"time": "2018-05-30T15:56:36+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/polyfill-php55",
|
||||
@ -4255,12 +4258,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/phpspec/prophecy.git",
|
||||
"reference": "5d4764d0b9beb04d5b36801c868cfc79a12c70a3"
|
||||
"reference": "6471ce6aa91ec03e9fdf3ca188e277104d8a7d1c"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/5d4764d0b9beb04d5b36801c868cfc79a12c70a3",
|
||||
"reference": "5d4764d0b9beb04d5b36801c868cfc79a12c70a3",
|
||||
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/6471ce6aa91ec03e9fdf3ca188e277104d8a7d1c",
|
||||
"reference": "6471ce6aa91ec03e9fdf3ca188e277104d8a7d1c",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -4272,7 +4275,7 @@
|
||||
},
|
||||
"require-dev": {
|
||||
"phpspec/phpspec": "^2.5|^3.2",
|
||||
"phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5"
|
||||
"phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5 || ^7.1"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
@ -4310,7 +4313,7 @@
|
||||
"spy",
|
||||
"stub"
|
||||
],
|
||||
"time": "2018-04-19T14:17:18+00:00"
|
||||
"time": "2018-05-09T14:00:54+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/php-code-coverage",
|
||||
@ -5230,12 +5233,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/webmozart/assert.git",
|
||||
"reference": "23bf61bc8a7cc229d7ce8689b1bf818a9e192cac"
|
||||
"reference": "53927dddf3afa2088b355188e143bba42159bf5d"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/webmozart/assert/zipball/23bf61bc8a7cc229d7ce8689b1bf818a9e192cac",
|
||||
"reference": "23bf61bc8a7cc229d7ce8689b1bf818a9e192cac",
|
||||
"url": "https://api.github.com/repos/webmozart/assert/zipball/53927dddf3afa2088b355188e143bba42159bf5d",
|
||||
"reference": "53927dddf3afa2088b355188e143bba42159bf5d",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -5272,7 +5275,7 @@
|
||||
"check",
|
||||
"validate"
|
||||
],
|
||||
"time": "2018-04-19T15:46:26+00:00"
|
||||
"time": "2018-05-29T14:25:02+00:00"
|
||||
}
|
||||
],
|
||||
"aliases": [],
|
||||
|
108
tests/SummitICloudCalendarSyncTest.php
Normal file
108
tests/SummitICloudCalendarSyncTest.php
Normal file
@ -0,0 +1,108 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2017 OpenStack Foundation
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
use App\Services\Model\MemberActionsCalendarSyncProcessingService;
|
||||
use models\summit\IAbstractCalendarSyncWorkRequestRepository;
|
||||
use models\summit\ICalendarSyncInfoRepository;
|
||||
use models\main\IEmailCreationRequestRepository;
|
||||
use App\Services\Model\ICalendarSyncWorkRequestPreProcessor;
|
||||
use App\Services\Apis\CalendarSync\ICalendarSyncRemoteFacadeFactory;
|
||||
use utils\PagingResponse;
|
||||
use models\summit\CalendarSync\WorkQueue\MemberEventScheduleSummitActionSyncWorkRequest;
|
||||
use models\summit\SummitEvent;
|
||||
use models\main\Member;
|
||||
use models\summit\CalendarSync\CalendarSyncInfo;
|
||||
use models\summit\CalendarSync\WorkQueue\AbstractCalendarSyncWorkRequest;
|
||||
use services\apis\CalendarSync\ICalendarSyncRemoteFacade;
|
||||
use CalDAVClient\Facade\Exceptions\ConflictException;
|
||||
/**
|
||||
* Class SummitICloudCalendarSyncTest
|
||||
*/
|
||||
final class SummitICloudCalendarSyncTest extends TestCase
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
protected function prepareForTests()
|
||||
{
|
||||
parent::prepareForTests();
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
Mockery::close();
|
||||
}
|
||||
|
||||
public function createApplication()
|
||||
{
|
||||
$app = parent::createApplication();
|
||||
|
||||
|
||||
$repo_mock = Mockery::mock(IAbstractCalendarSyncWorkRequestRepository::class)
|
||||
->shouldIgnoreMissing();
|
||||
|
||||
$repo_mock->shouldReceive('getUnprocessedMemberScheduleWorkRequestActionByPage')->andReturn(new PagingResponse(1, 10, 1, 1, []));
|
||||
|
||||
$app->instance(IAbstractCalendarSyncWorkRequestRepository::class, $repo_mock);
|
||||
|
||||
$repo_mock = Mockery::mock(ICalendarSyncInfoRepository::class)->shouldIgnoreMissing();
|
||||
$app->instance(ICalendarSyncInfoRepository::class, $repo_mock);
|
||||
|
||||
$values = [];
|
||||
$request = Mockery::mock(MemberEventScheduleSummitActionSyncWorkRequest::class)->shouldIgnoreMissing();
|
||||
$request->shouldReceive('getSummitEventId')->andReturn(1);
|
||||
$summit_event = Mockery::mock(SummitEvent::class)->shouldIgnoreMissing();
|
||||
$member = Mockery::mock(Member::class)->shouldIgnoreMissing();
|
||||
$calendar_sync_info = Mockery::mock(CalendarSyncInfo::class)->shouldIgnoreMissing();
|
||||
$summit_event->shouldReceive('getId')->andReturn(1);
|
||||
|
||||
$request->shouldReceive('getSummitEvent')->andReturn($summit_event);
|
||||
|
||||
$request->shouldReceive('getCalendarSyncInfo')->andReturn($calendar_sync_info);
|
||||
$request->shouldReceive('getOwner')->andReturn($member);
|
||||
$request->shouldReceive('getType')->andReturn(AbstractCalendarSyncWorkRequest::TypeAdd);
|
||||
$request->shouldReceive('getSubType')->andReturn(MemberEventScheduleSummitActionSyncWorkRequest::SubType);
|
||||
|
||||
$values[] = $request;
|
||||
|
||||
$repo_email = Mockery::mock(IEmailCreationRequestRepository::class)
|
||||
->shouldIgnoreMissing();
|
||||
$app->instance(IEmailCreationRequestRepository::class, $repo_email);
|
||||
|
||||
$processor = Mockery::mock(ICalendarSyncWorkRequestPreProcessor::class)->shouldIgnoreMissing();
|
||||
$processor->shouldReceive('preProcessActions')->andReturn($values);
|
||||
|
||||
$app->instance(ICalendarSyncWorkRequestPreProcessor::class, $processor);
|
||||
|
||||
$facade = Mockery::mock(ICalendarSyncRemoteFacade::class)->shouldIgnoreMissing();
|
||||
$message = <<<HTML
|
||||
<html><head><title>Conflict</title></head><body><h1>Conflict</h1><p>cannot
|
||||
PUT to non-existent parent</p></body></html>
|
||||
HTML;
|
||||
$error = new ConflictException($message, 409);
|
||||
$facade->shouldReceive('addEvent')->andThrow($error);
|
||||
|
||||
$factory = Mockery::mock(ICalendarSyncRemoteFacadeFactory::class)->shouldIgnoreMissing();
|
||||
$factory->shouldReceive('build')->andReturn($facade);
|
||||
$app->instance(ICalendarSyncRemoteFacadeFactory::class, $factory);
|
||||
return $app;
|
||||
}
|
||||
|
||||
public function test409ResponseFromCalDav(){
|
||||
|
||||
$service = App::make(MemberActionsCalendarSyncProcessingService::class);
|
||||
|
||||
$service->processActions(CalendarSyncInfo::ProvideriCloud, 1000);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user