This is an automated email from the ASF dual-hosted git repository.
clebertsuconic pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git
The following commit(s) were added to refs/heads/main by this push:
new 6597f028a3 ARTEMIS-4515 Fix setting web request log using system
properties
6597f028a3 is described below
commit 6597f028a3d1c4227a5716104e7a4b96480264be
Author: Domenico Francesco Bruscino <[email protected]>
AuthorDate: Tue Nov 28 11:51:03 2023 +0100
ARTEMIS-4515 Fix setting web request log using system properties
---
.../apache/activemq/artemis/dto/RequestLogDTO.java | 56 ++++++++++++++++++++++
.../apache/activemq/artemis/dto/WebServerDTO.java | 1 +
.../artemis/component/WebServerComponent.java | 3 +-
.../integration/web/WebServerDTOConfigTest.java | 25 ++++++++++
4 files changed, 84 insertions(+), 1 deletion(-)
diff --git
a/artemis-dto/src/main/java/org/apache/activemq/artemis/dto/RequestLogDTO.java
b/artemis-dto/src/main/java/org/apache/activemq/artemis/dto/RequestLogDTO.java
index ec6097984a..5137307c34 100644
---
a/artemis-dto/src/main/java/org/apache/activemq/artemis/dto/RequestLogDTO.java
+++
b/artemis-dto/src/main/java/org/apache/activemq/artemis/dto/RequestLogDTO.java
@@ -115,4 +115,60 @@ public class RequestLogDTO {
*/
@XmlAttribute
public String format;
+
+ public String getFilename() {
+ return filename;
+ }
+
+ public void setFilename(String filename) {
+ this.filename = filename;
+ }
+
+ public Boolean getAppend() {
+ return append;
+ }
+
+ public void setAppend(Boolean append) {
+ this.append = append;
+ }
+
+ public Boolean getExtended() {
+ return extended;
+ }
+
+ public void setExtended(Boolean extended) {
+ this.extended = extended;
+ }
+
+ public String getFilenameDateFormat() {
+ return filenameDateFormat;
+ }
+
+ public void setFilenameDateFormat(String filenameDateFormat) {
+ this.filenameDateFormat = filenameDateFormat;
+ }
+
+ public Integer getRetainDays() {
+ return retainDays;
+ }
+
+ public void setRetainDays(Integer retainDays) {
+ this.retainDays = retainDays;
+ }
+
+ public String getIgnorePaths() {
+ return ignorePaths;
+ }
+
+ public void setIgnorePaths(String ignorePaths) {
+ this.ignorePaths = ignorePaths;
+ }
+
+ public String getFormat() {
+ return format;
+ }
+
+ public void setFormat(String format) {
+ this.format = format;
+ }
}
diff --git
a/artemis-dto/src/main/java/org/apache/activemq/artemis/dto/WebServerDTO.java
b/artemis-dto/src/main/java/org/apache/activemq/artemis/dto/WebServerDTO.java
index 94dd61b954..91f12ad9b5 100644
---
a/artemis-dto/src/main/java/org/apache/activemq/artemis/dto/WebServerDTO.java
+++
b/artemis-dto/src/main/java/org/apache/activemq/artemis/dto/WebServerDTO.java
@@ -180,6 +180,7 @@ public class WebServerDTO extends ComponentDTO {
public WebServerDTO() {
componentClassName =
"org.apache.activemq.artemis.component.WebServerComponent";
bindings = new ArrayList<>();
+ requestLog = new RequestLogDTO();
}
public List<BindingDTO> getAllBindings() {
diff --git
a/artemis-web/src/main/java/org/apache/activemq/artemis/component/WebServerComponent.java
b/artemis-web/src/main/java/org/apache/activemq/artemis/component/WebServerComponent.java
index 1d6d9b7bb3..62aaff910d 100644
---
a/artemis-web/src/main/java/org/apache/activemq/artemis/component/WebServerComponent.java
+++
b/artemis-web/src/main/java/org/apache/activemq/artemis/component/WebServerComponent.java
@@ -175,7 +175,8 @@ public class WebServerComponent implements
ExternalComponent, WebServerComponent
defaultHandler.setServeIcon(false);
defaultHandler.setRootRedirectLocation(this.webServerConfig.rootRedirectLocation);
- if (this.webServerConfig.requestLog != null) {
+ if (this.webServerConfig.requestLog != null &&
+ this.webServerConfig.requestLog.filename != null) {
server.setRequestLog(getRequestLog());
}
diff --git
a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/web/WebServerDTOConfigTest.java
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/web/WebServerDTOConfigTest.java
index 49321ed0e9..079212a263 100644
---
a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/web/WebServerDTOConfigTest.java
+++
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/web/WebServerDTOConfigTest.java
@@ -156,6 +156,31 @@ public class WebServerDTOConfigTest {
testSetWebBindingAppProperties(webServer, BINDING_TEST_NAME,
APP_TEST_URL);
}
+ @Test
+ public void testSetRequestLogProperties() throws Throwable {
+ WebServerDTO webServer = new WebServerDTO();
+ Properties properties = new Properties();
+
properties.put(ActiveMQDefaultConfiguration.getDefaultSystemWebPropertyPrefix()
+ "requestLog.filename", "filenameTest");
+
properties.put(ActiveMQDefaultConfiguration.getDefaultSystemWebPropertyPrefix()
+ "requestLog.append", "true");
+
properties.put(ActiveMQDefaultConfiguration.getDefaultSystemWebPropertyPrefix()
+ "requestLog.extended", "true");
+
properties.put(ActiveMQDefaultConfiguration.getDefaultSystemWebPropertyPrefix()
+ "requestLog.filenameDateFormat", "filenameDateFormatTest");
+
properties.put(ActiveMQDefaultConfiguration.getDefaultSystemWebPropertyPrefix()
+ "requestLog.retainDays", "3");
+
properties.put(ActiveMQDefaultConfiguration.getDefaultSystemWebPropertyPrefix()
+ "requestLog.ignorePaths", "ignorePathTest0,ignorePathTest1,ignorePathTest2");
+
properties.put(ActiveMQDefaultConfiguration.getDefaultSystemWebPropertyPrefix()
+ "requestLog." + INVALID_ATTRIBUTE_NAME, "true");
+ Configuration configuration = new ConfigurationImpl();
+ String systemWebPropertyPrefix =
ActiveMQDefaultConfiguration.getDefaultSystemWebPropertyPrefix();
+ configuration.parsePrefixedProperties(webServer, "system-" +
systemWebPropertyPrefix, properties, systemWebPropertyPrefix);
+
+ Assert.assertEquals("filenameTest",
webServer.getRequestLog().getFilename());
+ Assert.assertEquals(true, webServer.getRequestLog().getAppend());
+ Assert.assertEquals(true, webServer.getRequestLog().getExtended());
+ Assert.assertEquals("filenameDateFormatTest",
webServer.getRequestLog().getFilenameDateFormat());
+ Assert.assertEquals(Integer.valueOf(3),
webServer.getRequestLog().getRetainDays());
+ Assert.assertEquals("ignorePathTest0,ignorePathTest1,ignorePathTest2",
webServer.getRequestLog().getIgnorePaths());
+
+ testStatus(configuration.getStatus(), "system-" +
systemWebPropertyPrefix, "requestLog.");
+ }
+
private void testSetWebBindingAppProperties(WebServerDTO webServer, String
bindingName, String appName) throws Throwable {
Properties properties = new Properties();
properties.put(ActiveMQDefaultConfiguration.getDefaultSystemWebPropertyPrefix()
+ "bindings." + bindingName + ".apps." + appName + ".url", APP_TEST_URL);