Ejemplo n.º 1
0
 /**
  * Add external media entry
  *
  * @action add
  * @param KalturaExternalMediaEntry $entry
  * @return KalturaExternalMediaEntry
  */
 function addAction(KalturaExternalMediaEntry $entry)
 {
     $dbEntry = parent::add($entry, $entry->conversionProfileId);
     $dbEntry->setStatus(entryStatus::READY);
     $dbEntry->save();
     $trackEntry = new TrackEntry();
     $trackEntry->setEntryId($dbEntry->getId());
     $trackEntry->setTrackEventTypeId(TrackEntry::TRACK_ENTRY_EVENT_TYPE_ADD_ENTRY);
     $trackEntry->setDescription(__METHOD__ . ":" . __LINE__ . "::ENTRY_EXTERNAL_MEDIA");
     TrackEntry::addTrackEntry($trackEntry);
     $entry->fromObject($dbEntry, $this->getResponseProfile());
     return $entry;
 }
 /**
  * Generic add entry, should be used when the uploaded entry type is not known.
  *
  * @action add
  * @param KalturaBaseEntry $entry
  * @param KalturaEntryType $type
  * @return KalturaBaseEntry
  * @throws KalturaErrors::ENTRY_TYPE_NOT_SUPPORTED
  */
 function addAction(KalturaBaseEntry $entry, $type = -1)
 {
     $dbEntry = parent::add($entry, $entry->conversionProfileId);
     $dbEntry->setStatus(entryStatus::NO_CONTENT);
     $dbEntry->save();
     $trackEntry = new TrackEntry();
     $trackEntry->setEntryId($dbEntry->getId());
     $trackEntry->setTrackEventTypeId(TrackEntry::TRACK_ENTRY_EVENT_TYPE_ADD_ENTRY);
     $trackEntry->setDescription(__METHOD__ . ":" . __LINE__ . "::ENTRY_BASE");
     TrackEntry::addTrackEntry($trackEntry);
     myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_ENTRY_ADD, $dbEntry, $dbEntry->getPartnerId(), null, null, null, $dbEntry->getId());
     $entry->fromObject($dbEntry);
     return $entry;
 }
 /**
  * Add entry
  *
  * @action add
  * @param KalturaMediaEntry $entry
  * @return KalturaMediaEntry
  */
 function addAction(KalturaMediaEntry $entry)
 {
     kWAMS::testConnection($this->getPartner()->getWamsAccountName(), $this->getPartner()->getWamsAccountKey());
     if ($entry->conversionQuality && !$entry->conversionProfileId) {
         $entry->conversionProfileId = $entry->conversionQuality;
     }
     $dbEntry = parent::add($entry, $entry->conversionProfileId);
     $dbEntry->setStatus(entryStatus::NO_CONTENT);
     $dbEntry->save();
     $trackEntry = new TrackEntry();
     $trackEntry->setEntryId($dbEntry->getId());
     $trackEntry->setTrackEventTypeId(TrackEntry::TRACK_ENTRY_EVENT_TYPE_ADD_ENTRY);
     $trackEntry->setDescription(__METHOD__ . ":" . __LINE__ . "::ENTRY_MEDIA");
     TrackEntry::addTrackEntry($trackEntry);
     myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_ENTRY_ADD, $dbEntry, $dbEntry->getPartnerId(), null, null, null, $dbEntry->getId());
     $entry->fromObject($dbEntry);
     return $entry;
 }
Ejemplo n.º 4
0
 /**
  * Add new entry after the specific media file was uploaded and the upload token id exists
  *
  * @action addFromUploadedFile
  * @param KalturaMediaEntry $mediaEntry Media entry metadata
  * @param string $uploadTokenId Upload token id
  * @return KalturaMediaEntry The new media entry
  *
  * @throws KalturaErrors::PROPERTY_VALIDATION_MIN_LENGTH
  * @throws KalturaErrors::PROPERTY_VALIDATION_CANNOT_BE_NULL
  * @throws KalturaErrors::UPLOADED_FILE_NOT_FOUND_BY_TOKEN
  *
  * @deprecated use media.add instead
  */
 function addFromUploadedFileAction(KalturaMediaEntry $mediaEntry, $uploadTokenId)
 {
     if ($mediaEntry->conversionQuality && !$mediaEntry->conversionProfileId) {
         $mediaEntry->conversionProfileId = $mediaEntry->conversionQuality;
     }
     try {
         // check that the uploaded file exists
         $entryFullPath = kUploadTokenMgr::getFullPathByUploadTokenId($uploadTokenId);
         // Make sure that the uploads path is not modified by $uploadTokenId (with the value of "../" for example )
         $entryRootDir = realpath(dirname($entryFullPath));
         $uploadPathBase = realpath(myContentStorage::getFSUploadsPath());
         if (strpos($entryRootDir, $uploadPathBase) !== 0) {
             KalturaLog::err("uploadTokenId [{$uploadTokenId}] points outside of uploads directory");
             throw new KalturaAPIException(KalturaErrors::INVALID_UPLOAD_TOKEN_ID);
         }
     } catch (kCoreException $ex) {
         if ($ex->getCode() == kUploadTokenException::UPLOAD_TOKEN_INVALID_STATUS) {
         }
         throw new KalturaAPIException(KalturaErrors::UPLOAD_TOKEN_INVALID_STATUS_FOR_ADD_ENTRY);
         throw $ex;
     }
     if (!file_exists($entryFullPath)) {
         // Backward compatability - support case in which the required file exist in the other DC
         kFileUtils::dumpApiRequest(kDataCenterMgr::getRemoteDcExternalUrlByDcId(1 - kDataCenterMgr::getCurrentDcId()));
         /*
         $remoteDCHost = kUploadTokenMgr::getRemoteHostForUploadToken($uploadTokenId, kDataCenterMgr::getCurrentDcId());
         if($remoteDCHost)
         {
         	kFileUtils::dumpApiRequest($remoteDCHost);
         }
         else
         {
         	throw new KalturaAPIException(KalturaErrors::UPLOADED_FILE_NOT_FOUND_BY_TOKEN);
         }
         */
     }
     $dbEntry = parent::add($mediaEntry, $mediaEntry->conversionProfileId);
     $kshowId = $dbEntry->getKshowId();
     // setup the needed params for my insert entry helper
     $paramsArray = array("entry_media_source" => KalturaSourceType::FILE, "entry_media_type" => $dbEntry->getMediaType(), "entry_full_path" => $entryFullPath, "entry_license" => $dbEntry->getLicenseType(), "entry_credit" => $dbEntry->getCredit(), "entry_source_link" => $dbEntry->getSourceLink(), "entry_tags" => $dbEntry->getTags());
     $token = $this->getKsUniqueString();
     $insert_entry_helper = new myInsertEntryHelper(null, $dbEntry->getKuserId(), $kshowId, $paramsArray);
     $insert_entry_helper->setPartnerId($this->getPartnerId(), $this->getPartnerId() * 100);
     $insert_entry_helper->insertEntry($token, $dbEntry->getType(), $dbEntry->getId(), $dbEntry->getName(), $dbEntry->getTags(), $dbEntry);
     $dbEntry = $insert_entry_helper->getEntry();
     kUploadTokenMgr::closeUploadTokenById($uploadTokenId);
     $ret = new KalturaMediaEntry();
     if ($dbEntry) {
         myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_ENTRY_ADD, $dbEntry, $dbEntry->getPartnerId(), null, null, null, $dbEntry->getId());
         $ret->fromObject($dbEntry, $this->getResponseProfile());
     }
     return $ret;
 }