/*-
 * ~~~~~~licensing~~~~~~
 * entaxy-audit
 * ==========
 * Copyright (C) 2020 - 2025 EmDev LLC
 * ==========
 * You may not use this file except in accordance with the License Terms of the Copyright
 * Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
 * rights to the Software and any copies are the property of the Copyright Holder. Unless
 * it is explicitly allowed the Copyright Holder, the User is prohibited from using the
 * Software for commercial purposes to provide services to third parties.
 * 
 * The Copyright Holder hereby declares that the Software is provided on an "AS IS".
 * Under no circumstances does the Copyright Holder guarantee or promise that the
 * Software provided by him will be suitable or not suitable for the specific purposes
 * of the User, that the Software will meet all commercial and personal subjective
 * expectations of the User, that the Software will work properly, without technical
 * errors, quickly and uninterruptedly.
 * 
 * Under no circumstances shall the Copyright Holder or its Affiliates is not liable
 * to the User for any direct or indirect losses of the User, his expenses or actual
 * damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
 * or damage to data, property, etc.
 * ~~~~~~/licensing~~~~~~
 */
package ru.entaxy.audit.data;

import ru.entaxy.audit.utils.AuditHelper;

public class AuditEvent {
    private final String target;
    private final String category;
    private final String suser;
    private final String duser;
    private final String message;
    private final Outcome outcome;

    private final Severity severity;
    private final String src;

    public AuditEvent(String target, String category, String suser,
                      String duser, String message, Outcome outcome,
                      Severity severity, String src) {
        this.target = target;
        this.category = category;
        this.suser = suser;
        this.duser = duser;
        this.message = message;
        this.outcome = outcome;
        this.severity = severity;
        this.src = src;
    }

    public String getTarget() {
        return target;
    }

    public String getCategory() {
        return category;
    }

    public String getSuser() {
        return suser;
    }

    public String getDuser() {
        return duser;
    }

    public String getMessage() {
        return message;
    }

    public Outcome getOutcome() {
        return outcome;
    }

    public Severity getSeverity() {
        return severity;
    }

    public String getSrc() {
        return src;
    }

    public static class AuditLoggingEventBuilder {
        private String target = AuditHelper.DEFAULT_TARGET;
        private String category;
        private String suser;
        private String duser;
        private String message;

        private String src;
        private Outcome outcome = Outcome.SUCCESS;
        private Severity severity = AuditHelper.DEFAULT_SEVERITY;


        public static AuditLoggingEventBuilder getInstance() {
            return new AuditLoggingEventBuilder();
        }

        public AuditLoggingEventBuilder target(String target) {
            this.target = target;
            return this;
        }

        public AuditLoggingEventBuilder category(String category) {
            this.category = category;
            return this;
        }

        public AuditLoggingEventBuilder suser(String suser) {
            this.suser = suser;
            return this;
        }

        public AuditLoggingEventBuilder duser(String duser) {
            this.duser = duser;
            return this;
        }

        public AuditLoggingEventBuilder message(String message) {
            this.message = message;
            return this;
        }

        public AuditLoggingEventBuilder outcome(Outcome outcome) {
            this.outcome = outcome;
            return this;
        }

        public AuditLoggingEventBuilder severity(Severity severity) {
            this.severity = severity;
            return this;
        }

        public AuditLoggingEventBuilder src(String src) {
            this.src = src;
            return this;
        }

        public AuditEvent build() {
            return new AuditEvent(target, category, suser, duser,
                    message, outcome, severity, src);
        }
    }
}
