예제 #1
0
 /**
  * Generic add entry using an uploaded file, should be used when the uploaded entry type is not known
  *
  * @action addFromUploadedFile
  * @param KalturaBaseEntry $entry
  * @param string $uploadTokenId
  * @param KalturaEntryType $type
  * @return KalturaBaseEntry
  */
 function addFromUploadedFileAction(KalturaBaseEntry $entry, $uploadTokenId, $type = -1)
 {
     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) {
             kFile::dumpApiRequest($remoteDCHost);
         } else {
             throw new KalturaAPIException(KalturaErrors::UPLOADED_FILE_NOT_FOUND_BY_TOKEN);
         }
     }
     // validate the input object
     //$entry->validatePropertyMinLength("name", 1);
     if (!$entry->name) {
         $entry->name = $this->getPartnerId() . '_' . time();
     }
     // first copy all the properties to the db entry, then we'll check for security stuff
     $dbEntry = $entry->toInsertableObject(new entry());
     $dbEntry->setType($type);
     $dbEntry->setMediaType(entry::ENTRY_MEDIA_TYPE_AUTOMATIC);
     $this->checkAndSetValidUser($entry, $dbEntry);
     $this->checkAdminOnlyInsertProperties($entry);
     $this->validateAccessControlId($entry);
     $this->validateEntryScheduleDates($entry);
     $dbEntry->setPartnerId($this->getPartnerId());
     $dbEntry->setSubpId($this->getPartnerId() * 100);
     $dbEntry->setSourceId($uploadTokenId);
     $dbEntry->setSourceLink($entryFullPath);
     $dbEntry->setDefaultModerationStatus();
     $dbEntry->save();
     $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);
     $entry->fromObject($dbEntry);
     return $entry;
 }
예제 #2
0
 /**
  * @param KalturaBaseEntry $entry
  * @return entry
  */
 protected function prepareEntryForInsert(KalturaBaseEntry $entry)
 {
     // create a default name if none was given
     if (!$entry->name) {
         $entry->name = $this->getPartnerId() . '_' . time();
     }
     // first copy all the properties to the db entry, then we'll check for security stuff
     $dbEntry = $entry->toInsertableObject(new entry());
     $this->checkAndSetValidUser($entry, $dbEntry);
     $this->checkAdminOnlyInsertProperties($entry);
     $this->validateAccessControlId($entry);
     $this->validateEntryScheduleDates($entry);
     $dbEntry->setPartnerId($this->getPartnerId());
     $dbEntry->setSubpId($this->getPartnerId() * 100);
     $dbEntry->setDefaultModerationStatus();
     return $dbEntry;
 }
예제 #3
0
 /**
  * @param KalturaBaseEntry $entry
  * @param entry $dbEntry
  * @return entry
  */
 protected function prepareEntryForInsert(KalturaBaseEntry $entry, entry $dbEntry = null)
 {
     // create a default name if none was given
     if (!$entry->name) {
         $entry->name = $this->getPartnerId() . '_' . time();
     }
     if ($entry->licenseType === null) {
         $entry->licenseType = KalturaLicenseType::UNKNOWN;
     }
     // first copy all the properties to the db entry, then we'll check for security stuff
     if (!$dbEntry) {
         $entryType = kPluginableEnumsManager::apiToCore('entryType', $entry->type);
         $class = entryPeer::getEntryClassByType($entryType);
         KalturaLog::debug("Creating new entry of API type [{$entry->type}] core type [{$entryType}] class [{$class}]");
         $dbEntry = new $class();
     }
     $dbEntry = $entry->toInsertableObject($dbEntry);
     $this->checkAndSetValidUserInsert($entry, $dbEntry);
     $this->checkAdminOnlyInsertProperties($entry);
     $this->validateAccessControlId($entry);
     $this->validateEntryScheduleDates($entry, $dbEntry);
     $dbEntry->setPartnerId($this->getPartnerId());
     $dbEntry->setSubpId($this->getPartnerId() * 100);
     $dbEntry->setDefaultModerationStatus();
     return $dbEntry;
 }