Skip to content

Commit

Permalink
Merge pull request #267 from anakinj/db-defaults-from-configuration
Browse files Browse the repository at this point in the history
Fixes for handling SML and directory related configuration keys
  • Loading branch information
phax authored Jul 30, 2024
2 parents acdfbd5 + bc51a89 commit c4c034b
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,21 @@ public static Document toBson (@Nonnull final ISMPSettings aValue)
public static void toDomain (@Nonnull final Document aDoc, @Nonnull final SMPSettings aTarget)
{
aTarget.setRESTWritableAPIDisabled (aDoc.getBoolean (BSON_SMP_REST_WRITABLE_API_DISABLED,
SMPSettings.DEFAULT_SMP_REST_WRITABLE_API_DISABLED));
aTarget.setDirectoryIntegrationRequired (aDoc.getBoolean (BSON_DIRECTORY_INTEGRATION_REQUIRED,
SMPSettings.DEFAULT_SMP_DIRECTORY_INTEGRATION_REQUIRED));
aTarget.isRESTWritableAPIDisabled ()));
aTarget.setDirectoryIntegrationEnabled (aDoc.getBoolean (BSON_DIRECTORY_INTEGRATION_ENABLED,
SMPSettings.DEFAULT_SMP_DIRECTORY_INTEGRATION_ENABLED));
aTarget.isDirectoryIntegrationEnabled ()));
aTarget.setDirectoryIntegrationRequired (aDoc.getBoolean (BSON_DIRECTORY_INTEGRATION_REQUIRED,
aTarget.isDirectoryIntegrationRequired ()));
aTarget.setDirectoryIntegrationAutoUpdate (aDoc.getBoolean (BSON_DIRECTORY_INTEGRATION_AUTO_UPDATE,
SMPSettings.DEFAULT_SMP_DIRECTORY_INTEGRATION_AUTO_UPDATE));
aTarget.setDirectoryHostName (aDoc.getString (BSON_DIRECTORY_HOSTNAME));
aTarget.setSMLRequired (aDoc.getBoolean (BSON_SML_REQUIRED, SMPSettings.DEFAULT_SML_REQUIRED));
aTarget.setSMLEnabled (aDoc.getBoolean (BSON_SML_ENABLED, SMPSettings.DEFAULT_SML_ENABLED));
aTarget.isDirectoryIntegrationAutoUpdate ()));
String sDirectoryHostName = aDoc.getString (BSON_DIRECTORY_HOSTNAME);
if (sDirectoryHostName == null)
{
sDirectoryHostName = aTarget.getDirectoryHostName ();
}
aTarget.setDirectoryHostName (sDirectoryHostName);
aTarget.setSMLEnabled (aDoc.getBoolean (BSON_SML_ENABLED, aTarget.isSMLEnabled ()));
aTarget.setSMLRequired (aDoc.getBoolean (BSON_SML_REQUIRED, aTarget.isSMLRequired ()));
aTarget.setSMLInfoID (aDoc.getString (BSON_SML_INFO_ID));
}

Expand All @@ -100,7 +105,7 @@ public SMPSettingsManagerMongoDB ()
}

