Exemplo n.º 1
0
 /**
  * @param entry $object
  * @return bool true if should continue to the next consumer
  */
 public function entryCreated(entry $object)
 {
     $mediaType = null;
     if ($object->getType() == entryType::AUTOMATIC) {
         KalturaLog::debug("entry id [" . $object->getId() . "] type [" . $object->getType() . "] source link [" . $object->getSourceLink() . "]");
         $mediaType = $object->getMediaType();
         if (isset(self::$fileExtensions[$mediaType])) {
             $object->setType(entryType::DOCUMENT);
         } elseif (is_null($mediaType) || $mediaType == entry::ENTRY_MEDIA_TYPE_ANY || $mediaType == entry::ENTRY_MEDIA_TYPE_AUTOMATIC) {
             $this->setDocumentType($object);
         }
     }
     if ($object->getType() != entryType::DOCUMENT) {
         KalturaLog::debug("entry id [" . $object->getId() . "] type [" . $object->getType() . "]");
         return true;
     }
     if (is_null($mediaType) || $mediaType == entry::ENTRY_MEDIA_TYPE_ANY || $mediaType == entry::ENTRY_MEDIA_TYPE_AUTOMATIC) {
         $this->setDocumentType($object);
     }
     if ($object instanceof DocumentEntry) {
         KalturaLog::debug("entry id [" . $object->getId() . "] already handled");
         return true;
     }
     KalturaLog::debug("Handling object [" . get_class($object) . "] type [" . $object->getType() . "] id [" . $object->getId() . "] status [" . $object->getStatus() . "]");
     if ($object->getConversionProfileId()) {
         $object->setStatus(entryStatus::PRECONVERT);
         $object->save();
     }
     return true;
 }
 /**
  * @return kManifestRenderer
  */
 private function serveHttp()
 {
     if ($this->entry->getType() != entryType::MEDIA_CLIP) {
         KExternalErrors::dieError(KExternalErrors::INVALID_ENTRY_TYPE);
     }
     switch ($this->entry->getType()) {
         case entryType::MEDIA_CLIP:
             switch ($this->entry->getMediaType()) {
                 case entry::ENTRY_MEDIA_TYPE_IMAGE:
                     // TODO - create sequence manifest
                     break;
                 case entry::ENTRY_MEDIA_TYPE_VIDEO:
                 case entry::ENTRY_MEDIA_TYPE_AUDIO:
                     $flavors = $this->buildHttpFlavorsArray($duration, true);
                     $renderer = new kF4MManifestRenderer();
                     $renderer->entryId = $this->entryId;
                     $renderer->tokenizer = $this->tokenizer;
                     $renderer->flavors = $flavors;
                     $renderer->duration = $duration;
                     $renderer->mimeType = $this->getMimeType($flavors);
                     return $renderer;
             }
         default:
             break;
     }
     KExternalErrors::dieError(KExternalErrors::INVALID_ENTRY_TYPE);
 }
Exemplo n.º 3
0
 /**
  * Executes addComment action, which returns a form enabling the insertion of a comment
  * The request may include 1 fields: entry id.
  */
 protected function executeImpl(kshow $kshow, entry &$entry)
 {
     $version = @$_REQUEST["version"];
     // it's a path on the disk
     if (kString::beginsWith($version, ".")) {
         // someone is trying to hack in the system
         return sfView::ERROR;
     }
     // in case we're making a roughcut out of a regular invite, we start from scratch
     if ($entry->getMediaType() != entry::ENTRY_MEDIA_TYPE_SHOW || $entry->getDataPath($version) === null) {
         $this->xml_content = "<xml></xml>";
         return;
     }
     // fetch content of file from disk - it should hold the XML
     $file_name = myContentStorage::getFSContentRootPath() . "/" . $entry->getDataPath($version);
     //echo "[$file_name]";
     if (kString::endsWith($file_name, "xml")) {
         if (file_exists($file_name)) {
             $this->xml_content = kFile::getFileContent($file_name);
             //	echo "[" . $this->xml_content . "]" ;
         } else {
             $this->xml_content = "<xml></xml>";
         }
         myMetadataUtils::updateEntryForPending($entry, $version, $this->xml_content);
     } else {
         return sfView::ERROR;
     }
     // this is NOT an xml file we are looking for !
 }
Exemplo n.º 4
0
 /**
  * @param entry $entry
  * @param SimpleXMLElement $mrss
  */
 protected static function appendMediaEntryMrss(entry $entry, SimpleXMLElement $mrss)
 {
     $media = $mrss->addChild('media');
     $media->addChild('mediaType', $entry->getMediaType());
     $media->addChild('duration', $entry->getLengthInMsecs());
     $media->addChild('conversionProfileId', $entry->getConversionProfileId());
     $media->addChild('flavorParamsIds', $entry->getFlavorParamsIds());
 }
Exemplo n.º 5
0
 private function enforceAudioVideoEntry()
 {
     if ($this->entry->getType() != entryType::MEDIA_CLIP) {
         KExternalErrors::dieError(KExternalErrors::INVALID_ENTRY_TYPE);
     }
     if (!in_array($this->entry->getMediaType(), array(entry::ENTRY_MEDIA_TYPE_VIDEO, entry::ENTRY_MEDIA_TYPE_AUDIO))) {
         KExternalErrors::dieError(KExternalErrors::INVALID_ENTRY_TYPE);
     }
 }
