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 declaration of CRegistryEntry class.
23 ////////////////////////////////////////////////////////////////////////////////////////////////////
25 #include "ns_npp_notificationpersistentservicelog.h"
26 #include "ns_npp_registry_entry.h"
28 ////////////////////////////////////////////////////////////////////////////////////////////
30 ////////////////////////////////////////////////////////////////////////////////////////////
31 CRegistryEntry::CRegistryEntry(const std::string &f_ctag, const std::string &f_crequester,
32 const std::string &f_cstoragepath,
33 const BOOL f_bisuserpersistence):
34 m_eJobState(ENOTIFICATIONPERSISTENTSERVICEPERSISTJObSTATEIDLE),
36 m_cRequestor(f_crequester),
38 m_bIsPersisted(FALSE),
39 m_bIsUserPersistence(f_bisuserpersistence),
40 m_eCurrentAction(LOADTYPE_NONE),
41 m_ePersistType(ENOTIFICATIONPERSISTENTSERVICEPERSISTNONE),
42 m_ePersistCategory(eFrameworkunifiedUserData) {
46 m_cBasePath += f_cstoragepath;
49 ////////////////////////////////////////////////////////////////////////////////////////////
51 ////////////////////////////////////////////////////////////////////////////////////////////
52 CRegistryEntry::CRegistryEntry(const CRegistryEntry &in):
53 m_eJobState(ENOTIFICATIONPERSISTENTSERVICEPERSISTJObSTATEIDLE),
55 m_cRequestor(in.m_cRequestor),
56 m_bIsReleased(in.m_bIsReleased),
57 m_bIsPersisted(in.m_bIsPersisted),
58 m_cPersistPath(in.m_cPersistPath),
59 m_cBasePath(in.m_cBasePath),
60 m_bIsUserPersistence(in.m_bIsUserPersistence),
61 m_eCurrentAction(in.m_eCurrentAction),
62 m_ePersistType(in.m_ePersistType),
63 m_ePersistCategory(in.m_ePersistCategory) {
66 ////////////////////////////////////////////////////////////////////////////////////////////
69 ////////////////////////////////////////////////////////////////////////////////////////////
70 CRegistryEntry &CRegistryEntry::operator=(const CRegistryEntry &in) { // LCOV_EXCL_START 8: never be used
71 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
73 m_eJobState = in.m_eJobState;
75 m_cRequestor = in.m_cRequestor;
76 m_bIsReleased = in.m_bIsReleased;
77 m_bIsPersisted = in.m_bIsPersisted;
78 m_cPersistPath = in.m_cPersistPath;
79 m_cBasePath = in.m_cBasePath;
80 m_bIsUserPersistence = in.m_bIsUserPersistence;
81 m_ePersistType = in.m_ePersistType;
87 ////////////////////////////////////////////////////////////////////////////////////////////
90 ////////////////////////////////////////////////////////////////////////////////////////////
91 VOID CRegistryEntry::SetReleasePath(const std::string &f_creleasepath) {
93 m_cReleasePath = f_creleasepath;
96 ////////////////////////////////////////////////////////////////////////////////////////////
98 /// Set the file/folder is being persisted.
99 ////////////////////////////////////////////////////////////////////////////////////////////
100 VOID CRegistryEntry::SetBeingPersisted() {
101 if (LOADTYPE_RELEASE == m_eCurrentAction) {
102 m_bIsPersisted = TRUE;
106 ////////////////////////////////////////////////////////////////////////////////////////////
108 /// File/folder released or not.
109 ////////////////////////////////////////////////////////////////////////////////////////////
110 BOOL CRegistryEntry::IsReleased() const {
111 return m_bIsReleased;
114 ////////////////////////////////////////////////////////////////////////////////////////////
115 /// HasntBeenPersisted
116 /// File/Folder persisted or not
117 ////////////////////////////////////////////////////////////////////////////////////////////
118 BOOL CRegistryEntry::HasntBeenPersisted() const {
119 return !m_bIsPersisted;
122 ////////////////////////////////////////////////////////////////////////////////////////////
124 /// File persisted or not
125 ////////////////////////////////////////////////////////////////////////////////////////////
126 BOOL CRegistryEntry::IsPersisted() const {
127 return m_bIsPersisted;
130 ////////////////////////////////////////////////////////////////////////////////////////////
132 /// Get the persist path.
133 ////////////////////////////////////////////////////////////////////////////////////////////
134 std::string CRegistryEntry::GetPersistPath() const {
135 return m_cPersistPath;
138 ////////////////////////////////////////////////////////////////////////////////////////////
140 /// Get the release path.
141 ////////////////////////////////////////////////////////////////////////////////////////////
142 std::string CRegistryEntry::GetReleasePath() const {
143 return m_cReleasePath;
146 ////////////////////////////////////////////////////////////////////////////////////////////
148 /// Get the load path.
149 ////////////////////////////////////////////////////////////////////////////////////////////
150 std::string CRegistryEntry::GetLoadPath(ENotificationpersistentservicePersistType f_epersisttype, std::string f_cusername) const {
151 std::string l_cLoadPath = "";
153 if (f_epersisttype > ENOTIFICATIONPERSISTENTSERVICEPERSISTFIRST && f_epersisttype < ENOTIFICATIONPERSISTENTSERVICEPERSISTLAST) { // LCOV_EXCL_BR_LINE 6: f_epersisttype must be in range. // NOLINT[whitespace/line_length]
154 l_cLoadPath = m_cBasePath;
156 switch (m_ePersistCategory) {
157 case eFrameworkunifiedUserData: {
158 l_cLoadPath += USERDATADIR;
160 // Check if to persist for user
161 if (m_bIsUserPersistence) {
162 // if its a user file, user name can't be empty
163 if (!f_cusername.empty()) { // LCOV_EXCL_BR_LINE 6: f_cusername can't be empty
164 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Tag %s is registered for user %s", m_cTag.c_str(), f_cusername.c_str());
165 l_cLoadPath += f_cusername;
169 l_cLoadPath += ALLUSERAPPDATADIR;
174 case eFrameworkunifiedFactoryData: {
175 l_cLoadPath += FACTORYDATADIR;
178 case eFrameworkunifiedFactoryCustomerData: {
179 l_cLoadPath += FACTORYCUSTOMERDATADIR;
182 case eFrameworkunifiedDealerData: {
183 l_cLoadPath += DEALERDATADIR;
188 l_cLoadPath += m_cRequestor;
191 // file and folder persistency has different storage paths mapped
192 if (ENOTIFICATIONPERSISTENTSERVICEPERSISTFILE == f_epersisttype) {
193 l_cLoadPath += "NSFile/";
194 } else if (ENOTIFICATIONPERSISTENTSERVICEPERSISTFOLDER == f_epersisttype) { // LCOV_EXCL_BR_LINE 6: f_epersisttype must be ENOTIFICATIONPERSISTENTSERVICEPERSISTFILE or ENOTIFICATIONPERSISTENTSERVICEPERSISTFOLDER. // NOLINT[whitespace/line_length]
195 l_cLoadPath += "NSFolder/";
198 l_cLoadPath += m_cTag;
204 ////////////////////////////////////////////////////////////////////////////////////////////
206 /// Get the name of requester.
207 ////////////////////////////////////////////////////////////////////////////////////////////
208 std::string CRegistryEntry::GetRequester() const {
212 ////////////////////////////////////////////////////////////////////////////////////////////
215 ////////////////////////////////////////////////////////////////////////////////////////////
216 std::string CRegistryEntry::GetTag() const {
220 ////////////////////////////////////////////////////////////////////////////////////////////
221 /// IsUserPersistence
223 ////////////////////////////////////////////////////////////////////////////////////////////
224 BOOL CRegistryEntry::IsUserPersistence() {
225 return m_bIsUserPersistence;
228 ////////////////////////////////////////////////////////////////////////////////////////////
231 ////////////////////////////////////////////////////////////////////////////////////////////
232 VOID CRegistryEntry::SetCurrentAction(ENPS_Loadtype f_ecurrentaction) {
233 m_eCurrentAction = f_ecurrentaction;
236 ////////////////////////////////////////////////////////////////////////////////////////////
237 /// ResetPersistedFlag
239 ////////////////////////////////////////////////////////////////////////////////////////////
240 VOID CRegistryEntry::ResetPersistedFlag() {
241 m_bIsPersisted = FALSE;
244 ////////////////////////////////////////////////////////////////////////////////////////////
245 /// SetPersistProperties
247 ////////////////////////////////////////////////////////////////////////////////////////////
248 VOID CRegistryEntry::SetPersistProperties(ENotificationpersistentservicePersistType f_epersisttype, std::string f_cusername) {
249 if (f_epersisttype > ENOTIFICATIONPERSISTENTSERVICEPERSISTFIRST && f_epersisttype < ENOTIFICATIONPERSISTENTSERVICEPERSISTLAST) { // LCOV_EXCL_BR_LINE 6: f_epersisttype must be in range. // NOLINT[whitespace/line_length]
250 // set the persist type
251 m_ePersistType = f_epersisttype;
253 // set the persist file based on the persist type and username (if a user file)
254 m_cPersistPath = m_cBasePath;
256 switch (m_ePersistCategory) {
257 case eFrameworkunifiedUserData: {
258 m_cPersistPath += USERDATADIR;
260 // Check if to persist for user
261 if (m_bIsUserPersistence) {
262 // if its a user file, user name can't be empty
263 if (!f_cusername.empty()) { // LCOV_EXCL_BR_LINE 6: f_cusername can't be empty
264 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Tag %s is registered for user %s", m_cTag.c_str(), f_cusername.c_str());
265 m_cPersistPath += f_cusername;
266 m_cPersistPath += "/";
269 m_cPersistPath += ALLUSERAPPDATADIR;
274 case eFrameworkunifiedFactoryData: {
275 m_cPersistPath += FACTORYDATADIR;
278 case eFrameworkunifiedFactoryCustomerData: {
279 m_cPersistPath += FACTORYCUSTOMERDATADIR;
282 case eFrameworkunifiedDealerData: {
283 m_cPersistPath += DEALERDATADIR;
288 m_cPersistPath += m_cRequestor;
289 m_cPersistPath += "/";
291 // file and folder persistency has different storage paths mapped
292 if (ENOTIFICATIONPERSISTENTSERVICEPERSISTFILE == f_epersisttype) {
293 m_cPersistPath += "NSFile/";
294 } else if (ENOTIFICATIONPERSISTENTSERVICEPERSISTFOLDER == f_epersisttype) { // LCOV_EXCL_BR_LINE 6: f_epersisttype must be ENOTIFICATIONPERSISTENTSERVICEPERSISTFILE or ENOTIFICATIONPERSISTENTSERVICEPERSISTFOLDER. // NOLINT[whitespace/line_length]
295 m_cPersistPath += "NSFolder/";
298 m_cPersistPath += m_cTag;
302 ////////////////////////////////////////////////////////////////////////////////////////////
305 ////////////////////////////////////////////////////////////////////////////////////////////
306 ENotificationpersistentservicePersistType CRegistryEntry::GetPersistType() const {
307 return m_ePersistType;
310 ////////////////////////////////////////////////////////////////////////////////////////////
311 /// SetPersistentCategory
312 /// Sets the persistent type related to tag
313 ////////////////////////////////////////////////////////////////////////////////////////////
314 EFrameworkunifiedStatus CRegistryEntry::SetPersistentCategory(EFrameworkunifiedPersistCategory f_epersistcategory) {
315 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
316 EFrameworkunifiedStatus l_estatus = eFrameworkunifiedStatusOK;
318 m_ePersistCategory = f_epersistcategory;
320 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
324 ////////////////////////////////////////////////////////////////////////////////////////////
325 /// GetPersistentCategory
326 /// Gets the persistent type of a tag
327 ////////////////////////////////////////////////////////////////////////////////////////////
328 EFrameworkunifiedPersistCategory CRegistryEntry::GetPersistentCategory() {
329 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
331 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
332 return m_ePersistCategory;