From 9d4ea6047deb44be1ebd4a1181a068335a57b01e Mon Sep 17 00:00:00 2001
From: Kacper Magdziarz <95610011+kmagdziarz@users.noreply.github.com>
Date: Wed, 27 Nov 2024 16:18:08 +0100
Subject: [PATCH] [ACS-9040] Project refactoring
* Update README.md, add contributing guide
* Update dependencies, switch to Junit Jupiter
* Cleanup POM
* Add dependabot
* Add Spotless
* Update gitignore
---
.github/dependabot.yml | 21 +
.github/workflows/ci.yml | 2 +-
.gitignore | 10 +
README.md | 121 +++--
pom.xml | 315 +++++++-----
.../alfresco/repo/event/EventAttributes.java | 14 +-
.../repo/event/databind/DateSerializer.java | 10 +-
.../event/databind/DateTimeDeserializer.java | 2 +-
.../event/databind/DateTimeSerializer.java | 2 +-
.../event/databind/ExtensionDeserializer.java | 33 +-
.../event/databind/ExtensionSerializer.java | 8 +-
.../event/databind/ObjectMapperFactory.java | 19 +-
.../event/databind/ResourceDeserializer.java | 23 +-
.../event/extension/ExtensionAttributes.java | 18 +-
.../extension/ExtensionAttributesImpl.java | 6 +-
.../repo/event/util/NodeResourceUtils.java | 61 +--
.../event/v1/model/AbstractNodeResource.java | 2 +-
.../repo/event/v1/model/ChildAssocInfo.java | 3 +-
.../v1/model/ChildAssociationResource.java | 10 +-
.../repo/event/v1/model/ContentInfo.java | 17 +-
.../repo/event/v1/model/EventData.java | 6 +-
.../repo/event/v1/model/EventType.java | 23 +-
.../repo/event/v1/model/NodeResource.java | 133 +++--
.../repo/event/v1/model/PeerAssocInfo.java | 3 +-
.../v1/model/PeerAssociationResource.java | 6 +-
.../repo/event/v1/model/RepoEvent.java | 52 +-
.../repo/event/v1/model/Resource.java | 3 +-
.../repo/event/v1/model/UserInfo.java | 9 +-
.../event/util/NodeResourceUtilsTest.java | 108 ++--
.../alfresco/repo/event/util/TestUtil.java | 49 +-
.../repo/event/v1/model/EventTest.java | 473 +++++++++---------
.../repo/event/v1/model/NodeResourceTest.java | 13 +-
.../model/extension/EventExtensionTest.java | 155 +++---
.../schema/ChildAssociationResource.java | 9 +-
.../schema/EventDataWithResourceBefore.java | 7 +-
.../EventDataWithoutResourceBefore.java | 9 +-
.../event/v1/model/schema/NodeResource.java | 33 +-
.../model/schema/PeerAssociationResource.java | 9 +-
.../repo/event/v1/model/schema/RepoEvent.java | 18 +-
.../repo/event/v1/model/schema/Required.java | 4 +-
.../generator/JsonSchemaGeneratorTest.java | 50 +-
41 files changed, 981 insertions(+), 888 deletions(-)
create mode 100644 .github/dependabot.yml
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
new file mode 100644
index 0000000..ebcc078
--- /dev/null
+++ b/.github/dependabot.yml
@@ -0,0 +1,21 @@
+version: 2
+registries:
+ maven-alfresco-internal:
+ type: maven-repository
+ url: https://artifacts.alfresco.com/nexus/content/groups/internal
+ username: ${{secrets.NEXUS_USERNAME}}
+ password: ${{secrets.NEXUS_PASSWORD}}
+updates:
+ - package-ecosystem: "maven"
+ directory: "/"
+ registries:
+ - maven-alfresco-internal
+ schedule:
+ interval: "daily"
+ time: "22:00"
+ timezone: "Europe/London"
+ open-pull-requests-limit: 99
+ - package-ecosystem: "github-actions"
+ directory: "/"
+ schedule:
+ interval: "monthly"
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 20118e6..b326472 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -14,5 +14,5 @@ on:
jobs:
build_and_release:
name: "Build and Release"
- uses: Alfresco/alfresco-build-tools/.github/workflows/build-and-release-maven.yml@v7.0.0
+ uses: Alfresco/alfresco-build-tools/.github/workflows/build-and-release-maven.yml@v8.4.0
secrets: inherit
diff --git a/.gitignore b/.gitignore
index dedf33f..97863b0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -25,6 +25,11 @@ hs_err_pid*
# maven
target/
+*.log.*
+pom.xml.*
+.flattened-pom.xml
+.flattened-pom.xml.*
+release.properties
# IDE
.classpath
@@ -35,3 +40,8 @@ target/
.idea
*.iml
*.ipr
+.gradle
+.history
+
+# Mac
+.DS_Store
diff --git a/README.md b/README.md
index caa460c..8e92aa2 100644
--- a/README.md
+++ b/README.md
@@ -1,48 +1,50 @@
## Alfresco Content Services Event Model
-[![Build Status](https://travis-ci.com/Alfresco/acs-event-model.svg?branch=master)](https://travis-ci.com/Alfresco/acs-event-model)
+
+[![Build Status](https://github.com/Alfresco/acs-event-model/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/Alfresco/acs-event-model/actions/workflows/ci.yml)
Alfresco Content Services Event Model is a library packaged as a jar file which is part of [Alfresco Content Services Repository](https://community.alfresco.com/docs/DOC-6385-project-overview-repository).
The library contains the events models and databind helpers to help the clients to marshall and unmarshall the events.
### Event Object
-| Property | Type | Description |
-|-----------------------|---------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
-| `type` |String | The Alfresco event type. ([1.0 spec#type](https://github.com/cloudevents/spec/blob/v1.0/spec.md#type)) |
-| `specversion` |String | The CloudEvents specification version. Value should be '1.0'. ([1.0 spec#specversion](https://github.com/cloudevents/spec/blob/v1.0/spec.md#specversion)) |
-| `id` |String | Event ID, a UUID generated by the producer ([1.0 spec#id](https://github.com/cloudevents/spec/blob/v1.0/spec.md#id)) |
-| `source` |URI-reference | The instance of a repository that produced the event, .i.e. repository cluster node identifier ([1.0 spec#source](https://github.com/cloudevents/spec/blob/v1.0/spec.md#source)) |
-| `time` |Timestamp | The producer's timestamp of when the event occurred. ([1.0 spec#time](https://github.com/cloudevents/spec/blob/v1.0/spec.md#time)) |
-| `dataschema` |URI-reference | Identifies the schema that data adheres to |
-| `datacontenttype` |String | The content type of the data attribute. Value should be 'application/json'. ([1.0 spec#datacontenttype](https://github.com/cloudevents/spec/blob/v1.0/spec.md#datacontenttype)) |
-| `data` |JSON | The domain-specific data of the event. ([1.0 spec#data](https://github.com/cloudevents/spec/blob/v1.0/spec.md#data-attribute)) |
-| `data.eventGroupId` |String | Optional unique identifier for events group, i.e. a transaction ID |
-| `data.resource` |Object (varies)| The object representing the resource affected |
-| `data.resourceBefore` |Object (varies)| The object representing the old values of the changed resource's attributes. Note, this object is only available on the `Updated` event type |
-| `extensionAttributes` |Object (varies)| (Optional) The object representing extension attributes (if any) that can be additionally added to the event. Note, this object will not be serialized if it is null. | |
-
+| Property | Type | Description |
+|---------------------------------------|-----------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
+| `type` | String | The Alfresco event type. ([1.0 spec#type](https://github.com/cloudevents/spec/blob/v1.0/spec.md#type)) |
+| `specversion` | String | The CloudEvents specification version. Value should be '1.0'. ([1.0 spec#specversion](https://github.com/cloudevents/spec/blob/v1.0/spec.md#specversion)) |
+| `id` | String | Event ID, a UUID generated by the producer ([1.0 spec#id](https://github.com/cloudevents/spec/blob/v1.0/spec.md#id)) |
+| `source` | URI-reference | The instance of a repository that produced the event, .i.e. repository cluster node identifier ([1.0 spec#source](https://github.com/cloudevents/spec/blob/v1.0/spec.md#source)) |
+| `time` | Timestamp | The producer's timestamp of when the event occurred. ([1.0 spec#time](https://github.com/cloudevents/spec/blob/v1.0/spec.md#time)) |
+| `dataschema` | URI-reference | Identifies the schema that data adheres to |
+| `datacontenttype` | String | The content type of the data attribute. Value should be 'application/json'. ([1.0 spec#datacontenttype](https://github.com/cloudevents/spec/blob/v1.0/spec.md#datacontenttype)) |
+| `data` | JSON | The domain-specific data of the event. ([1.0 spec#data](https://github.com/cloudevents/spec/blob/v1.0/spec.md#data-attribute)) |
+| `data.eventGroupId` | String | Optional unique identifier for events group, i.e. a transaction ID |
+| `data.resource` | Object (varies) | The object representing the resource affected |
+| `data.resourceBefore` | Object (varies) | The object representing the old values of the changed resource's attributes. Note, this object is only available on the `Updated` event type |
+| `extensionAttributes` | Object (varies) | (Optional) The object representing extension attributes (if any) that can be additionally added to the event. Note, this object will not be serialized if it is null. |
+| `data.resourceReaderAuthorities` | Array | The authority IDs that have READ access to the resource affected by the event. **Note:** this property will not be present in the event when `authorities generation` is disabled |
+| `data.resourceDeniedAuthorities` | Array | The authority IDs that are denied READ access to the resource affected by the event. **Note:** this property will not be present in the event when `authorities generation` is disabled |
+| `data.resourceReaderSecurityControls` | Array | The Governance security controls that have been placed on the resource affected by the event. **Note:** this property is only available for AGS. Also, it will not be present in the event response when `authorities generation` is disabled or AGS module is not installed |
### Resource Object
-| Property | Type | Description |
-|---------------------------------|---------------|------------------------------------------------------------------|
-|`data.resource.id` |String |The unique ID of the resource, i.e. a node ID|
-|`data.resource.primaryHierarchy` |Array |Optional primary hierarchy of ancestors of the resource affected, i.e. folder path for content. Note that the first element is the immediate parent|
+| Property | Type | Description |
+|----------------------------------|--------|-----------------------------------------------------------------------------------------------------------------------------------------------------|
+| `data.resource.id` | String | The unique ID of the resource, i.e. a node ID |
+| `data.resource.primaryHierarchy` | Array | Optional primary hierarchy of ancestors of the resource affected, i.e. folder path for content. Note that the first element is the immediate parent |
The rest of resource object attributes are self explanatory. See [JSON Schema](#json-schema) for the detailed view of the attributes' types.
### Event Types
-| Name | Description |
-|-----------------------------------|------------------------------------------------------------------|
-| `org.alfresco.event.node.Created` | Occurs when a node is created |
-| `org.alfresco.event.node.Updated` | Occurs when a node is updated or moved. Currently only node's name, type, properties, aspects, and content are supported|
-| `org.alfresco.event.node.Deleted` | Occurs when a node is deleted |
-| `org.alfresco.event.assoc.child.Created` | Occurs when a secondary child association is created |
-| `org.alfresco.event.assoc.child.Deleted` | Occurs when a secondary child association is deleted |
-| `org.alfresco.event.assoc.peer.Created` | Occurs when a peer association is created |
-| `org.alfresco.event.assoc.peer.Deleted` | Occurs when a peer association is deleted |
-
+| Name | Description |
+|------------------------------------------|--------------------------------------------------------------------------------------------------------------------------|
+| `org.alfresco.event.node.Created` | Occurs when a node is created |
+| `org.alfresco.event.node.Updated` | Occurs when a node is updated or moved. Currently only node's name, type, properties, aspects, and content are supported |
+| `org.alfresco.event.node.Deleted` | Occurs when a node is deleted |
+| `org.alfresco.event.assoc.child.Created` | Occurs when a secondary child association is created |
+| `org.alfresco.event.assoc.child.Deleted` | Occurs when a secondary child association is deleted |
+| `org.alfresco.event.assoc.peer.Created` | Occurs when a peer association is created |
+| `org.alfresco.event.assoc.peer.Deleted` | Occurs when a peer association is deleted |
### JSON Schema
@@ -94,6 +96,16 @@ For a detailed view of the event content refer to [Repo Event JSON schema](src/m
"aspectNames": [
"cm:titled",
"cm:auditable"
+ ],
+ "resourceReaderAuthorities": [
+ "GROUP_EVERYONE",
+ "GROUP_site_u1privatesite",
+ "GROUP_site_u1privatesite_SiteConsumer"
+ ],
+ "resourceDeniedAuthorities": [],
+ "resourceReaderSecurityControls": [
+ "e428663f-9171-42e2-b233-d8f2cd3f54f7:m6gFifJH",
+ "e428663f-9171-42e2-b233-d8f2cd3f54f7:mF2foUuA"
]
}
}
@@ -178,7 +190,7 @@ For a detailed view of the event content refer to [Repo Event JSON schema](src/m
}
```
-### Node updated event example - _content changed_
+### Node updated event example - _content changed_
```json
{
@@ -247,7 +259,7 @@ For a detailed view of the event content refer to [Repo Event JSON schema](src/m
}
```
-### Node updated event example - _content added_
+### Node updated event example - _content added_
```json
{
@@ -314,7 +326,7 @@ For a detailed view of the event content refer to [Repo Event JSON schema](src/m
}
```
-### Node updated event example - _node type changed_
+### Node updated event example - _node type changed_
```json
{
@@ -378,7 +390,7 @@ For a detailed view of the event content refer to [Repo Event JSON schema](src/m
}
```
-### Node updated event example - _property added_
+### Node updated event example - _property added_
```json
{
@@ -448,7 +460,7 @@ For a detailed view of the event content refer to [Repo Event JSON schema](src/m
}
```
-### Node updated event example - _property updated_
+### Node updated event example - _property updated_
```json
{
@@ -818,14 +830,17 @@ For a detailed view of the event content refer to [Repo Event JSON schema](src/m
## Building and testing
The project can be built and tested by running the following Maven command:
+
~~~
mvn clean install
~~~
### Artifacts
+
The artifact can be obtained by:
-* downloading from [Alfresco repository](https://artifacts.alfresco.com/nexus/content/groups/public)
+* downloading from [Alfresco repository](https://artifacts.alfresco.com/nexus/#browse/browse:public)
* getting as Maven dependency by adding the dependency to your pom file:
+
~~~
org.alfresco
@@ -833,13 +848,16 @@ The artifact can be obtained by:
version
~~~
+
and Alfresco repository:
+
~~~
alfresco-maven-repo
https://artifacts.alfresco.com/nexus/content/groups/public
~~~
+
**Note:**
The SNAPSHOT version of the artifact is **never** published.
@@ -858,18 +876,37 @@ RepoEvent> result = mapper.readValue(jsonString, new Typ
If the event also has `extensionAttributes` that contains an extension object, then you can use the same mapper to deserialize the extension to its expected object:
```java
- ExtensionAttributes resultExtensionAttributes = result.getExtensionAttributes();
- Object extValue = resultExtensionAttributes.getExtension("Your-Extension-Name");
- YOUR-OBJECT-TYPE obj = mapper.readValue(extValue.toString(), YOUR-OBJECT.class);
+ExtensionAttributes resultExtensionAttributes = result.getExtensionAttributes();
+Object extValue = resultExtensionAttributes.getExtension("Your-Extension-Name");
+YOUR-OBJECT-TYPE obj = mapper.readValue(extValue.toString(), YOUR-OBJECT.class);
```
Other extension types (can only be one of the: **String**, **Number**, **Boolean**) can be retrieved directly without mapper. E.g.
```java
- String myExt = (String) resultExtensionAttributes.getExtension("someStringExt");
+String myExt = (String) resultExtensionAttributes.getExtension("someStringExt");
```
-
### Contributing guide
-Please use [this guide](CONTRIBUTING.md) to make a contribution to the project.
+
+Thanks for your interest in contributing to this project!
+
+The following is a set of guidelines for contributing to this library.
+Most of them will make the life of the reviewer easier and therefore decrease the time required for the patch be included in the next version.
+
+#### Code Quality
+
+This project uses spotless that enforces Alfresco formatting to ensure code quality.
+
+To check code-style violations you can use:
+
+```shell
+mvn spotless:check
+```
+
+To reformat files you can use:
+
+```shell
+mvn spotless:apply
+```
diff --git a/pom.xml b/pom.xml
index 9d6ac34..12875df 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,137 +1,204 @@
- 4.0.0
+ 4.0.0
-
- org.alfresco
- alfresco-super-pom
- 12
-
+
+ org.alfresco
+ alfresco-super-pom
+ 12
+
- acs-event-model
- 1.0.1-SNAPSHOT
- jar
- acs-event-model
- Alfresco Content Services Event Model
+ acs-event-model
+ 1.0.1-SNAPSHOT
+ jar
+ acs-event-model
+ Alfresco Content Services Event Model
-
- 17
- ${java.version}
- ${java.version}
- ${java.version}
- ${java.version}
- 2.17.2
+
+ scm:git:https://github.com/Alfresco/acs-event-model.git
+ scm:git:https://github.com/Alfresco/acs-event-model.git
+ HEAD
+ https://github.com/Alfresco/acs-event-model
+
- 4.12.2
- 2.0.1
-
+
+
+ alfresco-public
+ https://artifacts.alfresco.com/nexus/content/repositories/releases
+
+
-
- scm:git:https://github.com/Alfresco/acs-event-model.git
- scm:git:https://github.com/Alfresco/acs-event-model.git
- https://github.com/Alfresco/acs-event-model
- HEAD
-
+
+ UTF-8
+ UTF-8
-
-
- alfresco-public
- https://artifacts.alfresco.com/nexus/content/repositories/releases
-
-
+ 17
+ ${java.version}
+ ${java.version}
+ ${java.version}
+ ${java.version}
-
-
- com.fasterxml.jackson.core
- jackson-databind
- ${jackson.version}
- provided
-
+ 4.12.2
+ 2.0.1
-
-
- junit
- junit
- 4.13.1
- test
-
-
- org.skyscreamer
- jsonassert
- 1.5.0
- test
-
-
- commons-io
- commons-io
- 2.14.0
- test
-
+ 2.18.0
+ 5.11.3
+ 2.17.0
+ 1.5.3
+ 3.4.2
+ 2.43.0
+
-
-
- com.fasterxml.jackson.module
- jackson-module-jsonSchema
- ${jackson.version}
- test
-
-
- com.github.victools
- jsonschema-generator
- ${jsonschema-generator.version}
- test
-
-
- com.github.victools
- jsonschema-module-jackson
- ${jsonschema-generator.version}
- test
-
-
- org.slf4j
- slf4j-simple
- 1.7.30
- test
-
-
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+ ${dependency.jackson.version}
+ provided
+
-
-
-
- org.codehaus.mojo
- license-maven-plugin
- ${license-maven-plugin.version}
-
-
- third-party-licenses
-
- add-third-party
-
- generate-resources
-
- true
- provided,test
- org.alfresco
- true
- https://raw.githubusercontent.com/Alfresco/third-party-license-overrides/master/includedLicenses.txt
- https://raw.githubusercontent.com/Alfresco/third-party-license-overrides/master/licenseMerges.txt
- https://raw.githubusercontent.com/Alfresco/third-party-license-overrides/master/override-THIRD-PARTY.properties
-
-
-
-
-
- org.apache.maven.plugins
- maven-jar-plugin
- 3.0.2
-
-
-
- test-jar
-
-
-
-
-
-
+
+
+ org.junit.jupiter
+ junit-jupiter
+ ${dependency.junit-jupiter.version}
+ test
+
+
+ org.skyscreamer
+ jsonassert
+ ${dependency.jsonassert.version}
+ test
+
+
+ commons-io
+ commons-io
+ ${dependency.commons-io.version}
+ test
+
+
+
+
+ com.fasterxml.jackson.module
+ jackson-module-jsonSchema
+ ${dependency.jackson.version}
+ test
+
+
+ com.github.victools
+ jsonschema-generator
+ ${jsonschema-generator.version}
+ test
+
+
+ com.github.victools
+ jsonschema-module-jackson
+ ${jsonschema-generator.version}
+ test
+
+
+
+
+
+
+ org.codehaus.mojo
+ license-maven-plugin
+ ${license-maven-plugin.version}
+
+
+ third-party-licenses
+
+ add-third-party
+
+ generate-resources
+
+ true
+ provided,test
+ org.alfresco
+ true
+ https://raw.githubusercontent.com/Alfresco/third-party-license-overrides/master/includedLicenses.txt
+ https://raw.githubusercontent.com/Alfresco/third-party-license-overrides/master/licenseMerges.txt
+ https://raw.githubusercontent.com/Alfresco/third-party-license-overrides/master/override-THIRD-PARTY.properties
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+ ${dependency.maven-jar-plugin.version}
+
+
+
+ test-jar
+
+
+
+
+
+ org.codehaus.mojo
+ flatten-maven-plugin
+
+ minimum
+
+
+
+ flatten
+
+ flatten
+
+ process-resources
+
+
+ flatten.clean
+
+ clean
+
+ clean
+
+
+
+
+ com.diffplug.spotless
+ spotless-maven-plugin
+ ${dependency.spotless-maven-plugin.version}
+
+
+
+ https://raw.githubusercontent.com/Alfresco/alfresco-community-repo/refs/heads/master/alfresco-formatter.xml
+
+
+ \#java|\#javax|\#jakarta,\#,\#org.alfresco,java|javax|jakarta,,org.alfresco
+
+
+
+
+
+
+ pom.xml
+
+
+ false
+ true
+
+
+
+
+ *.md
+
+
+
+
+
+
+
+ check
+
+ compile
+
+
+
+
+
+
diff --git a/src/main/java/org/alfresco/repo/event/EventAttributes.java b/src/main/java/org/alfresco/repo/event/EventAttributes.java
index b9c7c75..7cadc67 100644
--- a/src/main/java/org/alfresco/repo/event/EventAttributes.java
+++ b/src/main/java/org/alfresco/repo/event/EventAttributes.java
@@ -31,8 +31,7 @@
import org.alfresco.repo.event.extension.ExtensionAttributes;
/**
- * Event's attributes conforming to
- * CloudEvents v1.0 specification.
+ * Event's attributes conforming to CloudEvents v1.0 specification.
*
* @author Jamal Kaabi-Mofrad
*/
@@ -49,8 +48,7 @@ public interface EventAttributes
String getType();
/**
- * @return The context in which an event happened.
- * E.g. The instance of a DBP component that produced the event.
+ * @return The context in which an event happened. E.g. The instance of a DBP component that produced the event.
*/
URI getSource();
@@ -70,15 +68,13 @@ public interface EventAttributes
ZonedDateTime getTime();
/**
- * @return The content type of the data attribute adhering
- * to the RFC2046
+ * @return The content type of the data attribute adhering to the RFC2046
*/
String getDatacontenttype();
/**
- * @return Optional extension attributes that can be additionally added to the event.
- *
- * See CloudEvents v1.0 specification Extension Context Attributes for more details.
+ * @return Optional extension attributes that can be additionally added to the event.
+ * See CloudEvents v1.0 specification Extension Context Attributes for more details.
*/
default ExtensionAttributes getExtensionAttributes()
{
diff --git a/src/main/java/org/alfresco/repo/event/databind/DateSerializer.java b/src/main/java/org/alfresco/repo/event/databind/DateSerializer.java
index 552734e..2961e23 100644
--- a/src/main/java/org/alfresco/repo/event/databind/DateSerializer.java
+++ b/src/main/java/org/alfresco/repo/event/databind/DateSerializer.java
@@ -15,15 +15,15 @@
*/
package org.alfresco.repo.event.databind;
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.databind.SerializerProvider;
-import com.fasterxml.jackson.databind.ser.std.StdSerializer;
-
import java.io.IOException;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.util.Date;
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.ser.std.StdSerializer;
+
public class DateSerializer extends StdSerializer
{
@@ -41,7 +41,7 @@ public void serialize(Date date, JsonGenerator jsonGenerator, SerializerProvider
throws IOException
{
ZonedDateTime zonedDateTime = ZonedDateTime.ofInstant(date.toInstant(), ZoneOffset.UTC);
- //delegating the formatting to the DateTimeSerializer in order to apply the same strategy
+ // delegating the formatting to the DateTimeSerializer in order to apply the same strategy
dateTimeSerializer.serialize(zonedDateTime, jsonGenerator, serializerProvider);
}
}
diff --git a/src/main/java/org/alfresco/repo/event/databind/DateTimeDeserializer.java b/src/main/java/org/alfresco/repo/event/databind/DateTimeDeserializer.java
index 602a89e..934ab3e 100644
--- a/src/main/java/org/alfresco/repo/event/databind/DateTimeDeserializer.java
+++ b/src/main/java/org/alfresco/repo/event/databind/DateTimeDeserializer.java
@@ -55,7 +55,7 @@ public DateTimeDeserializer(Class> valueClass)
@Override
public ZonedDateTime deserialize(JsonParser jsonParser, DeserializationContext deserializationContext)
- throws IOException
+ throws IOException
{
try
{
diff --git a/src/main/java/org/alfresco/repo/event/databind/DateTimeSerializer.java b/src/main/java/org/alfresco/repo/event/databind/DateTimeSerializer.java
index f9d3b5c..efaacd0 100644
--- a/src/main/java/org/alfresco/repo/event/databind/DateTimeSerializer.java
+++ b/src/main/java/org/alfresco/repo/event/databind/DateTimeSerializer.java
@@ -55,7 +55,7 @@ protected DateTimeSerializer(Class> t, boolean dummy)
@Override
public void serialize(ZonedDateTime zonedDateTime, JsonGenerator jsonGenerator,
- SerializerProvider serializerProvider) throws IOException
+ SerializerProvider serializerProvider) throws IOException
{
jsonGenerator.writeString(zonedDateTime.format(DateTimeFormatter.ISO_OFFSET_DATE_TIME));
}
diff --git a/src/main/java/org/alfresco/repo/event/databind/ExtensionDeserializer.java b/src/main/java/org/alfresco/repo/event/databind/ExtensionDeserializer.java
index 4d7bcfb..8e1cbb3 100644
--- a/src/main/java/org/alfresco/repo/event/databind/ExtensionDeserializer.java
+++ b/src/main/java/org/alfresco/repo/event/databind/ExtensionDeserializer.java
@@ -27,15 +27,15 @@
import java.io.IOException;
-import org.alfresco.repo.event.extension.ExtensionAttributes;
-import org.alfresco.repo.event.extension.ExtensionAttributesImpl;
-
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.ObjectCodec;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonNode;
+import org.alfresco.repo.event.extension.ExtensionAttributes;
+import org.alfresco.repo.event.extension.ExtensionAttributesImpl;
+
/**
* Custom Jackson deserializer for the {@link ExtensionAttributes} type.
*
@@ -44,8 +44,7 @@
public class ExtensionDeserializer extends JsonDeserializer
{
public ExtensionDeserializer()
- {
- }
+ {}
@Override
public ExtensionAttributes deserialize(JsonParser parser, DeserializationContext ctxt) throws IOException
@@ -61,21 +60,19 @@ public ExtensionAttributes deserialize(JsonParser parser, DeserializationContext
switch (extValue.getNodeType())
{
- case STRING:
- extension.addExtension(extName, extValue.textValue());
- break;
- case NUMBER:
- extension.addExtension(extName, extValue.numberValue());
- break;
- case BOOLEAN:
- extension.addExtension(extName, extValue.booleanValue());
- break;
- default:
- extension.addExtension(extName, extValue.toString());
+ case STRING:
+ extension.addExtension(extName, extValue.textValue());
+ break;
+ case NUMBER:
+ extension.addExtension(extName, extValue.numberValue());
+ break;
+ case BOOLEAN:
+ extension.addExtension(extName, extValue.booleanValue());
+ break;
+ default:
+ extension.addExtension(extName, extValue.toString());
}
});
return extension;
}
}
-
-
diff --git a/src/main/java/org/alfresco/repo/event/databind/ExtensionSerializer.java b/src/main/java/org/alfresco/repo/event/databind/ExtensionSerializer.java
index ba1f855..d7e0433 100644
--- a/src/main/java/org/alfresco/repo/event/databind/ExtensionSerializer.java
+++ b/src/main/java/org/alfresco/repo/event/databind/ExtensionSerializer.java
@@ -27,12 +27,12 @@
import java.io.IOException;
-import org.alfresco.repo.event.extension.ExtensionAttributes;
-
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
+import org.alfresco.repo.event.extension.ExtensionAttributes;
+
/**
* Custom Jackson serializer for the {@link ExtensionAttributes} type.
*
@@ -47,7 +47,7 @@ protected ExtensionSerializer()
@Override
public void serialize(ExtensionAttributes eventExtension, JsonGenerator jsonGenerator,
- SerializerProvider serializerProvider) throws IOException
+ SerializerProvider serializerProvider) throws IOException
{
jsonGenerator.writeStartObject();
for (String ext : eventExtension.getExtensionNames())
@@ -59,5 +59,3 @@ public void serialize(ExtensionAttributes eventExtension, JsonGenerator jsonGene
jsonGenerator.writeEndObject();
}
}
-
-
diff --git a/src/main/java/org/alfresco/repo/event/databind/ObjectMapperFactory.java b/src/main/java/org/alfresco/repo/event/databind/ObjectMapperFactory.java
index e4621ba..c9464e7 100644
--- a/src/main/java/org/alfresco/repo/event/databind/ObjectMapperFactory.java
+++ b/src/main/java/org/alfresco/repo/event/databind/ObjectMapperFactory.java
@@ -25,20 +25,21 @@
*/
package org.alfresco.repo.event.databind;
+import java.time.ZonedDateTime;
+import java.util.Date;
+
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.databind.module.SimpleAbstractTypeResolver;
import com.fasterxml.jackson.databind.module.SimpleModule;
+
+import org.alfresco.repo.event.extension.ExtensionAttributes;
+import org.alfresco.repo.event.extension.ExtensionAttributesImpl;
import org.alfresco.repo.event.v1.model.DataAttributes;
import org.alfresco.repo.event.v1.model.EventData;
import org.alfresco.repo.event.v1.model.Resource;
-import org.alfresco.repo.event.extension.ExtensionAttributes;
-import org.alfresco.repo.event.extension.ExtensionAttributesImpl;
-
-import java.time.ZonedDateTime;
-import java.util.Date;
/**
* Repo Event object factory.
@@ -61,10 +62,9 @@ public ObjectMapper createObjectMapper()
final SimpleModule module = getSimpleModule();
final SimpleAbstractTypeResolver resolver = getSimpleAbstractTypeResolver();
- if(resolver != null)
+ if (resolver != null)
{
- // add the extension when creating the Mapper. As 'getSimpleAbstractTypeResolver' can be
- // overridden by enterprise code.
+ // add the extension when creating the Mapper.
resolver.addMapping(ExtensionAttributes.class, ExtensionAttributesImpl.class);
module.setAbstractTypes(resolver);
}
@@ -75,8 +75,7 @@ public ObjectMapper createObjectMapper()
protected SimpleModule getSimpleModule()
{
- final SimpleModule module =
- new SimpleModule("Resource Serializer-Deserializer", new Version(0, 1, 0, "", "", ""));
+ final SimpleModule module = new SimpleModule("Resource Serializer-Deserializer", new Version(0, 1, 0, "", "", ""));
module.addSerializer(ZonedDateTime.class, new DateTimeSerializer());
module.addDeserializer(ZonedDateTime.class, new DateTimeDeserializer());
module.addSerializer(Date.class, new DateSerializer());
diff --git a/src/main/java/org/alfresco/repo/event/databind/ResourceDeserializer.java b/src/main/java/org/alfresco/repo/event/databind/ResourceDeserializer.java
index 5207722..5ef5c88 100644
--- a/src/main/java/org/alfresco/repo/event/databind/ResourceDeserializer.java
+++ b/src/main/java/org/alfresco/repo/event/databind/ResourceDeserializer.java
@@ -28,11 +28,6 @@
import java.io.IOException;
import java.util.Map;
-import org.alfresco.repo.event.v1.model.ChildAssociationResource;
-import org.alfresco.repo.event.v1.model.NodeResource;
-import org.alfresco.repo.event.v1.model.PeerAssociationResource;
-import org.alfresco.repo.event.v1.model.Resource;
-
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.ObjectCodec;
import com.fasterxml.jackson.core.TreeNode;
@@ -41,20 +36,24 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.TextNode;
+import org.alfresco.repo.event.v1.model.ChildAssociationResource;
+import org.alfresco.repo.event.v1.model.NodeResource;
+import org.alfresco.repo.event.v1.model.PeerAssociationResource;
+import org.alfresco.repo.event.v1.model.Resource;
+
/**
* @author Jamal Kaabi-Mofrad
*/
public class ResourceDeserializer extends JsonDeserializer
{
- private static final String TYPE_FIELD = "@type";
- private static final Map> TYPE_MAP = Map.of(
- getName(NodeResource.class), NodeResource.class,
- getName(ChildAssociationResource.class), ChildAssociationResource.class,
- getName(PeerAssociationResource.class), PeerAssociationResource.class);
+ private static final String TYPE_FIELD = "@type";
+ private static final Map> TYPE_MAP = Map.of(
+ getName(NodeResource.class), NodeResource.class,
+ getName(ChildAssociationResource.class), ChildAssociationResource.class,
+ getName(PeerAssociationResource.class), PeerAssociationResource.class);
public ResourceDeserializer()
- {
- }
+ {}
private static String getName(Class aClass)
{
diff --git a/src/main/java/org/alfresco/repo/event/extension/ExtensionAttributes.java b/src/main/java/org/alfresco/repo/event/extension/ExtensionAttributes.java
index 2e7d625..3aa6ec5 100644
--- a/src/main/java/org/alfresco/repo/event/extension/ExtensionAttributes.java
+++ b/src/main/java/org/alfresco/repo/event/extension/ExtensionAttributes.java
@@ -36,15 +36,15 @@ public interface ExtensionAttributes
{
/**
- * Gets the extension value. The value's type can only be one of the following types:
- *
+ * Gets the extension value. The value's type can only be one of the following types:
*
- * - String
- * - Number
- * - Boolean
+ * - String
+ * - Number
+ * - Boolean
*
*
- * @param extensionName the extension name (i.e. Json field name)
+ * @param extensionName
+ * the extension name (i.e. Json field name)
* @return the extension value
*/
Object getExtension(String extensionName);
@@ -52,8 +52,10 @@ public interface ExtensionAttributes
/**
* Adds extension
*
- * @param extensionName the extension name (i.e. key)
- * @param extension the extension value
+ * @param extensionName
+ * the extension name (i.e. key)
+ * @param extension
+ * the extension value
*/
void addExtension(String extensionName, Object extension);
diff --git a/src/main/java/org/alfresco/repo/event/extension/ExtensionAttributesImpl.java b/src/main/java/org/alfresco/repo/event/extension/ExtensionAttributesImpl.java
index bba3a28..6f31a11 100644
--- a/src/main/java/org/alfresco/repo/event/extension/ExtensionAttributesImpl.java
+++ b/src/main/java/org/alfresco/repo/event/extension/ExtensionAttributesImpl.java
@@ -30,12 +30,12 @@
import java.util.Objects;
import java.util.Set;
-import org.alfresco.repo.event.databind.ExtensionDeserializer;
-import org.alfresco.repo.event.databind.ExtensionSerializer;
-
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import org.alfresco.repo.event.databind.ExtensionDeserializer;
+import org.alfresco.repo.event.databind.ExtensionSerializer;
+
/**
* @author Jamal Kaabi-Mofrad
*/
diff --git a/src/main/java/org/alfresco/repo/event/util/NodeResourceUtils.java b/src/main/java/org/alfresco/repo/event/util/NodeResourceUtils.java
index abbb559..ddc7eed 100644
--- a/src/main/java/org/alfresco/repo/event/util/NodeResourceUtils.java
+++ b/src/main/java/org/alfresco/repo/event/util/NodeResourceUtils.java
@@ -26,39 +26,42 @@
package org.alfresco.repo.event.util;
-import org.alfresco.repo.event.v1.model.NodeResource;
-
import java.util.Objects;
+import org.alfresco.repo.event.v1.model.NodeResource;
+
public final class NodeResourceUtils
{
- private NodeResourceUtils() {}
+ private NodeResourceUtils()
+ {}
- /**
- * From a NodeResource
, creates a NodeResource.Builder
filled with all NodeResource
information
- *
- * @param nodeResource to be used to copy information from
- * @return a NodeResource.Builder
filled with nodeResource information
- */
- public static NodeResource.Builder getFilledBuilder( NodeResource nodeResource ) {
- Objects.requireNonNull(nodeResource);
+ /**
+ * From a NodeResource
, creates a NodeResource.Builder
filled with all NodeResource
information
+ *
+ * @param nodeResource
+ * to be used to copy information from
+ * @return a NodeResource.Builder
filled with nodeResource information
+ */
+ public static NodeResource.Builder getFilledBuilder(NodeResource nodeResource)
+ {
+ Objects.requireNonNull(nodeResource);
- return new NodeResource.Builder()
- .setAspectNames(nodeResource.getAspectNames())
- .setContent(nodeResource.getContent())
- .setCreatedAt(nodeResource.getCreatedAt())
- .setId(nodeResource.getId())
- .setIsFile(nodeResource.isFile())
- .setCreatedByUser(nodeResource.getCreatedByUser())
- .setIsFolder(nodeResource.isFolder())
- .setLocalizedProperties(nodeResource.getLocalizedProperties())
- .setModifiedAt(nodeResource.getModifiedAt())
- .setModifiedByUser(nodeResource.getModifiedByUser())
- .setName(nodeResource.getName())
- .setNodeType(nodeResource.getNodeType())
- .setPrimaryAssocQName(nodeResource.getPrimaryAssocQName())
- .setPrimaryHierarchy(nodeResource.getPrimaryHierarchy())
- .setProperties(nodeResource.getProperties())
- .setSecondaryParents(nodeResource.getSecondaryParents());
- }
+ return new NodeResource.Builder()
+ .setAspectNames(nodeResource.getAspectNames())
+ .setContent(nodeResource.getContent())
+ .setCreatedAt(nodeResource.getCreatedAt())
+ .setId(nodeResource.getId())
+ .setIsFile(nodeResource.isFile())
+ .setCreatedByUser(nodeResource.getCreatedByUser())
+ .setIsFolder(nodeResource.isFolder())
+ .setLocalizedProperties(nodeResource.getLocalizedProperties())
+ .setModifiedAt(nodeResource.getModifiedAt())
+ .setModifiedByUser(nodeResource.getModifiedByUser())
+ .setName(nodeResource.getName())
+ .setNodeType(nodeResource.getNodeType())
+ .setPrimaryAssocQName(nodeResource.getPrimaryAssocQName())
+ .setPrimaryHierarchy(nodeResource.getPrimaryHierarchy())
+ .setProperties(nodeResource.getProperties())
+ .setSecondaryParents(nodeResource.getSecondaryParents());
+ }
}
diff --git a/src/main/java/org/alfresco/repo/event/v1/model/AbstractNodeResource.java b/src/main/java/org/alfresco/repo/event/v1/model/AbstractNodeResource.java
index b0d0097..2cbdb6e 100644
--- a/src/main/java/org/alfresco/repo/event/v1/model/AbstractNodeResource.java
+++ b/src/main/java/org/alfresco/repo/event/v1/model/AbstractNodeResource.java
@@ -78,7 +78,7 @@ public boolean equals(Object o)
}
AbstractNodeResource resource = (AbstractNodeResource) o;
return Objects.equals(id, resource.id)
- && Objects.equals(primaryHierarchy, resource.primaryHierarchy);
+ && Objects.equals(primaryHierarchy, resource.primaryHierarchy);
}
@Override
diff --git a/src/main/java/org/alfresco/repo/event/v1/model/ChildAssocInfo.java b/src/main/java/org/alfresco/repo/event/v1/model/ChildAssocInfo.java
index c16c94d..784814c 100644
--- a/src/main/java/org/alfresco/repo/event/v1/model/ChildAssocInfo.java
+++ b/src/main/java/org/alfresco/repo/event/v1/model/ChildAssocInfo.java
@@ -35,8 +35,7 @@ public class ChildAssocInfo
private String id;
public ChildAssocInfo()
- {
- }
+ {}
public ChildAssocInfo(String id)
{
diff --git a/src/main/java/org/alfresco/repo/event/v1/model/ChildAssociationResource.java b/src/main/java/org/alfresco/repo/event/v1/model/ChildAssociationResource.java
index 7dbb8a1..3cdc029 100644
--- a/src/main/java/org/alfresco/repo/event/v1/model/ChildAssociationResource.java
+++ b/src/main/java/org/alfresco/repo/event/v1/model/ChildAssociationResource.java
@@ -60,7 +60,7 @@ public ChildAssocInfo getChild()
return child;
}
- public String getAssocQName()
+ public String getAssocQName()
{
return assocQName;
}
@@ -95,10 +95,10 @@ public String toString()
{
final StringBuilder sb = new StringBuilder(100);
sb.append("ChildAssociationResource [parent=").append(parent)
- .append(", child=").append(child)
- .append(", assocType=").append(assocType)
- .append(", assocQName=").append(assocQName)
- .append(']');
+ .append(", child=").append(child)
+ .append(", assocType=").append(assocType)
+ .append(", assocQName=").append(assocQName)
+ .append(']');
return sb.toString();
}
}
diff --git a/src/main/java/org/alfresco/repo/event/v1/model/ContentInfo.java b/src/main/java/org/alfresco/repo/event/v1/model/ContentInfo.java
index d863412..07e2307 100644
--- a/src/main/java/org/alfresco/repo/event/v1/model/ContentInfo.java
+++ b/src/main/java/org/alfresco/repo/event/v1/model/ContentInfo.java
@@ -33,16 +33,15 @@
/**
* @author Jamal Kaabi-Mofrad
*/
-@JsonInclude (Include.NON_NULL)
+@JsonInclude(Include.NON_NULL)
public class ContentInfo
{
private String mimeType;
- private Long sizeInBytes;
+ private Long sizeInBytes;
private String encoding;
public ContentInfo()
- {
- }
+ {}
public ContentInfo(String mimeType, Long sizeInBytes, String encoding)
{
@@ -79,8 +78,8 @@ public boolean equals(Object o)
}
ContentInfo that = (ContentInfo) o;
return Objects.equals(mimeType, that.mimeType)
- && Objects.equals(sizeInBytes, that.sizeInBytes)
- && Objects.equals(encoding, that.encoding);
+ && Objects.equals(sizeInBytes, that.sizeInBytes)
+ && Objects.equals(encoding, that.encoding);
}
@Override
@@ -94,9 +93,9 @@ public String toString()
{
final StringBuilder sb = new StringBuilder(100);
sb.append("ContentInfo [mimeType=").append(mimeType)
- .append(", sizeInBytes=").append(sizeInBytes)
- .append(", encoding=").append(encoding)
- .append(']');
+ .append(", sizeInBytes=").append(sizeInBytes)
+ .append(", encoding=").append(encoding)
+ .append(']');
return sb.toString();
}
}
diff --git a/src/main/java/org/alfresco/repo/event/v1/model/EventData.java b/src/main/java/org/alfresco/repo/event/v1/model/EventData.java
index 864e963..4aa11b7 100644
--- a/src/main/java/org/alfresco/repo/event/v1/model/EventData.java
+++ b/src/main/java/org/alfresco/repo/event/v1/model/EventData.java
@@ -159,9 +159,9 @@ public String toString()
public static class Builder
{
- private String eventGroupId;
- private R resource;
- private R resourceBefore;
+ private String eventGroupId;
+ private R resource;
+ private R resourceBefore;
private Set resourceReaderAuthorities;
private Set resourceDeniedAuthorities;
private Set resourceReaderSecurityControls;
diff --git a/src/main/java/org/alfresco/repo/event/v1/model/EventType.java b/src/main/java/org/alfresco/repo/event/v1/model/EventType.java
index 39dd357..1dff24f 100644
--- a/src/main/java/org/alfresco/repo/event/v1/model/EventType.java
+++ b/src/main/java/org/alfresco/repo/event/v1/model/EventType.java
@@ -32,10 +32,7 @@
*/
public enum EventType
{
- NODE_CREATED(EventTypeConst.CREATED, ContextType.NODE), NODE_UPDATED(EventTypeConst.UPDATED, ContextType.NODE), NODE_DELETED(EventTypeConst.DELETED, ContextType.NODE),
- CHILD_ASSOC_CREATED(EventTypeConst.CREATED, ContextType.CHILD_ASSOC), CHILD_ASSOC_DELETED(EventTypeConst.DELETED, ContextType.CHILD_ASSOC),
- PEER_ASSOC_CREATED(EventTypeConst.CREATED, ContextType.PEER_ASSOC), PEER_ASSOC_DELETED(EventTypeConst.DELETED, ContextType.PEER_ASSOC),
- PERMISSION_UPDATED(EventTypeConst.UPDATED, ContextType.PERMISSION);
+ NODE_CREATED(EventTypeConst.CREATED, ContextType.NODE), NODE_UPDATED(EventTypeConst.UPDATED, ContextType.NODE), NODE_DELETED(EventTypeConst.DELETED, ContextType.NODE), CHILD_ASSOC_CREATED(EventTypeConst.CREATED, ContextType.CHILD_ASSOC), CHILD_ASSOC_DELETED(EventTypeConst.DELETED, ContextType.CHILD_ASSOC), PEER_ASSOC_CREATED(EventTypeConst.CREATED, ContextType.PEER_ASSOC), PEER_ASSOC_DELETED(EventTypeConst.DELETED, ContextType.PEER_ASSOC), PERMISSION_UPDATED(EventTypeConst.UPDATED, ContextType.PERMISSION);
private static final String PREFIX = "org.alfresco.event.";
private final String type;
@@ -43,19 +40,19 @@ public enum EventType
EventType(String type, ContextType contextType)
{
- this.type = type;
- this.contextType = contextType;
+ this.type = type;
+ this.contextType = contextType;
}
- /* package*/ String getContext()
+ /* package */ String getContext()
{
- return contextType.getContext();
+ return contextType.getContext();
}
@Override
public String toString()
{
- return PREFIX + getContext() + type;
+ return PREFIX + getContext() + type;
}
/**
@@ -73,15 +70,16 @@ private enum ContextType
NODE("node."), CHILD_ASSOC("assoc.child."), PEER_ASSOC("assoc.peer."), PERMISSION("permission.");
private final String context;
+
ContextType(String context)
{
this.context = context;
}
String getContext()
- {
- return context;
- }
+ {
+ return context;
+ }
}
private static class EventTypeConst
@@ -91,4 +89,3 @@ private static class EventTypeConst
private static final String DELETED = "Deleted";
}
}
-
diff --git a/src/main/java/org/alfresco/repo/event/v1/model/NodeResource.java b/src/main/java/org/alfresco/repo/event/v1/model/NodeResource.java
index 7021677..989b31b 100644
--- a/src/main/java/org/alfresco/repo/event/v1/model/NodeResource.java
+++ b/src/main/java/org/alfresco/repo/event/v1/model/NodeResource.java
@@ -29,7 +29,6 @@
import java.io.Serializable;
import java.time.ZonedDateTime;
-import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@@ -42,8 +41,7 @@
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
/**
- * Represents Alfresco node resource.
- * Any attribute that its value is null, will not be serialized.
+ * Represents Alfresco node resource. Any attribute that its value is null, will not be serialized.
*
* @author Jamal Kaabi-Mofrad
*/
@@ -51,20 +49,20 @@
@JsonDeserialize(builder = NodeResource.Builder.class)
public class NodeResource extends AbstractNodeResource
{
- private final String name;
- private final String nodeType;
- private final Boolean isFile;
- private final Boolean isFolder;
- private final UserInfo createdByUser;
- private final ZonedDateTime createdAt;
- private final UserInfo modifiedByUser;
- private final ZonedDateTime modifiedAt;
- private final ContentInfo content;
- private final Map properties;
- private final Map> localizedProperties;
- private final Set aspectNames;
- private final String primaryAssocQName;
- private final List secondaryParents;
+ private final String name;
+ private final String nodeType;
+ private final Boolean isFile;
+ private final Boolean isFolder;
+ private final UserInfo createdByUser;
+ private final ZonedDateTime createdAt;
+ private final UserInfo modifiedByUser;
+ private final ZonedDateTime modifiedAt;
+ private final ContentInfo content;
+ private final Map properties;
+ private final Map> localizedProperties;
+ private final Set aspectNames;
+ private final String primaryAssocQName;
+ private final List secondaryParents;
private NodeResource(Builder builder)
{
@@ -152,7 +150,8 @@ public Set getAspectNames()
return aspectNames;
}
- public String getPrimaryAssocQName() {
+ public String getPrimaryAssocQName()
+ {
return primaryAssocQName;
}
@@ -178,26 +177,26 @@ public boolean equals(Object o)
}
NodeResource that = (NodeResource) o;
return Objects.equals(name, that.name)
- && Objects.equals(nodeType, that.nodeType)
- && Objects.equals(isFile, that.isFile)
- && Objects.equals(isFolder, that.isFolder)
- && Objects.equals(createdByUser, that.createdByUser)
- && Objects.equals(createdAt, that.createdAt)
- && Objects.equals(modifiedByUser, that.modifiedByUser)
- && Objects.equals(modifiedAt, that.modifiedAt)
- && Objects.equals(content, that.content)
- && Objects.equals(properties, that.properties)
- && Objects.equals(localizedProperties, that.localizedProperties)
- && Objects.equals(aspectNames, that.aspectNames)
- && Objects.equals(secondaryParents, that.secondaryParents);
+ && Objects.equals(nodeType, that.nodeType)
+ && Objects.equals(isFile, that.isFile)
+ && Objects.equals(isFolder, that.isFolder)
+ && Objects.equals(createdByUser, that.createdByUser)
+ && Objects.equals(createdAt, that.createdAt)
+ && Objects.equals(modifiedByUser, that.modifiedByUser)
+ && Objects.equals(modifiedAt, that.modifiedAt)
+ && Objects.equals(content, that.content)
+ && Objects.equals(properties, that.properties)
+ && Objects.equals(localizedProperties, that.localizedProperties)
+ && Objects.equals(aspectNames, that.aspectNames)
+ && Objects.equals(secondaryParents, that.secondaryParents);
}
@Override
public int hashCode()
{
return Objects.hash(super.hashCode(), name, nodeType, isFile, isFolder, createdByUser,
- createdAt, modifiedByUser, modifiedAt, content, properties,
- localizedProperties, aspectNames, primaryAssocQName, secondaryParents);
+ createdAt, modifiedByUser, modifiedAt, content, properties,
+ localizedProperties, aspectNames, primaryAssocQName, secondaryParents);
}
@Override
@@ -205,22 +204,22 @@ public String toString()
{
final StringBuilder sb = new StringBuilder(500);
sb.append("NodeResource [id=").append(id)
- .append(", name=").append(name)
- .append(", nodeType=").append(nodeType)
- .append(", isFile=").append(isFile)
- .append(", isFolder=").append(isFolder)
- .append(", createdByUser=").append(createdByUser)
- .append(", createdAt=").append(createdAt)
- .append(", modifiedByUser=").append(modifiedByUser)
- .append(", modifiedAt=").append(modifiedAt)
- .append(", content=").append(content)
- .append(", properties=").append(properties)
- .append(", localizedProperties=").append(localizedProperties)
- .append(", aspectNames=").append(aspectNames)
- .append(", primaryHierarchy=").append(primaryHierarchy)
- .append(", primaryAssocQName=").append(primaryAssocQName)
- .append(", secondaryParents=").append(secondaryParents)
- .append(']');
+ .append(", name=").append(name)
+ .append(", nodeType=").append(nodeType)
+ .append(", isFile=").append(isFile)
+ .append(", isFolder=").append(isFolder)
+ .append(", createdByUser=").append(createdByUser)
+ .append(", createdAt=").append(createdAt)
+ .append(", modifiedByUser=").append(modifiedByUser)
+ .append(", modifiedAt=").append(modifiedAt)
+ .append(", content=").append(content)
+ .append(", properties=").append(properties)
+ .append(", localizedProperties=").append(localizedProperties)
+ .append(", aspectNames=").append(aspectNames)
+ .append(", primaryHierarchy=").append(primaryHierarchy)
+ .append(", primaryAssocQName=").append(primaryAssocQName)
+ .append(", secondaryParents=").append(secondaryParents)
+ .append(']');
return sb.toString();
}
@@ -231,31 +230,31 @@ public String toString()
@JsonPOJOBuilder(withPrefix = "set")
public static class Builder
{
- private String id;
- private String name;
- private String nodeType;
- private Boolean isFile;
- private Boolean isFolder;
- private UserInfo createdByUser;
- private ZonedDateTime createdAt;
- private UserInfo modifiedByUser;
- private ZonedDateTime modifiedAt;
- private List primaryHierarchy;
- private ContentInfo content;
- private Map properties;
- private Map> localizedProperties;
- private Set aspectNames;
- private String primaryAssocQName;
- private List secondaryParents;
+ private String id;
+ private String name;
+ private String nodeType;
+ private Boolean isFile;
+ private Boolean isFolder;
+ private UserInfo createdByUser;
+ private ZonedDateTime createdAt;
+ private UserInfo modifiedByUser;
+ private ZonedDateTime modifiedAt;
+ private List primaryHierarchy;
+ private ContentInfo content;
+ private Map properties;
+ private Map> localizedProperties;
+ private Set aspectNames;
+ private String primaryAssocQName;
+ private List secondaryParents;
public Builder()
- {
- }
+ {}
/**
* Copy builder
*
- * @param that existing {@code Builder} object
+ * @param that
+ * existing {@code Builder} object
*/
public Builder(Builder that)
{
diff --git a/src/main/java/org/alfresco/repo/event/v1/model/PeerAssocInfo.java b/src/main/java/org/alfresco/repo/event/v1/model/PeerAssocInfo.java
index 1583efc..69620bf 100644
--- a/src/main/java/org/alfresco/repo/event/v1/model/PeerAssocInfo.java
+++ b/src/main/java/org/alfresco/repo/event/v1/model/PeerAssocInfo.java
@@ -36,8 +36,7 @@ public class PeerAssocInfo
private String id;
public PeerAssocInfo()
- {
- }
+ {}
public PeerAssocInfo(String id)
{
diff --git a/src/main/java/org/alfresco/repo/event/v1/model/PeerAssociationResource.java b/src/main/java/org/alfresco/repo/event/v1/model/PeerAssociationResource.java
index d368823..44c1221 100644
--- a/src/main/java/org/alfresco/repo/event/v1/model/PeerAssociationResource.java
+++ b/src/main/java/org/alfresco/repo/event/v1/model/PeerAssociationResource.java
@@ -87,9 +87,9 @@ public String toString()
{
final StringBuilder sb = new StringBuilder(100);
sb.append("PeerAssociationResource [source=").append(source)
- .append(", target=").append(target)
- .append(", assocType=").append(assocType)
- .append(']');
+ .append(", target=").append(target)
+ .append(", assocType=").append(assocType)
+ .append(']');
return sb.toString();
}
}
diff --git a/src/main/java/org/alfresco/repo/event/v1/model/RepoEvent.java b/src/main/java/org/alfresco/repo/event/v1/model/RepoEvent.java
index d3d82cd..a00d9ea 100644
--- a/src/main/java/org/alfresco/repo/event/v1/model/RepoEvent.java
+++ b/src/main/java/org/alfresco/repo/event/v1/model/RepoEvent.java
@@ -29,14 +29,14 @@
import java.time.ZonedDateTime;
import java.util.Objects;
-import org.alfresco.repo.event.EventAttributes;
-import org.alfresco.repo.event.extension.ExtensionAttributes;
-
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
+import org.alfresco.repo.event.EventAttributes;
+import org.alfresco.repo.event.extension.ExtensionAttributes;
+
/**
* Represents Alfresco event.
*
@@ -48,13 +48,13 @@ public class RepoEvent> implements
private static final String SPEC_VERSION = "1.0";
private static final String CONTENT_TYPE = "application/json";
- private final String specversion;
- private final String type;
- private final String id;
- private final URI source;
+ private final String specversion;
+ private final String type;
+ private final String id;
+ private final URI source;
private final ZonedDateTime time;
- private final URI dataschema;
- private final String datacontenttype;
+ private final URI dataschema;
+ private final String datacontenttype;
private final D data;
private final ExtensionAttributes extensionAttributes;
@@ -144,14 +144,14 @@ public boolean equals(Object o)
}
RepoEvent> repoEvent = (RepoEvent>) o;
return Objects.equals(specversion, repoEvent.specversion)
- && Objects.equals(type, repoEvent.type)
- && Objects.equals(id, repoEvent.id)
- && Objects.equals(source, repoEvent.source)
- && Objects.equals(dataschema, repoEvent.dataschema)
- && Objects.equals(time, repoEvent.time)
- && Objects.equals(datacontenttype, repoEvent.datacontenttype)
- && Objects.equals(data, repoEvent.data)
- && Objects.equals(extensionAttributes, repoEvent.extensionAttributes);
+ && Objects.equals(type, repoEvent.type)
+ && Objects.equals(id, repoEvent.id)
+ && Objects.equals(source, repoEvent.source)
+ && Objects.equals(dataschema, repoEvent.dataschema)
+ && Objects.equals(time, repoEvent.time)
+ && Objects.equals(datacontenttype, repoEvent.datacontenttype)
+ && Objects.equals(data, repoEvent.data)
+ && Objects.equals(extensionAttributes, repoEvent.extensionAttributes);
}
@Override
@@ -165,15 +165,15 @@ public String toString()
{
final StringBuilder sb = new StringBuilder(250);
sb.append("RepoEvent [specversion=").append(specversion)
- .append(", type=").append(type)
- .append(", id=").append(id)
- .append(", source=").append(source)
- .append(", time=").append(time)
- .append(", dataschema=").append(dataschema)
- .append(", datacontenttype=").append(datacontenttype)
- .append(", data=").append(data)
- .append(", extensionAttributes=").append(extensionAttributes)
- .append(']');
+ .append(", type=").append(type)
+ .append(", id=").append(id)
+ .append(", source=").append(source)
+ .append(", time=").append(time)
+ .append(", dataschema=").append(dataschema)
+ .append(", datacontenttype=").append(datacontenttype)
+ .append(", data=").append(data)
+ .append(", extensionAttributes=").append(extensionAttributes)
+ .append(']');
return sb.toString();
}
diff --git a/src/main/java/org/alfresco/repo/event/v1/model/Resource.java b/src/main/java/org/alfresco/repo/event/v1/model/Resource.java
index 509246d..f180749 100644
--- a/src/main/java/org/alfresco/repo/event/v1/model/Resource.java
+++ b/src/main/java/org/alfresco/repo/event/v1/model/Resource.java
@@ -31,5 +31,4 @@
* @author Jamal Kaabi-Mofrad
*/
public interface Resource
-{
-}
+{}
diff --git a/src/main/java/org/alfresco/repo/event/v1/model/UserInfo.java b/src/main/java/org/alfresco/repo/event/v1/model/UserInfo.java
index 8f0871d..e0f3dff 100644
--- a/src/main/java/org/alfresco/repo/event/v1/model/UserInfo.java
+++ b/src/main/java/org/alfresco/repo/event/v1/model/UserInfo.java
@@ -36,8 +36,7 @@ public class UserInfo
private String displayName;
public UserInfo()
- {
- }
+ {}
public UserInfo(String id, String firstName, String lastName)
{
@@ -68,7 +67,7 @@ public boolean equals(Object o)
}
UserInfo userInfo = (UserInfo) o;
return Objects.equals(id, userInfo.id)
- && Objects.equals(displayName, userInfo.displayName);
+ && Objects.equals(displayName, userInfo.displayName);
}
@Override
@@ -82,8 +81,8 @@ public String toString()
{
final StringBuilder sb = new StringBuilder(100);
sb.append("UserInfo [id=").append(id)
- .append(", displayName=").append(displayName)
- .append(']');
+ .append(", displayName=").append(displayName)
+ .append(']');
return sb.toString();
}
diff --git a/src/test/java/org/alfresco/repo/event/util/NodeResourceUtilsTest.java b/src/test/java/org/alfresco/repo/event/util/NodeResourceUtilsTest.java
index 5c73026..eb7503c 100644
--- a/src/test/java/org/alfresco/repo/event/util/NodeResourceUtilsTest.java
+++ b/src/test/java/org/alfresco/repo/event/util/NodeResourceUtilsTest.java
@@ -26,10 +26,16 @@
package org.alfresco.repo.event.util;
-import org.alfresco.repo.event.v1.model.ContentInfo;
-import org.alfresco.repo.event.v1.model.NodeResource;
-import org.alfresco.repo.event.v1.model.UserInfo;
-import org.junit.Test;
+import static java.util.Locale.ENGLISH;
+import static java.util.Locale.GERMAN;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.fail;
+
+import static org.alfresco.repo.event.util.TestUtil.getSecondaryParents;
+import static org.alfresco.repo.event.util.TestUtil.getTestNodePrimaryHierarchy;
+import static org.alfresco.repo.event.util.TestUtil.getUUID;
import java.lang.reflect.Field;
import java.time.ZonedDateTime;
@@ -37,60 +43,56 @@
import java.util.Map;
import java.util.Set;
-import static java.util.Locale.ENGLISH;
-import static java.util.Locale.GERMAN;
+import org.junit.jupiter.api.Test;
-import static org.alfresco.repo.event.util.TestUtil.getSecondaryParents;
-import static org.alfresco.repo.event.util.TestUtil.getTestNodePrimaryHierarchy;
-import static org.alfresco.repo.event.util.TestUtil.getUUID;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
+import org.alfresco.repo.event.v1.model.ContentInfo;
+import org.alfresco.repo.event.v1.model.NodeResource;
+import org.alfresco.repo.event.v1.model.UserInfo;
public class NodeResourceUtilsTest
{
- @Test
- public void nodeResource_createCopyFromBuilder()
- {
- // GIVEN: a nodeResource with all fields setup
- NodeResource originalResource = NodeResource.builder()
- .setId(getUUID())
- .setName("testFile.txt")
- .setPrimaryHierarchy(getTestNodePrimaryHierarchy())
- .setIsFile(true)
- .setIsFolder(false)
- .setNodeType("cm:content")
- .setPrimaryAssocQName("cm:testFile.txt")
- .setCreatedByUser(new UserInfo("john.doe", "John", "Doe"))
- .setCreatedAt(ZonedDateTime.now())
- .setModifiedByUser(new UserInfo("jane.doe", "Jane", "Doe"))
- .setModifiedAt(ZonedDateTime.now())
- .setProperties(Map.of("cm:title", "test title", "cm:from", new Date(-2637887000L)))
- .setLocalizedProperties(Map.of("cm:description",
- Map.of(GERMAN.getLanguage(), "ruf mich an", ENGLISH.getLanguage(), "call me")))
- .setAspectNames(Set.of("cm:titled", "cm:auditable"))
- .setContent(new ContentInfo("text/plain", 16L, "UTF-8"))
- .setSecondaryParents(getSecondaryParents())
- .build();
+ @Test
+ public void nodeResource_createCopyFromBuilder()
+ {
+ // GIVEN: a nodeResource with all fields setup
+ NodeResource originalResource = NodeResource.builder()
+ .setId(getUUID())
+ .setName("testFile.txt")
+ .setPrimaryHierarchy(getTestNodePrimaryHierarchy())
+ .setIsFile(true)
+ .setIsFolder(false)
+ .setNodeType("cm:content")
+ .setPrimaryAssocQName("cm:testFile.txt")
+ .setCreatedByUser(new UserInfo("john.doe", "John", "Doe"))
+ .setCreatedAt(ZonedDateTime.now())
+ .setModifiedByUser(new UserInfo("jane.doe", "Jane", "Doe"))
+ .setModifiedAt(ZonedDateTime.now())
+ .setProperties(Map.of("cm:title", "test title", "cm:from", new Date(-2637887000L)))
+ .setLocalizedProperties(Map.of("cm:description",
+ Map.of(GERMAN.getLanguage(), "ruf mich an", ENGLISH.getLanguage(), "call me")))
+ .setAspectNames(Set.of("cm:titled", "cm:auditable"))
+ .setContent(new ContentInfo("text/plain", 16L, "UTF-8"))
+ .setSecondaryParents(getSecondaryParents())
+ .build();
- // asserts that all fields have information (are non-null)
- try
- {
- for (Field field : NodeResource.class.getDeclaredFields())
- {
- field.setAccessible(true);
- assertNotNull(field.get(originalResource));
- }
- }
- catch( IllegalAccessException exception )
- {
- fail("all fields should be accessible in this test");
- }
+ // asserts that all fields have information (are non-null)
+ try
+ {
+ for (Field field : NodeResource.class.getDeclaredFields())
+ {
+ field.setAccessible(true);
+ assertNotNull(field.get(originalResource));
+ }
+ }
+ catch (IllegalAccessException exception)
+ {
+ fail("all fields should be accessible in this test");
+ }
- // WHEN: a new nodeResource is created based on the original nodeResource
- final NodeResource copiedResource = NodeResourceUtils.getFilledBuilder(originalResource).build();
+ // WHEN: a new nodeResource is created based on the original nodeResource
+ final NodeResource copiedResource = NodeResourceUtils.getFilledBuilder(originalResource).build();
- // THEN: the new nodeResource must have the same information as the original one
- assertEquals(originalResource, copiedResource);
- }
+ // THEN: the new nodeResource must have the same information as the original one
+ assertEquals(originalResource, copiedResource);
+ }
}
diff --git a/src/test/java/org/alfresco/repo/event/util/TestUtil.java b/src/test/java/org/alfresco/repo/event/util/TestUtil.java
index 3ba4545..38ac387 100644
--- a/src/test/java/org/alfresco/repo/event/util/TestUtil.java
+++ b/src/test/java/org/alfresco/repo/event/util/TestUtil.java
@@ -37,7 +37,7 @@
import java.util.UUID;
import java.util.regex.Pattern;
-import org.alfresco.repo.event.databind.ObjectMapperFactory;
+import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.io.IOUtils;
import org.json.JSONException;
import org.skyscreamer.jsonassert.Customization;
@@ -46,7 +46,7 @@
import org.skyscreamer.jsonassert.ValueMatcher;
import org.skyscreamer.jsonassert.comparator.CustomComparator;
-import com.fasterxml.jackson.databind.ObjectMapper;
+import org.alfresco.repo.event.databind.ObjectMapperFactory;
/**
* @author Jamal Kaabi-Mofrad
@@ -56,9 +56,9 @@ public class TestUtil
public static final ObjectMapper OBJECT_MAPPER = ObjectMapperFactory.createInstance();
public static final Pattern UUID_PATTERN = Pattern.compile(
- "[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}");
+ "[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}");
public static final Pattern DATE_TIME_PATTERN = Pattern.compile(
- "^([0-9]+)-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])[Tt]([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]|60)(\\.[0-9]+)?(([Zz])|([+|\\-]([01][0-9]|2[0-3]):[0-5][0-9]))$");
+ "^([0-9]+)-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])[Tt]([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]|60)(\\.[0-9]+)?(([Zz])|([+|\\-]([01][0-9]|2[0-3]):[0-5][0-9]))$");
public static final ValueMatcher