/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.gateway.common.audit.AuditDetailMessage
 *  com.l7tech.gateway.common.audit.SystemMessages
 *  com.l7tech.gateway.common.service.PublishedService
 *  com.l7tech.gateway.common.uddi.UDDIProxiedServiceInfo
 *  com.l7tech.gateway.common.uddi.UDDIProxiedServiceInfo$PublishType
 *  com.l7tech.gateway.common.uddi.UDDIPublishStatus
 *  com.l7tech.gateway.common.uddi.UDDIPublishStatus$PublishStatus
 *  com.l7tech.gateway.common.uddi.UDDIRegistry
 *  com.l7tech.gateway.common.uddi.UDDIServiceControl
 *  com.l7tech.objectmodel.Goid
 *  com.l7tech.objectmodel.ObjectModelException
 *  com.l7tech.uddi.BusinessServicePublisher
 *  com.l7tech.uddi.UDDIException
 *  com.l7tech.uddi.UDDIInvalidKeyException
 *  com.l7tech.util.ExceptionUtils
 *  com.l7tech.util.ResourceUtils
 */
package com.l7tech.server.uddi;

import com.l7tech.gateway.common.audit.AuditDetailMessage;
import com.l7tech.gateway.common.audit.SystemMessages;
import com.l7tech.gateway.common.service.PublishedService;
import com.l7tech.gateway.common.uddi.UDDIProxiedServiceInfo;
import com.l7tech.gateway.common.uddi.UDDIPublishStatus;
import com.l7tech.gateway.common.uddi.UDDIRegistry;
import com.l7tech.gateway.common.uddi.UDDIServiceControl;
import com.l7tech.objectmodel.Goid;
import com.l7tech.objectmodel.ObjectModelException;
import com.l7tech.server.uddi.PublishingUDDITaskFactory;
import com.l7tech.server.uddi.UDDITaskFactory;
import com.l7tech.uddi.BusinessServicePublisher;
import com.l7tech.uddi.UDDIException;
import com.l7tech.uddi.UDDIInvalidKeyException;
import com.l7tech.util.ExceptionUtils;
import com.l7tech.util.ResourceUtils;
import java.io.Closeable;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;

