protected function addBulkUploadResult(KalturaBulkUploadResult $bulkUploadResult)
 {
     parent::addBulkUploadResult($bulkUploadResult);
     if (($bulkUploadResult->entryId || $bulkUploadResult->objectId) && $bulkUploadResult->entryStatus == KalturaEntryStatus::IMPORT) {
         $url = $bulkUploadResult->url;
         $isSsh = stripos($url, 'sftp:') === 0 || stripos($url, 'scp:') === 0;
         if ($isSsh) {
             $resource = new KalturaSshUrlResource();
             $resource->privateKey = $bulkUploadResult->sshPrivateKey;
             $resource->publicKey = $bulkUploadResult->sshPublicKey;
             $resource->keyPassphrase = $bulkUploadResult->sshKeyPassphrase;
         } else {
             $resource = new KalturaUrlResource();
         }
         $resource->url = $url;
         $this->impersonate();
         $this->kClient->media->addContent($bulkUploadResult->entryId, $resource);
         $this->unimpersonate();
     }
 }
 protected function addBulkUploadResult(KalturaBulkUploadResult $bulkUploadResult)
 {
     parent::addBulkUploadResult($bulkUploadResult);
 }
 /**
  *
  * Creates a new upload result object from the given parameters
  * @param array $values
  * @param array $columns
  */
 protected function createUploadResult($values, $columns)
 {
     $bulkUploadResult = parent::createUploadResult($values, $columns);
     if (!$bulkUploadResult) {
         return;
     }
     $bulkUploadResult->bulkUploadResultObjectType = KalturaBulkUploadResultObjectType::ENTRY;
     // Check variables count
     if ($this->csvVersion != KalturaBulkUploadCsvVersion::V3) {
         if (count($values) == self::VALUES_COUNT_V1) {
             $this->csvVersion = KalturaBulkUploadCsvVersion::V1;
             $columns = $this->getV1Columns();
         } elseif (count($values) == self::VALUES_COUNT_V2) {
             $this->csvVersion = KalturaBulkUploadCsvVersion::V2;
             $columns = $this->getV2Columns();
         } else {
             // fail and continue with next line
             $bulkUploadResult->entryStatus = KalturaEntryStatus::ERROR_IMPORTING;
             $bulkUploadResult->status = KalturaBulkUploadResultStatus::ERROR;
             $bulkUploadResult->errorDescription = "Wrong number of values on line {$this->lineNumber}";
             $this->addBulkUploadResult($bulkUploadResult);
             return;
         }
         KalturaLog::info("Columns:\n" . print_r($columns, true));
     }
     // trim the values
     array_walk($values, array('BulkUploadEntryEngineCsv', 'trimArray'));
     $scheduleStartDate = null;
     $scheduleEndDate = null;
     // sets the result values
     foreach ($columns as $index => $column) {
         if (!is_numeric($index)) {
             continue;
         }
         if ($column == 'scheduleStartDate' || $column == 'scheduleEndDate') {
             ${$column} = strlen($values[$index]) ? $values[$index] : null;
             KalturaLog::info("Set value \${$column} [{${$column}}]");
         } else {
             if ($column == 'entryId') {
                 $bulkUploadResult->objectId = $values[$index];
             } else {
                 if (iconv_strlen($values[$index], 'UTF-8')) {
                     $bulkUploadResult->{$column} = $values[$index];
                     KalturaLog::info("Set value {$column} [{$bulkUploadResult->{$column}}]");
                 } else {
                     KalturaLog::info("Value {$column} is empty");
                 }
             }
         }
     }
     if (isset($columns['plugins'])) {
         $bulkUploadPlugins = array();
         foreach ($columns['plugins'] as $index => $column) {
             $bulkUploadPlugin = new KalturaBulkUploadPluginData();
             $bulkUploadPlugin->field = $column;
             $bulkUploadPlugin->value = iconv_strlen($values[$index], 'UTF-8') ? $values[$index] : null;
             $bulkUploadPlugins[] = $bulkUploadPlugin;
             KalturaLog::info("Set plugin value {$column} [{$bulkUploadPlugin->value}]");
         }
         $bulkUploadResult->pluginsData = $bulkUploadPlugins;
     }
     $bulkUploadResult->entryStatus = KalturaEntryStatus::IMPORT;
     $bulkUploadResult->status = KalturaBulkUploadResultStatus::IN_PROGRESS;
     if (!$bulkUploadResult->action) {
         $bulkUploadResult->action = KalturaBulkUploadAction::ADD;
     }
     if (!is_numeric($bulkUploadResult->conversionProfileId)) {
         $bulkUploadResult->conversionProfileId = null;
     }
     if (!is_numeric($bulkUploadResult->accessControlProfileId)) {
         $bulkUploadResult->accessControlProfileId = null;
     }
     if ($this->maxRecords && $this->lineNumber > $this->maxRecords) {
         $bulkUploadResult->entryStatus = KalturaEntryStatus::ERROR_IMPORTING;
         $bulkUploadResult->status = KalturaBulkUploadResultStatus::ERROR;
         $bulkUploadResult->errorDescription = "Exeeded max records count per bulk";
     }
     if (!$this->isUrl($bulkUploadResult->url)) {
         $bulkUploadResult->entryStatus = KalturaEntryStatus::ERROR_IMPORTING;
         $bulkUploadResult->status = KalturaBulkUploadResultStatus::ERROR;
         $bulkUploadResult->errorDescription = "Invalid url '{$bulkUploadResult->url}' on line {$this->lineNumber}";
     }
     if ($scheduleStartDate && !self::isFormatedDate($scheduleStartDate)) {
         $bulkUploadResult->entryStatus = KalturaEntryStatus::ERROR_IMPORTING;
         $bulkUploadResult->status = KalturaBulkUploadResultStatus::ERROR;
         $bulkUploadResult->errorDescription = "Invalid schedule start date '{$scheduleStartDate}' on line {$this->lineNumber}";
     }
     if ($scheduleEndDate && !self::isFormatedDate($scheduleEndDate)) {
         $bulkUploadResult->entryStatus = KalturaEntryStatus::ERROR_IMPORTING;
         $bulkUploadResult->status = KalturaBulkUploadResultStatus::ERROR;
         $bulkUploadResult->errorDescription = "Invalid schedule end date '{$scheduleEndDate}' on line {$this->lineNumber}";
     }
     $privateKey = isset($bulkUploadResult->sshPrivateKey) ? $bulkUploadResult->sshPrivateKey : false;
     $publicKey = isset($bulkUploadResult->sshPublicKey) ? $bulkUploadResult->sshPublicKey : false;
     if (empty($privateKey) & !empty($publicKey)) {
         $bulkUploadResult->entryStatus = KalturaEntryStatus::ERROR_IMPORTING;
         $bulkUploadResult->status = KalturaBulkUploadResultStatus::ERROR;
         $bulkUploadResult->errorDescription = "Missing SSH private key on line  {$this->lineNumber}";
     } else {
         if (!empty($privateKey) & empty($publicKey)) {
             $bulkUploadResult->entryStatus = KalturaEntryStatus::ERROR_IMPORTING;
             $bulkUploadResult->status = KalturaBulkUploadResultStatus::ERROR;
             $bulkUploadResult->errorDescription = "Missing SSH public key on line {$this->lineNumber}";
         }
     }
     if ($bulkUploadResult->status == KalturaBulkUploadResultStatus::ERROR) {
         $this->addBulkUploadResult($bulkUploadResult);
         return;
     }
     $bulkUploadResult->scheduleStartDate = self::parseFormatedDate($scheduleStartDate);
     $bulkUploadResult->scheduleEndDate = self::parseFormatedDate($scheduleEndDate);
     $this->bulkUploadResults[] = $bulkUploadResult;
 }