Skip to content

Commit

Permalink
[ACS-9024] Merge enterprise event model into the community one (#39)
Browse files Browse the repository at this point in the history
* [ACS-9024] Merge Enterprise Event Model into Community

* [ACS-9024] Prepare for 1.0.0 release
  • Loading branch information
kmagdziarz authored Nov 26, 2024
1 parent aff64e7 commit f2ef271
Show file tree
Hide file tree
Showing 14 changed files with 569 additions and 27 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</parent>

<artifactId>acs-event-model</artifactId>
<version>0.0.34-SNAPSHOT</version>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>acs-event-model</name>
<description>Alfresco Content Services Event Model</description>
Expand Down Expand Up @@ -64,7 +64,7 @@
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.7</version>
<version>2.14.0</version>
<scope>test</scope>
</dependency>

Expand Down
83 changes: 71 additions & 12 deletions src/main/java/org/alfresco/repo/event/v1/model/EventData.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
package org.alfresco.repo.event.v1.model;

import java.util.Objects;
import java.util.Set;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
Expand All @@ -51,11 +52,26 @@ public class EventData<R extends Resource> implements DataAttributes<R>
@JsonTypeInfo(use = Id.NAME)
private final R resourceBefore;

// Ignored if authorities is disabled
@JsonInclude(Include.NON_NULL)
private final Set<String> resourceReaderAuthorities;

// Ignored if authorities is disabled
@JsonInclude(Include.NON_NULL)
private final Set<String> resourceDeniedAuthorities;

// Only relevant for AGS module
@JsonInclude(Include.NON_NULL)
private final Set<String> resourceReaderSecurityControls;

private EventData(Builder<R> builder)
{
this.eventGroupId = builder.eventGroupId;
this.resource = builder.resource;
this.resourceBefore = builder.resourceBefore;
this.resourceReaderAuthorities = builder.resourceReaderAuthorities;
this.resourceDeniedAuthorities = builder.resourceDeniedAuthorities;
this.resourceReaderSecurityControls = builder.resourceReaderSecurityControls;
}

public static <R extends Resource> Builder<R> builder()
Expand All @@ -81,37 +97,58 @@ public R getResourceBefore()
return resourceBefore;
}

public Set<String> getResourceReaderAuthorities()
{
return resourceReaderAuthorities;
}

public Set<String> getResourceDeniedAuthorities()
{
return resourceDeniedAuthorities;
}

public Set<String> getResourceReaderSecurityControls()
{
return resourceReaderSecurityControls;
}

@Override
public boolean equals(Object o)
{
if (this == o)
{
return true;
}
if (!(o instanceof EventData))
if (!(o instanceof EventData<?> that))
{
return false;
}
EventData<?> eventData = (EventData<?>) o;
return Objects.equals(eventGroupId, eventData.eventGroupId)
&& Objects.equals(resource, eventData.resource)
&& Objects.equals(resourceBefore, eventData.resourceBefore);
return Objects.equals(eventGroupId, that.eventGroupId)
&& Objects.equals(resource, that.resource)
&& Objects.equals(resourceBefore, that.resourceBefore)
&& Objects.equals(resourceReaderAuthorities, that.resourceReaderAuthorities)
&& Objects.equals(resourceDeniedAuthorities, that.resourceDeniedAuthorities)
&& Objects.equals(resourceReaderSecurityControls, that.resourceReaderSecurityControls);
}

@Override
public int hashCode()
{
return Objects.hash(eventGroupId, resource, resourceBefore);
return Objects.hash(eventGroupId, resource, resourceBefore, resourceReaderAuthorities,
resourceDeniedAuthorities, resourceReaderSecurityControls);
}

@Override
public String toString()
{
final StringBuilder sb = new StringBuilder(500);
sb.append("EventData [eventGroupId=").append(eventGroupId)
.append(", resource=").append(resource)
.append(", resourceBefore=").append(resourceBefore)
.append(']');
.append(", resource=").append(resource)
.append(", resourceBefore=").append(resourceBefore)
.append(", resourceReaderAuthorities=").append(resourceReaderAuthorities)
.append(", resourceDeniedAuthorities=").append(resourceDeniedAuthorities)
.append(", resourceReaderSecurityControls=").append(resourceReaderSecurityControls)
.append(']');
return sb.toString();
}

Expand All @@ -121,9 +158,13 @@ public String toString()
@JsonPOJOBuilder(withPrefix = "set")
public static class Builder<R extends Resource>
{
private String eventGroupId;
private R resource;
private R resourceBefore;

private String eventGroupId;
private R resource;
private R resourceBefore;
private Set<String> resourceReaderAuthorities;
private Set<String> resourceDeniedAuthorities;
private Set<String> resourceReaderSecurityControls;

public Builder<R> setEventGroupId(String eventGroupId)
{
Expand All @@ -143,6 +184,24 @@ public Builder<R> setResourceBefore(R resourceBefore)
return this;
}

public Builder<R> setResourceReaderAuthorities(Set<String> resourceReaderAuthorities)
{
this.resourceReaderAuthorities = resourceReaderAuthorities;
return this;
}

public Builder<R> setResourceDeniedAuthorities(Set<String> resourceDeniedAuthorities)
{
this.resourceDeniedAuthorities = resourceDeniedAuthorities;
return this;
}

public Builder<R> setResourceReaderSecurityControls(Set<String> resourceReaderSecurityControls)
{
this.resourceReaderSecurityControls = resourceReaderSecurityControls;
return this;
}

public EventData<R> build()
{
return new EventData<>(this);
Expand Down
6 changes: 5 additions & 1 deletion src/test/java/org/alfresco/repo/event/util/TestUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,11 @@ public class TestUtil
new Customization("data.resource.aspectNames", ELEMENTS_ORDERING_MATCHER),
new Customization("extensionAttributes.extObject.id", UUID_VALUE_MATCHER),
new Customization("extensionAttributes.extObject.setProp", ELEMENTS_ORDERING_MATCHER),
new Customization("extensionAttributes.extObject.mapProp", ELEMENTS_ORDERING_MATCHER),};
new Customization("extensionAttributes.extObject.mapProp", ELEMENTS_ORDERING_MATCHER),
new Customization("data.resourceReaderAuthorities", TestUtil.ELEMENTS_ORDERING_MATCHER),
new Customization("data.resourceDeniedAuthorities", TestUtil.ELEMENTS_ORDERING_MATCHER),
new Customization("data.resourceReaderSecurityControls", TestUtil.ELEMENTS_ORDERING_MATCHER),
new Customization("extensionAttributes.client.id", TestUtil.UUID_VALUE_MATCHER),};

public static final CustomComparator JSON_COMPARATOR = new CustomComparator(JSONCompareMode.STRICT, CUSTOMIZATIONS);

Expand Down
Loading

0 comments on commit f2ef271

Please sign in to comment.