コード例 #1
0
ファイル: kuserPeer.php プロジェクト: wzur/server
 public static function createKuserForPartner($partner_id, $puser_id, $is_admin = false)
 {
     $kuser = kuserPeer::getKuserForPartner($partner_id, $puser_id);
     if (!$kuser) {
         $lockKey = "user_add_" . $partner_id . $puser_id;
         return kLock::runLocked($lockKey, array('kuserPeer', 'createNewUser'), array($partner_id, $puser_id, $is_admin));
     }
     return $kuser;
 }
コード例 #2
0
ファイル: UserService.php プロジェクト: wzur/server
 /**
  * Adds a new user to an existing account in the Kaltura database.
  * Input param $id is the unique identifier in the partner's system.
  *
  * @action add
  * @param KalturaUser $user The new user
  * @return KalturaUser The new user
  *
  * @throws KalturaErrors::DUPLICATE_USER_BY_ID
  * @throws KalturaErrors::PROPERTY_VALIDATION_CANNOT_BE_NULL
  * @throws KalturaErrors::INVALID_FIELD_VALUE
  * @throws KalturaErrors::UNKNOWN_PARTNER_ID
  * @throws KalturaErrors::ADMIN_LOGIN_USERS_QUOTA_EXCEEDED
  * @throws KalturaErrors::PASSWORD_STRUCTURE_INVALID
  * @throws KalturaErrors::DUPLICATE_USER_BY_LOGIN_ID
  * @throws KalturaErrors::USER_ROLE_NOT_FOUND
  */
 function addAction(KalturaUser $user)
 {
     if (!preg_match(kuser::PUSER_ID_REGEXP, $user->id)) {
         throw new KalturaAPIException(KalturaErrors::INVALID_FIELD_VALUE, 'id');
     }
     if ($user instanceof KalturaAdminUser) {
         $user->isAdmin = true;
     }
     $user->partnerId = $this->getPartnerId();
     $lockKey = "user_add_" . $this->getPartnerId() . $user->id;
     return kLock::runLocked($lockKey, array($this, 'adduserImpl'), array($user));
 }
コード例 #3
0
ファイル: MetadataService.php プロジェクト: DBezemer/server
 /**
  * Action transforms current metadata object XML using a provided XSL.
  * @action updateFromXSL
  * 
  * @param int $id
  * @param file $xslFile
  * @return KalturaMetadata
  * @throws MetadataErrors::XSLT_VALIDATION_ERROR
  * @throws MetadataErrors::METADATA_FILE_NOT_FOUND
  * @throws MetadataErrors::METADATA_NOT_FOUND
  */
 public function updateFromXSLAction($id, $xslFile)
 {
     $xslFilePath = $xslFile['tmp_name'];
     if (!file_exists($xslFilePath)) {
         throw new KalturaAPIException(MetadataErrors::METADATA_FILE_NOT_FOUND, $xslFile['name']);
     }
     $xslData = file_get_contents($xslFilePath);
     @unlink($xslFilePath);
     return kLock::runLocked("metadata_update_xsl_{$id}", array($this, 'updateFromXSLImpl'), array($id, $xslData));
 }
