/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.gateway.common.cassandra.CassandraConnection
 *  com.l7tech.objectmodel.Entity
 *  com.l7tech.objectmodel.ExternalEntityHeader
 *  com.l7tech.objectmodel.ExternalEntityHeader$ValueType
 *  com.l7tech.objectmodel.migration.MigrationDependency
 *  com.l7tech.objectmodel.migration.MigrationMappingSelection
 *  com.l7tech.objectmodel.migration.MigrationUtils
 *  com.l7tech.objectmodel.migration.PropertyResolver$Type
 *  com.l7tech.objectmodel.migration.PropertyResolverException
 *  com.l7tech.policy.assertion.CassandraConnectionable
 *  com.l7tech.policy.variable.Syntax
 */
package com.l7tech.server.migration;

import com.l7tech.gateway.common.cassandra.CassandraConnection;
import com.l7tech.objectmodel.Entity;
import com.l7tech.objectmodel.ExternalEntityHeader;
import com.l7tech.objectmodel.migration.MigrationDependency;
import com.l7tech.objectmodel.migration.MigrationMappingSelection;
import com.l7tech.objectmodel.migration.MigrationUtils;
import com.l7tech.objectmodel.migration.PropertyResolver;
import com.l7tech.objectmodel.migration.PropertyResolverException;
import com.l7tech.policy.assertion.CassandraConnectionable;
import com.l7tech.policy.variable.Syntax;
import com.l7tech.server.EntityHeaderUtils;
import com.l7tech.server.cassandra.CassandraConnectionEntityManager;
import com.l7tech.server.migration.AbstractPropertyResolver;
import com.l7tech.server.migration.PropertyResolverFactory;
import java.lang.reflect.Method;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;