Exemplo n.º 6
0
 private function setContextDataFlavorAssets($flavorTags)
 {
     if ($this->entry->getType() == entryType::PLAYLIST && $this->entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_TEXT) {
         list($entryIds, $durations, $mediaEntry) = myPlaylistUtils::executeStitchedPlaylist($this->entry);
         if (!$mediaEntry) {
             return;
         }
         $mediaEntryId = $mediaEntry->getId();
         $this->msDuration = array_sum($durations);
     } else {
         $mediaEntryId = $this->entry->getId();
         $this->msDuration = $this->entry->getLengthInMsecs();
     }
     $flavorParamsIds = null;
     $flavorParamsNotIn = false;
     if (!$this->isAdmin) {
         foreach ($this->contextDataResult->getActions() as $action) {
             if ($action->getType() == RuleActionType::BLOCK) {
                 //in case of block action do not set the list of flavors
                 return;
             }
             if ($action->getType() == RuleActionType::LIMIT_FLAVORS) {
                 /* @var $action kAccessControlLimitFlavorsAction */
                 $flavorParamsIds = explode(',', $action->getFlavorParamsIds());
                 $flavorParamsNotIn = $action->getIsBlockedList();
             }
         }
     }
     $flavorAssets = array();
     if (is_null($this->asset)) {
         if (count($flavorParamsIds)) {
             $flavorAssets = assetPeer::retrieveReadyByEntryIdAndFlavorParams($mediaEntryId, $flavorParamsIds, $flavorParamsNotIn);
         } else {
             $flavorAssets = assetPeer::retrieveFlavorsByEntryIdAndStatus($mediaEntryId, null, array(flavorAsset::ASSET_STATUS_READY));
         }
         if ($mediaEntryId != $this->entry->getId()) {
             // hack: setting the entry id of the flavors to the original playlist id
             //		since the player uses it in the playManifest url
             foreach ($flavorAssets as $flavorAsset) {
                 $flavorAsset->setEntryId($this->entry->getId());
             }
         }
     } else {
         $flavorAllowed = true;
         if (count($flavorParamsIds)) {
             $flavorAllowed = $this->isFlavorAllowed($this->asset->getFlavorParamsId(), $flavorParamsIds, $flavorParamsNotIn);
         }
         if ($flavorAllowed) {
             $flavorAssets[] = $this->asset;
         }
     }
     $this->filterFlavorAssetsByTags($flavorAssets, $flavorTags);
 }
 public function entryHandled(entry $dbEntry)
 {
     $srcEntry = entryPeer::retrieveByPK($this->entryId);
     if ($srcEntry->getType() == KalturaEntryType::MEDIA_CLIP && $dbEntry->getType() == KalturaEntryType::MEDIA_CLIP && $dbEntry->getMediaType() == KalturaMediaType::IMAGE) {
         if ($dbEntry->getMediaType() == KalturaMediaType::IMAGE) {
             $dbEntry->setDimensions($srcEntry->getWidth(), $srcEntry->getHeight());
             $dbEntry->setMediaDate($srcEntry->getMediaDate(null));
             $dbEntry->save();
         } else {
             $srcFlavorAsset = null;
             if (is_null($this->flavorParamsId)) {
                 $srcFlavorAsset = assetPeer::retrieveOriginalByEntryId($this->entryId);
             } else {
                 $srcFlavorAsset = assetPeer::retrieveByEntryIdAndParams($this->entryId, $this->flavorParamsId);
             }
             if ($srcFlavorAsset) {
                 $dbEntry->setDimensions($srcFlavorAsset->getWidth(), $srcFlavorAsset->getHeight());
                 $dbEntry->save();
             }
         }
     }
     return parent::entryHandled($dbEntry);
 }
Exemplo n.º 8
0
 protected function executeImpl(kshow $kshow, entry &$entry)
 {
     if ($entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_SHOW) {
         $this->show_versions = array_reverse($entry->getAllversions());
     } else {
         $this->show_versions = array();
     }
     $this->producer = kuser::getKuserById($kshow->getProducerId());
     $this->editor = $entry->getKuser();
     $this->thumbnail = $entry ? $entry->getThumbnailPath() : "";
     // is the logged-in-user is an admin or the producer or the show can always be published...
     $likuser_id = $this->getLoggedInUserId();
     $viewer_type = myKshowUtils::getViewerType($kshow, $likuser_id);
     $this->entry = $entry ? $entry : new entry();
     // create a dummy entry for the GUI
     $this->can_publish = $viewer_type == KshowKuser::KSHOWKUSER_VIEWER_PRODUCER || $kshow->getCanPublish();
 }
Exemplo n.º 9
0
 private function enforceAudioVideoEntry()
 {
     switch ($this->entry->getType()) {
         case entryType::MEDIA_CLIP:
             if (!in_array($this->entry->getMediaType(), array(entry::ENTRY_MEDIA_TYPE_VIDEO, entry::ENTRY_MEDIA_TYPE_AUDIO))) {
                 KExternalErrors::dieError(KExternalErrors::INVALID_ENTRY_TYPE);
             }
             break;
         case entryType::PLAYLIST:
             if ($this->entry->getMediaType() != entry::ENTRY_MEDIA_TYPE_TEXT) {
                 KExternalErrors::dieError(KExternalErrors::INVALID_ENTRY_TYPE);
             }
             break;
         default:
             KExternalErrors::dieError(KExternalErrors::INVALID_ENTRY_TYPE);
     }
 }
Exemplo n.º 10
0
 public function executeImpl(kshow $kshow, entry &$entry)
 {
     $genericWidget = "";
     $myspaceWidget = "";
     $kshow_id = $kshow->getId();
     $entry_id = $entry->getId();
     if (!$kshow->getPartnerId() && !$this->forceViewPermissions($kshow, $kshow_id, false, false)) {
         die;
     }
     $this->kshow_category = $kshow->getTypeText();
     $this->kshow_description = $kshow->getDescription();
     $this->kshow_name = $kshow->getName();
     $this->kshow_tags = $kshow->getTags();
     $kdata = @$_REQUEST["kdata"];
     if ($kdata == "null") {
         $kdata = "";
     }
     $this->widget_type = @$_REQUEST["widget_type"];
     list($genericWidget, $myspaceWidget) = myKshowUtils::getEmbedPlayerUrl($kshow_id, $entry_id, false, $kdata);
     if ($entry_id == 1002) {
         $this->share_url = requestUtils::getHost() . "/index.php/corp/kalturaPromo";
     } else {
         if ($kdata) {
             $this->share_url = myKshowUtils::getWidgetCmdUrl($kdata, "share");
         } else {
             $this->share_url = myKshowUtils::getUrl($kshow_id) . "&entry_id={$entry_id}";
         }
     }
     //list($status, $kmediaType, $kmediaData) = myContentRender::createPlayerMedia($entry); // myContentRender class removed, old code
     $status = $entry->getStatus();
     $kmediaType = $entry->getMediaType();
     $kmediaData = "";
     $this->message = $kmediaType == entry::ENTRY_MEDIA_TYPE_TEXT ? $kmediaData : "";
     $this->generic_embed_code = $genericWidget;
     $this->myspace_embed_code = $myspaceWidget;
     $this->thumbnail = $entry ? $entry->getBigThumbnailPath(true) : "";
     $this->kuser = $entry->getKuser();
     $this->entry = $entry;
 }
