/*
 * 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.uddi.UDDIRegistry
 *  com.l7tech.gateway.common.uddi.UDDIServiceControl
 *  com.l7tech.objectmodel.Goid
 *  com.l7tech.objectmodel.ObjectModelException
 *  com.l7tech.objectmodel.PersistentEntity
 *  com.l7tech.uddi.UDDIException
 *  com.l7tech.uddi.UDDISubscriptionResultFactory
 *  com.l7tech.uddi.UDDISubscriptionResults
 *  com.l7tech.uddi.UDDISubscriptionResults$Result
 *  com.l7tech.util.ConfigFactory
 *  com.l7tech.util.ExceptionUtils
 *  com.l7tech.util.TimeUnit
 */
package com.l7tech.server.uddi;

import com.l7tech.gateway.common.audit.AuditDetailMessage;
import com.l7tech.gateway.common.audit.SystemMessages;
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.objectmodel.PersistentEntity;
import com.l7tech.server.uddi.PollUDDIEvent;
import com.l7tech.server.uddi.SubscriptionUDDITaskFactory;
import com.l7tech.server.uddi.UDDIRegistrySubscription;
import com.l7tech.server.uddi.UDDITaskFactory;
import com.l7tech.server.uddi.ad;
import com.l7tech.uddi.UDDIException;
import com.l7tech.uddi.UDDISubscriptionResultFactory;
import com.l7tech.uddi.UDDISubscriptionResults;
import com.l7tech.util.ConfigFactory;
import com.l7tech.util.ExceptionUtils;
import com.l7tech.util.TimeUnit;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Collection;
import java.util.Date;
import java.util.logging.Logger;

