Remove unused directories and files in video_in_hal
[staging/basesystem.git] / nsframework / notification_persistent_service / server / src / ns_npp_persist_file.cpp
1 /*
2  * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
3  *
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
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
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.
21 ///
22 ///
23 ////////////////////////////////////////////////////////////////////////////////////////////////////
24 #include <unistd.h>
25 #include <string>
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"
30
31 ////////////////////////////////////////////////////////////////////////////////////////////////////
32 /// CFilePersistence
33 /// Constructor of CFilePersistence class
34 ////////////////////////////////////////////////////////////////////////////////////////////////////
35 CFilePersistence::CFilePersistence() {
36 }
37
38 ////////////////////////////////////////////////////////////////////////////////////////////////////
39 /// CFilePersistence
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
44 }
45 // LCOV_EXCL_STOP
46
47 ////////////////////////////////////////////////////////////////////////////////////////////////////
48 /// Release
49 /// Entry for the file is stored in map for persistence.
50 ////////////////////////////////////////////////////////////////////////////////////////////////////
51 EFrameworkunifiedStatus CFilePersistence::Release(std::string f_crequesterappname,
52                                      std::string f_ctag,
53                                      std::string f_cmempath,
54                                      EFrameworkunifiedReleaseType enotificationpersistentservicereleasetype,
55                                      std::string f_cusername) {
56   EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
57   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
58
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;
64     // LCOV_EXCL_STOP
65   } else {
66     l_estatus = ProcessReleaseRequest(f_crequesterappname, f_ctag, ENOTIFICATIONPERSISTENTSERVICEPERSISTFILE, f_cmempath, enotificationpersistentservicereleasetype,
67                                       f_cusername);  // LCOV_EXCL_BR_LINE 11: unexpected branch
68   }
69
70   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "- l_estatus:0x%x", l_estatus);
71   return l_estatus;
72 }
73
74 ////////////////////////////////////////////////////////////////////////////////////////////////////
75 /// Load
76 /// Load file from persistent memory to the specified location.
77 ////////////////////////////////////////////////////////////////////////////////////////////////////
78 EFrameworkunifiedStatus CFilePersistence::Load(std::string f_crequesterappname,
79                                   std::string f_ctag,
80                                   std::string f_cretrievepath,
81                                   std::string f_cusername) {
82   EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
83   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
84
85
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
88   } else {
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());
93
94     l_estatus = eFrameworkunifiedStatusInvldParam;
95     // LCOV_EXCL_STOP
96   }
97
98   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
99   return l_estatus;
100 }