summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuy Sagnes <guy.sagnes@continental-corporation.com>2017-03-17 08:40:10 +0100
committerGuy Sagnes <guy.sagnes@continental-corporation.com>2017-03-17 08:40:10 +0100
commit635b4843b5189d68c38abfa14c9cd61815b2152b (patch)
treea47b6d74b0f281da2ddd331f3ccecb221ec66d80
parent7fb70fdc6b42047024afbab1598424236e822985 (diff)
parentf11b2f130885826cca26072afd6791f00874ac54 (diff)
downloadpersistence-administrator-635b4843b5189d68c38abfa14c9cd61815b2152b.tar.gz
Merge commit with PAS Vers 1.0.9
-rw-r--r--Administrator/src/ssw_pers_admin_backup.c35
-rw-r--r--Administrator/src/ssw_pers_admin_recovery.c3471
-rw-r--r--Administrator/src/ssw_pers_admin_resource_config_add.c108
-rw-r--r--ChangeLog11
-rw-r--r--configure.ac2
-rw-r--r--test/pers_svc_test/Makefile.am13
-rw-r--r--test/pers_svc_test/dbus_specifications/OIPModuleTestPASCodeGeneration.txt1
-rw-r--r--test/pers_svc_test/dbus_specifications/OIPModuleTestPASCodeGeneration.xml25
-rw-r--r--test/pers_svc_test/dbus_specifications/OIPModuleTestPASDBusCall.txt3
-rw-r--r--test/pers_svc_test/inc/test_PAS.h6
-rwxr-xr-xtest/pers_svc_test/src/test_PAS.c3
-rw-r--r--test/pers_svc_test/src/test_PAS_dbus.c233
12 files changed, 1884 insertions, 2027 deletions
diff --git a/Administrator/src/ssw_pers_admin_backup.c b/Administrator/src/ssw_pers_admin_backup.c
index aa14c51..cd68f06 100644
--- a/Administrator/src/ssw_pers_admin_backup.c
+++ b/Administrator/src/ssw_pers_admin_backup.c
@@ -174,26 +174,35 @@ static long persadmin_priv_data_backup_create_all(pstr_t backup_name)
/* append root path to backup name -> /backup_name/Data; */
(void)snprintf(pchBckupPathDst, (size_t)s32SizeBckup, "%s%s", backup_name, gRootPath);
- /* TODO: check if folder exists; */
- /* copy content of source (/Data) to destination (/backup); */
- sResult = persadmin_copy_folder(gRootPath, pchBckupPathDst, PersadminFilterAll, true);
- if( 0 > sResult )
+ /* check if folder exists; */
+ if( 0 == persadmin_check_if_file_exists(gRootPath, true) )
{
- bCanContinue = false;
- /* some info; */
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR), DLT_STRING("persadmin_priv_data_backup_create_all -"), DLT_STRING("persadmin_copy_folder"),
- DLT_STRING(gRootPath), DLT_STRING("to"), DLT_STRING(pchBckupPathDst), DLT_STRING("ERR"), DLT_INT(sResult));
+ /* copy content of source (/Data) to destination (/backup); */
+ sResult = persadmin_copy_folder(gRootPath, pchBckupPathDst, PersadminFilterAll, true);
+ if( 0 > sResult )
+ {
+ bCanContinue = false;
+ /* some info; */
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR), DLT_STRING("persadmin_priv_data_backup_create_all -"), DLT_STRING("persadmin_copy_folder"),
+ DLT_STRING(gRootPath), DLT_STRING("to"), DLT_STRING(pchBckupPathDst), DLT_STRING("ERR"), DLT_INT(sResult));
+ }
+ else
+ {
+ /* some info; */
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_INFO, DLT_STRING(LT_HDR), DLT_STRING("persadmin_priv_data_backup_create_all -"), DLT_STRING("backed up"),
+ DLT_STRING(gRootPath), DLT_STRING("to"), DLT_STRING(pchBckupPathDst));
+ }
+
+ /* TODO: filter destination folder of files which do not correspond with the definition in BackupFileList.info; */
+ /* persadmin_priv_filter_folder(); */
}
else
{
/* some info; */
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_INFO, DLT_STRING(LT_HDR), DLT_STRING("persadmin_priv_data_backup_create_all -"), DLT_STRING("backed up"),
- DLT_STRING(gRootPath), DLT_STRING("to"), DLT_STRING(pchBckupPathDst));
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_INFO, DLT_STRING(LT_HDR), DLT_STRING("persadmin_priv_data_backup_create_all -"),
+ DLT_STRING(gRootPath), DLT_STRING("does not exist"));
}
- /* TODO: filter destination folder of files which do not correspond with the definition in BackupFileList.info; */
- /* persadmin_priv_filter_folder(); */
-
/* return result; */
return sResult;
diff --git a/Administrator/src/ssw_pers_admin_recovery.c b/Administrator/src/ssw_pers_admin_recovery.c
index 3a74544..e121a11 100644
--- a/Administrator/src/ssw_pers_admin_recovery.c
+++ b/Administrator/src/ssw_pers_admin_recovery.c
@@ -11,16 +11,16 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* Date Author Reason
-* 2013.03.20 uidu0250 CSP_WZ#2250: Provide compress/uncompress functionality
-* 2013.02.15 uidu0250 CSP_WZ#8849: Fix persadmin_restore_all_data issue for restoring inexistent apps
-* 2013.02.07 uidu0250 CSP_WZ#2220: Changed implementation of persadmin_restore_check_RCT_compatibility to remove Helplibs usage
-* 2013.02.04 uidu0250 CSP_WZ#2211: Modified the implementation to be QAC compliant
-* 2013.01.10 uidu0250 CSP_WZ#2060: Adapted last database_helper modifications
-* 2013.01.10 uidu0250 CSP_WZ#2060: Switched to common defines from pers_data_organization_if.h
-* 2013.01.04 uidu0250 CSP_WZ#2060: Switched from using CRC32 to using CRC16 provided by HelpLibs
-* 2012.12.11 uidu0250 CSP_WZ#1925: Added RCT compatibility check
-* 2012.12.11 uidu0250 CSP_WZ#1925: Fixed data_backup_restore issues.
-* 2012.12.05 uidu0250 CSP_WZ#1925: Ignore the new applications from the backup content for PersASSelectionType_All.
+* 2013.03.20 uidu0250 CSP_WZ#2250: Provide compress/uncompress functionality
+* 2013.02.15 uidu0250 CSP_WZ#8849: Fix persadmin_restore_all_data issue for restoring inexistent apps
+* 2013.02.07 uidu0250 CSP_WZ#2220: Changed implementation of persadmin_restore_check_RCT_compatibility to remove Helplibs usage
+* 2013.02.04 uidu0250 CSP_WZ#2211: Modified the implementation to be QAC compliant
+* 2013.01.10 uidu0250 CSP_WZ#2060: Adapted last database_helper modifications
+* 2013.01.10 uidu0250 CSP_WZ#2060: Switched to common defines from pers_data_organization_if.h
+* 2013.01.04 uidu0250 CSP_WZ#2060: Switched from using CRC32 to using CRC16 provided by HelpLibs
+* 2012.12.11 uidu0250 CSP_WZ#1925: Added RCT compatibility check
+* 2012.12.11 uidu0250 CSP_WZ#1925: Fixed data_backup_restore issues.
+* 2012.12.05 uidu0250 CSP_WZ#1925: Ignore the new applications from the backup content for PersASSelectionType_All.
* 2012.11.16 uidu0250 CSP_WZ#1280: Initial version
*
**********************************************************************************************************************/
@@ -40,25 +40,25 @@
/* ---------- local defines, macros, constants and type definitions ------------ */
-#define PAS_ITEM_LIST_DELIMITER '\0'
+#define PAS_ITEM_LIST_DELIMITER '\0'
/* path prefix for destination local cached database/folder: backup_path/Data/mnt-c/<appId>/<database_name or folder_name> */
-#define PAS_SRC_LOCAL_CACHE_PATH_FORMAT "%s"PERS_ORG_LOCAL_CACHE_PATH_FORMAT
+#define PAS_SRC_LOCAL_CACHE_PATH_FORMAT "%s"PERS_ORG_LOCAL_CACHE_PATH_FORMAT
/* path prefix for destination shared group cached database/folder: backup_path/Data/mnt-c/shared/group/<group_no>/<database_name or folder_name> */
-#define PAS_SRC_SHARED_GROUP_CACHE_PATH_STRING_FORMAT "%s"PERS_ORG_SHARED_CACHE_PATH_STRING_FORMAT
+#define PAS_SRC_SHARED_GROUP_CACHE_PATH_STRING_FORMAT "%s"PERS_ORG_SHARED_CACHE_PATH_STRING_FORMAT
-#define PAS_SHARED_PUBLIC_PATH PERS_ORG_SHARED_FOLDER_NAME"/"PERS_ORG_PUBLIC_FOLDER_NAME
+#define PAS_SHARED_PUBLIC_PATH PERS_ORG_SHARED_FOLDER_NAME"/"PERS_ORG_PUBLIC_FOLDER_NAME
-#define PAS_SHARED_GROUP_PATH PERS_ORG_SHARED_FOLDER_NAME"/"PERS_ORG_GROUP_FOLDER_NAME
+#define PAS_SHARED_GROUP_PATH PERS_ORG_SHARED_FOLDER_NAME"/"PERS_ORG_GROUP_FOLDER_NAME
-#define PAS_MAX_LIST_DB_SIZE (32 * 1024)
+#define PAS_MAX_LIST_DB_SIZE (32 * 1024)
-#define SUCCESS_CODE (0)
-#define GENERIC_ERROR_CODE PAS_FAILURE;
+#define SUCCESS_CODE (0)
+#define GENERIC_ERROR_CODE PAS_FAILURE;
-#define LT_HDR "RESTORE >>"
+#define LT_HDR "RESTORE >>"
/* ----------global variables. initialization of global contexts ------------ */
DLT_IMPORT_CONTEXT(persAdminSvcDLTCtx);
@@ -74,7 +74,7 @@ DLT_IMPORT_CONTEXT(persAdminSvcDLTCtx);
* \return positive value: number of bytes restored; negative value: error code
*/
static long persadmin_restore_appl_data( pstr_t backup_data_path,
- pstr_t appId );
+ pstr_t appId );
/**
@@ -85,9 +85,9 @@ static long persadmin_restore_appl_data( pstr_t backup_data_path,
* \param seat_no the seat ID
* \return positive value: number of bytes restored; negative value: error code
*/
-static long persadmin_restore_user_data(pstr_t backup_data_path,
- uint32_t user_no,
- uint32_t seat_no );
+static long persadmin_restore_user_data(pstr_t backup_data_path,
+ uint32_t user_no,
+ uint32_t seat_no );
/**
@@ -109,7 +109,7 @@ static long persadmin_restore_all_data( pstr_t backup_data_path );
* \return positive value: number of bytes restored; negative value: error code
*/
static long persadmin_restore_appl_node(pstr_t backupDataPath,
- pstr_t appId );
+ pstr_t appId );
/**
* \brief Allow recovery of data backup on application level for the user section (all or a specific user)
@@ -121,10 +121,10 @@ static long persadmin_restore_appl_node(pstr_t backupDataPath,
*
* \return positive value: number of bytes restored; negative value: error code
*/
-static long persadmin_restore_appl_user( pstr_t backupDataPath,
- pstr_t appId,
- uint32_t user_no,
- uint32_t seat_no);
+static long persadmin_restore_appl_user( pstr_t backupDataPath,
+ pstr_t appId,
+ uint32_t user_no,
+ uint32_t seat_no);
/**
* \brief Allow recovery of local user data for the selected user_no (all or a specific user)
@@ -135,9 +135,9 @@ static long persadmin_restore_appl_user( pstr_t backupDataPath,
*
* \return positive value: number of bytes restored; negative value: error code
*/
-static long persadmin_restore_user_local_data( pstr_t backupDataPath,
- uint32_t user_no,
- uint32_t seat_no);
+static long persadmin_restore_user_local_data( pstr_t backupDataPath,
+ uint32_t user_no,
+ uint32_t seat_no);
/**
* \brief Allow recovery of shared user data for the selected user_no (all or a specific user)
@@ -149,10 +149,10 @@ static long persadmin_restore_user_local_data( pstr_t backupDataPa
*
* \return positive value: number of bytes restored; negative value: error code
*/
-static long persadmin_restore_user_shared_data( PersASSelectionType_e type,
- pstr_t backupDataPath,
- uint32_t user_no,
- uint32_t seat_no);
+static long persadmin_restore_user_shared_data( PersASSelectionType_e type,
+ pstr_t backupDataPath,
+ uint32_t user_no,
+ uint32_t seat_no);
/**
* \brief Allow recovery of user public files for the selected user_no (all or a specific user)
@@ -163,9 +163,9 @@ static long persadmin_restore_user_shared_data( PersASSelectionType_e type,
*
* \return positive value: number of bytes restored; negative value: error code
*/
-static long persadmin_restore_user_public_files(pstr_t backupDataPath,
- uint32_t user_no,
- uint32_t seat_no);
+static long persadmin_restore_user_public_files(pstr_t backupDataPath,
+ uint32_t user_no,
+ uint32_t seat_no);
/**
* \brief Allow recovery of user group files for the selected user_no (all or a specific user)
*
@@ -175,9 +175,9 @@ static long persadmin_restore_user_public_files(pstr_t backupDataP
*
* \return positive value: number of bytes restored; negative value: error code
*/
-static long persadmin_restore_user_group_files( pstr_t backupDataPath,
- uint32_t user_no,
- uint32_t seat_no);
+static long persadmin_restore_user_group_files( pstr_t backupDataPath,
+ uint32_t user_no,
+ uint32_t seat_no);
/**
* \brief Allow recovery of shared data not related to user
@@ -186,7 +186,7 @@ static long persadmin_restore_user_group_files( pstr_t backupDataP
*
* \return positive value: number of bytes restored; negative value: error code
*/
-static long persadmin_restore_non_user_shared_data( pstr_t backupDataPath);
+static long persadmin_restore_non_user_shared_data( pstr_t backupDataPath);
/**
@@ -200,11 +200,11 @@ static long persadmin_restore_non_user_shared_data( pstr_t backupDa
*
* \return positive value: number of bytes restored; negative value: error code
*/
-static long persadmin_restore_local_keys( PersASSelectionType_e type,
- pstr_t backupDataPath,
- pstr_t appId,
- uint32_t user_no,
- uint32_t seat_no);
+static long persadmin_restore_local_keys( PersASSelectionType_e type,
+ pstr_t backupDataPath,
+ pstr_t appId,
+ uint32_t user_no,
+ uint32_t seat_no);
/**
@@ -218,11 +218,11 @@ static long persadmin_restore_local_keys( PersASSelectionType_e type,
*
* \return positive value: number of bytes restored; negative value: error code
*/
-static long persadmin_restore_shared_keys( PersASSelectionType_e type,
- pstr_t backupDataPath,
- pstr_t appId,
- uint32_t user_no,
- uint32_t seat_no);
+static long persadmin_restore_shared_keys( PersASSelectionType_e type,
+ pstr_t backupDataPath,
+ pstr_t appId,
+ uint32_t user_no,
+ uint32_t seat_no);
/**
@@ -234,7 +234,7 @@ static long persadmin_restore_shared_keys( PersASSelectionType_e type,
* \return true if the two RCT files have the same content, false otherwise
*/
static bool_t persadmin_restore_check_RCT_compatibility(pstr_t sourceRCTPath,
- pstr_t destRCTPath );
+ pstr_t destRCTPath );
/**
@@ -245,8 +245,8 @@ static bool_t persadmin_restore_check_RCT_compatibility(pstr_t sourceRCTP
*
* \return true if the application exists in the specified sourceRootPath, false otherwise
*/
-static bool_t persadmin_restore_check_if_app_exists( pstr_t sourceRootPath,
- pstr_t appId );
+static bool_t persadmin_restore_check_if_app_exists( pstr_t sourceRootPath,
+ pstr_t appId );
/**
* \brief Forms the path (by appending) according to the provided user_no and seat_no
@@ -258,10 +258,10 @@ static bool_t persadmin_restore_check_if_app_exists( pstr_t sourceRootPat
*
* \return void
*/
-static void persadmin_restore_set_user_path(pstr_t parentUserPath,
- uint_t parentUserPathLength,
- uint32_t user_no,
- uint32_t seat_no);
+static void persadmin_restore_set_user_path(pstr_t parentUserPath,
+ uint_t parentUserPathLength,
+ uint32_t user_no,
+ uint32_t seat_no);
/**
* \brief Allow recovery of data from backup on different level (application, user or complete)
@@ -274,1562 +274,1629 @@ static void persadmin_restore_set_user_path(pstr_t parentUserPath,
*
* \return positive value: number of bytes restored; negative value: error code
*/
-long persadmin_data_backup_recovery(PersASSelectionType_e type,
- char* backup_name,
- char* applicationID,
- unsigned int user_no,
- unsigned int seat_no)
+long persadmin_data_backup_recovery(PersASSelectionType_e type,
+ char* backup_name,
+ char* applicationID,
+ unsigned int user_no,
+ unsigned int seat_no)
{
- sint_t retVal = SUCCESS_CODE;
- str_t pUncompressFromPath [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
- str_t pUncompressToPath [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
- str_t pDataRootPath [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
-
- if((NIL == backup_name) || (NIL == applicationID))
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("Invalid parameter in persadmin_data_backup_recovery call."));
- return GENERIC_ERROR_CODE;
- }
- else
- {
- (void)memset(pUncompressFromPath, 0, sizeof(pUncompressFromPath));
- (void)snprintf(pUncompressFromPath, sizeof(pUncompressFromPath), "%s%s", BACKUP_LOCATION, backup_name);
-
- (void)memset(pUncompressToPath, 0, sizeof(pUncompressToPath));
- (void)snprintf(pUncompressToPath, sizeof(pUncompressToPath), "%s", BACKUP_LOCATION);
-
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
- DLT_STRING("Backup file path:"),
- DLT_STRING(pUncompressFromPath));
-
- /* Check if the specified backup file exists */
- if( persadmin_check_if_file_exists(pUncompressFromPath, false) < 0)
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("Backup file does not exist:"),
- DLT_STRING(pUncompressFromPath));
- return GENERIC_ERROR_CODE;
- }
-
- /* Extract backup data in the same location as the backup file */
- retVal = persadmin_uncompress(pUncompressFromPath, pUncompressToPath);
- if(retVal < SUCCESS_CODE)
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("Failed to extract backup content from:"),
- DLT_STRING(pUncompressFromPath),
- DLT_STRING("to"),
- DLT_STRING(pUncompressToPath));
- return retVal;
- }
- else
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
- DLT_STRING("Successfully extracted backup content to:"),
- DLT_STRING(pUncompressToPath));
- }
-
- /* remove trailing '/' */
- (void)memset(pUncompressToPath, 0, sizeof(pUncompressToPath));
- (void)snprintf(pUncompressToPath, strlen(BACKUP_LOCATION) * sizeof(*pUncompressToPath), "%s", BACKUP_LOCATION);
-
- switch(type)
- {
-
- case PersASSelectionType_All:
- {
- retVal = persadmin_restore_all_data( pUncompressToPath );
- }
- break;
-
- case PersASSelectionType_User:
- {
- retVal = persadmin_restore_user_data( pUncompressToPath,
- user_no,
- seat_no);
- }
- break;
-
- case PersASSelectionType_Application:
- {
- retVal = persadmin_restore_appl_data( pUncompressToPath,
- applicationID );
- }
- break;
-
- default:
- retVal = GENERIC_ERROR_CODE;
- break; // redundant
- }
-
- if(SUCCESS_CODE <= retVal)
- {
- /* <backupDataPath>/Data */
- (void)snprintf(pDataRootPath, sizeof(pDataRootPath), "%s", BACKUP_LOCATION);
- (void)snprintf(pDataRootPath + strlen(BACKUP_LOCATION) - 1, (sizeof(pDataRootPath) - strlen(BACKUP_LOCATION) + 1) * sizeof(*pDataRootPath), "%s", PERS_ORG_ROOT_PATH);
- if( 0 > persadmin_delete_folder(pDataRootPath))
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_WARN, DLT_STRING(LT_HDR),
- DLT_STRING("Failed to delete folder :"),
- DLT_STRING(pDataRootPath));
- }
- else
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
- DLT_STRING("Successfully deleted folder:"),
- DLT_STRING(pDataRootPath));
- }
- }
- }
+ sint_t retVal = SUCCESS_CODE;
+ str_t pUncompressFromPath [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
+ str_t pUncompressToPath [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
+ str_t pDataRootPath [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
+
+ if((NIL == backup_name) || (NIL == applicationID))
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("Invalid parameter in persadmin_data_backup_recovery call."));
+ return GENERIC_ERROR_CODE;
+ }
+ else
+ {
+ (void)memset(pUncompressFromPath, 0, sizeof(pUncompressFromPath));
+ (void)snprintf(pUncompressFromPath, sizeof(pUncompressFromPath), "%s%s", BACKUP_LOCATION, backup_name);
+
+ (void)memset(pUncompressToPath, 0, sizeof(pUncompressToPath));
+ (void)snprintf(pUncompressToPath, sizeof(pUncompressToPath), "%s", BACKUP_LOCATION);
+
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
+ DLT_STRING("Backup file path:"),
+ DLT_STRING(pUncompressFromPath));
+
+ /* Check if the specified backup file exists */
+ if( persadmin_check_if_file_exists(pUncompressFromPath, false) < 0)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("Backup file does not exist:"),
+ DLT_STRING(pUncompressFromPath));
+ return GENERIC_ERROR_CODE;
+ }
+
+ /* Extract backup data in the same location as the backup file */
+ retVal = persadmin_uncompress(pUncompressFromPath, pUncompressToPath);
+ if(retVal < SUCCESS_CODE)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("Failed to extract backup content from:"),
+ DLT_STRING(pUncompressFromPath),
+ DLT_STRING("to"),
+ DLT_STRING(pUncompressToPath));
+ return retVal;
+ }
+ else
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
+ DLT_STRING("Successfully extracted backup content to:"),
+ DLT_STRING(pUncompressToPath));
+ }
+
+ /* remove trailing '/' */
+ (void)memset(pUncompressToPath, 0, sizeof(pUncompressToPath));
+ (void)snprintf(pUncompressToPath, strlen(BACKUP_LOCATION) * sizeof(*pUncompressToPath), "%s", BACKUP_LOCATION);
+
+ switch(type)
+ {
+
+ case PersASSelectionType_All:
+ {
+ retVal = persadmin_restore_all_data( pUncompressToPath );
+ }
+ break;
+
+ case PersASSelectionType_User:
+ {
+ retVal = persadmin_restore_user_data( pUncompressToPath,
+ user_no,
+ seat_no);
+ }
+ break;
+
+ case PersASSelectionType_Application:
+ {
+ retVal = persadmin_restore_appl_data( pUncompressToPath,
+ applicationID );
+ }
+ break;
+
+ default:
+ retVal = GENERIC_ERROR_CODE;
+ break; // redundant
+ }
+
+ if(SUCCESS_CODE <= retVal)
+ {
+ /* <backupDataPath>/Data */
+ (void)snprintf(pDataRootPath, sizeof(pDataRootPath), "%s", BACKUP_LOCATION);
+ (void)snprintf(pDataRootPath + strlen(BACKUP_LOCATION) - 1, (sizeof(pDataRootPath) - strlen(BACKUP_LOCATION) + 1) * sizeof(*pDataRootPath), "%s", PERS_ORG_ROOT_PATH);
+ if( 0 > persadmin_delete_folder(pDataRootPath))
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_WARN, DLT_STRING(LT_HDR),
+ DLT_STRING("Failed to delete folder :"),
+ DLT_STRING(pDataRootPath));
+ }
+ else
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
+ DLT_STRING("Successfully deleted folder:"),
+ DLT_STRING(pDataRootPath));
+ }
+ }
+ }
return retVal;
}/*DG C8ISQP-ISQP Metric 10-SSW_Administrator_0001*/
//---------------------------------------------------------------
-static void persadmin_restore_set_user_path(pstr_t parentUserPath,
- uint_t parentUserPathLength,
- uint32_t user_no,
- uint32_t seat_no)
+static void persadmin_restore_set_user_path(pstr_t parentUserPath,
+ uint_t parentUserPathLength,
+ uint32_t user_no,
+ uint32_t seat_no)
{
- pstr_t pTempSrcUserPath = NIL;
-
- pTempSrcUserPath = (pstr_t)malloc(parentUserPathLength * sizeof(*parentUserPath));/*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
- if(NIL == pTempSrcUserPath)
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("Failed to allocate memory for user path."));
- }
- else
- {
- if(NIL != parentUserPath)
- {
- // all users & all seats;
- if( (PERSIST_SELECT_ALL_USERS == user_no) && (PERSIST_SELECT_ALL_SEATS == seat_no) )
- {
- /* <parentUserPath>/user */
- (void)snprintf(pTempSrcUserPath, parentUserPathLength, "%s%s", parentUserPath, gUser);
- }
- // only one user & all seats;
- if( (PERSIST_SELECT_ALL_USERS != user_no) && (PERSIST_SELECT_ALL_SEATS == seat_no) )
- {
- /* <parentUserPath>/user/<user> */
- (void)snprintf(pTempSrcUserPath, parentUserPathLength, "%s%s%d", parentUserPath, gUser, user_no);
- }
- // only one user & one seat;
- if( (PERSIST_SELECT_ALL_USERS != user_no) && (PERSIST_SELECT_ALL_SEATS != seat_no) )
- {
- /* <parentUserPath>/user/<user_no>/seat/<seat_no> */
- (void)snprintf(pTempSrcUserPath, parentUserPathLength, "%s%s%d%s%d", parentUserPath, gUser, user_no, gSeat, seat_no);
- }
-
- (void)snprintf(parentUserPath, parentUserPathLength, "%s", pTempSrcUserPath);
- }
- else
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("Invalid parameter in persadmin_restore_set_user_path call."));
- }
-
- free(pTempSrcUserPath);/*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
- }
+ pstr_t pTempSrcUserPath = NIL;
+
+ pTempSrcUserPath = (pstr_t)malloc(parentUserPathLength * sizeof(*parentUserPath));/*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
+ if(NIL == pTempSrcUserPath)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("Failed to allocate memory for user path."));
+ }
+ else
+ {
+ if(NIL != parentUserPath)
+ {
+ // all users & all seats;
+ if( (PERSIST_SELECT_ALL_USERS == user_no) && (PERSIST_SELECT_ALL_SEATS == seat_no) )
+ {
+ /* <parentUserPath>/user */
+ (void)snprintf(pTempSrcUserPath, parentUserPathLength, "%s%s", parentUserPath, gUser);
+ }
+ // only one user & all seats;
+ if( (PERSIST_SELECT_ALL_USERS != user_no) && (PERSIST_SELECT_ALL_SEATS == seat_no) )
+ {
+ /* <parentUserPath>/user/<user> */
+ (void)snprintf(pTempSrcUserPath, parentUserPathLength, "%s%s%d", parentUserPath, gUser, user_no);
+ }
+ // only one user & one seat;
+ if( (PERSIST_SELECT_ALL_USERS != user_no) && (PERSIST_SELECT_ALL_SEATS != seat_no) )
+ {
+ /* <parentUserPath>/user/<user_no>/seat/<seat_no> */
+ (void)snprintf(pTempSrcUserPath, parentUserPathLength, "%s%s%d%s%d", parentUserPath, gUser, user_no, gSeat, seat_no);
+ }
+
+ (void)snprintf(parentUserPath, parentUserPathLength, "%s", pTempSrcUserPath);
+ }
+ else
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("Invalid parameter in persadmin_restore_set_user_path call."));
+ }
+
+ free(pTempSrcUserPath);/*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
+ }
}
//---------------------------------------------------------------
static long persadmin_restore_appl_node(pstr_t backupDataPath,
- pstr_t appId ) // could use an 'extended' app path
+ pstr_t appId ) // could use an 'extended' app path
{
- sint_t retVal;
- long bytesRestored = 0;
- str_t pNodeSourcePath [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
- str_t pNodeDestPath [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
-
- if((NIL == backupDataPath) || (NIL == appId))
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("Invalid parameter in persadmin_restore_appl_node call."));
- return GENERIC_ERROR_CODE;
- }
-
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
- DLT_STRING("Restore node content for:"),
- DLT_STRING(appId),
- DLT_STRING("from"),
- DLT_STRING(backupDataPath));
-
- /* app node source path */
-
- /* <backupDataPath>/Data/mnt-c/<appId>/node */
- (void)snprintf(pNodeSourcePath, sizeof(pNodeSourcePath), PAS_SRC_LOCAL_CACHE_PATH_FORMAT, backupDataPath, appId, gNode);
-
-
- /* app node dest path */
-
- /* /Data/mnt-c/<appId>/node */
- (void)snprintf(pNodeDestPath, sizeof(pNodeDestPath), gLocalCachePath, appId, gNode);
-
- /* erase node content */
- retVal = persadmin_delete_folder(pNodeDestPath);
- if(retVal < SUCCESS_CODE)
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("persadmin_delete_folder call failed with error code:"),
- DLT_INT(retVal),
- DLT_STRING("for"),
- DLT_STRING(pNodeDestPath));
- }
-
- /* copy node content */
- retVal = persadmin_copy_folder( pNodeSourcePath,
- pNodeDestPath,
- PersadminFilterAll,
- true);
-
- if(retVal < SUCCESS_CODE)
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("persadmin_copy_folder call failed with error code:"),
- DLT_INT(retVal),
- DLT_STRING("for source:"),
- DLT_STRING(pNodeSourcePath),
- DLT_STRING("and destination:"),
- DLT_STRING(pNodeDestPath));
- return GENERIC_ERROR_CODE;
- }
-
- bytesRestored += retVal;
-
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
- DLT_STRING("Restored successfully node content for:"),
- DLT_STRING(appId),
- DLT_STRING("from"),
- DLT_STRING(backupDataPath),
- DLT_STRING("."),
- DLT_INT64(bytesRestored),
- DLT_STRING("bytes restored."));
-
- return bytesRestored;
+ sint_t retVal;
+ long bytesRestored = 0;
+ str_t pNodeSourcePath [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
+ str_t pNodeDestPath [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
+
+ if((NIL == backupDataPath) || (NIL == appId))
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("Invalid parameter in persadmin_restore_appl_node call."));
+ return GENERIC_ERROR_CODE;
+ }
+
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
+ DLT_STRING("Restore node content for:"),
+ DLT_STRING(appId),
+ DLT_STRING("from"),
+ DLT_STRING(backupDataPath));
+
+ /* app node source path */
+
+ /* <backupDataPath>/Data/mnt-c/<appId>/node */
+ (void)snprintf(pNodeSourcePath, sizeof(pNodeSourcePath), PAS_SRC_LOCAL_CACHE_PATH_FORMAT, backupDataPath, appId, gNode);
+
+
+ /* app node dest path */
+
+ /* /Data/mnt-c/<appId>/node */
+ (void)snprintf(pNodeDestPath, sizeof(pNodeDestPath), gLocalCachePath, appId, gNode);
+
+ if( 0 == persadmin_check_if_file_exists(pNodeSourcePath, true) )
+ {
+ /* erase node content */
+ retVal = persadmin_delete_folder(pNodeDestPath);
+ if(retVal < SUCCESS_CODE)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("persadmin_delete_folder call failed with error code:"),
+ DLT_INT(retVal),
+ DLT_STRING("for"),
+ DLT_STRING(pNodeDestPath));
+ }
+
+ /* copy node content */
+ retVal = persadmin_copy_folder( pNodeSourcePath,
+ pNodeDestPath,
+ PersadminFilterAll,
+ true);
+
+ if(retVal < SUCCESS_CODE)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("persadmin_copy_folder call failed with error code:"),
+ DLT_INT(retVal),
+ DLT_STRING("for source:"),
+ DLT_STRING(pNodeSourcePath),
+ DLT_STRING("and destination:"),
+ DLT_STRING(pNodeDestPath));
+ return GENERIC_ERROR_CODE;
+ }
+
+ bytesRestored += retVal;
+
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
+ DLT_STRING("Restored successfully node content for:"),
+ DLT_STRING(appId),
+ DLT_STRING("from"),
+ DLT_STRING(backupDataPath),
+ DLT_STRING("."),
+ DLT_INT64(bytesRestored),
+ DLT_STRING("bytes restored."));
+ }
+ else
+ {
+ /* some info; */
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_INFO, DLT_STRING(LT_HDR), DLT_STRING("persadmin_restore_appl_node -"),
+ DLT_STRING(pNodeSourcePath), DLT_STRING("does not exist"));
+ }
+
+ return bytesRestored;
}/*DG C8ISQP-ISQP Metric 10-SSW_Administrator_0001*/
//-----------------------------------------------------------------------
-static long persadmin_restore_appl_user( pstr_t backupDataPath,
- pstr_t appId,
- uint32_t user_no,
- uint32_t seat_no)
+static long persadmin_restore_appl_user( pstr_t backupDataPath,
+ pstr_t appId,
+ uint32_t user_no,
+ uint32_t seat_no)
{
- sint_t retVal;
- long bytesRestored = 0;
- str_t pUserSourcePath [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
- str_t pUserDestPath [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
-
-
- if((NIL == backupDataPath) || (NIL == appId))
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("Invalid parameter in persadmin_restore_appl_user call."));
- return GENERIC_ERROR_CODE;
- }
-
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
- DLT_STRING("Restore user content for App:"),
- DLT_STRING(appId),
- DLT_STRING("User:"),
- DLT_UINT8(user_no),
- DLT_STRING("Seat:"),
- DLT_UINT8(seat_no),
- DLT_STRING("from"),
- DLT_STRING(backupDataPath));
-
- /* user source path */
-
- /* <backupDataPath>/Data/mnt-c/<appId>/user/<user_no>/seat/<seat_no> */
- (void)snprintf(pUserSourcePath, sizeof(pUserSourcePath), PAS_SRC_LOCAL_CACHE_PATH_FORMAT, backupDataPath, appId, "");
- persadmin_restore_set_user_path( pUserSourcePath,
- sizeof(pUserSourcePath)/sizeof(str_t),
- user_no,
- seat_no);
-
- /* user dest path */
-
- /* /Data/mnt-c/<appId>/user/<user_no>/seat/<seat_no> */
- (void)snprintf(pUserDestPath, sizeof(pUserDestPath), gLocalCachePath, appId, "");
- persadmin_restore_set_user_path(pUserDestPath,
- sizeof(pUserDestPath)/sizeof(str_t),
- user_no,
- seat_no);
-
- /* erase user content */
- retVal = persadmin_delete_folder(pUserDestPath);
- if(retVal < SUCCESS_CODE)
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("persadmin_delete_folder call failed with error code:"),
- DLT_INT(retVal),
- DLT_STRING("for"),
- DLT_STRING(pUserDestPath));
- }
-
- /* copy user content */
- retVal = persadmin_copy_folder( pUserSourcePath,
- pUserDestPath,
- PersadminFilterAll,
- true);
- if(retVal < SUCCESS_CODE)
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("persadmin_copy_folder call failed with error code:"),
- DLT_INT(retVal),
- DLT_STRING("from"),
- DLT_STRING(pUserSourcePath),
- DLT_STRING("to"),
- DLT_STRING(pUserDestPath));
- return GENERIC_ERROR_CODE;
- }
-
- bytesRestored += retVal;
-
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
- DLT_STRING("Restored successfully user content for App:"),
- DLT_STRING(appId),
- DLT_STRING("User:"),
- DLT_UINT8(user_no),
- DLT_STRING("Seat:"),
- DLT_UINT8(seat_no),
- DLT_STRING("from"),
- DLT_STRING(backupDataPath),
- DLT_STRING("."),
- DLT_INT64(bytesRestored),
- DLT_STRING("bytes restored."));
-
- return bytesRestored;
+ sint_t retVal;
+ long bytesRestored = 0;
+ str_t pUserSourcePath [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
+ str_t pUserDestPath [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
+
+
+ if((NIL == backupDataPath) || (NIL == appId))
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("Invalid parameter in persadmin_restore_appl_user call."));
+ return GENERIC_ERROR_CODE;
+ }
+
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
+ DLT_STRING("Restore user content for App:"),
+ DLT_STRING(appId),
+ DLT_STRING("User:"),
+ DLT_UINT8(user_no),
+ DLT_STRING("Seat:"),
+ DLT_UINT8(seat_no),
+ DLT_STRING("from"),
+ DLT_STRING(backupDataPath));
+
+ /* user source path */
+
+ /* <backupDataPath>/Data/mnt-c/<appId>/user/<user_no>/seat/<seat_no> */
+ (void)snprintf(pUserSourcePath, sizeof(pUserSourcePath), PAS_SRC_LOCAL_CACHE_PATH_FORMAT, backupDataPath, appId, "");
+ persadmin_restore_set_user_path( pUserSourcePath,
+ sizeof(pUserSourcePath)/sizeof(str_t),
+ user_no,
+ seat_no);
+
+ /* user dest path */
+
+ /* /Data/mnt-c/<appId>/user/<user_no>/seat/<seat_no> */
+ (void)snprintf(pUserDestPath, sizeof(pUserDestPath), gLocalCachePath, appId, "");
+ persadmin_restore_set_user_path(pUserDestPath,
+ sizeof(pUserDestPath)/sizeof(str_t),
+ user_no,
+ seat_no);
+
+ if( 0 == persadmin_check_if_file_exists(pUserSourcePath, true) )
+ {
+ /* erase user content */
+ retVal = persadmin_delete_folder(pUserDestPath);
+ if(retVal < SUCCESS_CODE)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("persadmin_delete_folder call failed with error code:"),
+ DLT_INT(retVal),
+ DLT_STRING("for"),
+ DLT_STRING(pUserDestPath));
+ }
+
+ /* copy user content */
+ retVal = persadmin_copy_folder( pUserSourcePath,
+ pUserDestPath,
+ PersadminFilterAll,
+ true);
+ if(retVal < SUCCESS_CODE)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("persadmin_copy_folder call failed with error code:"),
+ DLT_INT(retVal),
+ DLT_STRING("from"),
+ DLT_STRING(pUserSourcePath),
+ DLT_STRING("to"),
+ DLT_STRING(pUserDestPath));
+ return GENERIC_ERROR_CODE;
+ }
+
+ bytesRestored += retVal;
+
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
+ DLT_STRING("Restored successfully user content for App:"),
+ DLT_STRING(appId),
+ DLT_STRING("User:"),
+ DLT_UINT8(user_no),
+ DLT_STRING("Seat:"),
+ DLT_UINT8(seat_no),
+ DLT_STRING("from"),
+ DLT_STRING(backupDataPath),
+ DLT_STRING("."),
+ DLT_INT64(bytesRestored),
+ DLT_STRING("bytes restored."));
+ }
+ else
+ {
+ /* some info; */
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_INFO, DLT_STRING(LT_HDR), DLT_STRING("persadmin_restore_appl_user -"),
+ DLT_STRING(pUserSourcePath), DLT_STRING("does not exist"));
+ }
+
+ return bytesRestored;
}/*DG C8ISQP-ISQP Metric 10-SSW_Administrator_0001*/
//-------------------------------------------------------------------------------------
-static long persadmin_restore_non_user_shared_data( pstr_t backupDataPath)
+static long persadmin_restore_non_user_shared_data( pstr_t backupDataPath)
{
- sint_t retVal;
- long bytesRestored = 0;
- str_t pGroupRootSourcePath [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
- str_t pExtendedAppId [PERS_ORG_MAX_LENGTH_PATH_FILENAME]; // group path
- sint_t listBuffSize = 0;
- pstr_t pStrList = NIL;
- pstr_t pItemName = NIL;
- sint_t outBuffSize = 0;
-
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
- DLT_STRING("Restore non-user shared data from"),
- DLT_STRING(backupDataPath));
-
-
- /* --- public file/folder restore --- */
- retVal = persadmin_restore_appl_node( backupDataPath,
- PAS_SHARED_PUBLIC_PATH );
- if(retVal < 0)
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("persadmin_restore_appl_node call failed with error code:"),
- DLT_INT(retVal));
- return GENERIC_ERROR_CODE;
- }
- bytesRestored += retVal;
-
-
- /* --- group file/folder restore --- */
-
- /* <backupDataPath>/Data/mnt-c/shared/group */
- (void)snprintf(pGroupRootSourcePath, sizeof(pGroupRootSourcePath), "%s%s", backupDataPath, PERS_ORG_SHARED_GROUP_CACHE_PATH);
-
-
- /* Check all groups */
- listBuffSize = persadmin_list_folder_get_size( pGroupRootSourcePath,
- PersadminFilterFolders,
- false );
- if(listBuffSize < SUCCESS_CODE)
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("persadmin_list_folder_get_size call failed with error code:"),
- DLT_INT(listBuffSize));
- return GENERIC_ERROR_CODE;
- }
- if(listBuffSize > 0)
- {
- pStrList = NIL;
- pStrList = (pstr_t)malloc((uint_t)listBuffSize); /*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
- if(NIL == pStrList)
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("Error allocating memory for list of folders."));
- return GENERIC_ERROR_CODE;
- }
- (void)memset(pStrList, 0, (uint_t)listBuffSize);
-
- outBuffSize = persadmin_list_folder( pGroupRootSourcePath,
- pStrList,
- listBuffSize,
- PersadminFilterFolders,
- false);
- if(outBuffSize < SUCCESS_CODE)
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("Error obtaining the list of folders."));
- free(pStrList); /*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
- pStrList = NIL;
- return GENERIC_ERROR_CODE;
- }
-
- pItemName = pStrList;
- while(listBuffSize > 0)
- {
- if(0 == strlen(pItemName))
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("Invalid folder item found."));
- break;
- }
-
- /* Restore the node content for every group */
-
- /* shared/group/<group_id> */
- (void)snprintf(pExtendedAppId, sizeof(pExtendedAppId), "%s/%s/%s", PERS_ORG_SHARED_FOLDER_NAME, PERS_ORG_GROUP_FOLDER_NAME, pItemName);
-
- retVal = persadmin_restore_appl_node( backupDataPath,
- pExtendedAppId);
- if(retVal < 0)
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("persadmin_restore_appl_node call failed with error code:"),
- DLT_INT(retVal));
- free(pStrList);/*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
- pStrList = NIL;
- return GENERIC_ERROR_CODE;
- }
-
- bytesRestored += retVal;
-
- listBuffSize -= ((sint_t)strlen(pItemName) + 1) * (sint_t)sizeof(*pItemName);
- pItemName += (strlen(pItemName) + 1); // MISRA-C:2004 Rule 17.4 Performing pointer arithmetic. - Rule currently not accepted
- }
-
- free(pStrList);/*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
- pStrList = NIL;
- }
-
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
- DLT_STRING("Restore non-user shared data from"),
- DLT_STRING(backupDataPath),
- DLT_STRING("."),
- DLT_INT64(bytesRestored),
- DLT_STRING("bytes restored"));
-
- return bytesRestored;
+ sint_t retVal;
+ long bytesRestored = 0;
+ str_t pGroupRootSourcePath [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
+ str_t pExtendedAppId [PERS_ORG_MAX_LENGTH_PATH_FILENAME]; // group path
+ sint_t listBuffSize = 0;
+ pstr_t pStrList = NIL;
+ pstr_t pItemName = NIL;
+ sint_t outBuffSize = 0;
+
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
+ DLT_STRING("Restore non-user shared data from"),
+ DLT_STRING(backupDataPath));
+
+
+ /* --- public file/folder restore --- */
+ retVal = persadmin_restore_appl_node( backupDataPath,
+ PAS_SHARED_PUBLIC_PATH );
+ if(retVal < 0)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("persadmin_restore_appl_node call failed with error code:"),
+ DLT_INT(retVal));
+ return GENERIC_ERROR_CODE;
+ }
+ bytesRestored += retVal;
+
+
+ /* --- group file/folder restore --- */
+
+ /* <backupDataPath>/Data/mnt-c/shared/group */
+ (void)snprintf(pGroupRootSourcePath, sizeof(pGroupRootSourcePath), "%s%s", backupDataPath, PERS_ORG_SHARED_GROUP_CACHE_PATH);
+
+ /* check if folder exists; */
+ if( 0 == persadmin_check_if_file_exists(pGroupRootSourcePath, true) )
+ {
+ /* Check all groups */
+ listBuffSize = persadmin_list_folder_get_size( pGroupRootSourcePath,
+ PersadminFilterFolders,
+ false );
+ if(listBuffSize < SUCCESS_CODE)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("persadmin_list_folder_get_size call failed with error code:"),
+ DLT_INT(listBuffSize));
+ return GENERIC_ERROR_CODE;
+ }
+ if(listBuffSize > 0)
+ {
+ pStrList = NIL;
+ pStrList = (pstr_t)malloc((uint_t)listBuffSize); /*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
+ if(NIL == pStrList)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("Error allocating memory for list of folders."));
+ return GENERIC_ERROR_CODE;
+ }
+ (void)memset(pStrList, 0, (uint_t)listBuffSize);
+
+ outBuffSize = persadmin_list_folder( pGroupRootSourcePath,
+ pStrList,
+ listBuffSize,
+ PersadminFilterFolders,
+ false);
+ if(outBuffSize < SUCCESS_CODE)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("Error obtaining the list of folders."));
+ free(pStrList); /*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
+ pStrList = NIL;
+ return GENERIC_ERROR_CODE;
+ }
+
+ pItemName = pStrList;
+ while(listBuffSize > 0)
+ {
+ if(0 == strlen(pItemName))
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("Invalid folder item found."));
+ break;
+ }
+
+ /* Restore the node content for every group */
+
+ /* shared/group/<group_id> */
+ (void)snprintf(pExtendedAppId, sizeof(pExtendedAppId), "%s/%s/%s", PERS_ORG_SHARED_FOLDER_NAME, PERS_ORG_GROUP_FOLDER_NAME, pItemName);
+
+ retVal = persadmin_restore_appl_node( backupDataPath,
+ pExtendedAppId);
+ if(retVal < 0)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("persadmin_restore_appl_node call failed with error code:"),
+ DLT_INT(retVal));
+ free(pStrList);/*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
+ pStrList = NIL;
+ return GENERIC_ERROR_CODE;
+ }
+
+ bytesRestored += retVal;
+
+ listBuffSize -= ((sint_t)strlen(pItemName) + 1) * (sint_t)sizeof(*pItemName);
+ pItemName += (strlen(pItemName) + 1); // MISRA-C:2004 Rule 17.4 Performing pointer arithmetic. - Rule currently not accepted
+ }
+
+ free(pStrList);/*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
+ pStrList = NIL;
+ }
+ }
+ else
+ {
+ /* some info; */
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_INFO, DLT_STRING(LT_HDR), DLT_STRING("persadmin_restore_non_user_shared_data -"),
+ DLT_STRING(pGroupRootSourcePath), DLT_STRING("does not exist"));
+ }
+
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
+ DLT_STRING("Restore non-user shared data from"),
+ DLT_STRING(backupDataPath),
+ DLT_STRING("."),
+ DLT_INT64(bytesRestored),
+ DLT_STRING("bytes restored"));
+
+ return bytesRestored;
}/*DG C8ISQP-ISQP Metric 10-SSW_Administrator_0001*/
//--------------------------------------------------------------------------
-static long persadmin_restore_user_public_files(pstr_t backupDataPath,
- uint32_t user_no,
- uint32_t seat_no)
+static long persadmin_restore_user_public_files(pstr_t backupDataPath,
+ uint32_t user_no,
+ uint32_t seat_no)
{
- sint_t retVal;
- long bytesRestored = 0;
- str_t pPublicSourcePath [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
- str_t pPublicDestPath [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
- str_t pUserSourcePath [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
- str_t pUserDestPath [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
-
-
- if(NIL == backupDataPath)
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("Invalid parameter in persadmin_restore_user_public_files call."));
- return GENERIC_ERROR_CODE;
- }
-
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
- DLT_STRING("Restore user public files from"),
- DLT_STRING(backupDataPath),
- DLT_STRING("for User:"),
- DLT_UINT8(user_no),
- DLT_STRING("for Seat:"),
- DLT_UINT8(seat_no));
-
-
- /* --- public RCT compatibility check --- */
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
- DLT_STRING("public RCT compatibility check..."));
-
- /* <backupDataPath>/Data/mnt-c/shared/public */
- (void)snprintf(pPublicSourcePath, sizeof(pPublicSourcePath), "%s%s", backupDataPath, PERS_ORG_SHARED_PUBLIC_CACHE_PATH);
-
- /* /Data/mnt-c/shared/public */
- (void)snprintf(pPublicDestPath, sizeof(pPublicDestPath), "%s", PERS_ORG_SHARED_PUBLIC_CACHE_PATH);
-
-
- if(false == persadmin_restore_check_RCT_compatibility(pPublicSourcePath, pPublicDestPath))
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("Incompatible public RCT files:"),
- DLT_STRING(pPublicSourcePath),
- DLT_STRING("<->"),
- DLT_STRING(pPublicDestPath));
- return GENERIC_ERROR_CODE;
- }
-
- /* --- public file/folder restore --- */
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
- DLT_STRING("public file/folder restore..."));
-
- /* <backupDataPath>/Data/mnt-c/shared/public/user/<user_no>/seat/<seat_no> */
- (void)snprintf(pUserSourcePath, sizeof(pUserSourcePath), "%s%s", backupDataPath, PERS_ORG_SHARED_PUBLIC_CACHE_PATH);
- persadmin_restore_set_user_path(pUserSourcePath,
- sizeof(pUserSourcePath)/sizeof(str_t),
- user_no,
- seat_no);
-
- /* /Data/mnt-c/shared/public/user/<user_no>/seat/<seat_no> */
- (void)snprintf(pUserDestPath, sizeof(pUserDestPath), "%s", PERS_ORG_SHARED_PUBLIC_CACHE_PATH);
- persadmin_restore_set_user_path(pUserDestPath,
- sizeof(pUserDestPath)/sizeof(str_t),
- user_no,
- seat_no);
-
- /* erase user content */
- retVal = persadmin_delete_folder(pUserDestPath);
- if(retVal < SUCCESS_CODE)
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("persadmin_delete_folder call failed with error code:"),
- DLT_INT(retVal));
- }
-
- /* copy user content */
- retVal = persadmin_copy_folder( pUserSourcePath,
- pUserDestPath,
- PersadminFilterAll,
- true);
- if(retVal < 0)
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("persadmin_copy_folder call failed with error code:"),
- DLT_INT(retVal));
- return GENERIC_ERROR_CODE;
- }
-
- bytesRestored += retVal;
-
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
- DLT_STRING("Restored successfully user public files from"),
- DLT_STRING(backupDataPath),
- DLT_STRING("for User:"),
- DLT_UINT8(user_no),
- DLT_STRING("for Seat:"),
- DLT_UINT8(seat_no),
- DLT_STRING("."),
- DLT_INT64(bytesRestored),
- DLT_STRING("bytes restored"));
-
- return bytesRestored;
+ sint_t retVal;
+ long bytesRestored = 0;
+ str_t pPublicSourcePath [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
+ str_t pPublicDestPath [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
+ str_t pUserSourcePath [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
+ str_t pUserDestPath [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
+
+
+ if(NIL == backupDataPath)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("Invalid parameter in persadmin_restore_user_public_files call."));
+ return GENERIC_ERROR_CODE;
+ }
+
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
+ DLT_STRING("Restore user public files from"),
+ DLT_STRING(backupDataPath),
+ DLT_STRING("for User:"),
+ DLT_UINT8(user_no),
+ DLT_STRING("for Seat:"),
+ DLT_UINT8(seat_no));
+
+
+ /* --- public RCT compatibility check --- */
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
+ DLT_STRING("public RCT compatibility check..."));
+
+ /* <backupDataPath>/Data/mnt-c/shared/public */
+ (void)snprintf(pPublicSourcePath, sizeof(pPublicSourcePath), "%s%s", backupDataPath, PERS_ORG_SHARED_PUBLIC_CACHE_PATH);
+
+ /* /Data/mnt-c/shared/public */
+ (void)snprintf(pPublicDestPath, sizeof(pPublicDestPath), "%s", PERS_ORG_SHARED_PUBLIC_CACHE_PATH);
+
+ /* check if folder exists; */
+ if( 0 == persadmin_check_if_file_exists(pPublicSourcePath, true) )
+ {
+ if(false == persadmin_restore_check_RCT_compatibility(pPublicSourcePath, pPublicDestPath))
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("Incompatible public RCT files:"),
+ DLT_STRING(pPublicSourcePath),
+ DLT_STRING("<->"),
+ DLT_STRING(pPublicDestPath));
+ return GENERIC_ERROR_CODE;
+ }
+
+ /* --- public file/folder restore --- */
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
+ DLT_STRING("public file/folder restore..."));
+
+ /* <backupDataPath>/Data/mnt-c/shared/public/user/<user_no>/seat/<seat_no> */
+ (void)snprintf(pUserSourcePath, sizeof(pUserSourcePath), "%s%s", backupDataPath, PERS_ORG_SHARED_PUBLIC_CACHE_PATH);
+ persadmin_restore_set_user_path(pUserSourcePath,
+ sizeof(pUserSourcePath)/sizeof(str_t),
+ user_no,
+ seat_no);
+
+ /* /Data/mnt-c/shared/public/user/<user_no>/seat/<seat_no> */
+ (void)snprintf(pUserDestPath, sizeof(pUserDestPath), "%s", PERS_ORG_SHARED_PUBLIC_CACHE_PATH);
+ persadmin_restore_set_user_path(pUserDestPath,
+ sizeof(pUserDestPath)/sizeof(str_t),
+ user_no,
+ seat_no);
+
+ if( 0 == persadmin_check_if_file_exists(pUserSourcePath, true) )
+ {
+ /* erase user content */
+ retVal = persadmin_delete_folder(pUserDestPath);
+ if(retVal < SUCCESS_CODE)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("persadmin_delete_folder call failed with error code:"),
+ DLT_INT(retVal));
+ }
+
+ /* copy user content */
+ retVal = persadmin_copy_folder( pUserSourcePath,
+ pUserDestPath,
+ PersadminFilterAll,
+ true);
+ if(retVal < 0)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("persadmin_copy_folder call failed with error code:"),
+ DLT_INT(retVal));
+ return GENERIC_ERROR_CODE;
+ }
+
+ bytesRestored += retVal;
+
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
+ DLT_STRING("Restored successfully user public files from"),
+ DLT_STRING(backupDataPath),
+ DLT_STRING("for User:"),
+ DLT_UINT8(user_no),
+ DLT_STRING("for Seat:"),
+ DLT_UINT8(seat_no),
+ DLT_STRING("."),
+ DLT_INT64(bytesRestored),
+ DLT_STRING("bytes restored"));
+ }
+ else
+ {
+ /* some info; */
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_INFO, DLT_STRING(LT_HDR), DLT_STRING("persadmin_restore_user_public_files -"),
+ DLT_STRING(pUserSourcePath), DLT_STRING("does not exist"));
+ }
+ }
+ else
+ {
+ /* some info; */
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_INFO, DLT_STRING(LT_HDR), DLT_STRING("persadmin_restore_user_public_files -"),
+ DLT_STRING(pPublicSourcePath), DLT_STRING("does not exist"));
+ }
+
+ return bytesRestored;
}/*DG C8ISQP-ISQP Metric 10-SSW_Administrator_0001*/
//--------------------------------------------------------------------------
-static long persadmin_restore_user_group_files( pstr_t backupDataPath,
- uint32_t user_no,
- uint32_t seat_no)
+static long persadmin_restore_user_group_files( pstr_t backupDataPath,
+ uint32_t user_no,
+ uint32_t seat_no)
{
- sint_t retVal;
- long bytesRestored = 0;
- str_t pGroupRootSourcePath [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
- str_t pGroupSourcePath [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
- str_t pGroupDestPath [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
- str_t pUserSourcePath [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
- str_t pUserDestPath [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
- pstr_t pStrList = NIL;
- pstr_t pItemName = NIL;
- sint_t listBuffSize = 0;
- sint_t outBuffSize = 0;
-
- if(NIL == backupDataPath)
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("Invalid parameter in persadmin_restore_user_group_files call."));
- return GENERIC_ERROR_CODE;
- }
-
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
- DLT_STRING("Restore user group files from"),
- DLT_STRING(backupDataPath),
- DLT_STRING("for User:"),
- DLT_UINT8(user_no),
- DLT_STRING("for Seat:"),
- DLT_UINT8(seat_no));
-
- /* <backupDataPath>/Data/mnt-c/shared/group */
- (void)snprintf(pGroupRootSourcePath, sizeof(pGroupRootSourcePath), "%s%s", backupDataPath, PERS_ORG_SHARED_GROUP_CACHE_PATH);
-
- /* Check all groups */
- listBuffSize = persadmin_list_folder_get_size( pGroupRootSourcePath,
- PersadminFilterFolders,
- false );
- if(listBuffSize < SUCCESS_CODE)
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("persadmin_list_folder_get_size call failed with error code:"),
- DLT_INT(listBuffSize));
- return GENERIC_ERROR_CODE;
- }
- if(listBuffSize > 0)
- {
- pStrList = NIL;
- pStrList = (pstr_t)malloc((uint_t)listBuffSize); /*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
- if(NIL == pStrList)
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("Error allocating memory for list of folders."));
- return GENERIC_ERROR_CODE;
- }
- (void)memset(pStrList, 0, (uint_t)listBuffSize);
-
- outBuffSize = persadmin_list_folder( pGroupRootSourcePath,
- pStrList,
- listBuffSize,
- PersadminFilterFolders,
- false);
- if(outBuffSize < SUCCESS_CODE)
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("Error obtaining the list of folders."));
- free(pStrList); /*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
- pStrList = NIL;
- return GENERIC_ERROR_CODE;
- }
-
- pItemName = pStrList;
- while(listBuffSize > 0)
- {
- if(0 == strlen(pItemName))
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("Invalid group name found."));
- break;
- }
-
- /* Restore the user content for every group */
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
- DLT_STRING("restore user content for group"),
- DLT_STRING(pItemName),
- DLT_STRING(" ..."));
-
- /* --- group RCT compatibility check --- */
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
- DLT_STRING("RCT compatibility check for group"),
- DLT_STRING(pItemName),
- DLT_STRING("..."));
-
- /* <backupDataPath>/Data/mnt-c/shared/group/<group_id> */
- (void)snprintf(pGroupSourcePath, sizeof(pGroupSourcePath), PAS_SRC_SHARED_GROUP_CACHE_PATH_STRING_FORMAT, backupDataPath, pItemName, "");
-
- /*/Data/mnt-c/shared/group/<group_id> */
- (void)snprintf(pGroupDestPath, sizeof(pGroupDestPath), PERS_ORG_SHARED_CACHE_PATH_STRING_FORMAT, pItemName, "");
-
- if(false == persadmin_restore_check_RCT_compatibility(pGroupSourcePath, pGroupDestPath))
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("Incompatible group RCT files:"),
- DLT_STRING(pGroupSourcePath),
- DLT_STRING("<->"),
- DLT_STRING(pGroupDestPath));
- free(pStrList); /*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
- pStrList = NIL;
- return GENERIC_ERROR_CODE;
- }
-
- /* <backupDataPath>/Data/mnt-c/shared/group/<group_id>/user/<user_no>/seat/<seat_no> */
- (void)snprintf(pUserSourcePath, sizeof(pUserSourcePath), PAS_SRC_SHARED_GROUP_CACHE_PATH_STRING_FORMAT, backupDataPath, pItemName, "");
- persadmin_restore_set_user_path(pUserSourcePath,
- sizeof(pUserSourcePath) / sizeof(str_t),
- user_no,
- seat_no);
-
- /* /Data/mnt-c/shared/group/<group_id>/user/<user_no>/seat/<seat_no> */
- (void)snprintf(pUserDestPath, sizeof(pUserDestPath), PERS_ORG_SHARED_CACHE_PATH_STRING_FORMAT, pItemName, "");
- persadmin_restore_set_user_path(pUserDestPath,
- sizeof(pUserDestPath) / sizeof(str_t),
- user_no,
- seat_no);
-
- /* erase user content */
- retVal = persadmin_delete_folder(pUserDestPath);
- if(retVal < SUCCESS_CODE)
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("persadmin_delete_folder call failed with error code:"),
- DLT_INT(retVal));
- }
-
- /* copy user content */
- retVal = persadmin_copy_folder( pUserSourcePath,
- pUserDestPath,
- PersadminFilterAll,
- true);
-
- if(retVal < 0)
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("persadmin_copy_folder call failed with error code:"),
- DLT_INT(retVal));
- free(pStrList); /*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
- pStrList = NIL;
- return GENERIC_ERROR_CODE;
- }
-
- bytesRestored += retVal;
-
- listBuffSize -= ((sint_t)strlen(pItemName) + 1) * (sint_t)sizeof(*pItemName);
- pItemName += (strlen(pItemName) + 1); // MISRA-C:2004 Rule 17.4 Performing pointer arithmetic. - Rule currently not accepted
- }
-
- free(pStrList); /*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
- pStrList = NIL;
- }
-
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
- DLT_STRING("Restored successfully user group files from"),
- DLT_STRING(backupDataPath),
- DLT_STRING("for User:"),
- DLT_UINT8(user_no),
- DLT_STRING("for Seat:"),
- DLT_UINT8(seat_no),
- DLT_STRING("."),
- DLT_INT64(bytesRestored),
- DLT_STRING("bytes restored"));
-
- return bytesRestored;
+ sint_t retVal;
+ long bytesRestored = 0;
+ str_t pGroupRootSourcePath [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
+ str_t pGroupSourcePath [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
+ str_t pGroupDestPath [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
+ str_t pUserSourcePath [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
+ str_t pUserDestPath [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
+ pstr_t pStrList = NIL;
+ pstr_t pItemName = NIL;
+ sint_t listBuffSize = 0;
+ sint_t outBuffSize = 0;
+
+ if(NIL == backupDataPath)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("Invalid parameter in persadmin_restore_user_group_files call."));
+ return GENERIC_ERROR_CODE;
+ }
+
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
+ DLT_STRING("Restore user group files from"),
+ DLT_STRING(backupDataPath),
+ DLT_STRING("for User:"),
+ DLT_UINT8(user_no),
+ DLT_STRING("for Seat:"),
+ DLT_UINT8(seat_no));
+
+ /* <backupDataPath>/Data/mnt-c/shared/group */
+ (void)snprintf(pGroupRootSourcePath, sizeof(pGroupRootSourcePath), "%s%s", backupDataPath, PERS_ORG_SHARED_GROUP_CACHE_PATH);
+
+ /* check if folder exists; */
+ if( 0 == persadmin_check_if_file_exists(pGroupRootSourcePath, true) )
+ {
+ /* Check all groups */
+ listBuffSize = persadmin_list_folder_get_size( pGroupRootSourcePath,
+ PersadminFilterFolders,
+ false );
+ if(listBuffSize < SUCCESS_CODE)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("persadmin_list_folder_get_size call failed with error code:"),
+ DLT_INT(listBuffSize));
+ return GENERIC_ERROR_CODE;
+ }
+ if(listBuffSize > 0)
+ {
+ pStrList = NIL;
+ pStrList = (pstr_t)malloc((uint_t)listBuffSize); /*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
+ if(NIL == pStrList)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("Error allocating memory for list of folders."));
+ return GENERIC_ERROR_CODE;
+ }
+ (void)memset(pStrList, 0, (uint_t)listBuffSize);
+
+ outBuffSize = persadmin_list_folder( pGroupRootSourcePath,
+ pStrList,
+ listBuffSize,
+ PersadminFilterFolders,
+ false);
+ if(outBuffSize < SUCCESS_CODE)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("Error obtaining the list of folders."));
+ free(pStrList); /*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
+ pStrList = NIL;
+ return GENERIC_ERROR_CODE;
+ }
+
+ pItemName = pStrList;
+ while(listBuffSize > 0)
+ {
+ if(0 == strlen(pItemName))
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("Invalid group name found."));
+ break;
+ }
+
+ /* Restore the user content for every group */
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
+ DLT_STRING("restore user content for group"),
+ DLT_STRING(pItemName),
+ DLT_STRING(" ..."));
+
+ /* --- group RCT compatibility check --- */
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
+ DLT_STRING("RCT compatibility check for group"),
+ DLT_STRING(pItemName),
+ DLT_STRING("..."));
+
+ /* <backupDataPath>/Data/mnt-c/shared/group/<group_id> */
+ (void)snprintf(pGroupSourcePath, sizeof(pGroupSourcePath), PAS_SRC_SHARED_GROUP_CACHE_PATH_STRING_FORMAT, backupDataPath, pItemName, "");
+
+ /*/Data/mnt-c/shared/group/<group_id> */
+ (void)snprintf(pGroupDestPath, sizeof(pGroupDestPath), PERS_ORG_SHARED_CACHE_PATH_STRING_FORMAT, pItemName, "");
+
+ if(false == persadmin_restore_check_RCT_compatibility(pGroupSourcePath, pGroupDestPath))
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("Incompatible group RCT files:"),
+ DLT_STRING(pGroupSourcePath),
+ DLT_STRING("<->"),
+ DLT_STRING(pGroupDestPath));
+ free(pStrList); /*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
+ pStrList = NIL;
+ return GENERIC_ERROR_CODE;
+ }
+
+ /* <backupDataPath>/Data/mnt-c/shared/group/<group_id>/user/<user_no>/seat/<seat_no> */
+ (void)snprintf(pUserSourcePath, sizeof(pUserSourcePath), PAS_SRC_SHARED_GROUP_CACHE_PATH_STRING_FORMAT, backupDataPath, pItemName, "");
+ persadmin_restore_set_user_path(pUserSourcePath,
+ sizeof(pUserSourcePath) / sizeof(str_t),
+ user_no,
+ seat_no);
+
+ /* /Data/mnt-c/shared/group/<group_id>/user/<user_no>/seat/<seat_no> */
+ (void)snprintf(pUserDestPath, sizeof(pUserDestPath), PERS_ORG_SHARED_CACHE_PATH_STRING_FORMAT, pItemName, "");
+ persadmin_restore_set_user_path(pUserDestPath,
+ sizeof(pUserDestPath) / sizeof(str_t),
+ user_no,
+ seat_no);
+
+ if( 0 == persadmin_check_if_file_exists(pUserSourcePath, true) )
+ {
+ /* erase user content */
+ retVal = persadmin_delete_folder(pUserDestPath);
+ if(retVal < SUCCESS_CODE)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("persadmin_delete_folder call failed with error code:"),
+ DLT_INT(retVal));
+ }
+
+ /* copy user content */
+ retVal = persadmin_copy_folder( pUserSourcePath,
+ pUserDestPath,
+ PersadminFilterAll,
+ true);
+
+ if(retVal < 0)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("persadmin_copy_folder call failed with error code:"),
+ DLT_INT(retVal));
+ free(pStrList); /*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
+ pStrList = NIL;
+ return GENERIC_ERROR_CODE;
+ }
+
+ bytesRestored += retVal;
+ }
+ else
+ {
+ /* some info; */
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_INFO, DLT_STRING(LT_HDR), DLT_STRING("persadmin_restore_user_group_files -"),
+ DLT_STRING(pUserSourcePath), DLT_STRING("does not exist"));
+ }
+
+ listBuffSize -= ((sint_t)strlen(pItemName) + 1) * (sint_t)sizeof(*pItemName);
+ pItemName += (strlen(pItemName) + 1); // MISRA-C:2004 Rule 17.4 Performing pointer arithmetic. - Rule currently not accepted
+ }
+
+ free(pStrList); /*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
+ pStrList = NIL;
+ }
+ }
+ else
+ {
+ /* some info; */
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_INFO, DLT_STRING(LT_HDR), DLT_STRING("persadmin_restore_user_group_files -"),
+ DLT_STRING(pGroupRootSourcePath), DLT_STRING("does not exist"));
+ }
+
+ if( bytesRestored != 0)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
+ DLT_STRING("Restored successfully user group files from"),
+ DLT_STRING(backupDataPath),
+ DLT_STRING("for User:"),
+ DLT_UINT8(user_no),
+ DLT_STRING("for Seat:"),
+ DLT_UINT8(seat_no),
+ DLT_STRING("."),
+ DLT_INT64(bytesRestored),
+ DLT_STRING("bytes restored"));
+ }
+
+ return bytesRestored;
}/*DG C8ISQP-ISQP Metric 10-SSW_Administrator_0001*/
//--------------------------------------------------------------------------
-static long persadmin_restore_user_local_data( pstr_t backupDataPath,
- uint32_t user_no,
- uint32_t seat_no)
+static long persadmin_restore_user_local_data( pstr_t backupDataPath,
+ uint32_t user_no,
+ uint32_t seat_no)
{
- sint_t siRetVal = 0;
- sint_t listBuffSize = 0;
- long retVal = 0;
- long bytesRestored = 0;
- pstr_t pAppNameList = NIL;
- pstr_t pAppName = NIL;
- str_t pAppSourcePath [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
- str_t pAppDestPath [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
-
-
- if(NIL == backupDataPath)
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("Invalid parameter in persadmin_restore_user_local_data call."));
- return GENERIC_ERROR_CODE;
- }
-
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
- DLT_STRING("Restore user local data from"),
- DLT_STRING(backupDataPath),
- DLT_STRING("for User:"),
- DLT_UINT8(user_no),
- DLT_STRING("for Seat:"),
- DLT_UINT8(seat_no));
-
- /* Get list of application names */
- siRetVal = persadmin_list_application_folders_get_size(backupDataPath);
- if(siRetVal < SUCCESS_CODE)
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("persadmin_list_application_folders_get_size call failed with error code:"),
- DLT_INT(siRetVal));
- return GENERIC_ERROR_CODE;
- }
-
- if(0 == siRetVal)
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_WARN, DLT_STRING(LT_HDR),
- DLT_STRING("No application found."));
- return siRetVal;
- }
-
- listBuffSize = siRetVal;
-
- pAppNameList = NIL;
- pAppNameList = (pstr_t) malloc((uint_t)listBuffSize); /*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
- if(NIL == pAppNameList)
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("Error allocating memory for App name list."));
- return GENERIC_ERROR_CODE;
- }
- (void)memset(pAppNameList, 0, (uint_t)listBuffSize);
-
- siRetVal = persadmin_list_application_folders(backupDataPath,
- pAppNameList,
- listBuffSize );
-
- if((siRetVal <= SUCCESS_CODE) || (siRetVal > listBuffSize))
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("persadmin_list_application_folders call failed with error code:"),
- DLT_INT(siRetVal));
- free(pAppNameList); /*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
- pAppNameList = NIL;
- return GENERIC_ERROR_CODE;
- }
-
- listBuffSize = siRetVal;
- pAppName = pAppNameList;
- while(listBuffSize > 0)
- {
- if(0 == strlen(pAppName))
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("Invalid app name found."));
- break;
- }
-
- /* <backupDataPath>/Data/mnt-c/<appId> */
- (void)snprintf(pAppSourcePath, sizeof(pAppSourcePath), PAS_SRC_LOCAL_CACHE_PATH_FORMAT, backupDataPath, pAppName, "");
-
- /* /Data/mnt-c/<appId> */
- (void)snprintf(pAppDestPath, sizeof(pAppDestPath), PERS_ORG_LOCAL_CACHE_PATH_FORMAT, pAppName, "");
-
- /* --- RCT compatibility check --- */
- if(false == persadmin_restore_check_RCT_compatibility(pAppSourcePath, pAppDestPath))
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("Incompatible App RCT files:"),
- DLT_STRING(pAppSourcePath),
- DLT_STRING("<->"),
- DLT_STRING(pAppDestPath));
- free(pAppNameList); /*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
- pAppNameList = NIL;
- return GENERIC_ERROR_CODE;
- }
-
-
- /* user_no for every app */
- retVal = persadmin_restore_appl_user( backupDataPath,
- pAppName,
- user_no,
- seat_no);
- if(retVal < SUCCESS_CODE)
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("persadmin_restore_appl_user call failed with error code:"),
- DLT_INT(retVal));
- free(pAppNameList); /*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
- pAppNameList = NIL;
- return GENERIC_ERROR_CODE;
- }
- bytesRestored += retVal;
-
-
- /* user_no for local keys */
- retVal = persadmin_restore_local_keys( PersASSelectionType_User,
- backupDataPath,
- pAppName,
- user_no,
- seat_no);
-
- if(retVal < SUCCESS_CODE)
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("persadmin_restore_local_keys call failed with error code:"),
- DLT_INT(retVal));
- free(pAppNameList); /*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
- pAppNameList = NIL;
- return GENERIC_ERROR_CODE;
- }
- bytesRestored += retVal;
-
-
- /* links to groups and public */
- siRetVal = persadmin_import_links(pAppSourcePath,
- pAppDestPath );
-
- if(retVal < SUCCESS_CODE)
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("persadmin_import_links call failed with error code:"),
- DLT_INT(retVal));
- free(pAppNameList); /*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
- pAppNameList = NIL;
- return GENERIC_ERROR_CODE;
- }
- bytesRestored += siRetVal;
-
- listBuffSize -= ((sint_t)strlen(pAppName) + 1) * (sint_t)sizeof(*pAppName);
- pAppName += (strlen(pAppName) + 1); // MISRA-C:2004 Rule 17.4 Performing pointer arithmetic. - Rule currently not accepted
- }
-
- free(pAppNameList); /*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
- pAppNameList = NIL;
-
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
- DLT_STRING("Restored successfully user local data from"),
- DLT_STRING(backupDataPath),
- DLT_STRING("for User:"),
- DLT_UINT8(user_no),
- DLT_STRING("for Seat:"),
- DLT_UINT8(seat_no),
- DLT_STRING("."),
- DLT_INT64(bytesRestored),
- DLT_STRING("bytes restored"));
-
- return bytesRestored;
+ sint_t siRetVal = 0;
+ sint_t listBuffSize = 0;
+ long retVal = 0;
+ long bytesRestored = 0;
+ pstr_t pAppNameList = NIL;
+ pstr_t pAppName = NIL;
+ str_t pAppSourcePath [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
+ str_t pAppDestPath [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
+
+
+ if(NIL == backupDataPath)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("Invalid parameter in persadmin_restore_user_local_data call."));
+ return GENERIC_ERROR_CODE;
+ }
+
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
+ DLT_STRING("Restore user local data from"),
+ DLT_STRING(backupDataPath),
+ DLT_STRING("for User:"),
+ DLT_UINT8(user_no),
+ DLT_STRING("for Seat:"),
+ DLT_UINT8(seat_no));
+
+ /* Get list of application names */
+ siRetVal = persadmin_list_application_folders_get_size(backupDataPath);
+ if(siRetVal < SUCCESS_CODE)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("persadmin_list_application_folders_get_size call failed with error code:"),
+ DLT_INT(siRetVal));
+ return GENERIC_ERROR_CODE;
+ }
+
+ if(0 == siRetVal)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_WARN, DLT_STRING(LT_HDR),
+ DLT_STRING("No application found."));
+ return siRetVal;
+ }
+
+ listBuffSize = siRetVal;
+
+ pAppNameList = NIL;
+ pAppNameList = (pstr_t) malloc((uint_t)listBuffSize); /*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
+ if(NIL == pAppNameList)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("Error allocating memory for App name list."));
+ return GENERIC_ERROR_CODE;
+ }
+ (void)memset(pAppNameList, 0, (uint_t)listBuffSize);
+
+ siRetVal = persadmin_list_application_folders(backupDataPath,
+ pAppNameList,
+ listBuffSize );
+
+ if((siRetVal <= SUCCESS_CODE) || (siRetVal > listBuffSize))
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("persadmin_list_application_folders call failed with error code:"),
+ DLT_INT(siRetVal));
+ free(pAppNameList); /*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
+ pAppNameList = NIL;
+ return GENERIC_ERROR_CODE;
+ }
+
+ listBuffSize = siRetVal;
+ pAppName = pAppNameList;
+ while(listBuffSize > 0)
+ {
+ if(0 == strlen(pAppName))
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("Invalid app name found."));
+ break;
+ }
+
+ /* <backupDataPath>/Data/mnt-c/<appId> */
+ (void)snprintf(pAppSourcePath, sizeof(pAppSourcePath), PAS_SRC_LOCAL_CACHE_PATH_FORMAT, backupDataPath, pAppName, "");
+
+ /* /Data/mnt-c/<appId> */
+ (void)snprintf(pAppDestPath, sizeof(pAppDestPath), PERS_ORG_LOCAL_CACHE_PATH_FORMAT, pAppName, "");
+
+ /* --- RCT compatibility check --- */
+ if(false == persadmin_restore_check_RCT_compatibility(pAppSourcePath, pAppDestPath))
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("Incompatible App RCT files:"),
+ DLT_STRING(pAppSourcePath),
+ DLT_STRING("<->"),
+ DLT_STRING(pAppDestPath));
+ free(pAppNameList); /*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
+ pAppNameList = NIL;
+ return GENERIC_ERROR_CODE;
+ }
+
+
+ /* user_no for every app */
+ retVal = persadmin_restore_appl_user( backupDataPath,
+ pAppName,
+ user_no,
+ seat_no);
+ if(retVal < SUCCESS_CODE)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("persadmin_restore_appl_user call failed with error code:"),
+ DLT_INT(retVal));
+ free(pAppNameList); /*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
+ pAppNameList = NIL;
+ return GENERIC_ERROR_CODE;
+ }
+ bytesRestored += retVal;
+
+
+ /* user_no for local keys */
+ retVal = persadmin_restore_local_keys( PersASSelectionType_User,
+ backupDataPath,
+ pAppName,
+ user_no,
+ seat_no);
+
+ if(retVal < SUCCESS_CODE)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("persadmin_restore_local_keys call failed with error code:"),
+ DLT_INT(retVal));
+ free(pAppNameList); /*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
+ pAppNameList = NIL;
+ return GENERIC_ERROR_CODE;
+ }
+ bytesRestored += retVal;
+
+
+ /* links to groups and public */
+ siRetVal = persadmin_import_links(pAppSourcePath,
+ pAppDestPath );
+
+ if(retVal < SUCCESS_CODE)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("persadmin_import_links call failed with error code:"),
+ DLT_INT(retVal));
+ free(pAppNameList); /*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
+ pAppNameList = NIL;
+ return GENERIC_ERROR_CODE;
+ }
+ bytesRestored += siRetVal;
+
+ listBuffSize -= ((sint_t)strlen(pAppName) + 1) * (sint_t)sizeof(*pAppName);
+ pAppName += (strlen(pAppName) + 1); // MISRA-C:2004 Rule 17.4 Performing pointer arithmetic. - Rule currently not accepted
+ }
+
+ free(pAppNameList); /*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
+ pAppNameList = NIL;
+
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
+ DLT_STRING("Restored successfully user local data from"),
+ DLT_STRING(backupDataPath),
+ DLT_STRING("for User:"),
+ DLT_UINT8(user_no),
+ DLT_STRING("for Seat:"),
+ DLT_UINT8(seat_no),
+ DLT_STRING("."),
+ DLT_INT64(bytesRestored),
+ DLT_STRING("bytes restored"));
+
+ return bytesRestored;
}/*DG C8ISQP-ISQP Metric 10-SSW_Administrator_0001*/
//--------------------------------------------------------------------------
-static long persadmin_restore_user_shared_data( PersASSelectionType_e type,
- pstr_t backupDataPath,
- uint32_t user_no,
- uint32_t seat_no)
+static long persadmin_restore_user_shared_data( PersASSelectionType_e type,
+ pstr_t backupDataPath,
+ uint32_t user_no,
+ uint32_t seat_no)
{
- sint_t retVal;
- long bytesRestored = 0;
-
-
- if(NIL == backupDataPath)
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("Invalid parameter in persadmin_restore_user_shared_data call."));
- return GENERIC_ERROR_CODE;
- }
-
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
- DLT_STRING("Restore (of type"),
- DLT_INT(type),
- DLT_STRING(") user shared data from"),
- DLT_STRING(backupDataPath),
- DLT_STRING("for User:"),
- DLT_UINT8(user_no),
- DLT_STRING("for Seat:"),
- DLT_UINT8(seat_no));
-
-
- /* --- public user files restore --- */
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
- DLT_STRING("public file/folder restore..."));
-
- retVal = persadmin_restore_user_public_files( backupDataPath,
- user_no,
- seat_no);
- if(retVal < SUCCESS_CODE)
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("persadmin_restore_user_public_files call failed with error code:"),
- DLT_INT(retVal));
- }
-
- bytesRestored += retVal;
-
-
- /* --- group user files restore --- */
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
- DLT_STRING("group file/folder restore..."));
-
- retVal = persadmin_restore_user_group_files(backupDataPath,
- user_no,
- seat_no);
- if(retVal < SUCCESS_CODE)
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("persadmin_restore_user_group_files call failed with error code:"),
- DLT_INT(retVal));
- }
-
- bytesRestored += retVal;
-
-
- /* --- shared key-value restore --- */
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
- DLT_STRING("restore shared keys for User:"),
- DLT_UINT8(user_no),
- DLT_STRING("for Seat:"),
- DLT_UINT8(seat_no),
- DLT_STRING("..."));
-
- retVal = persadmin_restore_shared_keys( type,
- backupDataPath,
- "",
- user_no,
- seat_no);
-
- if(retVal < 0)
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("persadmin_restore_shared_keys call failed with error code:"),
- DLT_INT(retVal));
- return GENERIC_ERROR_CODE;
- }
-
- bytesRestored += retVal;
-
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
- DLT_STRING("Restored successfully user shared data from"),
- DLT_STRING(backupDataPath),
- DLT_STRING("for User:"),
- DLT_UINT8(user_no),
- DLT_STRING("for Seat:"),
- DLT_UINT8(seat_no),
- DLT_STRING("."),
- DLT_INT64(bytesRestored),
- DLT_STRING("bytes restored"));
-
- return bytesRestored;
+ sint_t retVal;
+ long bytesRestored = 0;
+
+
+ if(NIL == backupDataPath)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("Invalid parameter in persadmin_restore_user_shared_data call."));
+ return GENERIC_ERROR_CODE;
+ }
+
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
+ DLT_STRING("Restore (of type"),
+ DLT_INT(type),
+ DLT_STRING(") user shared data from"),
+ DLT_STRING(backupDataPath),
+ DLT_STRING("for User:"),
+ DLT_UINT8(user_no),
+ DLT_STRING("for Seat:"),
+ DLT_UINT8(seat_no));
+
+
+ /* --- public user files restore --- */
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
+ DLT_STRING("public file/folder restore..."));
+
+ retVal = persadmin_restore_user_public_files( backupDataPath,
+ user_no,
+ seat_no);
+ if(retVal < SUCCESS_CODE)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("persadmin_restore_user_public_files call failed with error code:"),
+ DLT_INT(retVal));
+ }
+
+ bytesRestored += retVal;
+
+
+ /* --- group user files restore --- */
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
+ DLT_STRING("group file/folder restore..."));
+
+ retVal = persadmin_restore_user_group_files(backupDataPath,
+ user_no,
+ seat_no);
+ if(retVal < SUCCESS_CODE)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("persadmin_restore_user_group_files call failed with error code:"),
+ DLT_INT(retVal));
+ }
+
+ bytesRestored += retVal;
+
+
+ /* --- shared key-value restore --- */
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
+ DLT_STRING("restore shared keys for User:"),
+ DLT_UINT8(user_no),
+ DLT_STRING("for Seat:"),
+ DLT_UINT8(seat_no),
+ DLT_STRING("..."));
+
+ retVal = persadmin_restore_shared_keys( type,
+ backupDataPath,
+ "",
+ user_no,
+ seat_no);
+
+ if(retVal < 0)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("persadmin_restore_shared_keys call failed with error code:"),
+ DLT_INT(retVal));
+ return GENERIC_ERROR_CODE;
+ }
+
+ bytesRestored += retVal;
+
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
+ DLT_STRING("Restored successfully user shared data from"),
+ DLT_STRING(backupDataPath),
+ DLT_STRING("for User:"),
+ DLT_UINT8(user_no),
+ DLT_STRING("for Seat:"),
+ DLT_UINT8(seat_no),
+ DLT_STRING("."),
+ DLT_INT64(bytesRestored),
+ DLT_STRING("bytes restored"));
+
+ return bytesRestored;
}/*DG C8ISQP-ISQP Metric 10-SSW_Administrator_0001*/
//-------------------------------------------------------------------------
-static long persadmin_restore_local_keys( PersASSelectionType_e type,
- pstr_t backupDataPath,
- pstr_t appId,
- uint32_t user_no,
- uint32_t seat_no)
+static long persadmin_restore_local_keys( PersASSelectionType_e type,
+ pstr_t backupDataPath,
+ pstr_t appId,
+ uint32_t user_no,
+ uint32_t seat_no)
{
- sint_t siRetVal;
- long bytesRestored = 0;
- str_t pDBFileName [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
- str_t pDBFileName_ [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
- str_t pDestDBPath [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
- pstr_t pSourceDBPath = NIL;
- pstr_t pDBList = NIL;
-
- if((NIL == backupDataPath) || (NIL == appId))
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("Invalid parameter in persadmin_restore_local_keys call."));
- return GENERIC_ERROR_CODE;
- }
-
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
- DLT_STRING("Restore local keys from "),
- DLT_STRING(backupDataPath),
- DLT_STRING("for App:"),
- DLT_STRING(appId),
- DLT_STRING("for User:"),
- DLT_UINT8(user_no),
- DLT_STRING("for Seat:"),
- DLT_UINT8(seat_no));
-
- // alloc. a fixed size for DB list
- pDBList = NIL;
- pDBList = (pstr_t) malloc(PAS_MAX_LIST_DB_SIZE); /*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
- if(NIL == pDBList)
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("Error allocating memory for DB list."));
- return GENERIC_ERROR_CODE;
- }
- (void)memset(pDBList, 0, PAS_MAX_LIST_DB_SIZE);
-
-
- siRetVal = persadmin_get_all_db_paths_with_names( backupDataPath,
- appId,
- PersistenceStorage_local,
- pDBList,
- PAS_MAX_LIST_DB_SIZE);
-
- if(siRetVal <= 0)
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("persadmin_get_all_db_paths_with_names call failed with error code:"),
- DLT_INT(siRetVal));
- free(pDBList); /*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
- pDBList = NIL;
- return GENERIC_ERROR_CODE;
- }
-
- pSourceDBPath = pDBList;
- while(PAS_ITEM_LIST_DELIMITER != (*pSourceDBPath))
- {
- (void)memset(pDBFileName, 0, sizeof(pDBFileName));
-
- siRetVal = persadmin_get_filename(pSourceDBPath,
- pDBFileName,
- sizeof(pDBFileName));
-
- if(siRetVal < 0)
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("persadmin_get_filename call failed with error code:"),
- DLT_INT(siRetVal));
- free(pDBList); /*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
- pDBList = NIL;
- return GENERIC_ERROR_CODE;
- }
-
- (void)snprintf(pDBFileName_, sizeof(pDBFileName_), "/%s", pDBFileName);
-
- /* Form a local path */
- (void)snprintf(pDestDBPath, sizeof(pDestDBPath), PERS_ORG_LOCAL_CACHE_PATH_FORMAT, appId, pDBFileName_);
-
- // delete the keys in the destination DB only if the source DB exists
- if(SUCCESS_CODE == persadmin_check_if_file_exists( pSourceDBPath, false))
- {
- // remove current keys before transferring keys from backup content
- siRetVal = persadmin_delete_keys_by_filter( type,
- pDestDBPath,
- user_no,
- seat_no);
- if(siRetVal < SUCCESS_CODE)
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("persadmin_delete_keys_by_filter call failed with error code:"),
- DLT_INT(siRetVal));
- }
- }
-
- // transfer the keys from the backup content
- if(SUCCESS_CODE == persadmin_check_if_file_exists( pSourceDBPath, false))
- {
- siRetVal = persadmin_copy_keys_by_filter( type,
- pDestDBPath,
- pSourceDBPath,
- user_no,
- seat_no );
- if(siRetVal < SUCCESS_CODE)
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("persadmin_copy_keys_by_filter call failed with error code:"),
- DLT_INT(siRetVal));
- free(pDBList); /*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
- pDBList = NIL;
- return GENERIC_ERROR_CODE;
- }
-
- bytesRestored += siRetVal;
- }
- else
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_WARN, DLT_STRING(LT_HDR),
- DLT_STRING("Source database does not exist (ignore):"),
- DLT_STRING(pSourceDBPath));
- }
-
- pSourceDBPath += (strlen(pSourceDBPath) + 1); // MISRA-C:2004 Rule 17.4 Performing pointer arithmetic. - Rule currently not accepted
- }
-
- free(pDBList); /*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
- pDBList=NIL;
-
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
- DLT_STRING("Restored successfully local keys from"),
- DLT_STRING(backupDataPath),
- DLT_STRING("for App:"),
- DLT_STRING(appId),
- DLT_STRING("for User:"),
- DLT_UINT8(user_no),
- DLT_STRING("for Seat:"),
- DLT_UINT8(seat_no),
- DLT_STRING("."),
- DLT_INT64(bytesRestored),
- DLT_STRING("bytes restored"));
-
- return bytesRestored;
+ sint_t siRetVal;
+ long bytesRestored = 0;
+ str_t pDBFileName [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
+ str_t pDBFileName_ [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
+ str_t pDestDBPath [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
+ pstr_t pSourceDBPath = NIL;
+ pstr_t pDBList = NIL;
+
+ if((NIL == backupDataPath) || (NIL == appId))
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("Invalid parameter in persadmin_restore_local_keys call."));
+ return GENERIC_ERROR_CODE;
+ }
+
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
+ DLT_STRING("Restore local keys from "),
+ DLT_STRING(backupDataPath),
+ DLT_STRING("for App:"),
+ DLT_STRING(appId),
+ DLT_STRING("for User:"),
+ DLT_UINT8(user_no),
+ DLT_STRING("for Seat:"),
+ DLT_UINT8(seat_no));
+
+ // alloc. a fixed size for DB list
+ pDBList = NIL;
+ pDBList = (pstr_t) malloc(PAS_MAX_LIST_DB_SIZE); /*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
+ if(NIL == pDBList)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("Error allocating memory for DB list."));
+ return GENERIC_ERROR_CODE;
+ }
+ (void)memset(pDBList, 0, PAS_MAX_LIST_DB_SIZE);
+
+
+ siRetVal = persadmin_get_all_db_paths_with_names( backupDataPath,
+ appId,
+ PersistenceStorage_local,
+ pDBList,
+ PAS_MAX_LIST_DB_SIZE);
+
+ if(siRetVal <= 0)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("persadmin_get_all_db_paths_with_names call failed with error code:"),
+ DLT_INT(siRetVal));
+ free(pDBList); /*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
+ pDBList = NIL;
+ return GENERIC_ERROR_CODE;
+ }
+
+ pSourceDBPath = pDBList;
+ while(PAS_ITEM_LIST_DELIMITER != (*pSourceDBPath))
+ {
+ (void)memset(pDBFileName, 0, sizeof(pDBFileName));
+
+ siRetVal = persadmin_get_filename(pSourceDBPath,
+ pDBFileName,
+ sizeof(pDBFileName));
+
+ if(siRetVal < 0)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("persadmin_get_filename call failed with error code:"),
+ DLT_INT(siRetVal));
+ free(pDBList); /*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
+ pDBList = NIL;
+ return GENERIC_ERROR_CODE;
+ }
+
+ (void)snprintf(pDBFileName_, sizeof(pDBFileName_), "/%s", pDBFileName);
+
+ /* Form a local path */
+ (void)snprintf(pDestDBPath, sizeof(pDestDBPath), PERS_ORG_LOCAL_CACHE_PATH_FORMAT, appId, pDBFileName_);
+
+ // delete the keys in the destination DB only if the source DB exists
+ if(SUCCESS_CODE == persadmin_check_if_file_exists( pSourceDBPath, false))
+ {
+ // remove current keys before transferring keys from backup content
+ siRetVal = persadmin_delete_keys_by_filter( type,
+ pDestDBPath,
+ user_no,
+ seat_no);
+ if(siRetVal < SUCCESS_CODE)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("persadmin_delete_keys_by_filter call failed with error code:"),
+ DLT_INT(siRetVal));
+ }
+ }
+
+ // transfer the keys from the backup content
+ if(SUCCESS_CODE == persadmin_check_if_file_exists( pSourceDBPath, false))
+ {
+ siRetVal = persadmin_copy_keys_by_filter( type,
+ pDestDBPath,
+ pSourceDBPath,
+ user_no,
+ seat_no );
+ if(siRetVal < SUCCESS_CODE)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("persadmin_copy_keys_by_filter call failed with error code:"),
+ DLT_INT(siRetVal));
+ free(pDBList); /*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
+ pDBList = NIL;
+ return GENERIC_ERROR_CODE;
+ }
+
+ bytesRestored += siRetVal;
+ }
+ else
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_WARN, DLT_STRING(LT_HDR),
+ DLT_STRING("Source database does not exist (ignore):"),
+ DLT_STRING(pSourceDBPath));
+ }
+
+ pSourceDBPath += (strlen(pSourceDBPath) + 1); // MISRA-C:2004 Rule 17.4 Performing pointer arithmetic. - Rule currently not accepted
+ }
+
+ free(pDBList); /*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
+ pDBList=NIL;
+
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
+ DLT_STRING("Restored successfully local keys from"),
+ DLT_STRING(backupDataPath),
+ DLT_STRING("for App:"),
+ DLT_STRING(appId),
+ DLT_STRING("for User:"),
+ DLT_UINT8(user_no),
+ DLT_STRING("for Seat:"),
+ DLT_UINT8(seat_no),
+ DLT_STRING("."),
+ DLT_INT64(bytesRestored),
+ DLT_STRING("bytes restored"));
+
+ return bytesRestored;
}/*DG C8ISQP-ISQP Metric 10-SSW_Administrator_0001*/
//-------------------------------------------------------------------------
-static long persadmin_restore_shared_keys( PersASSelectionType_e type,
- pstr_t backupDataPath,
- pstr_t appId,
- uint32_t user_no,
- uint32_t seat_no)
+static long persadmin_restore_shared_keys( PersASSelectionType_e type,
+ pstr_t backupDataPath,
+ pstr_t appId,
+ uint32_t user_no,
+ uint32_t seat_no)
{
- sint_t siRetVal;
- long bytesRestored = 0;
- str_t pDBFileName [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
- str_t pDBFileName_ [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
- str_t pDestDBPath [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
- pstr_t pSourceDBPath = NIL;
- pstr_t pDBList = NIL;
- pstr_t pSharedSubstr = NIL;
-
- if((NIL == backupDataPath) || (NIL == appId))
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("Invalid parameter in persadmin_restore_shared_keys call."));
- return GENERIC_ERROR_CODE;
- }
-
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
- DLT_STRING("Restore shared keys from"),
- DLT_STRING(backupDataPath),
- DLT_STRING("for App:"),
- DLT_STRING(appId),
- DLT_STRING("for User:"),
- DLT_UINT8(user_no),
- DLT_STRING("for Seat:"),
- DLT_UINT8(seat_no));
-
- // alloc. a fixed size for DB list
- pDBList = NIL;
- pDBList = (pstr_t) malloc(PAS_MAX_LIST_DB_SIZE); /*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
- if(NIL == pDBList)
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("Error allocating memory for DB list."));
- return GENERIC_ERROR_CODE;
- }
- (void)memset(pDBList, 0, PAS_MAX_LIST_DB_SIZE);
-
-
- siRetVal = persadmin_get_all_db_paths_with_names( backupDataPath,
- appId,
- PersistenceStorage_shared,
- pDBList,
- PAS_MAX_LIST_DB_SIZE);
-
- if(siRetVal <= 0)
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("persadmin_get_all_db_paths_with_names call failed with error code:"),
- DLT_INT(siRetVal));
- free(pDBList); /*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
- pDBList = NIL;
- return GENERIC_ERROR_CODE;
- }
-
- pSourceDBPath = pDBList;
- while(PAS_ITEM_LIST_DELIMITER != (*pSourceDBPath))
- {
- (void)memset(pDBFileName, 0, sizeof(pDBFileName));
-
- siRetVal = persadmin_get_filename(pSourceDBPath,
- pDBFileName,
- sizeof(pDBFileName));
-
- if(siRetVal < 0)
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("persadmin_get_filename call failed with error code:"),
- DLT_INT(siRetVal));
- free(pDBList); /*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
- pDBList = NIL;
- return GENERIC_ERROR_CODE;
- }
-
- (void)snprintf(pDBFileName_, sizeof(pDBFileName_), "/%s", pDBFileName);
-
- /* Form a shared path */
- pSharedSubstr = NIL;
- /* public DB */
- pSharedSubstr = strstr(pSourceDBPath, PAS_SHARED_PUBLIC_PATH);
- if(NIL == pSharedSubstr)
- {
- /* group DB */
- pSharedSubstr = strstr(pSourceDBPath, PAS_SHARED_GROUP_PATH);
- }
-
- if(NIL != pSharedSubstr)
- {
- (void)snprintf(pDestDBPath, sizeof(pDestDBPath), "%s%s", PERS_ORG_LOCAL_APP_CACHE_PATH_, pSharedSubstr);
- }
-
- // transfer the keys from the backup content
- if(SUCCESS_CODE == persadmin_check_if_file_exists( pSourceDBPath, false))
- {
- siRetVal = persadmin_copy_keys_by_filter( type,
- pDestDBPath,
- pSourceDBPath,
- user_no,
- seat_no );
- if(siRetVal < SUCCESS_CODE)
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("persadmin_copy_keys_by_filter call failed with error code:"),
- DLT_INT(siRetVal));
- free(pDBList); /*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
- pDBList = NIL;
- return GENERIC_ERROR_CODE;
- }
-
- bytesRestored += siRetVal;
- }
- else
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_WARN, DLT_STRING(LT_HDR),
- DLT_STRING("Source database does not exist (ignore):"),
- DLT_STRING(pSourceDBPath));
- }
-
- pSourceDBPath += (strlen(pSourceDBPath) + 1); // MISRA-C:2004 Rule 17.4 Performing pointer arithmetic. - Rule currently not accepted
- }
-
- free(pDBList); /*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
- pDBList=NIL;
-
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
- DLT_STRING("Restored successfully shared keys from"),
- DLT_STRING(backupDataPath),
- DLT_STRING("for App:"),
- DLT_STRING(appId),
- DLT_STRING("for User:"),
- DLT_UINT8(user_no),
- DLT_STRING("for Seat:"),
- DLT_UINT8(seat_no),
- DLT_STRING("."),
- DLT_INT64(bytesRestored),
- DLT_STRING("bytes restored"));
-
- return bytesRestored;
+ sint_t siRetVal;
+ long bytesRestored = 0;
+ str_t pDBFileName [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
+ str_t pDBFileName_ [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
+ str_t pDestDBPath [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
+ pstr_t pSourceDBPath = NIL;
+ pstr_t pDBList = NIL;
+ pstr_t pSharedSubstr = NIL;
+
+ if((NIL == backupDataPath) || (NIL == appId))
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("Invalid parameter in persadmin_restore_shared_keys call."));
+ return GENERIC_ERROR_CODE;
+ }
+
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
+ DLT_STRING("Restore shared keys from"),
+ DLT_STRING(backupDataPath),
+ DLT_STRING("for App:"),
+ DLT_STRING(appId),
+ DLT_STRING("for User:"),
+ DLT_UINT8(user_no),
+ DLT_STRING("for Seat:"),
+ DLT_UINT8(seat_no));
+
+ // alloc. a fixed size for DB list
+ pDBList = NIL;
+ pDBList = (pstr_t) malloc(PAS_MAX_LIST_DB_SIZE); /*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
+ if(NIL == pDBList)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("Error allocating memory for DB list."));
+ return GENERIC_ERROR_CODE;
+ }
+ (void)memset(pDBList, 0, PAS_MAX_LIST_DB_SIZE);
+
+
+ siRetVal = persadmin_get_all_db_paths_with_names( backupDataPath,
+ appId,
+ PersistenceStorage_shared,
+ pDBList,
+ PAS_MAX_LIST_DB_SIZE);
+
+ if(siRetVal <= 0)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("persadmin_get_all_db_paths_with_names call failed with error code:"),
+ DLT_INT(siRetVal));
+ free(pDBList); /*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
+ pDBList = NIL;
+ return GENERIC_ERROR_CODE;
+ }
+
+ pSourceDBPath = pDBList;
+ while(PAS_ITEM_LIST_DELIMITER != (*pSourceDBPath))
+ {
+ (void)memset(pDBFileName, 0, sizeof(pDBFileName));
+
+ siRetVal = persadmin_get_filename(pSourceDBPath,
+ pDBFileName,
+ sizeof(pDBFileName));
+
+ if(siRetVal < 0)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("persadmin_get_filename call failed with error code:"),
+ DLT_INT(siRetVal));
+ free(pDBList); /*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
+ pDBList = NIL;
+ return GENERIC_ERROR_CODE;
+ }
+
+ (void)snprintf(pDBFileName_, sizeof(pDBFileName_), "/%s", pDBFileName);
+
+ /* Form a shared path */
+ pSharedSubstr = NIL;
+ /* public DB */
+ pSharedSubstr = strstr(pSourceDBPath, PAS_SHARED_PUBLIC_PATH);
+ if(NIL == pSharedSubstr)
+ {
+ /* group DB */
+ pSharedSubstr = strstr(pSourceDBPath, PAS_SHARED_GROUP_PATH);
+ }
+
+ if(NIL != pSharedSubstr)
+ {
+ (void)snprintf(pDestDBPath, sizeof(pDestDBPath), "%s%s", PERS_ORG_LOCAL_APP_CACHE_PATH_, pSharedSubstr);
+ }
+
+ // transfer the keys from the backup content
+ if(SUCCESS_CODE == persadmin_check_if_file_exists( pSourceDBPath, false))
+ {
+ siRetVal = persadmin_copy_keys_by_filter( type,
+ pDestDBPath,
+ pSourceDBPath,
+ user_no,
+ seat_no );
+ if(siRetVal < SUCCESS_CODE)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("persadmin_copy_keys_by_filter call failed with error code:"),
+ DLT_INT(siRetVal));
+ free(pDBList); /*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
+ pDBList = NIL;
+ return GENERIC_ERROR_CODE;
+ }
+
+ bytesRestored += siRetVal;
+ }
+ else
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_WARN, DLT_STRING(LT_HDR),
+ DLT_STRING("Source database does not exist (ignore):"),
+ DLT_STRING(pSourceDBPath));
+ }
+
+ pSourceDBPath += (strlen(pSourceDBPath) + 1); // MISRA-C:2004 Rule 17.4 Performing pointer arithmetic. - Rule currently not accepted
+ }
+
+ free(pDBList); /*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
+ pDBList=NIL;
+
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
+ DLT_STRING("Restored successfully shared keys from"),
+ DLT_STRING(backupDataPath),
+ DLT_STRING("for App:"),
+ DLT_STRING(appId),
+ DLT_STRING("for User:"),
+ DLT_UINT8(user_no),
+ DLT_STRING("for Seat:"),
+ DLT_UINT8(seat_no),
+ DLT_STRING("."),
+ DLT_INT64(bytesRestored),
+ DLT_STRING("bytes restored"));
+
+ return bytesRestored;
}/*DG C8ISQP-ISQP Metric 10-SSW_Administrator_0001*/
//-------------------------------------------------------------------------------
static bool_t persadmin_restore_check_if_app_exists(pstr_t sourceRootPath,
- pstr_t appId )
+ pstr_t appId )
{
- str_t pAppPath [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
+ str_t pAppPath [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
- if((NIL == sourceRootPath) || (NIL == appId))
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("Invalid parameter in persadmin_restore_check_if_app_exists call."));
- return false;
- }
+ if((NIL == sourceRootPath) || (NIL == appId))
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("Invalid parameter in persadmin_restore_check_if_app_exists call."));
+ return false;
+ }
- /* <sourceRootPath>/Data/mnt-c/<appId> */
- (void)snprintf(pAppPath, sizeof(pAppPath), PAS_SRC_LOCAL_CACHE_PATH_FORMAT, sourceRootPath, appId, "");
+ /* <sourceRootPath>/Data/mnt-c/<appId> */
+ (void)snprintf(pAppPath, sizeof(pAppPath), PAS_SRC_LOCAL_CACHE_PATH_FORMAT, sourceRootPath, appId, "");
- if(SUCCESS_CODE == persadmin_check_if_file_exists( pAppPath, true))
- {
- return true;
- }
+ if(SUCCESS_CODE == persadmin_check_if_file_exists( pAppPath, true))
+ {
+ return true;
+ }
- return false;
+ return false;
}
//---------------------------------------------------------------------------------
static bool_t persadmin_restore_check_RCT_compatibility(pstr_t sourceRCTPath,
- pstr_t destRCTPath )
+ pstr_t destRCTPath )
{
- str_t pSrcRCTPath [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
- str_t pDestRCTPath [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
+ str_t pSrcRCTPath [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
+ str_t pDestRCTPath [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
- if((NIL == sourceRCTPath) || (NIL == destRCTPath))
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("Invalid parameter in persadmin_restore_check_RCT_compatibility call."));
- return false;
- }
+ if((NIL == sourceRCTPath) || (NIL == destRCTPath))
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("Invalid parameter in persadmin_restore_check_RCT_compatibility call."));
+ return false;
+ }
- /* path to source RCT file */
- (void)snprintf(pSrcRCTPath, sizeof(pSrcRCTPath), "%s%s", sourceRCTPath, gResTableCfg);
+ /* path to source RCT file */
+ (void)snprintf(pSrcRCTPath, sizeof(pSrcRCTPath), "%s%s", sourceRCTPath, gResTableCfg);
- /* path to dest RCT file */
- (void)snprintf(pDestRCTPath, sizeof(pDestRCTPath), "%s%s", destRCTPath, gResTableCfg);
+ /* path to dest RCT file */
+ (void)snprintf(pDestRCTPath, sizeof(pDestRCTPath), "%s%s", destRCTPath, gResTableCfg);
- return persadmin_check_for_same_file_content(pSrcRCTPath, pDestRCTPath);
+ return persadmin_check_for_same_file_content(pSrcRCTPath, pDestRCTPath);
}
//---------------------------------------------------------------------------
static long persadmin_restore_appl_data( pstr_t backup_data_path,
- pstr_t appId )
+ pstr_t appId )
{
- long retVal = SUCCESS_CODE;
- long bytesRestored = 0;
- str_t pAppSourcePath [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
- str_t pAppDestPath [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
-
- if((NIL == backup_data_path) || (NIL == appId))
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("Invalid parameter in persadmin_restore_appl_data call."));
- return GENERIC_ERROR_CODE;
- }
-
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
- DLT_STRING("Restore app data from"),
- DLT_STRING(backup_data_path),
- DLT_STRING("for App:"),
- DLT_STRING(appId));
-
-
- /* <backupDataPath>/Data/mnt-c/<appId> */
- (void)snprintf(pAppSourcePath, sizeof(pAppSourcePath), PAS_SRC_LOCAL_CACHE_PATH_FORMAT, backup_data_path, appId, "");
-
- /* /Data/mnt-c/<appId> */
- (void)snprintf(pAppDestPath, sizeof(pAppDestPath), PERS_ORG_LOCAL_CACHE_PATH_FORMAT, appId, "");
-
-
- /* --- RCT compatibility check --- */
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
- DLT_STRING("RCT compatibility check for App:"),
- DLT_STRING(appId),
- DLT_STRING("..."));
-
- if(false == persadmin_restore_check_RCT_compatibility(pAppSourcePath, pAppDestPath))
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("Incompatible App RCT files."));
- return GENERIC_ERROR_CODE;
- }
-
-
- /* --- local file/folder restore --- */
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
- DLT_STRING("local file/folder restore..."));
-
-
- /* Check if the specified application data exists */
- if(true == persadmin_restore_check_if_app_exists( (pstr_t)backup_data_path,
- (pstr_t)appId) )
- {
- /* restore node content */
- retVal = persadmin_restore_appl_node( backup_data_path,
- (pstr_t)appId);
- if(retVal < SUCCESS_CODE)
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("persadmin_restore_appl_node call failed with error code:"),
- DLT_INT(retVal));
- return GENERIC_ERROR_CODE;
- }
- else
- {
- bytesRestored += retVal;
- }
-
- /* restore user content (for all users) */
- retVal = persadmin_restore_appl_user( backup_data_path,
- (pstr_t)appId,
- PERSIST_SELECT_ALL_USERS,
- PERSIST_SELECT_ALL_SEATS);
- if(retVal < SUCCESS_CODE)
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("persadmin_restore_appl_user call failed with error code:"),
- DLT_INT(retVal));
- return GENERIC_ERROR_CODE;
- }
- else
- {
- bytesRestored += retVal;
- }
- }
-
-
- /* --- local key-value restore --- */
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
- DLT_STRING("local key/value restore..."));
-
- retVal = persadmin_restore_local_keys( PersASSelectionType_Application,
- backup_data_path,
- appId,
- PERSIST_SELECT_ALL_USERS,
- PERSIST_SELECT_ALL_SEATS);
-
- if(retVal < SUCCESS_CODE)
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("persadmin_restore_local_keys call failed with error code:"),
- DLT_INT(retVal));
- return GENERIC_ERROR_CODE;
- }
- else
- {
- bytesRestored += retVal;
- }
-
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
- DLT_STRING("Restored successfully app data from"),
- DLT_STRING(backup_data_path),
- DLT_STRING("for App:"),
- DLT_STRING(appId),
- DLT_STRING("."),
- DLT_INT64(bytesRestored),
- DLT_STRING("bytes restored"));
-
- return bytesRestored;
+ long retVal = SUCCESS_CODE;
+ long bytesRestored = 0;
+ str_t pAppSourcePath [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
+ str_t pAppDestPath [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
+
+ if((NIL == backup_data_path) || (NIL == appId))
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("Invalid parameter in persadmin_restore_appl_data call."));
+ return GENERIC_ERROR_CODE;
+ }
+
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
+ DLT_STRING("Restore app data from"),
+ DLT_STRING(backup_data_path),
+ DLT_STRING("for App:"),
+ DLT_STRING(appId));
+
+
+ /* <backupDataPath>/Data/mnt-c/<appId> */
+ (void)snprintf(pAppSourcePath, sizeof(pAppSourcePath), PAS_SRC_LOCAL_CACHE_PATH_FORMAT, backup_data_path, appId, "");
+
+ /* /Data/mnt-c/<appId> */
+ (void)snprintf(pAppDestPath, sizeof(pAppDestPath), PERS_ORG_LOCAL_CACHE_PATH_FORMAT, appId, "");
+
+
+ /* --- RCT compatibility check --- */
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
+ DLT_STRING("RCT compatibility check for App:"),
+ DLT_STRING(appId),
+ DLT_STRING("..."));
+
+ if(false == persadmin_restore_check_RCT_compatibility(pAppSourcePath, pAppDestPath))
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("Incompatible App RCT files."));
+ return GENERIC_ERROR_CODE;
+ }
+
+
+ /* --- local file/folder restore --- */
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
+ DLT_STRING("local file/folder restore..."));
+
+
+ /* Check if the specified application data exists */
+ if(true == persadmin_restore_check_if_app_exists( (pstr_t)backup_data_path,
+ (pstr_t)appId) )
+ {
+ /* restore node content */
+ retVal = persadmin_restore_appl_node( backup_data_path,
+ (pstr_t)appId);
+ if(retVal < SUCCESS_CODE)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("persadmin_restore_appl_node call failed with error code:"),
+ DLT_INT(retVal));
+ return GENERIC_ERROR_CODE;
+ }
+ else
+ {
+ bytesRestored += retVal;
+ }
+
+ /* restore user content (for all users) */
+ retVal = persadmin_restore_appl_user( backup_data_path,
+ (pstr_t)appId,
+ PERSIST_SELECT_ALL_USERS,
+ PERSIST_SELECT_ALL_SEATS);
+ if(retVal < SUCCESS_CODE)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("persadmin_restore_appl_user call failed with error code:"),
+ DLT_INT(retVal));
+ return GENERIC_ERROR_CODE;
+ }
+ else
+ {
+ bytesRestored += retVal;
+ }
+ }
+
+
+ /* --- local key-value restore --- */
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
+ DLT_STRING("local key/value restore..."));
+
+ retVal = persadmin_restore_local_keys( PersASSelectionType_Application,
+ backup_data_path,
+ appId,
+ PERSIST_SELECT_ALL_USERS,
+ PERSIST_SELECT_ALL_SEATS);
+
+ if(retVal < SUCCESS_CODE)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("persadmin_restore_local_keys call failed with error code:"),
+ DLT_INT(retVal));
+ return GENERIC_ERROR_CODE;
+ }
+ else
+ {
+ bytesRestored += retVal;
+ }
+
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
+ DLT_STRING("Restored successfully app data from"),
+ DLT_STRING(backup_data_path),
+ DLT_STRING("for App:"),
+ DLT_STRING(appId),
+ DLT_STRING("."),
+ DLT_INT64(bytesRestored),
+ DLT_STRING("bytes restored"));
+
+ return bytesRestored;
}/*DG C8ISQP-ISQP Metric 10-SSW_Administrator_0001*/
//---------------------------------------------------------------------------
-static long persadmin_restore_user_data(pstr_t backup_data_path,
- uint32_t user_no,
- uint32_t seat_no )
+static long persadmin_restore_user_data(pstr_t backup_data_path,
+ uint32_t user_no,
+ uint32_t seat_no )
{
- long retVal = 0;
- long bytesRestored = 0;
-
-
- if(NIL == backup_data_path)
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("Invalid parameter in persadmin_restore_user_data call."));
- return GENERIC_ERROR_CODE;
- }
-
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
- DLT_STRING("Restore user data from"),
- DLT_STRING(backup_data_path),
- DLT_STRING("for User:"),
- DLT_UINT8(user_no),
- DLT_STRING("for Seat:"),
- DLT_UINT8(seat_no));
-
- /* --- local user data restore --- */
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
- DLT_STRING("local user data restore..."));
-
- retVal = persadmin_restore_user_local_data( backup_data_path,
- user_no,
- seat_no);
- if(retVal < SUCCESS_CODE)
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("persadmin_restore_user_local_data call failed with error code:"),
- DLT_INT(retVal));
- return GENERIC_ERROR_CODE;
- }
-
- bytesRestored += retVal;
-
-
- /* --- shared user data restore --- */
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
- DLT_STRING("shared user data restore..."));
-
- retVal = persadmin_restore_user_shared_data(PersASSelectionType_User,
- backup_data_path,
- user_no,
- seat_no);
- if(retVal < SUCCESS_CODE)
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("persadmin_restore_user_shared_data call failed with error code:"),
- DLT_INT(retVal));
- return GENERIC_ERROR_CODE;
- }
-
- bytesRestored += retVal;
-
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
- DLT_STRING("Restored successfully user data from"),
- DLT_STRING(backup_data_path),
- DLT_STRING("for User:"),
- DLT_UINT8(user_no),
- DLT_STRING("for Seat:"),
- DLT_UINT8(seat_no),
- DLT_STRING("."),
- DLT_INT64(bytesRestored),
- DLT_STRING("bytes restored"));
-
- return bytesRestored;
+ long retVal = 0;
+ long bytesRestored = 0;
+
+
+ if(NIL == backup_data_path)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("Invalid parameter in persadmin_restore_user_data call."));
+ return GENERIC_ERROR_CODE;
+ }
+
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
+ DLT_STRING("Restore user data from"),
+ DLT_STRING(backup_data_path),
+ DLT_STRING("for User:"),
+ DLT_UINT8(user_no),
+ DLT_STRING("for Seat:"),
+ DLT_UINT8(seat_no));
+
+ /* --- local user data restore --- */
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
+ DLT_STRING("local user data restore..."));
+
+ retVal = persadmin_restore_user_local_data( backup_data_path,
+ user_no,
+ seat_no);
+ if(retVal < SUCCESS_CODE)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("persadmin_restore_user_local_data call failed with error code:"),
+ DLT_INT(retVal));
+ return GENERIC_ERROR_CODE;
+ }
+
+ bytesRestored += retVal;
+
+
+ /* --- shared user data restore --- */
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
+ DLT_STRING("shared user data restore..."));
+
+ retVal = persadmin_restore_user_shared_data(PersASSelectionType_User,
+ backup_data_path,
+ user_no,
+ seat_no);
+ if(retVal < SUCCESS_CODE)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("persadmin_restore_user_shared_data call failed with error code:"),
+ DLT_INT(retVal));
+ return GENERIC_ERROR_CODE;
+ }
+
+ bytesRestored += retVal;
+
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
+ DLT_STRING("Restored successfully user data from"),
+ DLT_STRING(backup_data_path),
+ DLT_STRING("for User:"),
+ DLT_UINT8(user_no),
+ DLT_STRING("for Seat:"),
+ DLT_UINT8(seat_no),
+ DLT_STRING("."),
+ DLT_INT64(bytesRestored),
+ DLT_STRING("bytes restored"));
+
+ return bytesRestored;
}/*DG C8ISQP-ISQP Metric 10-SSW_Administrator_0001*/
@@ -1837,176 +1904,176 @@ static long persadmin_restore_user_data(pstr_t backup_data_path,
//---------------------------------------------------------------------------
static long persadmin_restore_all_data( pstr_t backup_data_path )
{
- sint_t siRetVal = 0;
- sint_t listBuffSize = 0;
- long retVal = 0;
- long bytesRestored = 0;
- pstr_t pAppNameList = NIL;
- pstr_t pAppName = NIL;
- str_t pAppSourcePath [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
- str_t pAppDestPath [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
-
-
- if(NIL == backup_data_path)
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("Invalid parameter in persadmin_restore_all_data call."));
- return GENERIC_ERROR_CODE;
- }
-
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
- DLT_STRING("Restore all data from"),
- DLT_STRING(backup_data_path));
-
-
- /* --- local data restore --- */
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
- DLT_STRING("local data restore..."));
-
- /* Get list of backup application names */
- /* Only the existing applications will be restored, no new applications will be added from the backup content */
- siRetVal = persadmin_list_application_folders_get_size(backup_data_path);
- if(siRetVal < SUCCESS_CODE)
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("persadmin_list_application_folders_get_size call failed with error code:"),
- DLT_INT(siRetVal));
- return GENERIC_ERROR_CODE;
- }
-
- if(0 == siRetVal)
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_WARN, DLT_STRING(LT_HDR),
- DLT_STRING("No application found."));
- return siRetVal;
- }
-
- listBuffSize = siRetVal;
-
- pAppNameList = (pstr_t) malloc((uint_t)listBuffSize); /*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
- if(NIL == pAppNameList)
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("Error allocating memory for App name list."));
- return GENERIC_ERROR_CODE;
- }
- (void)memset(pAppNameList, 0, (uint_t)listBuffSize);
-
- siRetVal = persadmin_list_application_folders(backup_data_path,
- pAppNameList,
- listBuffSize );
-
- if((siRetVal < SUCCESS_CODE) || (siRetVal > listBuffSize))
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("persadmin_list_application_folders call failed with error code:"),
- DLT_INT(siRetVal));
- free(pAppNameList); /*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
- pAppNameList = NIL;
- return GENERIC_ERROR_CODE;
- }
-
- listBuffSize = siRetVal;
- pAppName = pAppNameList;
- while(listBuffSize > 0)
- {
- if(0 == strlen(pAppName))
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("Invalid app name found."));
- break;
- }
-
- /* Check if the application exists. Skip the application otherwise */
- /* /Data/mnt-c/<appId> */
- (void)snprintf(pAppDestPath, sizeof(pAppDestPath), PERS_ORG_LOCAL_CACHE_PATH_FORMAT, pAppName, "");
-
- if(true == persadmin_restore_check_if_app_exists("", pAppName))
- {
- /* local app data */
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
- DLT_STRING("local app data restore..."));
-
- retVal = persadmin_restore_appl_data( backup_data_path,
- pAppName );
- if(retVal < SUCCESS_CODE)
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("persadmin_restore_appl_data call failed with error code:"),
- DLT_INT(retVal));
- free(pAppNameList); /*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
- pAppNameList = NIL;
- return GENERIC_ERROR_CODE;
- }
- bytesRestored += retVal;
-
-
- /* links to groups and public */
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
- DLT_STRING("restore links to groups and public..."));
-
- /* <backupDataPath>/Data/mnt-c/<appId> */
- (void)snprintf(pAppSourcePath, sizeof(pAppSourcePath), PAS_SRC_LOCAL_CACHE_PATH_FORMAT, backup_data_path, pAppName, "");
-
- siRetVal = persadmin_import_links( pAppSourcePath,
- pAppDestPath );
- if(retVal < SUCCESS_CODE)
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("persadmin_import_links call failed with error code:"),
- DLT_INT(retVal));
- free(pAppNameList); /*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
- pAppNameList = NIL;
- return GENERIC_ERROR_CODE;
- }
- bytesRestored += retVal;
- }
-
- listBuffSize -= ((sint_t)strlen(pAppName) + 1) * (sint_t)sizeof(*pAppName);
- pAppName += (strlen(pAppName) + 1); // MISRA-C:2004 Rule 17.4 Performing pointer arithmetic. - Rule currently not accepted
- }
- free(pAppNameList); /*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
- pAppNameList = NIL;
-
-
- /* non-user shared data */
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
- DLT_STRING("restore non-user shared data..."));
-
- retVal = persadmin_restore_non_user_shared_data(backup_data_path);
- if(retVal < SUCCESS_CODE)
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("persadmin_restore_non_user_shared_data call failed with error code:"),
- DLT_INT(retVal));
- return GENERIC_ERROR_CODE;
- }
- bytesRestored += retVal;
-
-
- /* user shared data */
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
- DLT_STRING("restore user shared data..."));
-
- retVal = persadmin_restore_user_shared_data( PersASSelectionType_All,
- backup_data_path,
- PERSIST_SELECT_ALL_USERS,
- PERSIST_SELECT_ALL_SEATS);
- if(retVal < SUCCESS_CODE)
- {
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
- DLT_STRING("persadmin_restore_user_shared_data call failed with error code:"),
- DLT_INT(retVal));
- return GENERIC_ERROR_CODE;
- }
- bytesRestored += retVal;
-
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
- DLT_STRING("Restored successfully all data from"),
- DLT_STRING(backup_data_path),
- DLT_STRING("."),
- DLT_INT64(bytesRestored),
- DLT_STRING("bytes restored"));
-
- return bytesRestored;
+ sint_t siRetVal = 0;
+ sint_t listBuffSize = 0;
+ long retVal = 0;
+ long bytesRestored = 0;
+ pstr_t pAppNameList = NIL;
+ pstr_t pAppName = NIL;
+ str_t pAppSourcePath [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
+ str_t pAppDestPath [PERS_ORG_MAX_LENGTH_PATH_FILENAME];
+
+
+ if(NIL == backup_data_path)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("Invalid parameter in persadmin_restore_all_data call."));
+ return GENERIC_ERROR_CODE;
+ }
+
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
+ DLT_STRING("Restore all data from"),
+ DLT_STRING(backup_data_path));
+
+
+ /* --- local data restore --- */
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
+ DLT_STRING("local data restore..."));
+
+ /* Get list of backup application names */
+ /* Only the existing applications will be restored, no new applications will be added from the backup content */
+ siRetVal = persadmin_list_application_folders_get_size(backup_data_path);
+ if(siRetVal < SUCCESS_CODE)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("persadmin_list_application_folders_get_size call failed with error code:"),
+ DLT_INT(siRetVal));
+ return GENERIC_ERROR_CODE;
+ }
+
+ if(0 == siRetVal)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_WARN, DLT_STRING(LT_HDR),
+ DLT_STRING("No application found."));
+ return siRetVal;
+ }
+
+ listBuffSize = siRetVal;
+
+ pAppNameList = (pstr_t) malloc((uint_t)listBuffSize); /*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
+ if(NIL == pAppNameList)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("Error allocating memory for App name list."));
+ return GENERIC_ERROR_CODE;
+ }
+ (void)memset(pAppNameList, 0, (uint_t)listBuffSize);
+
+ siRetVal = persadmin_list_application_folders(backup_data_path,
+ pAppNameList,
+ listBuffSize );
+
+ if((siRetVal < SUCCESS_CODE) || (siRetVal > listBuffSize))
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("persadmin_list_application_folders call failed with error code:"),
+ DLT_INT(siRetVal));
+ free(pAppNameList); /*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
+ pAppNameList = NIL;
+ return GENERIC_ERROR_CODE;
+ }
+
+ listBuffSize = siRetVal;
+ pAppName = pAppNameList;
+ while(listBuffSize > 0)
+ {
+ if(0 == strlen(pAppName))
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("Invalid app name found."));
+ break;
+ }
+
+ /* Check if the application exists. Skip the application otherwise */
+ /* /Data/mnt-c/<appId> */
+ (void)snprintf(pAppDestPath, sizeof(pAppDestPath), PERS_ORG_LOCAL_CACHE_PATH_FORMAT, pAppName, "");
+
+ if(true == persadmin_restore_check_if_app_exists("", pAppName))
+ {
+ /* local app data */
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
+ DLT_STRING("local app data restore..."));
+
+ retVal = persadmin_restore_appl_data( backup_data_path,
+ pAppName );
+ if(retVal < SUCCESS_CODE)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("persadmin_restore_appl_data call failed with error code:"),
+ DLT_INT(retVal));
+ free(pAppNameList); /*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
+ pAppNameList = NIL;
+ return GENERIC_ERROR_CODE;
+ }
+ bytesRestored += retVal;
+
+
+ /* links to groups and public */
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
+ DLT_STRING("restore links to groups and public..."));
+
+ /* <backupDataPath>/Data/mnt-c/<appId> */
+ (void)snprintf(pAppSourcePath, sizeof(pAppSourcePath), PAS_SRC_LOCAL_CACHE_PATH_FORMAT, backup_data_path, pAppName, "");
+
+ siRetVal = persadmin_import_links( pAppSourcePath,
+ pAppDestPath );
+ if(retVal < SUCCESS_CODE)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("persadmin_import_links call failed with error code:"),
+ DLT_INT(retVal));
+ free(pAppNameList); /*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
+ pAppNameList = NIL;
+ return GENERIC_ERROR_CODE;
+ }
+ bytesRestored += retVal;
+ }
+
+ listBuffSize -= ((sint_t)strlen(pAppName) + 1) * (sint_t)sizeof(*pAppName);
+ pAppName += (strlen(pAppName) + 1); // MISRA-C:2004 Rule 17.4 Performing pointer arithmetic. - Rule currently not accepted
+ }
+ free(pAppNameList); /*DG C8MR2R-MISRA-C:2004 Rule 20.4-SSW_Administrator_0002*/
+ pAppNameList = NIL;
+
+
+ /* non-user shared data */
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
+ DLT_STRING("restore non-user shared data..."));
+
+ retVal = persadmin_restore_non_user_shared_data(backup_data_path);
+ if(retVal < SUCCESS_CODE)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("persadmin_restore_non_user_shared_data call failed with error code:"),
+ DLT_INT(retVal));
+ return GENERIC_ERROR_CODE;
+ }
+ bytesRestored += retVal;
+
+
+ /* user shared data */
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
+ DLT_STRING("restore user shared data..."));
+
+ retVal = persadmin_restore_user_shared_data( PersASSelectionType_All,
+ backup_data_path,
+ PERSIST_SELECT_ALL_USERS,
+ PERSIST_SELECT_ALL_SEATS);
+ if(retVal < SUCCESS_CODE)
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR),
+ DLT_STRING("persadmin_restore_user_shared_data call failed with error code:"),
+ DLT_INT(retVal));
+ return GENERIC_ERROR_CODE;
+ }
+ bytesRestored += retVal;
+
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_DEBUG, DLT_STRING(LT_HDR),
+ DLT_STRING("Restored successfully all data from"),
+ DLT_STRING(backup_data_path),
+ DLT_STRING("."),
+ DLT_INT64(bytesRestored),
+ DLT_STRING("bytes restored"));
+
+ return bytesRestored;
}/*DG C8ISQP-ISQP Metric 10-SSW_Administrator_0001*/
diff --git a/Administrator/src/ssw_pers_admin_resource_config_add.c b/Administrator/src/ssw_pers_admin_resource_config_add.c
index 973bfca..297349e 100644
--- a/Administrator/src/ssw_pers_admin_resource_config_add.c
+++ b/Administrator/src/ssw_pers_admin_resource_config_add.c
@@ -11,6 +11,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* Date Author Reason
+* 2017-01-30 Cosmin Cernat Improve robustness of pas_conf_getContextInstallFolder function().
* 2016-06-02 Cosmin Cernat Bugzilla Bug 437: Moved WDOG re-triggering to glib loop
* 2013.10.23 Ionut Ieremie CSP_WZ#6300: Installation of the default values in context of the custom keys not working
* 2013.09.27 Ionut Ieremie CSP_WZ#5781: Fix memory leakage
@@ -347,7 +348,7 @@ Helpers
static bool_t pas_conf_unarchiveResourceFile(constpstr_t resourcePathname) ;
static bool_t pas_conf_deleteFolderContent(pstr_t folderPathName, PersadminFilterMode_e eFilterMode) ;
static sint_t pas_conf_filterResourcesList(pstr_t resourceID, bool_t bFilterOnlyNonDefault, bool_t bIsKeyType, pas_conf_listOfItems_s* const psListUnfiltered, pstr_t pListFiltered_out);
-
+static bool_t pas_conf_createDefaultContentJsonFile(constpstr_t filePath, constpstr_t appName) ;
/******************************************************************************************************
******************************** Implementation ****************************************************
@@ -1600,6 +1601,35 @@ static bool_t pas_conf_removeDataForApp(constpstr_t appID, bool_t bPrepareForNew
****************************** Folder (public, group, app) data related *****************************************
*****************************************************************************************************************/
+
+/**
+ * \brief Create json configuration file with default content in given destination.
+ * \param filePath [in] path where the file will be created
+ * \param appName [in] application name which will be put into json config file
+ * \return true for success, false other way
+ */
+static bool_t pas_conf_createDefaultContentJsonFile(constpstr_t filePath, constpstr_t appName)
+{
+ FILE * pFile;
+ pFile = fopen (filePath,"w");
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_INFO, DLT_STRING(LT_HDR), DLT_STRING(__FUNCTION__), DLT_STRING("Json config file '"),
+ DLT_STRING(filePath), DLT_STRING("' with default configuration has been created."));
+
+ if (pFile != NULL)
+ {
+ fputs("{\n", pFile);
+ char buffer[PERSADMIN_MAX_PATH_LENGHT];
+ sprintf(buffer, " \"config_appl\": \"%s\",\n", appName);
+ fputs(buffer,pFile);
+ fputs(" \"version\": \"0.1.0\",\n", pFile);
+ fputs(" \"resources\": {} \n", pFile);
+ fputs("}\n", pFile);
+ fclose(pFile);
+ }
+ return true;
+}
+
+
/**
* \brief Get the context for the public/group/app's install folder
* \param destInstallFolder [in] pathname for the destination(install) folder
@@ -1611,7 +1641,10 @@ static bool_t pas_conf_getContextInstallFolder(constpstr_t destInstallFolder, co
{
bool_t bEverythingOK = true ;
size_t iIndex = 0 ;
-
+
+ pstr_t appName[PERSADMIN_MAX_PATH_LENGHT];
+ persadmin_get_filename(destInstallFolder, appName, PERSADMIN_MAX_PATH_LENGHT);
+
/*---------------------------------------------------------------------------------------------------------
get context for destination folder
---------------------------------------------------------------------------------------------------------*/
@@ -1622,15 +1655,15 @@ static bool_t pas_conf_getContextInstallFolder(constpstr_t destInstallFolder, co
(void)snprintf(psInstallFolderCtx_inout->sDestContext.sRctDB.pathname,
sizeof(psInstallFolderCtx_inout->sDestContext.sRctDB.pathname),
"%s/%s", destInstallFolder, PERS_ORG_RCT_NAME) ;
- psInstallFolderCtx_inout->sDestContext.sRctDB.handler = persComRctOpen(psInstallFolderCtx_inout->sDestContext.sRctDB.pathname, true) ;
+ psInstallFolderCtx_inout->sDestContext.sRctDB.handler = persComRctOpen(psInstallFolderCtx_inout->sDestContext.sRctDB.pathname, true) ;
if(psInstallFolderCtx_inout->sDestContext.sRctDB.handler >= 0)
- {
+ {
psInstallFolderCtx_inout->sDestContext.sRctDB.bIsAvailable = true ;
}
else
- {
+ {
bEverythingOK = false ;
- }
+ }
(void)snprintf(g_msg, sizeof(g_msg), "%s - persComRctOpen(%s) returned <%d>",
__FUNCTION__, psInstallFolderCtx_inout->sDestContext.sRctDB.pathname, psInstallFolderCtx_inout->sDestContext.sRctDB.handler) ;
DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_INFO, DLT_STRING(LT_HDR), DLT_STRING(g_msg));
@@ -1656,6 +1689,7 @@ static bool_t pas_conf_getContextInstallFolder(constpstr_t destInstallFolder, co
sizeof(tab_sDestLocalDBsInfo[iIndex].psFileAvailability->pathname),
"%s/%s", destInstallFolder, tab_sDestLocalDBsInfo[iIndex].filename) ;
tab_sDestLocalDBsInfo[iIndex].psFileAvailability->handler = persComDbOpen(tab_sDestLocalDBsInfo[iIndex].psFileAvailability->pathname, true) ;
+
if(tab_sDestLocalDBsInfo[iIndex].psFileAvailability->handler >= 0)
{
tab_sDestLocalDBsInfo[iIndex].psFileAvailability->bIsAvailable = true ;
@@ -1669,7 +1703,6 @@ static bool_t pas_conf_getContextInstallFolder(constpstr_t destInstallFolder, co
DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_INFO, DLT_STRING(LT_HDR), DLT_STRING(g_msg));
}
}
-
/*---------------------------------------------------------------------------------------------------------
get context for source folders
---------------------------------------------------------------------------------------------------------*/
@@ -1692,18 +1725,32 @@ static bool_t pas_conf_getContextInstallFolder(constpstr_t destInstallFolder, co
for(iIndex = 0 ; bEverythingOK && (iIndex < sizeof(tab_sSrcContextEntries)/sizeof(tab_sSrcContextEntries[0])) ; iIndex++)
{
(void)snprintf( tab_sSrcContextEntries[iIndex].psFileAvailability->pathname,
- sizeof(tab_sSrcContextEntries[iIndex].psFileAvailability->pathname),
+ sizeof(tab_sSrcContextEntries[iIndex].psFileAvailability->pathname),
"%s%s", srcInstallFolder, tab_sSrcContextEntries[iIndex].filename) ;
if(0 <= persadmin_check_if_file_exists(tab_sSrcContextEntries[iIndex].psFileAvailability->pathname, tab_sSrcContextEntries[iIndex].bIsFolder))
{
- tab_sSrcContextEntries[iIndex].psFileAvailability->bIsAvailable = true ;
+ tab_sSrcContextEntries[iIndex].psFileAvailability->bIsAvailable = true ;
}
else
{
- tab_sSrcContextEntries[iIndex].psFileAvailability->bIsAvailable = false ;
+ tab_sSrcContextEntries[iIndex].psFileAvailability->bIsAvailable = false ;
if(tab_sSrcContextEntries[iIndex].bPresenceIsMandatory)
{
- bEverythingOK = false ;
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_INFO, DLT_STRING(LT_HDR), DLT_STRING(__FUNCTION__),
+ DLT_STRING(" - Folder with pathname: "), DLT_STRING( tab_sSrcContextEntries[iIndex].psFileAvailability->pathname ), DLT_STRING(" cannot be found! ") );
+
+ if (0 <= persadmin_create_folder( tab_sSrcContextEntries[iIndex].psFileAvailability->pathname))
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_INFO, DLT_STRING(LT_HDR), DLT_STRING(__FUNCTION__),
+ DLT_STRING(" - Empty folder has been created. Please be sure if it's ok!"));
+
+ tab_sSrcContextEntries[iIndex].psFileAvailability->bIsAvailable = true ;
+ }
+ else
+ {
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_ERROR, DLT_STRING(LT_HDR), DLT_STRING(__FUNCTION__), DLT_STRING("- Cannot create an empty folder."));
+ bEverythingOK = false ;
+ }
}
}
(void)snprintf(g_msg, sizeof(g_msg), "%s - %s <<%s>>", __FUNCTION__,
@@ -1720,9 +1767,9 @@ static bool_t pas_conf_getContextInstallFolder(constpstr_t destInstallFolder, co
{
{false, NIL,/* &psInstallFolderCtx_inout->sSrcContext.sRctFile */
PERSADM_CFG_RESOURCE_RCT_FILENAME, PersAdminCfgFileType_RCT, true},
- {false, NIL,/* &psInstallFolderCtx_inout->sSrcContext.sFactoryDefaultDataFile */
+ {false, NIL,/* &psInstallFolderCtx_inout->sSrcContext.sFactoryDefaultDataFile */
PERSADM_CFG_RESOURCE_ROOT_KEYDATA_FOLDER_NAME"/"PERSADM_CFG_RESOURCE_FACTORY_DEFAULT_KEYDATA_FILENAME, PersAdminCfgFileType_Database, true},
- {false, NIL,/* &psInstallFolderCtx_inout->sSrcContext.sConfigurableDefaultDataFile */
+ {false, NIL,/* &psInstallFolderCtx_inout->sSrcContext.sConfigurableDefaultDataFile */
PERSADM_CFG_RESOURCE_ROOT_KEYDATA_FOLDER_NAME"/"PERSADM_CFG_RESOURCE_CONFIG_KEYDEFAULT_DATA_FILENAME, PersAdminCfgFileType_Database, true},
{false, NIL,/* &psInstallFolderCtx_inout->sSrcContext.sInitialDataFile */
PERSADM_CFG_RESOURCE_ROOT_KEYDATA_FOLDER_NAME"/"PERSADM_CFG_RESOURCE_NON_DEFAULT_KEYDATA_FILENAME, PersAdminCfgFileType_Database, false},
@@ -1739,37 +1786,40 @@ static bool_t pas_conf_getContextInstallFolder(constpstr_t destInstallFolder, co
for(iIndex = 0 ; bEverythingOK && (iIndex < sizeof(tab_sSrcContextEntries)/sizeof(tab_sSrcContextEntries[0])) ; iIndex++)
{
(void)snprintf( tab_sSrcContextEntries[iIndex].psFileAvailability->pathname,
- sizeof(tab_sSrcContextEntries[iIndex].psFileAvailability->pathname),
+ sizeof(tab_sSrcContextEntries[iIndex].psFileAvailability->pathname),
"%s/%s", srcInstallFolder, tab_sSrcContextEntries[iIndex].filename) ;
- if(0 <= persadmin_check_if_file_exists(tab_sSrcContextEntries[iIndex].psFileAvailability->pathname, tab_sSrcContextEntries[iIndex].bIsFolder))
+
+ if(tab_sSrcContextEntries[iIndex].bPresenceIsMandatory)
{
- tab_sSrcContextEntries[iIndex].psFileAvailability->bIsAvailable = true ;
- tab_sSrcContextEntries[iIndex].psFileAvailability->handler =
- persAdmCfgFileOpen(tab_sSrcContextEntries[iIndex].psFileAvailability->pathname, tab_sSrcContextEntries[iIndex].eCfgFileType) ;
+ if(0 > persadmin_check_if_file_exists(tab_sSrcContextEntries[iIndex].psFileAvailability->pathname, tab_sSrcContextEntries[iIndex].bIsFolder))
+ {
+ pas_conf_createDefaultContentJsonFile(tab_sSrcContextEntries[iIndex].psFileAvailability->pathname, appName);
+ }
+
+ tab_sSrcContextEntries[iIndex].psFileAvailability->bIsAvailable = true ;
+ tab_sSrcContextEntries[iIndex].psFileAvailability->handler =
+ persAdmCfgFileOpen(tab_sSrcContextEntries[iIndex].psFileAvailability->pathname, tab_sSrcContextEntries[iIndex].eCfgFileType) ;
+
if(tab_sSrcContextEntries[iIndex].psFileAvailability->handler < 0)
{
bEverythingOK = false ;
}
- (void)snprintf(g_msg, sizeof(g_msg), "%s - persAdmCfgFileOpen(<%s>, %d) returned <%d>",
+ (void)snprintf(g_msg, sizeof(g_msg), "%s - persAdmCfgFileOpen(<%s>, %d) returned <%d>",
__FUNCTION__, tab_sSrcContextEntries[iIndex].psFileAvailability->pathname,
tab_sSrcContextEntries[iIndex].eCfgFileType, tab_sSrcContextEntries[iIndex].psFileAvailability->handler) ;
- DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_INFO, DLT_STRING(LT_HDR), DLT_STRING(g_msg));
+ DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_INFO, DLT_STRING(LT_HDR), DLT_STRING(g_msg));
}
else
{
- tab_sSrcContextEntries[iIndex].psFileAvailability->bIsAvailable = false ;
+ tab_sSrcContextEntries[iIndex].psFileAvailability->bIsAvailable = false ;
tab_sSrcContextEntries[iIndex].psFileAvailability->handler = -1 ;
- if(tab_sSrcContextEntries[iIndex].bPresenceIsMandatory)
- {
- bEverythingOK = false ;
- }
}
- (void)snprintf(g_msg, sizeof(g_msg), "%s - %s <<%s>>", __FUNCTION__,
+
+ (void)snprintf(g_msg, sizeof(g_msg), "%s - %s <<%s>>", __FUNCTION__,
tab_sSrcContextEntries[iIndex].psFileAvailability->bIsAvailable ? "Found" : "Not found",
tab_sSrcContextEntries[iIndex].filename) ;
DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_INFO, DLT_STRING(LT_HDR), DLT_STRING(g_msg));
}
-
}
/*---------------------------------------------------------------------------------------------------------
@@ -1783,11 +1833,11 @@ static bool_t pas_conf_getContextInstallFolder(constpstr_t destInstallFolder, co
__FUNCTION__, bEverythingOK ? "OK" : "FAILED") ;
DLT_LOG(persAdminSvcDLTCtx, DLT_LOG_INFO, DLT_STRING(LT_HDR), DLT_STRING(g_msg));
}
- }
-
+ }
return bEverythingOK ;
}/*DG C8ISQP-ISQP Metric 10-SSW_Administrator_0001*/ /*DG C8ISQP-ISQP Metric 1-SSW_Administrator_0021*/ /*DG C8ISQP-ISQP Metric 6-SSW_Administrator_0022*/
+
/**
* \brief Close handlers, free dynamicaly allocated memory for the public/group/app's context
* \param psInstallFolderCtx_inout [inout] pointer to the public/group/app's context
diff --git a/ChangeLog b/ChangeLog
index e720aff..4d859d1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -9,6 +9,17 @@
persistence-administrator ChangeLog
===================================
+Version 1.0.9 08.02.2017
+
+1. Add support to handle symbolic links when creating backup
+2. Limitation of user_no to 4 is removed
+3. Set ssw_pers_admin_common.c file formatting to unix
+4. Remove irrelevant functionality from pers_admin_test_framework
+5. Add error checking in recovery process
+6. Error checking in recovery when group/public data is not configured
+7. Handle empty /file and /key directories in database resources configuration
+8. Replace the tabulators by space in Administrator/src/ssw_pers_admin_recovery.c
+
Version 1.0.8 02.06.2016
1. Fixed issue http://bugs.genivi.org/show_bug.cgi?id=437
diff --git a/configure.ac b/configure.ac
index 0112c1f..a6b4e44 100644
--- a/configure.ac
+++ b/configure.ac
@@ -18,7 +18,7 @@ dnl **************************************************************************
dnl *** First, define all of the version numbers up front ***
dnl *** In particular, this allows the version macro to be used in AC_INIT ***
dnl **************************************************************************
-m4_define([PERS_PACKAGE_VERSION_S],[1.0.8])
+m4_define([PERS_PACKAGE_VERSION_S],[1.0.9])
m4_define([PERS_ADMINACCESSLIB_VERSION_N],[1000000])
dnl ***************************
diff --git a/test/pers_svc_test/Makefile.am b/test/pers_svc_test/Makefile.am
index 4a95fb6..bc16bd4 100644
--- a/test/pers_svc_test/Makefile.am
+++ b/test/pers_svc_test/Makefile.am
@@ -23,7 +23,7 @@ bin_PROGRAMS = pers_admin_test_framework
#
pers_admin_test_framework_CFLAGS = \
- -I $(top_srcdir)/Administrator/inc/private -I $(top_srcdir)/Administrator/inc/public -I inc -I generated \
+ -I $(top_srcdir)/Administrator/inc/private -I $(top_srcdir)/Administrator/inc/public -I inc \
$(DLT_CFLAGS) \
$(GIO_CFLAGS) \
$(GIO_UNIX_CFLAGS) \
@@ -49,7 +49,6 @@ pers_admin_test_framework_LDADD = \
pers_admin_test_framework_SOURCES = \
$(top_srcdir)/Administrator/src/ssw_pers_admin_files_helper.c \
- generated/PasModuleTestGen.c \
src/test_PAS.c \
src/test_pas_check_data_after_backup_application.c \
src/test_pas_check_data_after_backup_create_all.c \
@@ -57,7 +56,6 @@ pers_admin_test_framework_SOURCES = \
src/test_pas_check_data_after_backup_user2_seat_all.c \
src/test_pas_check_data_after_delete_user2_data.c \
src/test_pas_check_data_after_reset.c \
- src/test_PAS_dbus.c \
src/test_pas_import_all.c \
src/test_pas_import_app.c \
src/test_pas_import_source_content.c \
@@ -77,12 +75,3 @@ pers_admin_test_framework_SOURCES = \
src/test_pas_restore_default_User1.c \
src/test_pas_restore_default_User2App1.c \
src/test_pas_restore_default_User2Seat1.c
-
-generated/PasModuleTestGen.c: dbus_specifications/OIPModuleTestPASCodeGeneration.xml
- mkdir -p generated
- gdbus-codegen --interface-prefix="org.genivi.persistence." --c-namespace="OipPersistence" --generate-c-code="generated/PasModuleTestGen" dbus_specifications/OIPModuleTestPASCodeGeneration.xml
-
-
-# Delete all generated files on 'make clean'
-CLEANFILES = generated/PasModuleTestGen.c \
- generated/PasModuleTestGen.h
diff --git a/test/pers_svc_test/dbus_specifications/OIPModuleTestPASCodeGeneration.txt b/test/pers_svc_test/dbus_specifications/OIPModuleTestPASCodeGeneration.txt
deleted file mode 100644
index 2e77971..0000000
--- a/test/pers_svc_test/dbus_specifications/OIPModuleTestPASCodeGeneration.txt
+++ /dev/null
@@ -1 +0,0 @@
-gdbus-codegen --interface-prefix="org.genivi.persistence." --c-namespace="OipPersistence" --generate-c-code="PasModuleTestGen" OIPModuleTestPASCodeGeneration.xml \ No newline at end of file
diff --git a/test/pers_svc_test/dbus_specifications/OIPModuleTestPASCodeGeneration.xml b/test/pers_svc_test/dbus_specifications/OIPModuleTestPASCodeGeneration.xml
deleted file mode 100644
index 12d7f10..0000000
--- a/test/pers_svc_test/dbus_specifications/OIPModuleTestPASCodeGeneration.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<!--
-*
-* Copyright (C) 2012-2013 Continental Automotive GmbH.
-*
-* Author: guy.sagnes@continental-corporation.com
-*
-* XML model of the dbus interfaces for the test NodeStateMachine
-*
-* This Source Code Form is subject to the terms of the Mozilla Public
-* License, v. 2.0. If a copy of the MPL was not distributed with this
-* file, You can obtain one at http://mozilla.org/MPL/2.0/.
-*
-* Date Author Reason
-* 2012.11.27 uidu0250 CSP_WZ#1280: Initial version
-*
--->
-<node>
- <interface name="org.genivi.persistence.admintestframework">
- <method name="ExecuteTestCases">
- <arg name="noOfTestCases" type="i" direction="out"/>
- <arg name="noOfTestCasesSuccessful" type="i" direction="out"/>
- <arg name="noOfTestCasesFailed" type="i" direction="out"/>
- </method>
- </interface>
-</node>
diff --git a/test/pers_svc_test/dbus_specifications/OIPModuleTestPASDBusCall.txt b/test/pers_svc_test/dbus_specifications/OIPModuleTestPASDBusCall.txt
deleted file mode 100644
index c607a15..0000000
--- a/test/pers_svc_test/dbus_specifications/OIPModuleTestPASDBusCall.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-dbus-send --system --dest=org.genivi.persistence.admintestframework --print-reply \
---type=method_call /org/genivi/persistence/admintestframework \
-org.genivi.persistence.admintestframework.ExecuteTestCases \ No newline at end of file
diff --git a/test/pers_svc_test/inc/test_PAS.h b/test/pers_svc_test/inc/test_PAS.h
index 8b50cca..6e0d469 100644
--- a/test/pers_svc_test/inc/test_PAS.h
+++ b/test/pers_svc_test/inc/test_PAS.h
@@ -11,7 +11,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* Date Author Reason
-* 2013.04.15 uidu0250 CSP_WZ#3424: Add IF extension for "restore to default"
+* 2013.04.15 uidu0250 CSP_WZ#3424: Add IF extension for "restore to default"
* 2012.11.29 uidv2833 CSP_WZ#1280: Adapted implementation for the new test framework
* 2012.11.28 uidl9757 CSP_WZ#1280: Initial version
*
@@ -32,10 +32,6 @@ extern "C"
/* needed because of change in PCL (should be removed later) */
#define TST_DEFAULT_CONTEXT {0xFF, 0xFF, 0xFF}
-#define PERSISTENCE_ADMIN_TF_BUS_TYPE 1 //G_BUS_TYPE_SYSTEM (see gioenums.h)
-#define PERSISTENCE_ADMIN_TF_BUS_NAME "org.genivi.persistence.admintestframework"
-#define PERSISTENCE_ADMIN_TF_OBJ_PATH "/org/genivi/persistence/admintestframework"
-#define PERSISTENCE_ADMIN_TF_IFACE "org.genivi.persistence.admintestframework"
#define MAX_PATH_SIZE ( 256 )
#define MAX_APPLICATION_NAME_SIZE ( 64 )
diff --git a/test/pers_svc_test/src/test_PAS.c b/test/pers_svc_test/src/test_PAS.c
index f385164..37e7997 100755
--- a/test/pers_svc_test/src/test_PAS.c
+++ b/test/pers_svc_test/src/test_PAS.c
@@ -41,7 +41,6 @@
#include "persComRct.h"
#include "ssw_pers_admin_files_helper.h"
-#include "ssw_pers_admin_dbus.h"
#include "persistence_admin_service.h"
@@ -1954,8 +1953,6 @@ int main(void)
//sprintf(g_msg, "\n\n++++++++++ Test PAS - FINISH ++++++++++++++++\n\n") ;
DLT_LOG(testPersAdminDLTCtx, DLT_LOG_INFO, DLT_STRING(LT_HDR), DLT_STRING("++++++++++ Test PAS - FINISH ++++++++++++++++"));
- /* Init and run the main DBus loop */
- persadmin_RunDBusMainLoop();
return 1 ;
}
diff --git a/test/pers_svc_test/src/test_PAS_dbus.c b/test/pers_svc_test/src/test_PAS_dbus.c
deleted file mode 100644
index 550ca76..0000000
--- a/test/pers_svc_test/src/test_PAS_dbus.c
+++ /dev/null
@@ -1,233 +0,0 @@
-/*********************************************************************************************************************
-*
-* Copyright (C) 2012 Continental Automotive Systems, Inc.
-*
-* Author: Petrica.Manoila@continental-corporation.com
-*
-* Implementation of backup process
-*
-* This Source Code Form is subject to the terms of the Mozilla Public
-* License, v. 2.0. If a copy of the MPL was not distributed with this
-* file, You can obtain one at http://mozilla.org/MPL/2.0/.
-*
-* Date Author Reason
-* 2012.11.27 uidu0250 CSP_WZ#1280: Initial version
-*
-**********************************************************************************************************************/
-
-#include "stdio.h"
-#include <stdlib.h>
-#include <string.h>
-#include <gio/gio.h>
-#include <pthread.h>
-
-#include "test_PAS.h"
-#include "PasModuleTestGen.h"
-
-
-
-/**********************************************************************************************************************
-*
-* Global variables. Initialization of global contexts.
-*
-**********************************************************************************************************************/
-static GMainLoop *g_pMainLoop = NULL;
-static GDBusConnection *g_pBusConnection = NULL;
-static OipPersistenceAdmintestframeworkSkeleton *g_pTFSkeleton = NULL;
-static volatile bool_t g_bDBusConnInit = false;
-
-static pthread_mutex_t testOpMtx; // run test cases - operation mutex
-
-
-
-/**********************************************************************************************************************
-*
-* Prototypes for local functions (see implementation for description)
-*
-**********************************************************************************************************************/
-
-static void OnBusAcquired_cb(GDBusConnection *pConnection, const gchar* sName, gpointer pUserData);
-static void OnNameAcquired_cb(GDBusConnection *pConnection, const gchar* sName, gpointer pUserData);
-static void OnNameLost_cb(GDBusConnection *pConnection, const gchar* sName, gpointer pUserData);
-
-/* ExecuteTestCases */
-static gboolean OnHandleExecuteTestCases ( OipPersistenceAdmintestframework *object,
- GDBusMethodInvocation *invocation);
-
-
-
-/**********************************************************************************************************************
-*
-* The function is called when a connection to the D-Bus could be established.
-* According to the documentation the objects should be exported here.
-*
-* @param pConnection: Connection, which was acquired
-* @param sName: Bus name
-* @param pUserData: Optionally user data
-*
-* @return void
-*
-**********************************************************************************************************************/
-static void OnBusAcquired_cb(GDBusConnection *pConnection, const gchar* sName, gpointer pUserData)
-{
- GError *pError = NULL;
-
- /* Store the connection. */
- g_pBusConnection = pConnection;
-
- /* Create real object to offer on the DBus */
- g_pTFSkeleton = (OipPersistenceAdmintestframeworkSkeleton*) oip_persistence_admintestframework_skeleton_new();
-
- g_signal_connect(g_pTFSkeleton, "handle-execute-test-cases", G_CALLBACK(OnHandleExecuteTestCases), pUserData);
-
- /* Attach interfaces to the objects and export them */
- if(TRUE == g_dbus_interface_skeleton_export( G_DBUS_INTERFACE_SKELETON(g_pTFSkeleton),
- g_pBusConnection,
- PERSISTENCE_ADMIN_TF_OBJ_PATH,
- &pError))
- {
- printf("Successfully connected to D-Bus and exported object.\n");
- }
- else
- {
- /* Error: the PersistenceAdminService TF interface could not be exported. */
- printf("Failed to export PersistenceAdminService TF object.\n");
- g_main_loop_quit(g_pMainLoop);
- }
- fflush(stdout);
-}
-
-
-
-/**********************************************************************************************************************
-*
-* The function is called when the "bus name" could be acquired on the D-Bus.
-*
-* @param pConnection: Connection over which the bus name was acquired
-* @param sName: Acquired bus name
-* @param pUserData: Optionally user data
-*
-* @return void
-*
-**********************************************************************************************************************/
-static void OnNameAcquired_cb(GDBusConnection *pConnection, const gchar* sName, gpointer pUserData)
-{
- printf("Successfully obtained D-Bus name: %s\n", sName);
-
- /* DBus connection initialized */
- g_bDBusConnInit = true;
-
- fflush(stdout);
-}
-
-
-
-/**********************************************************************************************************************
-*
-* The function is called if either no connection to D-Bus could be established or
-* the bus name could not be acquired.
-*
-* @param pConnection: Connection. If it is NULL, no D-Bus connection could be established.
-* Otherwise the bus name was lost.
-* @param sName: Bus name
-* @param pUserData: Optionally user data
-*
-* @return void
-*
-**********************************************************************************************************************/
-static void OnNameLost_cb(GDBusConnection *pConnection, const gchar* sName, gpointer pUserData)
-{
- if(pConnection == NULL)
- {
- /* Error: the connection could not be established. */
- printf("Failed to establish D-Bus connection.");
- }
- else
- {
- /* Error: connection established, but name not obtained. This might be a second instance of the application */
- printf("Failed to obtain bus name %s\n", sName);
- }
- fflush(stdout);
-
- /* In both cases leave the main loop. */
- g_main_loop_quit(g_pMainLoop);
-}
-
-
-
-/**********************************************************************************************************************
-*
-* Handler for ExecuteTestCases.
-* Signature based on generated code.
-*
-**********************************************************************************************************************/
-static gboolean OnHandleExecuteTestCases ( OipPersistenceAdmintestframework *object,
- GDBusMethodInvocation *invocation)
-{
- sint_t noOfTestCases = 0;
- sint_t noOfTestCasesSuccessful = 0;
- sint_t noOfTestCasesFailed = 0;
-
- // Acquire op mutex
- pthread_mutex_lock (&testOpMtx);
-
- ExecuteTestCases( &noOfTestCases,
- &noOfTestCasesSuccessful,
- &noOfTestCasesFailed );
-
- // Release list mutex
- pthread_mutex_unlock (&testOpMtx);
-
- oip_persistence_admintestframework_complete_execute_test_cases( object,
- invocation,
- noOfTestCases,
- noOfTestCasesSuccessful,
- noOfTestCasesFailed);
-
- return(TRUE);
-}
-
-
-/**********************************************************************************************************************
-*
-* Initialize DBus registration mechanism
-*
-**********************************************************************************************************************/
-void persadmin_RunDBusMainLoop()
-{
- uint u32ConnectionId = 0;
-
- /* Initialize glib */
- g_type_init();
-
- /* Init synchronization objects */
- pthread_mutex_init (&testOpMtx, NULL);
-
- /* Create the main loop */
- g_pMainLoop = g_main_loop_new(NULL, FALSE);
-
-
- /* Connect to the D-Bus. Obtain a bus name to offer PAS objects */
- u32ConnectionId = g_bus_own_name( PERSISTENCE_ADMIN_TF_BUS_TYPE
- , PERSISTENCE_ADMIN_TF_BUS_NAME
- , G_BUS_NAME_OWNER_FLAGS_NONE
- , &OnBusAcquired_cb
- , &OnNameAcquired_cb
- , &OnNameLost_cb
- , NULL
- , NULL);
-
- /* The main loop is only canceled if the Node is completely shut down or the D-Bus connection fails */
- g_main_loop_run(g_pMainLoop);
-
- /* If the main loop returned, clean up. Release bus name and main loop */
- g_bus_unown_name(u32ConnectionId);
- g_main_loop_unref(g_pMainLoop);
-
-
- /* Release the (created) skeleton object */
- if(NULL != g_pTFSkeleton)
- {
- g_object_unref(g_pTFSkeleton);
- }
-}