/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.gateway.common.admin.PolicyBackedServiceAdmin
 *  com.l7tech.objectmodel.ConstraintViolationException
 *  com.l7tech.objectmodel.DeleteException
 *  com.l7tech.objectmodel.FindException
 *  com.l7tech.objectmodel.Goid
 *  com.l7tech.objectmodel.ObjectNotFoundException
 *  com.l7tech.objectmodel.PersistentEntity
 *  com.l7tech.objectmodel.SaveException
 *  com.l7tech.objectmodel.UpdateException
 *  com.l7tech.objectmodel.encass.EncapsulatedAssertionConfig
 *  com.l7tech.objectmodel.polback.PolicyBackedService
 *  com.l7tech.util.Functions
 *  com.l7tech.util.Functions$Unary
 *  jakarta.inject.Inject
 *  jakarta.inject.Named
 *  org.jetbrains.annotations.NotNull
 *  org.jetbrains.annotations.Nullable
 */
package com.l7tech.server.polback;

import com.l7tech.gateway.common.admin.PolicyBackedServiceAdmin;
import com.l7tech.objectmodel.ConstraintViolationException;
import com.l7tech.objectmodel.DeleteException;
import com.l7tech.objectmodel.FindException;
import com.l7tech.objectmodel.Goid;
import com.l7tech.objectmodel.ObjectNotFoundException;
import com.l7tech.objectmodel.PersistentEntity;
import com.l7tech.objectmodel.SaveException;
import com.l7tech.objectmodel.UpdateException;
import com.l7tech.objectmodel.encass.EncapsulatedAssertionConfig;
import com.l7tech.objectmodel.polback.PolicyBackedService;
import com.l7tech.server.polback.PolicyBackedServiceManager;
import com.l7tech.server.polback.PolicyBackedServiceRegistry;
import com.l7tech.server.polback.a;
import com.l7tech.util.Functions;
import jakarta.inject.Inject;
import jakarta.inject.Named;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import java.util.logging.Logger;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

/*
 * Exception performing whole class analysis ignored.
 */