@Nonnull
@ReturnsMutableObject
@aTargeturnsMutableObject
public final CallbackList <ISMPSettingsCallback> callbacks ()
{
return m_aCallbacks;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,18 +186,23 @@ private ISMPSettings _getSettingsFromDB (@Nonnull final SMPSettingsManagerJDBC a
// Queries DB
final ICommonsMap <String, String> aValues = aMgr.getAllSettingsValuesFromDB ();

final SMPSettings ret = new SMPSettings (false);
final SMPSettings ret = new SMPSettings (true);
ret.setRESTWritableAPIDisabled (StringParser.parseBool (aValues.get (SMP_REST_WRITABLE_API_DISABLED),
SMPSettings.DEFAULT_SMP_REST_WRITABLE_API_DISABLED));
ret.isRESTWritableAPIDisabled ()));
ret.setDirectoryIntegrationEnabled (StringParser.parseBool (aValues.get (DIRECTORY_INTEGRATION_ENABLED),
SMPSettings.DEFAULT_SMP_DIRECTORY_INTEGRATION_ENABLED));
ret.isDirectoryIntegrationEnabled ()));
ret.setDirectoryIntegrationRequired (StringParser.parseBool (aValues.get (DIRECTORY_INTEGRATION_REQUIRED),
SMPSettings.DEFAULT_SMP_DIRECTORY_INTEGRATION_REQUIRED));
ret.isDirectoryIntegrationRequired ()));
ret.setDirectoryIntegrationAutoUpdate (StringParser.parseBool (aValues.get (DIRECTORY_INTEGRATION_AUTO_UPDATE),
SMPSettings.DEFAULT_SMP_DIRECTORY_INTEGRATION_AUTO_UPDATE));
ret.setDirectoryHostName (aValues.get (DIRECTORY_HOSTNAME));
ret.setSMLEnabled (StringParser.parseBool (aValues.get (SML_ENABLED), SMPSettings.DEFAULT_SML_ENABLED));
ret.setSMLRequired (StringParser.parseBool (aValues.get (SML_REQUIRED), SMPSettings.DEFAULT_SML_REQUIRED));
ret.isDirectoryIntegrationAutoUpdate ()));
String sDirectoryHostName = aValues.get (DIRECTORY_HOSTNAME);
if (sDirectoryHostName == null)
{
sDirectoryHostName = ret.getDirectoryHostName ();
}
ret.setDirectoryHostName (sDirectoryHostName);
ret.setSMLEnabled (StringParser.parseBool (aValues.get (SML_ENABLED), ret.isSMLEnabled ()));
ret.setSMLRequired (StringParser.parseBool (aValues.get (SML_REQUIRED), ret.isSMLRequired ()));
ret.setSMLInfoID (aValues.get (SML_INFO_ID));
return ret;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,24 +146,24 @@ public EChange setRESTWritableAPIDisabled (final boolean bRESTWritableAPIDisable

public boolean isSMLRequired ()
{
return m_aSettings.getAsBoolean (KEY_SML_REQUIRED_OLD, DEFAULT_SML_REQUIRED);
return m_aSettings.getAsBoolean (KEY_SML_REQUIRED, DEFAULT_SML_REQUIRED);
}

@Nonnull
public EChange setSMLRequired (final boolean bSMLRequired)
{
return m_aSettings.putIn (KEY_SML_REQUIRED_OLD, bSMLRequired);
return m_aSettings.putIn (KEY_SML_REQUIRED, bSMLRequired);
}

public boolean isSMLEnabled ()
{
return m_aSettings.getAsBoolean (KEY_SML_ENABLED_OLD, DEFAULT_SML_ENABLED);
return m_aSettings.getAsBoolean (KEY_SML_ENABLED, DEFAULT_SML_ENABLED);
}

@Nonnull
public EChange setSMLEnabled (final boolean bSMLEnabled)
{
return m_aSettings.putIn (KEY_SML_ENABLED_OLD, bSMLEnabled);
return m_aSettings.putIn (KEY_SML_ENABLED, bSMLEnabled);
}

@Nullable
Expand All @@ -188,52 +188,52 @@ public EChange setSMLInfoID (@Nullable final String sSMLInfoID)

public boolean isDirectoryIntegrationRequired ()
{
return m_aSettings.getAsBoolean (KEY_SMP_DIRECTORY_INTEGRATION_REQUIRED_OLD,
return m_aSettings.getAsBoolean (KEY_SMP_DIRECTORY_INTEGRATION_REQUIRED,
DEFAULT_SMP_DIRECTORY_INTEGRATION_REQUIRED);
}

@Nonnull
public EChange setDirectoryIntegrationRequired (final boolean bPeppolDirectoryIntegrationRequired)
{
return m_aSettings.putIn (KEY_SMP_DIRECTORY_INTEGRATION_REQUIRED_OLD, bPeppolDirectoryIntegrationRequired);
return m_aSettings.putIn (KEY_SMP_DIRECTORY_INTEGRATION_REQUIRED, bPeppolDirectoryIntegrationRequired);
}

public boolean isDirectoryIntegrationEnabled ()
{
return m_aSettings.getAsBoolean (KEY_SMP_DIRECTORY_INTEGRATION_ENABLED_OLD,
return m_aSettings.getAsBoolean (KEY_SMP_DIRECTORY_INTEGRATION_ENABLED,
DEFAULT_SMP_DIRECTORY_INTEGRATION_ENABLED);
}

@Nonnull
public EChange setDirectoryIntegrationEnabled (final boolean bPeppolDirectoryIntegrationEnabled)
{
return m_aSettings.putIn (KEY_SMP_DIRECTORY_INTEGRATION_ENABLED_OLD, bPeppolDirectoryIntegrationEnabled);
return m_aSettings.putIn (KEY_SMP_DIRECTORY_INTEGRATION_ENABLED, bPeppolDirectoryIntegrationEnabled);
}

public boolean isDirectoryIntegrationAutoUpdate ()
{
return m_aSettings.getAsBoolean (KEY_SMP_DIRECTORY_INTEGRATION_AUTO_UPDATE_OLD,
return m_aSettings.getAsBoolean (KEY_SMP_DIRECTORY_INTEGRATION_AUTO_UPDATE,
DEFAULT_SMP_DIRECTORY_INTEGRATION_AUTO_UPDATE);
}

@Nonnull
public EChange setDirectoryIntegrationAutoUpdate (final boolean bPeppolDirectoryIntegrationAutoUpdate)
{
return m_aSettings.putIn (KEY_SMP_DIRECTORY_INTEGRATION_AUTO_UPDATE_OLD, bPeppolDirectoryIntegrationAutoUpdate);
return m_aSettings.putIn (KEY_SMP_DIRECTORY_INTEGRATION_AUTO_UPDATE, bPeppolDirectoryIntegrationAutoUpdate);
}

@Nonnull
public String getDirectoryHostName ()
{
// TODO select between test and prod in default
return m_aSettings.getAsString (KEY_SMP_DIRECTORY_HOSTNAME_OLD,
return m_aSettings.getAsString (KEY_SMP_DIRECTORY_HOSTNAME,
true ? DEFAULT_SMP_DIRECTORY_HOSTNAME_PROD : DEFAULT_SMP_DIRECTORY_HOSTNAME_TEST);
}

@Nonnull
public EChange setDirectoryHostName (@Nullable final String sDirectoryHostName)
{
return m_aSettings.putIn (KEY_SMP_DIRECTORY_HOSTNAME_OLD, sDirectoryHostName);
return m_aSettings.putIn (KEY_SMP_DIRECTORY_HOSTNAME, sDirectoryHostName);
}

@Nonnull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,22 +125,22 @@ smp.forceroot = true
#smp.publicurl = http://smp.example.org/

# Is an SML needed in the current scenario - show warnings if true
sml.required=true
#sml.required=true

## Write to SML? true or false
sml.enabled=false
#sml.enabled=false

# The SMP ID also used in the SML!
sml.smpid=TEST-SMP-ID1

# SML connection timeout milliseconds
# SML connection timeout milliseconds
#sml.connection.timeout.ms = 5000

# SML request timeout milliseconds
#sml.request.timeout.ms = 20000

# Enable Directory integration?
smp.directory.integration.enabled=true
#smp.directory.integration.enabled=true

# Use PEPPOL identifiers (with all constraints) or simple, unchecked identifiers?
# Possible values are "peppol", "simple" and "bdxr"
Expand All @@ -165,8 +165,8 @@ smp.rest.payload.on.error=true
#https.proxyHost = 10.0.0.10
#https.proxyPort = 8080
# Credentials for the proxy server (if needed)
#proxy.username =
#proxy.password =
#proxy.username =
#proxy.password =

# MongoDB specific settings
mongodb.connectionstring = mongodb://localhost
Expand Down
12 changes: 6 additions & 6 deletions phoss-smp-webapp-sql/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -123,22 +123,22 @@ smp.forceroot = true
#smp.publicurl = http://smp.example.org/

# Is an SML needed in the current scenario - show warnings if true
sml.required=true
#sml.required=true

## Write to SML? true or false
sml.enabled=false
#sml.enabled=false

# The SMP ID also used in the SML!
sml.smpid=TEST-SMP-ID1

# SML connection timeout milliseconds
# SML connection timeout milliseconds
#sml.connection.timeout.ms = 5000

# SML request timeout milliseconds
#sml.request.timeout.ms = 20000

# Enable Directory integration?
smp.directory.integration.enabled=true
#smp.directory.integration.enabled=true

# Use PEPPOL identifiers (with all constraints) or simple, unchecked identifiers?
# Possible values are "peppol", "simple" and "bdxr"
Expand All @@ -163,8 +163,8 @@ smp.rest.payload.on.error=true
#https.proxyHost = 10.0.0.10
#https.proxyPort = 8080
# Credentials for the proxy server (if needed)
#proxy.username =
#proxy.password =
#proxy.username =
#proxy.password =

## Required when using the SQL backend

Expand Down
12 changes: 6 additions & 6 deletions phoss-smp-webapp-xml/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -123,22 +123,22 @@ smp.forceroot = true
#smp.publicurl = http://smp.example.org/

# Is an SML needed in the current scenario - show warnings if true
sml.required=true
#sml.required=true

## Write to SML? true or false
sml.enabled=false
#sml.enabled=false

# The SMP ID also used in the SML!
sml.smpid=TEST-SMP-ID1

# SML connection timeout milliseconds
# SML connection timeout milliseconds
#sml.connection.timeout.ms = 5000

# SML request timeout milliseconds
#sml.request.timeout.ms = 20000

# Enable Directory integration?
smp.directory.integration.enabled=true
#smp.directory.integration.enabled=true

# Use PEPPOL identifiers (with all constraints) or simple, unchecked identifiers?
# Possible values are "peppol", "simple" and "bdxr"
Expand All @@ -163,5 +163,5 @@ smp.rest.payload.on.error=true
#https.proxyHost = 10.0.0.10
#https.proxyPort = 8080
# Credentials for the proxy server (if needed)
#proxy.username =
#proxy.password =
#proxy.username =
#proxy.password =

0 comments on commit c4c034b

Please sign in to comment.