• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 * Copyright (c) 2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15 
16 #define LOG_TAG "RdbAssetLoader"
17 #include "rdb_asset_loader.h"
18 
19 #include "error/general_error.h"
20 #include "log_print.h"
21 #include "rdb_cloud.h"
22 #include "value_proxy.h"
23 
24 using namespace DistributedDB;
25 namespace OHOS::DistributedRdb {
RdbAssetLoader(std::shared_ptr<DistributedData::AssetLoader> cloudAssetLoader)26 RdbAssetLoader::RdbAssetLoader(std::shared_ptr<DistributedData::AssetLoader> cloudAssetLoader)
27     : assetLoader_(std::move(cloudAssetLoader))
28 {
29 }
30 
Download(const std::string & tableName,const std::string & gid,const Type & prefix,std::map<std::string,Assets> & assets)31 DBStatus RdbAssetLoader::Download(const std::string &tableName, const std::string &gid, const Type &prefix,
32     std::map<std::string, Assets> &assets)
33 {
34     DistributedData::VBucket downLoadAssets = ValueProxy::Convert(assets);
35     DistributedDB::Type prefixTemp = prefix;
36     auto error = assetLoader_->Download(tableName, gid, ValueProxy::Convert(std::move(prefixTemp)), downLoadAssets);
37     if (error == DistributedData::GeneralError::E_OK) {
38         assets = ValueProxy::Convert(std::move(downLoadAssets));
39     }
40     return RdbCloud::ConvertStatus(static_cast<DistributedData::GeneralError>(error));
41 }
42 } // namespace OHOS::DistributedRdb