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

Fixes for handling SML and directory related configuration keys #267

Merged
merged 3 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use hasNoText

{
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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo to fix

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)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use hasNoText

{
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 @@ -122,22 +122,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 @@ -162,8 +162,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 @@ -121,22 +121,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 @@ -161,8 +161,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 @@ -120,22 +120,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 @@ -160,5 +160,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 =