Class AuditDto

java.lang.Object
com.qfs.snl.dtos.AuditDto
All Implemented Interfaces:
IAudit, IIdentifiable, Serializable

public class AuditDto extends Object implements IAudit, Serializable
The audit data transfer object.
Author:
ActiveViam
See Also:
  • Constructor Details

    • AuditDto

      public AuditDto()
      Constructor.
    • AuditDto

      public AuditDto(long id, long timestamp, String username, String ip, String hostname)
      Constructor.
      Parameters:
      id - audit id
      timestamp - time in milliseconds at which the action occurred
      username - the user performing the action
      ip - the ip address
      hostname - name of the host
    • AuditDto

      public AuditDto(IAudit audit)
      Constructor.
      Parameters:
      audit - to duplicate
  • Method Details

    • create

      public static AuditDto create(IAudit audit)
      Creates a DTO from an existing audit.

      If the audit is null, the equivalent DTO is null as well.

      Parameters:
      audit - audit to convert
      Returns:
      the DTO or null
    • getId

      public long getId()
      Description copied from interface: IIdentifiable
      Gets the resource id.
      Specified by:
      getId in interface IIdentifiable
      Returns:
      the id
    • setId

      public AuditDto setId(long id)
      Sets this audit unique id.
      Returns:
      this
    • getTimestamp

      public long getTimestamp()
      Description copied from interface: IAudit
      Return the timestamp in milliseconds when the action occurred.
      Specified by:
      getTimestamp in interface IAudit
      Returns:
      the timestamp in milliseconds
    • setTimestamp

      public AuditDto setTimestamp(long timestamp)
      Sets the timestamp of this audit entry.
      Parameters:
      timestamp - date time in milliseconds
      Returns:
      this
    • getUsername

      public String getUsername()
      Description copied from interface: IAudit
      Return the name of the user.
      Specified by:
      getUsername in interface IAudit
      Returns:
      the users's name
    • setUsername

      public AuditDto setUsername(String username)
      Sets the name of the user.
      Returns:
      this
    • getIp

      public String getIp()
      Description copied from interface: IAudit
      Return the ip of the computer that created the action.
      Specified by:
      getIp in interface IAudit
      Returns:
      the ip
    • setIp

      public AuditDto setIp(String ip)
      Sets the host ip address.
      Returns:
      this
    • getHostname

      public String getHostname()
      Description copied from interface: IAudit
      The hostname of the computer that created the action.
      Specified by:
      getHostname in interface IAudit
      Returns:
      the hostname
    • setHostname

      public AuditDto setHostname(String hostname)
      Sets the hostname of the host machine.
      Returns:
      this
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toString

      public static String toString(IAudit obj)
      Returns the string representation of the given audit.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • hashCode

      public static int hashCode(IAudit obj)
      Returns the hashcode of the given audit.
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • equals

      public static boolean equals(IAudit audit, Object obj)
      Tests the equality between a IAudit and an object.

      Two audit entries are equals if they come from the same user, using the same ip on the same host simultaneously.
      This is consistent for an append-only resource.

      Parameters:
      audit - the reference audit
      obj - the object to test
      Returns:
      true for equality