Ejemplo n.º 1
0
 public static function dependsOn()
 {
     $class = get_called_class();
     $integrationVersion = $class::getRequiredIntegrationPluginVersion();
     $dependency = new KalturaDependency(IntegrationPlugin::getPluginName(), $integrationVersion);
     return array($dependency);
 }
Ejemplo n.º 2
0
 /**
  * @action notify
  * @disableTags TAG_WIDGET_SESSION,TAG_ENTITLEMENT_ENTRY,TAG_ENTITLEMENT_CATEGORY
  * @param int $id integration job id
  */
 public function notifyAction($id)
 {
     $coreType = IntegrationPlugin::getBatchJobTypeCoreValue(IntegrationBatchJobType::INTEGRATION);
     $batchJob = BatchJobPeer::retrieveByPK($id);
     $invalidJobId = false;
     $invalidKs = false;
     if (!self::validateKs($batchJob)) {
         $invalidKs = true;
         KalturaLog::err("ks not valid for notifying job [{$id}]");
     } elseif (!$batchJob) {
         $invalidJobId = true;
         KalturaLog::err("Job [{$id}] not found");
     } elseif ($batchJob->getJobType() != $coreType) {
         $invalidJobId = true;
         KalturaLog::err("Job [{$id}] wrong type [" . $batchJob->getJobType() . "] expected [" . $coreType . "]");
     } elseif ($batchJob->getStatus() != KalturaBatchJobStatus::ALMOST_DONE) {
         $invalidJobId = true;
         KalturaLog::err("Job [{$id}] wrong status [" . $batchJob->getStatus() . "] expected [" . KalturaBatchJobStatus::ALMOST_DONE . "]");
     } elseif ($batchJob->getPartnerId() != kCurrentContext::getCurrentPartnerId()) {
         $invalidKs = true;
         KalturaLog::err("Job [{$id}] of wrong partner [" . $batchJob->getPartnerId() . "] expected [" . kCurrentContext::getCurrentPartnerId() . "]");
     }
     if ($invalidJobId) {
         throw new KalturaAPIException(KalturaErrors::INVALID_BATCHJOB_ID, $id);
     }
     if ($invalidKs) {
         throw new KalturaAPIException(KalturaIntegrationErrors::INTEGRATION_NOTIFY_FAILED);
     }
     kJobsManager::updateBatchJob($batchJob, KalturaBatchJobStatus::FINISHED);
 }
 public function shouldConsumeJobStatusEvent(BatchJob $dbBatchJob)
 {
     if ($dbBatchJob->getJobType() == IntegrationPlugin::getBatchJobTypeCoreValue(IntegrationBatchJobType::INTEGRATION) && $dbBatchJob->getStatus() == BatchJob::BATCHJOB_STATUS_DONT_PROCESS && $dbBatchJob->getData()->getTriggerType() == BpmEventNotificationIntegrationPlugin::getIntegrationTriggerCoreValue(BpmEventNotificationIntegrationTrigger::BPM_EVENT_NOTIFICATION)) {
         return true;
     }
     return false;
 }
 public static function dependsOn()
 {
     $integrationVersion = new KalturaVersion(self::INTEGRATION_PLUGIN_VERSION_MAJOR, self::INTEGRATION_PLUGIN_VERSION_MINOR, self::INTEGRATION_PLUGIN_VERSION_BUILD);
     $integrationDependency = new KalturaDependency(IntegrationPlugin::getPluginName(), $integrationVersion);
     $bpmVersion = new KalturaVersion(self::BPM_PLUGIN_VERSION_MAJOR, self::BPM_PLUGIN_VERSION_MINOR, self::BPM_PLUGIN_VERSION_BUILD);
     $bpmDependency = new KalturaDependency(BusinessProcessNotificationPlugin::getPluginName(), $bpmVersion);
     return array($integrationDependency, $bpmDependency);
 }
Ejemplo n.º 5
0
 public function shouldConsumeJobStatusEvent(BatchJob $dbBatchJob)
 {
     if (in_array($dbBatchJob->getStatus(), array(BatchJob::BATCHJOB_STATUS_FAILED, BatchJob::BATCHJOB_STATUS_DONT_PROCESS, BatchJob::BATCHJOB_STATUS_FINISHED)) && $dbBatchJob->getJobType() == IntegrationPlugin::getBatchJobTypeCoreValue(IntegrationBatchJobType::INTEGRATION)) {
         $providerType = $dbBatchJob->getJobSubType();
         if ($providerType == VoicebasePlugin::getProviderTypeCoreValue(VoicebaseIntegrationProviderType::VOICEBASE)) {
             return true;
         }
     }
     return false;
 }
