當前位置: 首頁>>代碼示例>>PHP>>正文


PHP kFileSyncUtils::compareContent方法代碼示例

本文整理匯總了PHP中kFileSyncUtils::compareContent方法的典型用法代碼示例。如果您正苦於以下問題:PHP kFileSyncUtils::compareContent方法的具體用法?PHP kFileSyncUtils::compareContent怎麽用?PHP kFileSyncUtils::compareContent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在kFileSyncUtils的用法示例。


在下文中一共展示了kFileSyncUtils::compareContent方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: updateImpl

 function updateImpl($id, $xmlData = null, $version = null)
 {
     $dbMetadata = MetadataPeer::retrieveByPK($id);
     if (!$dbMetadata) {
         throw new KalturaAPIException(MetadataErrors::METADATA_NOT_FOUND, $id);
     }
     if ($version && $dbMetadata->getVersion() != $version) {
         throw new KalturaAPIException(MetadataErrors::INVALID_METADATA_VERSION, $dbMetadata->getVersion());
     }
     $dbMetadataProfile = MetadataProfilePeer::retrieveByPK($dbMetadata->getMetadataProfileId());
     if (!$dbMetadataProfile) {
         throw new KalturaAPIException(MetadataErrors::INVALID_METADATA_PROFILE, $dbMetadata->getMetadataProfileId());
     }
     $previousVersion = null;
     if ($dbMetadata->getStatus() == Metadata::STATUS_VALID) {
         $previousVersion = $dbMetadata->getVersion();
     }
     if ($xmlData) {
         // if a metadata xslt is defined on the metadata profile - transform the given metadata
         $xmlDataTransformed = $this->transformMetadata($dbMetadata->getMetadataProfileId(), $xmlData);
         if ($xmlDataTransformed) {
             $xmlData = $xmlDataTransformed;
         }
         $errorMessage = '';
         if (!kMetadataManager::validateMetadata($dbMetadata->getMetadataProfileId(), $xmlData, $errorMessage)) {
             // if metadata profile is transforming, and metadata profile version is not the latest, try to validate againts previous version
             if ($dbMetadataProfile->getStatus() != MetadataProfile::STATUS_TRANSFORMING || $dbMetadata->getMetadataProfileVersion() >= $dbMetadataProfile->getVersion()) {
                 throw new KalturaAPIException(MetadataErrors::INVALID_METADATA_DATA, $errorMessage);
             }
             // validates against previous version
             $errorMessagePrevVersion = '';
             if (!kMetadataManager::validateMetadata($dbMetadata->getMetadataProfileId(), $xmlData, $errorMessagePrevVersion, true)) {
                 KalturaLog::err("Failed to validate metadata object [{$id}] against metadata profile previous version [" . $dbMetadata->getMetadataProfileVersion() . "] error: {$errorMessagePrevVersion}");
                 // throw the error with the original error message
                 throw new KalturaAPIException(MetadataErrors::INVALID_METADATA_DATA, $errorMessage);
             }
         } else {
             $dbMetadata->setMetadataProfileVersion($dbMetadataProfile->getVersion());
         }
         $key = $dbMetadata->getSyncKey(Metadata::FILE_SYNC_METADATA_DATA);
         if (!kFileSyncUtils::compareContent($key, $xmlData)) {
             $dbMetadata->incrementVersion();
             $key = $dbMetadata->getSyncKey(Metadata::FILE_SYNC_METADATA_DATA);
             kFileSyncUtils::file_put_contents($key, $xmlData);
             $dbMetadata->save();
             kEventsManager::raiseEvent(new kObjectDataChangedEvent($dbMetadata, $previousVersion));
         } else {
             KalturaLog::info("XML data MD5 matches current filesync content MD5. Update is not necessary.");
             //adding this save() in order to save the metadata profile version field in case there are no diffrences
             $dbMetadata->save();
         }
     }
     $metadata = new KalturaMetadata();
     $metadata->fromObject($dbMetadata, $this->getResponseProfile());
     return $metadata;
 }
開發者ID:DBezemer,項目名稱:server,代碼行數:56,代碼來源:MetadataService.php


注:本文中的kFileSyncUtils::compareContent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。