Exemplo n.º 11
0
 private function serveHttp()
 {
     if ($this->entry->getType() != entryType::MEDIA_CLIP) {
         KExternalErrors::dieError(KExternalErrors::INVALID_ENTRY_TYPE);
     }
     switch ($this->entry->getType()) {
         case entryType::MEDIA_CLIP:
             switch ($this->entry->getMediaType()) {
                 case entry::ENTRY_MEDIA_TYPE_IMAGE:
                     // TODO - create sequence manifest
                     break;
                 case entry::ENTRY_MEDIA_TYPE_VIDEO:
                 case entry::ENTRY_MEDIA_TYPE_AUDIO:
                     $duration = $this->entry->getDurationInt();
                     $flavors = $this->buildFlavorsArray($duration, true);
                     return $this->buildXml(self::PLAY_STREAM_TYPE_RECORDED, $flavors, 'video/x-flv', $duration);
             }
         default:
             break;
     }
     KExternalErrors::dieError(KExternalErrors::INVALID_ENTRY_TYPE);
 }
Exemplo n.º 12
0
 /**
  * @param kUrlResource $resource
  * @param entry $dbEntry
  * @param asset $dbAsset
  * @return asset
  */
 protected function attachUrlResource(kUrlResource $resource, entry $dbEntry, asset $dbAsset = null)
 {
     if ($dbAsset instanceof flavorAsset) {
         $dbEntry->setSource(KalturaSourceType::URL);
         $dbEntry->save();
     }
     $url = $resource->getUrl();
     if (!$resource->getForceAsyncDownload()) {
         // TODO - move image handling to media service
         if ($dbEntry->getMediaType() == KalturaMediaType::IMAGE) {
             $entryFullPath = myContentStorage::getFSUploadsPath() . '/' . $dbEntry->getId() . '.jpg';
             if (KCurlWrapper::getDataFromFile($url, $entryFullPath)) {
                 return $this->attachFile($entryFullPath, $dbEntry, $dbAsset);
             }
             KalturaLog::err("Failed downloading file[{$url}]");
             $dbEntry->setStatus(entryStatus::ERROR_IMPORTING);
             $dbEntry->save();
             return null;
         }
         if ($dbAsset && !$dbAsset instanceof flavorAsset) {
             $ext = pathinfo($url, PATHINFO_EXTENSION);
             $entryFullPath = myContentStorage::getFSUploadsPath() . '/' . $dbEntry->getId() . '.' . $ext;
             if (KCurlWrapper::getDataFromFile($url, $entryFullPath)) {
                 $dbAsset = $this->attachFile($entryFullPath, $dbEntry, $dbAsset);
                 return $dbAsset;
             }
             KalturaLog::err("Failed downloading file[{$url}]");
             $dbAsset->setStatus(asset::FLAVOR_ASSET_STATUS_ERROR);
             $dbAsset->save();
             return null;
         }
     }
     kJobsManager::addImportJob(null, $dbEntry->getId(), $this->getPartnerId(), $url, $dbAsset, null, $resource->getImportJobData());
     return $dbAsset;
 }
Exemplo n.º 13
0
 /**
  * @param kResource $resource
  * @param entry $dbEntry
  * @param asset $dbAsset
  * @return asset
  */
 protected function attachResource(kResource $resource, entry $dbEntry, asset $dbAsset = null)
 {
     switch ($resource->getType()) {
         case 'kAssetsParamsResourceContainers':
             // image entry doesn't support asset params
             if ($dbEntry->getMediaType() == KalturaMediaType::IMAGE) {
                 throw new KalturaAPIException(KalturaErrors::RESOURCE_TYPE_NOT_SUPPORTED, get_class($resource));
             }
             return $this->attachAssetsParamsResourceContainers($resource, $dbEntry);
         case 'kAssetParamsResourceContainer':
             // image entry doesn't support asset params
             if ($dbEntry->getMediaType() == KalturaMediaType::IMAGE) {
                 throw new KalturaAPIException(KalturaErrors::RESOURCE_TYPE_NOT_SUPPORTED, get_class($resource));
             }
             return $this->attachAssetParamsResourceContainer($resource, $dbEntry, $dbAsset);
         case 'kUrlResource':
             return $this->attachUrlResource($resource, $dbEntry, $dbAsset);
         case 'kLocalFileResource':
             return $this->attachLocalFileResource($resource, $dbEntry, $dbAsset);
         case 'kLiveEntryResource':
             return $this->attachLiveEntryResource($resource, $dbEntry, $dbAsset);
         case 'kFileSyncResource':
             return $this->attachFileSyncResource($resource, $dbEntry, $dbAsset);
         case 'kRemoteStorageResource':
         case 'kRemoteStorageResources':
             return $this->attachRemoteStorageResource($resource, $dbEntry, $dbAsset);
         case 'kOperationResource':
             if ($dbEntry->getMediaType() == KalturaMediaType::IMAGE) {
                 throw new KalturaAPIException(KalturaErrors::RESOURCE_TYPE_NOT_SUPPORTED, get_class($resource));
             }
             return $this->attachOperationResource($resource, $dbEntry, $dbAsset);
         default:
             KalturaLog::err("Resource of type [" . get_class($resource) . "] is not supported");
             $dbEntry->setStatus(entryStatus::ERROR_IMPORTING);
             $dbEntry->save();
             throw new KalturaAPIException(KalturaErrors::RESOURCE_TYPE_NOT_SUPPORTED, get_class($resource));
     }
 }