コード例 #4
0
ファイル: MediaService.php プロジェクト: AdiTal/server
 /**
  * Replace content associated with the media entry.
  *
  * @action updateContent
  * @param string $entryId Media entry id to update
  * @param KalturaResource $resource Resource to be used to replace entry media content
  * @param int $conversionProfileId The conversion profile id to be used on the entry
  * @param KalturaEntryReplacementOptions $advancedOptions Additional update content options
  * @return KalturaMediaEntry The updated media entry
  * @throws KalturaErrors::ENTRY_ID_NOT_FOUND
  * @throws KalturaErrors::ENTRY_REPLACEMENT_ALREADY_EXISTS
  * @throws KalturaErrors::INVALID_OBJECT_ID
  * @validateUser entry entryId edit
  */
 function updateContentAction($entryId, KalturaResource $resource, $conversionProfileId = null, $advancedOptions = null)
 {
     $dbEntry = entryPeer::retrieveByPK($entryId);
     if (!$dbEntry || $dbEntry->getType() != KalturaEntryType::MEDIA_CLIP) {
         throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
     }
     //calling replaceResource only if no lock or we grabbed it
     $lock = kLock::create("media_updateContent_{$entryId}");
     if ($lock && !$lock->lock(self::KLOCK_MEDIA_UPDATECONTENT_GRAB_TIMEOUT, self::KLOCK_MEDIA_UPDATECONTENT_HOLD_TIMEOUT)) {
         throw new KalturaAPIException(KalturaErrors::ENTRY_REPLACEMENT_ALREADY_EXISTS);
     }
     try {
         $this->replaceResource($resource, $dbEntry, $conversionProfileId, $advancedOptions);
     } catch (Exception $e) {
         if ($lock) {
             $lock->unlock();
         }
         throw $e;
     }
     if ($lock) {
         $lock->unlock();
     }
     return $this->getEntry($entryId);
 }
コード例 #5
0
 /**
  * @param LiveEntry $dbEntry
  * @return entry
  */
 private function createRecordedEntry(LiveEntry $dbEntry, $mediaServerIndex)
 {
     $lock = kLock::create("live_record_" . $dbEntry->getId());
     if ($lock && !$lock->lock(self::KLOCK_CREATE_RECORDED_ENTRY_GRAB_TIMEOUT, self::KLOCK_CREATE_RECORDED_ENTRY_HOLD_TIMEOUT)) {
         return;
     }
     // If while we were waiting for the lock, someone has updated the recorded entry id - we should use it.
     $dbEntry->reload();
     if ($dbEntry->getRecordStatus() != RecordStatus::PER_SESSION && $dbEntry->getRecordedEntryId()) {
         $lock->unlock();
         $recordedEntry = entryPeer::retrieveByPK($dbEntry->getRecordedEntryId());
         return $recordedEntry;
     }
     $recordedEntry = null;
     try {
         $recordedEntryName = $dbEntry->getName();
         if ($dbEntry->getRecordStatus() == RecordStatus::PER_SESSION) {
             $recordedEntryName .= ' ' . ($dbEntry->getRecordedEntryIndex() + 1);
         }
         $recordedEntry = new entry();
         $recordedEntry->setType(entryType::MEDIA_CLIP);
         $recordedEntry->setMediaType(entry::ENTRY_MEDIA_TYPE_VIDEO);
         $recordedEntry->setRootEntryId($dbEntry->getId());
         $recordedEntry->setName($recordedEntryName);
         $recordedEntry->setDescription($dbEntry->getDescription());
         $recordedEntry->setSourceType(EntrySourceType::RECORDED_LIVE);
         $recordedEntry->setAccessControlId($dbEntry->getAccessControlId());
         $recordedEntry->setConversionProfileId($dbEntry->getConversionProfileId());
         $recordedEntry->setKuserId($dbEntry->getKuserId());
         $recordedEntry->setPartnerId($dbEntry->getPartnerId());
         $recordedEntry->setModerationStatus($dbEntry->getModerationStatus());
         $recordedEntry->setIsRecordedEntry(true);
         $recordedEntry->setTags($dbEntry->getTags());
         $recordedEntry->save();
         $dbEntry->setRecordedEntryId($recordedEntry->getId());
         $dbEntry->save();
         $assets = assetPeer::retrieveByEntryId($dbEntry->getId(), array(assetType::LIVE));
         foreach ($assets as $asset) {
             /* @var $asset liveAsset */
             $asset->incLiveSegmentVersion($mediaServerIndex);
             $asset->save();
         }
     } catch (Exception $e) {
         $lock->unlock();
         throw $e;
     }
     $lock->unlock();
     return $recordedEntry;
 }