Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

Commit

Permalink
Merge pull request #90 from easitab/development
Browse files Browse the repository at this point in the history
Merge development to main, new release 0.1.7
  • Loading branch information
easitab-owner authored May 25, 2021
2 parents 8d74a3e + 681f4a4 commit b84df4b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 32 deletions.
17 changes: 8 additions & 9 deletions source/public/Get-EMFConfig.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,25 @@ function Get-EMFConfig {
}

process {
Write-Verbose "Process block start"
if (Test-Path "$EMFHome\$ConfigurationFileName") {
Write-Verbose "Found $EMFHome\$ConfigurationFileName"
if (Test-Path "$EMFHome\$EmfConfigurationFileName") {
Write-Verbose "Found $EMFHome\$EmfConfigurationFileName"
} else {
throw [System.IO.FileNotFoundException] "$EMFHome\$ConfigurationFileName does not exist"
throw [System.IO.FileNotFoundException] "$EMFHome\$EmfConfigurationFileName does not exist"
}
Write-Verbose "Retrieving configurations data"
try {
$configurationFileData = Import-EMFXMLData -Path "$EMFHome\$ConfigurationFileName"
$configurationFileData = Import-EMFXMLData -Path "$EMFHome\$EmfConfigurationFileName"
Write-Verbose "Configuration data retrieved"
} catch {
throw $_
}
if ($configurationFileData.systems.$ConfigurationName) {
Write-Verbose "Found configuration named $ConfigurationName"
if ($configurationFileData.systems.$EmfConfigurationName) {
Write-Verbose "Found configuration named $EmfConfigurationName"
} else {
throw "No configuration found named $ConfigurationName"
throw "No configuration found named $EmfConfigurationName"
}
$returnObject = New-Object -TypeName psobject
$configProperties = $configurationFileData.systems.$ConfigurationName
$configProperties = $configurationFileData.systems.$EmfConfigurationName
foreach ($property in $configProperties.ChildNodes) {
$returnObject | Add-Member -MemberType NoteProperty -Name "$($property.Name)" -Value "$($property.InnerText)"
}
Expand Down
18 changes: 9 additions & 9 deletions source/public/New-EMFConfig.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ function New-EMFConfig {
}

process {
$emfConfigFilePath = "$EMFHome\$ConfigurationFileName"
$emfConfigFilePath = "$EMFHome\$EmfConfigurationFileName"
if (Test-Path "$emfConfigFilePath") {
Write-Verbose -Message "$emfConfigFilePath already exists."
try {
Get-EMFConfig -EMFHome $EMFHome -ConfigurationFileName $ConfigurationFileName -ConfigurationName $ConfigurationName
Write-Warning "A configuration with the name $ConfigurationName does already exist in $emfConfigFilePath. Use Set-EMFConfig to update configuration!"
Get-EMFConfig -EMFHome $EMFHome -EmfConfigurationFileName $EmfConfigurationFileName -EmfConfigurationName $EmfConfigurationName
Write-Warning "A configuration with the name $EmfConfigurationName does already exist in $emfConfigFilePath. Use Set-EMFConfig to update configuration!"
break
} catch {
Write-Verbose "No configuration with name $ConfigurationName found"
Write-Verbose "No configuration with name $EmfConfigurationName found"
}
} else {
Write-Verbose "$emfConfigFilePath does not exist."
Expand Down Expand Up @@ -67,17 +67,17 @@ function New-EMFConfig {
throw $_
}
try {
Write-Verbose "Creating xml element for $ConfigurationName"
$configObjectItem = $configObject.CreateElement("$ConfigurationName")
Write-Verbose "Creating xml element for $EmfConfigurationName"
$configObjectItem = $configObject.CreateElement("$EmfConfigurationName")
$configObjectItems.AppendChild($configObjectItem) | Out-Null
} catch {
Write-Verbose "Failed to create xml element for $ConfigurationName"
Write-Verbose "Failed to create xml element for $EmfConfigurationName"
throw $_
}
foreach ($setting in $ConfigurationSettings.GetEnumerator()) {
$settingName = $setting.Name
$settingValue = $setting.Value
if (!($settingName -eq 'ConfigurationName')) {
if (!($settingName -eq 'EmfConfigurationName')) {
try {
Write-Verbose "Creating xml element for setting $settingName"
$configObjectItemSetting = $configObject.CreateElement("$settingName")
Expand All @@ -88,7 +88,7 @@ function New-EMFConfig {
throw $_
}
} else {
Write-Verbose "SettingName = ConfigurationName"
Write-Verbose "SettingName = EmfConfigurationName"
}
}

Expand Down
28 changes: 14 additions & 14 deletions source/public/Set-EMFConfig.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ function Set-EMFConfig {
[string] $EasitRoot,

[Parameter(ParameterSetName='Manual')]
[string] $SystemRoot = "$EasitRoot\Systems\$ConfigurationName",
[string] $SystemRoot = "$EasitRoot\Systems\$EmfConfigurationName",

[Parameter(ParameterSetName='Manual')]
[string] $ServiceName = "Easit$ConfigurationName",
[string] $ServiceName = "Easit$EmfConfigurationName",

[Parameter(ParameterSetName='Manual')]
[string] $WarName = "ROOT",

[Parameter(ParameterSetName='Manual')]
[string] $TomcatRoot = "$EasitRoot\Systems\$ConfigurationName",
[string] $TomcatRoot = "$EasitRoot\Systems\$EmfConfigurationName",

[Parameter(ParameterSetName='Manual')]
[string] $BackupRoot = "$EasitRoot\_Backup\$ConfigurationName",
[string] $BackupRoot = "$EasitRoot\_Backup\$EmfConfigurationName",

[Parameter(ParameterSetName='Manual')]
[Alias('ER','EmailRequest','erRoot')]
Expand Down Expand Up @@ -58,16 +58,16 @@ function Set-EMFConfig {
}

process {
if (Test-Path "$EMFHome\$ConfigurationFileName") {
Write-Verbose "Located $EMFHome\$ConfigurationFileName"
if (Test-Path "$EMFHome\$EmfConfigurationFileName") {
Write-Verbose "Located $EMFHome\$EmfConfigurationFileName"
try {
$currentConfigSettings = Get-EMFConfig -EMFHome $EMFHome -ConfigurationFileName $ConfigurationFileName -ConfigurationName $ConfigurationName
$currentConfigSettings = Get-EMFConfig -EMFHome $EMFHome -EmfConfigurationFileName $EmfConfigurationFileName -EmfConfigurationName $EmfConfigurationName
Write-Verbose "Successfully retrieved configuration"
} catch {
throw $_
}
} else {
throw "Cannot find $EMFHome\$ConfigurationFileName"
throw "Cannot find $EMFHome\$EmfConfigurationFileName"
}
$paramName = $PSCmdlet.ParameterSetName
if ($paramName -eq 'Manual') {
Expand Down Expand Up @@ -111,13 +111,13 @@ function Set-EMFConfig {
}
try {
$currentConfigurationFile = New-Object System.Xml.XmlDocument
$currentConfigurationFile.Load("$EMFHome\$ConfigurationFileName")
$currentConfigurationFile.Load("$EMFHome\$EmfConfigurationFileName")
} catch {
Write-Verbose "Something went wrong while loading currentConfigurationFile"
throw "$($_.Exception.Message)"
}
if (!($currentConfigurationFile.systems.${ConfigurationName})) {
Write-Warning "Unable to find configuration block for $ConfigurationName"
if (!($currentConfigurationFile.systems.${EmfConfigurationName})) {
Write-Warning "Unable to find configuration block for $EmfConfigurationName"
return
}
if ($ValidateSettings) {
Expand All @@ -127,16 +127,16 @@ function Set-EMFConfig {
$configurationSettings.GetEnumerator() | ForEach-Object {
$settingName = "$($_.Key)"
$settingValue = "$($_.Value)"
$currentConfigurationFile.systems.${ConfigurationName}.${settingName} = $settingValue
$currentConfigurationFile.systems.${EmfConfigurationName}.${settingName} = $settingValue
}
} catch {
Write-Warning "$($_.Exception.Message)"
}

try {
$currentConfigurationFile.Save("$EMFHome\$ConfigurationFileName")
$currentConfigurationFile.Save("$EMFHome\$EmfConfigurationFileName")
} catch {
Write-Verbose "Something went wrong while updating configuration file ($ConfigurationFileName), block $ConfigurationName"
Write-Verbose "Something went wrong while updating configuration file ($EmfConfigurationFileName), block $EmfConfigurationName"
throw $_
}
}
Expand Down

0 comments on commit b84df4b

Please sign in to comment.