当前位置: 首页>>代码示例>>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;未经允许,请勿转载。