Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OB3] [Accelerator] Fix issues in Realtime Notification #170

Closed
wants to merge 94 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
e055a7f
Improvement to Idempotency validation with extending capability
Ashi1993 Mar 22, 2024
00385c8
Improvement to Idempotency validation with extending capability
Ashi1993 Mar 22, 2024
eb45d2a
Improvement to Idempotency validation with extending capability
Ashi1993 Mar 25, 2024
e120569
Fixed review comments
Ashi1993 Mar 25, 2024
6b7b503
Fixed review comments
Ashi1993 Mar 25, 2024
473c6a6
Fixed review comments
Ashi1993 Mar 25, 2024
a4a8132
Fixed review comments
Ashi1993 Mar 25, 2024
0a8b134
Fixed review comments
Ashi1993 Mar 26, 2024
910e968
Fixed review comments
Ashi1993 Mar 26, 2024
872101f
Changing parent pom version to support jenkins releases
Ashi1993 Mar 26, 2024
bd0da2b
Changing parent pom version to support jenkins releases
Ashi1993 Mar 26, 2024
f440bda
Removing existing implementation
Ashi1993 Aug 22, 2024
0f16dff
Removing existing implementation
Ashi1993 Aug 22, 2024
4f27aa2
Merge pull request #105 from Ashi1993/mian-clone
RivinduM Aug 22, 2024
18c1762
Modifying root and module poms, module names and removing BI accelera…
Ashi1993 Aug 22, 2024
3f367da
Modifying root and module poms, module names and removing BI accelera…
Ashi1993 Aug 22, 2024
124b590
Modifying root and module poms, module names and removing BI accelera…
Ashi1993 Aug 22, 2024
105802d
Modifying root and module poms, module names and removing BI accelera…
Ashi1993 Aug 22, 2024
a6adad8
Merge pull request #106 from Ashi1993/OB4-common
hasithakn Aug 26, 2024
419a6ec
Adding Common Module Implementation
Ashi1993 Aug 27, 2024
961375f
Merge remote-tracking branch 'upstream/main' into OB4-common
Ashi1993 Aug 27, 2024
6e29685
Adding Common Module Implementation
Ashi1993 Aug 27, 2024
c4c384e
Adding Common Module Implementation
Ashi1993 Aug 27, 2024
e07b2e6
Adding Common Module Implementation
Ashi1993 Aug 27, 2024
434d1c8
Changing action build to java 11
Ashi1993 Aug 27, 2024
5a9cfd3
Adding Consent Implementation
Ashi1993 Sep 6, 2024
e989b60
Adding common implementation
Ashi1993 Sep 6, 2024
3c3d082
Adding consent implementation
Ashi1993 Sep 6, 2024
d416913
Adding common implementation
Ashi1993 Sep 6, 2024
b5c2175
Adding Identity extensions implementation
Ashi1993 Sep 9, 2024
cc9c4b8
Fix review comments
Ashi1993 Sep 9, 2024
fa83d03
Adding Identity Extensions Implementation
Ashi1993 Sep 9, 2024
ac613d1
Merge pull request #107 from Ashi1993/OB4-common
aka4rKO Sep 9, 2024
c21f459
Adding Identity Extensions Implementation
Ashi1993 Sep 9, 2024
fa0db59
Adding Webapp Implementation
Ashi1993 Sep 9, 2024
a48e448
[Accelerator 4] Adding Consent Management Implementation (#108)
Ashi1993 Sep 9, 2024
71d678a
Merge remote-tracking branch 'upstream/main' into test
Ashi1993 Sep 9, 2024
81c4f1a
Fixed review comments
Ashi1993 Sep 9, 2024
6948597
Adding identity implementation
Ashi1993 Sep 9, 2024
c99bab8
Merge remote-tracking branch 'upstream/main' into OB4-common
Ashi1993 Sep 9, 2024
d872fa9
Adding Webapp implementation
Ashi1993 Sep 9, 2024
c8dc488
Fixing review comments
Ashi1993 Sep 10, 2024
4f56d91
Fixing review comments
Ashi1993 Sep 10, 2024
113119a
Fixing review comments
Ashi1993 Sep 10, 2024
fe1e2b6
Fixing review comments
Ashi1993 Sep 10, 2024
5cb938e
Fixing review comments
Ashi1993 Sep 10, 2024
33337e1
Fixing review comments
Ashi1993 Sep 10, 2024
4f0b58b
Merge pull request #110 from Ashi1993/common
hasithakn Sep 10, 2024
651f8d5
Merge remote-tracking branch 'upstream/main' into test
Ashi1993 Sep 10, 2024
51e7cc3
Fixing review comments
Ashi1993 Sep 10, 2024
3a6f400
Fixing Osgi issues
Ashi1993 Sep 10, 2024
32f9970
Fixing Osgi issues
Ashi1993 Sep 10, 2024
39d8819
Update financial-services-accelerator/components/org.wso2.financial.s…
Ashi1993 Sep 11, 2024
8af72c7
Update financial-services-accelerator/components/org.wso2.financial.s…
Ashi1993 Sep 11, 2024
89fe5db
Fixing review comments
Ashi1993 Sep 11, 2024
9039e28
Merge pull request #109 from Ashi1993/test
RivinduM Sep 11, 2024
2b31858
Moving webapp implementations to a new folder
Ashi1993 Sep 25, 2024
75d5bf8
Merge pull request #124 from Ashi1993/test
hasithakn Sep 25, 2024
6d90d31
Adding Accelerator Gateway Implemntation
Ashi1993 Sep 26, 2024
e60e892
Modifying AM and IAM accelerator modules
Ashi1993 Sep 26, 2024
22af387
Renaming AM and IAM accelerator modules (#125)
Ashi1993 Sep 26, 2024
f25a66a
MOdifying AM and IAM accelerator modules
Ashi1993 Sep 27, 2024
1ad1816
Merge remote-tracking branch 'upstream/main' into configs
Ashi1993 Sep 27, 2024
b8e4184
Modifying AM and IAM accelerator modules
Ashi1993 Sep 27, 2024
bc89bd3
Modifying AM and IAM accelerator modules
Ashi1993 Sep 27, 2024
52338b8
Merge remote-tracking branch 'upstream/main' into gateway
Ashi1993 Sep 27, 2024
ccaa8bc
Merge pull request #126 from Ashi1993/configs
anjuchamantha Sep 30, 2024
43090a2
Adding gateway implementation
Ashi1993 Sep 30, 2024
e1c7fe0
Merge remote-tracking branch 'upstream/main' into gateway
Ashi1993 Sep 30, 2024
66dcc1b
Adding gateway implementation
Ashi1993 Sep 30, 2024
a79ad69
Adding unit tests
Ashi1993 Sep 30, 2024
118d0f4
Fixed review comments
Ashi1993 Oct 1, 2024
0a65db6
Merge pull request #127 from Ashi1993/gateway
aka4rKO Oct 2, 2024
6e9691a
Updating configuration and accelerators to support APIM 4.4 and IS 7.0
Ashi1993 Oct 2, 2024
4b6ddfc
Merge remote-tracking branch 'upstream/main' into configs
Ashi1993 Oct 2, 2024
8bf54bf
Updating configuration and accelerators to support APIM 4.4 and IS 7.0
Ashi1993 Oct 2, 2024
e4cf97b
Adding configs
Ashi1993 Oct 8, 2024
88cafc4
Adding configs
Ashi1993 Oct 8, 2024
99ad165
Adding configs
Ashi1993 Oct 9, 2024
82194da
Adding configs
Ashi1993 Oct 9, 2024
a580405
Merge pull request #129 from Ashi1993/configs
Akila94 Oct 11, 2024
1053789
Adding Event notification implementation
Ashi1993 Oct 24, 2024
b74b5f0
Adding Event creation, polling and subscription implementation
Ashi1993 Oct 27, 2024
867c2d6
Merge remote-tracking branch 'origin/event' into event
Ashi1993 Oct 27, 2024
358e98b
Removing conflicts
Ashi1993 Oct 27, 2024
339d87d
Fix unit test coverage issue
Ashi1993 Oct 28, 2024
edd1e17
Fixing build issue
Ashi1993 Oct 28, 2024
f37a27e
Fix osgi issues
Ashi1993 Oct 29, 2024
14b8de9
Adding event notification implementation
Ashi1993 Oct 31, 2024
05b0bdb
Adding realtime event notification implementation
Ashi1993 Oct 31, 2024
24d8b34
Fix issues in realtime notification
Ashi1993 Nov 1, 2024
74cd6aa
Fixed review comment
Ashi1993 Nov 1, 2024
605849f
Adding realtime event notification implementation
Ashi1993 Nov 4, 2024
a18ae9e
Merge remote-tracking branch 'origin/realtime' into realtime
Ashi1993 Nov 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
11 changes: 6 additions & 5 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com).
# Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
#
# WSO2 LLC. licenses this file to you under the Apache License,
# Version 2.0 (the "License"); you may not use this file except
Expand All @@ -14,7 +14,7 @@
# specific language governing permissions and limitations
# under the License.

name: Build Open Banking Repository
name: Build Financial Services Repository

on:
# Triggers the workflow on push or pull request events
Expand All @@ -30,10 +30,11 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Set up JDK 8
uses: actions/setup-java@v1
- name: Set up Adopt JDK 11
uses: actions/setup-java@v2
with:
java-version: 8
java-version: 11.0.16+8
distribution: 'temurin'
- uses: actions/checkout@v3
- name: Set up Node 16
uses: actions/setup-node@v3
Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,11 @@ plugins/ios.json
www/
$RECYCLE.BIN/
node_modules/

**/webapps

#mac
.DS_Store


# React dashboard ignore
.DS_STORE
**/node_modules/
Expand Down
27 changes: 27 additions & 0 deletions financial-services-accelerator/accelerators/fs-apim/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
### **WSO2 Financial Services APIM Accelerator 4.0.0**

**Try Locally:**

Prerequisites:
1. [Download](https://wso2.com/api-manager/#) the WSO2 API Manager product
2. Build the repository completely using the below command to create accelerator zip files.
<code>mvn clean install -P Solution</code>
3. Locate the Accelerator Zip file (wso2-fsam-accelerator-4.0.0.zip) from
the <code>target</code> folder in this directory
4. Setup MySQL database server
5. Install Java on your local machine

Below are the simplified steps to install the WSO2 Financial Services Accelerator. For more information,
please refer to [Quick Start Guide](https://ob.docs.wso2.com/en/latest/get-started/quick-start-guide/) or
to [ Complete install and Setup Guide ](https://ob.docs.wso2.com/en/latest/install-and-setup/)

Steps:
1. Extract the Base product (WSO2 API Manager product) to a preferred location (<WSO2_APIM_HOME>)
2. Extract WSO2 FS APIM Accelerator (wso2-fsam-accelerator-4.0.0.zip) to WSO2_APIM_HOME
3. Run <WSO2_FS_APIM_ACC_HOME>/bin/merge.sh. This will copy/install the Financial Services artifacts to
the WSO2 API Manager product
4. Run <WSO2_FS_APIM_ACC_HOME>/bin/configure.sh. This will configure the server and create databases and tables.
5. Run <WSO2_APIM_HOME>/bin/wso2server.sh to start the server.



251 changes: 251 additions & 0 deletions financial-services-accelerator/accelerators/fs-apim/bin/configure.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,251 @@
# Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
#
# WSO2 LLC. licenses this file to you under the Apache License,
# Version 2.0 (the "License"); you may not use this file except
# in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

# How to execute :
# If your accelerator is located inside of the base product you can just call .\configure.ps1
# If your accelerator is in a different location you can call .\configure.ps1 <YOUR_BASE_PRODUCT_HOME_DIR>

# IMPORTANT :
# Please note that these powershell files are not digitally signed yet. So, powershell will not allow these scripts under any of their execution policies.
# You may need to run these scripts on an execution policy bypassed powershell instance. You can do that using the following command.
# powershell.exe -executionpolicy bypass <SCRIPT_FILEPATH>

# Get the current working directory of the powershell session, so we can set to this directory after the script finishes.
$CURRENT_DIRECTORY = (Get-Location).path

# Some black magic to get the fully qualified path of the WSO2 Base Product if it was given as an argument.
$WSO2_BASE_PRODUCT_HOME = $args[0]
if (-NOT($null -eq $WSO2_BASE_PRODUCT_HOME)) {
if (Test-Path $WSO2_BASE_PRODUCT_HOME) {
Set-Location $WSO2_BASE_PRODUCT_HOME
$WSO2_BASE_PRODUCT_HOME = (Get-Location).path
Set-Location $CURRENT_DIRECTORY
}
}

Function Exit-Clean {
Set-Location $CURRENT_DIRECTORY
exit 1
}

# A utility function to Find and Replace texts in a file.
Function Find-Replace {
param(
[string]$FILE_PATH,
[string]$OLD_TEXT,
[string]$NEW_TEXT
)

# Read the file content
$CONTENT = Get-Content $FILE_PATH -Raw

# Escape special characters in OLD_TEXT for the regex
$escapedOldText = [regex]::Escape($OLD_TEXT)

# Define the regex pattern to consider non-word characters as boundaries
$regex = "(?<![a-zA-Z0-9_])" + $escapedOldText + "(?![a-zA-Z0-9_])"

# Replace the whole words
$NEW_CONTENT = [regex]::Replace($CONTENT, $regex, $NEW_TEXT)

# Write the new content back to the file
$NEW_CONTENT | Set-Content $FILE_PATH
}


# Get the root directory location of the accelerator. Which is <BASE_PRODUCT>/<ACCELERATOR>/
Set-Location (Join-Path $PSScriptRoot ".\..\")
$WSO2_FS_ACCELERATOR_HOME = (Get-Location).path
Write-Output "[INFO] Accelerator Home : $WSO2_FS_ACCELERATOR_HOME"

# Get the root directory of the base product.
if ($null -eq $WSO2_BASE_PRODUCT_HOME) {
Set-Location (Join-Path $WSO2_FS_ACCELERATOR_HOME ".\..\")
$WSO2_BASE_PRODUCT_HOME = (Get-Location).path
}
Write-Output "[INFO] Base Product Home : $WSO2_BASE_PRODUCT_HOME"

# Check whether the extracted base product location contains a valid WSO2 carbon product by checking whether this location
# contains the "repository/components" directory.
if (-NOT(Test-Path (Join-Path $WSO2_BASE_PRODUCT_HOME "repository\components"))) {
Write-Output "[ERROR] $WSO2_BASE_PRODUCT_HOME does NOT contain a valid carbon product!"
# The current path does not contain a valid carbon product.
# Set the current working directory to the original location and exit.
Exit-Clean
} else {
Write-Output "[INFO] $WSO2_BASE_PRODUCT_HOME is a valid carbon product home."
}

# Get the location of the configure.properties
$CONFIG_PROPERTIES_PATH = Join-Path $WSO2_FS_ACCELERATOR_HOME "repository\conf\configure.properties"
Write-Output "[INFO] configure.properties location : $CONFIG_PROPERTIES_PATH"

# Load the variables in the configure.properties file
$PROPERTIES = ConvertFrom-StringData (Get-Content $CONFIG_PROPERTIES_PATH -raw)

$SELECTED_DEPLOYMENT_TOML_FILE = Join-Path $WSO2_FS_ACCELERATOR_HOME $PROPERTIES.'PRODUCT_CONF_PATH'
Write-Output "[INFO] Selected deployment.toml location : $SELECTED_DEPLOYMENT_TOML_FILE"

$DEPLOYMENT_TOML_FILE = Join-Path $WSO2_FS_ACCELERATOR_HOME "repository\resources\deployment.toml"
# Temporary copy the selected toml file so we can make changes to it.
Copy-Item -Path $SELECTED_DEPLOYMENT_TOML_FILE $DEPLOYMENT_TOML_FILE
Write-Output "[INFO] Temporary deployment.toml location : $DEPLOYMENT_TOML_FILE"

# A function to replace the database related variables in the temp deployment.toml with their actual values from configure.properties
Function Set-Datasources
{
if ($PROPERTIES.'DB_TYPE' -eq "mysql")
{
# MySQL
Find-Replace $DEPLOYMENT_TOML_FILE "DB_APIMGT_URL" "jdbc:mysql://$( $PROPERTIES.'DB_HOST' ):3306/$( $PROPERTIES.'DB_APIMGT' )?allowPublicKeyRetrieval=true&amp;autoReconnect=true&amp;useSSL=false"
Find-Replace $DEPLOYMENT_TOML_FILE "DB_AM_CONFIG_URL" "jdbc:mysql://$( $PROPERTIES.'DB_HOST' ):3306/$( $PROPERTIES.'DB_AM_CONFIG' )?allowPublicKeyRetrieval=true&amp;autoReconnect=true&amp;useSSL=false"
Find-Replace $DEPLOYMENT_TOML_FILE "DB_GOV_URL" "jdbc:mysql://$( $PROPERTIES.'DB_HOST' ):3306/$( $PROPERTIES.'DB_GOV' )?allowPublicKeyRetrieval=true&amp;autoReconnect=true&amp;useSSL=false"
Find-Replace $DEPLOYMENT_TOML_FILE "DB_USER_STORE_URL" "jdbc:mysql://$( $PROPERTIES.'DB_HOST' ):3306/$( $PROPERTIES.'DB_USER_STORE' )?allowPublicKeyRetrieval=true&amp;autoReconnect=true&amp;useSSL=false"
Find-Replace $DEPLOYMENT_TOML_FILE "DB_USER" "$( $PROPERTIES.'DB_USER' )"
Find-Replace $DEPLOYMENT_TOML_FILE "DB_PASS" "$( $PROPERTIES.'DB_PASS' )"
Find-Replace $DEPLOYMENT_TOML_FILE "DB_DRIVER" "$( $PROPERTIES.'DB_DRIVER' )"
}
elseif($PROPERTIES.'DB_TYPE' -eq "mssql")
{
# Microsoft SQL Server
Find-Replace $DEPLOYMENT_TOML_FILE "DB_APIMGT_URL" "jdbc:sqlserver://$( $PROPERTIES.'DB_HOST' ):1433;databaseName=$( $PROPERTIES.'DB_APIMGT' );encrypt=false"
Find-Replace $DEPLOYMENT_TOML_FILE "DB_AM_CONFIG_URL" "jdbc:sqlserver://$( $PROPERTIES.'DB_HOST' ):1433;databaseName=$( $PROPERTIES.'DB_AM_CONFIG' );encrypt=false"
Find-Replace $DEPLOYMENT_TOML_FILE "DB_GOV_URL" "jdbc:sqlserver://$( $PROPERTIES.'DB_HOST' ):1433;databaseName=$( $PROPERTIES.'DB_GOV' );encrypt=false"
Find-Replace $DEPLOYMENT_TOML_FILE "DB_USER_STORE_URL" "jdbc:sqlserver://$( $PROPERTIES.'DB_HOST' ):1433;databaseName=$( $PROPERTIES.'DB_USER_STORE' );encrypt=false"
Find-Replace $DEPLOYMENT_TOML_FILE "DB_USER" "$( $PROPERTIES.'DB_USER' )"
Find-Replace $DEPLOYMENT_TOML_FILE "DB_PASS" "$( $PROPERTIES.'DB_PASS' )"
Find-Replace $DEPLOYMENT_TOML_FILE "DB_DRIVER" "$( $PROPERTIES.'DB_DRIVER' )"
}
else {
Write-Output "[ERROR] Unsupported Database Type!"
Exit-Clean
}
}

# A function to replace the hostname related variables in the temp deployment.toml with their actual values from configure.properties
Function Set-Hostnames {
Find-Replace $DEPLOYMENT_TOML_FILE "APIM_HOSTNAME" "$( $PROPERTIES.'APIM_HOSTNAME' )"
Find-Replace $DEPLOYMENT_TOML_FILE "IS_HOSTNAME" "$( $PROPERTIES.'IS_HOSTNAME' )"
}

# A utility function to create a database.
Function Add-Database {
param ([string]$DB_USER, [string]$DB_PASS, [string]$DB_HOST, [string]$DB_NAME)
mysql -u"$($DB_USER)" -p"$($DB_PASS)" -h"$($DB_HOST)" -e "DROP DATABASE IF EXISTS $($DB_NAME); CREATE DATABASE $( $DB_NAME ) DEFAULT CHARACTER SET latin1;"
}

# A utility function to create a table inside a given database.
Function Add-TablesToDatabase {
param ([string]$DB_USER, [string]$DB_PASS, [string]$DB_HOST, [string]$DB_NAME, [string]$DB_SOURCE)
mysql -u"$($DB_USER)" -p"$($DB_PASS)" -h"$($DB_HOST)" -D"$($DB_NAME)" -e "SOURCE $($DB_SOURCE)"
}

# A function to create the databases. ONLY SUPPORTED FOR THE MYSQL
Function Add-Databases {
if ($PROPERTIES.'DB_TYPE' -eq "mysql") {
$DB_MYSQL_PASS = ""
if (-NOT($PROPERTIES.'DB_PASS' -eq "")) {
$DB_MYSQL_PASS = $PROPERTIES.'DB_PASS'
}

Add-Database "$( $PROPERTIES.'DB_USER' )" $DB_MYSQL_PASS "$( $PROPERTIES.'DB_HOST' )" "$( $PROPERTIES.'DB_APIMGT' )"
Write-Output "[INFO] Database Created: $( $PROPERTIES.'DB_APIMGT' )"

Add-Database "$( $PROPERTIES.'DB_USER' )" $DB_MYSQL_PASS "$( $PROPERTIES.'DB_HOST' )" "$( $PROPERTIES.'DB_AM_CONFIG' )"
Write-Output "[INFO] Database Created: $( $PROPERTIES.'DB_AM_CONFIG' )"

Add-Database "$( $PROPERTIES.'DB_USER' )" $DB_MYSQL_PASS "$( $PROPERTIES.'DB_HOST' )" "$( $PROPERTIES.'DB_GOV' )"
Write-Output "[INFO] Database Created: $( $PROPERTIES.'DB_GOV' )"

Add-Database "$( $PROPERTIES.'DB_USER' )" $DB_MYSQL_PASS "$( $PROPERTIES.'DB_HOST' )" "$( $PROPERTIES.'DB_USER_STORE' )"
Write-Output "[INFO] Database Created: $( $PROPERTIES.'DB_USER_STORE' )"
}
else {
Write-Output "[INFO] The databases must be created manually for non mysql DBMSs."
}
}

# A function to create the database tables. ONLY SUPPORTED FOR THE MYSQL
Function Add-DatabaseTables {
if ($PROPERTIES.'DB_TYPE' -eq "mysql") {

Write-Output "[NOTE] Update am_application_registration table input field size (temporary)"
Find-Replace (Join-Path $WSO2_BASE_PRODUCT_HOME "dbscripts\apimgt\mysql.sql") "INPUTS VARCHAR(1000)," "INPUTS VARCHAR(7500),"

$DB_MYSQL_PASS = ""
if (-NOT($PROPERTIES.'DB_PASS' -eq "")) {
$DB_MYSQL_PASS = $PROPERTIES.'DB_PASS'
}

Add-TablesToDatabase "$( $PROPERTIES.'DB_USER' )" $DB_MYSQL_PASS "$( $PROPERTIES.'DB_HOST' )" "$( $PROPERTIES.'DB_APIMGT' )" "$(Join-Path $WSO2_BASE_PRODUCT_HOME "dbscripts\apimgt\mysql.sql")"
Write-Output "[NOTE] Database tables Created for: $( $PROPERTIES.'DB_APIMGT' )"

Add-TablesToDatabase "$( $PROPERTIES.'DB_USER' )" $DB_MYSQL_PASS "$( $PROPERTIES.'DB_HOST' )" "$( $PROPERTIES.'DB_AM_CONFIG' )" "$(Join-Path $WSO2_BASE_PRODUCT_HOME "dbscripts\mysql.sql")"
Write-Output "[NOTE] Database tables Created for: $( $PROPERTIES.'DB_AM_CONFIG' )"

Add-TablesToDatabase "$( $PROPERTIES.'DB_USER' )" $DB_MYSQL_PASS "$( $PROPERTIES.'DB_HOST' )" "$( $PROPERTIES.'DB_GOV' )" "$(Join-Path $WSO2_BASE_PRODUCT_HOME "dbscripts\mysql.sql")"
Write-Output "[NOTE] Database tables Created for: $( $PROPERTIES.'DB_GOV' )"

Add-TablesToDatabase "$( $PROPERTIES.'DB_USER' )" $DB_MYSQL_PASS "$( $PROPERTIES.'DB_HOST' )" "$( $PROPERTIES.'DB_USER_STORE' )" "$(Join-Path $WSO2_BASE_PRODUCT_HOME "dbscripts\mysql.sql")"
Write-Output "[NOTE] Database tables Created for: $( $PROPERTIES.'DB_USER_STORE' )"

mysql -u"$( $PROPERTIES.'DB_USER' )" -p"$DB_MYSQL_PASS" -h"$( $PROPERTIES.'DB_HOST' )" -e "ALTER TABLE $( $PROPERTIES.'DB_APIMGT' ).SP_METADATA MODIFY VALUE VARCHAR(4096);"
}
else {
Write-Output "[INFO] The database tables must be created manually for non mysql DBMSs."
Find-Replace (Join-Path $WSO2_BASE_PRODUCT_HOME "dbscripts\apimgt\mssql.sql") "FOREIGN KEY (CONSUMER_KEY_ID) REFERENCES IDN_OAUTH_CONSUMER_APPS(ID) ON DELETE CASCADE ," "FOREIGN KEY (CONSUMER_KEY_ID) REFERENCES IDN_OAUTH_CONSUMER_APPS(ID),"
Find-Replace (Join-Path $WSO2_BASE_PRODUCT_HOME "dbscripts\apimgt\mssql.sql") "FOREIGN KEY (TOKEN_ID) REFERENCES IDN_OAUTH2_ACCESS_TOKEN(TOKEN_ID)," "FOREIGN KEY (TOKEN_ID) REFERENCES IDN_OAUTH2_ACCESS_TOKEN(TOKEN_ID) ON DELETE CASCADE,"
}
}

Function Add-JsonFaultSequence
{
Write-Output "[INFO] Adding JSON Fault Sequence..."
$CORS_REQ_HANDLER_PATH = (Join-Path $WSO2_BASE_PRODUCT_HOME "repository\deployment\server\synapse-configs\default\sequences\_cors_request_handler_.xml")
Find-Replace $CORS_REQ_HANDLER_PATH "</sequence>" "`t<sequence key=`"jsonConverter`"/>`n</sequence>"
Write-Output "[INFO] JSON Fault Sequence added!"
}

Write-Output "============================================"
Write-Output "[INFO] Configuring the hostnames..."
Set-Hostnames
Write-Output "[INFO] Hostnames configurations completed!"

Write-Output "============================================"
Write-Output "[INFO] Configuring the datasources..."
Set-Datasources
Write-Output "[INFO] Datasources configurations completed!"

Write-Output "============================================"
Copy-Item $DEPLOYMENT_TOML_FILE (Join-Path $WSO2_BASE_PRODUCT_HOME "repository\conf\deployment.toml")
Write-Output "[INFO] Copied temp toml to the $(Join-Path $WSO2_BASE_PRODUCT_HOME "repository\conf\deployment.toml")"

Remove-Item $DEPLOYMENT_TOML_FILE
Write-Output "[INFO] Deleted temp toml $DEPLOYMENT_TOML_FILE"

Write-Output "============================================"
Add-Databases

Write-Output "============================================"
Add-DatabaseTables

Write-Output "============================================"
Add-JsonFaultSequence

$DEFAULT_JSON_FILE_PATH = Join-Path $WSO2_BASE_PRODUCT_HOME "repository\resources\conf\default.json"
Find-Replace $DEFAULT_JSON_FILE_PATH "`"keystore.listener_profile.bind_address`": `"0.0.0.0`"" "`"keystore.listener_profile.bind_address`": `"0:0:0:0:0:0:0:0`""

Exit-Clean
Loading