Exemplo n.º 14
0
 public static function copyEntry(entry $entry, Partner $toPartner = null, $dontCopyUsers = false)
 {
     KalturaLog::log("copyEntry - Copying entry [" . $entry->getId() . "] to partner [" . $toPartner->getId() . "]");
     $newEntry = $entry->copy();
     $newEntry->setIntId(null);
     if ($toPartner instanceof Partner) {
         $newEntry->setPartnerId($toPartner->getId());
         $newEntry->setSubpId($toPartner->getId() * 100);
         $newEntry->setAccessControlId($toPartner->getDefaultAccessControlId());
         $flavorParamsStr = $entry->getFlavorParamsIds();
         $flavorParams = explode(',', $flavorParamsStr);
         $newFlavorParams = array();
         foreach ($flavorParams as $flavorParamsId) {
             $newFlavorParamsId = kObjectCopyHandler::getMappedId('flavorParams', $flavorParamsId);
             if (is_null($newFlavorParamsId)) {
                 $newFlavorParamsId = $flavorParamsId;
             }
             $newFlavorParams[] = $newFlavorParamsId;
         }
         $newEntry->setFlavorParamsIds(implode(',', $newFlavorParams));
     }
     $newKuser = null;
     if (!$dontCopyUsers) {
         // copy the kuser (if the same puser id exists its kuser will be used)
         kuserPeer::setUseCriteriaFilter(false);
         $kuser = $entry->getKuser();
         $newKuser = kuserPeer::createKuserForPartner($newEntry->getPartnerId(), $kuser->getPuserId());
         $newEntry->setKuserId($newKuser->getId());
         kuserPeer::setUseCriteriaFilter(true);
     }
     // copy the kshow
     kshowPeer::setUseCriteriaFilter(false);
     $kshow = $entry->getKshow();
     if ($kshow) {
         $newKshow = $kshow->copy();
         $newKshow->setIntId(null);
         $newKshow->setPartnerId($toPartner->getId());
         $newKshow->setSubpId($toPartner->getId() * 100);
         if ($newKuser) {
             $newKshow->setProducerId($newKuser->getId());
         }
         $newKshow->save();
         $newEntry->setKshowId($newKshow->getId());
     }
     kshowPeer::setUseCriteriaFilter(true);
     // reset the statistics
     myEntryUtils::resetEntryStatistics($newEntry);
     // set the new partner id into the default category criteria filter
     $defaultCategoryFilter = categoryPeer::getCriteriaFilter()->getFilter();
     $oldPartnerId = $defaultCategoryFilter->get(categoryPeer::PARTNER_ID);
     $defaultCategoryFilter->remove(categoryPeer::PARTNER_ID);
     $defaultCategoryFilter->addAnd(categoryPeer::PARTNER_ID, $newEntry->getPartnerId());
     // save the entry
     $newEntry->save();
     // restore the original partner id in the default category criteria filter
     $defaultCategoryFilter->remove(categoryPeer::PARTNER_ID);
     $defaultCategoryFilter->addAnd(categoryPeer::PARTNER_ID, $oldPartnerId);
     KalturaLog::log("copyEntry - New entry [" . $newEntry->getId() . "] was created");
     // for any type that does not require assets:
     $shouldCopyDataForNonClip = $entry->getType() != entryType::MEDIA_CLIP;
     $shouldCopyDataForClip = false;
     // only images get their data copied
     if ($entry->getType() == entryType::MEDIA_CLIP) {
         if ($entry->getMediaType() != entry::ENTRY_MEDIA_TYPE_VIDEO && $entry->getMediaType() != entry::ENTRY_MEDIA_TYPE_AUDIO) {
             $shouldCopyDataForClip = true;
         }
     }
     if ($shouldCopyDataForNonClip || $shouldCopyDataForClip) {
         // copy the data
         $from = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA);
         // replaced__getDataPath
         $to = $newEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA);
         // replaced__getDataPath
         KalturaLog::log("copyEntriesByType - copying entry data [" . $from . "] to [" . $to . "]");
         kFileSyncUtils::softCopy($from, $to);
     }
     $ismFrom = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISM);
     if (kFileSyncUtils::fileSync_exists($ismFrom)) {
         $ismTo = $newEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISM);
         KalturaLog::log("copying entry ism [" . $ismFrom . "] to [" . $ismTo . "]");
         kFileSyncUtils::softCopy($ismFrom, $ismTo);
     }
     $ismcFrom = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISMC);
     if (kFileSyncUtils::fileSync_exists($ismcFrom)) {
         $ismcTo = $newEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISMC);
         KalturaLog::log("copying entry ism [" . $ismcFrom . "] to [" . $ismcTo . "]");
         kFileSyncUtils::softCopy($ismcFrom, $ismcTo);
     }
     $from = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB);
     // replaced__getThumbnailPath
     $considerCopyThumb = true;
     // if entry is image - data is thumbnail, and it was copied
     if ($entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_IMAGE) {
         $considerCopyThumb = false;
     }
     // if entry is not clip, and there is no file in both DCs - nothing to copy
     if ($entry->getType() != entryType::MEDIA_CLIP && !kFileSyncUtils::file_exists($from, true)) {
         $considerCopyThumb = false;
     }
     if ($considerCopyThumb) {
         $skipThumb = false;
         // don't attempt to copy a thumbnail for images - it's the same as the data which was just created
         if ($entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_AUDIO) {
             // check if audio entry has real thumb, if not - don't copy thumb.
             $originalFileSync = kFileSyncUtils::getOriginFileSyncForKey($from, false);
             if (!$originalFileSync) {
                 $skipThumb = true;
             }
         }
         if (!$skipThumb) {
             $to = $newEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB);
             // replaced__getThumbnailPath
             KalturaLog::log("copyEntriesByType - copying entry thumbnail [" . $from . "] to [" . $to . "]");
             kFileSyncUtils::softCopy($from, $to);
         }
     }
     // added by Tan-Tan 12/01/2010 to support falvors copy
     $sourceFlavorAssets = flavorAssetPeer::retrieveByEntryId($entry->getId());
     foreach ($sourceFlavorAssets as $sourceFlavorAsset) {
         $sourceFlavorAsset->copyToEntry($newEntry->getId(), $newEntry->getPartnerId());
     }
 }
 public static function addProvisionProvideJob(BatchJob $parentJob = null, entry $entry)
 {
     $subType = $entry->getSource();
     if ($subType == entry::ENTRY_MEDIA_SOURCE_AKAMAI_LIVE) {
         $partner = $entry->getPartner();
         if (!is_null($partner)) {
             $jobData = new kAkamaiProvisionJobData();
             $akamaiLiveParams = $partner->getAkamaiLiveParams();
             if ($akamaiLiveParams) {
                 $jobData->setWsdlUsername($akamaiLiveParams->getAkamaiLiveWsdlUsername());
                 $jobData->setWsdlPassword($akamaiLiveParams->getAkamaiLiveWsdlPassword());
                 $jobData->setCpcode($akamaiLiveParams->getAkamaiLiveCpcode());
                 $jobData->setEmailId($akamaiLiveParams->getAkamaiLiveEmailId());
                 $jobData->setPrimaryContact($akamaiLiveParams->getAkamaiLivePrimaryContact());
                 $jobData->setSecondaryContact($akamaiLiveParams->getAkamaiLiveSecondaryContact());
             }
         }
     } else {
         $jobData = new kProvisionJobData();
     }
     $jobData->setEncoderIP($entry->getEncodingIP1());
     $jobData->setBackupEncoderIP($entry->getEncodingIP2());
     $jobData->setEncoderPassword($entry->getStreamPassword());
     $jobData->setEncoderUsername($entry->getStreamUsername());
     $jobData->setEndDate($entry->getEndDate(null));
     $jobData->setMediaType($entry->getMediaType());
     $batchJob = null;
     if ($parentJob) {
         $batchJob = $parentJob->createChild();
     } else {
         $batchJob = new BatchJob();
         $batchJob->setEntryId($entry->getId());
         $batchJob->setPartnerId($entry->getPartnerId());
     }
     return self::addJob($batchJob, $jobData, BatchJobType::PROVISION_PROVIDE, $subType);
 }
