/*
 * 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.ObjectModelException
 *  com.l7tech.objectmodel.PersistentEntity
 *  com.l7tech.uddi.BusinessServicePublisher
 *  com.l7tech.uddi.EndpointPair
 *  com.l7tech.uddi.UDDIException
 *  com.l7tech.util.ExceptionUtils
 *  com.l7tech.util.ResourceUtils
 *  com.l7tech.wsdl.Wsdl
 *  javax.wsdl.WSDLException
 */
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.ObjectModelException;
import com.l7tech.objectmodel.PersistentEntity;
import com.l7tech.server.uddi.PublishingUDDITaskFactory;
import com.l7tech.server.uddi.UDDITaskFactory;
import com.l7tech.server.uddi.aa;
import com.l7tech.uddi.BusinessServicePublisher;
import com.l7tech.uddi.EndpointPair;
import com.l7tech.uddi.UDDIException;
import com.l7tech.util.ExceptionUtils;
import com.l7tech.util.ResourceUtils;
import com.l7tech.wsdl.Wsdl;
import java.io.Closeable;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.wsdl.WSDLException;

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

    public z(PublishingUDDITaskFactory publishingUDDITaskFactory, PublishedService publishedService) {
        this.b = publishingUDDITaskFactory;
        this.c = publishedService;
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    @Override
    public void apply(UDDITaskFactory.UDDITaskContext uDDITaskContext) throws UDDITaskFactory.UDDITaskException {
        UDDIPublishStatus uDDIPublishStatus = null;
        try {
            Set set;
            Wsdl wsdl;
            UDDIProxiedServiceInfo uDDIProxiedServiceInfo;
            block30: {
                uDDIProxiedServiceInfo = this.b.b.findByPublishedServiceGoid(this.c.getGoid());
                if (uDDIProxiedServiceInfo == null) {
                    return;
                }
                uDDIPublishStatus = this.b.c.findByProxiedSerivceInfoGoid(uDDIProxiedServiceInfo.getGoid());
                if (uDDIPublishStatus == null) {
                    return;
                }
                try {
                    if (uDDIPublishStatus.getPublishStatus() == UDDIPublishStatus.PublishStatus.PUBLISH_FAILED || uDDIPublishStatus.getPublishStatus() == UDDIPublishStatus.PublishStatus.PUBLISH) break block30;
                }
                catch (WSDLException wSDLException) {
                    throw z.a(wSDLException);
                }
                String[] stringArray = d;
                a.log(Level.FINER, stringArray[4]);
                return;
            }
            try {
                if (uDDIProxiedServiceInfo.getPublishType() != UDDIProxiedServiceInfo.PublishType.OVERWRITE) {
                    throw new IllegalStateException(d[6]);
                }
            }
            catch (WSDLException wSDLException) {
                throw z.a(wSDLException);
            }
            UDDIRegistry uDDIRegistry = (UDDIRegistry)this.b.a.findByPrimaryKey(uDDIProxiedServiceInfo.getUddiRegistryGoid());
            try {
                if (uDDIRegistry == null) {
                    throw new IllegalStateException(d[0] + String.valueOf(uDDIProxiedServiceInfo.getUddiRegistryGoid()) + d[1]);
                }
            }
            catch (WSDLException wSDLException) {
                throw z.a(wSDLException);
            }
            if (!uDDIRegistry.isEnabled()) {
                String[] stringArray = d;
                a.log(Level.WARNING, stringArray[11] + String.valueOf(uDDIProxiedServiceInfo.getUddiRegistryGoid()) + stringArray[7]);
                return;
            }
            PublishedService publishedService = this.b.d.getCachedService(uDDIProxiedServiceInfo.getPublishedServiceGoid());
            UDDIServiceControl uDDIServiceControl = this.b.f.findByPublishedServiceGoid(uDDIProxiedServiceInfo.getPublishedServiceGoid());
            try {
                if (uDDIServiceControl == null) {
                    throw new IllegalStateException(d[8] + String.valueOf(uDDIProxiedServiceInfo.getPublishedServiceGoid()) + ")");
                }
            }
            catch (WSDLException wSDLException) {
                throw z.a(wSDLException);
            }
            if (uDDIServiceControl.isHasBeenOverwritten()) {
                String[] stringArray = d;
                a.log(Level.FINER, stringArray[3]);
                return;
            }
            String[] stringArray = d;
            a.log(Level.INFO, stringArray[12] + String.valueOf(publishedService.getGoid()) + stringArray[10] + String.valueOf(uDDIRegistry.getGoid()) + ")");
            try {
                wsdl = publishedService.parsedWsdl();
            }
            catch (WSDLException wSDLException) {
                stringArray = d;
                a.log(Level.WARNING, stringArray[2] + publishedService.getName() + stringArray[5] + String.valueOf(publishedService.getGoid()) + stringArray[9], ExceptionUtils.getDebugException((Throwable)wSDLException));
                uDDIPublishStatus.setPublishStatus(UDDIPublishStatus.PublishStatus.DELETE);
                this.b.c.update((PersistentEntity)uDDIPublishStatus);
                return;
            }
            Set<EndpointPair> set2 = this.b.e.getAllExternalEndpointAndWsdlUrls(publishedService.getGoid());
            BusinessServicePublisher businessServicePublisher = null;
            try {
                businessServicePublisher = new BusinessServicePublisher(wsdl, uDDIProxiedServiceInfo.getPublishedServiceGoid().toHexString(), this.b.e.newUDDIClientConfig(uDDIRegistry));
                set = businessServicePublisher.overwriteServiceInUDDI(uDDIServiceControl.getUddiServiceKey(), uDDIServiceControl.getUddiBusinessKey(), set2);
            }
            catch (UDDIException uDDIException) {
                try {
                    PublishingUDDITaskFactory.a(uDDIPublishStatus.getGoid(), uDDITaskContext, this.b.c);
                    uDDITaskContext.logAndAudit((AuditDetailMessage)SystemMessages.UDDI_PUBLISH_SERVICE_FAILED, ExceptionUtils.getDebugException((Throwable)uDDIException), ExceptionUtils.getMessage((Throwable)uDDIException));
                }
                catch (Throwable throwable) {
                    ResourceUtils.closeQuietly(businessServicePublisher);
                    throw throwable;
                }
                ResourceUtils.closeQuietly((Closeable)businessServicePublisher);
                return;
            }
            ResourceUtils.closeQuietly((Closeable)businessServicePublisher);
            uDDIPublishStatus.setPublishStatus(UDDIPublishStatus.PublishStatus.PUBLISHED);
            this.b.c.update((PersistentEntity)uDDIPublishStatus);
            uDDIProxiedServiceInfo.setProperty(UDDIProxiedServiceInfo.ALL_ENDPOINT_PAIRS_KEY, set2);
            uDDIProxiedServiceInfo.setProperty(UDDIProxiedServiceInfo.ALL_BINDING_TEMPLATE_KEYS, (Object)set);
            this.b.b.update((PersistentEntity)uDDIProxiedServiceInfo);
            uDDIServiceControl = this.b.f.findByPublishedServiceGoid(uDDIProxiedServiceInfo.getPublishedServiceGoid());
            try {
                if (uDDIServiceControl != null) {
                    uDDIServiceControl.setHasBeenOverwritten(true);
                    uDDIServiceControl.setUnderUddiControl(false);
                    this.b.f.update((PersistentEntity)uDDIServiceControl);
                }
            }
            catch (WSDLException wSDLException) {
                throw z.a(wSDLException);
            }
        }
        catch (ObjectModelException objectModelException) {
            uDDITaskContext.logAndAudit((AuditDetailMessage)SystemMessages.UDDI_PUBLISH_SERVICE_FAILED, objectModelException, d[13]);
            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, true);
                }
            }
            catch (WSDLException wSDLException) {
                throw z.a(wSDLException);
            }
        }
    }

    /*
     * Unable to fully structure code
     */
    static {
        block10: {
            block9: {
                var5 = new String[14];
                var3_1 = 0;
                var2_2 = "4qj\u001cD%\u001f\u0006\\]!\u0016\u000eZB\u001d\fH\u0015@:\u0010W\u001c\u000e@@1J!4[O7\b\u0012Z\u0015Z\u000e%\u0005\u0005\t\u0004\u0015y\u0006 ;Z\u0007Z\\u\u0017\u0012\b\u0017\\M0DY4qj\u001c4\u0005\u0015\u0019\\K17\u0012\b\u0017\\M0-\u0019\u001c\u000e\u0015F4\u0017W\u001b\rGK4\u0000\u000eZ\u000eCK'\u0013\u0005\u0013\u0015AK;D\u0003\u0012\u0004\u0015l \u0017\u001e\u0014\u0004F]\u0006\u0001\u0005\f\bVKu\r\u0019Z4qj\u001cJW4\u000eAF<\n\u0010Z\u0015Z\u000e1\u000bQ4qj\u001c4\u0005\u0015\u0019\\K17\u0012\b\u0017\\M0-\u0019\u001c\u000e\u0015G&D\u0019\u0015\u0015\u0015G;D\u0003\u0012\u0004\u0015^ \u0006\u001b\u0013\u0012]\u0002u\u0014\u0002\u0018\r\\]=;\u0011\u001b\bYK1D\u0004\u000e\u0000AK{D9\u0015\u0015]G;\u0003W\u000e\u000e\u0015J:\u0002I\u0016C4qj\u001c4\u0005\u0015\u0019\\K17\u0012\b\u0017\\M0-\u0019\u001c\u000e\u0015G&D\u0003\u0012\u0004\u0015Y'\u000b\u0019\u001dAAW%\u0001YZ,@]!D\u0015\u001fAZHu\u0010\u000e\n\u0004\u0015a\u0003!%-3|z\u0010\rH\u0015G&D\u0013\u0013\u0012TL9\u0001\u0013;/Z\u000e\u0000 332P\\#\r\u0014\u001f\"Z@!\u0016\u0018\u0016ASA \n\u0013Z\u0007Z\\u4\u0002\u0018\r\\]=\u0001\u0013)\u0004GX<\u0007\u0012Z\u0016\\Z=D\u001e\u001eA\u0016\u0006@H\u001b\u000e\u0014\n\u000eZ\u0011GK#\r\u0018\u000f\u0012YWu\u0014\u0002\u0018\r\\]=\u0001\u0013Z\b[H:\u0016\u001a\u001b\u0015\\A;D\u0000\u0013\rY\u000e7\u0001W\u001e\u0004YK!\u0001W\u001c\u0013ZCu13>(\u0018H\u0015Z:D\">%|\u000e'\u0001\u0010\u0013\u0012A\\,D\u001e\u001eA\u0016\u0006$\"T@;\u000b\u0003Z\u0014EJ4\u0010\u0012Z4qj\u001cJW/%qgu6\u0012\u001d\bFZ'\u001dWYI";
                var4_3 = "4qj\u001cD%\u001f\u0006\\]!\u0016\u000eZB\u001d\fH\u0015@:\u0010W\u001c\u000e@@1J!4[O7\b\u0012Z\u0015Z\u000e%\u0005\u0005\t\u0004\u0015y\u0006 ;Z\u0007Z\\u\u0017\u0012\b\u0017\\M0DY4qj\u001c4\u0005\u0015\u0019\\K17\u0012\b\u0017\\M0-\u0019\u001c\u000e\u0015F4\u0017W\u001b\rGK4\u0000\u000eZ\u000eCK'\u0013\u0005\u0013\u0015AK;D\u0003\u0012\u0004\u0015l \u0017\u001e\u0014\u0004F]\u0006\u0001\u0005\f\bVKu\r\u0019Z4qj\u001cJW4\u000eAF<\n\u0010Z\u0015Z\u000e1\u000bQ4qj\u001c4\u0005\u0015\u0019\\K17\u0012\b\u0017\\M0-\u0019\u001c\u000e\u0015G&D\u0019\u0015\u0015\u0015G;D\u0003\u0012\u0004\u0015^ \u0006\u001b\u0013\u0012]\u0002u\u0014\u0002\u0018\r\\]=;\u0011\u001b\bYK1D\u0004\u000e\u0000AK{D9\u0015\u0015]G;\u0003W\u000e\u000e\u0015J:\u0002I\u0016C4qj\u001c4\u0005\u0015\u0019\\K17\u0012\b\u0017\\M0-\u0019\u001c\u000e\u0015G&D\u0003\u0012\u0004\u0015Y'\u000b\u0019\u001dAAW%\u0001YZ,@]!D\u0015\u001fAZHu\u0010\u000e\n\u0004\u0015a\u0003!%-3|z\u0010\rH\u0015G&D\u0013\u0013\u0012TL9\u0001\u0013;/Z\u000e\u0000 332P\\#\r\u0014\u001f\"Z@!\u0016\u0018\u0016ASA \n\u0013Z\u0007Z\\u4\u0002\u0018\r\\]=\u0001\u0013)\u0004GX<\u0007\u0012Z\u0016\\Z=D\u001e\u001eA\u0016\u0006@H\u001b\u000e\u0014\n\u000eZ\u0011GK#\r\u0018\u000f\u0012YWu\u0014\u0002\u0018\r\\]=\u0001\u0013Z\b[H:\u0016\u001a\u001b\u0015\\A;D\u0000\u0013\rY\u000e7\u0001W\u001e\u0004YK!\u0001W\u001c\u0013ZCu13>(\u0018H\u0015Z:D\">%|\u000e'\u0001\u0010\u0013\u0012A\\,D\u001e\u001eA\u0016\u0006$\"T@;\u000b\u0003Z\u0014EJ4\u0010\u0012Z4qj\u001cJW/%qgu6\u0012\u001d\bFZ'\u001dWYI".length();
                var1_4 = 16;
                var0_5 = -1;
lbl7:
                // 2 sources

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

                while (true) {
                    var5[var3_1++] = z.a(v0, z.a(v2));
                    if ((var0_5 += var1_4) < var4_3) {
                        var1_4 = var2_2.charAt(var0_5);
                        ** continue;
                    }
                    var2_2 = "`\r\u0005i]K][\u0012\u000e|\n{A\\\u0012\u000e~YJgJ\t\u0016rI\\\u0014X\u0012\u0014s\n~U[\u001e\u0017zS\u0019c|?,;LK[B[0nHU]\\\u0013\u0005\u007f\njQ]\r\txO\u0019]K[C3.k\u001a\u0014zHXGJ[\u0005iXVF\u000f\f\b~D\u0019DZ\u0019\frYQ]A\u001c@kXVLV[\u0013~XO]L\u001e\u00135";
                    var4_3 = "`\r\u0005i]K][\u0012\u000e|\n{A\\\u0012\u000e~YJgJ\t\u0016rI\\\u0014X\u0012\u0014s\n~U[\u001e\u0017zS\u0019c|?,;LK[B[0nHU]\\\u0013\u0005\u007f\njQ]\r\txO\u0019]K[C3.k\u001a\u0014zHXGJ[\u0005iXVF\u000f\f\b~D\u0019DZ\u0019\frYQ]A\u001c@kXVLV[\u0013~XO]L\u001e\u00135".length();
                    var1_4 = 74;
                    var0_5 = -1;
lbl22:
                    // 2 sources

                    while (true) {
                        v0 = 119;
                        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++] = z.a(v0, z.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;
            }
        }
        z.d = var5;
        z.a = Logger.getLogger(aa.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] ^ 0x43);
        }
        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 -> 88;
                    case 1 -> 12;
                    case 2 -> 23;
                    case 3 -> 108;
                    case 4 -> 93;
                    case 5 -> 78;
                    default -> 67;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

