You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
977 B
Java
32 lines
977 B
Java
package at.procon.dip.domain.access;
|
|
|
|
import at.procon.dip.domain.tenant.TenantRef;
|
|
import java.util.Objects;
|
|
|
|
/**
|
|
* Canonical ownership and visibility descriptor for a document.
|
|
* <p>
|
|
* A document may have no owner tenant, for example public TED notices.
|
|
* Visibility is always mandatory and defines who may search/read the document.
|
|
*/
|
|
public record DocumentAccessContext(
|
|
TenantRef ownerTenant,
|
|
DocumentVisibility visibility
|
|
) {
|
|
|
|
public DocumentAccessContext {
|
|
Objects.requireNonNull(visibility, "visibility must not be null");
|
|
}
|
|
|
|
public static DocumentAccessContext publicDocument() {
|
|
return new DocumentAccessContext(null, DocumentVisibility.PUBLIC);
|
|
}
|
|
|
|
public static DocumentAccessContext tenantOwned(TenantRef ownerTenant) {
|
|
return new DocumentAccessContext(
|
|
Objects.requireNonNull(ownerTenant, "ownerTenant must not be null"),
|
|
DocumentVisibility.TENANT
|
|
);
|
|
}
|
|
}
|