final class x
extends UDDITaskFactory.UDDITask {
    private static final Logger a;
    private final PublishingUDDITaskFactory b;
    private final Goid c;
    private static final String[] d;

    public x(PublishingUDDITaskFactory publishingUDDITaskFactory, Goid goid) {
        this.b = publishingUDDITaskFactory;
        this.c = goid;
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    @Override
    public void apply(UDDITaskFactory.UDDITaskContext uDDITaskContext) throws UDDITaskFactory.UDDITaskException {
        UDDIPublishStatus uDDIPublishStatus = null;
        try {
            UDDIProxiedServiceInfo uDDIProxiedServiceInfo;
            block26: {
                uDDIProxiedServiceInfo = (UDDIProxiedServiceInfo)this.b.b.findByPrimaryKey(this.c);
                if (uDDIProxiedServiceInfo == null) {
                    return;
                }
                uDDIPublishStatus = this.b.c.findByProxiedSerivceInfoGoid(uDDIProxiedServiceInfo.getGoid());
                if (uDDIPublishStatus == null) {
                    return;
                }
                try {
                    if (uDDIPublishStatus.getPublishStatus() == UDDIPublishStatus.PublishStatus.DELETE || uDDIPublishStatus.getPublishStatus() == UDDIPublishStatus.PublishStatus.DELETE_FAILED) break block26;
                }
                catch (UDDIException uDDIException) {
                    throw x.a(uDDIException);
                }
                String[] stringArray = d;
                a.log(Level.FINER, stringArray[2]);
                return;
            }
            try {
                if (uDDIProxiedServiceInfo.getPublishType() != UDDIProxiedServiceInfo.PublishType.ENDPOINT) {
                    throw new IllegalStateException(d[0]);
                }
            }
            catch (UDDIException uDDIException) {
                throw x.a(uDDIException);
            }
            UDDIServiceControl uDDIServiceControl = this.b.f.findByPublishedServiceGoid(uDDIProxiedServiceInfo.getPublishedServiceGoid());
            try {
                if (uDDIServiceControl == null) {
                    throw new IllegalStateException(d[6] + String.valueOf(uDDIProxiedServiceInfo.getPublishedServiceGoid()) + ")");
                }
            }
            catch (UDDIException uDDIException) {
                throw x.a(uDDIException);
            }
            UDDIRegistry uDDIRegistry = (UDDIRegistry)this.b.a.findByPrimaryKey(uDDIProxiedServiceInfo.getUddiRegistryGoid());
            try {
                if (uDDIRegistry == null) {
                    throw new IllegalStateException(d[7] + String.valueOf(uDDIProxiedServiceInfo.getUddiRegistryGoid()) + d[12]);
                }
            }
            catch (UDDIException uDDIException) {
                throw x.a(uDDIException);
            }
            if (!uDDIRegistry.isEnabled()) {
                String[] stringArray = d;
                a.log(Level.WARNING, stringArray[5] + String.valueOf(uDDIProxiedServiceInfo.getUddiRegistryGoid()) + stringArray[9]);
                return;
            }
            String string = String.valueOf(uDDIRegistry.getGoid());
            String string2 = String.valueOf(uDDIProxiedServiceInfo.getPublishedServiceGoid());
            String string3 = uDDIServiceControl.getUddiServiceKey();
            String[] stringArray = d;
            a.log(Level.INFO, stringArray[8] + string3 + stringArray[11] + string2 + stringArray[3] + string + ")");
            PublishedService publishedService = this.b.d.getCachedService(uDDIProxiedServiceInfo.getPublishedServiceGoid());
            BusinessServicePublisher businessServicePublisher = null;
            try {
                businessServicePublisher = new BusinessServicePublisher(publishedService.getGoid().toHexString(), this.b.e.newUDDIClientConfig(uDDIRegistry));
                businessServicePublisher.deleteGatewayBindingTemplates(uDDIServiceControl.getUddiServiceKey(), (Set)uDDIProxiedServiceInfo.getProperty(UDDIProxiedServiceInfo.ALL_ENDPOINT_PAIRS_KEY), (Set)uDDIProxiedServiceInfo.getProperty(UDDIProxiedServiceInfo.ALL_BINDING_TEMPLATE_KEYS));
                a.log(Level.INFO, stringArray[13]);
            }
            catch (UDDIException uDDIException) {
                block28: {
                    try {
                        block27: {
                            try {
                                if (!(uDDIException instanceof UDDIInvalidKeyException)) break block27;
                                a.log(Level.INFO, d[4] + uDDIServiceControl.getUddiServiceKey() + d[1]);
                                break block28;
                            }
                            catch (UDDIException uDDIException2) {
                                throw x.a(uDDIException2);
                            }
                        }
                        uDDITaskContext.logAndAudit((AuditDetailMessage)SystemMessages.UDDI_PUBLISH_REMOVE_ENDPOINT_BINDING, ExceptionUtils.getDebugException((Throwable)uDDIException), uDDIServiceControl.getUddiServiceKey(), ExceptionUtils.getMessage((Throwable)uDDIException));
                        PublishingUDDITaskFactory.b(uDDIPublishStatus.getGoid(), uDDITaskContext, this.b.c);
                    }
                    catch (Throwable throwable) {
                        ResourceUtils.closeQuietly(businessServicePublisher);
                        throw throwable;
                    }
                    ResourceUtils.closeQuietly((Closeable)businessServicePublisher);
                    return;
                }
                ResourceUtils.closeQuietly((Closeable)businessServicePublisher);
            }
            ResourceUtils.closeQuietly((Closeable)businessServicePublisher);
            this.b.b.delete(uDDIProxiedServiceInfo.getGoid());
        }
        catch (ObjectModelException objectModelException) {
            uDDITaskContext.logAndAudit((AuditDetailMessage)SystemMessages.UDDI_PUBLISH_REMOVE_ENDPOINT_FAILED, objectModelException, d[10]);
            throw new UDDITaskFactory.UDDITaskException(ExceptionUtils.getMessage((Throwable)objectModelException), objectModelException);
        }
        catch (RuntimeException runtimeException) {
            try {
                uDDITaskContext.logAndAudit((AuditDetailMessage)SystemMessages.UDDI_PUBLISH_UNEXPECTED_ERROR, runtimeException, ExceptionUtils.getMessage((Throwable)runtimeException));
                if (uDDIPublishStatus != null) {
                    PublishingUDDITaskFactory.a(uDDITaskContext, runtimeException, uDDIPublishStatus.getGoid(), this.b, false);
                }
            }
            catch (UDDIException uDDIException) {
                throw x.a(uDDIException);
            }
        }
    }

    /*
     * Unable to fully structure code
     */
    static {
        block10: {
            block9: {
                var5 = new String[14];
                var3_1 = 0;
                var2_2 = "UMl\u007f/L\u000ex`MR,[\u0013v`KS6P\u0007o)AE_J\te)_D\u0010P\u0006 }QF\u001a\u0010AM|[B_\\\u0004 fN\u0016\u000bG\u0011e)mx;n.IG|$)'\bu\u001eP\u000fo}\bR\u001aR\u0004tl\bP\rQ\f \\lr6\u001e3enAE\u000bL\u0018.@UMl\u007f/L\u000ex`MR,[\u0013v`KS6P\u0007o)AE_P\u000et)AX_J\te)LS\u0013[\u0015e)[B\u001eJ\u0004.)fY\u000bV\bnn\bB\u0010\u001e\u0005o\u0018))AX_k%D@\bd\u001aY\bs}ZO_W\u0005 *\u0000AB|[_\u0011[\u0012sZMD\tW\u0002e)\\^\u001eJAegLF\u0010W\u000ftz\bA\u001aL\u0004 y]T\u0013W\u0012hlL\u0016\u000bQAwh[\u0016\u0011Q\u0015 oGC\u0011ZA#!$ChFX\u0010JAuyLW\u000b[AUMl\u007fQ\u001e4DMa\u0016-[\u0006iz\\D\u0006\u001eB(;Nf\bc;z(SlZ@\u0016]\u0004CfFB\rQ\r oGC\u0011ZAffZ\u0016/K\u0003l`[^\u001aZ2e{^_\u001c[Aw`\\^_W\u0005 *\u0000\u000fUMl\u007f_l\u0004g`[B\rGA#BDlDS\u000bW\u000fg)OW\u000b[\u0016ap\bS\u0011Z\u0011o`FB\f\u001e\u0007rfE\u0016=K\u0012igME\fm\u0004r\u007fAU\u001a\u001e\u0016i}@\u0016\f[\u0013v`KS4[\u0018 *\u0000\r))AE_Z\bshJZ\u001aZ,Dh\\W\u001d_\u0012e)MD\rQ\u0013 ~@S\u0011\u001e\u0005eeMB\u0016P\u0006 yZY\u0007GAegLF\u0010W\u000ft'\u001a))NY\r\u001e\u0011ukD_\fV\u0004d)[S\rH\bcl\b\u0015W";
                var4_3 = "UMl\u007f/L\u000ex`MR,[\u0013v`KS6P\u0007o)AE_J\te)_D\u0010P\u0006 }QF\u001a\u0010AM|[B_\\\u0004 fN\u0016\u000bG\u0011e)mx;n.IG|$)'\bu\u001eP\u000fo}\bR\u001aR\u0004tl\bP\rQ\f \\lr6\u001e3enAE\u000bL\u0018.@UMl\u007f/L\u000ex`MR,[\u0013v`KS6P\u0007o)AE_P\u000et)AX_J\te)LS\u0013[\u0015e)[B\u001eJ\u0004.)fY\u000bV\bnn\bB\u0010\u001e\u0005o\u0018))AX_k%D@\bd\u001aY\bs}ZO_W\u0005 *\u0000AB|[_\u0011[\u0012sZMD\tW\u0002e)\\^\u001eJAegLF\u0010W\u000ftz\bA\u001aL\u0004 y]T\u0013W\u0012hlL\u0016\u000bQAwh[\u0016\u0011Q\u0015 oGC\u0011ZA#!$ChFX\u0010JAuyLW\u000b[AUMl\u007fQ\u001e4DMa\u0016-[\u0006iz\\D\u0006\u001eB(;Nf\bc;z(SlZ@\u0016]\u0004CfFB\rQ\r oGC\u0011ZAffZ\u0016/K\u0003l`[^\u001aZ2e{^_\u001c[Aw`\\^_W\u0005 *\u0000\u000fUMl\u007f_l\u0004g`[B\rGA#BDlDS\u000bW\u000fg)OW\u000b[\u0016ap\bS\u0011Z\u0011o`FB\f\u001e\u0007rfE\u0016=K\u0012igME\fm\u0004r\u007fAU\u001a\u001e\u0016i}@\u0016\f[\u0013v`KS4[\u0018 *\u0000\r))AE_Z\bshJZ\u001aZ,Dh\\W\u001d_\u0012e)MD\rQ\u0013 ~@S\u0011\u001e\u0005eeMB\u0016P\u0006 yZY\u0007GAegLF\u0010W\u000ft'\u001a))NY\r\u001e\u0011ukD_\fV\u0004d)[S\rH\bcl\b\u0015W".length();
                var1_4 = 66;
                var0_5 = -1;
lbl7:
                // 2 sources

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

                while (true) {
                    var5[var3_1++] = x.a(v0, x.a(v2));
                    if ((var0_5 += var1_4) < var4_3) {
                        var1_4 = var2_2.charAt(var0_5);
                        ** continue;
                    }
                    var2_2 = "BL#<n{b\n\u0019#74\u001e \u0002)#u2j\u0011\u001fm o8g\u0000\u001f>5o7h\u001cL)6v>p\u0000\b";
                    var4_3 = "BL#<n{b\n\u0019#74\u001e \u0002)#u2j\u0011\u001fm o8g\u0000\u001f>5o7h\u001cL)6v>p\u0000\b".length();
                    var1_4 = 12;
                    var0_5 = -1;
lbl22:
                    // 2 sources

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

    private static UDDIException a(UDDIException uDDIException) {
        return uDDIException;
    }

    private static char[] a(String string) {
        char[] cArray = string.toCharArray();
        if (cArray.length < 2) {
            cArray = cArray;
            cArray[0] = (char)(cArray[0] ^ 0x3F);
        }
        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 -> 94;
                    case 1 -> 87;
                    case 2 -> 118;
                    case 3 -> 104;
                    case 4 -> 33;
                    case 5 -> 96;
                    default -> 63;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

