/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.gateway.common.log.LogFileInfo
 *  com.l7tech.gateway.common.log.LogSinkAdmin
 *  com.l7tech.gateway.common.log.LogSinkData
 *  com.l7tech.gateway.common.log.LogSinkQuery
 *  com.l7tech.gateway.common.log.SinkConfiguration
 *  com.l7tech.objectmodel.DeleteException
 *  com.l7tech.objectmodel.FindException
 *  com.l7tech.objectmodel.Goid
 *  com.l7tech.objectmodel.PersistentEntity
 *  com.l7tech.objectmodel.SaveException
 *  com.l7tech.objectmodel.UpdateException
 */
package com.l7tech.server.log;

import com.l7tech.gateway.common.log.LogFileInfo;
import com.l7tech.gateway.common.log.LogSinkAdmin;
import com.l7tech.gateway.common.log.LogSinkData;
import com.l7tech.gateway.common.log.LogSinkQuery;
import com.l7tech.gateway.common.log.SinkConfiguration;
import com.l7tech.objectmodel.DeleteException;
import com.l7tech.objectmodel.FindException;
import com.l7tech.objectmodel.Goid;
import com.l7tech.objectmodel.PersistentEntity;
import com.l7tech.objectmodel.SaveException;
import com.l7tech.objectmodel.UpdateException;
import com.l7tech.server.log.SinkManager;
import java.util.Collection;

public class LogSinkAdminImpl
implements LogSinkAdmin {
    private final SinkManager a;
    private static final String[] b;

    public LogSinkAdminImpl(SinkManager sinkManager) {
        this.a = sinkManager;
    }

    public Collection<SinkConfiguration> findAllSinkConfigurations() throws FindException {
        return this.a.findAll();
    }

    public SinkConfiguration getSinkConfigurationByPrimaryKey(Goid goid) throws FindException {
        return (SinkConfiguration)this.a.findByPrimaryKey(goid);
    }

    public Goid saveSinkConfiguration(SinkConfiguration sinkConfiguration) throws SaveException, UpdateException {
        if (sinkConfiguration.isUnsaved()) {
            Goid goid = this.a.save((PersistentEntity)sinkConfiguration);
            sinkConfiguration.setGoid(goid);
            try {
                this.a.createRoles((PersistentEntity)sinkConfiguration);
            }
            catch (SaveException saveException) {
                throw new SaveException(b[1], (Throwable)saveException);
            }
            return goid;
        }
        this.a.update((PersistentEntity)sinkConfiguration);
        return sinkConfiguration.getGoid();
    }

    public void deleteSinkConfiguration(Goid goid) throws DeleteException, FindException {
        this.a.delete(goid);
    }

    public boolean sendTestSyslogMessage(SinkConfiguration sinkConfiguration, String string) {
        return this.a.test(sinkConfiguration, string);
    }

    public long getMaximumFileSize() {
        return this.a.getMaximumFileStorageSpace();
    }

    public long getReservedFileSize() {
        return this.a.getReservedFileStorageSpace();
    }

    public Collection<LogFileInfo> findAllFilesForSinkByNode(String string, Goid goid) throws FindException {
        try {
            if (string == null) {
                throw new FindException(b[0]);
            }
        }
        catch (FindException findException) {
            throw LogSinkAdminImpl.a(findException);
        }
        return this.a.findAllFilesForSinkByNode(string, goid);
    }

    public LogSinkData getSinkLogs(String string, Goid goid, String string2, LogSinkQuery logSinkQuery) throws FindException {
        return this.a.getSinkLogs(string, goid, string2, logSinkQuery);
    }

    private static FindException a(FindException findException) {
        return findException;
    }

    /*
     * Enabled aggressive block sorting
     */
    static {
        String[] stringArray = new String[2];
        int n2 = 0;
        String string = "9Wg3T\n\u0007TP{$XD\t\u0010[z4T\u0002\t\u0011L!1Lf/OD\u0003\u0006[u4T\n\u0007Tl{,XD\u0006\u001bL4,R\u0003@\u0007Wz+\u0013";
        int n3 = "9Wg3T\n\u0007TP{$XD\t\u0010[z4T\u0002\t\u0011L!1Lf/OD\u0003\u0006[u4T\n\u0007Tl{,XD\u0006\u001bL4,R\u0003@\u0007Wz+\u0013".length();
        int n4 = 23;
        int n5 = -1;
        while (true) {
            int n6 = ++n5;
            stringArray[n2++] = LogSinkAdminImpl.a(48, LogSinkAdminImpl.a(string.substring(n6, n6 + n4)));
            if ((n5 += n4) >= n3) {
                b = stringArray;
                return;
            }
            n4 = string.charAt(n5);
        }
    }

    private static char[] a(String string) {
        char[] cArray = string.toCharArray();
        if (cArray.length < 2) {
            cArray = cArray;
            cArray[0] = (char)(cArray[0] ^ 0x50);
        }
        return cArray;
    }

    /*
     * Handled impossible loop by duplicating code
     * Enabled aggressive block sorting
     */
    private static String a(int n2, char[] cArray) {
        char[] cArray2;
        block11: {
            int n3;
            int n4;
            int n5;
            block10: {
                n5 = n2;
                cArray2 = cArray;
                n4 = cArray.length;
                n3 = 0;
                if (!true) break block10;
                n4 = n4;
                if (n4 <= n3) break block11;
            }
            do {
                n5 = n5;
                cArray2 = cArray2;
                int n6 = n3;
                cArray2[n6] = (char)(cArray2[n6] ^ (n5 ^ (switch (n3 % 7) {
                    case 0 -> 68;
                    case 1 -> 14;
                    case 2 -> 36;
                    case 3 -> 112;
                    case 4 -> 13;
                    case 5 -> 84;
                    default -> 80;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