Exemplo n.º 16
0
 public static function copyEntryData(entry $entry, entry $targetEntry)
 {
     // for any type that does not require assets:
     $shouldCopyDataForNonClip = true;
     if ($entry->getType() == entryType::MEDIA_CLIP) {
         $shouldCopyDataForNonClip = false;
     }
     if ($entry->getType() == entryType::PLAYLIST) {
         $shouldCopyDataForNonClip = false;
     }
     $shouldCopyDataForClip = false;
     // only images get their data copied
     if ($entry->getType() == entryType::MEDIA_CLIP) {
         if ($entry->getMediaType() != entry::ENTRY_MEDIA_TYPE_VIDEO && $entry->getMediaType() != entry::ENTRY_MEDIA_TYPE_AUDIO) {
             $shouldCopyDataForClip = true;
         }
     }
     if ($shouldCopyDataForNonClip || $shouldCopyDataForClip) {
         // copy the data
         $from = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA);
         // replaced__getDataPath
         $to = $targetEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA);
         // replaced__getDataPath
         KalturaLog::log("copyEntriesByType - copying entry data [" . $from . "] to [" . $to . "]");
         kFileSyncUtils::softCopy($from, $to);
     }
     $ismFrom = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISM);
     if (kFileSyncUtils::fileSync_exists($ismFrom)) {
         $ismTo = $targetEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISM);
         KalturaLog::log("copying entry ism [" . $ismFrom . "] to [" . $ismTo . "]");
         kFileSyncUtils::softCopy($ismFrom, $ismTo);
     }
     $ismcFrom = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISMC);
     if (kFileSyncUtils::fileSync_exists($ismcFrom)) {
         $ismcTo = $targetEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISMC);
         KalturaLog::log("copying entry ism [" . $ismcFrom . "] to [" . $ismcTo . "]");
         kFileSyncUtils::softCopy($ismcFrom, $ismcTo);
     }
     $from = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB);
     // replaced__getThumbnailPath
     $considerCopyThumb = true;
     // if entry is image - data is thumbnail, and it was copied
     if ($entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_IMAGE) {
         $considerCopyThumb = false;
     }
     // if entry is not clip, and there is no file in both DCs - nothing to copy
     if ($entry->getType() != entryType::MEDIA_CLIP && !kFileSyncUtils::file_exists($from, true)) {
         $considerCopyThumb = false;
     }
     if ($considerCopyThumb) {
         $skipThumb = false;
         // don't attempt to copy a thumbnail for images - it's the same as the data which was just created
         if ($entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_AUDIO) {
             // check if audio entry has real thumb, if not - don't copy thumb.
             $originalFileSync = kFileSyncUtils::getOriginFileSyncForKey($from, false);
             if (!$originalFileSync) {
                 $skipThumb = true;
             }
         }
         if (!$skipThumb) {
             $to = $targetEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB);
             // replaced__getThumbnailPath
             KalturaLog::log("copyEntriesByType - copying entry thumbnail [" . $from . "] to [" . $to . "]");
             kFileSyncUtils::softCopy($from, $to);
         }
     }
     // added by Tan-Tan 12/01/2010 to support falvors copy
     $sourceAssets = assetPeer::retrieveByEntryId($entry->getId());
     foreach ($sourceAssets as $sourceAsset) {
         $sourceAsset->copyToEntry($targetEntry->getId(), $targetEntry->getPartnerId());
     }
 }
 /**
  * Executes addComment action, which returns a form enabling the insertion of a comment
  * The request may include 1 fields: entry id.
  */
 protected function executeImpl(kshow $kshow, entry &$entry)
 {
     $kshow_id = $kshow->getId();
     if ($this->partner_id != null) {
         // this part overhere should be in a more generic place - part of the services
         $multiple_roghcuts = Partner::allowMultipleRoughcuts($this->partner_id);
         $likuser_id = $this->getLoggedInUserId();
     } else {
         // 	is the logged-in-user is not an admin or the producer - check if show can be published
         $likuser_id = $this->getLoggedInUserId();
         $multiple_roghcuts = true;
     }
     if (!$likuser_id) {
         return $this->securityViolation($kshow->getId());
     }
     $isIntro = $kshow->getIntroId() == $entry->getId();
     if ($multiple_roghcuts) {
         // create a new entry in two cases:
         // 1. the user saving the roughcut isnt the owner of the entry
         // 2. the entry is an intro and the current entry is not show (probably an image or video)
         if ($entry->getKuserId() != $likuser_id || $isIntro && $entry->getMediaType() != entry::ENTRY_MEDIA_TYPE_SHOW) {
             // TODO: add security check to whether multiple roughcuts are allowed
             // create a new roughcut entry by cloning the original entry
             $entry = myEntryUtils::deepClone($entry, $kshow_id, false);
             $entry->setKuserId($likuser_id);
             $entry->setCreatorKuserId($likuser_id);
             $entry->setCreatedAt(time());
             $entry->setMediaType(entry::ENTRY_MEDIA_TYPE_SHOW);
             $entry->save();
         }
     }
     /*
     		$viewer_type = myKshowUtils::getViewerType($kshow, $likuser_id);
     		if ( $viewer_type != KshowKuser::KSHOWKUSER_VIEWER_PRODUCER && ( ! $kshow->getCanPublish() ) ) 
     		{
     			// ERROR - attempting to publish a non-publishable show
     			return $this->securityViolation( $kshow->getId() );
     		}
     */
     $this->xml_content = "<xml><EntryID>" . $entry->getId() . "</EntryID></xml>";
     if ($isIntro) {
         $kshow->setIntroId($entry->getId());
     } else {
         $kshow->setShowEntryId($entry->getId());
         $has_roughcut = @$_REQUEST["HasRoughCut"];
         if ($has_roughcut === "0") {
             $kshow->setHasRoughcut(false);
             $kshow->save();
             return;
         }
     }
     $content = @$_REQUEST["xml"];
     $update_kshow = false;
     if ($content != NULL) {
         list($xml_content, $this->comments, $update_kshow) = myMetadataUtils::setMetadata($content, $kshow, $entry);
         // Send an email alert to producer
         if ($kshow->getProducerId() != $likuser_id) {
             // don't send producer alerts when the producer is the editor
             alertPeer::sendEmailIfNeeded($kshow->getProducerId(), alert::KALTURAS_PRODUCED_ALERT_TYPE_ROUGHCUT_CREATED, array('screenname' => $this->getUser()->getAttribute('screenname'), 'kshow_name' => $kshow->getName(), 'kshow_id' => $kshow->getId()));
         }
         // TODO:  efficiency: see if there is a wa to search for contributors based on some other method than full entry table scan
         // Send email alerts to contributors
         $c = new Criteria();
         $c->add(entryPeer::KSHOW_ID, $kshow_id);
         $c->add(entryPeer::KUSER_ID, $likuser_id, Criteria::NOT_EQUAL);
         // the current user knows they just edited
         $c->addAnd(entryPeer::KUSER_ID, $kshow->getProducerId(), Criteria::NOT_EQUAL);
         // the producer knows they just edited
         $c->add(entryPeer::TYPE, entryType::MEDIA_CLIP);
         $c->addGroupByColumn(entryPeer::KUSER_ID);
         $entries = entryPeer::doSelect($c);
         $already_received_alert_array = array();
         foreach ($entries as $entry) {
             alertPeer::sendEmailIfNeeded($entry->getKuserId(), alert::KALTURAS_PARTOF_ALERT_TYPE_ROUGHCUT_CREATED, array('screenname' => $this->getUser()->getAttribute('screenname'), 'kshow_name' => $kshow->getName(), 'kshow_id' => $kshow->getId()));
             $already_received_alert_array[$entry->getKuserId()] = true;
         }
         // send email alert to subscribers
         $c = new Criteria();
         $c->add(KshowKuserPeer::KSHOW_ID, $kshow_id);
         //only subsribers of this show
         $c->add(KshowKuserPeer::KUSER_ID, $likuser_id, Criteria::NOT_EQUAL);
         // the current user knows they just edited
         $c->add(KshowKuserPeer::SUBSCRIPTION_TYPE, KshowKuser::KSHOW_SUBSCRIPTION_NORMAL);
         // this table stores other relations too
         $subscriptions = KshowKuserPeer::doSelect($c);
         foreach ($subscriptions as $subscription) {
             if (!isset($already_received_alert_array[$subscription->getKuserId()])) {
                 // don't send emails to subscribed users who are also contributors
                 alertPeer::sendEmailIfNeeded($subscription->getKuserId(), alert::KALTURAS_SUBSCRIBEDTO_ALERT_TYPE_ROUGHCUT_CREATED, array('screenname' => $this->getUser()->getAttribute('screenname'), 'kshow_name' => $kshow->getName(), 'kshow_id' => $kshow->getId()));
             }
         }
         if ($this->debug) {
             return "text/html; charset=utf-8";
         }
     } else {
         $this->comments = "";
         // if there is no xml - receive it from the user
         $this->debug = true;
         $file_name = myContentStorage::getFSContentRootPath() . "/" . $entry->getDataPath();
         //$this->xml_content = kFile::getFileContent( $file_name );
         return "text/html; charset=utf-8";
     }
 }
