diff --git a/.checkstyle b/.checkstyle
deleted file mode 100644
index 15ff199..0000000
--- a/.checkstyle
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/checkstyle.xml b/checkstyle.xml
deleted file mode 100644
index 052d3c4..0000000
--- a/checkstyle.xml
+++ /dev/null
@@ -1,117 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/ies-4-contentrepository-core-cs-cleanup.xml b/ies-4-contentrepository-core-cs-cleanup.xml
deleted file mode 100644
index 57b9c20..0000000
--- a/ies-4-contentrepository-core-cs-cleanup.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
diff --git a/ies-4-contentrepository-core-cs-formatter.xml b/ies-4-contentrepository-core-cs-formatter.xml
deleted file mode 100644
index 3f398f2..0000000
--- a/ies-4-contentrepository-core-cs-formatter.xml
+++ /dev/null
@@ -1,149 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/pom.xml b/pom.xml
index ce5074c..39fefb9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,3 +1,4 @@
+
4.0.0
@@ -7,6 +8,11 @@
IES Content Repository Core
IES contentrepository domain und use-case implementations
+
+ Sitepark
+ https://www.sitepark.com
+
+
The MIT License
@@ -14,11 +20,6 @@
-
- Sitepark
- https://www.sitepark.com
-
-
veltrup@sitepark
@@ -34,6 +35,13 @@
+
+ scm:git:git@github.com:sitepark/ies-contentrepository-core.git
+ scm:git:git@github.com:sitepark/ies-contentrepository-core.git
+ HEAD
+ https://github.com/sitepark/ies-contentrepository-core
+
+
5.10.2
4.8.3
@@ -42,13 +50,6 @@
true
-
- scm:git:git@github.com:sitepark/ies-contentrepository-core.git
- scm:git:git@github.com:sitepark/ies-contentrepository-core.git
- https://github.com/sitepark/ies-contentrepository-core
- HEAD
-
-
@@ -213,10 +214,10 @@
sign-artifacts
- verify
sign
+ verify
@@ -224,7 +225,7 @@
maven-release-plugin
3.0.1
- ci(release):
+ ci(release):
@{project.version}
@@ -232,6 +233,13 @@
org.apache.maven.plugins
maven-enforcer-plugin
3.4.1
+
+
+ io.github.thefolle
+ glowing-waffle
+ 1.2.0
+
+
enforce-maven
@@ -240,7 +248,7 @@
-
+
3.8
@@ -252,30 +260,22 @@
verify-release
- none
enforce
+ none
false
No Snapshots Allowed!
-
+
true
-
-
- io.github.thefolle
- glowing-waffle
- 1.2.0
-
-
org.jacoco
@@ -310,47 +310,78 @@
generate-code-coverage-report
- test
report
+ test
- org.apache.maven.plugins
- maven-checkstyle-plugin
- 3.3.1
+ com.diffplug.spotless
+ spotless-maven-plugin
+ 2.43.0
- checkstyle.xml
- UTF-8
- true
- true
- false
+
+
+
+ google-java-format
+
+
+
+
+ 1.19.2
+
+ true
+ false
+
+
+
+
+
+
+ pom.xml
+
+
+
+ -1
+
+
- checkstyle
- verify
+ spotless-check
check
+ verify
-
+
+ org.eclipse.m2e
+ lifecycle-mapping
+ 1.0.0
+
+
+
+
+
+ com.diffplug.spotless
+ spotless-maven-plugin
+
+
+
+
+
+
+
+
+
com.github.spotbugs
spotbugs-maven-plugin
4.8.3.0
-
-
- verify
-
- check
-
-
-
Max
Low
@@ -367,20 +398,19 @@
${spotbugs.version}
-
-
- org.apache.maven.plugins
- maven-pmd-plugin
- 3.21.2
- pmd
- verify
check
+ verify
+
+
+ org.apache.maven.plugins
+ maven-pmd-plugin
+ 3.21.2
pmd-ruleset.xml
@@ -389,9 +419,19 @@
true
5
true
- false
+ false
+
+
+
+ pmd
+
+ check
+
+ verify
+
+
-
\ No newline at end of file
+
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/databind/DatabindModule.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/databind/DatabindModule.java
index da5f6f9..7fcdf73 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/databind/DatabindModule.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/databind/DatabindModule.java
@@ -6,9 +6,9 @@
public class DatabindModule extends SimpleModule {
- private static final long serialVersionUID = 1L;
+ private static final long serialVersionUID = 1L;
- public DatabindModule() {
- super.addDeserializer(Filter.class, new FilterDeserializer());
- }
+ public DatabindModule() {
+ super.addDeserializer(Filter.class, new FilterDeserializer());
+ }
}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/databind/UniquePropertyPolymorphicDeserializer.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/databind/UniquePropertyPolymorphicDeserializer.java
index d6e0322..af7fcd1 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/databind/UniquePropertyPolymorphicDeserializer.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/databind/UniquePropertyPolymorphicDeserializer.java
@@ -1,17 +1,16 @@
package com.sitepark.ies.contentrepository.core.domain.databind;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Map.Entry;
-
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
import com.fasterxml.jackson.databind.node.ObjectNode;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
/**
* Deserializes documents without a specific field designated for
@@ -20,47 +19,48 @@
*/
public class UniquePropertyPolymorphicDeserializer extends StdDeserializer {
- private static final long serialVersionUID = 1L;
+ private static final long serialVersionUID = 1L;
- // the registry of unique field names to Class types
- private final Map> registry;
+ // the registry of unique field names to Class types
+ private final Map> registry;
- public UniquePropertyPolymorphicDeserializer(Class clazz) {
- super(clazz);
- this.registry = new HashMap>();
- }
+ public UniquePropertyPolymorphicDeserializer(Class clazz) {
+ super(clazz);
+ this.registry = new HashMap>();
+ }
- public void register(String uniqueProperty, Class extends T> clazz) {
- this.registry.put(uniqueProperty, clazz);
- }
+ public void register(String uniqueProperty, Class extends T> clazz) {
+ this.registry.put(uniqueProperty, clazz);
+ }
- /*
- * (non-Javadoc)
- *
- * @see com.fasterxml.jackson.databind.JsonDeserializer#deserialize(com.fasterxml.jackson.core.JsonParser,
- * com.fasterxml.jackson.databind.DeserializationContext)
- */
- @Override
- public T deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
- Class extends T> clazz = null;
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.fasterxml.jackson.databind.JsonDeserializer#deserialize(com.fasterxml.jackson.core.JsonParser,
+ * com.fasterxml.jackson.databind.DeserializationContext)
+ */
+ @Override
+ public T deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
+ Class extends T> clazz = null;
- ObjectMapper mapper = (ObjectMapper) jp.getCodec();
- ObjectNode obj = (ObjectNode) mapper.readTree(jp);
- Iterator> elementsIterator = obj.fields();
+ ObjectMapper mapper = (ObjectMapper) jp.getCodec();
+ ObjectNode obj = (ObjectNode) mapper.readTree(jp);
+ Iterator> elementsIterator = obj.fields();
- while (elementsIterator.hasNext()) {
- Entry element = elementsIterator.next();
- String name = element.getKey();
- if (registry.containsKey(name)) {
- clazz = registry.get(name);
- break;
- }
- }
+ while (elementsIterator.hasNext()) {
+ Entry element = elementsIterator.next();
+ String name = element.getKey();
+ if (registry.containsKey(name)) {
+ clazz = registry.get(name);
+ break;
+ }
+ }
- if (clazz == null) {
- ctxt.reportInputMismatch(this, "No registered unique properties found for polymorphic deserialization");
- }
+ if (clazz == null) {
+ ctxt.reportInputMismatch(
+ this, "No registered unique properties found for polymorphic deserialization");
+ }
- return mapper.treeToValue(obj, clazz);
- }
+ return mapper.treeToValue(obj, clazz);
+ }
}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/Anchor.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/Anchor.java
index ccc5ecf..a5b52d8 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/Anchor.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/Anchor.java
@@ -1,88 +1,83 @@
package com.sitepark.ies.contentrepository.core.domain.entity;
-
+import com.fasterxml.jackson.annotation.JsonValue;
+import com.sitepark.ies.contentrepository.core.domain.exception.InvalidAnchorException;
import java.io.Serializable;
import java.util.Objects;
import java.util.regex.Pattern;
-import com.fasterxml.jackson.annotation.JsonValue;
-import com.sitepark.ies.contentrepository.core.domain.exception.InvalidAnchorException;
-
public final class Anchor implements Serializable {
- private static final long serialVersionUID = 1L;
-
- public static final String VALID_CHARS_REGEX = "[a-zA-Z0-9_.\\-]+";
+ private static final long serialVersionUID = 1L;
- private static final Pattern VALIDATOR_PATTERN = Pattern.compile(VALID_CHARS_REGEX);
+ public static final String VALID_CHARS_REGEX = "[a-zA-Z0-9_.\\-]+";
- private static final Pattern ONLY_NUMBERS_PATTERN = Pattern.compile("[0-9]+");
+ private static final Pattern VALIDATOR_PATTERN = Pattern.compile(VALID_CHARS_REGEX);
- /**
- * Used to reset anchor when saving entries.
- */
- public static final Anchor EMPTY = new Anchor("");
+ private static final Pattern ONLY_NUMBERS_PATTERN = Pattern.compile("[0-9]+");
- @JsonValue
- private final String name;
+ /**
+ * Used to reset anchor when saving entries.
+ */
+ public static final Anchor EMPTY = new Anchor("");
- private Anchor(String name) {
- this.name = name;
- }
+ @JsonValue private final String name;
- public static Anchor ofString(String name) {
+ private Anchor(String name) {
+ this.name = name;
+ }
- if (name == null) {
- return null;
- }
+ public static Anchor ofString(String name) {
- if (name.isBlank()) {
- return EMPTY;
- }
+ if (name == null) {
+ return null;
+ }
- Anchor.validate(name);
- return new Anchor(name);
- }
+ if (name.isBlank()) {
+ return EMPTY;
+ }
- public String getName() {
- return this.name;
- }
+ Anchor.validate(name);
+ return new Anchor(name);
+ }
- /**
- * @throws InvalidAnchorException
- */
- private static void validate(String name) {
+ public String getName() {
+ return this.name;
+ }
- if (ONLY_NUMBERS_PATTERN.matcher(name).matches()) {
- throw new InvalidAnchorException(name, "Anchor must not only consist of numbers");
- }
+ /**
+ * @throws InvalidAnchorException
+ */
+ private static void validate(String name) {
- if (!VALIDATOR_PATTERN.matcher(name).matches()) {
- throw new InvalidAnchorException(
- name,
- "Anchor contains invalid characters. Allowd are: " + VALID_CHARS_REGEX);
- }
- }
+ if (ONLY_NUMBERS_PATTERN.matcher(name).matches()) {
+ throw new InvalidAnchorException(name, "Anchor must not only consist of numbers");
+ }
- @Override
- public int hashCode() {
- return this.name != null ? this.name.hashCode() : 0;
- }
+ if (!VALIDATOR_PATTERN.matcher(name).matches()) {
+ throw new InvalidAnchorException(
+ name, "Anchor contains invalid characters. Allowd are: " + VALID_CHARS_REGEX);
+ }
+ }
+ @Override
+ public int hashCode() {
+ return this.name != null ? this.name.hashCode() : 0;
+ }
- @Override
- public boolean equals(Object o) {
+ @Override
+ public boolean equals(Object o) {
- if (!(o instanceof Anchor)) {
- return false;
- }
+ if (!(o instanceof Anchor)) {
+ return false;
+ }
- Anchor anchor = (Anchor)o;
- return Objects.equals(this.name, anchor.name);
- }
+ Anchor anchor = (Anchor) o;
+ return Objects.equals(this.name, anchor.name);
+ }
- @Override
- public String toString() {
- return this == EMPTY ? "EMPTY" : this.name;
- }
+ @Override
+ public String toString() {
+ return this == EMPTY ? "EMPTY" : this.name;
+ }
}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/BulkOperationKey.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/BulkOperationKey.java
index 9e9fdf2..0a95e5e 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/BulkOperationKey.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/BulkOperationKey.java
@@ -1,19 +1,18 @@
package com.sitepark.ies.contentrepository.core.domain.entity;
public enum BulkOperationKey {
+ PURGE_LOCK("contentrepository.purge.lock"),
+ PURGE_DEPUBLISH("contentrepository.purge.depublish"),
+ PURGE_PURGE("contentrepository.purge.purge"),
+ PURGE_CLEANUP("contentrepository.purge.cleanup");
- PURGE_LOCK("contentrepository.purge.lock"),
- PURGE_DEPUBLISH("contentrepository.purge.depublish"),
- PURGE_PURGE("contentrepository.purge.purge"),
- PURGE_CLEANUP("contentrepository.purge.cleanup");
+ private final String name;
- private final String name;
+ private BulkOperationKey(String name) {
+ this.name = name;
+ }
- private BulkOperationKey(String name) {
- this.name = name;
- }
-
- public String getName() {
- return this.name;
- }
+ public String getName() {
+ return this.name;
+ }
}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/ChangeSet.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/ChangeSet.java
index e6d8dc9..9637b90 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/ChangeSet.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/ChangeSet.java
@@ -1,7 +1,7 @@
package com.sitepark.ies.contentrepository.core.domain.entity;
public class ChangeSet {
- public boolean isEmpty() {
- return true;
- }
+ public boolean isEmpty() {
+ return true;
+ }
}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/Entity.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/Entity.java
index 9908cff..81a1635 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/Entity.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/Entity.java
@@ -1,199 +1,202 @@
package com.sitepark.ies.contentrepository.core.domain.entity;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
import java.time.OffsetDateTime;
import java.util.Objects;
import java.util.Optional;
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
-
@JsonDeserialize(builder = Entity.EntityBuilder.class)
public class Entity {
- private final String id;
- private final Anchor anchor;
- private final String name;
- private final String parent;
- private final OffsetDateTime version;
- private final boolean isGroup;
-
- protected Entity(Builder> builder) {
- this.id = builder.id;
- this.anchor = builder.anchor;
- this.name = builder.name;
- this.parent = builder.parent;
- this.version = builder.version;
- this.isGroup = builder.isGroup;
- }
-
- public Optional getId() {
- if (this.id == null) {
- return Optional.empty();
- } else {
- return Optional.of(this.id);
- }
- }
-
- public Optional getAnchor() {
- return Optional.ofNullable(this.anchor);
- }
-
- public Optional getName() {
- return Optional.ofNullable(this.name);
- }
-
- public Optional getParent() {
- if (this.parent == null) {
- return Optional.empty();
- } else {
- return Optional.of(this.parent);
- }
- }
-
- public Optional getVersion() {
- if (this.version == null) {
- return Optional.empty();
- } else {
- return Optional.of(this.version);
- }
- }
-
- public boolean isGroup() {
- return this.isGroup;
- }
-
- public static Builder> builder() {
- return new EntityBuilder();
- }
-
- public Builder> toBuilder() {
- return new EntityBuilder(this);
- }
-
- @Override
- public final int hashCode() {
-
- return Objects.hash(
- this.id,
- this.anchor,
- this.name,
- this.parent,
- this.version,
- this.isGroup);
- }
-
- @Override
- public final boolean equals(Object o) {
-
- if (!(o instanceof Entity)) {
- return false;
- }
-
- Entity that = (Entity)o;
-
- return Objects.equals(this.id, that.id) &&
- Objects.equals(this.anchor, that.anchor) &&
- Objects.equals(this.name, that.name) &&
- Objects.equals(this.parent, that.parent) &&
- Objects.equals(this.version, that.version) &&
- Objects.equals(this.isGroup, that.isGroup);
- }
-
- @Override
- public String toString() {
- return "Entity [id=" + id + ", anchor=" + anchor + ", name=" + name + ", parent=" + parent + ", version="
- + version + ", isGroup=" + isGroup + "]";
- }
-
- public static abstract class Builder> {
-
- private String id;
- private Anchor anchor;
- private String name;
- private String parent;
- private OffsetDateTime version;
- private boolean isGroup;
-
- protected Builder() {
- }
-
- protected Builder(Entity entity) {
- this.id = entity.id;
- this.anchor = entity.anchor;
- this.name = entity.name;
- this.parent = entity.parent;
- this.version = entity.version;
- this.isGroup = entity.isGroup;
- }
-
- public B id(String id) {
- Objects.requireNonNull(id, "id is null");
- if (!Identifier.isId(id)) {
- throw new IllegalArgumentException(id + " is not an id");
- }
- this.id = id;
- return this.self();
- }
-
- public B anchor(String anchor) {
- Objects.requireNonNull(anchor, "anchor is null");
- this.anchor = Anchor.ofString(anchor);
- return this.self();
- }
-
- public B anchor(Anchor anchor) {
- Objects.requireNonNull(anchor, "anchor is null");
- this.anchor = anchor;
- return this.self();
- }
-
- public B name(String name) {
- Objects.requireNonNull(name, "name is null");
- if (name.isBlank()) {
- throw new IllegalArgumentException("name is blank");
- }
- this.name = name;
- return this.self();
- }
-
- public B parent(String parent) {
- Objects.requireNonNull(parent, "parent is null");
- if (!Identifier.isId(parent)) {
- throw new IllegalArgumentException(parent + " is not an id");
- }
- this.parent = parent;
- return this.self();
- }
-
- public B version(OffsetDateTime version) {
- Objects.requireNonNull(version, "version is null");
- this.version = version;
- return this.self();
- }
-
- public B isGroup(boolean isGroup) {
- this.isGroup = isGroup;
- return this.self();
- }
-
- protected abstract B self();
-
- public Entity build() {
- return new Entity(this);
- }
- }
-
- @JsonPOJOBuilder(withPrefix = "", buildMethodName = "build")
- protected static class EntityBuilder extends Builder {
- protected EntityBuilder() {}
-
- protected EntityBuilder(Entity entity) {
- super(entity);
- }
-
- @Override
- protected EntityBuilder self() {
- return this;
- }
- }
+ private final String id;
+ private final Anchor anchor;
+ private final String name;
+ private final String parent;
+ private final OffsetDateTime version;
+ private final boolean isGroup;
+
+ protected Entity(Builder> builder) {
+ this.id = builder.id;
+ this.anchor = builder.anchor;
+ this.name = builder.name;
+ this.parent = builder.parent;
+ this.version = builder.version;
+ this.isGroup = builder.isGroup;
+ }
+
+ public Optional getId() {
+ if (this.id == null) {
+ return Optional.empty();
+ } else {
+ return Optional.of(this.id);
+ }
+ }
+
+ public Optional getAnchor() {
+ return Optional.ofNullable(this.anchor);
+ }
+
+ public Optional getName() {
+ return Optional.ofNullable(this.name);
+ }
+
+ public Optional getParent() {
+ if (this.parent == null) {
+ return Optional.empty();
+ } else {
+ return Optional.of(this.parent);
+ }
+ }
+
+ public Optional getVersion() {
+ if (this.version == null) {
+ return Optional.empty();
+ } else {
+ return Optional.of(this.version);
+ }
+ }
+
+ public boolean isGroup() {
+ return this.isGroup;
+ }
+
+ public static Builder> builder() {
+ return new EntityBuilder();
+ }
+
+ public Builder> toBuilder() {
+ return new EntityBuilder(this);
+ }
+
+ @Override
+ public final int hashCode() {
+
+ return Objects.hash(this.id, this.anchor, this.name, this.parent, this.version, this.isGroup);
+ }
+
+ @Override
+ public final boolean equals(Object o) {
+
+ if (!(o instanceof Entity)) {
+ return false;
+ }
+
+ Entity that = (Entity) o;
+
+ return Objects.equals(this.id, that.id)
+ && Objects.equals(this.anchor, that.anchor)
+ && Objects.equals(this.name, that.name)
+ && Objects.equals(this.parent, that.parent)
+ && Objects.equals(this.version, that.version)
+ && Objects.equals(this.isGroup, that.isGroup);
+ }
+
+ @Override
+ public String toString() {
+ return "Entity [id="
+ + id
+ + ", anchor="
+ + anchor
+ + ", name="
+ + name
+ + ", parent="
+ + parent
+ + ", version="
+ + version
+ + ", isGroup="
+ + isGroup
+ + "]";
+ }
+
+ public abstract static class Builder> {
+
+ private String id;
+ private Anchor anchor;
+ private String name;
+ private String parent;
+ private OffsetDateTime version;
+ private boolean isGroup;
+
+ protected Builder() {}
+
+ protected Builder(Entity entity) {
+ this.id = entity.id;
+ this.anchor = entity.anchor;
+ this.name = entity.name;
+ this.parent = entity.parent;
+ this.version = entity.version;
+ this.isGroup = entity.isGroup;
+ }
+
+ public B id(String id) {
+ Objects.requireNonNull(id, "id is null");
+ if (!Identifier.isId(id)) {
+ throw new IllegalArgumentException(id + " is not an id");
+ }
+ this.id = id;
+ return this.self();
+ }
+
+ public B anchor(String anchor) {
+ Objects.requireNonNull(anchor, "anchor is null");
+ this.anchor = Anchor.ofString(anchor);
+ return this.self();
+ }
+
+ public B anchor(Anchor anchor) {
+ Objects.requireNonNull(anchor, "anchor is null");
+ this.anchor = anchor;
+ return this.self();
+ }
+
+ public B name(String name) {
+ Objects.requireNonNull(name, "name is null");
+ if (name.isBlank()) {
+ throw new IllegalArgumentException("name is blank");
+ }
+ this.name = name;
+ return this.self();
+ }
+
+ public B parent(String parent) {
+ Objects.requireNonNull(parent, "parent is null");
+ if (!Identifier.isId(parent)) {
+ throw new IllegalArgumentException(parent + " is not an id");
+ }
+ this.parent = parent;
+ return this.self();
+ }
+
+ public B version(OffsetDateTime version) {
+ Objects.requireNonNull(version, "version is null");
+ this.version = version;
+ return this.self();
+ }
+
+ public B isGroup(boolean isGroup) {
+ this.isGroup = isGroup;
+ return this.self();
+ }
+
+ protected abstract B self();
+
+ public Entity build() {
+ return new Entity(this);
+ }
+ }
+
+ @JsonPOJOBuilder(withPrefix = "", buildMethodName = "build")
+ protected static class EntityBuilder extends Builder {
+ protected EntityBuilder() {}
+
+ protected EntityBuilder(Entity entity) {
+ super(entity);
+ }
+
+ @Override
+ protected EntityBuilder self() {
+ return this;
+ }
+ }
}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/EntityBulkExecution.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/EntityBulkExecution.java
index 9b5e85a..2632ae8 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/EntityBulkExecution.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/EntityBulkExecution.java
@@ -1,5 +1,6 @@
package com.sitepark.ies.contentrepository.core.domain.entity;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -7,128 +8,122 @@
import java.util.Objects;
import java.util.Optional;
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-
public class EntityBulkExecution {
- private final String[] topic;
-
- private final List operations;
-
- private final EntityBulkOperation finalizer;
-
- protected EntityBulkExecution(Builder builder) {
- this.topic = builder.topic;
- this.operations = Collections.unmodifiableList(builder.operations);
- this.finalizer = builder.finalizer;
- }
-
- @SuppressFBWarnings("EI_EXPOSE_REP")
- public String[] getTopic() {
- return this.topic.clone();
- }
-
- @SuppressFBWarnings("EI_EXPOSE_REP")
- public List getOperations() {
- return this.operations;
- }
-
- public Optional getFinalizer() {
- return Optional.ofNullable(this.finalizer);
- }
-
- @Override
- public final int hashCode() {
- return Objects.hash(
- Arrays.hashCode(this.topic),
- this.operations,
- this.finalizer);
- }
-
-
- @Override
- public final boolean equals(Object o) {
-
- if (!(o instanceof EntityBulkExecution)) {
- return false;
- }
-
- EntityBulkExecution execution = (EntityBulkExecution)o;
-
- return Arrays.equals(this.topic, execution.topic) &&
- Objects.equals(this.operations, execution.operations) &&
- Objects.equals(this.finalizer, execution.finalizer);
- }
-
- @Override
- public String toString() {
- StringBuilder b = new StringBuilder(100)
- .append("EntityBulkExecution[topic:")
- .append(Arrays.toString(this.topic))
- .append(", operations:")
- .append(this.operations)
- .append(", finalizer:")
- .append(this.finalizer)
- .append(']');
- return b.toString();
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- public static class Builder {
-
- private String[] topic;
-
- private final List operations = new ArrayList<>();
-
- private EntityBulkOperation finalizer;
-
- protected Builder() {
- }
-
- /**
- * Topics are used to display all bulk operations for a specific topic.
- * Topics are hierarchical and the path of the topic is specified via
- * a string array. Topics are freely definable.
- * If e.g. all Topics of level1
are queried, all
- * BulkExecutions recursively below level1
are returned.
- */
- public Builder topic(String... topic) {
- Objects.requireNonNull(topic, "topic is null");
- for (String part : topic) {
- Objects.requireNonNull(part, "operations contains null values");
- }
-
- this.topic = topic.clone();
- return this;
- }
-
- @SuppressWarnings("PMD.UseArraysAsList")
- public Builder operation(EntityBulkOperation... operations) {
- Objects.requireNonNull(operations, "operations is null");
- for (EntityBulkOperation operation : operations) {
- Objects.requireNonNull(operation, "operations contains null values");
- this.operations.add(operation);
- }
- return this;
- }
-
- public Builder finalizer(EntityBulkOperation finalizer) {
- Objects.requireNonNull(finalizer, "finalizer is null");
- this.finalizer = finalizer;
- return this;
- }
-
- public EntityBulkExecution build() {
- if (this.topic == null) {
- throw new IllegalStateException("topic must be set");
- }
- if (this.operations.isEmpty()) {
- throw new IllegalStateException("operation must be set");
- }
- return new EntityBulkExecution(this);
- }
- }
+ private final String[] topic;
+
+ private final List operations;
+
+ private final EntityBulkOperation finalizer;
+
+ protected EntityBulkExecution(Builder builder) {
+ this.topic = builder.topic;
+ this.operations = Collections.unmodifiableList(builder.operations);
+ this.finalizer = builder.finalizer;
+ }
+
+ @SuppressFBWarnings("EI_EXPOSE_REP")
+ public String[] getTopic() {
+ return this.topic.clone();
+ }
+
+ @SuppressFBWarnings("EI_EXPOSE_REP")
+ public List getOperations() {
+ return this.operations;
+ }
+
+ public Optional getFinalizer() {
+ return Optional.ofNullable(this.finalizer);
+ }
+
+ @Override
+ public final int hashCode() {
+ return Objects.hash(Arrays.hashCode(this.topic), this.operations, this.finalizer);
+ }
+
+ @Override
+ public final boolean equals(Object o) {
+
+ if (!(o instanceof EntityBulkExecution)) {
+ return false;
+ }
+
+ EntityBulkExecution execution = (EntityBulkExecution) o;
+
+ return Arrays.equals(this.topic, execution.topic)
+ && Objects.equals(this.operations, execution.operations)
+ && Objects.equals(this.finalizer, execution.finalizer);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder b =
+ new StringBuilder(100)
+ .append("EntityBulkExecution[topic:")
+ .append(Arrays.toString(this.topic))
+ .append(", operations:")
+ .append(this.operations)
+ .append(", finalizer:")
+ .append(this.finalizer)
+ .append(']');
+ return b.toString();
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public static class Builder {
+
+ private String[] topic;
+
+ private final List operations = new ArrayList<>();
+
+ private EntityBulkOperation finalizer;
+
+ protected Builder() {}
+
+ /**
+ * Topics are used to display all bulk operations for a specific topic.
+ * Topics are hierarchical and the path of the topic is specified via
+ * a string array. Topics are freely definable.
+ * If e.g. all Topics of level1
are queried, all
+ * BulkExecutions recursively below level1
are returned.
+ */
+ public Builder topic(String... topic) {
+ Objects.requireNonNull(topic, "topic is null");
+ for (String part : topic) {
+ Objects.requireNonNull(part, "operations contains null values");
+ }
+
+ this.topic = topic.clone();
+ return this;
+ }
+
+ @SuppressWarnings("PMD.UseArraysAsList")
+ public Builder operation(EntityBulkOperation... operations) {
+ Objects.requireNonNull(operations, "operations is null");
+ for (EntityBulkOperation operation : operations) {
+ Objects.requireNonNull(operation, "operations contains null values");
+ this.operations.add(operation);
+ }
+ return this;
+ }
+
+ public Builder finalizer(EntityBulkOperation finalizer) {
+ Objects.requireNonNull(finalizer, "finalizer is null");
+ this.finalizer = finalizer;
+ return this;
+ }
+
+ public EntityBulkExecution build() {
+ if (this.topic == null) {
+ throw new IllegalStateException("topic must be set");
+ }
+ if (this.operations.isEmpty()) {
+ throw new IllegalStateException("operation must be set");
+ }
+ return new EntityBulkExecution(this);
+ }
+ }
}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/EntityBulkOperation.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/EntityBulkOperation.java
index 46f6dda..0ae87a1 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/EntityBulkOperation.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/EntityBulkOperation.java
@@ -1,119 +1,115 @@
package com.sitepark.ies.contentrepository.core.domain.entity;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.function.Consumer;
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-
public class EntityBulkOperation {
- private final BulkOperationKey key;
-
- private final List entityList;
-
- private final Consumer consumer;
-
- protected EntityBulkOperation(Builder builder) {
- this.key = builder.key;
- this.entityList = Collections.unmodifiableList(builder.entityList);
- this.consumer = builder.consumer;
- }
-
- public BulkOperationKey getKey() {
- return this.key;
- }
-
- @SuppressFBWarnings("EI_EXPOSE_REP")
- public List getEntityList() {
- return this.entityList;
- }
-
- public Consumer getConsumer() {
- return this.consumer;
- }
-
- @Override
- public final int hashCode() {
- return Objects.hash(
- this.key,
- this.entityList,
- this.consumer);
- }
-
- @Override
- public final boolean equals(Object o) {
-
- if (!(o instanceof EntityBulkOperation)) {
- return false;
- }
-
- EntityBulkOperation op = (EntityBulkOperation)o;
-
- return Objects.equals(this.key, op.key) &&
- Objects.equals(this.entityList, op.entityList) &&
- Objects.equals(this.consumer, op.consumer);
- }
-
- @Override
- public String toString() {
- StringBuilder b = new StringBuilder(100)
- .append("EntityBulkOperation[key:")
- .append(this.key)
- .append(", entityList:")
- .append(this.entityList)
- .append(", consumer:")
- .append(this.consumer)
- .append(']');
- return b.toString();
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- public static class Builder {
-
- private BulkOperationKey key;
-
- private final List entityList = new ArrayList<>();
-
- private Consumer consumer;
-
- protected Builder() {
- }
-
- public Builder key(BulkOperationKey key) {
- Objects.requireNonNull(key, "key is null");
- this.key = key;
- return this;
- }
-
- public Builder entityList(List entityList) {
- Objects.requireNonNull(entityList, "entityList is null");
- this.entityList.addAll(entityList);
- return this;
- }
-
- public Builder consumer(Consumer consumer) {
- Objects.requireNonNull(consumer, "consumer is null");
- this.consumer = consumer;
- return this;
- }
-
- public EntityBulkOperation build() {
- if (this.key == null) {
- throw new IllegalStateException("key must be set");
- }
- if (this.entityList.isEmpty()) {
- throw new IllegalStateException("entity must be set");
- }
- if (this.consumer == null) {
- throw new IllegalStateException("consumer must be set");
- }
- return new EntityBulkOperation(this);
- }
- }
+ private final BulkOperationKey key;
+
+ private final List entityList;
+
+ private final Consumer consumer;
+
+ protected EntityBulkOperation(Builder builder) {
+ this.key = builder.key;
+ this.entityList = Collections.unmodifiableList(builder.entityList);
+ this.consumer = builder.consumer;
+ }
+
+ public BulkOperationKey getKey() {
+ return this.key;
+ }
+
+ @SuppressFBWarnings("EI_EXPOSE_REP")
+ public List getEntityList() {
+ return this.entityList;
+ }
+
+ public Consumer getConsumer() {
+ return this.consumer;
+ }
+
+ @Override
+ public final int hashCode() {
+ return Objects.hash(this.key, this.entityList, this.consumer);
+ }
+
+ @Override
+ public final boolean equals(Object o) {
+
+ if (!(o instanceof EntityBulkOperation)) {
+ return false;
+ }
+
+ EntityBulkOperation op = (EntityBulkOperation) o;
+
+ return Objects.equals(this.key, op.key)
+ && Objects.equals(this.entityList, op.entityList)
+ && Objects.equals(this.consumer, op.consumer);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder b =
+ new StringBuilder(100)
+ .append("EntityBulkOperation[key:")
+ .append(this.key)
+ .append(", entityList:")
+ .append(this.entityList)
+ .append(", consumer:")
+ .append(this.consumer)
+ .append(']');
+ return b.toString();
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public static class Builder {
+
+ private BulkOperationKey key;
+
+ private final List entityList = new ArrayList<>();
+
+ private Consumer consumer;
+
+ protected Builder() {}
+
+ public Builder key(BulkOperationKey key) {
+ Objects.requireNonNull(key, "key is null");
+ this.key = key;
+ return this;
+ }
+
+ public Builder entityList(List entityList) {
+ Objects.requireNonNull(entityList, "entityList is null");
+ this.entityList.addAll(entityList);
+ return this;
+ }
+
+ public Builder consumer(Consumer consumer) {
+ Objects.requireNonNull(consumer, "consumer is null");
+ this.consumer = consumer;
+ return this;
+ }
+
+ public EntityBulkOperation build() {
+ if (this.key == null) {
+ throw new IllegalStateException("key must be set");
+ }
+ if (this.entityList.isEmpty()) {
+ throw new IllegalStateException("entity must be set");
+ }
+ if (this.consumer == null) {
+ throw new IllegalStateException("consumer must be set");
+ }
+ return new EntityBulkOperation(this);
+ }
+ }
}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/EntityLock.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/EntityLock.java
index 006b9c6..7b58331 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/EntityLock.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/EntityLock.java
@@ -6,152 +6,147 @@
public final class EntityLock implements Serializable {
- private final String entity;
- private final String user;
- private final OffsetDateTime created;
- private final OffsetDateTime lastAccess;
- private final long ttl;
-
- private static final long serialVersionUID = 1L;
-
- private EntityLock(Builder builder) {
- this.entity = builder.entity;
- this.user = builder.user;
- this.created = builder.created;
- this.lastAccess = builder.lastAccess;
- this.ttl = builder.ttl;
- }
-
- public String getEntity() {
- return entity;
- }
-
- public String getUser() {
- return user;
- }
-
- public OffsetDateTime getCreated() {
- return created;
- }
-
- public OffsetDateTime getLastAccess() {
- return lastAccess;
- }
-
- public long getTtl() {
- return ttl;
- }
-
- @Override
- public final int hashCode() {
- return Objects.hash(
- this.entity,
- this.user,
- this.created,
- this.lastAccess,
- this.ttl);
- }
-
- @Override
- public final boolean equals(Object o) {
-
- if (!(o instanceof EntityLock)) {
- return false;
- }
-
- EntityLock lock = (EntityLock)o;
-
- return Objects.equals(this.entity, lock.entity) &&
- Objects.equals(this.user, lock.user) &&
- Objects.equals(this.created, lock.created) &&
- Objects.equals(this.lastAccess, lock.lastAccess) &&
- Objects.equals(this.ttl, lock.ttl);
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- public Builder toBuilder() {
- return new Builder(this);
- }
-
- @Override
- public String toString() {
- StringBuilder b = new StringBuilder(100)
- .append("EntityLock[entity:")
- .append(this.entity)
- .append(", user:")
- .append(this.user)
- .append(", created:")
- .append(this.created)
- .append(", lastAccess:")
- .append(this.lastAccess)
- .append(", ttl:")
- .append(this.ttl)
- .append(']');
- return b.toString();
- }
-
- public static class Builder {
-
- private String entity;
- private String user;
- private OffsetDateTime created;
- private OffsetDateTime lastAccess;
- private long ttl;
-
- protected Builder() {
- }
-
- protected Builder(EntityLock entityLock) {
- this.entity = entityLock.entity;
- this.user = entityLock.user;
- this.created = entityLock.created;
- this.lastAccess = entityLock.lastAccess;
- this.ttl = entityLock.ttl;
- }
-
- public Builder entity(String entity) {
- Objects.requireNonNull(entity, "entity is null");
- if (!Identifier.isId(entity)) {
- throw new IllegalArgumentException(entity + " is not an id");
- }
- this.entity = entity;
- return this;
- }
-
- public Builder user(String user) {
- Objects.requireNonNull(user, "user is null");
- if (!Identifier.isId(user)) {
- throw new IllegalArgumentException(user + " is not an id");
- }
- this.user = user;
- return this;
- }
-
- public Builder created(OffsetDateTime created) {
- Objects.requireNonNull(created, "created is null");
- this.created = created;
- return this;
- }
-
- public Builder lastAccess(OffsetDateTime lastAccess) {
- Objects.requireNonNull(lastAccess, "lastAccess is null");
- this.lastAccess = lastAccess;
- return this;
- }
-
- public Builder ttl(long ttl) {
- if (ttl <= 0) {
- throw new IllegalArgumentException("ttl should be greater then 0");
- }
- this.ttl = ttl;
- return this;
- }
-
- public EntityLock build() {
- return new EntityLock(this);
- }
- }
+ private final String entity;
+ private final String user;
+ private final OffsetDateTime created;
+ private final OffsetDateTime lastAccess;
+ private final long ttl;
+
+ private static final long serialVersionUID = 1L;
+
+ private EntityLock(Builder builder) {
+ this.entity = builder.entity;
+ this.user = builder.user;
+ this.created = builder.created;
+ this.lastAccess = builder.lastAccess;
+ this.ttl = builder.ttl;
+ }
+
+ public String getEntity() {
+ return entity;
+ }
+
+ public String getUser() {
+ return user;
+ }
+
+ public OffsetDateTime getCreated() {
+ return created;
+ }
+
+ public OffsetDateTime getLastAccess() {
+ return lastAccess;
+ }
+
+ public long getTtl() {
+ return ttl;
+ }
+
+ @Override
+ public final int hashCode() {
+ return Objects.hash(this.entity, this.user, this.created, this.lastAccess, this.ttl);
+ }
+
+ @Override
+ public final boolean equals(Object o) {
+
+ if (!(o instanceof EntityLock)) {
+ return false;
+ }
+
+ EntityLock lock = (EntityLock) o;
+
+ return Objects.equals(this.entity, lock.entity)
+ && Objects.equals(this.user, lock.user)
+ && Objects.equals(this.created, lock.created)
+ && Objects.equals(this.lastAccess, lock.lastAccess)
+ && Objects.equals(this.ttl, lock.ttl);
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public Builder toBuilder() {
+ return new Builder(this);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder b =
+ new StringBuilder(100)
+ .append("EntityLock[entity:")
+ .append(this.entity)
+ .append(", user:")
+ .append(this.user)
+ .append(", created:")
+ .append(this.created)
+ .append(", lastAccess:")
+ .append(this.lastAccess)
+ .append(", ttl:")
+ .append(this.ttl)
+ .append(']');
+ return b.toString();
+ }
+
+ public static class Builder {
+
+ private String entity;
+ private String user;
+ private OffsetDateTime created;
+ private OffsetDateTime lastAccess;
+ private long ttl;
+
+ protected Builder() {}
+
+ protected Builder(EntityLock entityLock) {
+ this.entity = entityLock.entity;
+ this.user = entityLock.user;
+ this.created = entityLock.created;
+ this.lastAccess = entityLock.lastAccess;
+ this.ttl = entityLock.ttl;
+ }
+
+ public Builder entity(String entity) {
+ Objects.requireNonNull(entity, "entity is null");
+ if (!Identifier.isId(entity)) {
+ throw new IllegalArgumentException(entity + " is not an id");
+ }
+ this.entity = entity;
+ return this;
+ }
+
+ public Builder user(String user) {
+ Objects.requireNonNull(user, "user is null");
+ if (!Identifier.isId(user)) {
+ throw new IllegalArgumentException(user + " is not an id");
+ }
+ this.user = user;
+ return this;
+ }
+
+ public Builder created(OffsetDateTime created) {
+ Objects.requireNonNull(created, "created is null");
+ this.created = created;
+ return this;
+ }
+
+ public Builder lastAccess(OffsetDateTime lastAccess) {
+ Objects.requireNonNull(lastAccess, "lastAccess is null");
+ this.lastAccess = lastAccess;
+ return this;
+ }
+
+ public Builder ttl(long ttl) {
+ if (ttl <= 0) {
+ throw new IllegalArgumentException("ttl should be greater then 0");
+ }
+ this.ttl = ttl;
+ return this;
+ }
+
+ public EntityLock build() {
+ return new EntityLock(this);
+ }
+ }
}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/EntityTree.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/EntityTree.java
index b37576c..055298f 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/EntityTree.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/EntityTree.java
@@ -9,162 +9,156 @@
import java.util.Set;
import java.util.stream.Collectors;
-
@SuppressWarnings("PMD.UseConcurrentHashMap")
public class EntityTree {
- private final Map> children = new HashMap<>();
-
- private final Map parents = new HashMap<>();
-
- private final Map index = new HashMap<>();
-
- /**
- * Returns all roots of the tree.
- *
- * Roots are all entries without a parent
- */
- public List getRoots() {
- return this.getRootIdList().stream()
- .map(id -> {
- Entity entity = this.index.get(id);
- if (entity == null) {
- throw new IllegalStateException("Entity with id " + id + " missing");
- }
- return entity;
- })
- .collect(Collectors.toList());
- }
-
- private Set getRootIdList() {
- Set knownRoots = this.children.get(null);
- Set roots = new HashSet<>();
- if (knownRoots != null) {
- roots.addAll(knownRoots);
- }
- for (String parent : this.parents.values()) {
- if (parent != null && !this.parents.containsKey(parent)) {
- roots.add(parent);
- }
- }
- return roots;
- }
-
- /**
- * Places an element in the tree.
- *
- * If no parent present, it is set as root element.
- */
- public void add(Entity entity) {
-
- if (entity == null) {
- return;
- }
-
- this.parents.put(entity.getId().get(), entity.getParent().orElse(null));
- Set siblings = this.children.get(entity.getParent().orElse(null));
- if (siblings == null) {
- siblings = new HashSet<>();
- this.children.put(entity.getParent().orElse(null), siblings);
- }
- siblings.add(entity.getId().get());
- this.index.put(entity.getId().get(), entity);
- }
-
- public Entity get(String id) {
- return this.index.get(id);
- }
-
- public List getChildren(String parent) {
- Set children = this.children.get(parent);
- return children.stream()
- .map(id -> this.index.get(id))
- .collect(Collectors.toList());
- }
-
- /**
- * Liefert die Unterelemente des Parent rekusive.
- */
- public List getChildrenRecursive(String root) {
- Set children = this.getChildrenIdListRecursive(root);
- return children.stream()
- .map(id -> this.index.get(id))
- .collect(Collectors.toList());
- }
-
- private Set getChildrenIdListRecursive(String root) {
- Set list = new LinkedHashSet<>();
- Set children = this.children.get(root);
- if (children != null) {
- list.addAll(children);
- for (String id : children) {
- Set grandChildren = this.getChildrenIdListRecursive(id);
- list.addAll(grandChildren);
- }
- }
-
- return list;
- }
-
- /**
- * Returns all elements of the tree in hierarchical order
- */
- public List getAll() {
- Set rootIdList = this.getRootIdList();
- List list = new ArrayList<>();
- for (String rootId : rootIdList) {
- Entity root = this.index.get(rootId);
- if (root == null) {
- throw new IllegalStateException("Entity with id " + rootId + " missing");
- }
- list.add(root);
- List childrenOrRoot = this.getChildrenRecursive(rootId);
- list.addAll(childrenOrRoot);
- }
- return list;
- }
-
- public boolean hasChildren(String parent) {
- return this.children.containsKey(parent);
- }
-
- @Override
- public String toString() {
- return this.toString(0);
- }
-
- public String toString(int indent) {
- return this.toString(indent, null);
- }
-
- public String toString(int indent, String parent) {
- java.lang.StringBuilder b = new java.lang.StringBuilder();
- this.toString(indent, parent, new java.lang.StringBuilder(), b);
- return b.toString();
- }
-
- private void toString(int indent, String parent, java.lang.StringBuilder indentPrefix,
- java.lang.StringBuilder b) {
-
- if (parent == null) {
- Set roots = this.getRootIdList();
- for (String child : roots) {
- this.toString(indent, child, indentPrefix, b);
- }
- } else {
- b.append(indentPrefix.toString())
- .append(this.index.get(parent))
- .append('\n');
-
- if (this.hasChildren(parent)) {
- for (int i = 0; i < indent; i++) {
- indentPrefix.append(' ');
- }
- for (String child : this.children.get(parent)) {
- this.toString(indent, child, indentPrefix, b);
- }
- indentPrefix.delete(indentPrefix.length() - indent, indentPrefix.length());
- }
- }
- }
+ private final Map> children = new HashMap<>();
+
+ private final Map parents = new HashMap<>();
+
+ private final Map index = new HashMap<>();
+
+ /**
+ * Returns all roots of the tree.
+ *
+ * Roots are all entries without a parent
+ */
+ public List getRoots() {
+ return this.getRootIdList().stream()
+ .map(
+ id -> {
+ Entity entity = this.index.get(id);
+ if (entity == null) {
+ throw new IllegalStateException("Entity with id " + id + " missing");
+ }
+ return entity;
+ })
+ .collect(Collectors.toList());
+ }
+
+ private Set getRootIdList() {
+ Set knownRoots = this.children.get(null);
+ Set roots = new HashSet<>();
+ if (knownRoots != null) {
+ roots.addAll(knownRoots);
+ }
+ for (String parent : this.parents.values()) {
+ if (parent != null && !this.parents.containsKey(parent)) {
+ roots.add(parent);
+ }
+ }
+ return roots;
+ }
+
+ /**
+ * Places an element in the tree.
+ *
+ * If no parent present, it is set as root element.
+ */
+ public void add(Entity entity) {
+
+ if (entity == null) {
+ return;
+ }
+
+ this.parents.put(entity.getId().get(), entity.getParent().orElse(null));
+ Set siblings = this.children.get(entity.getParent().orElse(null));
+ if (siblings == null) {
+ siblings = new HashSet<>();
+ this.children.put(entity.getParent().orElse(null), siblings);
+ }
+ siblings.add(entity.getId().get());
+ this.index.put(entity.getId().get(), entity);
+ }
+
+ public Entity get(String id) {
+ return this.index.get(id);
+ }
+
+ public List getChildren(String parent) {
+ Set children = this.children.get(parent);
+ return children.stream().map(id -> this.index.get(id)).collect(Collectors.toList());
+ }
+
+ /**
+ * Liefert die Unterelemente des Parent rekusive.
+ */
+ public List getChildrenRecursive(String root) {
+ Set children = this.getChildrenIdListRecursive(root);
+ return children.stream().map(id -> this.index.get(id)).collect(Collectors.toList());
+ }
+
+ private Set getChildrenIdListRecursive(String root) {
+ Set list = new LinkedHashSet<>();
+ Set children = this.children.get(root);
+ if (children != null) {
+ list.addAll(children);
+ for (String id : children) {
+ Set grandChildren = this.getChildrenIdListRecursive(id);
+ list.addAll(grandChildren);
+ }
+ }
+
+ return list;
+ }
+
+ /**
+ * Returns all elements of the tree in hierarchical order
+ */
+ public List getAll() {
+ Set rootIdList = this.getRootIdList();
+ List list = new ArrayList<>();
+ for (String rootId : rootIdList) {
+ Entity root = this.index.get(rootId);
+ if (root == null) {
+ throw new IllegalStateException("Entity with id " + rootId + " missing");
+ }
+ list.add(root);
+ List childrenOrRoot = this.getChildrenRecursive(rootId);
+ list.addAll(childrenOrRoot);
+ }
+ return list;
+ }
+
+ public boolean hasChildren(String parent) {
+ return this.children.containsKey(parent);
+ }
+
+ @Override
+ public String toString() {
+ return this.toString(0);
+ }
+
+ public String toString(int indent) {
+ return this.toString(indent, null);
+ }
+
+ public String toString(int indent, String parent) {
+ java.lang.StringBuilder b = new java.lang.StringBuilder();
+ this.toString(indent, parent, new java.lang.StringBuilder(), b);
+ return b.toString();
+ }
+
+ private void toString(
+ int indent, String parent, java.lang.StringBuilder indentPrefix, java.lang.StringBuilder b) {
+
+ if (parent == null) {
+ Set roots = this.getRootIdList();
+ for (String child : roots) {
+ this.toString(indent, child, indentPrefix, b);
+ }
+ } else {
+ b.append(indentPrefix.toString()).append(this.index.get(parent)).append('\n');
+
+ if (this.hasChildren(parent)) {
+ for (int i = 0; i < indent; i++) {
+ indentPrefix.append(' ');
+ }
+ for (String child : this.children.get(parent)) {
+ this.toString(indent, child, indentPrefix, b);
+ }
+ indentPrefix.delete(indentPrefix.length() - indent, indentPrefix.length());
+ }
+ }
+ }
}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/HistoryEntry.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/HistoryEntry.java
index 7739dee..aaecbb8 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/HistoryEntry.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/HistoryEntry.java
@@ -6,168 +6,164 @@
public final class HistoryEntry implements Serializable {
- private final long entity;
- private final String initiator;
- private final Long user;
- private final long timestamp;
- private final HistoryEntryType type;
- private final String comment;
-
- private static final long serialVersionUID = 1L;
-
- private HistoryEntry(Builder builder) {
- this.entity = builder.entity;
- this.initiator = builder.initiator;
- this.user = builder.user;
- this.timestamp = builder.timestamp;
- this.type = builder.type;
- this.comment = builder.comment;
- }
-
- public long getEntity() {
- return entity;
- }
-
- /**
- * The initiator can be a user of a system-service or other subjects who
- * could authenticate themselves to work with the system.
- */
- public String getInitiator() {
- return initiator;
- }
-
- /**
- * If the initiator is a user of the IES, this returns the ID of the user.
- */
- public Optional getUser() {
- return Optional.ofNullable(this.user);
- }
-
- public long getTimestamp() {
- return timestamp;
- }
-
- public HistoryEntryType getType() {
- return type;
- }
-
- public String getComment() {
- return comment;
- }
-
- @Override
- public final int hashCode() {
- return Objects.hash(
- this.entity,
- this.initiator,
- this.user,
- this.timestamp,
- this.type,
- this.comment);
- }
-
- @Override
- public final boolean equals(Object o) {
-
- if (!(o instanceof HistoryEntry)) {
- return false;
- }
-
- HistoryEntry entry = (HistoryEntry)o;
-
- return Objects.equals(this.entity, entry.entity) &&
- Objects.equals(this.initiator, entry.initiator) &&
- Objects.equals(this.user, entry.user) &&
- Objects.equals(this.timestamp, entry.timestamp) &&
- Objects.equals(this.type, entry.type) &&
- Objects.equals(this.comment, entry.comment);
- }
-
- @Override
- public String toString() {
- StringBuilder b = new StringBuilder(100)
- .append("HistoryEntry[entity:")
- .append(this.entity)
- .append(", initiator:")
- .append(this.initiator)
- .append(", user:")
- .append(this.user)
- .append(", timestamp:")
- .append(this.timestamp)
- .append(", type:")
- .append(this.type)
- .append(", comment:")
- .append(this.comment)
- .append(']');
- return b.toString();
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- public Builder toBuilder() {
- return new Builder(this);
- }
-
- public static final class Builder {
-
- private long entity;
- private String initiator;
- private Long user;
- private long timestamp;
- private HistoryEntryType type;
- private String comment;
-
- private Builder() { }
-
- private Builder(HistoryEntry historyEntry) {
- this.entity = historyEntry.entity;
- this.initiator = historyEntry.initiator;
- this.user = historyEntry.user;
- this.timestamp = historyEntry.timestamp;
- this.type = historyEntry.type;
- this.comment = historyEntry.comment;
- }
-
- public Builder entity(long entity) {
- this.entity = entity;
- return this;
- }
-
- public Builder initiator(String initiator) {
- Objects.requireNonNull(initiator, "initiator is null");
- this.initiator = initiator;
- return this;
- }
-
- public Builder user(Long user) {
- this.user = user;
- return this;
- }
-
- public Builder timestamp(long timestamp) {
- if (timestamp <= 0) {
- throw new IllegalArgumentException("timestamp must be greater than 0");
- }
- this.timestamp = timestamp;
- return this;
- }
-
- public Builder type(HistoryEntryType type) {
- Objects.requireNonNull(type, "type is null");
- this.type = type;
- return this;
- }
-
- public Builder comment(String comment) {
- Objects.requireNonNull(comment, "comment is null");
- this.comment = comment;
- return this;
- }
-
- public HistoryEntry build() {
- return new HistoryEntry(this);
- }
- }
-}
\ No newline at end of file
+ private final long entity;
+ private final String initiator;
+ private final Long user;
+ private final long timestamp;
+ private final HistoryEntryType type;
+ private final String comment;
+
+ private static final long serialVersionUID = 1L;
+
+ private HistoryEntry(Builder builder) {
+ this.entity = builder.entity;
+ this.initiator = builder.initiator;
+ this.user = builder.user;
+ this.timestamp = builder.timestamp;
+ this.type = builder.type;
+ this.comment = builder.comment;
+ }
+
+ public long getEntity() {
+ return entity;
+ }
+
+ /**
+ * The initiator can be a user of a system-service or other subjects who
+ * could authenticate themselves to work with the system.
+ */
+ public String getInitiator() {
+ return initiator;
+ }
+
+ /**
+ * If the initiator is a user of the IES, this returns the ID of the user.
+ */
+ public Optional getUser() {
+ return Optional.ofNullable(this.user);
+ }
+
+ public long getTimestamp() {
+ return timestamp;
+ }
+
+ public HistoryEntryType getType() {
+ return type;
+ }
+
+ public String getComment() {
+ return comment;
+ }
+
+ @Override
+ public final int hashCode() {
+ return Objects.hash(
+ this.entity, this.initiator, this.user, this.timestamp, this.type, this.comment);
+ }
+
+ @Override
+ public final boolean equals(Object o) {
+
+ if (!(o instanceof HistoryEntry)) {
+ return false;
+ }
+
+ HistoryEntry entry = (HistoryEntry) o;
+
+ return Objects.equals(this.entity, entry.entity)
+ && Objects.equals(this.initiator, entry.initiator)
+ && Objects.equals(this.user, entry.user)
+ && Objects.equals(this.timestamp, entry.timestamp)
+ && Objects.equals(this.type, entry.type)
+ && Objects.equals(this.comment, entry.comment);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder b =
+ new StringBuilder(100)
+ .append("HistoryEntry[entity:")
+ .append(this.entity)
+ .append(", initiator:")
+ .append(this.initiator)
+ .append(", user:")
+ .append(this.user)
+ .append(", timestamp:")
+ .append(this.timestamp)
+ .append(", type:")
+ .append(this.type)
+ .append(", comment:")
+ .append(this.comment)
+ .append(']');
+ return b.toString();
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public Builder toBuilder() {
+ return new Builder(this);
+ }
+
+ public static final class Builder {
+
+ private long entity;
+ private String initiator;
+ private Long user;
+ private long timestamp;
+ private HistoryEntryType type;
+ private String comment;
+
+ private Builder() {}
+
+ private Builder(HistoryEntry historyEntry) {
+ this.entity = historyEntry.entity;
+ this.initiator = historyEntry.initiator;
+ this.user = historyEntry.user;
+ this.timestamp = historyEntry.timestamp;
+ this.type = historyEntry.type;
+ this.comment = historyEntry.comment;
+ }
+
+ public Builder entity(long entity) {
+ this.entity = entity;
+ return this;
+ }
+
+ public Builder initiator(String initiator) {
+ Objects.requireNonNull(initiator, "initiator is null");
+ this.initiator = initiator;
+ return this;
+ }
+
+ public Builder user(Long user) {
+ this.user = user;
+ return this;
+ }
+
+ public Builder timestamp(long timestamp) {
+ if (timestamp <= 0) {
+ throw new IllegalArgumentException("timestamp must be greater than 0");
+ }
+ this.timestamp = timestamp;
+ return this;
+ }
+
+ public Builder type(HistoryEntryType type) {
+ Objects.requireNonNull(type, "type is null");
+ this.type = type;
+ return this;
+ }
+
+ public Builder comment(String comment) {
+ Objects.requireNonNull(comment, "comment is null");
+ this.comment = comment;
+ return this;
+ }
+
+ public HistoryEntry build() {
+ return new HistoryEntry(this);
+ }
+ }
+}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/HistoryEntryType.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/HistoryEntryType.java
index 2995e81..4362c62 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/HistoryEntryType.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/HistoryEntryType.java
@@ -1,9 +1,9 @@
package com.sitepark.ies.contentrepository.core.domain.entity;
public enum HistoryEntryType {
- CREATED,
- UPDATED,
- MOVED,
- REMOVED,
- RESTORED
+ CREATED,
+ UPDATED,
+ MOVED,
+ REMOVED,
+ RESTORED
}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/Identifier.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/Identifier.java
index 2bceb2d..4841dab 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/Identifier.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/Identifier.java
@@ -1,103 +1,99 @@
package com.sitepark.ies.contentrepository.core.domain.entity;
+import com.fasterxml.jackson.annotation.JsonCreator;
import java.util.Objects;
import java.util.Optional;
-import com.fasterxml.jackson.annotation.JsonCreator;
-
public final class Identifier {
- private static final int MAX_ID_LENGTH = 19;
-
- private static final String ZERO_ID = "0";
-
- private final String id;
-
- private final Anchor anchor;
-
- private Identifier(String id) {
- this.id = id;
- this.anchor = null;
- }
-
- private Identifier(Anchor anchor) {
- this.id = null;
- this.anchor = anchor;
- }
-
- public static Identifier ofId(String id) {
- return new Identifier(id);
- }
-
- public static Identifier ofAnchor(Anchor anchor) {
- Objects.requireNonNull(anchor, "anchor is null");
- return new Identifier(anchor);
- }
-
- @JsonCreator
- public static Identifier ofString(String identifier) {
- Objects.requireNonNull(identifier, "identifier is null");
- if (identifier.isBlank()) {
- throw new IllegalArgumentException("identifier is blank");
- }
- if (isId(identifier)) {
- return new Identifier(identifier);
- }
- return new Identifier(Anchor.ofString(identifier));
- }
-
- public Optional getId() {
- return Optional.ofNullable(this.id);
- }
-
- public Optional getAnchor() {
- return Optional.ofNullable(this.anchor);
- }
-
- public static boolean isId(String str) {
-
- if (ZERO_ID.equals(str)) {
- throw new IllegalArgumentException("id should be greater than 0");
- }
-
- int length = str.length();
- if (length > MAX_ID_LENGTH) {
- return false;
- }
-
- for (int i = 0; i < length; i++) {
- char c = str.charAt(i);
- if (c < '0' || c > '9') {
- return false;
- }
- }
- return true;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(this.id, this.anchor);
- }
-
-
- @Override
- public boolean equals(Object o) {
-
- if (!(o instanceof Identifier)) {
- return false;
- }
-
- Identifier that = (Identifier)o;
- return
- Objects.equals(this.id, that.id) &&
- Objects.equals(this.anchor, that.anchor);
- }
-
- @Override
- public String toString() {
- if (this.id != null) {
- return this.id;
- }
- return this.anchor.toString();
- }
+ private static final int MAX_ID_LENGTH = 19;
+
+ private static final String ZERO_ID = "0";
+
+ private final String id;
+
+ private final Anchor anchor;
+
+ private Identifier(String id) {
+ this.id = id;
+ this.anchor = null;
+ }
+
+ private Identifier(Anchor anchor) {
+ this.id = null;
+ this.anchor = anchor;
+ }
+
+ public static Identifier ofId(String id) {
+ return new Identifier(id);
+ }
+
+ public static Identifier ofAnchor(Anchor anchor) {
+ Objects.requireNonNull(anchor, "anchor is null");
+ return new Identifier(anchor);
+ }
+
+ @JsonCreator
+ public static Identifier ofString(String identifier) {
+ Objects.requireNonNull(identifier, "identifier is null");
+ if (identifier.isBlank()) {
+ throw new IllegalArgumentException("identifier is blank");
+ }
+ if (isId(identifier)) {
+ return new Identifier(identifier);
+ }
+ return new Identifier(Anchor.ofString(identifier));
+ }
+
+ public Optional getId() {
+ return Optional.ofNullable(this.id);
+ }
+
+ public Optional getAnchor() {
+ return Optional.ofNullable(this.anchor);
+ }
+
+ public static boolean isId(String str) {
+
+ if (ZERO_ID.equals(str)) {
+ throw new IllegalArgumentException("id should be greater than 0");
+ }
+
+ int length = str.length();
+ if (length > MAX_ID_LENGTH) {
+ return false;
+ }
+
+ for (int i = 0; i < length; i++) {
+ char c = str.charAt(i);
+ if (c < '0' || c > '9') {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.id, this.anchor);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+
+ if (!(o instanceof Identifier)) {
+ return false;
+ }
+
+ Identifier that = (Identifier) o;
+ return Objects.equals(this.id, that.id) && Objects.equals(this.anchor, that.anchor);
+ }
+
+ @Override
+ public String toString() {
+ if (this.id != null) {
+ return this.id;
+ }
+ return this.anchor.toString();
+ }
}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/MediaReference.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/MediaReference.java
index fef465b..45a9ba6 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/MediaReference.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/MediaReference.java
@@ -4,90 +4,89 @@
public class MediaReference {
- private final String mediaId;
- final String usedBy;
- private final MediaReferenceType type;
-
- protected MediaReference(Builder builder) {
- this.mediaId = builder.mediaId;
- this.usedBy = builder.usedBy;
- this.type = builder.type;
- }
-
- public String getMediaId() {
- return this.mediaId;
- }
-
- public String getUsedBy() {
- return this.usedBy;
- }
-
- public MediaReferenceType getType() {
- return this.type;
- }
-
- @Override
- public final int hashCode() {
- return Objects.hash(
- this.mediaId,
- this.usedBy,
- this.type);
- }
-
- @Override
- public final boolean equals(Object o) {
-
- if (!(o instanceof MediaReference)) {
- return false;
- }
-
- MediaReference ref = (MediaReference)o;
-
- return Objects.equals(this.mediaId, ref.mediaId) &&
- Objects.equals(this.usedBy, ref.usedBy) &&
- Objects.equals(this.type, ref.type);
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- public Builder toBuilder() {
- return new Builder(this);
- }
-
- public static class Builder {
-
- private String mediaId;
- private String usedBy;
- private MediaReferenceType type;
-
- protected Builder() {}
-
- protected Builder(MediaReference media) {
- this.mediaId = media.mediaId;
- this.usedBy = media.usedBy;
- this.type = media.type;
- }
-
- public Builder mediaId(String mediaId) {
- Objects.requireNonNull(mediaId, "mediaId is null");
- this.mediaId = mediaId;
- return this;
- }
-
- public Builder usedBy(String usedBy) {
- Objects.requireNonNull(usedBy, "usedBy is null");
- this.usedBy = usedBy;
- return this;
- }
- public Builder type(MediaReferenceType type) {
- Objects.requireNonNull(type, "type is null");
- this.type = type;
- return this;
- }
- public MediaReference build() {
- return new MediaReference(this);
- }
- }
+ private final String mediaId;
+ final String usedBy;
+ private final MediaReferenceType type;
+
+ protected MediaReference(Builder builder) {
+ this.mediaId = builder.mediaId;
+ this.usedBy = builder.usedBy;
+ this.type = builder.type;
+ }
+
+ public String getMediaId() {
+ return this.mediaId;
+ }
+
+ public String getUsedBy() {
+ return this.usedBy;
+ }
+
+ public MediaReferenceType getType() {
+ return this.type;
+ }
+
+ @Override
+ public final int hashCode() {
+ return Objects.hash(this.mediaId, this.usedBy, this.type);
+ }
+
+ @Override
+ public final boolean equals(Object o) {
+
+ if (!(o instanceof MediaReference)) {
+ return false;
+ }
+
+ MediaReference ref = (MediaReference) o;
+
+ return Objects.equals(this.mediaId, ref.mediaId)
+ && Objects.equals(this.usedBy, ref.usedBy)
+ && Objects.equals(this.type, ref.type);
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public Builder toBuilder() {
+ return new Builder(this);
+ }
+
+ public static class Builder {
+
+ private String mediaId;
+ private String usedBy;
+ private MediaReferenceType type;
+
+ protected Builder() {}
+
+ protected Builder(MediaReference media) {
+ this.mediaId = media.mediaId;
+ this.usedBy = media.usedBy;
+ this.type = media.type;
+ }
+
+ public Builder mediaId(String mediaId) {
+ Objects.requireNonNull(mediaId, "mediaId is null");
+ this.mediaId = mediaId;
+ return this;
+ }
+
+ public Builder usedBy(String usedBy) {
+ Objects.requireNonNull(usedBy, "usedBy is null");
+ this.usedBy = usedBy;
+ return this;
+ }
+
+ public Builder type(MediaReferenceType type) {
+ Objects.requireNonNull(type, "type is null");
+ this.type = type;
+ return this;
+ }
+
+ public MediaReference build() {
+ return new MediaReference(this);
+ }
+ }
}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/MediaReferenceType.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/MediaReferenceType.java
index a679115..5f3920f 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/MediaReferenceType.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/MediaReferenceType.java
@@ -1,5 +1,5 @@
package com.sitepark.ies.contentrepository.core.domain.entity;
public enum MediaReferenceType {
- EMBEDDED
+ EMBEDDED
}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/RecycleBinItem.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/RecycleBinItem.java
index 060b349..4f70262 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/RecycleBinItem.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/RecycleBinItem.java
@@ -7,125 +7,129 @@
public final class RecycleBinItem {
- private final String id;
- private final String parent;
- private final Entity entity;
- private final List children;
-
- private RecycleBinItem(Builder builder) {
- this.id = builder.id;
- this.parent = builder.parent;
- this.entity = builder.entity;
- this.children = builder.children;
- }
-
- public String getId() {
- return this.id;
- }
-
- public String getParent() {
- return this.parent;
- }
-
- public Entity getEntity() {
- return this.entity;
- }
-
- public List getChildren() {
- return Collections.unmodifiableList(this.children);
- }
-
- @Override
- public final int hashCode() {
- return Objects.hash(
- this.id,
- this.parent,
- this.entity,
- this.children);
- }
-
- @Override
- public final boolean equals(Object o) {
-
- if (!(o instanceof RecycleBinItem)) {
- return false;
- }
-
- RecycleBinItem item = (RecycleBinItem)o;
-
- return Objects.equals(this.id, item.id) &&
- Objects.equals(this.parent, item.parent) &&
- Objects.equals(this.entity, item.entity) &&
- Objects.equals(this.children, item.children);
- }
-
- @Override
- public String toString() {
- return "RecycleBinItem [id=" + id + ", parent=" + parent + ", entity=" + entity + ", children=" + children
- + "]";
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- public Builder toBuilder() {
- return new Builder(this);
- }
-
- public static final class Builder {
-
- private String id;
- private String parent;
- private Entity entity;
- private List children = new ArrayList<>();
-
- private Builder() {}
- private Builder(RecycleBinItem recycleBinItem) {
- this.id = recycleBinItem.id;
- this.parent = recycleBinItem.parent;
- this.entity = recycleBinItem.entity;
- this.children = new ArrayList<>(recycleBinItem.children);
- }
-
- public Builder id(String id) {
- Objects.requireNonNull(id, "id is null");
- if (!Identifier.isId(id)) {
- throw new IllegalArgumentException(id + " is not an id");
- }
- this.id = id;
- return this;
- }
-
- public Builder parent(String parent) {
- Objects.requireNonNull(parent, "parent is null");
- if (!Identifier.isId(parent)) {
- throw new IllegalArgumentException(parent + " is not an id");
- }
- this.parent = parent;
- return this;
- }
-
- public Builder entity(Entity entity) {
- Objects.requireNonNull(entity, "entity is null");
- this.entity = entity;
- return this;
- }
-
- public Builder children(List children) {
- Objects.requireNonNull(children, "children is null");
- this.children = new ArrayList<>(children);
- return this;
- }
-
- public Builder child(RecycleBinItem child) {
- Objects.requireNonNull(child, "child is null");
- this.children.add(child);
- return this;
- }
-
- public RecycleBinItem build() {
- return new RecycleBinItem(this);
- }
- }
-}
\ No newline at end of file
+ private final String id;
+ private final String parent;
+ private final Entity entity;
+ private final List children;
+
+ private RecycleBinItem(Builder builder) {
+ this.id = builder.id;
+ this.parent = builder.parent;
+ this.entity = builder.entity;
+ this.children = builder.children;
+ }
+
+ public String getId() {
+ return this.id;
+ }
+
+ public String getParent() {
+ return this.parent;
+ }
+
+ public Entity getEntity() {
+ return this.entity;
+ }
+
+ public List getChildren() {
+ return Collections.unmodifiableList(this.children);
+ }
+
+ @Override
+ public final int hashCode() {
+ return Objects.hash(this.id, this.parent, this.entity, this.children);
+ }
+
+ @Override
+ public final boolean equals(Object o) {
+
+ if (!(o instanceof RecycleBinItem)) {
+ return false;
+ }
+
+ RecycleBinItem item = (RecycleBinItem) o;
+
+ return Objects.equals(this.id, item.id)
+ && Objects.equals(this.parent, item.parent)
+ && Objects.equals(this.entity, item.entity)
+ && Objects.equals(this.children, item.children);
+ }
+
+ @Override
+ public String toString() {
+ return "RecycleBinItem [id="
+ + id
+ + ", parent="
+ + parent
+ + ", entity="
+ + entity
+ + ", children="
+ + children
+ + "]";
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public Builder toBuilder() {
+ return new Builder(this);
+ }
+
+ public static final class Builder {
+
+ private String id;
+ private String parent;
+ private Entity entity;
+ private List children = new ArrayList<>();
+
+ private Builder() {}
+
+ private Builder(RecycleBinItem recycleBinItem) {
+ this.id = recycleBinItem.id;
+ this.parent = recycleBinItem.parent;
+ this.entity = recycleBinItem.entity;
+ this.children = new ArrayList<>(recycleBinItem.children);
+ }
+
+ public Builder id(String id) {
+ Objects.requireNonNull(id, "id is null");
+ if (!Identifier.isId(id)) {
+ throw new IllegalArgumentException(id + " is not an id");
+ }
+ this.id = id;
+ return this;
+ }
+
+ public Builder parent(String parent) {
+ Objects.requireNonNull(parent, "parent is null");
+ if (!Identifier.isId(parent)) {
+ throw new IllegalArgumentException(parent + " is not an id");
+ }
+ this.parent = parent;
+ return this;
+ }
+
+ public Builder entity(Entity entity) {
+ Objects.requireNonNull(entity, "entity is null");
+ this.entity = entity;
+ return this;
+ }
+
+ public Builder children(List children) {
+ Objects.requireNonNull(children, "children is null");
+ this.children = new ArrayList<>(children);
+ return this;
+ }
+
+ public Builder child(RecycleBinItem child) {
+ Objects.requireNonNull(child, "child is null");
+ this.children.add(child);
+ return this;
+ }
+
+ public RecycleBinItem build() {
+ return new RecycleBinItem(this);
+ }
+ }
+}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/RecycleBinItemFilter.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/RecycleBinItemFilter.java
index 6b9321e..279deae 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/RecycleBinItemFilter.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/RecycleBinItemFilter.java
@@ -6,97 +6,95 @@
public final class RecycleBinItemFilter {
- private final LocalDateTime from;
-
- private final LocalDateTime to;
-
- private final Long user;
-
- private RecycleBinItemFilter(Builder builder) {
- this.from = builder.from;
- this.to = builder.to;
- this.user = builder.user;
- }
-
- public Optional getFrom() {
- return Optional.ofNullable(this.from);
- }
-
- public Optional getTo() {
- return Optional.ofNullable(this.to);
- }
-
- public Optional getUser() {
- return Optional.ofNullable(this.user);
- }
-
- @Override
- public final int hashCode() {
- return Objects.hash(
- this.from,
- this.to,
- this.user);
- }
-
- @Override
- public final boolean equals(Object o) {
-
- if (!(o instanceof RecycleBinItemFilter)) {
- return false;
- }
-
- RecycleBinItemFilter filter = (RecycleBinItemFilter)o;
-
- return Objects.equals(this.from, filter.from) &&
- Objects.equals(this.to, filter.to) &&
- Objects.equals(this.user, filter.user);
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- public Builder toBuilder() {
- return new Builder(this);
- }
-
- public static final class Builder {
-
- private LocalDateTime from;
-
- private LocalDateTime to;
-
- private Long user;
-
- private Builder() {}
- private Builder(RecycleBinItemFilter recycleBinItemFilter) {
- this.from = recycleBinItemFilter.from;
- this.to = recycleBinItemFilter.to;
- this.user = recycleBinItemFilter.user;
- }
-
- public Builder from(LocalDateTime from) {
- Objects.requireNonNull(from, "from is null");
- this.from = from;
- return this;
- }
-
- public Builder to(LocalDateTime to) {
- Objects.requireNonNull(to, "to is null");
- this.to = to;
- return this;
- }
-
- public Builder user(long user) {
- if (user <= 0) {
- throw new IllegalArgumentException("user should be greater then 0");
- }
- this.user = user;
- return this;
- }
-
- public RecycleBinItemFilter build() {
- return new RecycleBinItemFilter(this);
- }
- }
+ private final LocalDateTime from;
+
+ private final LocalDateTime to;
+
+ private final Long user;
+
+ private RecycleBinItemFilter(Builder builder) {
+ this.from = builder.from;
+ this.to = builder.to;
+ this.user = builder.user;
+ }
+
+ public Optional getFrom() {
+ return Optional.ofNullable(this.from);
+ }
+
+ public Optional getTo() {
+ return Optional.ofNullable(this.to);
+ }
+
+ public Optional getUser() {
+ return Optional.ofNullable(this.user);
+ }
+
+ @Override
+ public final int hashCode() {
+ return Objects.hash(this.from, this.to, this.user);
+ }
+
+ @Override
+ public final boolean equals(Object o) {
+
+ if (!(o instanceof RecycleBinItemFilter)) {
+ return false;
+ }
+
+ RecycleBinItemFilter filter = (RecycleBinItemFilter) o;
+
+ return Objects.equals(this.from, filter.from)
+ && Objects.equals(this.to, filter.to)
+ && Objects.equals(this.user, filter.user);
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public Builder toBuilder() {
+ return new Builder(this);
+ }
+
+ public static final class Builder {
+
+ private LocalDateTime from;
+
+ private LocalDateTime to;
+
+ private Long user;
+
+ private Builder() {}
+
+ private Builder(RecycleBinItemFilter recycleBinItemFilter) {
+ this.from = recycleBinItemFilter.from;
+ this.to = recycleBinItemFilter.to;
+ this.user = recycleBinItemFilter.user;
+ }
+
+ public Builder from(LocalDateTime from) {
+ Objects.requireNonNull(from, "from is null");
+ this.from = from;
+ return this;
+ }
+
+ public Builder to(LocalDateTime to) {
+ Objects.requireNonNull(to, "to is null");
+ this.to = to;
+ return this;
+ }
+
+ public Builder user(long user) {
+ if (user <= 0) {
+ throw new IllegalArgumentException("user should be greater then 0");
+ }
+ this.user = user;
+ return this;
+ }
+
+ public RecycleBinItemFilter build() {
+ return new RecycleBinItemFilter(this);
+ }
+ }
}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/Anchor.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/Anchor.java
index c103698..286558c 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/Anchor.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/Anchor.java
@@ -1,20 +1,21 @@
package com.sitepark.ies.contentrepository.core.domain.entity.filter;
-import java.util.Objects;
-
import com.fasterxml.jackson.annotation.JsonProperty;
+import java.util.Objects;
public class Anchor implements Filter {
- @SuppressWarnings("PMD.AvoidFieldNameMatchingTypeName") // so that when deserializing it has the desired format
- private final com.sitepark.ies.contentrepository.core.domain.entity.Anchor anchor;
+ @SuppressWarnings(
+ "PMD.AvoidFieldNameMatchingTypeName") // so that when deserializing it has the desired format
+ private final com.sitepark.ies.contentrepository.core.domain.entity.Anchor anchor;
- protected Anchor(@JsonProperty("anchor") com.sitepark.ies.contentrepository.core.domain.entity.Anchor anchor) {
- Objects.requireNonNull(anchor, "anchor is null");
- this.anchor = anchor;
- }
+ protected Anchor(
+ @JsonProperty("anchor") com.sitepark.ies.contentrepository.core.domain.entity.Anchor anchor) {
+ Objects.requireNonNull(anchor, "anchor is null");
+ this.anchor = anchor;
+ }
- public com.sitepark.ies.contentrepository.core.domain.entity.Anchor getAnchor() {
- return this.anchor;
- }
+ public com.sitepark.ies.contentrepository.core.domain.entity.Anchor getAnchor() {
+ return this.anchor;
+ }
}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/AnchorList.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/AnchorList.java
index 57d8aee..534e914 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/AnchorList.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/AnchorList.java
@@ -1,26 +1,25 @@
package com.sitepark.ies.contentrepository.core.domain.entity.filter;
-import java.util.List;
-import java.util.Objects;
-
import com.fasterxml.jackson.annotation.JsonProperty;
-
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+import java.util.List;
+import java.util.Objects;
public class AnchorList implements Filter {
- @SuppressWarnings("PMD.AvoidFieldNameMatchingTypeName") // so that when deserializing it has the desired format
-
- private final List anchorList;
-
- protected AnchorList(@JsonProperty("anchorList")
- com.sitepark.ies.contentrepository.core.domain.entity.Anchor... anchorList) {
- Objects.requireNonNull(anchorList, "anchorList is null");
- this.anchorList = List.of(anchorList);
- }
-
- @SuppressFBWarnings("EI_EXPOSE_REP")
- public List getAnchorList() {
- return this.anchorList;
- }
+ @SuppressWarnings(
+ "PMD.AvoidFieldNameMatchingTypeName") // so that when deserializing it has the desired format
+ private final List anchorList;
+
+ protected AnchorList(
+ @JsonProperty("anchorList")
+ com.sitepark.ies.contentrepository.core.domain.entity.Anchor... anchorList) {
+ Objects.requireNonNull(anchorList, "anchorList is null");
+ this.anchorList = List.of(anchorList);
+ }
+
+ @SuppressFBWarnings("EI_EXPOSE_REP")
+ public List getAnchorList() {
+ return this.anchorList;
+ }
}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/And.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/And.java
index ef318ba..e07ecef 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/And.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/And.java
@@ -1,24 +1,23 @@
package com.sitepark.ies.contentrepository.core.domain.entity.filter;
-import java.util.List;
-import java.util.Objects;
-
import com.fasterxml.jackson.annotation.JsonProperty;
-
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+import java.util.List;
+import java.util.Objects;
public class And implements Filter {
- @SuppressWarnings("PMD.AvoidFieldNameMatchingTypeName") // so that when deserializing it has the desired format
- private final List and;
+ @SuppressWarnings(
+ "PMD.AvoidFieldNameMatchingTypeName") // so that when deserializing it has the desired format
+ private final List and;
- protected And(@JsonProperty("and") Filter... and) {
- Objects.requireNonNull(and, "and is null");
- this.and = List.of(and);
- }
+ protected And(@JsonProperty("and") Filter... and) {
+ Objects.requireNonNull(and, "and is null");
+ this.and = List.of(and);
+ }
- @SuppressFBWarnings("EI_EXPOSE_REP")
- public List getAnd() {
- return this.and;
- }
+ @SuppressFBWarnings("EI_EXPOSE_REP")
+ public List getAnd() {
+ return this.and;
+ }
}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/Filter.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/Filter.java
index e830380..5fe32a7 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/Filter.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/Filter.java
@@ -3,60 +3,62 @@
@SuppressWarnings("PMD.TooManyMethods")
public interface Filter {
- public static IsGroup isGroup(Boolean isGroup) {
- return new IsGroup(isGroup);
- }
-
- public static Id id(String id) {
- return new Id(id);
- }
-
- public static IdList idList(String... idlist) {
- return new IdList(idlist);
- }
-
- public static Anchor anchor(com.sitepark.ies.contentrepository.core.domain.entity.Anchor anchor) {
- return new Anchor(anchor);
- }
-
- public static AnchorList anchorList(com.sitepark.ies.contentrepository.core.domain.entity.Anchor... anchorList) {
- return new AnchorList(anchorList);
- }
-
- public static Parent parent(String parent) {
- return new Parent(parent);
- }
-
- public static ParentList parentList(String... parentList) {
- return new ParentList(parentList);
- }
-
- public static ParentAnchor parentAnchor(com.sitepark.ies.contentrepository.core.domain.entity.Anchor parentAnchor) {
- return new ParentAnchor(parentAnchor);
- }
-
- public static ParentAnchorList parentAnchorList(
- com.sitepark.ies.contentrepository.core.domain.entity.Anchor... parentAnchorList) {
- return new ParentAnchorList(parentAnchorList);
- }
-
- public static Root root(String root) {
- return new Root(root);
- }
-
- public static RootList rootList(String... rootList) {
- return new RootList(rootList);
- }
-
- public static Or or(Filter... filterList) {
- return new Or(filterList);
- }
-
- public static And and(Filter... filterList) {
- return new And(filterList);
- }
-
- public static Not not(Filter filter) {
- return new Not(filter);
- }
+ public static IsGroup isGroup(Boolean isGroup) {
+ return new IsGroup(isGroup);
+ }
+
+ public static Id id(String id) {
+ return new Id(id);
+ }
+
+ public static IdList idList(String... idlist) {
+ return new IdList(idlist);
+ }
+
+ public static Anchor anchor(com.sitepark.ies.contentrepository.core.domain.entity.Anchor anchor) {
+ return new Anchor(anchor);
+ }
+
+ public static AnchorList anchorList(
+ com.sitepark.ies.contentrepository.core.domain.entity.Anchor... anchorList) {
+ return new AnchorList(anchorList);
+ }
+
+ public static Parent parent(String parent) {
+ return new Parent(parent);
+ }
+
+ public static ParentList parentList(String... parentList) {
+ return new ParentList(parentList);
+ }
+
+ public static ParentAnchor parentAnchor(
+ com.sitepark.ies.contentrepository.core.domain.entity.Anchor parentAnchor) {
+ return new ParentAnchor(parentAnchor);
+ }
+
+ public static ParentAnchorList parentAnchorList(
+ com.sitepark.ies.contentrepository.core.domain.entity.Anchor... parentAnchorList) {
+ return new ParentAnchorList(parentAnchorList);
+ }
+
+ public static Root root(String root) {
+ return new Root(root);
+ }
+
+ public static RootList rootList(String... rootList) {
+ return new RootList(rootList);
+ }
+
+ public static Or or(Filter... filterList) {
+ return new Or(filterList);
+ }
+
+ public static And and(Filter... filterList) {
+ return new And(filterList);
+ }
+
+ public static Not not(Filter filter) {
+ return new Not(filter);
+ }
}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/FilterDeserializer.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/FilterDeserializer.java
index bdc1785..f9b9d94 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/FilterDeserializer.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/FilterDeserializer.java
@@ -4,20 +4,20 @@
public class FilterDeserializer extends UniquePropertyPolymorphicDeserializer {
- private static final long serialVersionUID = 1L;
+ private static final long serialVersionUID = 1L;
- public FilterDeserializer() {
- super(Filter.class);
- super.register("id", Id.class);
- super.register("idList", IdList.class);
- super.register("parent", Parent.class);
- super.register("parentList", ParentList.class);
- super.register("root", Root.class);
- super.register("rootList", RootList.class);
- super.register("anchor", Anchor.class);
- super.register("anchorList", AnchorList.class);
- super.register("and", And.class);
- super.register("or", Or.class);
- super.register("not", Not.class);
- }
+ public FilterDeserializer() {
+ super(Filter.class);
+ super.register("id", Id.class);
+ super.register("idList", IdList.class);
+ super.register("parent", Parent.class);
+ super.register("parentList", ParentList.class);
+ super.register("root", Root.class);
+ super.register("rootList", RootList.class);
+ super.register("anchor", Anchor.class);
+ super.register("anchorList", AnchorList.class);
+ super.register("and", And.class);
+ super.register("or", Or.class);
+ super.register("not", Not.class);
+ }
}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/Id.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/Id.java
index 040065e..6775efe 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/Id.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/Id.java
@@ -1,20 +1,20 @@
package com.sitepark.ies.contentrepository.core.domain.entity.filter;
-import java.util.Objects;
-
import com.fasterxml.jackson.annotation.JsonProperty;
+import java.util.Objects;
public class Id implements Filter {
- @SuppressWarnings("PMD.AvoidFieldNameMatchingTypeName") // so that when deserializing it has the desired format
- private final String id;
+ @SuppressWarnings(
+ "PMD.AvoidFieldNameMatchingTypeName") // so that when deserializing it has the desired format
+ private final String id;
- protected Id(@JsonProperty("id") String id) {
- Objects.requireNonNull(id, "id is null");
- this.id = id;
- }
+ protected Id(@JsonProperty("id") String id) {
+ Objects.requireNonNull(id, "id is null");
+ this.id = id;
+ }
- public String getId() {
- return this.id;
- }
+ public String getId() {
+ return this.id;
+ }
}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/IdList.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/IdList.java
index d505fbd..430e0dd 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/IdList.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/IdList.java
@@ -1,25 +1,23 @@
package com.sitepark.ies.contentrepository.core.domain.entity.filter;
-import java.util.List;
-import java.util.Objects;
-
import com.fasterxml.jackson.annotation.JsonProperty;
-
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+import java.util.List;
+import java.util.Objects;
public class IdList implements Filter {
- @SuppressWarnings("PMD.AvoidFieldNameMatchingTypeName") // so that when deserializing it has the desired format
-
- private final List idList;
+ @SuppressWarnings(
+ "PMD.AvoidFieldNameMatchingTypeName") // so that when deserializing it has the desired format
+ private final List idList;
- protected IdList(@JsonProperty("idList") String... idList) {
- Objects.requireNonNull(idList, "idList is null");
- this.idList = List.of(idList);
- }
+ protected IdList(@JsonProperty("idList") String... idList) {
+ Objects.requireNonNull(idList, "idList is null");
+ this.idList = List.of(idList);
+ }
- @SuppressFBWarnings("EI_EXPOSE_REP")
- public List getIdList() {
- return this.idList;
- }
+ @SuppressFBWarnings("EI_EXPOSE_REP")
+ public List getIdList() {
+ return this.idList;
+ }
}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/IsGroup.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/IsGroup.java
index 42a29b5..8e9b60c 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/IsGroup.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/IsGroup.java
@@ -4,14 +4,15 @@
public class IsGroup implements Filter {
- @SuppressWarnings("PMD.AvoidFieldNameMatchingTypeName") // so that when deserializing it has the desired format
- private final boolean isGroup;
+ @SuppressWarnings(
+ "PMD.AvoidFieldNameMatchingTypeName") // so that when deserializing it has the desired format
+ private final boolean isGroup;
- protected IsGroup(@JsonProperty("isGroup") boolean isGroup) {
- this.isGroup = isGroup;
- }
+ protected IsGroup(@JsonProperty("isGroup") boolean isGroup) {
+ this.isGroup = isGroup;
+ }
- public boolean isGroup() {
- return this.isGroup;
- }
+ public boolean isGroup() {
+ return this.isGroup;
+ }
}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/Not.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/Not.java
index 4681d4c..9b34370 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/Not.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/Not.java
@@ -1,20 +1,20 @@
package com.sitepark.ies.contentrepository.core.domain.entity.filter;
-import java.util.Objects;
-
import com.fasterxml.jackson.annotation.JsonProperty;
+import java.util.Objects;
public class Not implements Filter {
- @SuppressWarnings("PMD.AvoidFieldNameMatchingTypeName") // so that when deserializing it has the desired format
- private final Filter not;
+ @SuppressWarnings(
+ "PMD.AvoidFieldNameMatchingTypeName") // so that when deserializing it has the desired format
+ private final Filter not;
- protected Not(@JsonProperty("not") Filter not) {
- Objects.requireNonNull(not, "not is null");
- this.not = not;
- }
+ protected Not(@JsonProperty("not") Filter not) {
+ Objects.requireNonNull(not, "not is null");
+ this.not = not;
+ }
- public Filter getNot() {
- return this.not;
- }
+ public Filter getNot() {
+ return this.not;
+ }
}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/Or.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/Or.java
index a105d85..6bc10ce 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/Or.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/Or.java
@@ -1,24 +1,23 @@
package com.sitepark.ies.contentrepository.core.domain.entity.filter;
-import java.util.List;
-import java.util.Objects;
-
import com.fasterxml.jackson.annotation.JsonProperty;
-
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+import java.util.List;
+import java.util.Objects;
public class Or implements Filter {
- @SuppressWarnings("PMD.AvoidFieldNameMatchingTypeName") // so that when deserializing it has the desired format
- private final List or;
+ @SuppressWarnings(
+ "PMD.AvoidFieldNameMatchingTypeName") // so that when deserializing it has the desired format
+ private final List or;
- protected Or(@JsonProperty("or") Filter... or) {
- Objects.requireNonNull(or, "or is null");
- this.or = List.of(or);
- }
+ protected Or(@JsonProperty("or") Filter... or) {
+ Objects.requireNonNull(or, "or is null");
+ this.or = List.of(or);
+ }
- @SuppressFBWarnings("EI_EXPOSE_REP")
- public List getOr() {
- return this.or;
- }
-}
\ No newline at end of file
+ @SuppressFBWarnings("EI_EXPOSE_REP")
+ public List getOr() {
+ return this.or;
+ }
+}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/Parent.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/Parent.java
index bc04ee8..fe7855e 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/Parent.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/Parent.java
@@ -1,20 +1,20 @@
package com.sitepark.ies.contentrepository.core.domain.entity.filter;
-import java.util.Objects;
-
import com.fasterxml.jackson.annotation.JsonProperty;
+import java.util.Objects;
public class Parent implements Filter {
- @SuppressWarnings("PMD.AvoidFieldNameMatchingTypeName") // so that when deserializing it has the desired format
- private final String parent;
+ @SuppressWarnings(
+ "PMD.AvoidFieldNameMatchingTypeName") // so that when deserializing it has the desired format
+ private final String parent;
- protected Parent(@JsonProperty("parent") String parent) {
- Objects.requireNonNull(parent, "parent is null");
- this.parent = parent;
- }
+ protected Parent(@JsonProperty("parent") String parent) {
+ Objects.requireNonNull(parent, "parent is null");
+ this.parent = parent;
+ }
- public String getParent() {
- return this.parent;
- }
+ public String getParent() {
+ return this.parent;
+ }
}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/ParentAnchor.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/ParentAnchor.java
index c2bb4f4..d47bbc4 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/ParentAnchor.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/ParentAnchor.java
@@ -1,21 +1,22 @@
package com.sitepark.ies.contentrepository.core.domain.entity.filter;
-import java.util.Objects;
-
import com.fasterxml.jackson.annotation.JsonProperty;
+import java.util.Objects;
public class ParentAnchor implements Filter {
- @SuppressWarnings("PMD.AvoidFieldNameMatchingTypeName") // so that when deserializing it has the desired format
- private final com.sitepark.ies.contentrepository.core.domain.entity.Anchor parentAnchor;
+ @SuppressWarnings(
+ "PMD.AvoidFieldNameMatchingTypeName") // so that when deserializing it has the desired format
+ private final com.sitepark.ies.contentrepository.core.domain.entity.Anchor parentAnchor;
- protected ParentAnchor(@JsonProperty("parentAnchor")
- com.sitepark.ies.contentrepository.core.domain.entity.Anchor parentAnchor) {
- Objects.requireNonNull(parentAnchor, "parentAnchor is null");
- this.parentAnchor = parentAnchor;
- }
+ protected ParentAnchor(
+ @JsonProperty("parentAnchor")
+ com.sitepark.ies.contentrepository.core.domain.entity.Anchor parentAnchor) {
+ Objects.requireNonNull(parentAnchor, "parentAnchor is null");
+ this.parentAnchor = parentAnchor;
+ }
- public com.sitepark.ies.contentrepository.core.domain.entity.Anchor getParentAnchor() {
- return this.parentAnchor;
- }
+ public com.sitepark.ies.contentrepository.core.domain.entity.Anchor getParentAnchor() {
+ return this.parentAnchor;
+ }
}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/ParentAnchorList.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/ParentAnchorList.java
index 23a9f26..3278adc 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/ParentAnchorList.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/ParentAnchorList.java
@@ -1,26 +1,25 @@
package com.sitepark.ies.contentrepository.core.domain.entity.filter;
-import java.util.List;
-import java.util.Objects;
-
import com.fasterxml.jackson.annotation.JsonProperty;
-
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+import java.util.List;
+import java.util.Objects;
public class ParentAnchorList implements Filter {
- @SuppressWarnings("PMD.AvoidFieldNameMatchingTypeName") // so that when deserializing it has the desired format
-
- private final List parentAnchorList;
-
- protected ParentAnchorList(@JsonProperty("parentAnchorList")
- com.sitepark.ies.contentrepository.core.domain.entity.Anchor... parentAnchorList) {
- Objects.requireNonNull(parentAnchorList, "parentAnchorList is null");
- this.parentAnchorList = List.of(parentAnchorList);
- }
-
- @SuppressFBWarnings("EI_EXPOSE_REP")
- public List getParentAnchorList() {
- return this.parentAnchorList;
- }
+ @SuppressWarnings(
+ "PMD.AvoidFieldNameMatchingTypeName") // so that when deserializing it has the desired format
+ private final List parentAnchorList;
+
+ protected ParentAnchorList(
+ @JsonProperty("parentAnchorList")
+ com.sitepark.ies.contentrepository.core.domain.entity.Anchor... parentAnchorList) {
+ Objects.requireNonNull(parentAnchorList, "parentAnchorList is null");
+ this.parentAnchorList = List.of(parentAnchorList);
+ }
+
+ @SuppressFBWarnings("EI_EXPOSE_REP")
+ public List getParentAnchorList() {
+ return this.parentAnchorList;
+ }
}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/ParentList.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/ParentList.java
index 005d259..6714cd4 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/ParentList.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/ParentList.java
@@ -1,24 +1,23 @@
package com.sitepark.ies.contentrepository.core.domain.entity.filter;
-import java.util.List;
-import java.util.Objects;
-
import com.fasterxml.jackson.annotation.JsonProperty;
-
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+import java.util.List;
+import java.util.Objects;
public class ParentList implements Filter {
- @SuppressWarnings("PMD.AvoidFieldNameMatchingTypeName") // so that when deserializing it has the desired format
- private final List parentList;
+ @SuppressWarnings(
+ "PMD.AvoidFieldNameMatchingTypeName") // so that when deserializing it has the desired format
+ private final List parentList;
- protected ParentList(@JsonProperty("parentList") String... parentList) {
- Objects.requireNonNull(parentList, "parentList is null");
- this.parentList = List.of(parentList);
- }
+ protected ParentList(@JsonProperty("parentList") String... parentList) {
+ Objects.requireNonNull(parentList, "parentList is null");
+ this.parentList = List.of(parentList);
+ }
- @SuppressFBWarnings("EI_EXPOSE_REP")
- public List getParentList() {
- return this.parentList;
- }
+ @SuppressFBWarnings("EI_EXPOSE_REP")
+ public List getParentList() {
+ return this.parentList;
+ }
}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/Root.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/Root.java
index d34228f..0f5e12b 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/Root.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/Root.java
@@ -1,21 +1,20 @@
package com.sitepark.ies.contentrepository.core.domain.entity.filter;
-import java.util.Objects;
-
import com.fasterxml.jackson.annotation.JsonProperty;
+import java.util.Objects;
public class Root implements Filter {
- @SuppressWarnings("PMD.AvoidFieldNameMatchingTypeName") // so that when deserializing it has the desired format
- private final String root;
-
- protected Root(@JsonProperty("root") String root) {
- Objects.requireNonNull(root, "root is null");
- this.root = root;
- }
+ @SuppressWarnings(
+ "PMD.AvoidFieldNameMatchingTypeName") // so that when deserializing it has the desired format
+ private final String root;
- public String getRoot() {
- return this.root;
- }
+ protected Root(@JsonProperty("root") String root) {
+ Objects.requireNonNull(root, "root is null");
+ this.root = root;
+ }
+ public String getRoot() {
+ return this.root;
+ }
}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/RootList.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/RootList.java
index cb657af..6468fb2 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/RootList.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/RootList.java
@@ -1,24 +1,23 @@
package com.sitepark.ies.contentrepository.core.domain.entity.filter;
-import java.util.List;
-import java.util.Objects;
-
import com.fasterxml.jackson.annotation.JsonProperty;
-
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+import java.util.List;
+import java.util.Objects;
public class RootList implements Filter {
- @SuppressWarnings("PMD.AvoidFieldNameMatchingTypeName") // so that when deserializing it has the desired format
- private final List rootList;
+ @SuppressWarnings(
+ "PMD.AvoidFieldNameMatchingTypeName") // so that when deserializing it has the desired format
+ private final List rootList;
- protected RootList(@JsonProperty("rootList") String... rootList) {
- Objects.requireNonNull(rootList, "rootList is null");
- this.rootList = List.of(rootList);
- }
+ protected RootList(@JsonProperty("rootList") String... rootList) {
+ Objects.requireNonNull(rootList, "rootList is null");
+ this.rootList = List.of(rootList);
+ }
- @SuppressFBWarnings("EI_EXPOSE_REP")
- public List getRootList() {
- return this.rootList;
- }
+ @SuppressFBWarnings("EI_EXPOSE_REP")
+ public List getRootList() {
+ return this.rootList;
+ }
}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/query/CursorBasedQuery.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/query/CursorBasedQuery.java
index 41978aa..266e217 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/query/CursorBasedQuery.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/query/CursorBasedQuery.java
@@ -1,109 +1,103 @@
package com.sitepark.ies.contentrepository.core.domain.entity.query;
-import java.util.Objects;
-
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
+import java.util.Objects;
@JsonDeserialize(builder = Query.Builder.class)
public class CursorBasedQuery extends Query {
- private final int first;
-
- private final String after;
-
- protected CursorBasedQuery(Builder builder) {
- super(builder);
- this.first = builder.first;
- this.after = builder.after;
- }
-
- public int getFirst() {
- return this.first;
- }
-
- public String getAfter() {
- return this.after;
- }
-
- @Override
- public final int hashCode() {
- return Objects.hash(
- super.hashCode(),
- this.first,
- this.after);
- }
-
- @Override
- public final boolean equals(Object o) {
-
- if (!(o instanceof CursorBasedQuery)) {
- return false;
- }
-
- CursorBasedQuery that = (CursorBasedQuery)o;
-
- return
- that.canEqual(this) &&
- super.equals(o) &&
- Objects.equals(this.first, that.first) &&
- Objects.equals(this.after, that.after);
- }
-
- /**
- * @see
- * How to Write an Equality Method in Java
- *
- */
- @Override
- public boolean canEqual(Object other) {
- return (other instanceof CursorBasedQuery);
- }
-
-
- public static Builder builder() {
- return new Builder();
- }
-
- @Override
- public Builder toBuilder() {
- return new Builder(this);
- }
-
- @JsonPOJOBuilder(withPrefix = "", buildMethodName = "build")
- public static class Builder extends Query.Builder {
-
- private int first;
-
- private String after;
-
- protected Builder() { }
-
- protected Builder(CursorBasedQuery curserBasedQuery) {
- super(curserBasedQuery);
- this.first = curserBasedQuery.first;
- this.after = curserBasedQuery.after;
- }
-
- public Builder first(int first) {
- this.first = first;
- return this.self();
- }
-
- public Builder after(String after) {
- Objects.requireNonNull(after, "after is null");
- this.after = after;
- return this.self();
- }
-
- @Override
- public CursorBasedQuery build() {
- return new CursorBasedQuery(this);
- }
-
- @Override
- public Builder self() {
- return this;
- }
- }
+ private final int first;
+
+ private final String after;
+
+ protected CursorBasedQuery(Builder builder) {
+ super(builder);
+ this.first = builder.first;
+ this.after = builder.after;
+ }
+
+ public int getFirst() {
+ return this.first;
+ }
+
+ public String getAfter() {
+ return this.after;
+ }
+
+ @Override
+ public final int hashCode() {
+ return Objects.hash(super.hashCode(), this.first, this.after);
+ }
+
+ @Override
+ public final boolean equals(Object o) {
+
+ if (!(o instanceof CursorBasedQuery)) {
+ return false;
+ }
+
+ CursorBasedQuery that = (CursorBasedQuery) o;
+
+ return that.canEqual(this)
+ && super.equals(o)
+ && Objects.equals(this.first, that.first)
+ && Objects.equals(this.after, that.after);
+ }
+
+ /**
+ * @see
+ * How to Write an Equality Method in Java
+ *
+ */
+ @Override
+ public boolean canEqual(Object other) {
+ return (other instanceof CursorBasedQuery);
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ @Override
+ public Builder toBuilder() {
+ return new Builder(this);
+ }
+
+ @JsonPOJOBuilder(withPrefix = "", buildMethodName = "build")
+ public static class Builder extends Query.Builder {
+
+ private int first;
+
+ private String after;
+
+ protected Builder() {}
+
+ protected Builder(CursorBasedQuery curserBasedQuery) {
+ super(curserBasedQuery);
+ this.first = curserBasedQuery.first;
+ this.after = curserBasedQuery.after;
+ }
+
+ public Builder first(int first) {
+ this.first = first;
+ return this.self();
+ }
+
+ public Builder after(String after) {
+ Objects.requireNonNull(after, "after is null");
+ this.after = after;
+ return this.self();
+ }
+
+ @Override
+ public CursorBasedQuery build() {
+ return new CursorBasedQuery(this);
+ }
+
+ @Override
+ public Builder self() {
+ return this;
+ }
+ }
}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/query/Query.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/query/Query.java
index 07e1677..8ad4e1a 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/query/Query.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/query/Query.java
@@ -1,139 +1,134 @@
package com.sitepark.ies.contentrepository.core.domain.entity.query;
-import java.util.Objects;
-import java.util.Optional;
-
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
import com.sitepark.ies.contentrepository.core.domain.entity.filter.Filter;
import com.sitepark.ies.contentrepository.core.domain.entity.sort.OrderBy;
+import java.util.Objects;
+import java.util.Optional;
@JsonDeserialize(builder = Query.Builder.class)
public class Query {
- private final Filter filterBy;
+ private final Filter filterBy;
+
+ private final OrderBy orderBy;
+
+ private final QueryOptions options;
+
+ protected Query(Builder> builder) {
+ this.filterBy = builder.filterBy;
+ this.orderBy = builder.orderBy;
+ this.options = builder.options;
+ }
- private final OrderBy orderBy;
+ public Optional getFilterBy() {
+ return Optional.ofNullable(this.filterBy);
+ }
- private final QueryOptions options;
+ public OrderBy getOrderBy() {
+ return this.orderBy;
+ }
- protected Query(Builder> builder) {
- this.filterBy = builder.filterBy;
- this.orderBy = builder.orderBy;
- this.options = builder.options;
- }
+ public QueryOptions getOptions() {
+ return this.options;
+ }
- public Optional getFilterBy() {
- return Optional.ofNullable(this.filterBy);
- }
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.filterBy, this.orderBy, this.options);
+ }
- public OrderBy getOrderBy() {
- return this.orderBy;
- }
+ @Override
+ public boolean equals(Object o) {
- public QueryOptions getOptions() {
- return this.options;
- }
+ if (!(o instanceof Query)) {
+ return false;
+ }
- @Override
- public int hashCode() {
- return Objects.hash(
- this.filterBy,
- this.orderBy,
- this.options);
- }
+ Query that = (Query) o;
- @Override
- public boolean equals(Object o) {
+ return that.canEqual(this)
+ && Objects.equals(this.filterBy, that.filterBy)
+ && Objects.equals(this.orderBy, that.orderBy)
+ && Objects.equals(this.options, that.options);
+ }
- if (!(o instanceof Query)) {
- return false;
- }
+ /**
+ * @see
+ * How to Write an Equality Method in Java
+ *
+ */
+ public boolean canEqual(Object other) {
+ return (other instanceof Query);
+ }
- Query that = (Query)o;
+ public static Builder> builder() {
+ return new QueryBuilder();
+ }
- return
- that.canEqual(this) &&
- Objects.equals(this.filterBy, that.filterBy) &&
- Objects.equals(this.orderBy, that.orderBy) &&
- Objects.equals(this.options, that.options);
- }
+ public Builder> toBuilder() {
+ return new QueryBuilder(this);
+ }
- /**
- * @see
- * How to Write an Equality Method in Java
- *
- */
- public boolean canEqual(Object other) {
- return (other instanceof Query);
- }
+ public abstract static class Builder> {
- public static Builder> builder() {
- return new QueryBuilder();
- }
+ protected Filter filterBy;
- public Builder> toBuilder() {
- return new QueryBuilder(this);
- }
+ protected OrderBy orderBy;
- public static abstract class Builder> {
+ protected QueryOptions options;
- protected Filter filterBy;
+ protected Builder() {}
- protected OrderBy orderBy;
+ protected Builder(Query query) {
+ this.filterBy = query.filterBy;
+ this.orderBy = query.orderBy;
+ this.options = query.options;
+ }
- protected QueryOptions options;
+ public B filterBy(Filter filterBy) {
+ this.filterBy = filterBy;
+ return this.self();
+ }
- protected Builder() { }
+ public B orderBy(OrderBy orderBy) {
+ Objects.requireNonNull(orderBy, "orderBy is null");
+ this.orderBy = orderBy;
+ return this.self();
+ }
- protected Builder(Query query) {
- this.filterBy = query.filterBy;
- this.orderBy = query.orderBy;
- this.options = query.options;
- }
+ public B options(QueryOptions options) {
+ Objects.requireNonNull(options, "options is null");
+ this.options = options;
+ return this.self();
+ }
- public B filterBy(Filter filterBy) {
- this.filterBy = filterBy;
- return this.self();
- }
+ public abstract B self();
- public B orderBy(OrderBy orderBy) {
- Objects.requireNonNull(orderBy, "orderBy is null");
- this.orderBy = orderBy;
- return this.self();
- }
+ public abstract Query build();
+ }
- public B options(QueryOptions options) {
- Objects.requireNonNull(options, "options is null");
- this.options = options;
- return this.self();
- }
+ @JsonPOJOBuilder(withPrefix = "", buildMethodName = "build")
+ public static class QueryBuilder extends Query.Builder {
- public abstract B self();
+ protected QueryBuilder() {}
- public abstract Query build();
- }
-
- @JsonPOJOBuilder(withPrefix = "", buildMethodName = "build")
- public static class QueryBuilder extends Query.Builder {
-
- protected QueryBuilder() { }
-
- protected QueryBuilder(Query query) {
- super(query);
- }
-
- @Override
- public QueryBuilder self() {
- return this;
- }
-
- @Override
- public Query build() {
- if (this.options == null) {
- this.options = QueryOptions.builder().build();
- }
- return new Query(this);
- }
- }
+ protected QueryBuilder(Query query) {
+ super(query);
+ }
+
+ @Override
+ public QueryBuilder self() {
+ return this;
+ }
+
+ @Override
+ public Query build() {
+ if (this.options == null) {
+ this.options = QueryOptions.builder().build();
+ }
+ return new Query(this);
+ }
+ }
}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/query/QueryOptions.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/query/QueryOptions.java
index 3a14702..944b283 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/query/QueryOptions.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/query/QueryOptions.java
@@ -4,61 +4,58 @@
public class QueryOptions {
- private final boolean showHidden;
+ private final boolean showHidden;
- protected QueryOptions(Builder builder) {
- this.showHidden = builder.showHidden;
- }
+ protected QueryOptions(Builder builder) {
+ this.showHidden = builder.showHidden;
+ }
- public boolean isShowHidden() {
- return this.showHidden;
- }
+ public boolean isShowHidden() {
+ return this.showHidden;
+ }
- @Override
- public final int hashCode() {
- return Objects.hash(
- this.showHidden);
- }
+ @Override
+ public final int hashCode() {
+ return Objects.hash(this.showHidden);
+ }
- @Override
- public final boolean equals(Object o) {
+ @Override
+ public final boolean equals(Object o) {
- if (!(o instanceof QueryOptions)) {
- return false;
- }
+ if (!(o instanceof QueryOptions)) {
+ return false;
+ }
- QueryOptions that = (QueryOptions)o;
+ QueryOptions that = (QueryOptions) o;
- return
- Objects.equals(this.showHidden, that.showHidden);
- }
+ return Objects.equals(this.showHidden, that.showHidden);
+ }
- public static Builder builder() {
- return new Builder();
- }
+ public static Builder builder() {
+ return new Builder();
+ }
- public Builder toBuilder() {
- return new Builder(this);
- }
+ public Builder toBuilder() {
+ return new Builder(this);
+ }
- public static class Builder {
+ public static class Builder {
- private boolean showHidden;
+ private boolean showHidden;
- protected Builder() {
- }
+ protected Builder() {}
- protected Builder(QueryOptions queryOptions) {
- this.showHidden = queryOptions.showHidden;
- }
+ protected Builder(QueryOptions queryOptions) {
+ this.showHidden = queryOptions.showHidden;
+ }
- public Builder showHidden(boolean showHidden) {
- this.showHidden = showHidden;
- return this;
- }
+ public Builder showHidden(boolean showHidden) {
+ this.showHidden = showHidden;
+ return this;
+ }
- public QueryOptions build() {
- return new QueryOptions(this);
- }
- }
+ public QueryOptions build() {
+ return new QueryOptions(this);
+ }
+ }
}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/query/SubTreeQuery.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/query/SubTreeQuery.java
index f1b2c9d..cb74644 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/query/SubTreeQuery.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/query/SubTreeQuery.java
@@ -1,106 +1,100 @@
package com.sitepark.ies.contentrepository.core.domain.entity.query;
+import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
-import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
-
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-
public class SubTreeQuery extends Query {
- private final List rootList;
-
- protected SubTreeQuery(Builder builder) {
- super(builder);
- this.rootList = Collections.unmodifiableList(builder.rootList);
- }
-
- @SuppressFBWarnings("EI_EXPOSE_REP")
- public List getRootList() {
- return this.rootList;
- }
-
- @Override
- public final int hashCode() {
- return Objects.hash(
- super.hashCode(),
- this.rootList);
- }
-
- @Override
- public final boolean equals(Object o) {
-
- if (!(o instanceof SubTreeQuery)) {
- return false;
- }
-
- SubTreeQuery that = (SubTreeQuery)o;
-
- return
- that.canEqual(this) &&
- super.equals(o) &&
- Objects.equals(this.rootList, that.rootList);
- }
-
- /**
- * @see
- * How to Write an Equality Method in Java
- *
- */
- @Override
- public boolean canEqual(Object other) {
- return (other instanceof SubTreeQuery);
- }
- public static Builder builder() {
- return new Builder();
- }
-
- @Override
- public Builder toBuilder() {
- return new Builder(this);
- }
-
- @JsonPOJOBuilder(withPrefix = "", buildMethodName = "build")
- public static class Builder extends Query.Builder {
-
- private final List rootList = new ArrayList<>();
-
- protected Builder() { }
-
- protected Builder(SubTreeQuery curserBasedQuery) {
- super(curserBasedQuery);
- this.rootList.addAll(curserBasedQuery.rootList);
- }
-
- public Builder root(Long root) {
- Objects.requireNonNull(root, "root is null");
- this.rootList.add(root);
- return this.self();
- }
-
- public Builder rootList(List rootList) {
- Objects.requireNonNull(rootList, "rootList is null");
- this.rootList.clear();
- for (Long root : rootList) {
- this.root(root);
- }
- return this.self();
- }
-
- @Override
- public SubTreeQuery build() {
- if (this.rootList.isEmpty()) {
- throw new IllegalStateException("rootList must not be empty");
- }
- return new SubTreeQuery(this);
- }
-
- @Override
- public Builder self() {
- return this;
- }
- }
+ private final List rootList;
+
+ protected SubTreeQuery(Builder builder) {
+ super(builder);
+ this.rootList = Collections.unmodifiableList(builder.rootList);
+ }
+
+ @SuppressFBWarnings("EI_EXPOSE_REP")
+ public List getRootList() {
+ return this.rootList;
+ }
+
+ @Override
+ public final int hashCode() {
+ return Objects.hash(super.hashCode(), this.rootList);
+ }
+
+ @Override
+ public final boolean equals(Object o) {
+
+ if (!(o instanceof SubTreeQuery)) {
+ return false;
+ }
+
+ SubTreeQuery that = (SubTreeQuery) o;
+
+ return that.canEqual(this) && super.equals(o) && Objects.equals(this.rootList, that.rootList);
+ }
+
+ /**
+ * @see
+ * How to Write an Equality Method in Java
+ *
+ */
+ @Override
+ public boolean canEqual(Object other) {
+ return (other instanceof SubTreeQuery);
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ @Override
+ public Builder toBuilder() {
+ return new Builder(this);
+ }
+
+ @JsonPOJOBuilder(withPrefix = "", buildMethodName = "build")
+ public static class Builder extends Query.Builder {
+
+ private final List rootList = new ArrayList<>();
+
+ protected Builder() {}
+
+ protected Builder(SubTreeQuery curserBasedQuery) {
+ super(curserBasedQuery);
+ this.rootList.addAll(curserBasedQuery.rootList);
+ }
+
+ public Builder root(Long root) {
+ Objects.requireNonNull(root, "root is null");
+ this.rootList.add(root);
+ return this.self();
+ }
+
+ public Builder rootList(List rootList) {
+ Objects.requireNonNull(rootList, "rootList is null");
+ this.rootList.clear();
+ for (Long root : rootList) {
+ this.root(root);
+ }
+ return this.self();
+ }
+
+ @Override
+ public SubTreeQuery build() {
+ if (this.rootList.isEmpty()) {
+ throw new IllegalStateException("rootList must not be empty");
+ }
+ return new SubTreeQuery(this);
+ }
+
+ @Override
+ public Builder self() {
+ return this;
+ }
+ }
}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/sort/Direction.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/sort/Direction.java
index 543fb44..17d378a 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/sort/Direction.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/sort/Direction.java
@@ -1,6 +1,6 @@
package com.sitepark.ies.contentrepository.core.domain.entity.sort;
public enum Direction {
- ASC,
- DESC
+ ASC,
+ DESC
}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/sort/Name.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/sort/Name.java
index 7bb7bcd..b3e536b 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/sort/Name.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/sort/Name.java
@@ -6,48 +6,50 @@
@JsonDeserialize(builder = Name.Builder.class)
public class Name extends OrderCriteria {
- protected Name(Builder builder) {
- super(builder);
- }
-
- @Override
- public String toString() {
- StringBuilder b = new StringBuilder(100)
- .append("OrderBy.Name[name:")
- .append(this.getName())
- .append(", direction:")
- .append(this.getDirection())
- .append(']');
- return b.toString();
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- @Override public Builder toBuilder() {
- return new Builder(this);
- }
-
- @JsonPOJOBuilder(withPrefix = "", buildMethodName = "build")
- public static class Builder extends OrderCriteria.Builder {
-
- protected Builder() {
- super();
- }
-
- protected Builder(Name name) {
- super(name);
- }
-
- @Override
- public Name build() {
- return new Name(this);
- }
-
- @Override
- public Builder self() {
- return this;
- }
- }
+ protected Name(Builder builder) {
+ super(builder);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder b =
+ new StringBuilder(100)
+ .append("OrderBy.Name[name:")
+ .append(this.getName())
+ .append(", direction:")
+ .append(this.getDirection())
+ .append(']');
+ return b.toString();
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ @Override
+ public Builder toBuilder() {
+ return new Builder(this);
+ }
+
+ @JsonPOJOBuilder(withPrefix = "", buildMethodName = "build")
+ public static class Builder extends OrderCriteria.Builder {
+
+ protected Builder() {
+ super();
+ }
+
+ protected Builder(Name name) {
+ super(name);
+ }
+
+ @Override
+ public Name build() {
+ return new Name(this);
+ }
+
+ @Override
+ public Builder self() {
+ return this;
+ }
+ }
}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/sort/OrderBy.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/sort/OrderBy.java
index bc2a590..5f371a6 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/sort/OrderBy.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/sort/OrderBy.java
@@ -1,89 +1,81 @@
package com.sitepark.ies.contentrepository.core.domain.entity.sort;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
-
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-
@JsonDeserialize(builder = OrderBy.Builder.class)
public class OrderBy {
- private final List sort;
-
- protected OrderBy(Builder builder) {
- this.sort = Collections.unmodifiableList(builder.sort);
- }
-
- @SuppressFBWarnings("EI_EXPOSE_REP")
- public List getSort() {
- return this.sort;
- }
-
- @Override
- public final int hashCode() {
- return Objects.hash(
- this.sort);
- }
-
- @Override
- public final boolean equals(Object o) {
-
- if (!(o instanceof OrderBy)) {
- return false;
- }
-
- OrderBy orderBy = (OrderBy)o;
-
- return Objects.equals(this.sort, orderBy.sort);
- }
-
- @Override
- public String toString() {
- StringBuilder b = new StringBuilder(100)
- .append("OrderBy[sort:")
- .append(this.sort)
- .append(']');
- return b.toString();
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- public Builder toBuilder() {
- return new Builder(this);
- }
-
- @JsonPOJOBuilder(withPrefix = "", buildMethodName = "build")
- public static class Builder {
-
- private final List sort = new ArrayList<>();
-
- protected Builder() { }
-
- protected Builder(OrderBy orderBy) {
- this.sort.addAll(orderBy.sort);
- }
-
- @SuppressWarnings("PMD.UseArraysAsList")
- public Builder sort(OrderCriteria... sortCriteriaList) {
- Objects.requireNonNull(sortCriteriaList, "sortCriteriaList is null");
- for (OrderCriteria sortCriteria : sortCriteriaList) {
- Objects.requireNonNull(
- sortCriteria,
- "sortCriteria in sortCriteriaList is null");
- this.sort.add(sortCriteria);
- }
- return this;
- }
-
- public OrderBy build() {
- return new OrderBy(this);
- }
- }
+ private final List sort;
+
+ protected OrderBy(Builder builder) {
+ this.sort = Collections.unmodifiableList(builder.sort);
+ }
+
+ @SuppressFBWarnings("EI_EXPOSE_REP")
+ public List getSort() {
+ return this.sort;
+ }
+
+ @Override
+ public final int hashCode() {
+ return Objects.hash(this.sort);
+ }
+
+ @Override
+ public final boolean equals(Object o) {
+
+ if (!(o instanceof OrderBy)) {
+ return false;
+ }
+
+ OrderBy orderBy = (OrderBy) o;
+
+ return Objects.equals(this.sort, orderBy.sort);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder b = new StringBuilder(100).append("OrderBy[sort:").append(this.sort).append(']');
+ return b.toString();
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public Builder toBuilder() {
+ return new Builder(this);
+ }
+
+ @JsonPOJOBuilder(withPrefix = "", buildMethodName = "build")
+ public static class Builder {
+
+ private final List sort = new ArrayList<>();
+
+ protected Builder() {}
+
+ protected Builder(OrderBy orderBy) {
+ this.sort.addAll(orderBy.sort);
+ }
+
+ @SuppressWarnings("PMD.UseArraysAsList")
+ public Builder sort(OrderCriteria... sortCriteriaList) {
+ Objects.requireNonNull(sortCriteriaList, "sortCriteriaList is null");
+ for (OrderCriteria sortCriteria : sortCriteriaList) {
+ Objects.requireNonNull(sortCriteria, "sortCriteria in sortCriteriaList is null");
+ this.sort.add(sortCriteria);
+ }
+ return this;
+ }
+
+ public OrderBy build() {
+ return new OrderBy(this);
+ }
+ }
}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/sort/OrderCriteria.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/sort/OrderCriteria.java
index bc9d337..7f10c51 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/sort/OrderCriteria.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/sort/OrderCriteria.java
@@ -1,80 +1,77 @@
package com.sitepark.ies.contentrepository.core.domain.entity.sort;
-import java.util.Objects;
-
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
+import java.util.Objects;
@JsonDeserialize(builder = OrderCriteria.Builder.class)
public abstract class OrderCriteria {
- private final String name;
+ private final String name;
- private final Direction direction;
+ private final Direction direction;
- protected OrderCriteria(Builder> builder) {
- this.name = builder.name;
- this.direction = builder.direction;
- }
+ protected OrderCriteria(Builder> builder) {
+ this.name = builder.name;
+ this.direction = builder.direction;
+ }
- public String getName() {
- return this.name;
- }
+ public String getName() {
+ return this.name;
+ }
- public Direction getDirection() {
- return this.direction;
- }
+ public Direction getDirection() {
+ return this.direction;
+ }
- @Override
- public final int hashCode() {
- return Objects.hash(
- this.name,
- this.direction);
- }
+ @Override
+ public final int hashCode() {
+ return Objects.hash(this.name, this.direction);
+ }
- @Override
- public final boolean equals(Object o) {
+ @Override
+ public final boolean equals(Object o) {
- if (!(o instanceof OrderCriteria)) {
- return false;
- }
+ if (!(o instanceof OrderCriteria)) {
+ return false;
+ }
- OrderCriteria criteria = (OrderCriteria)o;
+ OrderCriteria criteria = (OrderCriteria) o;
- return Objects.equals(this.name, criteria.name) &&
- Objects.equals(this.direction, criteria.direction);
- }
+ return Objects.equals(this.name, criteria.name)
+ && Objects.equals(this.direction, criteria.direction);
+ }
- public abstract Builder> toBuilder();
+ public abstract Builder> toBuilder();
- @JsonPOJOBuilder(withPrefix = "", buildMethodName = "build")
- public static abstract class Builder> {
+ @JsonPOJOBuilder(withPrefix = "", buildMethodName = "build")
+ public abstract static class Builder> {
- private String name;
+ private String name;
- private Direction direction = Direction.DESC;
+ private Direction direction = Direction.DESC;
- protected Builder() { }
+ protected Builder() {}
- protected Builder(OrderCriteria sortCriteria) {
- this.name = sortCriteria.name;
- this.direction = sortCriteria.direction;
- }
+ protected Builder(OrderCriteria sortCriteria) {
+ this.name = sortCriteria.name;
+ this.direction = sortCriteria.direction;
+ }
- public B name(String name) {
- Objects.requireNonNull(name, "name is null");
- this.name = name;
- return this.self();
- }
+ public B name(String name) {
+ Objects.requireNonNull(name, "name is null");
+ this.name = name;
+ return this.self();
+ }
- public B direction(Direction direction) {
- Objects.requireNonNull(direction, "direction is null");
- this.direction = direction;
- return this.self();
- }
+ public B direction(Direction direction) {
+ Objects.requireNonNull(direction, "direction is null");
+ this.direction = direction;
+ return this.self();
+ }
- public abstract B self();
+ public abstract B self();
- public abstract OrderCriteria build();
- }
+ public abstract OrderCriteria build();
+ }
}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/AccessDeniedException.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/AccessDeniedException.java
index 4d6c755..710b337 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/AccessDeniedException.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/AccessDeniedException.java
@@ -1,13 +1,13 @@
package com.sitepark.ies.contentrepository.core.domain.exception;
public class AccessDeniedException extends ContentRepositoryException {
- private static final long serialVersionUID = 1L;
+ private static final long serialVersionUID = 1L;
- public AccessDeniedException(String message) {
- super(message);
- }
+ public AccessDeniedException(String message) {
+ super(message);
+ }
- public AccessDeniedException(String message, Throwable t) {
- super(message, t);
- }
-}
\ No newline at end of file
+ public AccessDeniedException(String message, Throwable t) {
+ super(message, t);
+ }
+}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/AnchorAlreadyExistsException.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/AnchorAlreadyExistsException.java
index 43ee728..b2cdd3d 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/AnchorAlreadyExistsException.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/AnchorAlreadyExistsException.java
@@ -4,29 +4,28 @@
public class AnchorAlreadyExistsException extends ContentRepositoryException {
- private static final long serialVersionUID = 1L;
+ private static final long serialVersionUID = 1L;
- private final Anchor anchor;
+ private final Anchor anchor;
- private final long owner;
+ private final long owner;
- public AnchorAlreadyExistsException(Anchor anchor, long owner) {
- super();
- this.anchor = anchor;
- this.owner = owner;
- }
+ public AnchorAlreadyExistsException(Anchor anchor, long owner) {
+ super();
+ this.anchor = anchor;
+ this.owner = owner;
+ }
- public Anchor getAnchor() {
- return this.anchor;
- }
+ public Anchor getAnchor() {
+ return this.anchor;
+ }
- public long getOwner() {
- return this.owner;
- }
-
- @Override
- public String getMessage() {
- return "Anchor " + this.anchor + " already exists for entity " + this.owner;
- }
+ public long getOwner() {
+ return this.owner;
+ }
+ @Override
+ public String getMessage() {
+ return "Anchor " + this.anchor + " already exists for entity " + this.owner;
+ }
}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/AnchorNotFoundException.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/AnchorNotFoundException.java
index 86fa15e..771b2fc 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/AnchorNotFoundException.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/AnchorNotFoundException.java
@@ -4,21 +4,21 @@
public class AnchorNotFoundException extends ContentRepositoryException {
- private static final long serialVersionUID = 1L;
+ private static final long serialVersionUID = 1L;
- private final Anchor anchor;
+ private final Anchor anchor;
- public AnchorNotFoundException(Anchor anchor) {
- super();
- this.anchor = anchor;
- }
+ public AnchorNotFoundException(Anchor anchor) {
+ super();
+ this.anchor = anchor;
+ }
- public Anchor getAnchor() {
- return this.anchor;
- }
+ public Anchor getAnchor() {
+ return this.anchor;
+ }
- @Override
- public String getMessage() {
- return "Entity with anchor " + this.anchor + " not found";
- }
-}
\ No newline at end of file
+ @Override
+ public String getMessage() {
+ return "Entity with anchor " + this.anchor + " not found";
+ }
+}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/ContentRepositoryException.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/ContentRepositoryException.java
index a24e1c9..1087ae3 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/ContentRepositoryException.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/ContentRepositoryException.java
@@ -2,15 +2,17 @@
public abstract class ContentRepositoryException extends RuntimeException {
- private static final long serialVersionUID = 1L;
+ private static final long serialVersionUID = 1L;
- public ContentRepositoryException() {
- super();
- }
- public ContentRepositoryException(String message) {
- super(message);
- }
- public ContentRepositoryException(String message, Throwable t) {
- super(message, t);
- }
+ public ContentRepositoryException() {
+ super();
+ }
+
+ public ContentRepositoryException(String message) {
+ super(message);
+ }
+
+ public ContentRepositoryException(String message, Throwable t) {
+ super(message, t);
+ }
}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/EntityLockedException.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/EntityLockedException.java
index c636302..15be49d 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/EntityLockedException.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/EntityLockedException.java
@@ -4,21 +4,21 @@
public class EntityLockedException extends ContentRepositoryException {
- private static final long serialVersionUID = 1L;
+ private static final long serialVersionUID = 1L;
- private final EntityLock lock;
+ private final EntityLock lock;
- public EntityLockedException(EntityLock lock) {
- super();
- this.lock = lock;
- }
+ public EntityLockedException(EntityLock lock) {
+ super();
+ this.lock = lock;
+ }
- public EntityLock getLock() {
- return this.lock;
- }
+ public EntityLock getLock() {
+ return this.lock;
+ }
- @Override
- public String getMessage() {
- return "Entity is locked: " + this.lock;
- }
+ @Override
+ public String getMessage() {
+ return "Entity is locked: " + this.lock;
+ }
}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/EntityNotFoundException.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/EntityNotFoundException.java
index a85e6bb..6ec6ad2 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/EntityNotFoundException.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/EntityNotFoundException.java
@@ -2,21 +2,21 @@
public class EntityNotFoundException extends ContentRepositoryException {
- private static final long serialVersionUID = 1L;
+ private static final long serialVersionUID = 1L;
- private final String id;
+ private final String id;
- public EntityNotFoundException(String id) {
- super();
- this.id = id;
- }
+ public EntityNotFoundException(String id) {
+ super();
+ this.id = id;
+ }
- public String getId() {
- return this.id;
- }
+ public String getId() {
+ return this.id;
+ }
- @Override
- public String getMessage() {
- return "Entity with id " + this.id + " not found";
- }
+ @Override
+ public String getMessage() {
+ return "Entity with id " + this.id + " not found";
+ }
}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/GroupNotEmptyException.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/GroupNotEmptyException.java
index c94ff91..1e63ad1 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/GroupNotEmptyException.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/GroupNotEmptyException.java
@@ -1,22 +1,21 @@
package com.sitepark.ies.contentrepository.core.domain.exception;
public class GroupNotEmptyException extends ContentRepositoryException {
- private static final long serialVersionUID = 1L;
+ private static final long serialVersionUID = 1L;
- private final String id;
+ private final String id;
- public GroupNotEmptyException(String id) {
- super();
- this.id = id;
- }
+ public GroupNotEmptyException(String id) {
+ super();
+ this.id = id;
+ }
- public String getId() {
- return this.id;
- }
+ public String getId() {
+ return this.id;
+ }
- @Override
- public String getMessage() {
- return "Group with id " + this.id + " not empty";
- }
-
-}
\ No newline at end of file
+ @Override
+ public String getMessage() {
+ return "Group with id " + this.id + " not empty";
+ }
+}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/InvalidAnchorException.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/InvalidAnchorException.java
index 89ce988..3017e9a 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/InvalidAnchorException.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/InvalidAnchorException.java
@@ -2,21 +2,21 @@
public class InvalidAnchorException extends ContentRepositoryException {
- private final String name;
+ private final String name;
- private static final long serialVersionUID = 1L;
+ private static final long serialVersionUID = 1L;
- public InvalidAnchorException(String name, String message) {
- super(message);
- this.name = name;
- }
+ public InvalidAnchorException(String name, String message) {
+ super(message);
+ this.name = name;
+ }
- public String getName() {
- return this.name;
- }
+ public String getName() {
+ return this.name;
+ }
- @Override
- public String getMessage() {
- return "Invalid anchor '" + this.name + "': " + super.getMessage();
- }
+ @Override
+ public String getMessage() {
+ return "Invalid anchor '" + this.name + "': " + super.getMessage();
+ }
}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/ParentMissingException.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/ParentMissingException.java
index 4e66c28..c0d6878 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/ParentMissingException.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/exception/ParentMissingException.java
@@ -1,5 +1,5 @@
package com.sitepark.ies.contentrepository.core.domain.exception;
public class ParentMissingException extends ContentRepositoryException {
- private static final long serialVersionUID = 1L;
-}
\ No newline at end of file
+ private static final long serialVersionUID = 1L;
+}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/service/ContentDiffer.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/service/ContentDiffer.java
index e42b22c..1dd9a4f 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/service/ContentDiffer.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/service/ContentDiffer.java
@@ -4,7 +4,7 @@
import com.sitepark.ies.contentrepository.core.domain.entity.Entity;
public class ContentDiffer {
- public ChangeSet diff(Entity left, Entity right) {
- throw new UnsupportedOperationException();
- }
+ public ChangeSet diff(Entity left, Entity right) {
+ throw new UnsupportedOperationException();
+ }
}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/port/AccessControl.java b/src/main/java/com/sitepark/ies/contentrepository/core/port/AccessControl.java
index fc86301..ec17bbe 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/port/AccessControl.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/port/AccessControl.java
@@ -2,13 +2,19 @@
public interface AccessControl {
- boolean isEntityCreateable(String parent);
- boolean isEntityReadable(String id);
- boolean isEntityWritable(String id);
- boolean isEntityRemovable(String id);
-
- boolean isGroupCreateable(String parent);
- boolean isGroupReadable(String id);
- boolean isGroupWritable(String id);
- boolean isGroupRemoveable(String id);
+ boolean isEntityCreateable(String parent);
+
+ boolean isEntityReadable(String id);
+
+ boolean isEntityWritable(String id);
+
+ boolean isEntityRemovable(String id);
+
+ boolean isGroupCreateable(String parent);
+
+ boolean isGroupReadable(String id);
+
+ boolean isGroupWritable(String id);
+
+ boolean isGroupRemoveable(String id);
}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/port/ContentRepository.java b/src/main/java/com/sitepark/ies/contentrepository/core/port/ContentRepository.java
index 5714f82..c14bdb8 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/port/ContentRepository.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/port/ContentRepository.java
@@ -1,18 +1,23 @@
package com.sitepark.ies.contentrepository.core.port;
-import java.util.List;
-import java.util.Optional;
-
import com.sitepark.ies.contentrepository.core.domain.entity.Anchor;
import com.sitepark.ies.contentrepository.core.domain.entity.Entity;
import com.sitepark.ies.contentrepository.core.domain.entity.query.Query;
+import java.util.List;
+import java.util.Optional;
public interface ContentRepository {
- boolean isGroup(String id);
- boolean isEmptyGroup(String id);
- Entity store(Entity entity);
- Optional get(String id);
- void removeEntity(String id);
- Optional resolveAnchor(Anchor anchor);
- List getAll(Query query);
+ boolean isGroup(String id);
+
+ boolean isEmptyGroup(String id);
+
+ Entity store(Entity entity);
+
+ Optional get(String id);
+
+ void removeEntity(String id);
+
+ Optional resolveAnchor(Anchor anchor);
+
+ List getAll(Query query);
}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/port/EntityBulkExecutor.java b/src/main/java/com/sitepark/ies/contentrepository/core/port/EntityBulkExecutor.java
index 7accf9a..425992b 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/port/EntityBulkExecutor.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/port/EntityBulkExecutor.java
@@ -3,5 +3,5 @@
import com.sitepark.ies.contentrepository.core.domain.entity.EntityBulkExecution;
public interface EntityBulkExecutor {
- String execute(EntityBulkExecution execution);
+ String execute(EntityBulkExecution execution);
}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/port/EntityLockManager.java b/src/main/java/com/sitepark/ies/contentrepository/core/port/EntityLockManager.java
index c1fa2d0..51107ee 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/port/EntityLockManager.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/port/EntityLockManager.java
@@ -1,14 +1,17 @@
package com.sitepark.ies.contentrepository.core.port;
+import com.sitepark.ies.contentrepository.core.domain.entity.EntityLock;
import java.util.List;
import java.util.Optional;
-import com.sitepark.ies.contentrepository.core.domain.entity.EntityLock;
-
public interface EntityLockManager {
- Optional getLock(String id);
- EntityLock forceLock(String id);
- void lock(String id);
- void unlock(String id);
- List getLockList();
+ Optional getLock(String id);
+
+ EntityLock forceLock(String id);
+
+ void lock(String id);
+
+ void unlock(String id);
+
+ List getLockList();
}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/port/ExtensionsNotifier.java b/src/main/java/com/sitepark/ies/contentrepository/core/port/ExtensionsNotifier.java
index de5202b..a61ee35 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/port/ExtensionsNotifier.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/port/ExtensionsNotifier.java
@@ -1,5 +1,5 @@
package com.sitepark.ies.contentrepository.core.port;
public interface ExtensionsNotifier {
- void notifyPurge(String id);
+ void notifyPurge(String id);
}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/port/HistoryManager.java b/src/main/java/com/sitepark/ies/contentrepository/core/port/HistoryManager.java
index 27c1efd..ac407cc 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/port/HistoryManager.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/port/HistoryManager.java
@@ -1,13 +1,14 @@
package com.sitepark.ies.contentrepository.core.port;
-import java.time.OffsetDateTime;
-import java.util.List;
-
import com.sitepark.ies.contentrepository.core.domain.entity.HistoryEntry;
import com.sitepark.ies.contentrepository.core.domain.entity.HistoryEntryType;
+import java.time.OffsetDateTime;
+import java.util.List;
public interface HistoryManager {
- void purge(String id);
- HistoryEntry createEntry(String id, OffsetDateTime date, HistoryEntryType type);
- List getHistory(String id);
-}
\ No newline at end of file
+ void purge(String id);
+
+ HistoryEntry createEntry(String id, OffsetDateTime date, HistoryEntryType type);
+
+ List getHistory(String id);
+}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/port/IdGenerator.java b/src/main/java/com/sitepark/ies/contentrepository/core/port/IdGenerator.java
index e3aafa6..aae6bae 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/port/IdGenerator.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/port/IdGenerator.java
@@ -1,5 +1,5 @@
package com.sitepark.ies.contentrepository.core.port;
public interface IdGenerator {
- String generate();
+ String generate();
}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/port/MediaReferenceManager.java b/src/main/java/com/sitepark/ies/contentrepository/core/port/MediaReferenceManager.java
index efb86f1..80b4e0a 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/port/MediaReferenceManager.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/port/MediaReferenceManager.java
@@ -3,6 +3,7 @@
import com.sitepark.ies.contentrepository.core.domain.entity.MediaReference;
public interface MediaReferenceManager {
- void removeByReference(String usedBy);
- void addReference(MediaReference reference);
+ void removeByReference(String usedBy);
+
+ void addReference(MediaReference reference);
}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/port/Publisher.java b/src/main/java/com/sitepark/ies/contentrepository/core/port/Publisher.java
index 0c552aa..dd6af62 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/port/Publisher.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/port/Publisher.java
@@ -5,7 +5,9 @@
import java.util.function.Consumer;
public interface Publisher {
- void republish(String id, LocalDateTime version);
- void depublish(String id);
- void depublish(List idList, Consumer consumer);
+ void republish(String id, LocalDateTime version);
+
+ void depublish(String id);
+
+ void depublish(List idList, Consumer consumer);
}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/port/RecycleBin.java b/src/main/java/com/sitepark/ies/contentrepository/core/port/RecycleBin.java
index 765a6e2..2421aec 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/port/RecycleBin.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/port/RecycleBin.java
@@ -1,14 +1,16 @@
package com.sitepark.ies.contentrepository.core.port;
-import java.util.List;
-import java.util.Optional;
-
import com.sitepark.ies.contentrepository.core.domain.entity.RecycleBinItem;
import com.sitepark.ies.contentrepository.core.domain.entity.RecycleBinItemFilter;
+import java.util.List;
+import java.util.Optional;
public interface RecycleBin {
- Optional get(String id);
- void add(RecycleBinItem item);
- void removeByObject(String id);
- List find(RecycleBinItemFilter filter);
+ Optional get(String id);
+
+ void add(RecycleBinItem item);
+
+ void removeByObject(String id);
+
+ List find(RecycleBinItemFilter filter);
}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/port/SearchIndex.java b/src/main/java/com/sitepark/ies/contentrepository/core/port/SearchIndex.java
index 50365ca..c82d814 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/port/SearchIndex.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/port/SearchIndex.java
@@ -1,6 +1,7 @@
package com.sitepark.ies.contentrepository.core.port;
public interface SearchIndex {
- void index(String id);
- void remove(String id);
+ void index(String id);
+
+ void remove(String id);
}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/port/VersioningManager.java b/src/main/java/com/sitepark/ies/contentrepository/core/port/VersioningManager.java
index 3b22206..c29706a 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/port/VersioningManager.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/port/VersioningManager.java
@@ -1,17 +1,20 @@
package com.sitepark.ies.contentrepository.core.port;
+import com.sitepark.ies.contentrepository.core.domain.entity.Entity;
import java.time.LocalDateTime;
import java.util.List;
-import com.sitepark.ies.contentrepository.core.domain.entity.Entity;
-
public interface VersioningManager {
- void removeAllVersions(String id);
- Entity createNewVersion(Entity entity);
- Entity revertToVersion(LocalDateTime version);
- Entity getVersion(LocalDateTime version);
- Entity getNextVersionSince(LocalDateTime date);
- List getAllMediaReferences(String id);
+ void removeAllVersions(String id);
+
+ Entity createNewVersion(Entity entity);
+
+ Entity revertToVersion(LocalDateTime version);
+
+ Entity getVersion(LocalDateTime version);
+
+ Entity getNextVersionSince(LocalDateTime date);
+ List getAllMediaReferences(String id);
}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/usecase/BulkPurge.java b/src/main/java/com/sitepark/ies/contentrepository/core/usecase/BulkPurge.java
index ecbc8ff..0684dd8 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/usecase/BulkPurge.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/usecase/BulkPurge.java
@@ -1,13 +1,5 @@
package com.sitepark.ies.contentrepository.core.usecase;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.stream.Collectors;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-
import com.sitepark.ies.contentrepository.core.domain.entity.BulkOperationKey;
import com.sitepark.ies.contentrepository.core.domain.entity.Entity;
import com.sitepark.ies.contentrepository.core.domain.entity.EntityBulkExecution;
@@ -28,231 +20,245 @@
import com.sitepark.ies.contentrepository.core.port.RecycleBin;
import com.sitepark.ies.contentrepository.core.port.SearchIndex;
import com.sitepark.ies.contentrepository.core.port.VersioningManager;
-
import jakarta.inject.Inject;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
public class BulkPurge {
- private final ContentRepository repository;
-
- private final EntityLockManager lockManager;
-
- private final VersioningManager versioningManager;
-
- private final HistoryManager historyManager;
-
- private final AccessControl accessControl;
-
- private final RecycleBin recycleBin;
-
- private final SearchIndex searchIndex;
-
- private final MediaReferenceManager mediaReferenceManager;
-
- private final Publisher publisher;
-
- private final ExtensionsNotifier extensionsNotifier;
+ private final ContentRepository repository;
- private final EntityBulkExecutor entityBulkExecutor;
+ private final EntityLockManager lockManager;
- private static Logger LOGGER = LogManager.getLogger();
+ private final VersioningManager versioningManager;
- @Inject
- @SuppressWarnings("PMD.ExcessiveParameterList")
- protected BulkPurge(ContentRepository repository, EntityLockManager lockManager,
- VersioningManager versioningManager, HistoryManager historyManager, AccessControl accessControl,
- RecycleBin recycleBin, SearchIndex searchIndex, MediaReferenceManager mediaReferenceManager,
- Publisher publisher, ExtensionsNotifier extensionsNotifier, EntityBulkExecutor entityBulkExecutor) {
-
- this.repository = repository;
- this.lockManager = lockManager;
- this.historyManager = historyManager;
- this.versioningManager = versioningManager;
- this.accessControl = accessControl;
- this.recycleBin = recycleBin;
- this.searchIndex = searchIndex;
- this.mediaReferenceManager = mediaReferenceManager;
- this.publisher = publisher;
- this.extensionsNotifier = extensionsNotifier;
- this.entityBulkExecutor = entityBulkExecutor;
- }
-
- /**
- * Create a BulkExecution and pass it to the EntityBulkExecutor to execute the purge.
- * The return is a BulkExecution ID that can be used to track the progress.
- *
- * @param input Input argument for the bulk operations
- * @return BulkExecution ID that can be used to track the progress
- */
- public String bulkPurge(BulkPurgeInput input) {
-
- List entityList = this.getEntityList(input);
-
- this.accessControl(entityList);
-
- EntityBulkOperation lock = this.buildLockOperation(entityList, false);
- EntityBulkOperation depublish = this.buildDepublishOperation(entityList);
- EntityBulkOperation purge = this.buildPurgeOperation(entityList);
-
- EntityBulkOperation unlock = this.buildUnlockOperation(entityList);
-
- EntityBulkExecution execution = EntityBulkExecution.builder()
- .topic("contentrepository", "purge")
- .operation(lock, depublish, purge)
- .finalizer(unlock)
- .build();
-
- return this.entityBulkExecutor.execute(execution);
- }
-
- private List getEntityList(BulkPurgeInput input) {
- Query query = this.buildQuery(input);
- return this.repository.getAll(query);
- }
-
- private Query buildQuery(BulkPurgeInput input) {
- if (!input.getRootList().isEmpty()) {
- return SubTreeQuery.builder()
- .rootList(input.getRootList())
- .filterBy(input.getFilter().orElse(null))
- .build();
- }
-
- return Query.builder()
- .filterBy(input.getFilter().get())
- .build();
- }
-
- private void accessControl(List entityList) {
-
- entityList.stream().forEach(entity -> {
- String id = entity.getId().get();
- if (entity.isGroup()) {
- if (!this.accessControl.isGroupRemoveable(id)) {
- throw new AccessDeniedException("Not allowed to remove group " + id);
- }
- } else {
- if (!this.accessControl.isEntityRemovable(id)) {
- throw new AccessDeniedException("Not allowed to remove entity " + id);
- }
- }
- });
- }
-
- private EntityBulkOperation buildLockOperation(List entityList, boolean forceLock) {
-
- return EntityBulkOperation.builder()
- .key(BulkOperationKey.PURGE_LOCK)
- .entityList(entityList)
- .consumer(entity -> {
-
- String id = entity.getId().get();
-
- if (forceLock) {
- this.lockManager.forceLock(id);
- } else {
- this.lockManager.lock(id);
- }
- })
- .build();
- }
-
- private EntityBulkOperation buildDepublishOperation(List entityList) {
-
- return EntityBulkOperation.builder()
- .key(BulkOperationKey.PURGE_DEPUBLISH)
- .entityList(entityList)
- .consumer(entity -> {
- String id = entity.getId().get();
- this.publisher.depublish(id);
- })
- .build();
- }
-
- private EntityBulkOperation buildPurgeOperation(List entityList) {
-
- List nonGroupList = entityList.stream()
- .filter(entity -> !entity.isGroup())
- .collect(Collectors.toList());
-
- List groupList = entityList.stream()
- .filter(entity -> entity.isGroup())
- .collect(Collectors.toList());
-
- /*
- * Arrange the entityList so that first all group entries are deleted
- * and then the groups in the hierarchy from bottom to top.
- * This ensures that only empty pools are deleted.
- */
- List orderedGroupList = this.orderGroupListHierarchicallyFromBottomToTop(groupList);
- List orderedList = new ArrayList<>();
- orderedList.addAll(nonGroupList);
- orderedList.addAll(orderedGroupList);
-
- if (LOGGER.isDebugEnabled()) {
- orderedList.stream()
- .forEach(entity -> {
- LOGGER.debug("purge order: {}", entity);
- });
- }
-
- return EntityBulkOperation.builder()
- .key(BulkOperationKey.PURGE_PURGE)
- .entityList(orderedList)
- .consumer(entity -> {
- String id = entity.getId().get();
-
- if (this.repository.isGroup(id) && !this.repository.isEmptyGroup(id)) {
- throw new GroupNotEmptyException(id);
- }
-
- if (LOGGER.isInfoEnabled()) {
- LOGGER.info("purge: {}", entity);
- }
-
- this.searchIndex.remove(id);
- this.mediaReferenceManager.removeByReference(id);
- this.repository.removeEntity(id);
- this.historyManager.purge(id);
- this.versioningManager.removeAllVersions(id);
- this.recycleBin.removeByObject(id);
- this.extensionsNotifier.notifyPurge(id);
- })
- .build();
- }
-
- /**
- * Arranges the groups according to their hierarchy from bottom to top.
- */
- private List orderGroupListHierarchicallyFromBottomToTop(List groupList) {
-
- EntityTree tree = new EntityTree();
- groupList.stream().forEach(tree::add);
-
- List hierarchicalOrder = tree.getAll();
-
- Collections.reverse(hierarchicalOrder);
-
- return hierarchicalOrder;
- }
-
- private EntityBulkOperation buildUnlockOperation(List entityList) {
-
- return EntityBulkOperation.builder()
- .key(BulkOperationKey.PURGE_CLEANUP)
- .entityList(entityList)
- .consumer(entity -> {
- String id = entity.getId().get();
- try {
- this.lockManager.unlock(id);
- } catch (Exception e) {
- if (LOGGER.isTraceEnabled()) {
- LOGGER.atTrace()
- .withThrowable(e)
- .log("Unable to unlock {}", entity);
- }
- }
- })
- .build();
- }
+ private final HistoryManager historyManager;
+
+ private final AccessControl accessControl;
+
+ private final RecycleBin recycleBin;
+
+ private final SearchIndex searchIndex;
+
+ private final MediaReferenceManager mediaReferenceManager;
+
+ private final Publisher publisher;
+
+ private final ExtensionsNotifier extensionsNotifier;
+
+ private final EntityBulkExecutor entityBulkExecutor;
+
+ private static Logger LOGGER = LogManager.getLogger();
+
+ @Inject
+ @SuppressWarnings("PMD.ExcessiveParameterList")
+ protected BulkPurge(
+ ContentRepository repository,
+ EntityLockManager lockManager,
+ VersioningManager versioningManager,
+ HistoryManager historyManager,
+ AccessControl accessControl,
+ RecycleBin recycleBin,
+ SearchIndex searchIndex,
+ MediaReferenceManager mediaReferenceManager,
+ Publisher publisher,
+ ExtensionsNotifier extensionsNotifier,
+ EntityBulkExecutor entityBulkExecutor) {
+
+ this.repository = repository;
+ this.lockManager = lockManager;
+ this.historyManager = historyManager;
+ this.versioningManager = versioningManager;
+ this.accessControl = accessControl;
+ this.recycleBin = recycleBin;
+ this.searchIndex = searchIndex;
+ this.mediaReferenceManager = mediaReferenceManager;
+ this.publisher = publisher;
+ this.extensionsNotifier = extensionsNotifier;
+ this.entityBulkExecutor = entityBulkExecutor;
+ }
+
+ /**
+ * Create a BulkExecution and pass it to the EntityBulkExecutor to execute the purge.
+ * The return is a BulkExecution ID that can be used to track the progress.
+ *
+ * @param input Input argument for the bulk operations
+ * @return BulkExecution ID that can be used to track the progress
+ */
+ public String bulkPurge(BulkPurgeInput input) {
+
+ List entityList = this.getEntityList(input);
+
+ this.accessControl(entityList);
+
+ EntityBulkOperation lock = this.buildLockOperation(entityList, false);
+ EntityBulkOperation depublish = this.buildDepublishOperation(entityList);
+ EntityBulkOperation purge = this.buildPurgeOperation(entityList);
+
+ EntityBulkOperation unlock = this.buildUnlockOperation(entityList);
+
+ EntityBulkExecution execution =
+ EntityBulkExecution.builder()
+ .topic("contentrepository", "purge")
+ .operation(lock, depublish, purge)
+ .finalizer(unlock)
+ .build();
+
+ return this.entityBulkExecutor.execute(execution);
+ }
+
+ private List getEntityList(BulkPurgeInput input) {
+ Query query = this.buildQuery(input);
+ return this.repository.getAll(query);
+ }
+
+ private Query buildQuery(BulkPurgeInput input) {
+ if (!input.getRootList().isEmpty()) {
+ return SubTreeQuery.builder()
+ .rootList(input.getRootList())
+ .filterBy(input.getFilter().orElse(null))
+ .build();
+ }
+
+ return Query.builder().filterBy(input.getFilter().get()).build();
+ }
+
+ private void accessControl(List entityList) {
+
+ entityList.stream()
+ .forEach(
+ entity -> {
+ String id = entity.getId().get();
+ if (entity.isGroup()) {
+ if (!this.accessControl.isGroupRemoveable(id)) {
+ throw new AccessDeniedException("Not allowed to remove group " + id);
+ }
+ } else {
+ if (!this.accessControl.isEntityRemovable(id)) {
+ throw new AccessDeniedException("Not allowed to remove entity " + id);
+ }
+ }
+ });
+ }
+
+ private EntityBulkOperation buildLockOperation(List entityList, boolean forceLock) {
+
+ return EntityBulkOperation.builder()
+ .key(BulkOperationKey.PURGE_LOCK)
+ .entityList(entityList)
+ .consumer(
+ entity -> {
+ String id = entity.getId().get();
+
+ if (forceLock) {
+ this.lockManager.forceLock(id);
+ } else {
+ this.lockManager.lock(id);
+ }
+ })
+ .build();
+ }
+
+ private EntityBulkOperation buildDepublishOperation(List entityList) {
+
+ return EntityBulkOperation.builder()
+ .key(BulkOperationKey.PURGE_DEPUBLISH)
+ .entityList(entityList)
+ .consumer(
+ entity -> {
+ String id = entity.getId().get();
+ this.publisher.depublish(id);
+ })
+ .build();
+ }
+
+ private EntityBulkOperation buildPurgeOperation(List entityList) {
+
+ List nonGroupList =
+ entityList.stream().filter(entity -> !entity.isGroup()).collect(Collectors.toList());
+
+ List groupList =
+ entityList.stream().filter(entity -> entity.isGroup()).collect(Collectors.toList());
+
+ /*
+ * Arrange the entityList so that first all group entries are deleted
+ * and then the groups in the hierarchy from bottom to top.
+ * This ensures that only empty pools are deleted.
+ */
+ List orderedGroupList = this.orderGroupListHierarchicallyFromBottomToTop(groupList);
+ List orderedList = new ArrayList<>();
+ orderedList.addAll(nonGroupList);
+ orderedList.addAll(orderedGroupList);
+
+ if (LOGGER.isDebugEnabled()) {
+ orderedList.stream()
+ .forEach(
+ entity -> {
+ LOGGER.debug("purge order: {}", entity);
+ });
+ }
+
+ return EntityBulkOperation.builder()
+ .key(BulkOperationKey.PURGE_PURGE)
+ .entityList(orderedList)
+ .consumer(
+ entity -> {
+ String id = entity.getId().get();
+
+ if (this.repository.isGroup(id) && !this.repository.isEmptyGroup(id)) {
+ throw new GroupNotEmptyException(id);
+ }
+
+ if (LOGGER.isInfoEnabled()) {
+ LOGGER.info("purge: {}", entity);
+ }
+
+ this.searchIndex.remove(id);
+ this.mediaReferenceManager.removeByReference(id);
+ this.repository.removeEntity(id);
+ this.historyManager.purge(id);
+ this.versioningManager.removeAllVersions(id);
+ this.recycleBin.removeByObject(id);
+ this.extensionsNotifier.notifyPurge(id);
+ })
+ .build();
+ }
+
+ /**
+ * Arranges the groups according to their hierarchy from bottom to top.
+ */
+ private List orderGroupListHierarchicallyFromBottomToTop(List groupList) {
+
+ EntityTree tree = new EntityTree();
+ groupList.stream().forEach(tree::add);
+
+ List hierarchicalOrder = tree.getAll();
+
+ Collections.reverse(hierarchicalOrder);
+
+ return hierarchicalOrder;
+ }
+
+ private EntityBulkOperation buildUnlockOperation(List entityList) {
+
+ return EntityBulkOperation.builder()
+ .key(BulkOperationKey.PURGE_CLEANUP)
+ .entityList(entityList)
+ .consumer(
+ entity -> {
+ String id = entity.getId().get();
+ try {
+ this.lockManager.unlock(id);
+ } catch (Exception e) {
+ if (LOGGER.isTraceEnabled()) {
+ LOGGER.atTrace().withThrowable(e).log("Unable to unlock {}", entity);
+ }
+ }
+ })
+ .build();
+ }
}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/usecase/BulkPurgeInput.java b/src/main/java/com/sitepark/ies/contentrepository/core/usecase/BulkPurgeInput.java
index f4a6065..c816a36 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/usecase/BulkPurgeInput.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/usecase/BulkPurgeInput.java
@@ -1,120 +1,114 @@
package com.sitepark.ies.contentrepository.core.usecase;
+import com.sitepark.ies.contentrepository.core.domain.entity.filter.Filter;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
-import com.sitepark.ies.contentrepository.core.domain.entity.filter.Filter;
+public final class BulkPurgeInput {
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+ private final List rootList;
-public final class BulkPurgeInput {
+ private final Filter filterBy;
+
+ private final boolean forceLock;
+
+ private BulkPurgeInput(Builder builder) {
+ this.rootList = Collections.unmodifiableList(builder.rootList);
+ this.filterBy = builder.filterBy;
+ this.forceLock = builder.forceLock;
+ }
+
+ @SuppressFBWarnings("EI_EXPOSE_REP")
+ public List getRootList() {
+ return this.rootList;
+ }
+
+ public Optional getFilter() {
+ return Optional.ofNullable(this.filterBy);
+ }
+
+ public boolean isForceLock() {
+ return this.forceLock;
+ }
+
+ @Override
+ public final int hashCode() {
+ return Objects.hash(this.rootList, this.filterBy, this.forceLock);
+ }
+
+ @Override
+ public final boolean equals(Object o) {
+
+ if (!(o instanceof BulkPurgeInput)) {
+ return false;
+ }
+
+ BulkPurgeInput that = (BulkPurgeInput) o;
+
+ return Objects.equals(this.rootList, that.rootList)
+ && Objects.equals(this.filterBy, that.filterBy)
+ && Objects.equals(this.forceLock, that.forceLock);
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public Builder toBuilder() {
+ return new Builder(this);
+ }
+
+ public static final class Builder {
+
+ private final List rootList = new ArrayList<>();
+
+ private Filter filterBy;
+
+ private boolean forceLock;
+
+ private Builder() {}
+
+ private Builder(BulkPurgeInput bulkPurgeRequest) {
+ this.rootList.addAll(bulkPurgeRequest.rootList);
+ this.filterBy = bulkPurgeRequest.filterBy;
+ this.forceLock = bulkPurgeRequest.forceLock;
+ }
+
+ public Builder rootList(List rootList) {
+ Objects.requireNonNull(rootList, "rootList is null");
+ this.rootList.clear();
+ for (Long root : rootList) {
+ this.root(root);
+ }
+ return this;
+ }
+
+ public Builder root(Long root) {
+ Objects.requireNonNull(root, "root is null");
+ this.rootList.add(root);
+ return this;
+ }
+
+ public Builder filterBy(Filter filterBy) {
+ Objects.requireNonNull(filterBy, "filterBy is null");
+ this.filterBy = filterBy;
+ return this;
+ }
- private final List rootList;
+ public Builder forceLock(boolean forceLock) {
+ this.forceLock = forceLock;
+ return this;
+ }
- private final Filter filterBy;
-
- private final boolean forceLock;
-
- private BulkPurgeInput(Builder builder) {
- this.rootList = Collections.unmodifiableList(builder.rootList);
- this.filterBy = builder.filterBy;
- this.forceLock = builder.forceLock;
- }
-
- @SuppressFBWarnings("EI_EXPOSE_REP")
- public List getRootList() {
- return this.rootList;
- }
-
- public Optional getFilter() {
- return Optional.ofNullable(this.filterBy);
- }
-
- public boolean isForceLock() {
- return this.forceLock;
- }
-
- @Override
- public final int hashCode() {
- return Objects.hash(
- this.rootList,
- this.filterBy,
- this.forceLock);
- }
-
- @Override
- public final boolean equals(Object o) {
-
- if (!(o instanceof BulkPurgeInput)) {
- return false;
- }
-
- BulkPurgeInput that = (BulkPurgeInput)o;
-
- return Objects.equals(this.rootList, that.rootList) &&
- Objects.equals(this.filterBy, that.filterBy) &&
- Objects.equals(this.forceLock, that.forceLock);
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- public Builder toBuilder() {
- return new Builder(this);
- }
-
- public static final class Builder {
-
- private final List rootList = new ArrayList<>();
-
- private Filter filterBy;
-
- private boolean forceLock;
-
- private Builder() { }
-
- private Builder(BulkPurgeInput bulkPurgeRequest) {
- this.rootList.addAll(bulkPurgeRequest.rootList);
- this.filterBy = bulkPurgeRequest.filterBy;
- this.forceLock = bulkPurgeRequest.forceLock;
- }
-
- public Builder rootList(List rootList) {
- Objects.requireNonNull(rootList, "rootList is null");
- this.rootList.clear();
- for (Long root : rootList) {
- this.root(root);
- }
- return this;
- }
-
- public Builder root(Long root) {
- Objects.requireNonNull(root, "root is null");
- this.rootList.add(root);
- return this;
- }
-
- public Builder filterBy(Filter filterBy) {
- Objects.requireNonNull(filterBy, "filterBy is null");
- this.filterBy = filterBy;
- return this;
- }
-
- public Builder forceLock(boolean forceLock) {
- this.forceLock = forceLock;
- return this;
- }
-
- public BulkPurgeInput build() {
- if (this.rootList.isEmpty() && this.filterBy == null) {
- throw new IllegalStateException(
- "Either rootList or filterBy must be specified");
- }
- return new BulkPurgeInput(this);
- }
- }
+ public BulkPurgeInput build() {
+ if (this.rootList.isEmpty() && this.filterBy == null) {
+ throw new IllegalStateException("Either rootList or filterBy must be specified");
+ }
+ return new BulkPurgeInput(this);
+ }
+ }
}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/usecase/GetAllEntities.java b/src/main/java/com/sitepark/ies/contentrepository/core/usecase/GetAllEntities.java
index 152f814..aa4bad1 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/usecase/GetAllEntities.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/usecase/GetAllEntities.java
@@ -1,23 +1,21 @@
package com.sitepark.ies.contentrepository.core.usecase;
-import java.util.List;
-
import com.sitepark.ies.contentrepository.core.domain.entity.Entity;
import com.sitepark.ies.contentrepository.core.domain.entity.query.Query;
import com.sitepark.ies.contentrepository.core.port.ContentRepository;
-
import jakarta.inject.Inject;
+import java.util.List;
public final class GetAllEntities {
- private final ContentRepository repository;
+ private final ContentRepository repository;
- @Inject
- protected GetAllEntities(ContentRepository repository) {
- this.repository = repository;
- }
+ @Inject
+ protected GetAllEntities(ContentRepository repository) {
+ this.repository = repository;
+ }
- public List getAllEntities(Query query) {
- return this.repository.getAll(query);
- }
+ public List getAllEntities(Query query) {
+ return this.repository.getAll(query);
+ }
}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/usecase/PurgeEntity.java b/src/main/java/com/sitepark/ies/contentrepository/core/usecase/PurgeEntity.java
index f4aa670..babda83 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/usecase/PurgeEntity.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/usecase/PurgeEntity.java
@@ -1,8 +1,5 @@
package com.sitepark.ies.contentrepository.core.usecase;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-
import com.sitepark.ies.contentrepository.core.domain.exception.AccessDeniedException;
import com.sitepark.ies.contentrepository.core.domain.exception.GroupNotEmptyException;
import com.sitepark.ies.contentrepository.core.port.AccessControl;
@@ -15,87 +12,95 @@
import com.sitepark.ies.contentrepository.core.port.RecycleBin;
import com.sitepark.ies.contentrepository.core.port.SearchIndex;
import com.sitepark.ies.contentrepository.core.port.VersioningManager;
-
import jakarta.inject.Inject;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
public final class PurgeEntity {
- private final ContentRepository repository;
+ private final ContentRepository repository;
- private final EntityLockManager lockManager;
+ private final EntityLockManager lockManager;
- private final VersioningManager versioningManager;
+ private final VersioningManager versioningManager;
- private final HistoryManager historyManager;
+ private final HistoryManager historyManager;
- private final AccessControl accessControl;
+ private final AccessControl accessControl;
- private final RecycleBin recycleBin;
+ private final RecycleBin recycleBin;
- private final SearchIndex searchIndex;
+ private final SearchIndex searchIndex;
- private final MediaReferenceManager mediaReferenceManager;
+ private final MediaReferenceManager mediaReferenceManager;
- private final Publisher publisher;
+ private final Publisher publisher;
- private final ExtensionsNotifier extensionsNotifier;
+ private final ExtensionsNotifier extensionsNotifier;
- private static Logger LOGGER = LogManager.getLogger();
+ private static Logger LOGGER = LogManager.getLogger();
- @Inject
- @SuppressWarnings("PMD.ExcessiveParameterList")
- protected PurgeEntity(ContentRepository repository, EntityLockManager lockManager,
- VersioningManager versioningManager, HistoryManager historyManager, AccessControl accessControl,
- RecycleBin recycleBin, SearchIndex searchIndex, MediaReferenceManager mediaReferenceManager,
- Publisher publisher, ExtensionsNotifier extensionsNotifier) {
+ @Inject
+ @SuppressWarnings("PMD.ExcessiveParameterList")
+ protected PurgeEntity(
+ ContentRepository repository,
+ EntityLockManager lockManager,
+ VersioningManager versioningManager,
+ HistoryManager historyManager,
+ AccessControl accessControl,
+ RecycleBin recycleBin,
+ SearchIndex searchIndex,
+ MediaReferenceManager mediaReferenceManager,
+ Publisher publisher,
+ ExtensionsNotifier extensionsNotifier) {
- this.repository = repository;
- this.lockManager = lockManager;
- this.historyManager = historyManager;
- this.versioningManager = versioningManager;
- this.accessControl = accessControl;
- this.recycleBin = recycleBin;
- this.searchIndex = searchIndex;
- this.mediaReferenceManager = mediaReferenceManager;
- this.publisher = publisher;
- this.extensionsNotifier = extensionsNotifier;
- }
+ this.repository = repository;
+ this.lockManager = lockManager;
+ this.historyManager = historyManager;
+ this.versioningManager = versioningManager;
+ this.accessControl = accessControl;
+ this.recycleBin = recycleBin;
+ this.searchIndex = searchIndex;
+ this.mediaReferenceManager = mediaReferenceManager;
+ this.publisher = publisher;
+ this.extensionsNotifier = extensionsNotifier;
+ }
- public void purgeEntity(String id) {
+ public void purgeEntity(String id) {
- if (!this.accessControl.isEntityRemovable(id)) {
- throw new AccessDeniedException("Not allowed to remove entity " + id);
- }
+ if (!this.accessControl.isEntityRemovable(id)) {
+ throw new AccessDeniedException("Not allowed to remove entity " + id);
+ }
- if (this.repository.isGroup(id) && !this.repository.isEmptyGroup(id)) {
- throw new GroupNotEmptyException(id);
- }
+ if (this.repository.isGroup(id) && !this.repository.isEmptyGroup(id)) {
+ throw new GroupNotEmptyException(id);
+ }
- try {
- this.lockManager.lock(id);
+ try {
+ this.lockManager.lock(id);
- this.publisher.depublish(id);
+ this.publisher.depublish(id);
- if (LOGGER.isInfoEnabled()) {
- LOGGER.info("purge: {}", this.repository.get(id));
- }
+ if (LOGGER.isInfoEnabled()) {
+ LOGGER.info("purge: {}", this.repository.get(id));
+ }
- this.searchIndex.remove(id);
+ this.searchIndex.remove(id);
- this.mediaReferenceManager.removeByReference(id);
+ this.mediaReferenceManager.removeByReference(id);
- this.repository.removeEntity(id);
+ this.repository.removeEntity(id);
- this.historyManager.purge(id);
+ this.historyManager.purge(id);
- this.versioningManager.removeAllVersions(id);
+ this.versioningManager.removeAllVersions(id);
- this.recycleBin.removeByObject(id);
+ this.recycleBin.removeByObject(id);
- this.extensionsNotifier.notifyPurge(id);
+ this.extensionsNotifier.notifyPurge(id);
- } finally {
- this.lockManager.unlock(id);
- }
- }
+ } finally {
+ this.lockManager.unlock(id);
+ }
+ }
}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/usecase/RecoverEntity.java b/src/main/java/com/sitepark/ies/contentrepository/core/usecase/RecoverEntity.java
index 542a2d0..33760a0 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/usecase/RecoverEntity.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/usecase/RecoverEntity.java
@@ -1,8 +1,5 @@
package com.sitepark.ies.contentrepository.core.usecase;
-import java.time.OffsetDateTime;
-import java.util.Optional;
-
import com.sitepark.ies.contentrepository.core.domain.entity.Entity;
import com.sitepark.ies.contentrepository.core.domain.entity.HistoryEntryType;
import com.sitepark.ies.contentrepository.core.domain.entity.RecycleBinItem;
@@ -13,48 +10,53 @@
import com.sitepark.ies.contentrepository.core.port.HistoryManager;
import com.sitepark.ies.contentrepository.core.port.RecycleBin;
import com.sitepark.ies.contentrepository.core.port.SearchIndex;
+import java.time.OffsetDateTime;
+import java.util.Optional;
public class RecoverEntity {
- private final ContentRepository repository;
+ private final ContentRepository repository;
- private final HistoryManager historyManager;
+ private final HistoryManager historyManager;
- private final AccessControl accessControl;
+ private final AccessControl accessControl;
- private final RecycleBin recycleBin;
+ private final RecycleBin recycleBin;
- private final SearchIndex searchIndex;
+ private final SearchIndex searchIndex;
- protected RecoverEntity(
- ContentRepository repository,
- HistoryManager historyManager,
- AccessControl accessControl,
- RecycleBin recycleBin,
- SearchIndex searchIndex) {
- this.repository = repository;
- this.historyManager = historyManager;
- this.accessControl = accessControl;
- this.recycleBin = recycleBin;
- this.searchIndex = searchIndex;
- }
+ protected RecoverEntity(
+ ContentRepository repository,
+ HistoryManager historyManager,
+ AccessControl accessControl,
+ RecycleBin recycleBin,
+ SearchIndex searchIndex) {
+ this.repository = repository;
+ this.historyManager = historyManager;
+ this.accessControl = accessControl;
+ this.recycleBin = recycleBin;
+ this.searchIndex = searchIndex;
+ }
- public void recover(String id) {
+ public void recover(String id) {
- Optional recycleBinItem = this.recycleBin.get(id);
- recycleBinItem.orElseThrow(() -> new EntityNotFoundException(id));
+ Optional recycleBinItem = this.recycleBin.get(id);
+ recycleBinItem.orElseThrow(() -> new EntityNotFoundException(id));
- if (!this.accessControl.isGroupCreateable(recycleBinItem.get().getParent())) {
- throw new AccessDeniedException("Not allowed to recover entity " + recycleBinItem.get().getId()
- + " in group " + recycleBinItem.get().getParent());
- }
+ if (!this.accessControl.isGroupCreateable(recycleBinItem.get().getParent())) {
+ throw new AccessDeniedException(
+ "Not allowed to recover entity "
+ + recycleBinItem.get().getId()
+ + " in group "
+ + recycleBinItem.get().getParent());
+ }
- Entity entity = recycleBinItem.get().getEntity();
+ Entity entity = recycleBinItem.get().getEntity();
- this.repository.store(entity);
+ this.repository.store(entity);
- this.historyManager.createEntry(id, OffsetDateTime.now(), HistoryEntryType.RESTORED);
+ this.historyManager.createEntry(id, OffsetDateTime.now(), HistoryEntryType.RESTORED);
- this.searchIndex.index(id);
- }
+ this.searchIndex.index(id);
+ }
}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/usecase/RemoveEntity.java b/src/main/java/com/sitepark/ies/contentrepository/core/usecase/RemoveEntity.java
index 54ed780..1a2098e 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/usecase/RemoveEntity.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/usecase/RemoveEntity.java
@@ -1,8 +1,5 @@
package com.sitepark.ies.contentrepository.core.usecase;
-import java.time.OffsetDateTime;
-import java.util.Optional;
-
import com.sitepark.ies.contentrepository.core.domain.entity.Entity;
import com.sitepark.ies.contentrepository.core.domain.entity.EntityLock;
import com.sitepark.ies.contentrepository.core.domain.entity.HistoryEntryType;
@@ -16,60 +13,68 @@
import com.sitepark.ies.contentrepository.core.port.Publisher;
import com.sitepark.ies.contentrepository.core.port.RecycleBin;
import com.sitepark.ies.contentrepository.core.port.SearchIndex;
+import java.time.OffsetDateTime;
+import java.util.Optional;
public final class RemoveEntity {
- private final ContentRepository repository;
- private final EntityLockManager lockManager;
- private final HistoryManager historyManager;
- private final AccessControl accessControl;
- private final RecycleBin recycleBin;
- private final SearchIndex searchIndex;
- private final Publisher publisher;
-
- protected RemoveEntity(ContentRepository repository, EntityLockManager lockManager,
- HistoryManager historyManager, AccessControl accessControl,
- RecycleBin recycleBin, SearchIndex searchIndex, Publisher publisher) {
-
- this.repository = repository;
- this.lockManager = lockManager;
- this.historyManager = historyManager;
- this.accessControl = accessControl;
- this.recycleBin = recycleBin;
- this.searchIndex = searchIndex;
- this.publisher = publisher;
- }
-
- public void remove(String id) {
-
- if (!this.accessControl.isEntityRemovable(id)) {
- throw new AccessDeniedException("Not allowed to remove entity " + id);
- }
-
- Optional entity = this.repository.get(id);
- if (entity.isEmpty()) {
- return;
- }
-
- try {
- Optional lock = this.lockManager.getLock(id);
- lock.ifPresent(l -> {
- throw new EntityLockedException(l);
- });
-
- this.searchIndex.remove(id);
-
- this.publisher.depublish(id);
-
- this.repository.removeEntity(id);
-
- this.historyManager.createEntry(id, OffsetDateTime.now(), HistoryEntryType.REMOVED);
-
- RecycleBinItem recycleBinItem = RecycleBinItem.builder().build();
- this.recycleBin.add(recycleBinItem);
-
- } finally {
- this.lockManager.unlock(id);
- }
- }
+ private final ContentRepository repository;
+ private final EntityLockManager lockManager;
+ private final HistoryManager historyManager;
+ private final AccessControl accessControl;
+ private final RecycleBin recycleBin;
+ private final SearchIndex searchIndex;
+ private final Publisher publisher;
+
+ protected RemoveEntity(
+ ContentRepository repository,
+ EntityLockManager lockManager,
+ HistoryManager historyManager,
+ AccessControl accessControl,
+ RecycleBin recycleBin,
+ SearchIndex searchIndex,
+ Publisher publisher) {
+
+ this.repository = repository;
+ this.lockManager = lockManager;
+ this.historyManager = historyManager;
+ this.accessControl = accessControl;
+ this.recycleBin = recycleBin;
+ this.searchIndex = searchIndex;
+ this.publisher = publisher;
+ }
+
+ public void remove(String id) {
+
+ if (!this.accessControl.isEntityRemovable(id)) {
+ throw new AccessDeniedException("Not allowed to remove entity " + id);
+ }
+
+ Optional entity = this.repository.get(id);
+ if (entity.isEmpty()) {
+ return;
+ }
+
+ try {
+ Optional lock = this.lockManager.getLock(id);
+ lock.ifPresent(
+ l -> {
+ throw new EntityLockedException(l);
+ });
+
+ this.searchIndex.remove(id);
+
+ this.publisher.depublish(id);
+
+ this.repository.removeEntity(id);
+
+ this.historyManager.createEntry(id, OffsetDateTime.now(), HistoryEntryType.REMOVED);
+
+ RecycleBinItem recycleBinItem = RecycleBinItem.builder().build();
+ this.recycleBin.add(recycleBinItem);
+
+ } finally {
+ this.lockManager.unlock(id);
+ }
+ }
}
diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/usecase/StoreEntity.java b/src/main/java/com/sitepark/ies/contentrepository/core/usecase/StoreEntity.java
index a74477b..9bb7276 100644
--- a/src/main/java/com/sitepark/ies/contentrepository/core/usecase/StoreEntity.java
+++ b/src/main/java/com/sitepark/ies/contentrepository/core/usecase/StoreEntity.java
@@ -1,7 +1,5 @@
package com.sitepark.ies.contentrepository.core.usecase;
-import java.util.Optional;
-
import com.sitepark.ies.contentrepository.core.domain.entity.ChangeSet;
import com.sitepark.ies.contentrepository.core.domain.entity.Entity;
import com.sitepark.ies.contentrepository.core.domain.entity.EntityLock;
@@ -18,100 +16,108 @@
import com.sitepark.ies.contentrepository.core.port.IdGenerator;
import com.sitepark.ies.contentrepository.core.port.SearchIndex;
import com.sitepark.ies.contentrepository.core.port.VersioningManager;
+import java.util.Optional;
public final class StoreEntity {
- private final ContentRepository repository;
- private final EntityLockManager lockManager;
- private final VersioningManager versioningManager;
- private final HistoryManager historyManager;
- private final AccessControl accessControl;
- private final IdGenerator idGenerator;
- private final SearchIndex searchIndex;
- private final ContentDiffer contentDiffer;
-
- protected StoreEntity(ContentRepository repository, EntityLockManager lockManager,
- VersioningManager versioningManager, HistoryManager historyManager, AccessControl accessControl,
- IdGenerator idGenerator, SearchIndex searchIndex, ContentDiffer contentDiffer) {
- this.repository = repository;
- this.lockManager = lockManager;
- this.versioningManager = versioningManager;
- this.historyManager = historyManager;
- this.accessControl = accessControl;
- this.idGenerator = idGenerator;
- this.searchIndex = searchIndex;
- this.contentDiffer = contentDiffer;
- }
-
- public String store(Entity entity) {
- if (entity.getId().isEmpty()) {
- return this.create(entity);
- } else {
- return this.update(entity);
- }
- }
-
- private String create(Entity newEntity) {
-
- Optional parent = newEntity.getParent();
- parent.orElseThrow(() -> new ParentMissingException());
-
- String parentId = parent.get();
-
- if (!this.accessControl.isEntityCreateable(parentId)) {
- throw new AccessDeniedException("Not allowed to create entity in group " + parent);
- }
-
- String generatedId = this.idGenerator.generate();
-
- Entity entityWithId = newEntity.toBuilder().id(generatedId).build();
-
- Entity versioned = this.versioningManager.createNewVersion(entityWithId);
-
- this.repository.store(versioned);
- this.historyManager.createEntry(generatedId, versioned.getVersion().get(),
- HistoryEntryType.CREATED);
- this.searchIndex.index(generatedId);
-
- return versioned.getId().get();
- }
-
- private String update(Entity updateEntity) {
-
- updateEntity.getId()
- .orElseThrow(() -> new IllegalArgumentException("Update failed, identifier missing"));
-
- String id = updateEntity.getId().get();
-
- Optional existsEntity = this.repository.get(id);
- existsEntity.orElseThrow(() -> new EntityNotFoundException(id));
-
- if (!this.accessControl.isEntityWritable(id)) {
- throw new AccessDeniedException("Not allowed to update entity " + id);
- }
-
- try {
- Optional lock = this.lockManager.getLock(id);
- lock.ifPresent(l -> {
- throw new EntityLockedException(l);
- });
-
- ChangeSet changeSet = this.contentDiffer.diff(updateEntity, existsEntity.get());
- if (changeSet.isEmpty()) {
- return updateEntity.getId().get();
- }
-
- Entity versioned = this.versioningManager.createNewVersion(updateEntity);
-
- this.repository.store(versioned);
- this.historyManager.createEntry(id, versioned.getVersion().get(),
- HistoryEntryType.UPDATED);
- this.searchIndex.index(id);
-
- return versioned.getId().get();
-
- } finally {
- this.lockManager.unlock(id);
- }
- }
+ private final ContentRepository repository;
+ private final EntityLockManager lockManager;
+ private final VersioningManager versioningManager;
+ private final HistoryManager historyManager;
+ private final AccessControl accessControl;
+ private final IdGenerator idGenerator;
+ private final SearchIndex searchIndex;
+ private final ContentDiffer contentDiffer;
+
+ protected StoreEntity(
+ ContentRepository repository,
+ EntityLockManager lockManager,
+ VersioningManager versioningManager,
+ HistoryManager historyManager,
+ AccessControl accessControl,
+ IdGenerator idGenerator,
+ SearchIndex searchIndex,
+ ContentDiffer contentDiffer) {
+ this.repository = repository;
+ this.lockManager = lockManager;
+ this.versioningManager = versioningManager;
+ this.historyManager = historyManager;
+ this.accessControl = accessControl;
+ this.idGenerator = idGenerator;
+ this.searchIndex = searchIndex;
+ this.contentDiffer = contentDiffer;
+ }
+
+ public String store(Entity entity) {
+ if (entity.getId().isEmpty()) {
+ return this.create(entity);
+ } else {
+ return this.update(entity);
+ }
+ }
+
+ private String create(Entity newEntity) {
+
+ Optional parent = newEntity.getParent();
+ parent.orElseThrow(() -> new ParentMissingException());
+
+ String parentId = parent.get();
+
+ if (!this.accessControl.isEntityCreateable(parentId)) {
+ throw new AccessDeniedException("Not allowed to create entity in group " + parent);
+ }
+
+ String generatedId = this.idGenerator.generate();
+
+ Entity entityWithId = newEntity.toBuilder().id(generatedId).build();
+
+ Entity versioned = this.versioningManager.createNewVersion(entityWithId);
+
+ this.repository.store(versioned);
+ this.historyManager.createEntry(
+ generatedId, versioned.getVersion().get(), HistoryEntryType.CREATED);
+ this.searchIndex.index(generatedId);
+
+ return versioned.getId().get();
+ }
+
+ private String update(Entity updateEntity) {
+
+ updateEntity
+ .getId()
+ .orElseThrow(() -> new IllegalArgumentException("Update failed, identifier missing"));
+
+ String id = updateEntity.getId().get();
+
+ Optional existsEntity = this.repository.get(id);
+ existsEntity.orElseThrow(() -> new EntityNotFoundException(id));
+
+ if (!this.accessControl.isEntityWritable(id)) {
+ throw new AccessDeniedException("Not allowed to update entity " + id);
+ }
+
+ try {
+ Optional lock = this.lockManager.getLock(id);
+ lock.ifPresent(
+ l -> {
+ throw new EntityLockedException(l);
+ });
+
+ ChangeSet changeSet = this.contentDiffer.diff(updateEntity, existsEntity.get());
+ if (changeSet.isEmpty()) {
+ return updateEntity.getId().get();
+ }
+
+ Entity versioned = this.versioningManager.createNewVersion(updateEntity);
+
+ this.repository.store(versioned);
+ this.historyManager.createEntry(id, versioned.getVersion().get(), HistoryEntryType.UPDATED);
+ this.searchIndex.index(id);
+
+ return versioned.getId().get();
+
+ } finally {
+ this.lockManager.unlock(id);
+ }
+ }
}
diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java
index 9fe359a..095dd31 100644
--- a/src/main/java/module-info.java
+++ b/src/main/java/module-info.java
@@ -1,24 +1,23 @@
module com.sitepark.ies.contentrepository.core {
+ exports com.sitepark.ies.contentrepository.core.domain.entity;
+ exports com.sitepark.ies.contentrepository.core.domain.entity.filter;
+ exports com.sitepark.ies.contentrepository.core.domain.entity.sort;
+ exports com.sitepark.ies.contentrepository.core.domain.entity.query;
+ exports com.sitepark.ies.contentrepository.core.domain.exception;
+ exports com.sitepark.ies.contentrepository.core.port;
+ exports com.sitepark.ies.contentrepository.core.usecase;
- exports com.sitepark.ies.contentrepository.core.domain.entity;
- exports com.sitepark.ies.contentrepository.core.domain.entity.filter;
- exports com.sitepark.ies.contentrepository.core.domain.entity.sort;
- exports com.sitepark.ies.contentrepository.core.domain.entity.query;
- exports com.sitepark.ies.contentrepository.core.domain.exception;
- exports com.sitepark.ies.contentrepository.core.port;
- exports com.sitepark.ies.contentrepository.core.usecase;
+ requires jakarta.inject;
+ requires org.eclipse.jdt.annotation;
+ requires com.github.spotbugs.annotations;
+ requires com.fasterxml.jackson.databind;
+ requires com.fasterxml.jackson.annotation;
+ requires com.fasterxml.jackson.datatype.jdk8;
+ requires org.apache.logging.log4j;
+ requires com.fasterxml.jackson.datatype.jsr310;
- requires jakarta.inject;
- requires org.eclipse.jdt.annotation;
- requires com.github.spotbugs.annotations;
- requires com.fasterxml.jackson.databind;
- requires com.fasterxml.jackson.annotation;
- requires com.fasterxml.jackson.datatype.jdk8;
- requires org.apache.logging.log4j;
- requires com.fasterxml.jackson.datatype.jsr310;
-
- opens com.sitepark.ies.contentrepository.core.domain.entity;
- opens com.sitepark.ies.contentrepository.core.domain.entity.filter;
- opens com.sitepark.ies.contentrepository.core.domain.entity.sort;
- opens com.sitepark.ies.contentrepository.core.domain.entity.query;
-}
\ No newline at end of file
+ opens com.sitepark.ies.contentrepository.core.domain.entity;
+ opens com.sitepark.ies.contentrepository.core.domain.entity.filter;
+ opens com.sitepark.ies.contentrepository.core.domain.entity.sort;
+ opens com.sitepark.ies.contentrepository.core.domain.entity.query;
+}
diff --git a/src/test/java/com/sitepark/ies/contentrepository/core/domain/databind/UniquePropertyPolymorphicDeserializerTest.java b/src/test/java/com/sitepark/ies/contentrepository/core/domain/databind/UniquePropertyPolymorphicDeserializerTest.java
index e767a09..29a1706 100644
--- a/src/test/java/com/sitepark/ies/contentrepository/core/domain/databind/UniquePropertyPolymorphicDeserializerTest.java
+++ b/src/test/java/com/sitepark/ies/contentrepository/core/domain/databind/UniquePropertyPolymorphicDeserializerTest.java
@@ -5,88 +5,84 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.Map.Entry;
-
-import org.junit.jupiter.api.Test;
-
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.Map.Entry;
+import org.junit.jupiter.api.Test;
class UniquePropertyPolymorphicDeserializerTest {
- @Test
- @SuppressWarnings("PMD.CloseResource")
- void test() throws IOException {
+ @Test
+ @SuppressWarnings("PMD.CloseResource")
+ void test() throws IOException {
- UniquePropertyPolymorphicDeserializer deserializer =
- new UniquePropertyPolymorphicDeserializer<>(A.class);
+ UniquePropertyPolymorphicDeserializer deserializer =
+ new UniquePropertyPolymorphicDeserializer<>(A.class);
- deserializer.register("b", B.class);
- deserializer.register("c", C.class);
+ deserializer.register("b", B.class);
+ deserializer.register("c", C.class);
- JsonParser jp = mock();
- DeserializationContext ctxt = mock();
- ObjectMapper mapper = mock();
- ObjectNode obj = mock();
+ JsonParser jp = mock();
+ DeserializationContext ctxt = mock();
+ ObjectMapper mapper = mock();
+ ObjectNode obj = mock();
- Entry element = mock();
+ Entry element = mock();
- Iterator> elementsIterator =
- Arrays.asList(element).iterator();
+ Iterator> elementsIterator = Arrays.asList(element).iterator();
- when(mapper.readTree(any(JsonParser.class))).thenReturn(obj);
- when(jp.getCodec()).thenReturn(mapper);
- when(obj.fields()).thenReturn(elementsIterator);
- when(element.getKey()).thenReturn("c");
+ when(mapper.readTree(any(JsonParser.class))).thenReturn(obj);
+ when(jp.getCodec()).thenReturn(mapper);
+ when(obj.fields()).thenReturn(elementsIterator);
+ when(element.getKey()).thenReturn("c");
- deserializer.deserialize(jp, ctxt);
+ deserializer.deserialize(jp, ctxt);
- verify(mapper).treeToValue(obj, C.class);
- }
+ verify(mapper).treeToValue(obj, C.class);
+ }
- @Test
- @SuppressWarnings("PMD.CloseResource")
- void testNotRegistered() throws IOException {
+ @Test
+ @SuppressWarnings("PMD.CloseResource")
+ void testNotRegistered() throws IOException {
- UniquePropertyPolymorphicDeserializer deserializer =
- new UniquePropertyPolymorphicDeserializer<>(A.class);
+ UniquePropertyPolymorphicDeserializer deserializer =
+ new UniquePropertyPolymorphicDeserializer<>(A.class);
- deserializer.register("b", B.class);
- deserializer.register("c", C.class);
+ deserializer.register("b", B.class);
+ deserializer.register("c", C.class);
- JsonParser jp = mock();
- DeserializationContext ctxt = mock();
- ObjectMapper mapper = mock();
- ObjectNode obj = mock();
+ JsonParser jp = mock();
+ DeserializationContext ctxt = mock();
+ ObjectMapper mapper = mock();
+ ObjectNode obj = mock();
- Entry element = mock();
+ Entry element = mock();
- Iterator> elementsIterator =
- Arrays.asList(element).iterator();
+ Iterator> elementsIterator = Arrays.asList(element).iterator();
- when(mapper.readTree(any(JsonParser.class))).thenReturn(obj);
- when(jp.getCodec()).thenReturn(mapper);
- when(obj.fields()).thenReturn(elementsIterator);
- when(element.getKey()).thenReturn("d");
+ when(mapper.readTree(any(JsonParser.class))).thenReturn(obj);
+ when(jp.getCodec()).thenReturn(mapper);
+ when(obj.fields()).thenReturn(elementsIterator);
+ when(element.getKey()).thenReturn("d");
- deserializer.deserialize(jp, ctxt);
+ deserializer.deserialize(jp, ctxt);
- verify(ctxt).reportInputMismatch(
- any(UniquePropertyPolymorphicDeserializer.class),
- any(String.class));
- }
- private static class A { };
+ verify(ctxt)
+ .reportInputMismatch(any(UniquePropertyPolymorphicDeserializer.class), any(String.class));
+ }
- private static final class B extends A {
- };
+ private static class A {}
+ ;
- private static final class C extends A {
- };
+ private static final class B extends A {}
+ ;
+ private static final class C extends A {}
+ ;
}
diff --git a/src/test/java/com/sitepark/ies/contentrepository/core/domain/entity/AnchorTest.java b/src/test/java/com/sitepark/ies/contentrepository/core/domain/entity/AnchorTest.java
index f376f07..76e8078 100644
--- a/src/test/java/com/sitepark/ies/contentrepository/core/domain/entity/AnchorTest.java
+++ b/src/test/java/com/sitepark/ies/contentrepository/core/domain/entity/AnchorTest.java
@@ -4,78 +4,86 @@
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
-import org.junit.jupiter.api.Test;
-
import com.sitepark.ies.contentrepository.core.domain.exception.InvalidAnchorException;
-
import nl.jqno.equalsverifier.EqualsVerifier;
+import org.junit.jupiter.api.Test;
@SuppressWarnings("PMD.AvoidDuplicateLiterals")
class AnchorTest {
- @Test
- @SuppressWarnings("PMD.JUnitTestsShouldIncludeAssert")
- void testEquals() {
- EqualsVerifier.forClass(Anchor.class)
- .verify();
- }
-
- @Test
- void testToString() {
- Anchor anchor = Anchor.ofString("abc");
- assertEquals("abc", anchor.toString(), "name of anchor expected");
- }
-
- @Test
- void testToStringForEmptyAnchor() {
- Anchor anchor = Anchor.EMPTY;
- assertEquals("EMPTY", anchor.toString(), "EMPTY expected");
- }
-
- @Test
- void testOfString() {
- Anchor anchor = Anchor.ofString("abc");
- assertEquals("abc", anchor.getName(), "expected name");
- }
-
- @Test
- void testOfStringWithNull() {
- Anchor anchor = Anchor.ofString(null);
- assertNull(anchor, "anchor should be null");
- }
-
- @Test
- void testOfStringWithBlank() {
- Anchor anchor = Anchor.ofString(" ");
- assertEquals(Anchor.EMPTY, anchor, "anchor should be empty");
- }
-
- @Test
- void testOfStringWithOnlyNumbers() {
- assertThrows(InvalidAnchorException.class, () -> {
- Anchor.ofString("123");
- }, "anchor must not only contain numbers");
- }
-
- @Test
- void testOfStringWithContainsSpace() {
- assertThrows(InvalidAnchorException.class, () -> {
- Anchor.ofString("12 3");
- }, "anchor must not contain spaces");
- }
-
- @Test
- void testOfStringWithAmp() {
- assertThrows(InvalidAnchorException.class, () -> {
- Anchor.ofString("12&3");
- }, "anchor must not contain amp");
- }
-
- @Test
- void testOfStringWithOtherSpezialCharacter() {
- assertThrows(InvalidAnchorException.class, () -> {
- Anchor.ofString("12$3");
- }, "anchor must not contain special characters");
- }
-
+ @Test
+ @SuppressWarnings("PMD.JUnitTestsShouldIncludeAssert")
+ void testEquals() {
+ EqualsVerifier.forClass(Anchor.class).verify();
+ }
+
+ @Test
+ void testToString() {
+ Anchor anchor = Anchor.ofString("abc");
+ assertEquals("abc", anchor.toString(), "name of anchor expected");
+ }
+
+ @Test
+ void testToStringForEmptyAnchor() {
+ Anchor anchor = Anchor.EMPTY;
+ assertEquals("EMPTY", anchor.toString(), "EMPTY expected");
+ }
+
+ @Test
+ void testOfString() {
+ Anchor anchor = Anchor.ofString("abc");
+ assertEquals("abc", anchor.getName(), "expected name");
+ }
+
+ @Test
+ void testOfStringWithNull() {
+ Anchor anchor = Anchor.ofString(null);
+ assertNull(anchor, "anchor should be null");
+ }
+
+ @Test
+ void testOfStringWithBlank() {
+ Anchor anchor = Anchor.ofString(" ");
+ assertEquals(Anchor.EMPTY, anchor, "anchor should be empty");
+ }
+
+ @Test
+ void testOfStringWithOnlyNumbers() {
+ assertThrows(
+ InvalidAnchorException.class,
+ () -> {
+ Anchor.ofString("123");
+ },
+ "anchor must not only contain numbers");
+ }
+
+ @Test
+ void testOfStringWithContainsSpace() {
+ assertThrows(
+ InvalidAnchorException.class,
+ () -> {
+ Anchor.ofString("12 3");
+ },
+ "anchor must not contain spaces");
+ }
+
+ @Test
+ void testOfStringWithAmp() {
+ assertThrows(
+ InvalidAnchorException.class,
+ () -> {
+ Anchor.ofString("12&3");
+ },
+ "anchor must not contain amp");
+ }
+
+ @Test
+ void testOfStringWithOtherSpezialCharacter() {
+ assertThrows(
+ InvalidAnchorException.class,
+ () -> {
+ Anchor.ofString("12$3");
+ },
+ "anchor must not contain special characters");
+ }
}
diff --git a/src/test/java/com/sitepark/ies/contentrepository/core/domain/entity/BulkOperationKeyTest.java b/src/test/java/com/sitepark/ies/contentrepository/core/domain/entity/BulkOperationKeyTest.java
index 6b8cf76..cda9502 100644
--- a/src/test/java/com/sitepark/ies/contentrepository/core/domain/entity/BulkOperationKeyTest.java
+++ b/src/test/java/com/sitepark/ies/contentrepository/core/domain/entity/BulkOperationKeyTest.java
@@ -6,11 +6,9 @@
class BulkOperationKeyTest {
- @Test
- void testGetName() {
- assertEquals(
- "contentrepository.purge.lock",
- BulkOperationKey.PURGE_LOCK.getName(),
- "unexpected name");
- }
+ @Test
+ void testGetName() {
+ assertEquals(
+ "contentrepository.purge.lock", BulkOperationKey.PURGE_LOCK.getName(), "unexpected name");
+ }
}
diff --git a/src/test/java/com/sitepark/ies/contentrepository/core/domain/entity/ChangeSetTest.java b/src/test/java/com/sitepark/ies/contentrepository/core/domain/entity/ChangeSetTest.java
index 4017383..eabc42f 100644
--- a/src/test/java/com/sitepark/ies/contentrepository/core/domain/entity/ChangeSetTest.java
+++ b/src/test/java/com/sitepark/ies/contentrepository/core/domain/entity/ChangeSetTest.java
@@ -6,10 +6,9 @@
class ChangeSetTest {
- @Test
- void testIsEmpty() {
- ChangeSet changeSet = new ChangeSet();
- assertTrue(changeSet.isEmpty(), "changeSet should be empty");
- }
-
+ @Test
+ void testIsEmpty() {
+ ChangeSet changeSet = new ChangeSet();
+ assertTrue(changeSet.isEmpty(), "changeSet should be empty");
+ }
}
diff --git a/src/test/java/com/sitepark/ies/contentrepository/core/domain/entity/EntityBulkExecutionTest.java b/src/test/java/com/sitepark/ies/contentrepository/core/domain/entity/EntityBulkExecutionTest.java
index 71456e7..b742359 100644
--- a/src/test/java/com/sitepark/ies/contentrepository/core/domain/entity/EntityBulkExecutionTest.java
+++ b/src/test/java/com/sitepark/ies/contentrepository/core/domain/entity/EntityBulkExecutionTest.java
@@ -6,139 +6,135 @@
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
-import java.util.Arrays;
-import java.util.List;
-
-import org.junit.jupiter.api.Test;
-
import com.jparams.verifier.tostring.NameStyle;
import com.jparams.verifier.tostring.ToStringVerifier;
-
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+import java.util.Arrays;
+import java.util.List;
import nl.jqno.equalsverifier.EqualsVerifier;
+import org.junit.jupiter.api.Test;
@SuppressWarnings("PMD.AvoidDuplicateLiterals")
@SuppressFBWarnings({
- "PI_DO_NOT_REUSE_PUBLIC_IDENTIFIERS_CLASS_NAMES",
- "NP_NULL_PARAM_DEREF_NONVIRTUAL",
- "NP_NULL_PARAM_DEREF_ALL_TARGETS_DANGEROUS"
+ "PI_DO_NOT_REUSE_PUBLIC_IDENTIFIERS_CLASS_NAMES",
+ "NP_NULL_PARAM_DEREF_NONVIRTUAL",
+ "NP_NULL_PARAM_DEREF_ALL_TARGETS_DANGEROUS"
})
class EntityBulkExecutionTest {
- @Test
- @SuppressWarnings("PMD.JUnitTestsShouldIncludeAssert")
- void testEquals() {
- EqualsVerifier.forClass(EntityBulkExecution.class)
- .verify();
- }
-
- @Test
- @SuppressWarnings("PMD.JUnitTestsShouldIncludeAssert")
- public void testToString() {
- ToStringVerifier.forClass(EntityBulkExecution.class)
- .withClassName(NameStyle.SIMPLE_NAME)
- .verify();
- }
-
- @Test
- void testSetTopic() {
- EntityBulkOperation op = mock(EntityBulkOperation.class);
- EntityBulkExecution execution = EntityBulkExecution.builder()
- .topic("topic")
- .operation(op)
- .build();
-
- String[] expected = new String[] {"topic"};
-
- assertArrayEquals(expected, execution.getTopic(), "unexpected topics");
- }
-
- @Test
- void testSetNullTopic() {
- assertThrows(NullPointerException.class, () -> {
- EntityBulkExecution.builder().topic((String[])null);
- }, "topic must not be null");
- }
-
- @Test
- void testSetNullTopicPart() {
- assertThrows(NullPointerException.class, () -> {
- EntityBulkExecution.builder().topic((String)null);
- }, "topic part must not be null");
- }
-
- @Test
- void testMissingTopic() {
- assertThrows(IllegalStateException.class, () -> {
- EntityBulkOperation op = mock(EntityBulkOperation.class);
- EntityBulkExecution.builder()
- .operation(op)
- .build();
- }, "topic must be set");
- }
-
- @Test
- void testSetOperation() {
- EntityBulkOperation op = mock(EntityBulkOperation.class);
- EntityBulkExecution execution = EntityBulkExecution.builder()
- .topic("topic")
- .operation(op)
- .build();
-
- List expected = Arrays.asList(op);
-
- assertEquals(expected, execution.getOperations(), "unexpected operations");
- }
-
- @Test
- void testSetNullOperation() {
- assertThrows(NullPointerException.class, () -> {
- EntityBulkExecution.builder().operation((EntityBulkOperation)null);
- }, "operation must not be null");
- }
-
- @Test
- void testSetNullOperationArray() {
- assertThrows(NullPointerException.class, () -> {
- EntityBulkExecution.builder().operation((EntityBulkOperation[])null);
- }, "operations must not be null");
- }
-
- @Test
- void testMissingOperation() {
- assertThrows(IllegalStateException.class, () -> {
- EntityBulkExecution.builder()
- .topic("topic")
- .build();
- }, "operation must be set");
- }
-
- @Test
- void testSetFinalizer() {
- EntityBulkOperation op = mock(EntityBulkOperation.class);
- EntityBulkOperation finalizer = mock(EntityBulkOperation.class);
- EntityBulkExecution execution = EntityBulkExecution.builder()
- .topic("topic")
- .operation(op)
- .finalizer(finalizer)
- .build();
-
- assertEquals(
- finalizer,
- execution.getFinalizer().get(),
- "unexpected finalizer");
- }
-
- @Test
- void testEmptyFinalizer() {
- EntityBulkOperation op = mock(EntityBulkOperation.class);
- EntityBulkExecution execution = EntityBulkExecution.builder()
- .topic("topic")
- .operation(op)
- .build();
-
- assertTrue(
- execution.getFinalizer().isEmpty(),
- "finalizer optional should be empty");
- }
+ @Test
+ @SuppressWarnings("PMD.JUnitTestsShouldIncludeAssert")
+ void testEquals() {
+ EqualsVerifier.forClass(EntityBulkExecution.class).verify();
+ }
+
+ @Test
+ @SuppressWarnings("PMD.JUnitTestsShouldIncludeAssert")
+ public void testToString() {
+ ToStringVerifier.forClass(EntityBulkExecution.class)
+ .withClassName(NameStyle.SIMPLE_NAME)
+ .verify();
+ }
+
+ @Test
+ void testSetTopic() {
+ EntityBulkOperation op = mock(EntityBulkOperation.class);
+ EntityBulkExecution execution =
+ EntityBulkExecution.builder().topic("topic").operation(op).build();
+
+ String[] expected = new String[] {"topic"};
+
+ assertArrayEquals(expected, execution.getTopic(), "unexpected topics");
+ }
+
+ @Test
+ void testSetNullTopic() {
+ assertThrows(
+ NullPointerException.class,
+ () -> {
+ EntityBulkExecution.builder().topic((String[]) null);
+ },
+ "topic must not be null");
+ }
+
+ @Test
+ void testSetNullTopicPart() {
+ assertThrows(
+ NullPointerException.class,
+ () -> {
+ EntityBulkExecution.builder().topic((String) null);
+ },
+ "topic part must not be null");
+ }
+
+ @Test
+ void testMissingTopic() {
+ assertThrows(
+ IllegalStateException.class,
+ () -> {
+ EntityBulkOperation op = mock(EntityBulkOperation.class);
+ EntityBulkExecution.builder().operation(op).build();
+ },
+ "topic must be set");
+ }
+
+ @Test
+ void testSetOperation() {
+ EntityBulkOperation op = mock(EntityBulkOperation.class);
+ EntityBulkExecution execution =
+ EntityBulkExecution.builder().topic("topic").operation(op).build();
+
+ List