Skip to content

Commit

Permalink
refactor: rename bulk-execution to background-execution
Browse files Browse the repository at this point in the history
  • Loading branch information
sitepark-veltrup committed Nov 5, 2024
1 parent 148a8db commit 0462516
Show file tree
Hide file tree
Showing 16 changed files with 218 additions and 175 deletions.
26 changes: 26 additions & 0 deletions .fbExcludeFilterFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<FindBugsFilter
xmlns="https://github.com/spotbugs/filter/3.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://github.com/spotbugs/filter/3.0.0 https://raw.githubusercontent.com/spotbugs/spotbugs/3.1.0/spotbugs/etc/findbugsfilter.xsd">


<!-- https://spotbugs.readthedocs.io/en/stable/filter.html -->
<Match>
<Bug
pattern="REC_CATCH_EXCEPTION,RV_CHECK_FOR_POSITIVE_INDEXOF,BC_UNCONFIRMED_CAST_OF_RETURN_VALUE,THROWS_METHOD_THROWS_CLAUSE_THROWABLE,PI_DO_NOT_REUSE_PUBLIC_IDENTIFIERS_CLASS_NAMES" />
</Match>

<Match>
<Class name="~com.sitepark.ies.contentrepository.core.usecase.*" />
<Method name="&lt;init&gt;"/>
<Bug pattern="EI_EXPOSE_REP2" />
</Match>

<!-- False positive: https://github.com/spotbugs/spotbugs/issues/2628 -->
<Match>
<Class name="~.*\.*Test" />
<Bug pattern="RV_EXCEPTION_NOT_THROWN" />
</Match>

</FindBugsFilter>
2 changes: 1 addition & 1 deletion .pmd
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<pmd>
<useProjectRuleSet>true</useProjectRuleSet>
<ruleSetFile>pmd-ruleset.xml</ruleSetFile>
<ruleSetFile>/home/veltrup/git/ies-4-contentrepository-core/.pmdruleset.xml</ruleSetFile>
<includeDerivedFiles>false</includeDerivedFiles>
<violationsAsErrors>true</violationsAsErrors>
<fullBuildEnabled>true</fullBuildEnabled>
Expand Down
8 changes: 8 additions & 0 deletions .pmdruleset.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
name="M2Eclipse PMD RuleSet"
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
<description>M2Eclipse PMD RuleSet</description>
<exclude-pattern>.*/home/veltrup/git/ies-4-contentrepository-core/target.*</exclude-pattern>
</ruleset>
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package com.sitepark.ies.contentrepository.core.domain.entity;

