2 * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 ////////////////////////////////////////////////////////////////////////////////////////////////////
18 /// \ingroup tag_NPPService
19 /// \brief The file contains definition of CFilePersistence class.
20 /// This class is responsible for persisting and retrieving of files.
23 ////////////////////////////////////////////////////////////////////////////////////////////////////
26 #include "ns_npp_notificationpersistentservicelog.h"
27 #include "ns_npp_copy_worker.h"
28 #include "ns_npp_persist_file.h"
29 #include "ns_npp_registry_entry.h"
31 ////////////////////////////////////////////////////////////////////////////////////////////////////
33 /// Constructor of CFilePersistence class
34 ////////////////////////////////////////////////////////////////////////////////////////////////////
35 CFilePersistence::CFilePersistence() {
38 ////////////////////////////////////////////////////////////////////////////////////////////////////
40 /// Destructor of CFilePersistence class
41 ////////////////////////////////////////////////////////////////////////////////////////////////////
42 CFilePersistence::~CFilePersistence() { // LCOV_EXCL_START 14: Resident process, global instance not released
43 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
47 ////////////////////////////////////////////////////////////////////////////////////////////////////
49 /// Entry for the file is stored in map for persistence.
50 ////////////////////////////////////////////////////////////////////////////////////////////////////
51 EFrameworkunifiedStatus CFilePersistence::Release(std::string f_crequesterappname,
53 std::string f_cmempath,
54 EFrameworkunifiedReleaseType enotificationpersistentservicereleasetype,
55 std::string f_cusername) {
56 EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
57 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
59 if (f_cmempath.empty() || f_crequesterappname.empty() || f_ctag.empty()) { // LCOV_EXCL_BR_LINE 6: double check, f_cmempath, f_crequesterappname and f_ctag can't be empty
60 // LCOV_EXCL_START 6: f_cmempath, f_crequesterappname and f_ctag can't be empty
61 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
62 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Invalid file path, requester or tag.");
63 l_estatus = eFrameworkunifiedStatusInvldParam;
66 l_estatus = ProcessReleaseRequest(f_crequesterappname, f_ctag, ENOTIFICATIONPERSISTENTSERVICEPERSISTFILE, f_cmempath, enotificationpersistentservicereleasetype,
67 f_cusername); // LCOV_EXCL_BR_LINE 11: unexpected branch
70 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "- l_estatus:0x%x", l_estatus);
74 ////////////////////////////////////////////////////////////////////////////////////////////////////
76 /// Load file from persistent memory to the specified location.
77 ////////////////////////////////////////////////////////////////////////////////////////////////////
78 EFrameworkunifiedStatus CFilePersistence::Load(std::string f_crequesterappname,
80 std::string f_cretrievepath,
81 std::string f_cusername) {
82 EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
83 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
86 if (!f_ctag.empty() && !f_crequesterappname.empty() && !f_cretrievepath.empty()) { // LCOV_EXCL_BR_LINE 6: double check, f_ctag, f_crequesterappname and f_cretrievepath can't be empty
87 l_estatus = ProcessLoadRequest(f_crequesterappname, f_ctag, ENOTIFICATIONPERSISTENTSERVICEPERSISTFILE, f_cretrievepath, f_cusername); // LCOV_EXCL_BR_LINE 11: unexpected branch
89 // LCOV_EXCL_START 6: f_ctag, f_crequesterappname and f_cretrievepath can't be empty
90 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
91 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Invalid argument passed (RetrievePath:%s ,tag:%s, requester:%s)",
92 f_cretrievepath.c_str(), f_ctag.c_str(), f_crequesterappname.c_str());
94 l_estatus = eFrameworkunifiedStatusInvldParam;
98 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");