/*
 * 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.uddi.UDDIUnpublishException
 *  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.uddi.UDDIUnpublishException;
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 y
extends UDDITaskFactory.UDDITask {
    private static final Logger a;
    private final PublishingUDDITaskFactory b;
    private final Goid c;
    private static final String[] d;

    private y(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;
            block28: {
                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 block28;
                }
                catch (UDDIException uDDIException) {
                    throw y.a(uDDIException);
                }
                String[] stringArray = d;
                a.log(Level.FINER, stringArray[1]);
                return;
            }
            try {
                if (uDDIProxiedServiceInfo.getPublishType() != UDDIProxiedServiceInfo.PublishType.ENDPOINT) {
                    throw new IllegalStateException(d[0]);
                }
            }
            catch (UDDIException uDDIException) {
                throw y.a(uDDIException);
            }
            UDDIServiceControl uDDIServiceControl = this.b.f.findByPublishedServiceGoid(uDDIProxiedServiceInfo.getPublishedServiceGoid());
            try {
                if (uDDIServiceControl == null) {
                    throw new IllegalStateException(d[5] + String.valueOf(uDDIProxiedServiceInfo.getPublishedServiceGoid()) + ")");
                }
            }
            catch (UDDIException uDDIException) {
                throw y.a(uDDIException);
            }
            UDDIRegistry uDDIRegistry = (UDDIRegistry)this.b.a.findByPrimaryKey(uDDIProxiedServiceInfo.getUddiRegistryGoid());
            try {
                if (uDDIRegistry == null) {
                    throw new IllegalStateException(d[3] + String.valueOf(uDDIProxiedServiceInfo.getUddiRegistryGoid()) + d[9]);
                }
            }
            catch (UDDIException uDDIException) {
                throw y.a(uDDIException);
            }
            if (!uDDIRegistry.isEnabled()) {
                String[] stringArray = d;
                a.log(Level.WARNING, stringArray[12] + String.valueOf(uDDIProxiedServiceInfo.getUddiRegistryGoid()) + stringArray[13]);
                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[7] + string3 + stringArray[14] + string2 + stringArray[6] + string + ")");
            PublishedService publishedService = this.b.d.getCachedService(uDDIProxiedServiceInfo.getPublishedServiceGoid());
            BusinessServicePublisher businessServicePublisher = null;
            try {
                businessServicePublisher = new BusinessServicePublisher(publishedService.getGoid().toHexString(), this.b.e.newUDDIClientConfig(uDDIRegistry));
                Set set = (Set)uDDIProxiedServiceInfo.getProperty(UDDIProxiedServiceInfo.ALL_BINDING_TEMPLATE_KEYS);
                String string4 = (String)uDDIProxiedServiceInfo.getProperty(UDDIProxiedServiceInfo.FUNCTIONAL_ENDPOINT_KEY);
                businessServicePublisher.deleteGatewayGifBindingTemplates(uDDIServiceControl.getUddiServiceKey(), (String)set.iterator().next(), string4);
                a.log(Level.INFO, stringArray[2]);
            }
            catch (UDDIException uDDIException) {
                block30: {
                    try {
                        block31: {
                            block29: {
                                try {
                                    if (!(uDDIException instanceof UDDIInvalidKeyException)) break block29;
                                    a.log(Level.INFO, d[10] + uDDIServiceControl.getUddiServiceKey() + d[8]);
                                    break block30;
                                }
                                catch (UDDIException uDDIException2) {
                                    throw y.a(uDDIException2);
                                }
                            }
                            try {
                                if (!(uDDIException instanceof UDDIUnpublishException)) break block31;
                                a.log(Level.INFO, uDDIException.getMessage() + d[4]);
                                break block30;
                            }
                            catch (UDDIException uDDIException3) {
                                throw y.a(uDDIException3);
                            }
                        }
                        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[11]);
            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 y.a(uDDIException);
            }
        }
    }

    /*
     * Unable to fully structure code
     */
    static {
        block10: {
            block9: {
                var5 = new String[15];
                var3_1 = 0;
                var2_2 = "\u0012Zt4g:;?wU\u0019d-&1wS\u0018~&2(>Y\u000e\u0017<<\">G\u000fX&3gjI\rRft\nkC\t\u0017*1gqV]C1$\">u3s\u0018\u001b\u000ePd@\u0012Zt4g:;?wU\u0019d-&1wS\u0018~&2(>Y\u000e\u0017&;3>Y\u0013\u0017<<\">T\u0018[- \">C\tV<1i>~\u0012C =)y\u0010\tXh0(!\u0000Wv]R&07qY\u0013Ch'2}S\u0018D;22r\\\u0004\u0017,1+{D\u0018S\u000f\u0012Zt4\u0017\u001a1 wC\tE1td\u0019g]Q\u0013Y' gk^\u0019Xh\u0013\u000eX\u0010\rB*8.mXS;\tq\u0010(s\f\u001d\u0014{B\u000b^+1\u0004q^\tE'8gx_\bY,t!qB]g=6+wC\u0015R,\u0007\"lF\u0014T-t0wD\u0015\u0017!0g=\u0018\u0018n>Y\u0013\u0017\u001d\u0010\u0003W\u0010/R/=4jB\u0004\u0017!0g=\u0018E\u0003{\\\u0018C!: >W\u001cC-#&g\u0010:~\u000et\"pT\rX!:3>V\u000fX%t\u0005kC\u0014Y-'4MU\u000fA!7\">G\u0014C t4{B\u000b^+1\f{I]\u0014`$n0\u0010>V&:(j\u0010\u0019R$13{\u0010\u001bE'9gKt9~h\u0006\"yY\u000eC:-i\f`>^\u0012Ch2(k^\u0019\u0019A\u0005kC\u0014Y-'4MU\u000fA!7\">D\u0015V<t\"pT\rX!:3m\u0010\nR:1gnE\u001f[!'/{T]C't0\u007fC]Y' gx_\bY,td60\u0003\u007fD\u001cU)'\">U\u000fE'&giX\u0018Yh0\"rU\t^&3gYy;\u00178&(fI]R&07qY\u0013Cf$\u0004\u007f^\u0013X<t2nT\u001cC-t\u0012Zt4\u0019h\u0001\u0003Zy]e-3.mD\u000fNhwo";
                var4_3 = "\u0012Zt4g:;?wU\u0019d-&1wS\u0018~&2(>Y\u000e\u0017<<\">G\u000fX&3gjI\rRft\nkC\t\u0017*1gqV]C1$\">u3s\u0018\u001b\u000ePd@\u0012Zt4g:;?wU\u0019d-&1wS\u0018~&2(>Y\u000e\u0017&;3>Y\u0013\u0017<<\">T\u0018[- \">C\tV<1i>~\u0012C =)y\u0010\tXh0(!\u0000Wv]R&07qY\u0013Ch'2}S\u0018D;22r\\\u0004\u0017,1+{D\u0018S\u000f\u0012Zt4\u0017\u001a1 wC\tE1td\u0019g]Q\u0013Y' gk^\u0019Xh\u0013\u000eX\u0010\rB*8.mXS;\tq\u0010(s\f\u001d\u0014{B\u000b^+1\u0004q^\tE'8gx_\bY,t!qB]g=6+wC\u0015R,\u0007\"lF\u0014T-t0wD\u0015\u0017!0g=\u0018\u0018n>Y\u0013\u0017\u001d\u0010\u0003W\u0010/R/=4jB\u0004\u0017!0g=\u0018E\u0003{\\\u0018C!: >W\u001cC-#&g\u0010:~\u000et\"pT\rX!:3>V\u000fX%t\u0005kC\u0014Y-'4MU\u000fA!7\">G\u0014C t4{B\u000b^+1\f{I]\u0014`$n0\u0010>V&:(j\u0010\u0019R$13{\u0010\u001bE'9gKt9~h\u0006\"yY\u000eC:-i\f`>^\u0012Ch2(k^\u0019\u0019A\u0005kC\u0014Y-'4MU\u000fA!7\">D\u0015V<t\"pT\rX!:3m\u0010\nR:1gnE\u001f[!'/{T]C't0\u007fC]Y' gx_\bY,td60\u0003\u007fD\u001cU)'\">U\u000fE'&giX\u0018Yh0\"rU\t^&3gYy;\u00178&(fI]R&07qY\u0013Cf$\u0004\u007f^\u0013X<t2nT\u001cC-t\u0012Zt4\u0019h\u0001\u0003Zy]e-3.mD\u000fNhwo".length();
                var1_4 = 66;
                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++] = y.a(v0, y.a(v2));
                    if ((var0_5 += var1_4) < var4_3) {
                        var1_4 = var2_2.charAt(var0_5);
                        ** continue;
                    }
                    var2_2 = "1a\u0006QHsbk \rN\rs\u001a1a\tM\u001a7{m#\u0003K\u001b\u007fn|a\u001cG\u001aab{$O\u0001@";
                    var4_3 = "1a\u0006QHsbk \rN\rs\u001a1a\tM\u001a7{m#\u0003K\u001b\u007fn|a\u001cG\u001aab{$O\u0001@".length();
                    var1_4 = 13;
                    var0_5 = -1;
lbl22:
                    // 2 sources

                    while (true) {
                        v0 = 43;
                        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++] = y.a(v0, y.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;
            }
        }
        y.d = var5;
        y.a = Logger.getLogger(y.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] ^ 0x20);
        }
        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 -> 51;
                    case 1 -> 106;
                    case 2 -> 68;
                    case 3 -> 9;
                    case 4 -> 67;
                    case 5 -> 60;
                    default -> 32;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