Exemplo n.º 18
0
 /**
  * @param entry $entry
  * @param SimpleXMLElement $mrss
  */
 protected static function appendDataEntryMrss(entry $entry, SimpleXMLElement $mrss)
 {
     $media = $mrss->addChild('livestream');
     $media->addChild('mediaType', $entry->getMediaType());
     $media->addChild('duration', $entry->getLengthInMsecs());
 }
Exemplo n.º 19
0
 public static function toQueryString(entry $playlist, $should_append_filter_to_url = false)
 {
     $query = "playlist_id={$playlist->getId()}";
     if ($playlist->getMediaType() != entry::ENTRY_MEDIA_TYPE_XML) {
         return $query;
     }
     if (!$should_append_filter_to_url) {
         return $query;
     }
     $xml = $playlist->getDataContent();
     list($total_results, $list_of_filters) = self::getPlaylistFilterListStruct($xml);
     $entry_filters = array();
     $partner_id = $playlist->getPartnerId();
     // add ks=_KS_ for the playlist to replace it before hitting the executePlaylist
     $query .= "&fp=f";
     // make sure the filter prefix is short
     if (!$list_of_filters) {
         return $query;
     }
     $i = 1;
     // the extra_filter is 1-based
     foreach ($list_of_filters as $entry_filter_xml) {
         $prefix = "f{$i}_";
         // 	in general this service can fetch entries from kaltura networks.
         // for each filter we should decide if thie assumption is true...
         $allow_partner_only = true;
         // compile all the filters - only then execute them if not yet reached the total_results
         // TODO - optimize - maybe create them only when needed. - For now it's safer to compile all even if not needed.
         $entry_filter = new entryFilter();
         // add the desired prefix "_" because the XML is not expected to have it while the entryFilter class expects it
         $entry_filter->fillObjectFromXml($entry_filter_xml, "_");
         // make sure there is alway a limit for each filter - if not an explicit one - the system limit should be used
         if ($entry_filter->getLimit() == null || $entry_filter->getLimit() < 1) {
             $entry_filter->setLimit(self::TOTAL_RESULTS);
         }
         $entry_filter->setPartnerSearchScope(baseObjectFilter::MATCH_KALTURA_NETWORK_AND_PRIVATE);
         self::updateEntryFilter($entry_filter, $partner_id);
         //$entry_filters[] = $entry_filter;
         $fields = $entry_filter->fields;
         foreach ($fields as $field => $value) {
             if ($value) {
                 $query .= "&" . $prefix . $field . "=" . $value;
             }
         }
         $i++;
     }
     return $query;
 }
 private function getBestSyncKeyForEntry(entry $entry)
 {
     $entryType = $entry->getType();
     $entryMediaType = $entry->getMediaType();
     $syncKey = null;
     switch ($entryType) {
         case entryType::MEDIA_CLIP:
             switch ($entryMediaType) {
                 case entry::ENTRY_MEDIA_TYPE_IMAGE:
                     $syncKey = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA);
                     break;
             }
             break;
     }
     return $syncKey;
 }
Exemplo n.º 21
0
 public static function addProvisionProvideJob(BatchJob $parentJob = null, entry $entry)
 {
     $jobData = new kProvisionJobData();
     $jobData->setEncoderIP($entry->getEncodingIP1());
     $jobData->setBackupEncoderIP($entry->getEncodingIP2());
     $jobData->setEncoderPassword($entry->getStreamPassword());
     $jobData->setEncoderUsername($entry->getStreamUsername());
     $jobData->setEndDate($entry->getEndDate(null));
     $jobData->setMediaType($entry->getMediaType());
     $batchJob = null;
     if ($parentJob) {
         $batchJob = $parentJob->createChild();
     } else {
         $batchJob = new BatchJob();
         $batchJob->setEntryId($entry->getId());
         $batchJob->setPartnerId($entry->getPartnerId());
     }
     $subType = $entry->getSource();
     return self::addJob($batchJob, $jobData, BatchJobType::PROVISION_PROVIDE, $subType);
 }
