Example #1
0
 protected function duplicateTemplateEntry($conversionProfileId)
 {
     $dbEntry = null;
     $conversionProfile = myPartnerUtils::getConversionProfile2ForPartner($this->getPartnerId(), $conversionProfileId);
     if ($conversionProfile && $conversionProfile->getDefaultEntryId()) {
         $templateEntry = entryPeer::retrieveByPKNoFilter($conversionProfile->getDefaultEntryId(), null, false);
         if ($templateEntry) {
             $dbEntry = $templateEntry->copyTemplate(true);
         }
     }
     return $dbEntry;
 }
Example #2
0
 /**
  * @param KalturaResource $resource
  * @param entry $dbEntry
  * @param int $conversionProfileId
  */
 protected function replaceResource(KalturaResource $resource, entry $dbEntry, $conversionProfileId = null, $advancedOptions = null)
 {
     if ($advancedOptions) {
         $dbEntry->setReplacementOptions($advancedOptions->toObject());
         $dbEntry->save();
     }
     if ($dbEntry->getStatus() == KalturaEntryStatus::NO_CONTENT || $dbEntry->getMediaType() == KalturaMediaType::IMAGE) {
         $resource->validateEntry($dbEntry);
         if ($conversionProfileId) {
             $dbEntry->setConversionQuality($conversionProfileId);
             $dbEntry->save();
         }
         $kResource = $resource->toObject();
         $this->attachResource($kResource, $dbEntry);
     } else {
         $tempMediaEntry = new KalturaMediaEntry();
         $tempMediaEntry->type = $dbEntry->getType();
         $tempMediaEntry->mediaType = $dbEntry->getMediaType();
         if (!$conversionProfileId) {
             $originalConversionProfileId = $dbEntry->getConversionQuality();
             $conversionProfile = conversionProfile2Peer::retrieveByPK($originalConversionProfileId);
             if (is_null($conversionProfile) || $conversionProfile->getType() != ConversionProfileType::MEDIA) {
                 $defaultConversionProfile = myPartnerUtils::getConversionProfile2ForPartner($this->getPartnerId());
                 if (!is_null($defaultConversionProfile)) {
                     $conversionProfileId = $defaultConversionProfile->getId();
                 }
             } else {
                 $conversionProfileId = $originalConversionProfileId;
             }
         }
         if ($conversionProfileId) {
             $tempMediaEntry->conversionProfileId = $conversionProfileId;
         }
         $this->replaceResourceByEntry($dbEntry, $resource, $tempMediaEntry);
     }
     $resource->entryHandled($dbEntry);
 }
 /**
  * Adds entry
  * 
  * @param KalturaBaseEntry $entry
  * @return entry
  */
 protected function add(KalturaBaseEntry $entry, $conversionProfileId = null)
 {
     $dbEntry = null;
     $conversionProfile = myPartnerUtils::getConversionProfile2ForPartner($this->getPartnerId(), $conversionProfileId);
     if ($conversionProfile && $conversionProfile->getDefaultEntryId()) {
         $templateEntry = entryPeer::retrieveByPK($conversionProfile->getDefaultEntryId());
         if ($templateEntry) {
             $dbEntry = $templateEntry->copyTemplate(true);
             $dbEntry->save();
         } else {
             KalturaLog::err("Template entry id [" . $conversionProfile->getDefaultEntryId() . "] not found");
         }
     }
     return $this->prepareEntryForInsert($entry, $dbEntry);
 }
Example #4
0
 /**
  * @param KalturaResource $resource
  * @param entry $dbEntry
  * @param int $conversionProfileId
  */
 protected function replaceResource(KalturaResource $resource, entry $dbEntry, $conversionProfileId = null, $advancedOptions = null)
 {
     if ($advancedOptions) {
         $dbEntry->setReplacementOptions($advancedOptions->toObject());
         $dbEntry->save();
     }
     if ($dbEntry->getStatus() == KalturaEntryStatus::NO_CONTENT || $dbEntry->getMediaType() == KalturaMediaType::IMAGE) {
         $resource->validateEntry($dbEntry);
         if ($conversionProfileId) {
             $dbEntry->setConversionQuality($conversionProfileId);
             $dbEntry->save();
         }
         $kResource = $resource->toObject();
         $this->attachResource($kResource, $dbEntry);
     } else {
         $kResource = $resource->toObject();
         if ($kResource instanceof kOperationResource && $this->isResourceKClip($kResource)) {
             $internalResource = $kResource->getResource();
             if ($dbEntry->getIsTrimDisabled() && $internalResource instanceof kFileSyncResource && $dbEntry->getId() == $internalResource->getOriginEntryId()) {
                 throw new KalturaAPIException(KalturaErrors::ENTRY_CANNOT_BE_TRIMMED);
             }
         }
         $tempMediaEntry = new KalturaMediaEntry();
         $tempMediaEntry->type = $dbEntry->getType();
         $tempMediaEntry->mediaType = $dbEntry->getMediaType();
         if (!$conversionProfileId) {
             $originalConversionProfileId = $dbEntry->getConversionQuality();
             $conversionProfile = conversionProfile2Peer::retrieveByPK($originalConversionProfileId);
             if (is_null($conversionProfile) || $conversionProfile->getType() != ConversionProfileType::MEDIA) {
                 $defaultConversionProfile = myPartnerUtils::getConversionProfile2ForPartner($this->getPartnerId());
                 if (!is_null($defaultConversionProfile)) {
                     $conversionProfileId = $defaultConversionProfile->getId();
                 }
             } else {
                 $conversionProfileId = $originalConversionProfileId;
             }
         }
         if ($conversionProfileId) {
             $tempMediaEntry->conversionProfileId = $conversionProfileId;
         }
         $this->replaceResourceByEntry($dbEntry, $resource, $tempMediaEntry);
     }
     $resource->entryHandled($dbEntry);
 }