/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.gateway.common.uddi.UDDIServiceControl
 *  com.l7tech.objectmodel.FindException
 *  com.l7tech.objectmodel.Goid
 *  com.l7tech.uddi.UDDISubscriptionResults
 *  com.l7tech.uddi.UDDISubscriptionResults$Result
 */
package com.l7tech.server.uddi;

import com.l7tech.gateway.common.uddi.UDDIServiceControl;
import com.l7tech.objectmodel.FindException;
import com.l7tech.objectmodel.Goid;
import com.l7tech.server.uddi.SubscribeUDDIEvent;
import com.l7tech.server.uddi.SubscriptionUDDITaskFactory;
import com.l7tech.server.uddi.UDDIRegistrySubscription;
import com.l7tech.server.uddi.UDDIServiceControlManager;
import com.l7tech.server.uddi.UDDITaskFactory;
import com.l7tech.server.uddi.p;
import com.l7tech.uddi.UDDISubscriptionResults;
import java.util.Collection;
import java.util.logging.Logger;

abstract class ad
extends UDDITaskFactory.UDDITask {
    private final Logger a;
    private final UDDIServiceControlManager b;
    private static final String[] h;

    ad(Logger logger, UDDIServiceControlManager uDDIServiceControlManager) {
        this.a = logger;
        this.b = uDDIServiceControlManager;
    }

    void a(UDDITaskFactory.UDDITaskContext uDDITaskContext, UDDIRegistrySubscription uDDIRegistrySubscription, UDDISubscriptionResults uDDISubscriptionResults, boolean bl2) throws FindException {
        block7: {
            Goid goid = uDDIRegistrySubscription.getUddiRegistryGoid();
            for (UDDISubscriptionResults.Result result : uDDISubscriptionResults.getResults()) {
                Collection<UDDIServiceControl> collection = this.b.findByUDDIRegistryAndServiceKey(goid, result.getEntityKey(), true);
                try {
                    if (collection.isEmpty()) continue;
                    uDDITaskContext.notifyEvent(new p(goid, result.getEntityKey(), result.isDeleted(), false));
                }
                catch (FindException findException) {
                    throw ad.a(findException);
                }
            }
            try {
                try {
                    if (!bl2 || !this.isExpiring(uDDIRegistrySubscription)) break block7;
                }
                catch (FindException findException) {
                    throw ad.a(findException);
                }
                this.a.info(h[0] + String.valueOf(goid) + h[1]);
                uDDITaskContext.notifyEvent(new SubscribeUDDIEvent(goid, SubscribeUDDIEvent.Type.SUBSCRIBE));
            }
            catch (FindException findException) {
                throw ad.a(findException);
            }
        }
    }

    protected boolean isExpiring(UDDIRegistrySubscription uDDIRegistrySubscription) {
        return uDDIRegistrySubscription.getSubscriptionExpiryTime() - System.currentTimeMillis() < SubscriptionUDDITaskFactory.b;
    }

    private static FindException a(FindException findException) {
        return findException;
    }

    /*
     * Enabled aggressive block sorting
     */
    static {
        String[] stringArray = new String[2];
        int n2 = 0;
        String string = "l\u0002K\u000eWL\u001dL\n\u001f\u0014DW\u0007A\u001fV\u0005T\u0015\u0011T\bQ\u0013\u0011S\u001bPMj#u|TP\bX\u000eBA\u0006[M\u0017D\u0002\u000bC";
        int n3 = "l\u0002K\u000eWL\u001dL\n\u001f\u0014DW\u0007A\u001fV\u0005T\u0015\u0011T\bQ\u0013\u0011S\u001bPMj#u|TP\bX\u000eBA\u0006[M\u0017D\u0002\u000bC".length();
        int n4 = 46;
        int n5 = -1;
        while (true) {
            int n6 = ++n5;
            stringArray[n2++] = ad.a(37, ad.a(string.substring(n6, n6 + n4)));
            if ((n5 += n4) >= n3) {
                h = stringArray;
                return;
            }
            n4 = string.charAt(n5);
        }
    }

    private static char[] a(String string) {
        char[] cArray = string.toCharArray();
        if (cArray.length < 2) {
            cArray = cArray;
            cArray[0] = (char)(cArray[0] ^ 0x51);
        }
        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 -> 7;
                    case 1 -> 72;
                    case 2 -> 26;
                    case 3 -> 66;
                    case 4 -> 20;
                    case 5 -> 16;
                    default -> 81;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

