/** * Add new playlist * Note that all entries used in a playlist will become public and may appear in KalturaNetwork * * @action add * @param KalturaPlaylist $playlist * @param bool $updateStats indicates that the playlist statistics attributes should be updated synchronously now * @return KalturaPlaylist * * @disableRelativeTime $playlist */ function addAction(KalturaPlaylist $playlist, $updateStats = false) { $dbPlaylist = $playlist->toInsertableObject(); $this->checkAndSetValidUserInsert($playlist, $dbPlaylist); $this->checkAdminOnlyInsertProperties($playlist); $this->validateAccessControlId($playlist); $this->validateEntryScheduleDates($playlist, $dbPlaylist); $dbPlaylist->setPartnerId($this->getPartnerId()); $dbPlaylist->setStatus(entryStatus::READY); $dbPlaylist->setKshowId(null); // this is brave !! $dbPlaylist->setType(entryType::PLAYLIST); myPlaylistUtils::validatePlaylist($dbPlaylist); $dbPlaylist->save(); if ($updateStats) { myPlaylistUtils::updatePlaylistStatistics($dbPlaylist->getPartnerId(), $dbPlaylist); } $trackEntry = new TrackEntry(); $trackEntry->setEntryId($dbPlaylist->getId()); $trackEntry->setTrackEventTypeId(TrackEntry::TRACK_ENTRY_EVENT_TYPE_ADD_ENTRY); $trackEntry->setDescription(__METHOD__ . ":" . __LINE__ . "::ENTRY_PLAYLIST"); TrackEntry::addTrackEntry($trackEntry); $playlist = new KalturaPlaylist(); // start from blank $playlist->fromObject($dbPlaylist, $this->getResponseProfile()); return $playlist; }
/** * Add entry * * @action add * @param KalturaMediaEntry $entry * @return KalturaMediaEntry */ function addAction(KalturaMediaEntry $entry) { if ($entry->conversionQuality && !$entry->conversionProfileId) { $entry->conversionProfileId = $entry->conversionQuality; } $dbEntry = parent::add($entry, $entry->conversionProfileId); $entryStatus = entryStatus::NO_CONTENT; if (PermissionPeer::isValidForPartner(PermissionName::FEATURE_DRAFT_ENTRY_CONV_PROF_SELECTION, $dbEntry->getPartnerId())) { $entryConversionProfileHasFlavors = myPartnerUtils::entryConversionProfileHasFlavors($dbEntry->getId()); if (!$entryConversionProfileHasFlavors) { // If the entry's conversion profile dones't contain any flavors, mark the entry as READY $entryStatus = entryStatus::READY; } } $dbEntry->setStatus($entryStatus); $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, $this->getResponseProfile()); return $entry; }
/** * 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; }
/** * Adds new live channel. * * @action add * @param KalturaLiveChannel $liveChannel Live channel metadata * @return KalturaLiveChannel The new live channel */ function addAction(KalturaLiveChannel $liveChannel) { $dbEntry = $this->prepareEntryForInsert($liveChannel); $dbEntry->save(); $te = new TrackEntry(); $te->setEntryId($dbEntry->getId()); $te->setTrackEventTypeId(TrackEntry::TRACK_ENTRY_EVENT_TYPE_ADD_ENTRY); $te->setDescription(__METHOD__ . ":" . __LINE__ . "::LIVE_CHANNEL"); TrackEntry::addTrackEntry($te); $liveChannel = new KalturaLiveChannel(); $liveChannel->fromObject($dbEntry, $this->getResponseProfile()); return $liveChannel; }
/** * 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 new document entry after the specific document file was uploaded and the upload token id exists * * @action addFromUploadedFile * @param KalturaDocumentEntry $documentEntry Document entry metadata * @param string $uploadTokenId Upload token id * @return KalturaDocumentEntry The new document entry * * @throws KalturaErrors::PROPERTY_VALIDATION_MIN_LENGTH * @throws KalturaErrors::PROPERTY_VALIDATION_CANNOT_BE_NULL * @throws KalturaErrors::UPLOADED_FILE_NOT_FOUND_BY_TOKEN */ function addFromUploadedFileAction(KalturaDocumentEntry $documentEntry, $uploadTokenId) { try { // check that the uploaded file exists $entryFullPath = kUploadTokenMgr::getFullPathByUploadTokenId($uploadTokenId); } 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)) { $remoteDCHost = kUploadTokenMgr::getRemoteHostForUploadToken($uploadTokenId, kDataCenterMgr::getCurrentDcId()); if ($remoteDCHost) { kFileUtils::dumpApiRequest($remoteDCHost); } else { throw new KalturaAPIException(KalturaErrors::UPLOADED_FILE_NOT_FOUND_BY_TOKEN); } } $dbEntry = $this->prepareEntryForInsert($documentEntry); $dbEntry->setSource(KalturaSourceType::FILE); $dbEntry->setSourceLink("file:{$entryFullPath}"); $dbEntry->save(); $te = new TrackEntry(); $te->setEntryId($dbEntry->getId()); $te->setTrackEventTypeId(TrackEntry::TRACK_ENTRY_EVENT_TYPE_ADD_ENTRY); $te->setDescription(__METHOD__ . ":" . __LINE__ . "::ENTRY_MEDIA_SOURCE_FILE"); TrackEntry::addTrackEntry($te); $msg = null; $flavorAsset = kFlowHelper::createOriginalFlavorAsset($this->getPartnerId(), $dbEntry->getId(), $msg); if (!$flavorAsset) { KalturaLog::err("Flavor asset not created for entry [" . $dbEntry->getId() . "] reason [{$msg}]"); $dbEntry->setStatus(entryStatus::ERROR_CONVERTING); $dbEntry->save(); } else { $ext = pathinfo($entryFullPath, PATHINFO_EXTENSION); KalturaLog::info("Uploaded file extension: {$ext}"); $flavorAsset->setFileExt($ext); $flavorAsset->save(); $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); kFileSyncUtils::moveFromFile($entryFullPath, $syncKey); kEventsManager::raiseEvent(new kObjectAddedEvent($flavorAsset)); } kUploadTokenMgr::closeUploadTokenById($uploadTokenId); myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_ENTRY_ADD, $dbEntry); $documentEntry->fromObject($dbEntry, $this->getResponseProfile()); return $documentEntry; }
public static function uploadFileByToken($file_data, $token, $filename, $extra_id = null, $create_thumb = false) { KalturaLog::log("Trace while uploading1 [{$filename}] [{$token}] [{$extra_id}] " . print_r($file_data, true)); $origFilename = @$file_data['name']; if (!$origFilename) { KalturaLog::log("Error while uploading, file does not have a name. [{$filename}] [{$token}] [{$extra_id}] " . print_r($file_data, true) . "\nerror: [" . @$file_data["error"] . "]"); return; } $parts = pathinfo($origFilename); $extension = @strtolower($parts['extension']); /* $filename = $token .'_'. $filename; // add the file extension after the "." character $fullPath = myContentStorage::getFSUploadsPath().$filename . ( $extra_id ? "_" . $extra_id : "" ) .".".$extension; */ list($fullPath, $fullUrl) = self::getUploadPathAndUrl($token, $filename, $extra_id, $extension); KalturaLog::log("Trace while uploading2 [{$filename}] [{$token}] [{$extra_id}] " . print_r($file_data, true) . "\n->[{$fullPath}]"); // start tracking what will hopefully become an entry $te = new TrackEntry(); $te->setTrackEventTypeId(TrackEntry::TRACK_ENTRY_EVENT_TYPE_UPLOADED_FILE); $te->setParam1Str($token); $te->setParam2Str($filename); $te->setParam3Str($fullPath); $te->setDescription(__METHOD__ . ":" . __LINE__); TrackEntry::addTrackEntry($te); myContentStorage::fullMkdir($fullPath); if (!move_uploaded_file($file_data['tmp_name'], $fullPath)) { KalturaLog::log("Error while uploading [{$token}] [{$filename}] [{$extra_id}] [{$create_thumb}] " . print_r($file_data, true) . "\n->[{$fullPath}]"); $err = array("token" => $token, "filename" => $filename, "origFilename" => $origFilename, "error" => @$file_data["error"]); KalturaLog::log("Error while uploading [{$token}] [{$filename}] [{$extra_id}] [{$create_thumb}] " . print_r($file_data, true) . "\n->[{$fullPath}]" . "\n" . print_r($err, true)); return $err; } chmod($fullPath, 0777); $upload_server_header = isset($_SERVER["HTTP_X_KALTURA_SERVER"]) ? $_SERVER["HTTP_X_KALTURA_SERVER"] : null; $thumb_created = false; // if the file originated from a kaltura upload server we dont need a thumbnail (kuploader) if ($create_thumb && !$upload_server_header) { $thumbFullPath = self::getThumbnailPath($fullPath, ".jpg"); kFile::fullMkdir($thumbFullPath); KalturaLog::log("Thumbnail full path [{$thumbFullPath}]"); if (myContentStorage::fileExtAccepted($extension)) { KalturaLog::log("Generating image thumbnail"); myFileConverter::createImageThumbnail($fullPath, $thumbFullPath, "image2"); $thumb_url = self::getThumbnailPath($fullUrl, ".jpg"); $thumb_created = file_exists($thumbFullPath); } elseif (myContentStorage::fileExtNeedConversion($extension)) { KalturaLog::log("Generating media thumbnail"); myFileConverter::captureFrame($fullPath, $thumbFullPath, 1, "image2", -1, -1, 3); if (!file_exists($thumbFullPath)) { myFileConverter::captureFrame($fullPath, $thumbFullPath, 1, "image2", -1, -1, 0); } } } if (!$thumb_created) { KalturaLog::log("Thumbnail not generated"); // in this case no thumbnail was created - don't extract false data $thumb_url = ""; } return array("token" => $token, "filename" => $filename, "origFilename" => $origFilename, "thumb_url" => $thumb_url, "thumb_created" => $thumb_created); }
/** * 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; }
/** * Adds a new data entry * * @action add * @param KalturaDataEntry $dataEntry Data entry * @return KalturaDataEntry The new data entry */ function addAction(KalturaDataEntry $dataEntry) { $dbEntry = $dataEntry->toObject(new entry()); $this->checkAndSetValidUserInsert($dataEntry, $dbEntry); $this->checkAdminOnlyInsertProperties($dataEntry); $this->validateAccessControlId($dataEntry); $this->validateEntryScheduleDates($dataEntry, $dbEntry); $dbEntry->setPartnerId($this->getPartnerId()); $dbEntry->setSubpId($this->getPartnerId() * 100); $dbEntry->setStatus(KalturaEntryStatus::READY); $dbEntry->setMediaType(entry::ENTRY_MEDIA_TYPE_AUTOMATIC); $dbEntry->save(); $trackEntry = new TrackEntry(); $trackEntry->setEntryId($dbEntry->getId()); $trackEntry->setTrackEventTypeId(TrackEntry::TRACK_ENTRY_EVENT_TYPE_ADD_ENTRY); $trackEntry->setDescription(__METHOD__ . ":" . __LINE__ . "::ENTRY_DATA"); TrackEntry::addTrackEntry($trackEntry); $dataEntry->fromObject($dbEntry); myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_ENTRY_ADD, $dbEntry); return $dataEntry; }
/** * Adds a new mix. * If the dataContent is null, a default timeline will be created. * * @action add * @param KalturaMixEntry $mixEntry Mix entry metadata * @return KalturaMixEntry The new mix entry */ function addAction(KalturaMixEntry $mixEntry) { $mixEntry->validatePropertyMinLength("name", 1); $mixEntry->validatePropertyNotNull("editorType"); $dbEntry = $mixEntry->toObject(new entry()); $this->checkAndSetValidUserInsert($mixEntry, $dbEntry); $this->checkAdminOnlyInsertProperties($mixEntry); $this->validateAccessControlId($mixEntry); $this->validateEntryScheduleDates($mixEntry, $dbEntry); $kshow = $this->createDummyKShow(); $dbEntry->setKshowId($kshow->getId()); $dbEntry->setPartnerId($this->getPartnerId()); $dbEntry->setSubpId($this->getPartnerId() * 100); $dbEntry->setStatus(KalturaEntryStatus::READY); $dbEntry->setMediaType(entry::ENTRY_MEDIA_TYPE_SHOW); // for backward compatibility if (!$dbEntry->getThumbnail()) { $dbEntry->setThumbnail("&auto_edit.jpg"); $dbEntry->setCreateThumb(false); } $dbEntry->save(); // we need the id for setDataContent // set default data if no data given if ($mixEntry->dataContent === null) { myEntryUtils::modifyEntryMetadataWithText($dbEntry, "", 0); } else { $dbEntry->setDataContent($mixEntry->dataContent, true, true); $dbEntry->save(); } $trackEntry = new TrackEntry(); $trackEntry->setEntryId($dbEntry->getId()); $trackEntry->setTrackEventTypeId(TrackEntry::TRACK_ENTRY_EVENT_TYPE_ADD_ENTRY); $trackEntry->setDescription(__METHOD__ . ":" . __LINE__ . "::ENTRY_MIX"); TrackEntry::addTrackEntry($trackEntry); $kshow->setShowEntry($dbEntry); $kshow->save(); $mixEntry->fromObject($dbEntry); myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_ENTRY_ADD, $dbEntry); return $mixEntry; }
/** * Adds new live stream entry. * The entry will be queued for provision. * * @action add * @param KalturaLiveStreamEntry $liveStreamEntry Live stream entry metadata * @param KalturaSourceType $sourceType Live stream source type * @return KalturaLiveStreamEntry The new live stream entry * * @throws KalturaErrors::PROPERTY_VALIDATION_CANNOT_BE_NULL */ function addAction(KalturaLiveStreamEntry $liveStreamEntry, $sourceType = null) { if ($sourceType) { $liveStreamEntry->sourceType = $sourceType; } elseif (is_null($liveStreamEntry->sourceType)) { // default sourceType is AKAMAI_LIVE $liveStreamEntry->sourceType = kPluginableEnumsManager::coreToApi('EntrySourceType', $this->getPartner()->getDefaultLiveStreamEntrySourceType()); } $dbEntry = $this->prepareEntryForInsert($liveStreamEntry); $dbEntry->save(); $te = new TrackEntry(); $te->setEntryId($dbEntry->getId()); $te->setTrackEventTypeId(TrackEntry::TRACK_ENTRY_EVENT_TYPE_ADD_ENTRY); $te->setDescription(__METHOD__ . ":" . __LINE__ . "::" . $dbEntry->getSource()); TrackEntry::addTrackEntry($te); //If a jobData can be created for entry sourceType, add provision job. Otherwise, just save the entry. $jobData = kProvisionJobData::getInstance($dbEntry->getSource()); if ($jobData) { /* @var $data kProvisionJobData */ $jobData->populateFromPartner($dbEntry->getPartner()); $jobData->populateFromEntry($dbEntry); kJobsManager::addProvisionProvideJob(null, $dbEntry, $jobData); } else { $dbEntry->setStatus(entryStatus::READY); $dbEntry->save(); $liveAssets = assetPeer::retrieveByEntryId($dbEntry->getId(), array(assetType::LIVE)); foreach ($liveAssets as $liveAsset) { /* @var $liveAsset liveAsset */ $liveAsset->setStatus(asset::ASSET_STATUS_READY); $liveAsset->save(); } } myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_ENTRY_ADD, $dbEntry, $this->getPartnerId(), null, null, null, $dbEntry->getId()); $liveStreamEntry->fromObject($dbEntry, $this->getResponseProfile()); return $liveStreamEntry; }
private function insertLiveStreamEntry(KalturaLiveStreamAdminEntry $liveStreamEntry) { // first validate the input object $liveStreamEntry->validatePropertyNotNull("mediaType"); $liveStreamEntry->validatePropertyNotNull("sourceType"); $liveStreamEntry->validatePropertyNotNull("encodingIP1"); $liveStreamEntry->validatePropertyNotNull("encodingIP2"); $liveStreamEntry->validatePropertyNotNull("streamPassword"); // create a default name if none was given if (!$liveStreamEntry->name) { $liveStreamEntry->name = $this->getPartnerId() . '_' . time(); } // first copy all the properties to the db entry, then we'll check for security stuff $dbEntry = $liveStreamEntry->toObject(new entry()); $this->checkAndSetValidUserInsert($liveStreamEntry, $dbEntry); $this->checkAdminOnlyInsertProperties($liveStreamEntry); $this->validateAccessControlId($liveStreamEntry); $this->validateEntryScheduleDates($liveStreamEntry, $dbEntry); $dbEntry->setPartnerId($this->getPartnerId()); $dbEntry->setSubpId($this->getPartnerId() * 100); $dbEntry->setKuserId($this->getKuser()->getId()); $dbEntry->setCreatorKuserId($this->getKuser()->getId()); $dbEntry->setStatus(entryStatus::IMPORT); $te = new TrackEntry(); $te->setEntryId($dbEntry->getId()); $te->setTrackEventTypeId(TrackEntry::TRACK_ENTRY_EVENT_TYPE_ADD_ENTRY); $te->setDescription(__METHOD__ . ":" . __LINE__ . "::ENTRY_MEDIA_SOURCE_AKAMAI_LIVE"); TrackEntry::addTrackEntry($te); //if type is manual don't create batch job, just change entry status to ready if ($liveStreamEntry->sourceType == KalturaSourceType::MANUAL_LIVE_STREAM) { $dbEntry->setStatus(entryStatus::READY); $dbEntry->save(); } else { $dbEntry->save(); kJobsManager::addProvisionProvideJob(null, $dbEntry); } return $dbEntry; }
/** * add KalturaMediaEntry from email ingestion * * @action addMediaEntry * @param KalturaMediaEntry $mediaEntry Media entry metadata * @param string $uploadTokenId Upload token id * @param int $emailProfId * @param string $fromAddress * @param string $emailMsgId * * @return KalturaMediaEntry * * @throws KalturaErrors::UPLOADED_FILE_NOT_FOUND_BY_TOKEN * @throws KalturaErrors::EMAIL_INGESTION_PROFILE_NOT_FOUND * */ function addMediaEntryAction(KalturaMediaEntry $mediaEntry, $uploadTokenId, $emailProfId, $fromAddress, $emailMsgId) { try { // check that the uploaded file exists $entryFullPath = kUploadTokenMgr::getFullPathByUploadTokenId($uploadTokenId); if (!file_exists($entryFullPath)) { throw new KalturaAPIException(KalturaErrors::UPLOADED_FILE_NOT_FOUND_BY_TOKEN); } // get the email profile by the given id $existingEIP = EmailIngestionProfilePeer::retrieveByPK($emailProfId); if (!$existingEIP) { throw new KalturaAPIException(KalturaErrors::EMAIL_INGESTION_PROFILE_NOT_FOUND, $emailProfId); } $emailIP = new KalturaEmailIngestionProfile(); $emailIP->fromObject($existingEIP, $this->getResponseProfile()); // handle defaults for media entry metadata $this->changeIfNull($mediaEntry->tags, $emailIP->defaultTags); $this->changeIfNull($mediaEntry->adminTags, $emailIP->defaultAdminTags); $this->changeIfNull($mediaEntry->conversionProfileId, $emailIP->conversionProfile2Id); $this->changeIfNull($mediaEntry->userId, $emailIP->defaultUserId); if (is_null($mediaEntry->categories) || is_null(categoryPeer::getByFullNameExactMatch($mediaEntry->categories))) { $mediaEntry->categories = $emailIP->defaultCategory; } // validate the input object //$entry->validatePropertyMinLength("name", 1); if (!$mediaEntry->name) { $mediaEntry->name = $this->getPartnerId() . '_' . time(); } // first copy all the properties to the db entry, then we'll check for security stuff $dbEntry = $mediaEntry->toObject(new entry()); if ($emailIP->moderationStatus == KalturaEntryModerationStatus::PENDING_MODERATION) { $dbEntry->setModerate(true); } $dbEntry->setType(KalturaEntryType::MEDIA_CLIP); $dbEntry->setMediaType(entry::ENTRY_MEDIA_TYPE_AUTOMATIC); $this->checkAndSetValidUserInsert($mediaEntry, $dbEntry); $this->checkAdminOnlyInsertProperties($mediaEntry); $this->validateAccessControlId($mediaEntry); $this->validateEntryScheduleDates($mediaEntry, $dbEntry); $dbEntry->setPartnerId($this->getPartnerId()); $dbEntry->setSubpId($this->getPartnerId() * 100); $dbEntry->setSourceId($uploadTokenId); $dbEntry->setSourceLink($entryFullPath); $dbEntry->setDefaultModerationStatus(); $dbEntry->save(); $te = new TrackEntry(); $te->setEntryId($dbEntry->getId()); $te->setTrackEventTypeId(TrackEntry::TRACK_ENTRY_EVENT_TYPE_ADD_ENTRY); $te->setDescription(__METHOD__ . ":" . __LINE__ . "::ENTRY_MEDIA_SOURCE_EMAIL_INGESTION"); $te->setParam1Str($fromAddress); $te->setParam2Str($emailMsgId); $te->setParam3Str($emailProfId . '::' . $emailIP->emailAddress . '::' . $emailIP->mailboxId); TrackEntry::addTrackEntry($te); $kshow = $this->createDummyKShow(); $kshowId = $kshow->getId(); myEntryUtils::setEntryTypeAndMediaTypeFromFile($dbEntry, $entryFullPath); // 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); myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_ENTRY_ADD, $dbEntry); $mediaEntry->fromObject($dbEntry, $this->getResponseProfile()); return $mediaEntry; } catch (kCoreException $ex) { if ($ex->getCode() == kUploadTokenException::UPLOAD_TOKEN_INVALID_STATUS) { } throw new KalturaAPIException(KalturaErrors::UPLOAD_TOKEN_INVALID_STATUS_FOR_ADD_ENTRY); throw $ex; } }
public function postUpdate(PropelPDO $con = null) { if (!$this->wasObjectSaved()) { return; } if ($this->alreadyInSave) { return parent::postUpdate($con); } $objectUpdated = $this->isModified(); $objectDeleted = false; if ($this->isColumnModified(entryPeer::STATUS) && $this->getStatus() == entryStatus::DELETED) { $objectDeleted = true; } $trackColumns = array(entryPeer::STATUS, entryPeer::MODERATION_STATUS, entryPeer::KUSER_ID, entryPeer::CREATOR_KUSER_ID, entryPeer::ACCESS_CONTROL_ID); $changedProperties = array(); foreach ($trackColumns as $trackColumn) { if ($this->isColumnModified($trackColumn)) { $column = entryPeer::translateFieldName($trackColumn, BasePeer::TYPE_COLNAME, BasePeer::TYPE_STUDLYPHPNAME); $previousValue = $this->getColumnsOldValue($trackColumn); $newValue = $this->getByName($trackColumn, BasePeer::TYPE_COLNAME); $changedProperties[] = "{$column} [{$previousValue}]->[{$newValue}]"; } } $ret = parent::postUpdate($con); if ($objectDeleted) { kEventsManager::raiseEvent(new kObjectDeletedEvent($this)); myStatisticsMgr::deleteEntry($this); $trackEntry = new TrackEntry(); $trackEntry->setEntryId($this->getId()); $trackEntry->setTrackEventTypeId(TrackEntry::TRACK_ENTRY_EVENT_TYPE_DELETED_ENTRY); $trackEntry->setChangedProperties(implode("\n", $changedProperties)); $trackEntry->setDescription(__METHOD__ . "[" . __LINE__ . "]"); TrackEntry::addTrackEntry($trackEntry); } if ($objectUpdated) { kEventsManager::raiseEvent(new kObjectUpdatedEvent($this)); if (!$objectDeleted && count($changedProperties)) { $trackEntry = new TrackEntry(); $trackEntry->setEntryId($this->getId()); $trackEntry->setTrackEventTypeId(TrackEntry::TRACK_ENTRY_EVENT_TYPE_UPDATE_ENTRY); $trackEntry->setChangedProperties(implode("\n", $changedProperties)); $trackEntry->setDescription(__METHOD__ . "[" . __LINE__ . "]"); TrackEntry::addTrackEntry($trackEntry); } } return $ret; }
/** * @param entry $entry * @param entry $tempEntry */ public static function replaceEntry(entry $entry, entry $tempEntry = null) { if (!$tempEntry) { $tempEntry = entryPeer::retrieveByPK($entry->getReplacingEntryId()); } if (!$tempEntry) { KalturaLog::err("Temp entry id [" . $entry->getReplacingEntryId() . "] not found"); return; } //Extract all assets of the temp entry $tempAssets = assetPeer::retrieveByEntryId($tempEntry->getId()); //Extract all assets of the existing entry $oldAssets = assetPeer::retrieveByEntryId($entry->getId()); $newAssets = array(); //Loop which creates a mapping between the new assets' paramsId and their type to the asset itself foreach ($tempAssets as $newAsset) { if ($newAsset->getStatus() != asset::FLAVOR_ASSET_STATUS_READY) { KalturaLog::info("Do not add new asset [" . $newAsset->getId() . "] to flavor [" . $newAsset->getFlavorParamsId() . "] status [" . $newAsset->getStatus() . "]"); continue; } //If doesn't exist - create a new array for the current asset's type. if (!isset($newAssets[$newAsset->getType()])) { $newAssets[$newAsset->getType()] = array(); } if ($newAsset->getFlavorParamsId() || $newAsset instanceof flavorAsset) { $newAssets[$newAsset->getType()][$newAsset->getFlavorParamsId()] = $newAsset; KalturaLog::info("Added new asset [" . $newAsset->getId() . "] for asset params [" . $newAsset->getFlavorParamsId() . "]"); } else { $newAssets[$newAsset->getType()]['asset_' . count($newAssets[$newAsset->getType()])] = $newAsset; KalturaLog::info("Added new asset [" . $newAsset->getId() . "] with no asset params"); } } $defaultThumbAssetNew = null; $defaultThumbAssetOld = null; foreach ($oldAssets as $oldAsset) { /* @var $oldAsset asset */ //If the newAssets map contains an asset of the same type and paramsId as the current old asset, // re-link the old asset to the new asset. if (isset($newAssets[$oldAsset->getType()]) && isset($newAssets[$oldAsset->getType()][$oldAsset->getFlavorParamsId()])) { $newAsset = $newAssets[$oldAsset->getType()][$oldAsset->getFlavorParamsId()]; if ($oldAsset->hasTag(assetParams::TAG_RECORDING_ANCHOR)) { $newAsset->addTags(array(assetParams::TAG_RECORDING_ANCHOR)); } /* @var $newAsset asset */ KalturaLog::info("Create link from new asset [" . $newAsset->getId() . "] to old asset [" . $oldAsset->getId() . "] for flavor [" . $oldAsset->getFlavorParamsId() . "]"); $oldAsset->linkFromAsset($newAsset); $oldAsset->save(); self::createFileSyncLinkFromReplacingAsset($oldAsset, $newAsset, asset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); self::createFileSyncLinkFromReplacingAsset($oldAsset, $newAsset, asset::FILE_SYNC_ASSET_SUB_TYPE_ISM); self::createFileSyncLinkFromReplacingAsset($oldAsset, $newAsset, asset::FILE_SYNC_ASSET_SUB_TYPE_ISMC); self::createFileSyncLinkFromReplacingAsset($oldAsset, $newAsset, asset::FILE_SYNC_ASSET_SUB_TYPE_MPD); $newFlavorMediaInfo = mediaInfoPeer::retrieveByFlavorAssetId($newAsset->getId()); if ($newFlavorMediaInfo) { $oldFlavorNewMediaInfo = $newFlavorMediaInfo->copy(); $oldFlavorNewMediaInfo->setFlavorAssetId($oldAsset->getId()); $oldFlavorNewMediaInfo->setFlavorAssetVersion($oldAsset->getVersion()); $oldFlavorNewMediaInfo->save(); } unset($newAssets[$oldAsset->getType()][$oldAsset->getFlavorParamsId()]); if ($oldAsset->hasTag(thumbParams::TAG_DEFAULT_THUMB)) { $defaultThumbAssetNew = $oldAsset; KalturaLog::info("Nominating ThumbAsset [" . $oldAsset->getId() . "] as the default ThumbAsset after replacent"); } } elseif ($oldAsset instanceof flavorAsset || $oldAsset instanceof thumbAsset) { if ($oldAsset instanceof thumbAsset && $oldAsset->keepOnEntryReplacement()) { KalturaLog::info("KeepManualThumbnails ind is set, manual thumbnail is not deleted [" . $oldAsset->getId() . "]"); if ($oldAsset->hasTag(thumbParams::TAG_DEFAULT_THUMB)) { $defaultThumbAssetOld = $oldAsset; } } else { KalturaLog::info("Delete old asset [" . $oldAsset->getId() . "] for paramsId [" . $oldAsset->getFlavorParamsId() . "]"); $oldAsset->setStatus(flavorAsset::FLAVOR_ASSET_STATUS_DELETED); $oldAsset->setDeletedAt(time()); $oldAsset->save(); } } } foreach ($newAssets as $newAssetsByTypes) { foreach ($newAssetsByTypes as $newAsset) { $createdAsset = $newAsset->copyToEntry($entry->getId(), $entry->getPartnerId()); KalturaLog::info("Copied from new asset [" . $newAsset->getId() . "] to copied asset [" . $createdAsset->getId() . "] for flavor [" . $newAsset->getFlavorParamsId() . "]"); if ($createdAsset->hasTag(thumbParams::TAG_DEFAULT_THUMB)) { $defaultThumbAssetNew = $newAsset; KalturaLog::info("Nominating ThumbAsset [" . $newAsset->getId() . "] as the default ThumbAsset after replacent"); } } } if ($defaultThumbAssetOld) { KalturaLog::info("Kepping ThumbAsset [" . $defaultThumbAssetOld->getId() . "] as the default ThumbAsset"); } elseif ($defaultThumbAssetNew) { kBusinessConvertDL::setAsDefaultThumbAsset($defaultThumbAssetNew); KalturaLog::info("Setting ThumbAsset [" . $defaultThumbAssetNew->getId() . "] as the default ThumbAsset"); } else { KalturaLog::info("No default ThumbAsset found for replacing entry [" . $tempEntry->getId() . "]"); $entry->setThumbnail(".jpg"); // thumbnailversion++ $entry->save(); $tempEntrySyncKey = $tempEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB); $realEntrySyncKey = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB); kFileSyncUtils::createSyncFileLinkForKey($realEntrySyncKey, $tempEntrySyncKey); } self::createIsmManifestFileSyncLinkFromReplacingEntry($tempEntry, $entry); $entry->setDimensions($tempEntry->getWidth(), $tempEntry->getHeight()); $entry->setLengthInMsecs($tempEntry->getLengthInMsecs()); $entry->setConversionProfileId($tempEntry->getConversionProfileId()); $entry->setConversionQuality($tempEntry->getConversionQuality()); $entry->setReplacingEntryId(null); $entry->setReplacementStatus(entryReplacementStatus::NONE); $entry->setReplacementOptions(null); $entry->setStatus($tempEntry->getStatus()); $entry->save(); //flush deffered events to re-index sphinx before temp entry deletion kEventsManager::flushEvents(); kBusinessConvertDL::checkForPendingLiveClips($entry); kEventsManager::raiseEvent(new kObjectReplacedEvent($entry, $tempEntry)); myEntryUtils::deleteEntry($tempEntry, null, true); $te = new TrackEntry(); $te->setTrackEventTypeId(TrackEntry::TRACK_ENTRY_EVENT_TYPE_REPLACED_ENTRY); $te->setEntryId($entry->getId()); $te->setParam1Str($tempEntry->getId()); $te->setDescription(__METHOD__ . "[" . __LINE__ . "]"); TrackEntry::addTrackEntry($te); }
/** * @param entry $entry * @param entry $tempEntry */ public static function replaceEntry(entry $entry, entry $tempEntry = null) { KalturaLog::debug("in replaceEntry"); if (!$tempEntry) { $tempEntry = entryPeer::retrieveByPK($entry->getReplacingEntryId()); } if (!$tempEntry) { KalturaLog::err("Temp entry id [" . $entry->getReplacingEntryId() . "] not found"); return; } //Extract all assets of the temp entry $tempAssets = assetPeer::retrieveByEntryId($tempEntry->getId()); //Extract all assets of the existing entry $oldAssets = assetPeer::retrieveByEntryId($entry->getId()); KalturaLog::debug("num of old assets: " . count($oldAssets)); $newAssets = array(); //Loop which creates a mapping between the new assets' paramsId and their type to the asset itself foreach ($tempAssets as $newAsset) { if ($newAsset->getStatus() != asset::FLAVOR_ASSET_STATUS_READY) { KalturaLog::debug("Do not add new asset [" . $newAsset->getId() . "] to flavor [" . $newAsset->getFlavorParamsId() . "] status [" . $newAsset->getStatus() . "]"); continue; } //If doesn't exist - create a new array for the current asset's type. if (!isset($newAssets[$newAsset->getType()])) { $newAssets[$newAsset->getType()] = array(); } if ($newAsset->getFlavorParamsId() || $newAsset instanceof flavorAsset) { $newAssets[$newAsset->getType()][$newAsset->getFlavorParamsId()] = $newAsset; KalturaLog::debug("Added new asset [" . $newAsset->getId() . "] for asset params [" . $newAsset->getFlavorParamsId() . "]"); } else { $newAssets[$newAsset->getType()]['asset_' . count($newAssets[$newAsset->getType()])] = $newAsset; KalturaLog::debug("Added new asset [" . $newAsset->getId() . "] with no asset params"); } } $saveEntry = false; $defaultThumbAssetNew = null; foreach ($oldAssets as $oldAsset) { /* @var $oldAsset asset */ kFileSyncUtils::clearWAMSDataForKey($oldAsset->getSyncKey(asset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET)); //If the newAssets map contains an asset of the same type and paramsId as the current old asset, // re-link the old asset to the new asset. if (isset($newAssets[$oldAsset->getType()]) && isset($newAssets[$oldAsset->getType()][$oldAsset->getFlavorParamsId()])) { $newAsset = $newAssets[$oldAsset->getType()][$oldAsset->getFlavorParamsId()]; /* @var $newAsset asset */ KalturaLog::debug("Create link from new asset [" . $newAsset->getId() . "] to old asset [" . $oldAsset->getId() . "] for flavor [" . $oldAsset->getFlavorParamsId() . "]"); if ($oldAsset instanceof flavorAsset) { $oldAsset->setBitrate($newAsset->getBitrate()); $oldAsset->setFrameRate($newAsset->getFrameRate()); $oldAsset->setVideoCodecId($newAsset->getVideoCodecId()); } $oldAsset->setWidth($newAsset->getWidth()); $oldAsset->setHeight($newAsset->getHeight()); $oldAsset->setContainerFormat($newAsset->getContainerFormat()); $oldAsset->setSize($newAsset->getSize()); $oldAsset->setFileExt($newAsset->getFileExt()); $oldAsset->setTags($newAsset->getTags()); $oldAsset->setDescription($newAsset->getDescription()); $oldAsset->incrementVersion(); $oldAsset->setStatusLocalReady(); $oldAsset->save(); $oldFileSync = $oldAsset->getSyncKey(asset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $newFileSync = $newAsset->getSyncKey(asset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); kFileSyncUtils::createSyncFileLinkForKey($oldFileSync, $newFileSync); $newFlavorMediaInfo = mediaInfoPeer::retrieveByFlavorAssetId($newAsset->getId()); if ($newFlavorMediaInfo) { $oldFlavorNewMediaInfo = $newFlavorMediaInfo->copy(); $oldFlavorNewMediaInfo->setFlavorAssetId($oldAsset->getId()); $oldFlavorNewMediaInfo->setFlavorAssetVersion($oldAsset->getVersion()); $oldFlavorNewMediaInfo->save(); } unset($newAssets[$oldAsset->getType()][$oldAsset->getFlavorParamsId()]); if ($oldAsset->hasTag(thumbParams::TAG_DEFAULT_THUMB)) { $defaultThumbAssetNew = $oldAsset; KalturaLog::debug("Nominating ThumbAsset [" . $oldAsset->getId() . "] as the default ThumbAsset after replacent"); } } elseif ($oldAsset instanceof flavorAsset || $oldAsset instanceof thumbAsset) { KalturaLog::debug("Delete old asset [" . $oldAsset->getId() . "] for paramsId [" . $oldAsset->getFlavorParamsId() . "]"); $oldAsset->setStatus(flavorAsset::ASSET_STATUS_DELETED); $oldAsset->setDeletedAt(time()); $oldAsset->save(); $entry->removeFlavorParamsId($oldAsset->getFlavorParamsId()); $saveEntry = true; } } foreach ($newAssets as $newAssetsByTypes) { foreach ($newAssetsByTypes as $newAsset) { $createdAsset = $newAsset->copyToEntry($entry->getId(), $entry->getPartnerId()); KalturaLog::debug("Copied from new asset [" . $newAsset->getId() . "] to copied asset [" . $createdAsset->getId() . "] for flavor [" . $newAsset->getFlavorParamsId() . "]"); if ($createdAsset->hasTag(thumbParams::TAG_DEFAULT_THUMB)) { $defaultThumbAssetNew = $newAsset; KalturaLog::debug("Nominating ThumbAsset [" . $newAsset->getId() . "] as the default ThumbAsset after replacent"); } } } if ($defaultThumbAssetNew) { kBusinessConvertDL::setAsDefaultThumbAsset($defaultThumbAssetNew); kalturalog::debug("Setting ThumbAsset [" . $defaultThumbAssetNew->getId() . "] as the default ThumbAsset"); } else { kalturalog::debug("No default ThumbAsset found for replacing entry [" . $tempEntry->getId() . "]"); $entry->setThumbnail(".jpg"); // thumbnailversion++ $entry->save(); $tempEntrySyncKey = $tempEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB); $realEntrySyncKey = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB); kFileSyncUtils::createSyncFileLinkForKey($realEntrySyncKey, $tempEntrySyncKey); } $entry->setDimensions($tempEntry->getWidth(), $tempEntry->getHeight()); $entry->setLengthInMsecs($tempEntry->getLengthInMsecs()); $entry->setConversionProfileId($tempEntry->getConversionProfileId()); $entry->setConversionQuality($tempEntry->getConversionQuality()); $entry->setReplacingEntryId(null); $entry->setReplacementStatus(entryReplacementStatus::NONE); $entry->setStatus($tempEntry->getStatus()); $entry->save(); myEntryUtils::deleteEntry($tempEntry, null, true); $te = new TrackEntry(); $te->setTrackEventTypeId(TrackEntry::TRACK_ENTRY_EVENT_TYPE_REPLACED_ENTRY); $te->setEntryId($entry->getId()); $te->setParam1Str($tempEntry->getId()); $te->setDescription(__METHOD__ . "[" . __LINE__ . "]"); TrackEntry::addTrackEntry($te); }
/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param TrackEntry $value A TrackEntry object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool(TrackEntry $obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getId(); } // if key === null self::$instances[$key] = $obj; } }
private function handleEntry($onlyExtractThumb, $prefix, $type, $entry_id, $name = null, $tags = null, $entry = null) { KalturaLog::debug("handleEntry({$type}, {$entry_id}, {$name})"); $this->clear($prefix, $entry_id); $kuser_id = $this->kuser_id; $entry_data_prefix = $kuser_id . '_' . ($prefix == '' ? 'data' : rtrim($prefix, '_')); $uploads = myContentStorage::getFSUploadsPath(); $content = myContentStorage::getFSContentRootPath(); $media_source = $this->getParam('entry_media_source'); $media_type = $this->getParam('entry_media_type'); $entry_url = $this->getParam('entry_url'); $entry_source_link = $this->getParam('entry_source_link'); $entry_fileName = $this->getParam('entry_data'); $entry_thumbNum = $this->getParam('entry_thumb_num', 0); $entry_thumbUrl = $this->getParam('entry_thumb_url', ''); $should_copy = $this->getParam('should_copy', false); $skip_conversion = $this->getParam('skip_conversion', false); $webcam_suffix = $this->getParam('webcam_suffix', ''); $duration = $this->getParam('duration', null); $entry_fullPath = ""; $ext = null; $entry = null; if ($entry_id) { $entry = entryPeer::retrieveByPK($entry_id); } else { $entry = new entry(); } $this->entry = $entry; $entry_status = $entry->getStatus(); if (is_null($entry_status)) { $entry_status = entryStatus::READY; } // by the end of this block of code $entry_fullPath will point to the location of the entry // the entry status will be set (IMPORT / PRECONVERT / READY) // a background image is always previewed by the user no matter what source he used // so the entry is already in the /uploads directory // continue tracking the file upload $te = new TrackEntry(); $te->setEntryId($entry_id); $te->setTrackEventTypeId(TrackEntry::TRACK_ENTRY_EVENT_TYPE_ADD_ENTRY); KalturaLog::debug("handleEntry: media_source: {$media_source}, prefix: {$prefix}"); if ($media_source == entry::ENTRY_MEDIA_SOURCE_FILE || $prefix == 'bg_') { $full_path = $this->getParam('entry_full_path'); if ($full_path) { $entry_fullPath = $full_path; } else { $entry_fullPath = $uploads . $entry_data_prefix . strrchr($entry_fileName, '.'); } if ($media_type == entry::ENTRY_MEDIA_TYPE_VIDEO || $media_type == entry::ENTRY_MEDIA_TYPE_AUDIO) { $entry_status = entryStatus::PRECONVERT; } $te->setParam3Str($entry_fullPath); $te->setDescription(__METHOD__ . ":" . __LINE__ . "::ENTRY_MEDIA_SOURCE_FILE"); } else { if ($media_source == entry::ENTRY_MEDIA_SOURCE_WEBCAM) { // set $entry_fileName to webcam output file and flag that conversion is not needed $webcam_basePath = $content . '/content/webcam/' . ($webcam_suffix ? $webcam_suffix : 'my_recorded_stream_' . $kuser_id); $entry_fullPath = $webcam_basePath . '.' . kWAMSWebcam::OUTPUT_FILE_EXT; $ext = kWAMSWebcam::OUTPUT_FILE_EXT; if (file_exists($entry_fullPath)) { // continue tracking the webcam $te->setParam3Str($entry_fullPath); $te->setDescription(__METHOD__ . ":" . __LINE__ . "::ENTRY_MEDIA_SOURCE_WEBCAM"); } else { KalturaLog::err("File [{$entry_fullPath}] does not exist"); $entry_status = entryStatus::ERROR_IMPORTING; } } else { // if the url ends with .ext, we'll extract it this way $urlext = strrchr($entry_url, '.'); // TODO: fix this patch if (strlen($urlext) > 4) { $urlext = '.jpg'; } // if we got something wierd, assume we're downloading a jpg $entry_fileName = $entry_data_prefix . $urlext; KalturaLog::debug("handleEntry: media_type: {$media_type}"); if ($media_type == entry::ENTRY_MEDIA_TYPE_IMAGE) { $duration = 0; $entry_fullPath = $uploads . $entry_fileName; if (!kFile::downloadUrlToFile($entry_url, $entry_fullPath)) { KalturaLog::debug("Failed downloading file[{$entry_url}]"); $entry_status = entryStatus::ERROR_IMPORTING; } // track images $te->setParam3Str($entry_fullPath); $te->setDescription(__METHOD__ . ":" . __LINE__ . "::ENTRY_MEDIA_SOURCE_URL:ENTRY_MEDIA_TYPE_IMAGE"); } else { if ($media_type == entry::ENTRY_MEDIA_TYPE_VIDEO) { //fixme - we can extract during import $ext = "flv"; } else { $ext = "mp3"; } $entry_status = entryStatus::IMPORT; // track images $te->setParam3Str($ext); $te->setDescription(__METHOD__ . ":" . __LINE__ . "::ENTRY_MEDIA_SOURCE_URL:ENTRY_MEDIA_TYPE_VIDEO"); } } } if ($ext == null) { $entry_fullPathTmp = $entry_fullPath; $qpos = strpos($entry_fullPathTmp, "?"); if ($qpos !== false) { $entry_fullPathTmp = substr($entry_fullPathTmp, 0, $qpos); } $ext = strtolower(pathinfo($entry_fullPathTmp, PATHINFO_EXTENSION)); } // save the Trackentry TrackEntry::addTrackEntry($te); KalturaLog::debug("handleEntry: ext: {$ext}"); // We don't want to reject entries based on file extentions anumore // Remarked by Tan-Tan // // if ($entry_status == entryStatus::PRECONVERT && !myContentStorage::fileExtNeedConversion($ext)) // { // // $this->errorMsg = "insertEntryAction Error - PRECONVERT file type not acceptable ($ext)"; // KalturaLog::debug("handleEntry: err: $this->errorMsg"); // if(is_null($entry) && $this->entry_id) // { // $entry = entryPeer::retrieveByPK($this->entry_id); // } // if($entry) // { // $entry->setStatus(entryStatus::ERROR_CONVERTING); // $entry->save(); // } // return false; // } $media_date = null; // We don't want to reject entries based on file extentions anumore // Remarked by Tan-Tan // // // if entry is ready, validate file type (webcam is an exception since we control the file type - flv) // if ($entry_status == entryStatus::READY && // $media_source != entry::ENTRY_MEDIA_SOURCE_WEBCAM && !myContentStorage::fileExtAccepted($ext)) // { // $this->errorMsg = "insertEntryAction Error - READY file type not acceptable ($ext)"; // KalturaLog::debug("handleEntry: err: $this->errorMsg"); // if(is_null($entry) && $this->entry_id) // { // $entry = entryPeer::retrieveByPK($this->entry_id); // } // if($entry) // { // $entry->setStatus(entryStatus::ERROR_CONVERTING); // $entry->save(); // } // return false; // } if ($entry_status == entryStatus::ERROR_IMPORTING) { $need_thumb = false; // we wont be needing a thumb for an errornous entry KalturaLog::debug("handleEntry: error importing, thumb not needed"); } else { // thumbs are created by one of the following ways: // 1. Image - images are already on disk for every selection method, so we can just create a thumb // 2. Audio - no thumb is needed // 3. Video - // a. uploaded (file / webcam) - file is on disk and the user already selected a thumb // b. imported - the source site had a thumbnail and we'll use it $thumbTempPrefix = $uploads . $entry_data_prefix . '_thumbnail_'; $thumbBigFullPath = null; $need_thumb = $type == entryType::MEDIA_CLIP; KalturaLog::debug("handleEntry: handling media {$media_type}"); if ($media_type == entry::ENTRY_MEDIA_TYPE_IMAGE) { // fetch media creation date $exif_image_type = @exif_imagetype($entry_fullPath); if ($exif_image_type == IMAGETYPE_JPEG || $exif_image_type == IMAGETYPE_TIFF_II || $exif_image_type == IMAGETYPE_TIFF_MM || $exif_image_type == IMAGETYPE_IFF || $exif_image_type == IMAGETYPE_PNG) { $exif_data = @exif_read_data($entry_fullPath); if ($exif_data && isset($exif_data["DateTimeOriginal"]) && $exif_data["DateTimeOriginal"]) { $media_date = $exif_data["DateTimeOriginal"]; $ts = strtotime($media_date); // handle invalid dates either due to bad format or out of range if ($ts === -1 || $ts === false || $ts < strtotime('2000-01-01') || $ts > strtotime('2015-01-01')) { $media_date = null; } } } // create thumb $thumbFullPath = $thumbTempPrefix . '1.jpg'; $entry_thumbNum = 1; $need_thumb = true; //copy($entry_fullPath, $thumbFullPath); myFileConverter::createImageThumbnail($entry_fullPath, $thumbFullPath, "image2"); //$thumbBigFullPath = $thumbFullPath; // no filesync for thumbnail of image } else { if ($media_type == entry::ENTRY_MEDIA_TYPE_VIDEO) { if ($entry_status == entryStatus::IMPORT || $media_source == entry::ENTRY_MEDIA_SOURCE_URL) { // import thumb and convert to our size $thumbFullPath = $thumbTempPrefix . '1.jpg'; $entry_thumbNum = 1; $importedThumbPath = $uploads . $entry_data_prefix . '_temp_thumb' . strrchr($entry_thumbUrl, '.'); if (kFile::downloadUrlToFile($entry_thumbUrl, $importedThumbPath)) { myFileConverter::createImageThumbnail($importedThumbPath, $thumbFullPath, "image2"); // set thumb as big thumb so fileSync will be created. $thumbBigFullPath = $thumbFullPath; } else { $need_thumb = false; } } else { if ($entry_thumbNum == 0) { $entry_thumbNum = 1; $thumbTime = 3; if ($duration && $duration < $thumbTime * 1000) { $thumbTime = floor($duration / 1000); } // for videos - thumbail should be created in post convert // otherwise this code will fail if the thumbanil wasn't created successfully (roman) //myFileConverter::autoCaptureFrame($entry_fullPath, $thumbTempPrefix."big_", $thumbTime, -1, -1); $need_thumb = false; $thumbBigFullPath = $thumbTempPrefix . "big_" . $entry_thumbNum . '.jpg'; } } //else select existing thumb ($entry_thumbNum already points to the right thumbnail) } } $thumbFullPath = $thumbTempPrefix . $entry_thumbNum . '.jpg'; // if we arrived here both entry and thumbnail are valid we can now update the db // in order to have the final entry_id and move its data to its final destination if ($onlyExtractThumb) { return $thumbFullPath; } } $entry->setkshowId($this->kshow_id); $entry->setKuserId($kuser_id); $entry->setCreatorKuserId($kuser_id); if ($this->partner_id != null) { $entry->setPartnerId($this->partner_id); $entry->setSubpId($this->subp_id); } $entry->setName($name ? $name : $this->getParam('entry_name')); // $entry->setDescription('');//$this->getParam('entry_description')); $entry->setType($type); $entry->setMediaType($media_type); $entry->setTags($tags ? $tags : $this->getParam('entry_tags')); $entry->setSource($media_source); $entry->setSourceId($this->getParam('entry_media_id')); if ($media_date) { $entry->setMediaDate($media_date); } // if source_link wasnt given use the entry_url HOWEVER, use it only if id doesnt contain @ which suggests the use of a password $entry->setSourceLink($entry_source_link ? $entry_source_link : (strstr($entry_url, '@') ? "" : $entry_url)); if ($media_source == entry::ENTRY_MEDIA_SOURCE_FILE) { $entry->setSourceLink("file:{$entry_fullPath}"); } $entry->setLicenseType($this->getParam('entry_license')); $entry->setCredit($this->getParam('entry_credit')); $entry->setStatus($entry_status); if ($duration !== null) { $entry->setLengthInMsecs($duration); } if ($this->entry_id == 0) { $entry->save(); $this->entry_id = $entry->getId(); } // move thumb to final destination and set db entry if ($media_type != entry::ENTRY_MEDIA_TYPE_AUDIO && $entry_thumbNum && $need_thumb) { KalturaLog::debug("handleEntry: saving none audio thumb [{$thumbBigFullPath}]"); $entry->setThumbnail('.jpg'); if ($thumbBigFullPath) { if ($media_type != entry::ENTRY_MEDIA_TYPE_IMAGE) { myFileConverter::convertImage($thumbBigFullPath, $thumbFullPath); } /*$thumbBigFinalPath = $content.$entry->getBigThumbnailPath(); myContentStorage::moveFile($thumbBigFullPath, $thumbBigFinalPath, true , $should_copy ); */ $entryThumbKey = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB); try { if (!$should_copy) { kFileSyncUtils::moveFromFile($thumbBigFullPath, $entryThumbKey); } else { kFileSyncUtils::copyFromFile($thumbBigFullPath, $entryThumbKey); } } catch (Exception $e) { $entry->setStatus(entryStatus::ERROR_CONVERTING); $entry->save(); throw $e; } } } // after extracting the thumb we can move the entry to its next destination KalturaLog::debug("handleEntry: current status [" . $entry->getStatus() . "]"); // if needed a job will be submitted for importing external media sources if ($entry->getStatus() == entryStatus::IMPORT) { KalturaLog::debug("handleEntry: creating import job"); // changed by Tan-Tan, Nov 09 to support the new batch mechanism kJobsManager::addImportJob(null, $this->entry_id, $this->partner_id, $entry_url); // remarked by Tan-Tan // $entry_fullPath = $content.'/content/imports/data/'.$this->entry_id.".".$ext; // myContentStorage::fullMkdir($entry_fullPath); // // $batchClient = new myBatchUrlImportClient(); // $batchClient->addJob($this->entry_id, $entry_url, $entry_fullPath); } else { if ($entry->getStatus() == entryStatus::PRECONVERT) { if (!$skip_conversion) { // changed by Tan-Tan, Dec 09 to support the new batch mechanism KalturaLog::debug("handleEntry: creating original flavor asset for pre convert"); $flavorAsset = kFlowHelper::createOriginalFlavorAsset($this->partner_id, $this->entry_id); if ($flavorAsset) { $flavorAsset->setFileExt($ext); $flavorAsset->save(); $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); try { kFileSyncUtils::moveFromFile($entry_fullPath, $syncKey); } catch (Exception $e) { $entry->setStatus(entryStatus::ERROR_CONVERTING); $flavorAsset->setStatus(flavorAsset::FLAVOR_ASSET_STATUS_ERROR); $entry->save(); $flavorAsset->save(); throw $e; } kEventsManager::raiseEvent(new kObjectAddedEvent($flavorAsset)); } else { $entry->setStatus(entryStatus::ERROR_CONVERTING); } // Remarked by Tan-Tan // $targetFileName = $this->entry_id.".".$ext; // if ( false /* old conversion */) // { // // if we need to convert move entry to conversion directory // $preConvPath = $content.'/content/preconvert/'; // myContentStorage::moveFile($entry_fullPath, $preConvPath."data/".$targetFileName, true , $should_copy ); // // $signalFilePath = $preConvPath."files/".$targetFileName; // myContentStorage::fullMkdir($signalFilePath); // touch($signalFilePath); // } // else // { // $preConvPath = myContentStorage::getFSContentRootPath (). "/content/new_preconvert"; // $to_data = $preConvPath . "/$targetFileName" ; // myContentStorage::moveFile($entry_fullPath, $to_data , true); // touch ( $to_data . ".indicator" ); // } } } else { if ($entry->getStatus() == entryStatus::PENDING || $media_source == entry::ENTRY_MEDIA_SOURCE_WEBCAM) { $entry->setData($entry_fullPath); $entry->save(); if ($media_type == entry::ENTRY_MEDIA_TYPE_VIDEO || $media_type == entry::ENTRY_MEDIA_TYPE_AUDIO) { KalturaLog::debug("handleEntry: creating original flavor asset for ready entry"); $flavorAsset = kFlowHelper::createOriginalFlavorAsset($this->partner_id, $this->entry_id); if ($flavorAsset) { $ext = pathinfo($entry_fullPath, PATHINFO_EXTENSION); $flavorAsset->setFileExt($ext); $flavorAsset->save(); $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); try { if (!$should_copy) { kFileSyncUtils::moveFromFile($entry_fullPath, $syncKey); } else { // copy & create file sync from $entry_fullPath kFileSyncUtils::copyFromFile($entry_fullPath, $syncKey); } } catch (Exception $e) { $entry->setStatus(entryStatus::ERROR_CONVERTING); $flavorAsset->setStatus(flavorAsset::FLAVOR_ASSET_STATUS_ERROR); $entry->save(); $flavorAsset->save(); throw $e; } // // bypass to conversion // kBusinessPreConvertDL::bypassConversion($flavorAsset, $entry); /** * if this is webcam entry, create mediaInfo for the source flavor asset synchronously * since entry is ready right at the beginning */ if ($media_source == entry::ENTRY_MEDIA_SOURCE_WEBCAM) { require_once SF_ROOT_DIR . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "api_v3" . DIRECTORY_SEPARATOR . "bootstrap.php"; // extract file path $sourceFileKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $sourceFilePath = kFileSyncUtils::getLocalFilePathForKey($sourceFileKey); // call mediaInfo for file $mediaInfo = new mediaInfo(); try { $mediaInfoParser = new KMediaInfoMediaParser($sourceFilePath, kConf::get('bin_path_mediainfo')); $KalturaMediaInfo = new KalturaMediaInfo(); $KalturaMediaInfo = $mediaInfoParser->getMediaInfo(); $mediaInfo = $KalturaMediaInfo->toInsertableObject($mediaInfo); $mediaInfo->setFlavorAssetId($flavorAsset->getId()); $mediaInfo->save(); } catch (Exception $e) { KalturaLog::err("Getting media info: " . $e->getMessage()); $mediaInfo = null; } // fix flavor asset according to mediainfo if ($mediaInfo) { KDLWrap::ConvertMediainfoCdl2FlavorAsset($mediaInfo, $flavorAsset); $flavorTags = KDLWrap::CDLMediaInfo2Tags($mediaInfo, array(flavorParams::TAG_WEB, flavorParams::TAG_MBR)); $flavorAsset->setTags(implode(',', $flavorTags)); } $flavorAsset->save(); } kEventsManager::raiseEvent(new kObjectAddedEvent($flavorAsset)); $flavorAsset->setStatusLocalReady(); $flavorAsset->save(); } else { $entry->setStatus(entryStatus::ERROR_IMPORTING); } } else { if ($entry->getType() == entryType::DOCUMENT) { //TODO: document should be handled by the plugin manager) KalturaLog::debug("handleEntry: creating original flavor asset for ready entry"); $flavorAsset = kFlowHelper::createOriginalFlavorAsset($this->partner_id, $this->entry_id); if ($flavorAsset) { $ext = pathinfo($entry_fullPath, PATHINFO_EXTENSION); $flavorAsset->setFileExt($ext); $flavorAsset->save(); $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); try { if (!$should_copy) { kFileSyncUtils::moveFromFile($entry_fullPath, $syncKey); } else { // copy & create file sync from $entry_fullPath kFileSyncUtils::copyFromFile($entry_fullPath, $syncKey); } } catch (Exception $e) { $entry->setStatus(entryStatus::ERROR_CONVERTING); $flavorAsset->setStatus(flavorAsset::FLAVOR_ASSET_STATUS_ERROR); $entry->save(); $flavorAsset->save(); throw $e; } kEventsManager::raiseEvent(new kObjectAddedEvent($flavorAsset)); } } else { KalturaLog::debug("handleEntry: creating data file sync for file [{$entry_fullPath}]"); $entryDataKey = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA); if (!kFileSyncUtils::file_exists($entryDataKey)) { try { if (!$should_copy) { kFileSyncUtils::moveFromFile($entry_fullPath, $entryDataKey); } else { // copy & create file sync from $entry_fullPath kFileSyncUtils::copyFromFile($entry_fullPath, $entryDataKey); } } catch (Exception $e) { $entry->setStatus(entryStatus::ERROR_CONVERTING); $entry->save(); throw $e; } } $entry->setStatus(entryStatus::READY); $entry->save(); } } // Remarked by Tan-Tan, the flavor asset should be synced instead of the entry // // $entryDataKey = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA); // if(!$should_copy) // { // kFileSyncUtils::moveFromFile($entry_fullPath, $entryDataKey); // } // else // { // // copy & create file sync from $entry_fullPath // kFileSyncUtils::copyFromFile($entry_fullPath, $entryDataKey); // } } } } if ($entry->getStatus() == entryStatus::READY) { $entry->updateDimensions(); } $entry->save(); return true; }
/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param TrackEntry $value A TrackEntry object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool(TrackEntry $obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getId(); } if (isset(self::$instances[$key]) || count(self::$instances) < kConf::get('max_num_instances_in_pool')) { self::$instances[$key] = $obj; kMemoryManager::registerPeer('TrackEntryPeer'); } } }
public static function addTrackEntry(TrackEntry $te) { // can be switched of once we decide this is not needed if (true) { if (!$te->getKs()) { $te->setKs(kCurrentContext::$ks); } if (!$te->getPartnerId()) { $te->setPartnerId(kCurrentContext::$partner_id); } if (!$te->getPsVersion()) { $te->setPsVersion(kCurrentContext::$ps_vesion); } if (!$te->getHostName()) { $te->setHostName(kCurrentContext::$host); } if (!$te->getUid()) { $te->setUid(kCurrentContext::$uid); } if (!$te->getUserIp()) { $te->setUserIp(kCurrentContext::$user_ip); } $te->setContext(kCurrentContext::$client_version . "|" . kCurrentContext::$client_lang . "|" . kCurrentContext::$service . "|" . kCurrentContext::$action); $te->setSessionId((string) new UniqueId()); $te->save(); } }
/** * Adds track entry for investigations */ protected function addTrackEntry() { $te = new TrackEntry(); $te->setTrackEventTypeId(TrackEntry::TRACK_ENTRY_EVENT_TYPE_UPLOADED_FILE); $te->setParam1Str($this->_uploadToken->getId()); $te->setParam2Str($this->_uploadToken->getFileName()); $te->setParam3Str($this->_uploadToken->getUploadTempPath()); $te->setDescription(__METHOD__ . ":" . __LINE__); TrackEntry::addTrackEntry($te); }
public function postUpdate(PropelPDO $con = null) { if (!$this->wasObjectSaved()) { return; } if ($this->alreadyInSave) { return parent::postUpdate($con); } $objectUpdated = $this->isModified(); $objectDeleted = false; if ($this->isColumnModified(entryPeer::STATUS) && $this->getStatus() == entryStatus::DELETED) { $objectDeleted = true; } if ($this->isColumnModified(entryPeer::DATA) && $this->getMediaType() == entry::ENTRY_MEDIA_TYPE_IMAGE) { $partner = $this->getPartner(); if ($partner) { $dataArr = explode('.', $this->getData()); $id = $this->getId(); if ($id == $partner->getAudioThumbEntryId()) { $partner->setAudioThumbEntryVersion($dataArr[0]); $partner->save(); } if ($id == $partner->getLiveThumbEntryId()) { $partner->setLiveThumbEntryVersion($dataArr[0]); $partner->save(); } } } $trackColumns = $this->getTrackColumns(); $changedProperties = array(); foreach ($trackColumns as $namespace => $trackColumn) { if (is_array($trackColumn)) { if (isset($this->oldCustomDataValues[$namespace])) { foreach ($trackColumn as $trackCustomData) { if (isset($this->oldCustomDataValues[$namespace][$trackCustomData])) { $column = $trackCustomData; if ($namespace) { $column = "{$namespace}.{$trackCustomData}"; } $previousValue = $this->oldCustomDataValues[$namespace][$trackCustomData]; $previousValue = is_scalar($previousValue) ? $previousValue : $this->getTrackEntryString($namespace, $trackCustomData, $previousValue); $newValue = $this->getFromCustomData($trackCustomData, $namespace); $newValue = is_scalar($newValue) ? $newValue : $this->getTrackEntryString($namespace, $trackCustomData, $newValue); $changedProperties[] = "{$column} [{$previousValue}]->[{$newValue}]"; } } } } elseif ($this->isColumnModified($trackColumn)) { $column = entryPeer::translateFieldName($trackColumn, BasePeer::TYPE_COLNAME, BasePeer::TYPE_STUDLYPHPNAME); $previousValue = $this->getColumnsOldValue($trackColumn); $newValue = $this->getByName($trackColumn, BasePeer::TYPE_COLNAME); $changedProperties[] = "{$column} [{$previousValue}]->[{$newValue}]"; } } if ($this->getRedirectEntryId() && array_key_exists('', $this->oldCustomDataValues) && array_key_exists('redirectEntryId', $this->oldCustomDataValues[''])) { $redirectEntry = entryPeer::retrieveByPK($this->getRedirectEntryId()); if ($redirectEntry) { $redirectEntry->setModerationStatus($this->getModerationStatus()); $redirectEntry->save(); } } $ret = parent::postUpdate($con); if ($objectDeleted) { kEventsManager::raiseEvent(new kObjectDeletedEvent($this)); myStatisticsMgr::deleteEntry($this); $trackEntry = new TrackEntry(); $trackEntry->setEntryId($this->getId()); $trackEntry->setTrackEventTypeId(TrackEntry::TRACK_ENTRY_EVENT_TYPE_DELETED_ENTRY); $trackEntry->setChangedProperties(implode("\n", $changedProperties)); $trackEntry->setDescription(__METHOD__ . "[" . __LINE__ . "]"); TrackEntry::addTrackEntry($trackEntry); //In case this entry has sub streams assigned to it we should delete them as well $subStreamEntries = entryPeer::retrieveChildEntriesByEntryIdAndPartnerId($this->id, $this->partner_id); foreach ($subStreamEntries as $subStreamEntry) { myEntryUtils::deleteEntry($subStreamEntry); } } if ($objectUpdated) { kEventsManager::raiseEvent(new kObjectUpdatedEvent($this)); if (!$objectDeleted && count($changedProperties)) { $trackEntry = new TrackEntry(); $trackEntry->setEntryId($this->getId()); $trackEntry->setTrackEventTypeId(TrackEntry::TRACK_ENTRY_EVENT_TYPE_UPDATE_ENTRY); $trackEntry->setChangedProperties(implode("\n", $changedProperties)); $trackEntry->setDescription(__METHOD__ . "[" . __LINE__ . "]"); TrackEntry::addTrackEntry($trackEntry); } } return $ret; }
public function save(PropelPDO $con = null) { $is_new = false; if ($this->isNew()) { $this->setId(self::calculateId()); // start by setting the modified_at to the current time $this->setModifiedAt(time()); $this->setModerationCount(0); if (is_null($this->getAccessControlId())) { $partner = $this->getPartner(); if ($partner) { $this->setAccessControlId($partner->getDefaultAccessControlId()); } } // only media clips should increments - not roughcuts or backgrounds if ($this->type == entryType::MEDIA_CLIP) { myStatisticsMgr::addEntry($this); } $is_new = true; } if ($this->isColumnModified(entryPeer::STATUS) && $this->previous_status != $this->getStatus()) { // add a track for when the status changed $track_entry = new TrackEntry(); $track_entry->setEntryId($this->getId()); $track_entry->setTrackEventTypeId(TrackEntry::TRACK_ENTRY_EVENT_TYPE_UPDATE_ENTRY); $track_entry->setChangedProperties("status [{$this->previous_status}]->[{$this->getStatus()}]"); if ($this->previous_status != entryStatus::DELETED && $this->getStatus() == entryStatus::DELETED) { myStatisticsMgr::deleteEntry($this); $track_entry->setTrackEventTypeId(TrackEntry::TRACK_ENTRY_EVENT_TYPE_DELETED_ENTRY); } TrackEntry::addTrackEntry($track_entry); } if ($this->type == entryType::MIX) { // some of the properties should be copied to the kshow $kshow = $this->getkshow(); if ($kshow) { $modified = false; if ($kshow->getRank() != $this->getRank()) { $kshow->setRank($this->getRank()); $modified = true; } if ($kshow->getLengthInMsecs() != $this->getLengthInMsecs()) { $kshow->setLengthInMsecs($this->getLengthInMsecs()); $modified = true; } if ($modified) { $kshow->save(); } } else { $this->log("entry [" . $this->getId() . "] does not have a real kshow with id [" . $this->getKshowId() . "]", Propel::LOG_WARNING); } } myPartnerUtils::setPartnerIdForObj($this); if ($this->getType() != entryType::PLAYLIST) { mySearchUtils::setDisplayInSearch($this); } mySearchUtils::setSearchTextDiscreteForEntry($this); // update the admin_tags per partner ktagword::updateAdminTags($this); // same for puserId ... $this->getPuserId(true); // make sure this entry is saved before calling updateAllMetadataVersionsRelevantForEntry, since fixMetadata retrieves the entry from the DB // and checks its data path which was modified above. $res = parent::save($con); if ($is_new) { // when retrieving the entry - ignore thr filter - when in partner has moderate_content =1 - the entry will have status=3 and will fail the retrieveByPk entryPeer::setUseCriteriaFilter(false); $obj = entryPeer::retrieveByPk($this->getId()); $this->setIntId($obj->getIntId()); entryPeer::setUseCriteriaFilter(true); } if ($this->should_call_set_data_content) { // calling the funciton with null will cause it to use the $this->data_content $this->setDataContent(null); $res = parent::save($con); } // the fix should be done whether the status is READY or ERROR_CONVERTING if ($this->getStatus() == entryStatus::READY || $this->getStatus() == entryStatus::ERROR_CONVERTING) { // fire some stuff due to the new status $version_to_update = $this->getUpdateWhenReady(); if ($version_to_update) { try { myMetadataUtils::updateAllMetadataVersionsRelevantForEntry($this); $this->resetUpdateWhenReady(); $res = parent::save($con); } catch (Exception $e) { KalturaLog::err($e->getMessage()); } } } $this->syncCategories(); return $res; }