Exemplo n.º 22
0
 public static function copyEntry(entry $entry, Partner $toPartner = null, $dontCopyUsers = false)
 {
     KalturaLog::log("copyEntry - Copying entry [" . $entry->getId() . "] to partner [" . $toPartner->getId() . "]");
     $newEntry = $entry->copy();
     $newEntry->setIntId(null);
     $newEntry->setCategories(null);
     $newEntry->setCategoriesIds(null);
     if ($toPartner instanceof Partner) {
         $newEntry->setPartnerId($toPartner->getId());
         $newEntry->setSubpId($toPartner->getId() * 100);
         $newEntry->setAccessControlId($toPartner->getDefaultAccessControlId());
     }
     $newKuser = null;
     if (!$dontCopyUsers) {
         // copy the kuser (if the same puser id exists its kuser will be used)
         kuserPeer::setUseCriteriaFilter(false);
         $kuser = $entry->getKuser();
         $newKuser = kuserPeer::createKuserForPartner($newEntry->getPartnerId(), $kuser->getPuserId());
         $newEntry->setKuserId($newKuser->getId());
         $newEntry->setCreatorKuserId($newKuser->getId());
         kuserPeer::setUseCriteriaFilter(true);
     }
     // copy the kshow
     kshowPeer::setUseCriteriaFilter(false);
     $kshow = $entry->getKshow();
     if ($kshow) {
         $newKshow = $kshow->copy();
         $newKshow->setIntId(null);
         $newKshow->setPartnerId($toPartner->getId());
         $newKshow->setSubpId($toPartner->getId() * 100);
         if ($newKuser) {
             $newKshow->setProducerId($newKuser->getId());
         }
         $newKshow->save();
         $newEntry->setKshowId($newKshow->getId());
     }
     kshowPeer::setUseCriteriaFilter(true);
     // reset the statistics
     myEntryUtils::resetEntryStatistics($newEntry);
     // set the new partner id into the default category criteria filter
     $defaultCategoryFilter = categoryPeer::getCriteriaFilter()->getFilter();
     $oldPartnerId = $defaultCategoryFilter->get(categoryPeer::PARTNER_ID);
     $defaultCategoryFilter->remove(categoryPeer::PARTNER_ID);
     $defaultCategoryFilter->addAnd(categoryPeer::PARTNER_ID, $newEntry->getPartnerId());
     // save the entry
     $newEntry->save();
     // restore the original partner id in the default category criteria filter
     $defaultCategoryFilter->remove(categoryPeer::PARTNER_ID);
     $defaultCategoryFilter->addAnd(categoryPeer::PARTNER_ID, $oldPartnerId);
     KalturaLog::log("copyEntry - New entry [" . $newEntry->getId() . "] was created");
     // for any type that does not require assets:
     $shouldCopyDataForNonClip = true;
     if ($entry->getType() == entryType::MEDIA_CLIP) {
         $shouldCopyDataForNonClip = false;
     }
     if ($entry->getType() == entryType::PLAYLIST) {
         $shouldCopyDataForNonClip = false;
     }
     $shouldCopyDataForClip = false;
     // only images get their data copied
     if ($entry->getType() == entryType::MEDIA_CLIP) {
         if ($entry->getMediaType() != entry::ENTRY_MEDIA_TYPE_VIDEO && $entry->getMediaType() != entry::ENTRY_MEDIA_TYPE_AUDIO) {
             $shouldCopyDataForClip = true;
         }
     }
     //if entry is a static playlist, link between it and its new child entries
     if ($entry->getType() == entryType::PLAYLIST) {
         switch ($entry->getMediaType()) {
             case entry::ENTRY_MEDIA_TYPE_TEXT:
                 $from = $entry->getDataContent();
                 KalturaLog::debug("Entries to copy from source static playlist: [{$from}]");
                 $fromEntryIds = explode(",", $from);
                 $toEntryIds = array();
                 foreach ($fromEntryIds as $fromEntryId) {
                     $toEntryIds[] = kObjectCopyHandler::getMappedId(entryPeer::OM_CLASS, $fromEntryId);
                 }
                 $newEntry->setDataContent(implode(",", $toEntryIds));
                 break;
             case entry::ENTRY_MEDIA_TYPE_XML:
                 list($totalResults, $fromFiltersList) = myPlaylistUtils::getPlaylistFilterListStruct($entry->getDataContent());
                 $toPlaylistXml = new SimpleXMLElement("<playlist/>");
                 $toPlaylistXml->addChild("total_results", $totalResults);
                 $toFiltersXml = $toPlaylistXml->addChild("filters");
                 foreach ($fromFiltersList as $filterXML) {
                     $entryFilter = new entryFilter();
                     $entryFilter->fillObjectFromXml($filterXML, "_");
                     if (isset($entryFilter->fields["_matchand_categories_ids"])) {
                         $categoriesIds = explode(",", $entryFilter->fields["_matchand_categories_ids"]);
                         $newCategoriesIds = array();
                         foreach ($categoriesIds as $categoryId) {
                             $newCategoriesIds[] = kObjectCopyHandler::getMappedId(categoryPeer::OM_CLASS, $categoryId);
                         }
                         $entryFilter->fields["_matchand_categories_ids"] = implode(",", $newCategoriesIds);
                     }
                     if (isset($entryFilter->fields["_matchor_categories_ids"])) {
                         $categoriesIds = explode(",", $entryFilter->fields["_matchor_categories_ids"]);
                         $newCategoriesIds = array();
                         foreach ($categoriesIds as $categoryId) {
                             $newCategoriesIds[] = kObjectCopyHandler::getMappedId(categoryPeer::OM_CLASS, $categoryId);
                         }
                         $entryFilter->fields["_matchor_categories_ids"] = implode(",", $newCategoriesIds);
                     }
                     if (isset($entryFilter->fields["_in_category_ancestor_id"])) {
                         $categoriesIds = explode(",", $entryFilter->fields["_in_category_ancestor_id"]);
                         $newCategoriesIds = array();
                         foreach ($categoriesIds as $categoryId) {
                             $newCategoriesIds[] = kObjectCopyHandler::getMappedId(categoryPeer::OM_CLASS, $categoryId);
                         }
                         $entryFilter->fields["_in_category_ancestor_id"] = implode(",", $newCategoriesIds);
                     }
                     $toEntryFilterXML = $toFiltersXml->addChild("filter");
                     $toEntryFilterXML = $entryFilter->toXml($toEntryFilterXML);
                 }
                 $newEntry->setDataContent($toPlaylistXml->asXML());
                 break;
         }
     }
     if ($shouldCopyDataForNonClip || $shouldCopyDataForClip) {
         // copy the data
         $from = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA);
         // replaced__getDataPath
         $to = $newEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA);
         // replaced__getDataPath
         KalturaLog::log("copyEntriesByType - copying entry data [" . $from . "] to [" . $to . "]");
         kFileSyncUtils::softCopy($from, $to);
     }
     $ismFrom = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISM);
     if (kFileSyncUtils::fileSync_exists($ismFrom)) {
         $ismTo = $newEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISM);
         KalturaLog::log("copying entry ism [" . $ismFrom . "] to [" . $ismTo . "]");
         kFileSyncUtils::softCopy($ismFrom, $ismTo);
     }
     $ismcFrom = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISMC);
     if (kFileSyncUtils::fileSync_exists($ismcFrom)) {
         $ismcTo = $newEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISMC);
         KalturaLog::log("copying entry ism [" . $ismcFrom . "] to [" . $ismcTo . "]");
         kFileSyncUtils::softCopy($ismcFrom, $ismcTo);
     }
     $from = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB);
     // replaced__getThumbnailPath
     $considerCopyThumb = true;
     // if entry is image - data is thumbnail, and it was copied
     if ($entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_IMAGE) {
         $considerCopyThumb = false;
     }
     // if entry is not clip, and there is no file in both DCs - nothing to copy
     if ($entry->getType() != entryType::MEDIA_CLIP && !kFileSyncUtils::file_exists($from, true)) {
         $considerCopyThumb = false;
     }
     if ($considerCopyThumb) {
         $skipThumb = false;
         // don't attempt to copy a thumbnail for images - it's the same as the data which was just created
         if ($entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_AUDIO) {
             // check if audio entry has real thumb, if not - don't copy thumb.
             $originalFileSync = kFileSyncUtils::getOriginFileSyncForKey($from, false);
             if (!$originalFileSync) {
                 $skipThumb = true;
             }
         }
         if (!$skipThumb) {
             $to = $newEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB);
             // replaced__getThumbnailPath
             KalturaLog::log("copyEntriesByType - copying entry thumbnail [" . $from . "] to [" . $to . "]");
             kFileSyncUtils::softCopy($from, $to);
         }
     }
     // added by Tan-Tan 12/01/2010 to support falvors copy
     $sourceAssets = assetPeer::retrieveByEntryId($entry->getId());
     foreach ($sourceAssets as $sourceAsset) {
         $sourceAsset->copyToEntry($newEntry->getId(), $newEntry->getPartnerId());
     }
     // copy relationships to categories
     KalturaLog::debug('Copy relationships to categories from entry [' . $entry->getId() . '] to entry [' . $newEntry->getId() . ']');
     $c = KalturaCriteria::create(categoryEntryPeer::OM_CLASS);
     $c->addAnd(categoryEntryPeer::ENTRY_ID, $entry->getId());
     $c->addAnd(categoryEntryPeer::STATUS, CategoryEntryStatus::ACTIVE, Criteria::EQUAL);
     $c->addAnd(categoryEntryPeer::PARTNER_ID, $entry->getPartnerId());
     categoryEntryPeer::setUseCriteriaFilter(false);
     $categoryEntries = categoryEntryPeer::doSelect($c);
     categoryEntryPeer::setUseCriteriaFilter(true);
     // Create srcCategoryIdToDstCategoryIdMap - a map of source partner category ids -> dst. partner category ids
     //
     // Build src category IDs set
     $srcCategoryIdSet = array();
     foreach ($categoryEntries as $categoryEntry) {
         $srcCategoryIdSet[] = $categoryEntry->getCategoryId();
     }
     $illegalCategoryStatus = array(CategoryStatus::DELETED, CategoryStatus::PURGED);
     // Get src category objects
     $c = KalturaCriteria::create(categoryPeer::OM_CLASS);
     $c->add(categoryPeer::ID, $srcCategoryIdSet, Criteria::IN);
     $c->addAnd(categoryPeer::PARTNER_ID, $entry->getPartnerId());
     $c->addAnd(categoryPeer::STATUS, $illegalCategoryStatus, Criteria::NOT_IN);
     categoryPeer::setUseCriteriaFilter(false);
     $srcCategories = categoryPeer::doSelect($c);
     categoryPeer::setUseCriteriaFilter(true);
     // Map the category names to their IDs
     $fullNamesToSrcCategoryIdMap = array();
     foreach ($srcCategories as $category) {
         $fullNamesToSrcCategoryIdMap[$category->getFullName()] = $category->getId();
     }
     // Get dst. partner categories based on src. category full-names
     $c = KalturaCriteria::create(categoryPeer::OM_CLASS);
     $c->add(categoryPeer::FULL_NAME, array_keys($fullNamesToSrcCategoryIdMap), KalturaCriteria::IN);
     $c->addAnd(categoryPeer::PARTNER_ID, $newEntry->getPartnerId());
     $c->addAnd(categoryPeer::STATUS, $illegalCategoryStatus, Criteria::NOT_IN);
     categoryPeer::setUseCriteriaFilter(false);
     $dstCategories = categoryPeer::doSelect($c);
     categoryPeer::setUseCriteriaFilter(true);
     $srcCategoryIdToDstCategoryIdMap = array();
     foreach ($dstCategories as $dstCategory) {
         $fullName = $dstCategory->getFullName();
         if (array_key_exists($fullName, $fullNamesToSrcCategoryIdMap)) {
             $srcCategoryId = $fullNamesToSrcCategoryIdMap[$fullName];
             $srcCategoryIdToDstCategoryIdMap[$srcCategoryId] = $dstCategory->getId();
         }
     }
     foreach ($categoryEntries as $categoryEntry) {
         /* @var $categoryEntry categoryEntry */
         $newCategoryEntry = $categoryEntry->copy();
         $newCategoryEntry->setPartnerId($newEntry->getPartnerId());
         $newCategoryEntry->setEntryId($newEntry->getId());
         $srcCategoryId = $categoryEntry->getCategoryId();
         if (!array_key_exists($srcCategoryId, $srcCategoryIdToDstCategoryIdMap)) {
             continue;
             // Skip the category_entry's creation
         }
         $dstCategoryId = $srcCategoryIdToDstCategoryIdMap[$srcCategoryId];
         $newCategoryEntry->setCategoryId($dstCategoryId);
         categoryPeer::setUseCriteriaFilter(false);
         entryPeer::setUseCriteriaFilter(false);
         $newCategoryEntry->save();
         entryPeer::setUseCriteriaFilter(true);
         categoryPeer::setUseCriteriaFilter(true);
     }
     return $newEntry;
 }