Skip to content
Permalink
Browse files

Added new configuraiton property "smp.rest.payload.on.error"

  • Loading branch information...
phax committed Aug 17, 2019
1 parent bbdec65 commit 1f5585a88078ba17e524f09c4c592346f5b2bd3e
@@ -76,6 +76,7 @@
public static final String KEY_SMP_REST_TYPE = "smp.rest.type";
public static final String KEY_SMP_REST_WRITABLE_API_DISABLED = "smp.rest.writableapi.disabled";
public static final String KEY_SMP_REST_LOG_EXCEPTIONS = "smp.rest.log.exceptions";
public static final String KEY_SMP_REST_PAYLOAD_ON_ERROR = "smp.rest.payload.on.error";
public static final String KEY_SMP_STATUS_ENABLED = "smp.status.enabled";
/* legacy name */
public static final String KEY_SMP_DIRECTORY_INTEGRATION_ENABLED = "smp.peppol.directory.integration.enabled";
@@ -100,6 +101,7 @@
public static final ESMPRESTType DEFAULT_SMP_REST_TYPE = ESMPRESTType.PEPPOL;
public static final boolean DEFAULT_SMP_REST_WRITABLE_API_DISABLED = false;
public static final boolean DEFAULT_SMP_REST_LOG_EXCEPTIONS = false;
public static final boolean DEFAULT_SMP_REST_PAYLOAD_ON_ERROR = true;
public static final boolean DEFAULT_SMP_STATUS_ENABLED = true;
public static final boolean DEFAULT_SML_REQUIRED = true;
public static final boolean DEFAULT_SML_ENABLED = false;
@@ -328,6 +330,18 @@ public static boolean isRESTLogExceptions ()
return getConfigFile ().getAsBoolean (KEY_SMP_REST_LOG_EXCEPTIONS, DEFAULT_SMP_REST_LOG_EXCEPTIONS);
}

/**
* @return <code>true</code> if in case of an exception in the REST API´,
* payload text should be provided as test, <code>false</code> if not.
* By default it is enabled. For security reasons it should be
* disabled.
* @since 5.2.1
*/
public static boolean isRESTPayloadOnError ()
{
return getConfigFile ().getAsBoolean (KEY_SMP_REST_PAYLOAD_ON_ERROR, DEFAULT_SMP_REST_PAYLOAD_ON_ERROR);
}

/**
* @return <code>true</code> if the status servlet at
* <code>/smp-status/</code> is enabled, <code>false</code> if it is
@@ -71,6 +71,18 @@ smp.rest.type=peppol
# Log exceptions occurring in the REST API that are returned as HTTP errors?
smp.rest.log.exceptions=false

# Add payload to HTTP responses in case of REST API errors?
smp.rest.payload.on.error=true

# http/https Proxy settings
#http.proxyHost = 10.0.0.10
#http.proxyPort = 808
#https.proxyHost = 10.0.0.10
#https.proxyPort = 808
# Credentials for the proxy server (if needed)
#proxy.username =
#proxy.password =

# MongoDB specific settings
mongodb.connectionstring = mongodb://localhost
mongodb.dbname = phoss-smp
@@ -71,6 +71,18 @@ smp.rest.type=peppol
# Log exceptions occurring in the REST API that are returned as HTTP errors?
smp.rest.log.exceptions=false

# Add payload to HTTP responses in case of REST API errors?
smp.rest.payload.on.error=true

# http/https Proxy settings
#http.proxyHost = 10.0.0.10
#http.proxyPort = 808
#https.proxyHost = 10.0.0.10
#https.proxyPort = 808
# Credentials for the proxy server (if needed)
#proxy.username =
#proxy.password =

## Required when using the SQL backend
jdbc.driver = com.mysql.jdbc.Driver
jdbc.url = jdbc:mysql://localhost:3306/smp?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
@@ -63,3 +63,6 @@ smp.rest.type=peppol

# Log exceptions occurring in the REST API that are returned as HTTP errors?
smp.rest.log.exceptions=false

# Add payload to HTTP responses in case of REST API errors?
smp.rest.payload.on.error=true
@@ -64,6 +64,9 @@ smp.rest.type=peppol
# Log exceptions occurring in the REST API that are returned as HTTP errors?
smp.rest.log.exceptions=false

# Add payload to HTTP responses in case of REST API errors?
smp.rest.payload.on.error=true

# http/https Proxy settings
#http.proxyHost = 10.0.0.10
#http.proxyPort = 808
@@ -64,9 +64,18 @@ private static void _setSimpleTextResponse (@Nonnull final UnifiedResponse aUnif
final int nStatusCode,
@Nullable final String sContent)
{
setSimpleTextResponse (aUnifiedResponse, nStatusCode, sContent);
if (StringHelper.hasText (sContent))
aUnifiedResponse.disableCaching ();
if (SMPServerConfiguration.isRESTPayloadOnError ())
{
// With payload
setSimpleTextResponse (aUnifiedResponse, nStatusCode, sContent);
if (StringHelper.hasText (sContent))
aUnifiedResponse.disableCaching ();
}
else
{
// No payload
aUnifiedResponse.setStatus (nStatusCode);
}
}

@Nonnull
@@ -89,6 +89,8 @@ public static IJsonObject getDefaultStatusData ()
aStatusData.add ("smp.forceroot", SMPServerConfiguration.isForceRoot ());
// New in 5.2.0
aStatusData.add ("smp.rest.log-exceptions", SMPServerConfiguration.isRESTLogExceptions ());
// New in 5.2.1
aStatusData.add ("smp.rest.payload-on-error", SMPServerConfiguration.isRESTPayloadOnError ());

// SML information
aStatusData.add ("smp.sml.enabled", aSettings.isSMLEnabled ());

0 comments on commit 1f5585a

Please sign in to comment.
You can’t perform that action at this time.