This is an automated email from the ASF dual-hosted git repository.
danhaywood pushed a commit to branch ISIS-3110
in repository https://gitbox.apache.org/repos/asf/isis.git
The following commit(s) were added to refs/heads/ISIS-3110 by this push:
new a76d75a522 ISIS-3110: adds a flag for whether to publish command log
even if don't know that state has changed
a76d75a522 is described below
commit a76d75a5221fbff1f1c8e98b0e2be1e354f5afbf
Author: Dan Haywood <[email protected]>
AuthorDate: Thu Aug 4 18:32:18 2022 +0100
ISIS-3110: adds a flag for whether to publish command log even if don't
know that state has changed
---
.../isis/applib/services/command/Command.java | 10 +++++++
.../apache/isis/core/config/IsisConfiguration.java | 31 ++++++++++++++++++++++
.../subscriber/CommandSubscriberForCommandLog.java | 4 ++-
3 files changed, 44 insertions(+), 1 deletion(-)
diff --git
a/api/applib/src/main/java/org/apache/isis/applib/services/command/Command.java
b/api/applib/src/main/java/org/apache/isis/applib/services/command/Command.java
index 84e528a221..7dcd0d8d5f 100644
---
a/api/applib/src/main/java/org/apache/isis/applib/services/command/Command.java
+++
b/api/applib/src/main/java/org/apache/isis/applib/services/command/Command.java
@@ -243,6 +243,16 @@ public class Command implements HasInteractionId,
HasUsername, HasCommandDto {
* and replayed on another system, eg for regression testing.
* </p>
*
+ * <p>
+ * Note that this flag will only be accurate if the <i>Audit Trail</i>
extension (or equivalent) is configured
+ * to actually set it.
+ * </p>
+ *
+ * <p>
+ * See also the
<code>isis.extensions.command-log.publish-policy</code> configuration property,
that controls
+ * whether the <i>Command Log</i> extension checks this flag or not.
+ * </p>
+ *
*/
@Getter
private boolean systemStateChanged;
diff --git
a/core/config/src/main/java/org/apache/isis/core/config/IsisConfiguration.java
b/core/config/src/main/java/org/apache/isis/core/config/IsisConfiguration.java
index c1b5471688..5fa784bd5b 100644
---
a/core/config/src/main/java/org/apache/isis/core/config/IsisConfiguration.java
+++
b/core/config/src/main/java/org/apache/isis/core/config/IsisConfiguration.java
@@ -2764,6 +2764,37 @@ public class IsisConfiguration {
public static class Quartz {
}
+ private final CommandLog commandLog = new CommandLog();
+ @Data
+ public static class CommandLog {
+
+ public enum PublishPolicy {
+ ALWAYS,
+ ONLY_IF_SYSTEM_CHANGED,
+ ;
+ public boolean isAlways() { return this == ALWAYS; }
+ public boolean isOnlyIfSystemChanged() { return this ==
ONLY_IF_SYSTEM_CHANGED; }
+
+ }
+ /**
+ * Whether commands should be published always, or only if a
change in the system's state has been detected.
+ *
+ * <p>
+ * In general, the default of {@link PublishPolicy#ALWAYS} should
be used, <i>unless</i> the
+ * <i>Audit Trail</i> extension is also in use, which is able to
advise on whether the systems state has
+ * changed.
+ * </p>
+ *
+ * <p>
+ * Put another way, if this policy is set to {@link
PublishPolicy#ONLY_IF_SYSTEM_CHANGED} but the
+ * <i>Audit Trail</i> extension is <i>not</i> enabled, then
nothing will be logged.
+ * </p>
+ */
+ @Getter @Setter
+ private PublishPolicy publishPolicy = PublishPolicy.ALWAYS;
+
+ }
+
private final CommandReplay commandReplay = new CommandReplay();
@Data
public static class CommandReplay {
diff --git
a/extensions/core/commandlog/applib/src/main/java/org/apache/isis/extensions/commandlog/applib/subscriber/CommandSubscriberForCommandLog.java
b/extensions/core/commandlog/applib/src/main/java/org/apache/isis/extensions/commandlog/applib/subscriber/CommandSubscriberForCommandLog.java
index 3344bdc1cd..b0f3226689 100644
---
a/extensions/core/commandlog/applib/src/main/java/org/apache/isis/extensions/commandlog/applib/subscriber/CommandSubscriberForCommandLog.java
+++
b/extensions/core/commandlog/applib/src/main/java/org/apache/isis/extensions/commandlog/applib/subscriber/CommandSubscriberForCommandLog.java
@@ -28,6 +28,7 @@ import org.apache.isis.applib.services.command.Command;
import org.apache.isis.applib.services.publishing.spi.CommandSubscriber;
import org.apache.isis.applib.util.JaxbUtil;
import org.apache.isis.commons.internal.base._Casts;
+import org.apache.isis.core.config.IsisConfiguration;
import
org.apache.isis.extensions.commandlog.applib.IsisModuleExtCommandLogApplib;
import org.apache.isis.extensions.commandlog.applib.dom.CommandLogEntry;
import
org.apache.isis.extensions.commandlog.applib.dom.CommandLogEntryRepository;
@@ -47,11 +48,12 @@ import lombok.extern.log4j.Log4j2;
public class CommandSubscriberForCommandLog implements CommandSubscriber {
final CommandLogEntryRepository<? extends CommandLogEntry>
commandLogEntryRepository;
+ final IsisConfiguration isisConfiguration;
@Override
public void onCompleted(final Command command) {
- if(!command.isSystemStateChanged()) {
+ if
(isisConfiguration.getExtensions().getCommandLog().getPublishPolicy().isOnlyIfSystemChanged()
&& !command.isSystemStateChanged()) {
return;
}