/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.gateway.common.audit.AuditFactory
 *  com.l7tech.gateway.common.service.PublishedService
 *  com.l7tech.message.Message
 *  com.l7tech.wsdl.Wsdl
 *  javax.wsdl.BindingOperation
 *  javax.wsdl.Definition
 *  javax.wsdl.WSDLException
 */
package com.l7tech.server.service.resolution;

import com.l7tech.gateway.common.audit.AuditFactory;
import com.l7tech.gateway.common.service.PublishedService;
import com.l7tech.message.Message;
import com.l7tech.server.service.resolution.NameValueServiceResolver;
import com.l7tech.server.service.resolution.ServiceResolutionException;
import com.l7tech.wsdl.Wsdl;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.wsdl.BindingOperation;
import javax.wsdl.Definition;
import javax.wsdl.WSDLException;

public abstract class WsdlOperationServiceResolver<T>
extends NameValueServiceResolver<T> {
    private static final String[] c;

    protected WsdlOperationServiceResolver(AuditFactory auditFactory) {
        super(auditFactory);
    }

    /*
     * Enabled force condition propagation
     * Lifted jumps to return sites
     */
    @Override
    protected List<T> buildTargetValues(PublishedService publishedService) throws ServiceResolutionException {
        try {
            if (!publishedService.isSoap()) {
                return Collections.emptyList();
            }
        }
        catch (WSDLException wSDLException) {
            throw WsdlOperationServiceResolver.b((Exception)((Object)wSDLException));
        }
        ArrayList<T> arrayList = new ArrayList<T>(2);
        try {
            Wsdl wsdl = publishedService.parsedWsdl();
            if (wsdl == null) {
                return Collections.emptyList();
            }
            wsdl.setShowBindings(1);
            for (BindingOperation bindingOperation : wsdl.getBindingOperations()) {
                Set<T> set = this.getTargetValues(wsdl.getDefinition(), bindingOperation);
                try {
                    if (set == null) continue;
                    arrayList.addAll(set);
                }
                catch (WSDLException wSDLException) {
                    throw WsdlOperationServiceResolver.b((Exception)((Object)wSDLException));
                    return arrayList;
                }
            }
        }
        catch (WSDLException wSDLException) {
            String[] stringArray = c;
            throw new ServiceResolutionException(stringArray[2] + wSDLException.getMessage() + stringArray[0], wSDLException);
        }
    }

    public Set<T> getDistinctParameters(PublishedService publishedService) throws ServiceResolutionException {
        HashSet<T> hashSet = new HashSet<T>();
        try {
            if (!publishedService.isSoap()) {
                hashSet.add(null);
                return hashSet;
            }
        }
        catch (ServiceResolutionException serviceResolutionException) {
            throw WsdlOperationServiceResolver.b(serviceResolutionException);
        }
        hashSet.addAll(this.buildTargetValues(publishedService));
        return hashSet;
    }

    protected abstract Set<T> getTargetValues(Definition var1, BindingOperation var2);

    @Override
    public boolean isApplicableToMessage(Message message) throws ServiceResolutionException {
        try {
            return message.isSoap();
        }
        catch (Exception exception) {
            throw new ServiceResolutionException(c[1], exception);
        }
    }

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

    /*
     * Enabled aggressive block sorting
     */
    static {
        String[] stringArray = new String[3];
        int n2 = 0;
        String string = "\u00164+dt)syl\u001fEuhup}ZCw!\u007fp)HY\u007f<yp{\u001f\\\u007f;btnZ\u0011s;1FF~a\u001eth:~g)^Ry-bf`QV:;tg\u007fVR\u007fhFFMs\u0011=";
        int n3 = "\u00164+dt)syl\u001fEuhup}ZCw!\u007fp)HY\u007f<yp{\u001f\\\u007f;btnZ\u0011s;1FF~a\u001eth:~g)^Ry-bf`QV:;tg\u007fVR\u007fhFFMs\u0011=".length();
        int n4 = 2;
        int n5 = -1;
        while (true) {
            int n6 = ++n5;
            stringArray[n2++] = WsdlOperationServiceResolver.b(108, WsdlOperationServiceResolver.a(string.substring(n6, n6 + n4)));
            if ((n5 += n4) >= n3) {
                c = 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] ^ 0x53);
        }
        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 -> 93;
                    case 1 -> 118;
                    case 2 -> 36;
                    case 3 -> 125;
                    case 4 -> 121;
                    case 5 -> 101;
                    default -> 83;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

