/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.util.Functions$Nullary
 */
package com.l7tech.server.audit;

import com.l7tech.server.audit.AuditsCollector;
import com.l7tech.server.audit.an;
import com.l7tech.server.audit.ao;
import com.l7tech.util.Functions;

public class AuditContextUtils {
    private static final ThreadLocal<Boolean> a = new an();
    private static final ThreadLocal<AuditsCollector> b = new ao();

    public static boolean isSystem() {
        return a.get();
    }

    public static void setSystem(boolean bl2) {
        a.set(bl2);
    }

    public static void doAsSystem(Runnable runnable) {
        boolean bl2 = AuditContextUtils.isSystem();
        try {
            AuditContextUtils.setSystem(true);
            runnable.run();
        }
        finally {
            AuditContextUtils.setSystem(bl2);
        }
    }

    public static AuditsCollector getAuditsCollector() {
        return b.get();
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    public static <T> T doWithAuditsCollector(AuditsCollector auditsCollector, Functions.Nullary<T> nullary) {
        AuditsCollector auditsCollector2 = b.get();
        b.set(auditsCollector);
        try {
            Object object = nullary.call();
            return (T)object;
        }
        finally {
            b.set(auditsCollector2);
        }
    }
}

