/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.gateway.common.service.PublishedService
 *  com.l7tech.gateway.common.uddi.UDDIServiceControl
 *  com.l7tech.objectmodel.FindException
 *  com.l7tech.objectmodel.UpdateException
 *  com.l7tech.util.ExceptionUtils
 *  javax.wsdl.WSDLException
 */
package com.l7tech.server.uddi;

import com.l7tech.gateway.common.service.PublishedService;
import com.l7tech.gateway.common.uddi.UDDIServiceControl;
import com.l7tech.objectmodel.FindException;
import com.l7tech.objectmodel.UpdateException;
import com.l7tech.server.service.ServiceManager;
import com.l7tech.server.uddi.UDDIServiceControlManager;
import com.l7tech.util.ExceptionUtils;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.wsdl.WSDLException;

public class ServiceWsdlUpdateChecker {
    private static final Logger a;
    private final ServiceManager b;
    private final UDDIServiceControlManager c;
    private static final String[] d;

    public ServiceWsdlUpdateChecker(ServiceManager serviceManager, UDDIServiceControlManager uDDIServiceControlManager) {
        this.b = serviceManager;
        this.c = uDDIServiceControlManager;
    }

    public boolean isWsdlUpdatePermitted(PublishedService publishedService) throws UpdateException {
        return this.isWsdlUpdatePermitted(publishedService, false);
    }

    public boolean isWsdlUpdatePermitted(PublishedService publishedService, boolean bl2) throws UpdateException {
        boolean bl3;
        block10: {
            bl3 = true;
            try {
                PublishedService publishedService2;
                UDDIServiceControl uDDIServiceControl = this.c.findByPublishedServiceGoid(publishedService.getGoid());
                try {
                    if (uDDIServiceControl == null || !uDDIServiceControl.isUnderUddiControl()) break block10;
                }
                catch (WSDLException wSDLException) {
                    throw ServiceWsdlUpdateChecker.a(wSDLException);
                }
                bl3 = false;
                if (!bl2 || (publishedService2 = (PublishedService)this.b.findByPrimaryKey(publishedService.getGoid())) == null) break block10;
                try {
                    String string = publishedService.parsedWsdl().getHash();
                    String string2 = publishedService2.parsedWsdl().getHash();
                    try {
                        if (!string.equals(string2)) {
                            a.log(Level.INFO, d[1] + String.valueOf(publishedService.getGoid()) + d[3]);
                            publishedService.setWsdlXml(publishedService2.getWsdlXml());
                        }
                    }
                    catch (WSDLException wSDLException) {
                        throw ServiceWsdlUpdateChecker.a(wSDLException);
                    }
                }
                catch (WSDLException wSDLException) {
                    String[] stringArray = d;
                    throw new UpdateException(stringArray[2] + ExceptionUtils.getMessage((Throwable)wSDLException));
                }
                catch (IOException iOException) {
                    throw new UpdateException(d[0] + ExceptionUtils.getMessage((Throwable)iOException));
                }
            }
            catch (FindException findException) {
                throw new UpdateException((Throwable)findException);
            }
        }
        return bl3;
    }

    /*
     * Unable to fully structure code
     */
    static {
        block10: {
            block9: {
                var5 = new String[4];
                var3_1 = 0;
                var2_2 = "\u0000yI\u0003@\u0017#*fK\u0019F^.\"+l?v{`-jH\u0004\b\u0017\u0016\u0015~Y\u0000[D( o\u001b?WE6,h^L[Shf";
                var4_3 = "\u0000yI\u0003@\u0017#*fK\u0019F^.\"+l?v{`-jH\u0004\b\u0017\u0016\u0015~Y\u0000[D( o\u001b?WE6,h^L[Shf".length();
                var1_4 = 27;
                var0_5 = -1;
lbl7:
                // 2 sources

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

                while (true) {
                    var5[var3_1++] = ServiceWsdlUpdateChecker.a(v0, ServiceWsdlUpdateChecker.a(v2));
                    if ((var0_5 += var1_4) < var4_3) {
                        var1_4 = var2_2.charAt(var0_5);
                        ** continue;
                    }
                    var2_2 = "\fuE\u000fL\u001b<(uD\tP\\l\u001eTs,\u0004\u001b8inD@KU(,u\u00175z\u007f\u0005idX\u000eJI#%)\u00174V^l<wS\u0001J^(iPd$r\u001b; k[@\\^l `Y\u000fL^(";
                    var4_3 = "\fuE\u000fL\u001b<(uD\tP\\l\u001eTs,\u0004\u001b8inD@KU(,u\u00175z\u007f\u0005idX\u000eJI#%)\u00174V^l<wS\u0001J^(iPd$r\u001b; k[@\\^l `Y\u000fL^(".length();
                    var1_4 = 20;
                    var0_5 = -1;
lbl22:
                    // 2 sources

                    while (true) {
                        v0 = 34;
                        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++] = ServiceWsdlUpdateChecker.a(v0, ServiceWsdlUpdateChecker.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;
            }
        }
        ServiceWsdlUpdateChecker.d = var5;
        ServiceWsdlUpdateChecker.a = Logger.getLogger(ServiceWsdlUpdateChecker.class.getName());
    }

    private static WSDLException a(WSDLException wSDLException) {
        return wSDLException;
    }

    private static char[] a(String string) {
        char[] cArray = string.toCharArray();
        if (cArray.length < 2) {
            cArray = cArray;
            cArray[0] = (char)(cArray[0] ^ 0x6E);
        }
        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 -> 107;
                    case 1 -> 37;
                    case 2 -> 21;
                    case 3 -> 66;
                    case 4 -> 28;
                    case 5 -> 25;
                    default -> 110;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

