@@ -70,53 +70,62 @@ Get-ChildItem (Join-Path $WSO2_BASE_PRODUCT_HOME "repository\components\dropins"
7070Get-ChildItem (Join-Path $WSO2_BASE_PRODUCT_HOME " repository\components\lib" ) | Where-Object {$_.Name -Match " org.wso2.financial.services.accelerator.*" } | Remove-Item
7171Write-Output " [INFO] All previous FS artifacts have been deleted!"
7272
73- # Copying all the new FS artifacts to the base product
74- # Copy-Item -Force -Recurse -Verbose (Join-Path $WSO2_ACCELERATOR_HOME "carbon-home\*") -Destination $WSO2_BASE_PRODUCT_HOME
75- # Using Robocopy.exe becuase powershell Copy-Item cmdlet doesn't do recursive copying after a certain number of subdirectories.
76- Write-Output " [INFO] Copying new financial services artifacts..."
77- Robocopy.exe (Join-Path $WSO2_ACCELERATOR_HOME " carbon-home" ) $WSO2_BASE_PRODUCT_HOME * / E / NFL / NDL / NJH / NJS / nc / ns / np
78- Write-Output " [INFO] All the new FS artifacts has been copied!"
79-
8073$WEB_APPS_PATH = (Join-Path $WSO2_BASE_PRODUCT_HOME " repository\deployment\server\webapps" )
8174
82- # Delete the consentmgr web app if it exists .
75+ # Backup and delete the existing consentmgr web app BEFORE copying new artifacts .
8376$CONSENTMGR_PATH = (Join-Path $WEB_APPS_PATH " consentmgr" )
8477$CONSENTMGR_RUNTIME_JS_PATH = (Join-Path $CONSENTMGR_PATH " runtime-config.js" )
8578$CONSENTMGR_RUNTIME_JS_BACKUP_PATH = (Join-Path $WEB_APPS_PATH " runtime-config.js" )
79+ $CONSENTMGR_CONFIG_DIR_PATH = (Join-Path $CONSENTMGR_PATH " WEB-INF\classes" )
80+ $CONSENTMGR_CONFIG_FILE_PATH = (Join-Path $CONSENTMGR_CONFIG_DIR_PATH " configurations.properties" )
81+ $CONSENTMGR_CONFIG_BACKUP_PATH = (Join-Path $WEB_APPS_PATH " configurations.properties" )
8682if (Test-Path $CONSENTMGR_PATH ) {
8783 Write-Output " [INFO] consentmgr web app detected at `" $CONSENTMGR_PATH `" "
88-
84+
8985 if (Test-Path $CONSENTMGR_RUNTIME_JS_PATH - PathType Leaf) {
90- # If the consentmgr/ runtime-config, js file exists, backup it to the webapps directory before deleting the directory
86+ # Backup runtime-config. js to webapps directory before deleting the consentmgr directory
9187 Write-Output " [INFO] Copying $CONSENTMGR_RUNTIME_JS_PATH to $CONSENTMGR_RUNTIME_JS_BACKUP_PATH ..."
9288 Copy-Item $CONSENTMGR_RUNTIME_JS_PATH - Destination $CONSENTMGR_RUNTIME_JS_BACKUP_PATH - Force
89+ Write-Output " [INFO] Backup of runtime-config.js complete!"
90+ }
91+
92+ if (Test-Path $CONSENTMGR_CONFIG_FILE_PATH - PathType Leaf) {
93+ # Backup configurations.properties to webapps directory before deleting the consentmgr directory
94+ Write-Output " [INFO] Copying $CONSENTMGR_CONFIG_FILE_PATH to $CONSENTMGR_CONFIG_BACKUP_PATH ..."
95+ Copy-Item $CONSENTMGR_CONFIG_FILE_PATH - Destination $CONSENTMGR_CONFIG_BACKUP_PATH - Force
96+ Write-Output " [INFO] Backup of configurations.properties complete!"
9397 }
9498
9599 Write-Output " [INFO] Deleting the current consentmgr web app..."
96100 Remove-Item - LiteralPath $CONSENTMGR_PATH - Force - Recurse
97101 Write-Output " [INFO] Deleted the current consentmgr web app!"
98102}
99103
100- $CONSENTMGR_PATH_WAR = (Join-Path $WEB_APPS_PATH " consentmgr.war" )
101- $CONSENTMGR_PATH_ZIP = (Join-Path $WEB_APPS_PATH " consentmgr.zip" )
102-
103- # Expand-Archive cmdlet cannot directly extract the .war files. Since .war files are just zip files with some custom file headers and a fancy extension
104- # we can just rename the war file and extract it.
105- Move-Item - Path $CONSENTMGR_PATH_WAR - Destination $CONSENTMGR_PATH_ZIP - Force
106-
107- # Extract the consentmgr.zip
108- Write-Output " [INFO] Extracting the new consentmgr..."
109- Expand-Archive - LiteralPath $CONSENTMGR_PATH_ZIP - DestinationPath $CONSENTMGR_PATH - Force
110- Write-Output " [INFO] New consentmgr extracted!"
104+ # Copying all the new FS artifacts to the base product (includes fresh consentmgr directory from carbon-home)
105+ # Copy-Item -Force -Recurse -Verbose (Join-Path $WSO2_ACCELERATOR_HOME "carbon-home\*") -Destination $WSO2_BASE_PRODUCT_HOME
106+ # Using Robocopy.exe becuase powershell Copy-Item cmdlet doesn't do recursive copying after a certain number of subdirectories.
107+ Write-Output " [INFO] Copying new financial services artifacts..."
108+ Robocopy.exe (Join-Path $WSO2_ACCELERATOR_HOME " carbon-home" ) $WSO2_BASE_PRODUCT_HOME * / E / NFL / NDL / NJH / NJS / nc / ns / np
109+ Write-Output " [INFO] All the new FS artifacts has been copied!"
111110
111+ # Restore backed up runtime-config.js into the newly copied consentmgr directory
112112if (Test-Path $CONSENTMGR_RUNTIME_JS_BACKUP_PATH - PathType Leaf) {
113- # Copy back the backed up runtime-config.js
114113 Write-Output " [INFO] Copying $CONSENTMGR_RUNTIME_JS_BACKUP_PATH to $CONSENTMGR_RUNTIME_JS_PATH ..."
115114 Copy-Item $CONSENTMGR_RUNTIME_JS_BACKUP_PATH - Destination $CONSENTMGR_RUNTIME_JS_PATH - Force
116115 Remove-Item - LiteralPath $CONSENTMGR_RUNTIME_JS_BACKUP_PATH - Force
116+ Write-Output " [INFO] Restoring backup runtime-config.js file complete!"
117117}
118118
119- Remove-Item - LiteralPath $CONSENTMGR_PATH_ZIP - Force
119+ # Restore backed up configurations.properties into the newly copied consentmgr directory
120+ if (Test-Path $CONSENTMGR_CONFIG_BACKUP_PATH - PathType Leaf) {
121+ Write-Output " [INFO] Copying $CONSENTMGR_CONFIG_BACKUP_PATH to $CONSENTMGR_CONFIG_FILE_PATH ..."
122+ if (-NOT (Test-Path $CONSENTMGR_CONFIG_DIR_PATH )) {
123+ New-Item - ItemType Directory - Path $CONSENTMGR_CONFIG_DIR_PATH - Force | Out-Null
124+ }
125+ Copy-Item $CONSENTMGR_CONFIG_BACKUP_PATH - Destination $CONSENTMGR_CONFIG_FILE_PATH - Force
126+ Remove-Item - LiteralPath $CONSENTMGR_CONFIG_BACKUP_PATH - Force
127+ Write-Output " [INFO] Restoring backup configurations.properties file complete!"
128+ }
120129
121130Write-Output " [INFO] Completed!"
122131
0 commit comments