public enum BulkOperationKey {
public enum BackgroundOperationKey {
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 BulkOperationKey(String name) {
private BackgroundOperationKey(String name) {
this.name = name;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
import java.util.Objects;
import java.util.Optional;

public class EntityBulkExecution {
public class EntityBackgroundExecution {

private final String[] topic;

private final List<EntityBulkOperation> operations;
private final List<EntityBackgroundOperation> operations;

private final EntityBulkOperation finalizer;
private final EntityBackgroundOperation finalizer;

protected EntityBulkExecution(Builder builder) {
protected EntityBackgroundExecution(Builder builder) {
this.topic = builder.topic;
this.operations = Collections.unmodifiableList(builder.operations);
this.finalizer = builder.finalizer;
Expand All @@ -28,11 +28,11 @@ public String[] getTopic() {
}

@SuppressFBWarnings("EI_EXPOSE_REP")
public List<EntityBulkOperation> getOperations() {
public List<EntityBackgroundOperation> getOperations() {
return this.operations;
}

public Optional<EntityBulkOperation> getFinalizer() {
public Optional<EntityBackgroundOperation> getFinalizer() {
return Optional.ofNullable(this.finalizer);
}

Expand All @@ -44,11 +44,11 @@ public final int hashCode() {
@Override
public final boolean equals(Object o) {

if (!(o instanceof EntityBulkExecution)) {
if (!(o instanceof EntityBackgroundExecution)) {
return false;
}

EntityBulkExecution execution = (EntityBulkExecution) o;
EntityBackgroundExecution execution = (EntityBackgroundExecution) o;

return Arrays.equals(this.topic, execution.topic)
&& Objects.equals(this.operations, execution.operations)
Expand All @@ -59,7 +59,7 @@ public final boolean equals(Object o) {
public String toString() {
StringBuilder b =
new StringBuilder(100)
.append("EntityBulkExecution[topic:")
.append("EntityBackgroundExecution[topic:")
.append(Arrays.toString(this.topic))
.append(", operations:")
.append(this.operations)
Expand All @@ -77,18 +77,16 @@ public static class Builder {

private String[] topic;

private final List<EntityBulkOperation> operations = new ArrayList<>();
private final List<EntityBackgroundOperation> operations = new ArrayList<>();

private EntityBulkOperation finalizer;
private EntityBackgroundOperation 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 <code>level1</code> are queried, all
* BulkExecutions recursively below <code>level1</code> are returned.
* 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
* <code>level1</code> are queried, all BulkExecutions recursively below <code>level1</code> are returned.
*/
public Builder topic(String... topic) {
Objects.requireNonNull(topic, "topic is null");
Expand All @@ -101,29 +99,29 @@ public Builder topic(String... topic) {
}

@SuppressWarnings("PMD.UseArraysAsList")
public Builder operation(EntityBulkOperation... operations) {
public Builder operation(EntityBackgroundOperation... operations) {
Objects.requireNonNull(operations, "operations is null");
for (EntityBulkOperation operation : operations) {
for (EntityBackgroundOperation operation : operations) {
Objects.requireNonNull(operation, "operations contains null values");
this.operations.add(operation);
}
return this;
}

public Builder finalizer(EntityBulkOperation finalizer) {
public Builder finalizer(EntityBackgroundOperation finalizer) {
Objects.requireNonNull(finalizer, "finalizer is null");
this.finalizer = finalizer;
return this;
}

public EntityBulkExecution build() {
public EntityBackgroundExecution 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);
return new EntityBackgroundExecution(this);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@
import java.util.Objects;
import java.util.function.Consumer;

public class EntityBulkOperation {
public class EntityBackgroundOperation {

private final BulkOperationKey key;
private final BackgroundOperationKey key;

private final List<Entity> entityList;

private final Consumer<Entity> consumer;

protected EntityBulkOperation(Builder builder) {
protected EntityBackgroundOperation(Builder builder) {
this.key = builder.key;
this.entityList = Collections.unmodifiableList(builder.entityList);
this.consumer = builder.consumer;
}

public BulkOperationKey getKey() {
public BackgroundOperationKey getKey() {
return this.key;
}

Expand All @@ -42,11 +42,11 @@ public final int hashCode() {
@Override
public final boolean equals(Object o) {

if (!(o instanceof EntityBulkOperation)) {
if (!(o instanceof EntityBackgroundOperation)) {
return false;
}

EntityBulkOperation op = (EntityBulkOperation) o;
EntityBackgroundOperation op = (EntityBackgroundOperation) o;

return Objects.equals(this.key, op.key)
&& Objects.equals(this.entityList, op.entityList)
Expand All @@ -57,7 +57,7 @@ public final boolean equals(Object o) {
public String toString() {
StringBuilder b =
new StringBuilder(100)
.append("EntityBulkOperation[key:")
.append("EntityBackgroundOperation[key:")
.append(this.key)
.append(", entityList:")
.append(this.entityList)
Expand All @@ -73,15 +73,15 @@ public static Builder builder() {

public static class Builder {

private BulkOperationKey key;
private BackgroundOperationKey key;

private final List<Entity> entityList = new ArrayList<>();

private Consumer<Entity> consumer;

protected Builder() {}

public Builder key(BulkOperationKey key) {
public Builder key(BackgroundOperationKey key) {
Objects.requireNonNull(key, "key is null");
this.key = key;
return this;
Expand All @@ -99,7 +99,7 @@ public Builder consumer(Consumer<Entity> consumer) {
return this;
}

public EntityBulkOperation build() {
public EntityBackgroundOperation build() {
if (this.key == null) {
throw new IllegalStateException("key must be set");
}
Expand All @@ -109,7 +109,7 @@ public EntityBulkOperation build() {
if (this.consumer == null) {
throw new IllegalStateException("consumer must be set");
}
return new EntityBulkOperation(this);
return new EntityBackgroundOperation(this);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public long getEntity() {
}

/**
* The initiator can be a user of a system-service or other subjects who
* could authenticate themselves to work with the system.
* 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;
Expand Down Expand Up @@ -64,18 +64,16 @@ public final int hashCode() {
@Override
public final boolean equals(Object o) {

if (!(o instanceof HistoryEntry)) {
if (!(o instanceof HistoryEntry that)) {
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);
return Objects.equals(this.entity, that.entity)
&& Objects.equals(this.initiator, that.initiator)
&& Objects.equals(this.user, that.user)
&& Objects.equals(this.timestamp, that.timestamp)
&& Objects.equals(this.type, that.type)
&& Objects.equals(this.comment, that.comment);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.sitepark.ies.contentrepository.core.port;

import com.sitepark.ies.contentrepository.core.domain.entity.EntityBackgroundExecution;

public interface EntityBackgroundExecutor {
/**
* @return BulkExecution ID that can be used to track the progress
*/
String execute(EntityBackgroundExecution execution);
}

This file was deleted.

Loading

0 comments on commit 0462516

Please sign in to comment.