diff --git a/plugins/drop_folder/admin/DropFolderConfigureAction.php b/plugins/drop_folder/admin/DropFolderConfigureAction.php index 2da7f9cfafe..1df71679e91 100644 --- a/plugins/drop_folder/admin/DropFolderConfigureAction.php +++ b/plugins/drop_folder/admin/DropFolderConfigureAction.php @@ -34,8 +34,9 @@ public function doAction(Zend_Controller_Action $action) { $partnerId = $this->_getParam('partnerId'); $dropFolderType = $this->_getParam('type'); + $postData = $request->getPost(); $dropFolderForm = $this->getDropFolderConfigure($dropFolderType, $partnerId, $dropFolderType); - $action->view->formValid = $this->processForm($dropFolderForm, $request->getPost(), $partnerId, $dropFolderId); + $action->view->formValid = $this->processForm($dropFolderForm, $postData, $partnerId, $dropFolderId); if(!is_null($dropFolderId)) { $dropFolder = $dropFolderForm->getObject("Kaltura_Client_DropFolder_Type_DropFolder", $request->getPost(), false, true); @@ -103,9 +104,7 @@ private function processForm(Form_DropFolderConfigure $form, $formData, $partner $dropFolder = $form->getObject("Kaltura_Client_DropFolder_Type_DropFolder", $formData, false, true); $this->validateConversionProfileId($dropFolder->conversionProfileId, $partnerId); - unset($dropFolder->id); - if($dropFolder->fileHandlerType === Kaltura_Client_DropFolder_Enum_DropFolderFileHandlerType::CONTENT) $dropFolder->fileNamePatterns = '*'; if (is_null($dropFolderId)) { diff --git a/plugins/drop_folder/lib/api/types/KalturaDropFolder.php b/plugins/drop_folder/lib/api/types/KalturaDropFolder.php index bd3fb58e840..00bc17efeed 100644 --- a/plugins/drop_folder/lib/api/types/KalturaDropFolder.php +++ b/plugins/drop_folder/lib/api/types/KalturaDropFolder.php @@ -65,7 +65,7 @@ class KalturaDropFolder extends KalturaObject implements IFilterable * @var int */ public $fileSizeCheckInterval; - + /** * @var KalturaDropFolderFileDeletePolicy */ @@ -213,21 +213,21 @@ public function toObject($dbObject = null, $skip = array()) { if (is_null($dbObject)) $dbObject = new DropFolder(); - $this->trimStringProperties(array ('path')); + $this->trimStringProperties(array ('path')); parent::toObject($dbObject, $skip); if ($this->fileHandlerConfig) { $dbFileHandlerConfig = $this->fileHandlerConfig->toObject(); $dbObject->setFileHandlerConfig($dbFileHandlerConfig); } - + return $dbObject; } public function doFromObject($source_object, KalturaDetachedResponseProfile $responseProfile = null) { parent::doFromObject($source_object, $responseProfile); - + if($this->shouldGet('fileHandlerConfig', $responseProfile)) { $dbFileHandlerConfig = $source_object->getFileHandlerConfig(); diff --git a/plugins/drop_folder/lib/model/DropFolder.php b/plugins/drop_folder/lib/model/DropFolder.php index b47c161bedb..e009dbc1254 100644 --- a/plugins/drop_folder/lib/model/DropFolder.php +++ b/plugins/drop_folder/lib/model/DropFolder.php @@ -19,6 +19,8 @@ class DropFolder extends BaseDropFolder implements IBaseObject const AUTO_FILE_DELETE_DAYS_DEFAULT_VALUE = 0; const FILE_SIZE_CHECK_INTERVAL_DEFAULT_VALUE = '600'; // 600 seconds = 10 minutes const FILE_NAME_PATTERNS_DEFAULT_VALUE = '*'; + const FILE_PROCESSING_GRACE_PERIOD_DEFAULT_VALUE = 10800; // 10800 seconds = 3 hours + const FILE_PROCESSING_GRACE_PERIOD_MAX_VALUE = 21600; // 21600 seconds = 6 hours const INCREMENTAL = 'incremental'; const LAST_FILE_TIMESTAMP = 'last_file_timestamp'; const METADATA_PROFILE_ID = 'metadata_profile_id'; @@ -52,8 +54,8 @@ public function preInsert(PropelPDO $con = null) if (is_null($this->getAutoFileDeleteDays())) { $this->setAutoFileDeleteDays(DropFolder::AUTO_FILE_DELETE_DAYS_DEFAULT_VALUE); - } - + } + return $ret; } diff --git a/plugins/drop_folder/services/DropFolderService.php b/plugins/drop_folder/services/DropFolderService.php index 2722f810b1c..b1ca64603f3 100644 --- a/plugins/drop_folder/services/DropFolderService.php +++ b/plugins/drop_folder/services/DropFolderService.php @@ -23,11 +23,11 @@ public function initService($serviceId, $serviceName, $actionName) /** * Allows you to add a new KalturaDropFolder object - * + * * @action add * @param KalturaDropFolder $dropFolder * @return KalturaDropFolder - * + * * @throws KalturaErrors::PROPERTY_VALIDATION_CANNOT_BE_NULL * @throws KalturaErrors::INGESTION_PROFILE_ID_NOT_FOUND * @throws KalturaDropFolderErrors::DROP_FOLDER_ALREADY_EXISTS @@ -46,25 +46,25 @@ public function addAction(KalturaDropFolder $dropFolder) $dropFolder->validatePropertyMinValue('autoFileDeleteDays', 0, true); $dropFolder->validatePropertyNotNull('fileHandlerType'); $dropFolder->validatePropertyNotNull('fileHandlerConfig'); - + // validate values - + if (is_null($dropFolder->fileSizeCheckInterval)) { $dropFolder->fileSizeCheckInterval = DropFolder::FILE_SIZE_CHECK_INTERVAL_DEFAULT_VALUE; } - + if (is_null($dropFolder->fileNamePatterns)) { $dropFolder->fileNamePatterns = DropFolder::FILE_NAME_PATTERNS_DEFAULT_VALUE; } - + if (!kDataCenterMgr::dcExists($dropFolder->dc)) { throw new KalturaAPIException(KalturaErrors::DATA_CENTER_ID_NOT_FOUND, $dropFolder->dc); } - + if (!PartnerPeer::retrieveByPK($dropFolder->partnerId)) { throw new KalturaAPIException(KalturaErrors::INVALID_PARTNER_ID, $dropFolder->partnerId); } - + if (!DropFolderPlugin::isAllowedPartner($dropFolder->partnerId)) { throw new KalturaAPIException(KalturaErrors::PLUGIN_NOT_AVAILABLE_FOR_PARTNER, DropFolderPlugin::getPluginName(), $dropFolder->partnerId); @@ -77,34 +77,34 @@ public function addAction(KalturaDropFolder $dropFolder) throw new KalturaAPIException(KalturaDropFolderErrors::DROP_FOLDER_ALREADY_EXISTS, $dropFolder->path); } } - + if (!is_null($dropFolder->conversionProfileId)) { $conversionProfileDb = conversionProfile2Peer::retrieveByPK($dropFolder->conversionProfileId); if (!$conversionProfileDb) { throw new KalturaAPIException(KalturaErrors::INGESTION_PROFILE_ID_NOT_FOUND, $dropFolder->conversionProfileId); } } - + // save in database $dbDropFolder = $dropFolder->toInsertableObject(); $dbDropFolder->save(); - + // return the saved object $dropFolder = KalturaDropFolder::getInstanceByType($dbDropFolder->getType()); $dropFolder->fromObject($dbDropFolder, $this->getResponseProfile()); return $dropFolder; - + } - + /** * Retrieve a KalturaDropFolder object by ID - * + * * @action get - * @param int $dropFolderId + * @param int $dropFolderId * @return KalturaDropFolder - * + * * @throws KalturaErrors::INVALID_OBJECT_ID - */ + */ public function getAction($dropFolderId) { $dbDropFolder = DropFolderPeer::retrieveByPK($dropFolderId); @@ -142,7 +142,7 @@ public function updateAction($dropFolderId, KalturaDropFolder $dropFolder) $dropFolder->validatePropertyMinValue('fileSizeCheckInterval', 0, true); $dropFolder->validatePropertyMinValue('autoFileDeleteDays', 0, true); - + if (!is_null($dropFolder->path) && $dropFolder->path != $dbDropFolder->getPath() && $dropFolder->type == KalturaDropFolderType::LOCAL) { $existingDropFolder = DropFolderPeer::retrieveByPathDefaultFilter($dropFolder->path); diff --git a/plugins/vendor/zoom/ZoomDropFolderPlugin/admin/forms/Form_ZoomDropFolderConfigureExtend_SubForm.php b/plugins/vendor/zoom/ZoomDropFolderPlugin/admin/forms/Form_ZoomDropFolderConfigureExtend_SubForm.php index a1c133f6f16..8a47b44657a 100644 --- a/plugins/vendor/zoom/ZoomDropFolderPlugin/admin/forms/Form_ZoomDropFolderConfigureExtend_SubForm.php +++ b/plugins/vendor/zoom/ZoomDropFolderPlugin/admin/forms/Form_ZoomDropFolderConfigureExtend_SubForm.php @@ -17,11 +17,18 @@ public function init() 'disabled' => true, 'filters' => array('StringTrim'), )); - + $this->addElement('text', 'lastHandledMeetingTime', array( 'label' => 'Last Handled Meeting Time:', 'filters' => array('StringTrim'), )); + + $this->addElement('text', 'fileProcessingGracePeriod', array( + 'label' => 'File processing grace period (seconds):', + 'description' => 'Time to wait before processing a file. Leave empty for default: 10800 (3 hours). Maximum: 21600 (6 hours).', + 'required' => false, + 'filters' => array('StringTrim'), + )); } - + } diff --git a/plugins/vendor/zoom/ZoomDropFolderPlugin/batch/KZoomDropFolderEngine.php b/plugins/vendor/zoom/ZoomDropFolderPlugin/batch/KZoomDropFolderEngine.php index a444bbcc46b..cb0052e4b31 100644 --- a/plugins/vendor/zoom/ZoomDropFolderPlugin/batch/KZoomDropFolderEngine.php +++ b/plugins/vendor/zoom/ZoomDropFolderPlugin/batch/KZoomDropFolderEngine.php @@ -82,7 +82,7 @@ protected function shouldAdvanceByDay($startRunTime, $fileInStatusProcessingExis if($fileInStatusProcessingExists) { - $fileProcessingGracePeriod = $this->getZoomParam('fileProcessingGracePeriod'); + $fileProcessingGracePeriod = $this->dropFolder->fileProcessingGracePeriod; if($secondsFromMidnight <= $fileProcessingGracePeriod) { KalturaLog::info("DropFolderId {$this->dropFolder->id}: A new day is here, but found files in status Processing. Waiting for status completed"); diff --git a/plugins/vendor/zoom/ZoomDropFolderPlugin/lib/api/KalturaZoomDropFolder.php b/plugins/vendor/zoom/ZoomDropFolderPlugin/lib/api/KalturaZoomDropFolder.php index 8c4f6a880bd..8a2655d32ec 100644 --- a/plugins/vendor/zoom/ZoomDropFolderPlugin/lib/api/KalturaZoomDropFolder.php +++ b/plugins/vendor/zoom/ZoomDropFolderPlugin/lib/api/KalturaZoomDropFolder.php @@ -65,13 +65,22 @@ class KalturaZoomDropFolder extends KalturaDropFolder * @var time */ public $lastHandledMeetingTime; - + + /** + * The amount of time, in seconds, to wait before processing a drop folder file + * @var int + * @minValue 0 + * @maxValue 21600 + */ + public $fileProcessingGracePeriod; + /* * mapping between the field on this object (on the left) and the setter/getter on the entry object (on the right) */ private static $map_between_objects = array( 'zoomVendorIntegrationId', - 'lastHandledMeetingTime' + 'lastHandledMeetingTime', + 'fileProcessingGracePeriod' ); public function getMapBetweenObjects() @@ -83,6 +92,15 @@ public function doFromObject($sourceObject, KalturaDetachedResponseProfile $resp { parent::doFromObject($sourceObject, $responseProfile); + if ($this->shouldGet('fileProcessingGracePeriod', $responseProfile)) + { + $value = $sourceObject->getFileProcessingGracePeriod(); + if (!is_null($value)) + { + $this->fileProcessingGracePeriod = $value; + } + } + /* @var ZoomVendorIntegration $vendorIntegration */ $vendorIntegration = VendorIntegrationPeer::retrieveByPK($this->zoomVendorIntegrationId); try @@ -122,7 +140,7 @@ public function doFromObject($sourceObject, KalturaDetachedResponseProfile $resp { $this->errorDescription = $e->getMessage(); } - + } public function toObject($dbObject = null, $skip = array()) @@ -138,14 +156,49 @@ public function toObject($dbObject = null, $skip = array()) $vendorIntegration->setZoomAccountDescription($this->description); $vendorIntegration->save(); } - + if (!$dbObject) { $dbObject = new ZoomDropFolder(); } - + + $fileProcessingGracePeriodValue = $this->fileProcessingGracePeriod; + + // Convert to integer if it's a numeric string + if (is_string($fileProcessingGracePeriodValue) && is_numeric($fileProcessingGracePeriodValue)) + { + $fileProcessingGracePeriodValue = (int)$fileProcessingGracePeriodValue; + } + + // Set default if empty + if (is_null($fileProcessingGracePeriodValue) || $fileProcessingGracePeriodValue === '') + { + $fileProcessingGracePeriodValue = DropFolder::FILE_PROCESSING_GRACE_PERIOD_DEFAULT_VALUE; + } + $dbObject->setType(ZoomDropFolderPlugin::getDropFolderTypeCoreValue(ZoomDropFolderType::ZOOM)); - return parent::toObject($dbObject, $skip); + $dbObject = parent::toObject($dbObject, $skip); + + if (!is_null($fileProcessingGracePeriodValue) && !in_array('fileProcessingGracePeriod', $skip)) + { + $dbObject->setFileProcessingGracePeriod($fileProcessingGracePeriodValue); + } + + return $dbObject; + } + + public function validateForInsert($propertiesToSkip = array()) + { + $this->validatePropertyMinValue('fileProcessingGracePeriod', 0, true); + $this->validatePropertyMaxValue('fileProcessingGracePeriod', DropFolder::FILE_PROCESSING_GRACE_PERIOD_MAX_VALUE, true); + return parent::validateForInsert($propertiesToSkip); + } + + public function validateForUpdate($sourceObject, $propertiesToSkip = array()) + { + $this->validatePropertyMinValue('fileProcessingGracePeriod', 0, true); + $this->validatePropertyMaxValue('fileProcessingGracePeriod', DropFolder::FILE_PROCESSING_GRACE_PERIOD_MAX_VALUE, true); + return parent::validateForUpdate($sourceObject, $propertiesToSkip); } } diff --git a/plugins/vendor/zoom/ZoomDropFolderPlugin/lib/model/ZoomDropFolder.php b/plugins/vendor/zoom/ZoomDropFolderPlugin/lib/model/ZoomDropFolder.php index f0d0294cabe..638f7e1b4c3 100644 --- a/plugins/vendor/zoom/ZoomDropFolderPlugin/lib/model/ZoomDropFolder.php +++ b/plugins/vendor/zoom/ZoomDropFolderPlugin/lib/model/ZoomDropFolder.php @@ -9,16 +9,22 @@ class ZoomDropFolder extends RemoteDropFolder const ZOOM_VENDOR_INTEGRATION_ID = 'zoom_vendor_integration_id'; const LAST_HANDLED_MEETING_TIME = 'last_handled_meeting_time'; - + const FILE_PROCESSING_GRACE_PERIOD = 'file_processing_grace_period'; + /** * @var string */ protected $zoomVendorIntegrationId; - + /** * @var time */ protected $lastHandledMeetingTime; + + /** + * @var int + */ + protected $fileProcessingGracePeriod; /** * return string @@ -51,7 +57,41 @@ public function setLastHandledMeetingTime($v) { $this->putInCustomData(self::LAST_HANDLED_MEETING_TIME, $v); } - + + /** + * @return int + */ + public function getFileProcessingGracePeriod() + { + return $this->getFromCustomData(self::FILE_PROCESSING_GRACE_PERIOD); + } + + /** + * @param int $v + */ + public function setFileProcessingGracePeriod($v) + { + $this->putInCustomData(self::FILE_PROCESSING_GRACE_PERIOD, $v); + } + + /** + * Code to be run before inserting to database + * @param PropelPDO $con + * @return boolean + */ + public function preInsert(PropelPDO $con = null) + { + $ret = parent::preInsert($con); + + $currentValue = $this->getFileProcessingGracePeriod(); + if (is_null($currentValue)) + { + $this->setFileProcessingGracePeriod(DropFolder::FILE_PROCESSING_GRACE_PERIOD_DEFAULT_VALUE); + } + + return $ret; + } + public function getImportJobData() { return new kDropFolderImportJobData(); @@ -68,4 +108,4 @@ protected function getRemoteFileTransferMgrType() { return kFileTransferMgrType::ZOOM; /// TODO } -} \ No newline at end of file +}