Skip to content
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 @@ -55,6 +55,29 @@ public enum Publishing {
*/
ENABLED,

/**
* Applies only to {@link EntityPropertyChangeSubscriber}, whereby events are published for modifications to the
* object, but no events are published for the initial creation of an object.
*
* <p>
* In the case of audit trail extension,
* this effectively suppresses all of the "[NEW] -> value" entries that are created for every property of the
* entity when it is being created, and also all of the "value -> [DELETED]" entries that are created for every property of the
* entity when it is being deleted.
* </p>
*
* <p>
* This variant is intended only where the application code has enough traceability built into the domain
* (perhaps to provide visibility to the end-users) that the technical auditing is overkill. It will also
* of course reduce the volume of auditing, so improves performance (likely both response times and throughput).
* </p>
*
* <p>
* For other subscribers, behaviour is the same as {@link #ENABLED}.
* </p>
*/
ENABLED_FOR_UPDATES_ONLY,

/**
* Do <b>not</b> publish data triggered by interaction with this object
* (even if otherwise configured to enable publishing).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public static Optional<CommandPublishingFacet> create(
case DISABLED:
return new CommandPublishingFacetForActionAnnotation.Disabled(processor, holder, servicesInjector);
case ENABLED:
case ENABLED_FOR_UPDATES_ONLY:
return new CommandPublishingFacetForActionAnnotation.Enabled(processor, holder, servicesInjector);
default:
throw new IllegalStateException(String.format("@Action#commandPublishing '%s' not recognised", publishing));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public static CommandPublishingFacet create(
case DISABLED:
return new CommandPublishingFacetForPropertyAnnotation.Disabled(processor, holder, servicesInjector);
case ENABLED:
case ENABLED_FOR_UPDATES_ONLY:
return new CommandPublishingFacetForPropertyAnnotation.Enabled(processor, holder, servicesInjector);
default:
throw new IllegalStateException(String.format("@Property#commandPublishing '%s' not recognised", publishing));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public static Optional<ExecutionPublishingFacet> create(
case DISABLED:
return new ExecutionPublishingFacetForActionAnnotation.Disabled(holder);
case ENABLED:
case ENABLED_FOR_UPDATES_ONLY:
return new ExecutionPublishingFacetForActionAnnotation.Enabled(holder);
default:
throw new IllegalStateException(String.format("@Action#executionPublishing '%s' not recognised", publishing));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public static ExecutionPublishingFacet create(
case DISABLED:
return new ExecutionPublishingFacetForPropertyAnnotation.Disabled(holder);
case ENABLED:
case ENABLED_FOR_UPDATES_ONLY:
return new ExecutionPublishingFacetForPropertyAnnotation.Enabled(holder);
default:
throw new IllegalStateException(String.format("@Property#executionPublishing '%s' not recognised", publishing));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,19 @@ public static Optional<EntityChangePublishingFacet> create(
: new EntityChangePublishingFacetFromConfiguration(holder, true));
}
case DISABLED:
return Optional.of(new EntityChangePublishingFacetForDomainObjectAnnotation(holder, false));
return Optional.of(new EntityChangePublishingFacetForDomainObjectAnnotation(holder, false, false, false, false));
case ENABLED:
return Optional.of(new EntityChangePublishingFacetForDomainObjectAnnotation(holder, true));
return Optional.of(new EntityChangePublishingFacetForDomainObjectAnnotation(holder, true, true, true, true));
case ENABLED_FOR_UPDATES_ONLY:
return Optional.of(new EntityChangePublishingFacetForDomainObjectAnnotation(holder, true, false, true, false));

default:
throw _Exceptions.unmatchedCase(publish);
}
}

protected EntityChangePublishingFacetForDomainObjectAnnotation(final FacetHolder holder, boolean enabled) {
super(holder, enabled);
protected EntityChangePublishingFacetForDomainObjectAnnotation(final FacetHolder holder, boolean enabled, boolean enabledForCreate, boolean enabledForUpdate, boolean enabledForDelete) {
super(holder, enabled, enabledForCreate, enabledForUpdate, enabledForDelete);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
public class EntityChangePublishingFacetForDomainObjectAnnotationAsConfigured extends EntityChangePublishingFacetForDomainObjectAnnotation {

public EntityChangePublishingFacetForDomainObjectAnnotationAsConfigured(final FacetHolder facetHolder, final boolean enabled) {
super(facetHolder, enabled);
super(facetHolder, enabled, enabled, enabled, enabled);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class EntityChangePublishingFacetFromConfiguration
extends EntityChangePublishingFacetAbstract {

public EntityChangePublishingFacetFromConfiguration(final FacetHolder facetHolder, final boolean enabled) {
super(facetHolder, enabled);
super(facetHolder, enabled, enabled, enabled, enabled);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
*/
public interface EntityChangePublishingFacet extends Facet {

public static boolean isPublishingEnabled(final FacetHolder facetHolder) {
static boolean isPublishingEnabled(final FacetHolder facetHolder) {
if(facetHolder==null) {
return false;
}
Expand All @@ -50,6 +50,57 @@ public static boolean isPublishingEnabled(final FacetHolder facetHolder) {
&& entityChangePublishingFacet.isEnabled();
}

static boolean isPublishingEnabledForCreate(final FacetHolder facetHolder) {
if(facetHolder==null) {
return false;
}

if(facetHolder instanceof ObjectSpecification) {
if(!((ObjectSpecification)facetHolder).isEntity()) {
return false;
}
}

val entityChangePublishingFacet = facetHolder.getFacet(EntityChangePublishingFacet.class);
return entityChangePublishingFacet != null
&& entityChangePublishingFacet.isEnabledForCreate();
}

static boolean isPublishingEnabledForUpdate(final FacetHolder facetHolder) {
if(facetHolder==null) {
return false;
}

if(facetHolder instanceof ObjectSpecification) {
if(!((ObjectSpecification)facetHolder).isEntity()) {
return false;
}
}

val entityChangePublishingFacet = facetHolder.getFacet(EntityChangePublishingFacet.class);
return entityChangePublishingFacet != null
&& entityChangePublishingFacet.isEnabledForUpdate();
}

static boolean isPublishingEnabledForDelete(final FacetHolder facetHolder) {
if(facetHolder==null) {
return false;
}

if(facetHolder instanceof ObjectSpecification) {
if(!((ObjectSpecification)facetHolder).isEntity()) {
return false;
}
}

val entityChangePublishingFacet = facetHolder.getFacet(EntityChangePublishingFacet.class);
return entityChangePublishingFacet != null
&& entityChangePublishingFacet.isEnabledForDelete();
}

boolean isEnabled();
boolean isEnabledForCreate();
boolean isEnabledForUpdate();
boolean isEnabledForDelete();

}
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,21 @@ private static final Class<? extends Facet> type() {
@Getter
private final boolean enabled;

public EntityChangePublishingFacetAbstract(final FacetHolder facetHolder, boolean enabled) {
@Getter
private final boolean enabledForCreate;

@Getter
private final boolean enabledForUpdate;

@Getter
private final boolean enabledForDelete;

public EntityChangePublishingFacetAbstract(final FacetHolder facetHolder, boolean enabled, boolean enabledForCreate, boolean enabledForUpdate, boolean enabledForDelete) {
super(EntityChangePublishingFacetAbstract.type(), facetHolder);
this.enabled = enabled;
this.enabledForCreate = enabledForCreate;
this.enabledForUpdate = enabledForUpdate;
this.enabledForDelete = enabledForDelete;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
public interface EntityPropertyChangePublishingPolicyFacet extends Facet {

/**
* Must be one of Publishing.ENABLED or Publishing.DISABLED.
* Must be one of {@link Publishing#ENABLED}, {@link Publishing#ENABLED_FOR_UPDATES_ONLY} or {@link Publishing#DISABLED}.
*/
@NonNull Publishing getEntityChangePublishing();

Expand All @@ -43,7 +43,7 @@ default boolean isPublishingVetoed() {
}

default boolean isPublishingAllowed() {
return getEntityChangePublishing() == Publishing.ENABLED;
return getEntityChangePublishing() == Publishing.ENABLED || getEntityChangePublishing() == Publishing.ENABLED_FOR_UPDATES_ONLY;
}

static boolean isExcludedFromPublishing(final @NonNull OneToOneAssociation property) {
Expand All @@ -59,7 +59,7 @@ static boolean isExcludedFromPublishing(final @NonNull OneToOneAssociation prope
.map(EntityPropertyChangePublishingPolicyFacet::isPublishingAllowed)
.orElse(false);

//XXX CAUSEWAY-1488, exclude Bob/Clob from property change publishing unless explicitly allowed
//XXX CAUSEWAY-1488, exclude Blob/Clob from property change publishing unless explicitly allowed
return !isExplictlyAllowed;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ public static Optional<EntityPropertyChangePublishingPolicyFacet> create(
.map(Property::entityChangePublishing)
// only install facet if policy is explicit ('enabled' or 'disabled')
.filter(entityChangePublishing ->
entityChangePublishing == Publishing.ENABLED
|| entityChangePublishing == Publishing.DISABLED)
entityChangePublishing == Publishing.ENABLED ||
entityChangePublishing == Publishing.ENABLED_FOR_UPDATES_ONLY ||
entityChangePublishing == Publishing.DISABLED)
.map(entityChangePublishing ->
new EntityPropertyChangePublishingPolicyFacetForPropertyAnnotation(entityChangePublishing, holder));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,7 @@ public static CollectionScenarioBuilder builder(final Class<?> declaringClass, f

// --

@Getter(onMethod_ = {@Override})
private MetaModelContext metaModelContext;
@Getter(onMethod_ = {@Override}) protected MetaModelContext metaModelContext;


private MethodRemover_forTesting methodRemover;
Expand Down
Loading
Loading