/*
 * 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.UDDIProxiedService
 *  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.UDDIBusinessService
 *  com.l7tech.uddi.UDDIClient
 *  com.l7tech.uddi.UDDIException
 *  com.l7tech.uddi.UDDIRegistrySpecificMetaData
 *  com.l7tech.util.ExceptionUtils
 *  com.l7tech.util.Pair
 *  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.UDDIProxiedService;
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.b;
import com.l7tech.uddi.BusinessServicePublisher;
import com.l7tech.uddi.EndpointPair;
import com.l7tech.uddi.UDDIBusinessService;
import com.l7tech.uddi.UDDIClient;
import com.l7tech.uddi.UDDIException;
import com.l7tech.uddi.UDDIRegistrySpecificMetaData;
import com.l7tech.util.ExceptionUtils;
import com.l7tech.util.Pair;
import com.l7tech.util.ResourceUtils;
import com.l7tech.wsdl.Wsdl;
import java.io.Closeable;
import java.util.HashSet;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.wsdl.WSDLException;

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

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

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     * Loose catch block
     */
    @Override
    public void apply(UDDITaskFactory.UDDITaskContext uDDITaskContext) throws UDDITaskFactory.UDDITaskException {
        block58: {
            UDDIPublishStatus uDDIPublishStatus = null;
            try {
                Pair pair;
                Set set;
                UDDIProxiedServiceInfo uDDIProxiedServiceInfo;
                block59: {
                    UDDIProxiedService uDDIProxiedService2222;
                    Wsdl wsdl;
                    String string;
                    Level level;
                    Logger logger;
                    boolean bl2;
                    UDDIRegistry uDDIRegistry;
                    UDDIServiceControl uDDIServiceControl;
                    block62: {
                        block56: {
                            block57: {
                                block55: {
                                    block54: {
                                        block53: {
                                            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 block53;
                                            }
                                            catch (WSDLException wSDLException) {
                                                throw aa.a(wSDLException);
                                            }
                                            String[] stringArray = d;
                                            a.log(Level.FINER, stringArray[3]);
                                            return;
                                        }
                                        if (uDDIProxiedServiceInfo.getPublishType() == UDDIProxiedServiceInfo.PublishType.PROXY) break block54;
                                        try {
                                            block60: {
                                                if (uDDIProxiedServiceInfo.getPublishType() == UDDIProxiedServiceInfo.PublishType.OVERWRITE) break block54;
                                                break block60;
                                                catch (WSDLException wSDLException) {
                                                    throw aa.a(wSDLException);
                                                }
                                            }
                                            throw new IllegalStateException(d[10]);
                                        }
                                        catch (WSDLException wSDLException) {
                                            throw aa.a(wSDLException);
                                        }
                                    }
                                    uDDIServiceControl = this.b.f.findByPublishedServiceGoid(this.c.getGoid());
                                    if (uDDIServiceControl != null) break block55;
                                    try {
                                        block61: {
                                            if (uDDIProxiedServiceInfo.getPublishType() != UDDIProxiedServiceInfo.PublishType.OVERWRITE) break block55;
                                            break block61;
                                            catch (WSDLException wSDLException) {
                                                throw aa.a(wSDLException);
                                            }
                                        }
                                        throw new IllegalStateException(d[1]);
                                    }
                                    catch (WSDLException wSDLException) {
                                        throw aa.a(wSDLException);
                                    }
                                }
                                uDDIRegistry = (UDDIRegistry)this.b.a.findByPrimaryKey(uDDIProxiedServiceInfo.getUddiRegistryGoid());
                                try {
                                    if (uDDIRegistry == null) {
                                        throw new IllegalStateException(d[15] + String.valueOf(uDDIProxiedServiceInfo.getUddiRegistryGoid()) + d[2]);
                                    }
                                }
                                catch (WSDLException wSDLException) {
                                    throw aa.a(wSDLException);
                                }
                                if (!uDDIRegistry.isEnabled()) {
                                    String[] stringArray = d;
                                    a.log(Level.WARNING, stringArray[17] + String.valueOf(uDDIProxiedServiceInfo.getUddiRegistryGoid()) + stringArray[12]);
                                    return;
                                }
                                try {
                                    if (uDDIProxiedServiceInfo.getPublishType() != UDDIProxiedServiceInfo.PublishType.OVERWRITE) break block56;
                                    if (uDDIServiceControl != null) break block57;
                                }
                                catch (WSDLException wSDLException) {
                                    throw aa.a(wSDLException);
                                }
                                String[] stringArray = new String[1];
                                String[] stringArray2 = d;
                                stringArray[0] = stringArray2[9];
                                uDDITaskContext.logAndAudit((AuditDetailMessage)SystemMessages.UDDI_PUBLISH_SERVICE_FAILED, stringArray);
                                this.b.b.delete(uDDIProxiedServiceInfo.getGoid());
                                return;
                            }
                            try {
                                if (!uDDIServiceControl.isHasBeenOverwritten()) {
                                    throw new IllegalStateException(d[5]);
                                }
                            }
                            catch (WSDLException wSDLException) {
                                throw aa.a(wSDLException);
                            }
                            bl2 = true;
                            break block62;
                        }
                        bl2 = false;
                    }
                    try {
                        logger = a;
                        level = Level.INFO;
                        string = bl2 ? d[4] : "";
                    }
                    catch (WSDLException wSDLException) {
                        throw aa.a(wSDLException);
                    }
                    String string2 = String.valueOf(uDDIRegistry.getGoid());
                    String string3 = String.valueOf(this.c.getGoid());
                    String string4 = string;
                    String[] stringArray = d;
                    logger.log(level, stringArray[6] + string4 + stringArray[8] + string3 + stringArray[16] + string2 + ")");
                    try {
                        wsdl = this.c.parsedWsdl();
                    }
                    catch (WSDLException wSDLException) {
                        stringArray = d;
                        a.log(Level.WARNING, stringArray[14] + this.c.getName() + stringArray[7] + String.valueOf(this.c.getGoid()) + stringArray[13], ExceptionUtils.getDebugException((Throwable)wSDLException));
                        uDDIPublishStatus.setPublishStatus(UDDIPublishStatus.PublishStatus.DELETE);
                        this.b.c.update((PersistentEntity)uDDIPublishStatus);
                        return;
                    }
                    HashSet<String> hashSet = new HashSet<String>();
                    set = uDDIProxiedServiceInfo.getProxiedServices();
                    switch (com.l7tech.server.uddi.b.a[uDDIProxiedServiceInfo.getPublishType().ordinal()]) {
                        case 1: {
                            for (UDDIProxiedService uDDIProxiedService2222 : set) {
                                hashSet.add(uDDIProxiedService2222.getUddiServiceKey());
                            }
                            break;
                        }
                        case 3: {
                            hashSet.add(uDDIServiceControl.getUddiServiceKey());
                        }
                    }
                    UDDIClient uDDIClient = this.b.e.newUDDIClient(uDDIRegistry);
                    uDDIProxiedService2222 = PublishingUDDITaskFactory.a(uDDIRegistry, uDDIServiceControl, uDDIProxiedServiceInfo, this.b, uDDIClient);
                    Set<EndpointPair> set2 = this.b.e.getAllExternalEndpointAndWsdlUrls(this.c.getGoid());
                    BusinessServicePublisher businessServicePublisher = null;
                    try {
                        businessServicePublisher = new BusinessServicePublisher(wsdl, uDDIProxiedServiceInfo.getPublishedServiceGoid().toHexString(), uDDIClient);
                        pair = businessServicePublisher.publishServicesToUDDIRegistry(uDDIProxiedServiceInfo.getUddiBusinessKey(), hashSet, bl2, (UDDIRegistrySpecificMetaData)uDDIProxiedService2222, 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);
                    uDDIProxiedServiceInfo = this.b.b.findByPublishedServiceGoid(this.c.getGoid());
                    if (uDDIProxiedServiceInfo == null) break block58;
                    try {
                        block64: {
                            uDDIProxiedServiceInfo.setProperty(UDDIProxiedServiceInfo.ALL_ENDPOINT_PAIRS_KEY, set2);
                            if (uDDIProxiedServiceInfo.getPublishType() != UDDIProxiedServiceInfo.PublishType.OVERWRITE) break block59;
                            break block64;
                            catch (WSDLException wSDLException) {
                                throw aa.a(wSDLException);
                            }
                        }
                        uDDIProxiedServiceInfo.setProperty(UDDIProxiedServiceInfo.ALL_BINDING_TEMPLATE_KEYS, (Object)businessServicePublisher.getPublishedBindingTemplates());
                    }
                    catch (WSDLException wSDLException) {
                        throw aa.a(wSDLException);
                    }
                }
                if (uDDIProxiedServiceInfo.getPublishType() == UDDIProxiedServiceInfo.PublishType.PROXY) {
                    Object object2222;
                    Set set3 = (Set)pair.left;
                    HashSet<UDDIProxiedService> hashSet = new HashSet<UDDIProxiedService>();
                    for (Object object2222 : set3) {
                        for (UDDIProxiedService uDDIProxiedService : set) {
                            try {
                                if (!uDDIProxiedService.getUddiServiceKey().equals(object2222)) continue;
                                hashSet.add(uDDIProxiedService);
                                a.log(Level.FINE, d[11] + (String)object2222);
                            }
                            catch (WSDLException wSDLException) {
                                throw aa.a(wSDLException);
                            }
                        }
                    }
                    try {
                        if (!hashSet.isEmpty()) {
                            uDDIProxiedServiceInfo.getProxiedServices().removeAll(hashSet);
                            uDDITaskContext.flushSession();
                        }
                    }
                    catch (WSDLException wSDLException) {
                        throw aa.a(wSDLException);
                    }
                    Set set4 = (Set)pair.right;
                    object2222 = set4.iterator();
                    while (object2222.hasNext()) {
                        UDDIProxiedService uDDIProxiedService;
                        UDDIBusinessService uDDIBusinessService = (UDDIBusinessService)object2222.next();
                        uDDIProxiedService = new UDDIProxiedService(uDDIBusinessService.getServiceKey(), uDDIBusinessService.getServiceName(), uDDIBusinessService.getWsdlServiceName(), uDDIBusinessService.getWsdlServiceNamespace());
                        uDDIProxiedService.setUddiProxiedServiceInfo(uDDIProxiedServiceInfo);
                        uDDIProxiedServiceInfo.getProxiedServices().add(uDDIProxiedService);
                    }
                }
                uDDIPublishStatus.setPublishStatus(UDDIPublishStatus.PublishStatus.PUBLISHED);
                this.b.c.update((PersistentEntity)uDDIPublishStatus);
                this.b.b.update((PersistentEntity)uDDIProxiedServiceInfo);
            }
            catch (ObjectModelException objectModelException) {
                uDDITaskContext.logAndAudit((AuditDetailMessage)SystemMessages.UDDI_PUBLISH_SERVICE_FAILED, objectModelException, d[0]);
                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 aa.a(wSDLException);
                }
            }
        }
    }

    /*
     * Unable to fully structure code
     */
    static {
        block10: {
            block9: {
                var5 = new String[18];
                var3_1 = 0;
                var2_2 = "`Em||;\u001cA\u0004|ol5\u001d\u0004Sqxpz\u001fQFutm2\u0006JC9ml5\u0017]\u0004jxl,\u0006GAj3RsL|s>;OWAkkw9\n\u0004Lxn>8\nAJ9rh?\u001dSVpij?\u0001\b\u0004nx>7\u001aWP9u\u007f,\n\u0004E9o{9\u0000V@9rxz\u0006PW9HZ\u001e&\u0004Mw{q(\u0002EPprp\f\r\u0004wrjz\tKQwy0Qq`]TN(\u0000\\M|yM?\u001dRMzxW4\tK\u0004pn>4\u0000P\u0004ps>.\u0007A\u0004ih|6\u0006WL5=n/\rHMjuA<\u000eMH|y>)\u001bEP|3>\u0014\u0000PLpsyz\u001bK\u0004}r\u0018BKk=q,\nVSktj.\nJ\u0004jxl,\u0006GA92wAkkw9\n\u0004Mj=p5\u001b\u0004Koxl-\u001dMPmxpz\u0006J\u0004LYZ\u0013A\u0004gxsp5\u001b\u0004Qiy\u007f.\n\n\u0018tQ{qw)\u0007MJ~=Y;\u001bASxd>\r<`h9\u0002\f\u0007\u001bBKk=N/\rHMju{>OwAkkw9\n\u0004M}==rjcEmxi;\u0016\u0004V|~q(\u000b\u0004K\u007f=i2\u0006GL9HZ\u001e&\u0004flnw4\nWWJxl,\u0006GA9j\u007f)OKR|oi(\u0006PAw=i;\u001c\u0004Jvi><\u0000QJ}3>\u001e\nHAmtp=Oq`]TN(\u0000\\M|yM?\u001dRMzxW4\tKLq`]TN(\u0000\\M|yM?\u001dRMzxW4\tK\u0004pn>.\u0007A\u0004noq4\b\u0004P`m{tOiQji>8\n\u0004K\u007f=j#\u001fA\u0004IOQ\u00026\u0004Kk=Q\f*vsKTJ\u001f,`Auxj3\u0001C\u0004LYZ\u0013?VKat{><AVot}?OBKk=m?\u001dRMzxU?\u0016\u001e\u0004\r\r\u0004pn>>\u0006WE{q{>@\r\n9\\p#OTV|kw5\u001aWH`=n/\rHMju{>OMJ\u007frl7\u000ePMvs>-\u0006HH9\u007f{z\u000bAH|i{z\tVKt=K\u001e+m!qJx\u007fr?OPK9m\u007f(\u001cA\u0004NNZ\u0016OBKk=m?\u001dRMzx>\u0010q`]T>\b\nCMjil#O\u0007\f";
                var4_3 = "`Em||;\u001cA\u0004|ol5\u001d\u0004Sqxpz\u001fQFutm2\u0006JC9ml5\u0017]\u0004jxl,\u0006GAj3RsL|s>;OWAkkw9\n\u0004Lxn>8\nAJ9rh?\u001dSVpij?\u0001\b\u0004nx>7\u001aWP9u\u007f,\n\u0004E9o{9\u0000V@9rxz\u0006PW9HZ\u001e&\u0004Mw{q(\u0002EPprp\f\r\u0004wrjz\tKQwy0Qq`]TN(\u0000\\M|yM?\u001dRMzxW4\tK\u0004pn>4\u0000P\u0004ps>.\u0007A\u0004ih|6\u0006WL5=n/\rHMjuA<\u000eMH|y>)\u001bEP|3>\u0014\u0000PLpsyz\u001bK\u0004}r\u0018BKk=q,\nVSktj.\nJ\u0004jxl,\u0006GA92wAkkw9\n\u0004Mj=p5\u001b\u0004Koxl-\u001dMPmxpz\u0006J\u0004LYZ\u0013A\u0004gxsp5\u001b\u0004Qiy\u007f.\n\n\u0018tQ{qw)\u0007MJ~=Y;\u001bASxd>\r<`h9\u0002\f\u0007\u001bBKk=N/\rHMju{>OwAkkw9\n\u0004M}==rjcEmxi;\u0016\u0004V|~q(\u000b\u0004K\u007f=i2\u0006GL9HZ\u001e&\u0004flnw4\nWWJxl,\u0006GA9j\u007f)OKR|oi(\u0006PAw=i;\u001c\u0004Jvi><\u0000QJ}3>\u001e\nHAmtp=Oq`]TN(\u0000\\M|yM?\u001dRMzxW4\tKLq`]TN(\u0000\\M|yM?\u001dRMzxW4\tK\u0004pn>.\u0007A\u0004noq4\b\u0004P`m{tOiQji>8\n\u0004K\u007f=j#\u001fA\u0004IOQ\u00026\u0004Kk=Q\f*vsKTJ\u001f,`Auxj3\u0001C\u0004LYZ\u0013?VKat{><AVot}?OBKk=m?\u001dRMzxU?\u0016\u001e\u0004\r\r\u0004pn>>\u0006WE{q{>@\r\n9\\p#OTV|kw5\u001aWH`=n/\rHMju{>OMJ\u007frl7\u000ePMvs>-\u0006HH9\u007f{z\u000bAH|i{z\tVKt=K\u001e+m!qJx\u007fr?OPK9m\u007f(\u001cA\u0004NNZ\u0016OBKk=m?\u001dRMzx>\u0010q`]T>\b\nCMjil#O\u0007\f".length();
                var1_4 = 46;
                var0_5 = -1;
lbl7:
                // 2 sources

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

                while (true) {
                    var5[var3_1++] = aa.a(v0, aa.a(v2));
                    if ((var0_5 += var1_4) < var4_3) {
                        var1_4 = var2_2.charAt(var0_5);
                        ** continue;
                    }
                    var2_2 = "gn\u0007\u0018TeA\n\u0007S%\u0011Wl=:\u0001\u000eTYanm[$\r/\u001d\u0019\u001bD%;>\u0017\u0016\u0000U%\u001b\n7>Z\u0010P\n\n:W&Ub'=\u0007\u0005\r\u0010&f";
                    var4_3 = "gn\u0007\u0018TeA\n\u0007S%\u0011Wl=:\u0001\u000eTYanm[$\r/\u001d\u0019\u001bD%;>\u0017\u0016\u0000U%\u001b\n7>Z\u0010P\n\n:W&Ub'=\u0007\u0005\r\u0010&f".length();
                    var1_4 = 24;
                    var0_5 = -1;
lbl22:
                    // 2 sources

                    while (true) {
                        v0 = 113;
                        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++] = aa.a(v0, aa.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;
            }
        }
        aa.d = var5;
        aa.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] ^ 0x74);
        }
        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 -> 63;
                    case 1 -> 63;
                    case 2 -> 2;
                    case 3 -> 6;
                    case 4 -> 5;
                    case 5 -> 65;
                    default -> 116;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