public class CassandraConnectionPropertyResolver
extends AbstractPropertyResolver {
    private static final Logger c;
    private final CassandraConnectionEntityManager d;
    private static final String[] e;

    public CassandraConnectionPropertyResolver(PropertyResolverFactory propertyResolverFactory, PropertyResolver.Type type, CassandraConnectionEntityManager cassandraConnectionEntityManager) {
        super(propertyResolverFactory, type);
        this.d = cassandraConnectionEntityManager;
    }

    public Map<ExternalEntityHeader, Set<MigrationDependency>> getDependencies(ExternalEntityHeader externalEntityHeader, Object object, Method method, String string) throws PropertyResolverException {
        try {
            c.log(Level.FINEST, e[1], new Object[]{string, externalEntityHeader});
            if (!(object instanceof CassandraConnectionable)) {
                throw new IllegalArgumentException(e[0] + String.valueOf(object));
            }
        }
        catch (Exception exception) {
            throw CassandraConnectionPropertyResolver.a(exception);
        }
        HashMap<ExternalEntityHeader, Set<MigrationDependency>> hashMap = new HashMap<ExternalEntityHeader, Set<MigrationDependency>>();
        MigrationMappingSelection migrationMappingSelection = MigrationUtils.getMappingType((Method)method);
        MigrationMappingSelection migrationMappingSelection2 = MigrationUtils.getValueMappingType((Method)method);
        ExternalEntityHeader.ValueType valueType = MigrationUtils.getValueType((Method)method);
        boolean bl2 = MigrationUtils.isExported((Method)method);
        String string2 = ((CassandraConnectionable)object).getConnectionName();
        try {
            if (Syntax.getSingleVariableReferenced((String)string2) == null) {
                CassandraConnection cassandraConnection = this.d.getCassandraConnectionEntity(string2);
                ExternalEntityHeader externalEntityHeader2 = EntityHeaderUtils.toExternal(EntityHeaderUtils.fromEntity((Entity)cassandraConnection));
                externalEntityHeader2.setValueMapping(migrationMappingSelection2, valueType, CassandraConnectionPropertyResolver.getPropertyValue(object, method));
                hashMap.put(externalEntityHeader2, Collections.singleton(new MigrationDependency(externalEntityHeader, externalEntityHeader2, string, this.getType(), migrationMappingSelection, bl2)));
            }
        }
        catch (Exception exception) {
            throw new PropertyResolverException(e[2] + string2);
        }
        return hashMap;
    }

    public void applyMapping(Object object, String string, ExternalEntityHeader externalEntityHeader, Object object2, ExternalEntityHeader externalEntityHeader2) throws PropertyResolverException {
        block5: {
            try {
                try {
                    c.log(Level.FINEST, e[3], new Object[]{object, string});
                    if (!(object instanceof CassandraConnectionable) || !(object2 instanceof CassandraConnection)) {
                    }
                    break block5;
                }
                catch (PropertyResolverException propertyResolverException) {
                    throw CassandraConnectionPropertyResolver.a((Exception)((Object)propertyResolverException));
                }
                throw new PropertyResolverException(e[5] + String.valueOf(object) + e[4] + String.valueOf(object2));
            }
            catch (PropertyResolverException propertyResolverException) {
                throw CassandraConnectionPropertyResolver.a((Exception)((Object)propertyResolverException));
            }
        }
        CassandraConnectionable cassandraConnectionable = (CassandraConnectionable)object;
        CassandraConnection cassandraConnection = (CassandraConnection)object2;
        cassandraConnectionable.setConnectionName(cassandraConnection.getName());
    }

    /*
     * Unable to fully structure code
     */
    static {
        block10: {
            block9: {
                var5 = new String[6];
                var3_1 = 0;
                var2_2 = "dTS \u0004s\u0006OTS*\u0007b\u0006B[I'\u001f~\u001c\u0007@`PI:\u0002iA\u0007QX>\u000eiBB[^'\u000et\u0006AZOn\u001buIWPO:\u0012']\u0017H\u001d!\r'CIAT:\u0012'QNAUn\u0003bGCPOn\u00106[\t'bGO!\u0019'TBAO'\u000eqOIR\u001d\r\ntUF[Y<\n'EH[S+\bsOH[\u0007n\u001ffEM\"\u0012nH@\u0015P/\u001bwOIR\u001d(\u0004u\u0006\\\u0005@nQ']\u0016H\u0013";
                var4_3 = "dTS \u0004s\u0006OTS*\u0007b\u0006B[I'\u001f~\u001c\u0007@`PI:\u0002iA\u0007QX>\u000eiBB[^'\u000et\u0006AZOn\u001buIWPO:\u0012']\u0017H\u001d!\r'CIAT:\u0012'QNAUn\u0003bGCPOn\u00106[\t'bGO!\u0019'TBAO'\u000eqOIR\u001d\r\ntUF[Y<\n'EH[S+\bsOH[\u0007n\u001ffEM\"\u0012nH@\u0015P/\u001bwOIR\u001d(\u0004u\u0006\\\u0005@nQ']\u0016H\u0013".length();
                var1_4 = 22;
                var0_5 = -1;
lbl7:
                // 2 sources

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

                while (true) {
                    var5[var3_1++] = CassandraConnectionPropertyResolver.b(v0, CassandraConnectionPropertyResolver.a(v2));
                    if ((var0_5 += var1_4) < var4_3) {
                        var1_4 = var2_2.charAt(var0_5);
                        ** continue;
                    }
                    var2_2 = "#+9#@pw\u0004 W\"bai\u00066\u0003ffa|\u0004+Fl`h9\u001c.Owf1\u007f\u0005=\u0019\"";
                    var4_3 = "#+9#@pw\u0004 W\"bai\u00066\u0003ffa|\u0004+Fl`h9\u001c.Owf1\u007f\u0005=\u0019\"".length();
                    var1_4 = 3;
                    var0_5 = -1;
lbl22:
                    // 2 sources

                    while (true) {
                        v0 = 80;
                        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++] = CassandraConnectionPropertyResolver.b(v0, CassandraConnectionPropertyResolver.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;
            }
        }
        CassandraConnectionPropertyResolver.e = var5;
        CassandraConnectionPropertyResolver.c = Logger.getLogger(CassandraConnectionPropertyResolver.class.getName());
    }

    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] ^ 0x52);
        }
        return cArray;
    }

    /*
     * Handled impossible loop by duplicating code
     * Enabled aggressive block sorting
     */
    private static String b(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 -> 83;
                    case 1 -> 65;
                    case 2 -> 73;
                    case 3 -> 58;
                    case 4 -> 31;
                    case 5 -> 115;
                    default -> 82;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