final class af
extends ad {
    private static final Logger c;
    private static final long d;
    private final SubscriptionUDDITaskFactory e;
    private final String f;
    private final DateFormat g = new SimpleDateFormat(i[5]);
    private static final String[] i;

    private af(SubscriptionUDDITaskFactory subscriptionUDDITaskFactory, String string) {
        super(c, subscriptionUDDITaskFactory.f);
        this.e = subscriptionUDDITaskFactory;
        this.f = string;
    }

    @Override
    public void apply(UDDITaskFactory.UDDITaskContext uDDITaskContext) {
        block17: {
            String[] stringArray = i;
            c.fine(stringArray[0]);
            String string = null;
            try {
                UDDIRegistry uDDIRegistry;
                block18: {
                    UDDIRegistrySubscription uDDIRegistrySubscription;
                    UDDISubscriptionResults uDDISubscriptionResults;
                    block16: {
                        uDDISubscriptionResults = UDDISubscriptionResultFactory.buildResults((String)this.f);
                        string = uDDISubscriptionResults.getSubscriptionKey();
                        Collection<UDDIRegistrySubscription> collection = this.e.e.findBySubscriptionKey(string);
                        uDDIRegistrySubscription = null;
                        if (collection.size() > 1) {
                            for (UDDISubscriptionResults.Result result : uDDISubscriptionResults.getResults()) {
                                Collection<UDDIServiceControl> collection2 = this.e.f.findByUDDIServiceKey(result.getEntityKey());
                                for (UDDIServiceControl uDDIServiceControl : collection2) {
                                    for (UDDIRegistrySubscription uDDIRegistrySubscription2 : collection) {
                                        if (!Goid.equals((Goid)uDDIRegistrySubscription2.getUddiRegistryGoid(), (Goid)uDDIServiceControl.getUddiRegistryGoid())) continue;
                                        uDDIRegistrySubscription = uDDIRegistrySubscription2;
                                        break block16;
                                    }
                                }
                            }
                        } else if (collection.size() == 1) {
                            uDDIRegistrySubscription = collection.iterator().next();
                        } else {
                            uDDITaskContext.logAndAudit((AuditDetailMessage)SystemMessages.UDDI_SUBSCRIPTION_NOTIFICATION_BADKEY, string);
                        }
                    }
                    if (uDDIRegistrySubscription == null) break block17;
                    uDDIRegistry = (UDDIRegistry)this.e.c.findByPrimaryKey(uDDIRegistrySubscription.getUddiRegistryGoid());
                    try {
                        if (uDDIRegistry == null || !uDDIRegistry.isEnabled()) break block18;
                    }
                    catch (ObjectModelException objectModelException) {
                        throw af.a(objectModelException);
                    }
                    this.a(uDDITaskContext, uDDIRegistrySubscription, uDDISubscriptionResults, true);
                    long l2 = uDDIRegistrySubscription.getSubscriptionNotifiedTime();
                    if (l2 < uDDISubscriptionResults.getStartTime() - d) {
                        String string2 = SubscriptionUDDITaskFactory.a(uDDIRegistry);
                        String string3 = this.a(uDDISubscriptionResults.getStartTime());
                        String string4 = this.a(l2);
                        stringArray = i;
                        c.warning(stringArray[7] + string4 + stringArray[1] + string3 + stringArray[3] + string2 + ".");
                        uDDITaskContext.notifyEvent(new PollUDDIEvent(uDDIRegistrySubscription.getUddiRegistryGoid(), l2, uDDISubscriptionResults.getStartTime()));
                    }
                    uDDIRegistrySubscription.setSubscriptionNotifiedTime(uDDISubscriptionResults.getEndTime());
                    this.e.e.update((PersistentEntity)uDDIRegistrySubscription);
                    break block17;
                }
                try {
                    if (uDDIRegistry != null) {
                        c.info(i[2] + SubscriptionUDDITaskFactory.a(uDDIRegistry) + i[8]);
                    }
                }
                catch (ObjectModelException objectModelException) {
                    throw af.a(objectModelException);
                }
            }
            catch (ObjectModelException objectModelException) {
                uDDITaskContext.logAndAudit((AuditDetailMessage)SystemMessages.UDDI_SUBSCRIPTION_NOTIFICATION_FAILED, objectModelException, i[4] + string + ".");
            }
            catch (UDDIException uDDIException) {
                uDDITaskContext.logAndAudit((AuditDetailMessage)SystemMessages.UDDI_SUBSCRIPTION_NOTIFICATION_FAILED, ExceptionUtils.getDebugException((Throwable)uDDIException), ExceptionUtils.getMessage((Throwable)uDDIException));
            }
        }
    }

    private String a(long l2) {
        return this.g.format(new Date(l2));
    }

    /*
     * Unable to fully structure code
     */
    static {
        block10: {
            block9: {
                var5 = new String[9];
                var3_1 = 0;
                var2_2 = "\u000bHYy\u001e\u0016!2TQ:.!\u0016\u0012\u001aEo\u0019\u00161)SFn\u0012\n<{TYn\u0012\u0003;8[Bs\u0014\u000b|\u0004{NY:\u000e\u000e~rS[\u00177<SEn\t\u001cr\u000e{\\Yh[\u00177<SEn\t\u001cr0\u001f[B{\u0019\u0004!>\u001aSh\t\n {M^\u007f\u0015E\")UU\u007f\b\u0016;5]\u0016i\u000e\u0007!8H_j\u000f\f=5\u001aPu\tE\u0013\"COcV(\u001fv^R:3-h6W\fi\b,8U[4\u0017R&>Y^4\b\u0000 -_D4\u000e\u000162\u0014Eo\u0019\u00161)SFn\u0012\n<\u000fUZ\u007f\t\u0004<8_";
                var4_3 = "\u000bHYy\u001e\u0016!2TQ:.!\u0016\u0012\u001aEo\u0019\u00161)SFn\u0012\n<{TYn\u0012\u0003;8[Bs\u0014\u000b|\u0004{NY:\u000e\u000e~rS[\u00177<SEn\t\u001cr\u000e{\\Yh[\u00177<SEn\t\u001cr0\u001f[B{\u0019\u0004!>\u001aSh\t\n {M^\u007f\u0015E\")UU\u007f\b\u0016;5]\u0016i\u000e\u0007!8H_j\u000f\f=5\u001aPu\tE\u0013\"COcV(\u001fv^R:3-h6W\fi\b,8U[4\u0017R&>Y^4\b\u0000 -_D4\u000e\u000162\u0014Eo\u0019\u00161)SFn\u0012\n<\u000fUZ\u007f\t\u0004<8_".length();
                var1_4 = 42;
                var0_5 = -1;
lbl7:
                // 2 sources

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

                while (true) {
                    var5[var3_1++] = af.b(v0, af.b(v2));
                    if ((var0_5 += var1_4) < var4_3) {
                        var1_4 = var2_2.charAt(var0_5);
                        ** continue;
                    }
                    var2_2 = "5pfJ=\"Q\u000blwJ;4\u0018\bm|V6f\u001f\u0017m|_1%\u0010\fpzW+f\u0017\u0017k5I=4\u0018\u0017}51Xpf\u0019</\u0002\u0019{y\\<jQ\u0011~{V*/\u001f\u001f9fL:5\u0012\npeM1)\u001fXwzM1 \u0018\u001bxaP7(_";
                    var4_3 = "5pfJ=\"Q\u000blwJ;4\u0018\bm|V6f\u001f\u0017m|_1%\u0010\fpzW+f\u0017\u0017k5I=4\u0018\u0017}51Xpf\u0019</\u0002\u0019{y\\<jQ\u0011~{V*/\u001f\u001f9fL:5\u0012\npeM1)\u001fXwzM1 \u0018\u001bxaP7(_".length();
                    var1_4 = 45;
                    var0_5 = -1;
lbl22:
                    // 2 sources

                    while (true) {
                        v0 = 75;
                        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++] = af.b(v0, af.b(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;
            }
        }
        af.i = var5;
        af.c = Logger.getLogger(af.class.getName());
        af.d = ConfigFactory.getLongProperty((String)af.i[6], (long)TimeUnit.SECONDS.toMillis(10L));
    }

    private static ObjectModelException a(ObjectModelException objectModelException) {
        return objectModelException;
    }

    private static char[] b(String string) {
        char[] cArray = string.toCharArray();
        if (cArray.length < 2) {
            cArray = cArray;
            cArray[0] = (char)(cArray[0] ^ 0x3A);
        }
        return cArray;
    }

    /*
     * Handled impossible loop by duplicating code
     * Enabled aggressive block sorting
     */
    private static String b(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 -> 82;
                    case 2 -> 94;
                    case 3 -> 114;
                    case 4 -> 19;
                    case 5 -> 13;
                    default -> 58;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

