Record Class AuditChangeContext

java.lang.Object
java.lang.Record
io.leandev.appfuse.audit.entity.AuditChangeContext

public record AuditChangeContext(String subjectId, String actorId, List<String> grantorIds, AuditPrincipalKind principalKind, String tenantId, String requestId, String sessionId, AuditSource source) extends Record

一次持久化 changeset 的身份與關聯脈絡。

subjectIdactorIdgrantorIds 一律承載 stable subject,不是 username 或顯示名稱:

  • 一般操作:subject = actor、grantors = []
  • 模擬:subject = 被模擬者、actor = 真實操作者
  • 代理:subject = actor、grantors = 授權人集合
  • 兩者並存:subject = 被模擬者、actor = 真實操作者、grantors = 授權人集合

本型別不含 Hibernate/Envers API,可由不同 Entity history adapter 共用。

  • Constructor Details

    • AuditChangeContext

      public AuditChangeContext(String subjectId, String actorId, List<String> grantorIds, AuditPrincipalKind principalKind, String tenantId, String requestId, String sessionId, AuditSource source)
      Creates an instance of a AuditChangeContext record class.
      Parameters:
      subjectId - the value for the subjectId record component
      actorId - the value for the actorId record component
      grantorIds - the value for the grantorIds record component
      principalKind - the value for the principalKind record component
      tenantId - the value for the tenantId record component
      requestId - the value for the requestId record component
      sessionId - the value for the sessionId record component
      source - the value for the source record component
  • Method Details

    • withTenantId

      public AuditChangeContext withTenantId(String tenantId)
      以相同 changeset 脈絡補上應用層資料範圍;tenantless 應用維持 null
    • isImpersonating

      public boolean isImpersonating()
    • isDelegating

      public boolean isDelegating()
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • subjectId

      public String subjectId()
      Returns the value of the subjectId record component.
      Returns:
      the value of the subjectId record component
    • actorId

      public String actorId()
      Returns the value of the actorId record component.
      Returns:
      the value of the actorId record component
    • grantorIds

      public List<String> grantorIds()
      Returns the value of the grantorIds record component.
      Returns:
      the value of the grantorIds record component
    • principalKind

      public AuditPrincipalKind principalKind()
      Returns the value of the principalKind record component.
      Returns:
      the value of the principalKind record component
    • tenantId

      public String tenantId()
      Returns the value of the tenantId record component.
      Returns:
      the value of the tenantId record component
    • requestId

      public String requestId()
      Returns the value of the requestId record component.
      Returns:
      the value of the requestId record component
    • sessionId

      public String sessionId()
      Returns the value of the sessionId record component.
      Returns:
      the value of the sessionId record component
    • source

      public AuditSource source()
      Returns the value of the source record component.
      Returns:
      the value of the source record component