1 /*
2 * Copyright (c) 2021 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 #include "metadata/corrupted_meta_data.h"
17
18 #include "utils/constant.h"
19 namespace OHOS {
20 namespace DistributedData {
Marshal(json & node) const21 bool CorruptedMetaData::Marshal(json &node) const
22 {
23 SetValue(node[GET_NAME(appId)], appId);
24 SetValue(node[GET_NAME(bundleName)], bundleName);
25 SetValue(node[GET_NAME(storeId)], storeId);
26 SetValue(node[GET_NAME(isCorrupted)], isCorrupted);
27 return true;
28 }
29
Unmarshal(const json & node)30 bool CorruptedMetaData::Unmarshal(const json &node)
31 {
32 GetValue(node, GET_NAME(appId), appId);
33 GetValue(node, GET_NAME(bundleName), bundleName);
34 GetValue(node, GET_NAME(storeId), storeId);
35 GetValue(node, GET_NAME(isCorrupted), isCorrupted);
36 return true;
37 }
38
CorruptedMetaData()39 CorruptedMetaData::CorruptedMetaData()
40 {
41 }
42
~CorruptedMetaData()43 CorruptedMetaData::~CorruptedMetaData()
44 {
45 }
46
CorruptedMetaData(const std::string & appId,const std::string & bundleName,const std::string & storeId)47 CorruptedMetaData::CorruptedMetaData(
48 const std::string &appId, const std::string &bundleName, const std::string &storeId)
49 : appId(appId), bundleName(bundleName), storeId(storeId)
50 {
51 }
52
GetKey()53 std::string CorruptedMetaData::GetKey()
54 {
55 return Constant::Join(KEY_PREFIX, Constant::KEY_SEPARATOR,
56 { appId, bundleName, storeId });
57 }
58 } // namespace DistributedData
59 } // namespace OHOS
60