Skip to content

Commit

Permalink
feat: History entries can also be made about other authenticated
Browse files Browse the repository at this point in the history
subjects.
  • Loading branch information
sitepark-veltrup committed Nov 21, 2022
1 parent 7fe5095 commit 7f5d834
Showing 1 changed file with 29 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package com.sitepark.ies.contentrepository.core.domain.entity;

import java.io.Serializable;
import java.util.Optional;

public final class HistoryEntry implements Serializable {

private final long entity;
private final long user;
private final String initiator;
private final Long user;
private final long timestamp;
private final HistoryEntryType type;
private final String comment;
Expand All @@ -14,6 +16,7 @@ public final class HistoryEntry implements Serializable {

private HistoryEntry(Builder builder) {
this.entity = builder.entity;
this.initiator = builder.initiator;
this.user = builder.user;
this.timestamp = builder.timestamp;
this.type = builder.type;
Expand All @@ -24,8 +27,19 @@ public long getEntity() {
return entity;
}

public long getUser() {
return user;
/**
* 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<Long> getUser() {
return Optional.ofNullable(this.user);
}

public long getTimestamp() {
Expand All @@ -51,7 +65,8 @@ public Builder toBuilder() {
public static class Builder {

private long entity;
private long user;
private String initiator;
private Long user;
private long timestamp;
private HistoryEntryType type;
private String comment;
Expand All @@ -60,6 +75,7 @@ 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;
Expand All @@ -71,7 +87,13 @@ public Builder entity(long entity) {
return this;
}

public Builder user(long user) {
public Builder initiator(String initiator) {
assert initiator != null : "initiator is null";
this.initiator = initiator;
return this;
}

public Builder user(Long user) {
this.user = user;
return this;
}
Expand All @@ -83,13 +105,13 @@ public Builder timestamp(long timestamp) {
}

public Builder type(HistoryEntryType type) {
assert type != null;
assert type != null : "type is null";
this.type = type;
return this;
}

public Builder comment(String comment) {
assert comment != null;
assert comment != null : "comment is null";
this.comment = comment;
return this;
}
Expand Down

0 comments on commit 7f5d834

Please sign in to comment.