/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.gateway.common.service.ServiceDocument
 *  com.l7tech.objectmodel.Entity
 *  com.l7tech.objectmodel.EntityType
 *  com.l7tech.objectmodel.ExternalEntityHeader
 *  com.l7tech.objectmodel.FindException
 *  com.l7tech.objectmodel.Goid
 *  com.l7tech.objectmodel.migration.MigrationDependency
 *  com.l7tech.objectmodel.migration.PropertyResolver$Type
 *  com.l7tech.objectmodel.migration.PropertyResolverException
 *  com.l7tech.util.GoidUpgradeMapper
 */
package com.l7tech.server.migration;

import com.l7tech.gateway.common.service.ServiceDocument;
import com.l7tech.objectmodel.Entity;
import com.l7tech.objectmodel.EntityType;
import com.l7tech.objectmodel.ExternalEntityHeader;
import com.l7tech.objectmodel.FindException;
import com.l7tech.objectmodel.Goid;
import com.l7tech.objectmodel.migration.MigrationDependency;
import com.l7tech.objectmodel.migration.PropertyResolver;
import com.l7tech.objectmodel.migration.PropertyResolverException;
import com.l7tech.server.EntityHeaderUtils;
import com.l7tech.server.migration.AbstractPropertyResolver;
import com.l7tech.server.migration.PropertyResolverFactory;
import com.l7tech.server.service.ServiceDocumentManager;
import com.l7tech.util.GoidUpgradeMapper;
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 ServiceDocumentResolver
extends AbstractPropertyResolver {
    private static final Logger c;
    private ServiceDocumentManager d;
    private static final String[] e;

    public ServiceDocumentResolver(PropertyResolverFactory propertyResolverFactory, PropertyResolver.Type type, ServiceDocumentManager serviceDocumentManager) {
        super(propertyResolverFactory, type);
        this.d = serviceDocumentManager;
    }

    public Map<ExternalEntityHeader, Set<MigrationDependency>> getDependencies(ExternalEntityHeader externalEntityHeader, Object object, Method method, String string) throws PropertyResolverException {
        Goid goid;
        String[] stringArray = e;
        c.log(Level.FINEST, stringArray[2], new Object[]{method.getName(), externalEntityHeader});
        try {
            goid = GoidUpgradeMapper.mapId((EntityType)EntityType.SERVICE, (String)((String)ServiceDocumentResolver.getPropertyValue(object, method)));
        }
        catch (RuntimeException runtimeException) {
            stringArray = e;
            throw new PropertyResolverException(stringArray[1] + String.valueOf(object), (Throwable)runtimeException);
        }
        HashMap<ExternalEntityHeader, Set<MigrationDependency>> hashMap = new HashMap<ExternalEntityHeader, Set<MigrationDependency>>();
        try {
            for (ServiceDocument serviceDocument : this.d.findByServiceId(goid)) {
                ExternalEntityHeader externalEntityHeader2 = EntityHeaderUtils.toExternal(EntityHeaderUtils.fromEntity((Entity)serviceDocument));
                hashMap.put(externalEntityHeader2, Collections.singleton(null));
            }
        }
        catch (FindException findException) {
            c.log(Level.FINE, e[0], goid);
        }
        return hashMap;
    }

    public void applyMapping(Object object, String string, ExternalEntityHeader externalEntityHeader, Object object2, ExternalEntityHeader externalEntityHeader2) throws PropertyResolverException {
    }

    /*
     * Enabled aggressive block sorting
     */
    static {
        String[] stringArray = new String[3];
        int n2 = 0;
        String string = "\u000fFE3HM\r(J\u0000`IP\u00184D\u0000.YL['F\u0010.I\u001f\u001d.[E3HM\r(J\u0000z\rDK<\u0007)\u0004[\u0017/_\u001f\u001c$]\u0011)CX[1[\n0HM\u000f8\t\u0013!AJ\u001eaO\n2\rZ\u00155@\u00119\u0017\u001f@\u0006L\u00114DQ\u001caM\u00000HQ\u001f$G\u0006)HL['F\u0017`]M\u00141L\u00174T\u001f\u0000qTE/K\u001f\u001e/]\f4T\u001f\f(]\r`EZ\u001a%L\u0017`V\u000e\u0006o";
        int n3 = "\u000fFE3HM\r(J\u0000`IP\u00184D\u0000.YL['F\u0010.I\u001f\u001d.[E3HM\r(J\u0000z\rDK<\u0007)\u0004[\u0017/_\u001f\u001c$]\u0011)CX[1[\n0HM\u000f8\t\u0013!AJ\u001eaO\n2\rZ\u00155@\u00119\u0017\u001f@\u0006L\u00114DQ\u001caM\u00000HQ\u001f$G\u0006)HL['F\u0017`]M\u00141L\u00174T\u001f\u0000qTE/K\u001f\u001e/]\f4T\u001f\f(]\r`EZ\u001a%L\u0017`V\u000e\u0006o".length();
        int n4 = 44;
        int n5 = -1;
        while (true) {
            int n6 = ++n5;
            stringArray[n2++] = ServiceDocumentResolver.b(51, ServiceDocumentResolver.a(string.substring(n6, n6 + n4)));
            if ((n5 += n4) >= n3) {
                e = stringArray;
                c = Logger.getLogger(ServiceDocumentResolver.class.getName());
                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] ^ 0x48);
        }
        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 -> 114;
                    case 1 -> 26;
                    case 2 -> 86;
                    case 3 -> 115;
                    case 4 -> 30;
                    case 5 -> 12;
                    default -> 72;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

