/** * batch sets a configuration parameter to be loaded by a worker * * @action setWorkerConfig * @param int $workerId The id of the job to be configured * @param int $adminId The id of the admin that called the setConfig * @param string $configParam The parameter to be set * @param string $configValue The value to be set * @param string $configParamPart The parameter part to be set - for additional params * @param string $cause The reason it was changed * @return KalturaControlPanelCommand */ function setWorkerConfigAction($workerId, $adminId, $configParam, $configValue, $configParamPart = null, $cause = null) { $adminDb = kuserPeer::retrieveByPK($adminId); $workerDb = SchedulerWorkerPeer::retrieveByPK($workerId); if (!$workerDb) { throw new KalturaAPIException(KalturaErrors::WORKER_NOT_FOUND, $workerId); } $workerName = $workerDb->getName(); $schedulerId = $workerDb->getSchedulerId(); $schedulerDb = SchedulerPeer::retrieveByPK($schedulerId); if (!$schedulerDb) { throw new KalturaAPIException(KalturaErrors::SCHEDULER_NOT_FOUND, $schedulerId); } $schedulerName = $schedulerDb->getName(); $description = "Configure {$configParam} on {$schedulerName}"; if (!is_null($configParamPart)) { $description = "Configure {$configParam}.{$configParamPart} on {$schedulerName}"; } // saves the command to the DB $commandDb = new ControlPanelCommand(); $commandDb->setSchedulerId($schedulerId); $commandDb->setSchedulerConfiguredId($schedulerDb->getConfiguredId()); $commandDb->setCreatedById($adminId); $commandDb->setType(KalturaControlPanelCommandType::CONFIG); $commandDb->setStatus(KalturaControlPanelCommandStatus::PENDING); $commandDb->setDescription($description); $commandDb->setWorkerId($workerId); $commandDb->setWorkerConfiguredId($workerDb->getConfiguredId()); $commandDb->setWorkerName($workerName); $commandDb->setTargetType(KalturaControlPanelCommandTargetType::JOB); if ($adminDb) { $commandDb->setCreatedBy($adminDb->getName()); } $commandDb->setCause($cause); $commandDb->save(); // saves the new config to the DB $configDb = new SchedulerConfig(); $configDb->setSchedulerId($schedulerId); $configDb->setSchedulerConfiguredId($schedulerDb->getConfiguredId()); $configDb->setCommandId($commandDb->getId()); $configDb->setCommandStatus(KalturaControlPanelCommandStatus::PENDING); $configDb->setSchedulerName($schedulerName); $configDb->setVariable($configParam); $configDb->setVariablePart($configParamPart); $configDb->setValue($configValue); $configDb->setWorkerId($workerId); $configDb->setWorkerConfiguredId($workerDb->getConfiguredId()); $configDb->setWorkerName($workerName); if ($adminDb) { $configDb->setCreatedBy($adminDb->getName()); } $configDb->save(); $command = new KalturaControlPanelCommand(); $command->fromObject($commandDb, $this->getResponseProfile()); return $command; }