public class PolicyBackedServiceAdminImpl
implements PolicyBackedServiceAdmin {
    private static final Logger a;
    @Inject
    @Named(value="policyBackedServiceManager")
    private PolicyBackedServiceManager policyBackedServiceManager;
    @Inject
    @Named(value="policyBackedServiceRegistry")
    PolicyBackedServiceRegistry policyBackedServiceRegistry;
    private static final String[] b;

    @NotNull
    public Collection<PolicyBackedService> findAll() throws FindException {
        Collection collection;
        try {
            collection = this.policyBackedServiceManager.findAll();
            if (collection == null) {
                PolicyBackedServiceAdminImpl.a(0);
            }
        }
        catch (FindException findException) {
            throw PolicyBackedServiceAdminImpl.a((Exception)((Object)findException));
        }
        return collection;
    }

    @NotNull
    public Collection<PolicyBackedService> findAllForInterface(@NotNull String string) throws FindException {
        List list;
        try {
            if (string == null) {
                PolicyBackedServiceAdminImpl.a(1);
            }
        }
        catch (FindException findException) {
            throw PolicyBackedServiceAdminImpl.a((Exception)((Object)findException));
        }
        try {
            list = Functions.grep((Iterable)this.policyBackedServiceManager.findAll(), (Functions.Unary)new a(this, string));
            if (list == null) {
                PolicyBackedServiceAdminImpl.a(2);
            }
        }
        catch (FindException findException) {
            throw PolicyBackedServiceAdminImpl.a((Exception)((Object)findException));
        }
        return list;
    }

    @NotNull
    public Collection<String> findAllTemplateInterfaceNames() {
        Set<String> set;
        try {
            set = this.policyBackedServiceRegistry.getPolicyBackedServiceTemplates();
            if (set == null) {
                PolicyBackedServiceAdminImpl.a(3);
            }
        }
        catch (IllegalStateException illegalStateException) {
            throw PolicyBackedServiceAdminImpl.a(illegalStateException);
        }
        return set;
    }

    @NotNull
    public Collection<EncapsulatedAssertionConfig> getInterfaceDescription(String string) throws ObjectNotFoundException {
        List<EncapsulatedAssertionConfig> list;
        try {
            list = this.policyBackedServiceRegistry.getTemplateOperations(string);
            if (list == null) {
                PolicyBackedServiceAdminImpl.a(4);
            }
        }
        catch (ObjectNotFoundException objectNotFoundException) {
            throw PolicyBackedServiceAdminImpl.a((Exception)((Object)objectNotFoundException));
        }
        return list;
    }

    @Nullable
    public PolicyBackedService findByPrimaryKey(Goid goid) throws FindException {
        return (PolicyBackedService)this.policyBackedServiceManager.findByPrimaryKey(goid);
    }

    public Goid save(PolicyBackedService policyBackedService) throws SaveException, UpdateException {
        Goid goid;
        if (policyBackedService.isUnsaved()) {
            goid = this.policyBackedServiceManager.save((PersistentEntity)policyBackedService);
        } else {
            this.policyBackedServiceManager.update((PersistentEntity)policyBackedService);
            goid = policyBackedService.getGoid();
        }
        return goid;
    }

    public void deletePolicyBackedService(@NotNull Goid goid) throws FindException, DeleteException, ConstraintViolationException {
        try {
            if (goid == null) {
                PolicyBackedServiceAdminImpl.a(5);
            }
        }
        catch (FindException findException) {
            throw PolicyBackedServiceAdminImpl.a((Exception)((Object)findException));
        }
        this.policyBackedServiceManager.delete(goid);
    }

    /*
     * Unable to fully structure code
     */
    static {
        block10: {
            block9: {
                var5 = new String[12];
                var3_1 = 0;
                var2_2 = "\u0011\u0000pW\u0013\u0010\u0006wW;C?0\u0000kz\u0014[6\u0004\txP\u001f6\u0015\u0000t\u001c\u0016\u0018'\u0013\fq\u001c\tJ!\u0000\nk\u001c\n@?\u0014\u000ezXU\u007f<\u001a\u0006zJ8N0\u001d\n}`\u001f]%\u001f\f|r\u001eB:\u0018&tC\u0016\u0017\u0011\nmz\u0014[6\u0004\txP\u001fk6\u0005\fkZ\n[:\u0019\u0001\u0019\u0012\nuV\u000eJ\u0003\u0019\u0003pP\u0003m2\u0015\u0004|W)J!\u0000\u0006zV>7\u001d~F\u0017J=\u0002O\u007f\\\b\u000f\u00138\u0000m}\u000fC?V\u001fxA\u001bB6\u0002\nk\u0013]\n QOvUZ\n XJj\u0013\u0017Z \u0002Ow\\\u000e\u000f1\u0013OwF\u0016C6\u0015\u0000t\u001c\u0016\u0018'\u0013\fq\u001c\tJ!\u0000\nk\u001c\n@?\u0014\u000ezXU\u007f<\u001a\u0006zJ8N0\u001d\n}`\u001f]%\u001f\f|r\u001eB:\u0018&tC\u0016\u0007\u0010\u0006wW;C?\u001d\u0010\u0006wW;C?\"\ntC\u0016N'\u0013&wG\u001f]5\u0017\f|}\u001bB6\u0005\u0012\u001f\u0001mV\bI2\u0015\nZ_\u001b\\ 8\u000etV";
                var4_3 = "\u0011\u0000pW\u0013\u0010\u0006wW;C?0\u0000kz\u0014[6\u0004\txP\u001f6\u0015\u0000t\u001c\u0016\u0018'\u0013\fq\u001c\tJ!\u0000\nk\u001c\n@?\u0014\u000ezXU\u007f<\u001a\u0006zJ8N0\u001d\n}`\u001f]%\u001f\f|r\u001eB:\u0018&tC\u0016\u0017\u0011\nmz\u0014[6\u0004\txP\u001fk6\u0005\fkZ\n[:\u0019\u0001\u0019\u0012\nuV\u000eJ\u0003\u0019\u0003pP\u0003m2\u0015\u0004|W)J!\u0000\u0006zV>7\u001d~F\u0017J=\u0002O\u007f\\\b\u000f\u00138\u0000m}\u000fC?V\u001fxA\u001bB6\u0002\nk\u0013]\n QOvUZ\n XJj\u0013\u0017Z \u0002Ow\\\u000e\u000f1\u0013OwF\u0016C6\u0015\u0000t\u001c\u0016\u0018'\u0013\fq\u001c\tJ!\u0000\nk\u001c\n@?\u0014\u000ezXU\u007f<\u001a\u0006zJ8N0\u001d\n}`\u001f]%\u001f\f|r\u001eB:\u0018&tC\u0016\u0007\u0010\u0006wW;C?\u001d\u0010\u0006wW;C?\"\ntC\u0016N'\u0013&wG\u001f]5\u0017\f|}\u001bB6\u0005\u0012\u001f\u0001mV\bI2\u0015\nZ_\u001b\\ 8\u000etV".length();
                var1_4 = 4;
                var0_5 = -1;
lbl7:
                // 2 sources

                while (true) {
                    v0 = 58;
                    v1 = ++var0_5;
                    v2 = var2_2.substring(v1, v1 + var1_4);
                    v3 = -1;
                    break block9;
                    break;
                }
lbl13:
                // 1 sources

                while (true) {
                    var5[var3_1++] = PolicyBackedServiceAdminImpl.a(v0, PolicyBackedServiceAdminImpl.a(v2));
                    if ((var0_5 += var1_4) < var4_3) {
                        var1_4 = var2_2.charAt(var0_5);
                        ** continue;
                    }
                    var2_2 = "\u0003\u0014Cr\u0001o\n/zAc;r\t'z\tua?\u0015c7Yu;:\b,.\ft*n\u001314\fh:v\n\u0013%3Bb\u000ev\n\u00055^O!n\u00031<Me*";
                    var4_3 = "\u0003\u0014Cr\u0001o\n/zAc;r\t'z\tua?\u0015c7Yu;:\b,.\ft*n\u001314\fh:v\n\u0013%3Bb\u000ev\n\u00055^O!n\u00031<Me*".length();
                    var1_4 = 42;
                    var0_5 = -1;
lbl22:
                    // 2 sources

                    while (true) {
                        v0 = 15;
                        v4 = ++var0_5;
                        v2 = var2_2.substring(v4, v4 + var1_4);
                        v3 = 0;
                        break block9;
                        break;
                    }
                    break;
                }
lbl28:
                // 1 sources

                while (true) {
                    var5[var3_1++] = PolicyBackedServiceAdminImpl.a(v0, PolicyBackedServiceAdminImpl.a(v2));
                    if ((var0_5 += var1_4) < var4_3) {
                        var1_4 = var2_2.charAt(var0_5);
                        ** continue;
                    }
                    break block10;
                    break;
                }
            }
            switch (v3) {
                default: {
                    ** continue;
                }
                ** case 0:
lbl39:
                // 1 sources

                ** continue;
            }
        }
        PolicyBackedServiceAdminImpl.b = var5;
        PolicyBackedServiceAdminImpl.a = Logger.getLogger(PolicyBackedServiceAdminImpl.class.getName());
    }

    /*
     * Exception decompiling
     */
    private static /* synthetic */ void a(int var0) {
        /*
         * This method has failed to decompile.  When submitting a bug report, please provide this stack trace, and (if you hold appropriate legal rights) the relevant class file.
         * 
         * org.benf.cfr.reader.util.ConfusedCFRException: Tried to end blocks [0[TRYBLOCK]], but top level block is 6[SWITCH]
         *     at org.benf.cfr.reader.bytecode.analysis.opgraph.Op04StructuredStatement.processEndingBlocks(Op04StructuredStatement.java:435)
         *     at org.benf.cfr.reader.bytecode.analysis.opgraph.Op04StructuredStatement.buildNestedBlocks(Op04StructuredStatement.java:484)
         *     at org.benf.cfr.reader.bytecode.analysis.opgraph.Op03SimpleStatement.createInitialStructuredBlock(Op03SimpleStatement.java:736)
         *     at org.benf.cfr.reader.bytecode.CodeAnalyser.getAnalysisInner(CodeAnalyser.java:850)
         *     at org.benf.cfr.reader.bytecode.CodeAnalyser.getAnalysisOrWrapFail(CodeAnalyser.java:278)
         *     at org.benf.cfr.reader.bytecode.CodeAnalyser.getAnalysis(CodeAnalyser.java:201)
         *     at org.benf.cfr.reader.entities.attributes.AttributeCode.analyse(AttributeCode.java:94)
         *     at org.benf.cfr.reader.entities.Method.analyse(Method.java:531)
         *     at org.benf.cfr.reader.entities.ClassFile.analyseMid(ClassFile.java:1050)
         *     at org.benf.cfr.reader.entities.ClassFile.analyseTop(ClassFile.java:942)
         *     at org.benf.cfr.reader.Driver.doJarVersionTypes(Driver.java:257)
         *     at org.benf.cfr.reader.Driver.doJar(Driver.java:139)
         *     at org.benf.cfr.reader.CfrDriverImpl.analyse(CfrDriverImpl.java:76)
         *     at org.benf.cfr.reader.Main.main(Main.java:54)
         */
        throw new IllegalStateException("Decompilation failed");
    }

    private static Exception a(Exception exception) {
        return exception;
    }

    private static char[] a(String string) {
        char[] cArray = string.toCharArray();
        if (cArray.length < 2) {
            cArray = cArray;
            cArray[0] = (char)(cArray[0] ^ 0x69);
        }
        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 -> 76;
                    case 1 -> 85;
                    case 2 -> 35;
                    case 3 -> 9;
                    case 4 -> 64;
                    case 5 -> 21;
                    default -> 105;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