Ejemplo n.º 6
0
 /**
  * @action notify
  * @disableTags TAG_WIDGET_SESSION,TAG_ENTITLEMENT_ENTRY,TAG_ENTITLEMENT_CATEGORY
  * @param int $id integration job id
  */
 public function notifyAction($id)
 {
     $coreType = IntegrationPlugin::getBatchJobTypeCoreValue(IntegrationBatchJobType::INTEGRATION);
     $batchJob = BatchJobPeer::retrieveByPK($id);
     $invalid = false;
     if (!$batchJob) {
         $invalid = true;
         KalturaLog::err("Job [{$id}] not found");
     } elseif ($batchJob->getJobType() != $coreType) {
         $invalid = true;
         KalturaLog::err("Job [{$id}] wrong type [" . $batchJob->getJobType() . "] expected [" . $coreType . "]");
     } elseif ($batchJob->getStatus() != KalturaBatchJobStatus::ALMOST_DONE) {
         $invalid = true;
         KalturaLog::err("Job [{$id}] wrong status [" . $batchJob->getStatus() . "] expected [" . KalturaBatchJobStatus::ALMOST_DONE . "]");
     }
     if ($invalid) {
         throw new KalturaAPIException(KalturaErrors::INVALID_BATCHJOB_ID, $id);
     }
     kJobsManager::updateBatchJob($batchJob, KalturaBatchJobStatus::FINISHED);
 }
Ejemplo n.º 7
0
 public static function addintegrationJob($objectType, $objectId, kIntegrationJobData $data)
 {
     $partnerId = kCurrentContext::getCurrentPartnerId();
     $batchJob = new BatchJob();
     $batchJob->setPartnerId($partnerId);
     $batchJob->setObjectType($objectType);
     $batchJob->setObjectId($objectId);
     if ($objectType == BatchJobObjectType::ENTRY) {
         $batchJob->setEntryId($objectId);
     } elseif ($objectType == BatchJobObjectType::ASSET) {
         $asset = assetPeer::retrieveById($objectId);
         if ($asset) {
             $batchJob->setEntryId($asset->getEntryId());
         }
     }
     $batchJob->setStatus(BatchJob::BATCHJOB_STATUS_DONT_PROCESS);
     $jobType = IntegrationPlugin::getBatchJobTypeCoreValue(IntegrationBatchJobType::INTEGRATION);
     $batchJob = kJobsManager::addJob($batchJob, $data, $jobType, $data->getProviderType());
     return kJobsManager::updateBatchJob($batchJob, BatchJob::BATCHJOB_STATUS_PENDING);
 }
Ejemplo n.º 8
0
 public static function addintegrationJob($objectType, $objectId, kIntegrationJobData $data)
 {
     $partnerId = kCurrentContext::getCurrentPartnerId();
     $providerType = $data->getProviderType();
     $integrationProvider = KalturaPluginManager::loadObject('IIntegrationProvider', $providerType);
     if (!$integrationProvider || !$integrationProvider->validatePermissions($partnerId)) {
         KalturaLog::err("partner {$partnerId} not permitted with provider type {$providerType}");
         return false;
     }
     $batchJob = new BatchJob();
     $batchJob->setPartnerId($partnerId);
     $batchJob->setObjectType($objectType);
     $batchJob->setObjectId($objectId);
     if ($objectType == BatchJobObjectType::ENTRY) {
         $batchJob->setEntryId($objectId);
     } elseif ($objectType == BatchJobObjectType::ASSET) {
         $asset = assetPeer::retrieveById($objectId);
         if ($asset) {
             $batchJob->setEntryId($asset->getEntryId());
         }
     }
     $batchJob->setStatus(BatchJob::BATCHJOB_STATUS_DONT_PROCESS);
     $jobType = IntegrationPlugin::getBatchJobTypeCoreValue(IntegrationBatchJobType::INTEGRATION);
     $batchJob = kJobsManager::addJob($batchJob, $data, $jobType, $providerType);
     if ($integrationProvider->shouldSendCallBack()) {
         $jobId = $batchJob->getId();
         $ks = self::generateKs($partnerId, $jobId);
         $callBackUrl = "http://" . kConf::get('cdn_api_host');
         $callBackUrl .= "/api_v3/index.php/service/integration_integration/action/notify";
         $callBackUrl .= "/id/{$jobId}/ks/{$ks}";
         $data = $batchJob->getData();
         $data->setCallbackNotificationUrl($callBackUrl);
         $batchJob->setData($data);
     }
     return kJobsManager::updateBatchJob($batchJob, BatchJob::BATCHJOB_STATUS_PENDING);
 }