You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2022/09/30 09:12:01 UTC

[isis] 02/03: ISIS-3224: makes consistent

This is an automated email from the ASF dual-hosted git repository.

danhaywood pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git

commit 1da146b2eac9ed2af344ac6bdff88779647122b2
Author: Dan Haywood <da...@haywood-associates.co.uk>
AuthorDate: Tue Sep 27 14:42:45 2022 +0100

    ISIS-3224: makes consistent
---
 .../applib/dom/CommandLogEntryRepository.java      |  4 ++--
 .../applib/dom/ExecutionLogEntryRepository.java    |  5 ++++-
 .../applib/dom/AuditTrailEntryRepository.java      | 23 +++++++++++++++-------
 3 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/extensions/core/commandlog/applib/src/main/java/org/apache/isis/extensions/commandlog/applib/dom/CommandLogEntryRepository.java b/extensions/core/commandlog/applib/src/main/java/org/apache/isis/extensions/commandlog/applib/dom/CommandLogEntryRepository.java
index f4a139a48d..d59e46359b 100644
--- a/extensions/core/commandlog/applib/src/main/java/org/apache/isis/extensions/commandlog/applib/dom/CommandLogEntryRepository.java
+++ b/extensions/core/commandlog/applib/src/main/java/org/apache/isis/extensions/commandlog/applib/dom/CommandLogEntryRepository.java
@@ -396,7 +396,7 @@ public abstract class CommandLogEntryRepository<C extends CommandLogEntry> {
      */
     public List<C> findAll() {
         if (isisSystemEnvironment.getDeploymentType().isProduction()) {
-            throw new IllegalStateException("Cannot removeAll in production systems");
+            throw new IllegalStateException("Cannot call 'findAll' in production systems");
         }
         return repositoryService().allInstances(commandLogEntryClass);
     }
@@ -407,7 +407,7 @@ public abstract class CommandLogEntryRepository<C extends CommandLogEntry> {
      */
     public void removeAll() {
         if (isisSystemEnvironment.getDeploymentType().isProduction()) {
-            throw new IllegalStateException("Cannot removeAll in production systems");
+            throw new IllegalStateException("Cannot call 'removeAll' in production systems");
         }
         repositoryService().removeAll(commandLogEntryClass);
     }
diff --git a/extensions/core/executionlog/applib/src/main/java/org/apache/isis/extensions/executionlog/applib/dom/ExecutionLogEntryRepository.java b/extensions/core/executionlog/applib/src/main/java/org/apache/isis/extensions/executionlog/applib/dom/ExecutionLogEntryRepository.java
index cf72d07707..8afd7e46ae 100644
--- a/extensions/core/executionlog/applib/src/main/java/org/apache/isis/extensions/executionlog/applib/dom/ExecutionLogEntryRepository.java
+++ b/extensions/core/executionlog/applib/src/main/java/org/apache/isis/extensions/executionlog/applib/dom/ExecutionLogEntryRepository.java
@@ -189,6 +189,9 @@ public abstract class ExecutionLogEntryRepository<E extends ExecutionLogEntry> {
      * intended for testing purposes only
      */
     public List<E> findAll() {
+        if (isisSystemEnvironment.getDeploymentType().isProduction()) {
+            throw new IllegalStateException("Cannot call 'findAll' in production systems");
+        }
         return repositoryService().allInstances(executionLogEntryClass);
     }
 
@@ -198,7 +201,7 @@ public abstract class ExecutionLogEntryRepository<E extends ExecutionLogEntry> {
      */
     public void removeAll() {
         if (isisSystemEnvironment.getDeploymentType().isProduction()) {
-            throw new IllegalStateException("Cannot removeAll in production systems");
+            throw new IllegalStateException("Cannot call 'removeAll' in production systems");
         }
         repositoryService().removeAll(executionLogEntryClass);
     }
diff --git a/extensions/security/audittrail/applib/src/main/java/org/apache/isis/extensions/audittrail/applib/dom/AuditTrailEntryRepository.java b/extensions/security/audittrail/applib/src/main/java/org/apache/isis/extensions/audittrail/applib/dom/AuditTrailEntryRepository.java
index 7c57e09518..f2436c5f64 100644
--- a/extensions/security/audittrail/applib/src/main/java/org/apache/isis/extensions/audittrail/applib/dom/AuditTrailEntryRepository.java
+++ b/extensions/security/audittrail/applib/src/main/java/org/apache/isis/extensions/audittrail/applib/dom/AuditTrailEntryRepository.java
@@ -33,6 +33,7 @@ import org.apache.isis.applib.services.bookmark.Bookmark;
 import org.apache.isis.applib.services.factory.FactoryService;
 import org.apache.isis.applib.services.publishing.spi.EntityPropertyChange;
 import org.apache.isis.applib.services.repository.RepositoryService;
+import org.apache.isis.core.config.environment.IsisSystemEnvironment;
 
 import lombok.AccessLevel;
 import lombok.RequiredArgsConstructor;
@@ -49,6 +50,7 @@ public abstract class AuditTrailEntryRepository<E extends AuditTrailEntry> {
 
     @Inject RepositoryService repositoryService;
     @Inject FactoryService factoryService;
+    @Inject IsisSystemEnvironment isisSystemEnvironment;
 
     public Class<E> getEntityClass() {
         return auditTrailEntryClass;
@@ -156,26 +158,33 @@ public abstract class AuditTrailEntryRepository<E extends AuditTrailEntry> {
         return repositoryService.allMatches(query);
     }
 
+    private static Timestamp toTimestampStartOfDayWithOffset(final LocalDate dt, final int daysOffset) {
+        return dt!=null
+                ? Timestamp.valueOf(dt.atStartOfDay().plusDays(daysOffset))
+                :null;
+    }
+
+
+
     /**
      * intended for testing only
      */
     public List<? extends AuditTrailEntry> findAll() {
+        if (isisSystemEnvironment.getDeploymentType().isProduction()) {
+            throw new IllegalStateException("Cannot call 'findAll' in production systems");
+        }
         return repositoryService.allMatches(
                 Query.named(auditTrailEntryClass, AuditTrailEntry.Nq.FIND)
         );
     }
 
-    private static Timestamp toTimestampStartOfDayWithOffset(final LocalDate dt, final int daysOffset) {
-        return dt!=null
-                ? Timestamp.valueOf(dt.atStartOfDay().plusDays(daysOffset))
-                :null;
-    }
-
-
     /**
      * intended for testing only
      */
     public void removeAll() {
+        if (isisSystemEnvironment.getDeploymentType().isProduction()) {
+            throw new IllegalStateException("Cannot call 'removeAll' in production systems");
+        }
         repositoryService.removeAll(auditTrailEntryClass);
     }