/*
 * 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.objectmodel.Goid
 *  com.l7tech.objectmodel.ObjectModelException
 *  com.l7tech.objectmodel.PersistentEntity
 *  com.l7tech.uddi.UDDIClient
 *  com.l7tech.uddi.UDDIException
 *  com.l7tech.uddi.UDDIInvalidKeyException
 *  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.uddi.UDDIRegistry;
import com.l7tech.objectmodel.Goid;
import com.l7tech.objectmodel.ObjectModelException;
import com.l7tech.objectmodel.PersistentEntity;
import com.l7tech.server.uddi.MetricsUDDITaskFactory;
import com.l7tech.server.uddi.UDDIBusinessServiceStatus;
import com.l7tech.server.uddi.UDDITaskFactory;
import com.l7tech.server.uddi.UDDITemplate;
import com.l7tech.uddi.UDDIClient;
import com.l7tech.uddi.UDDIException;
import com.l7tech.uddi.UDDIInvalidKeyException;
import com.l7tech.util.ExceptionUtils;
import com.l7tech.util.ResourceUtils;
import java.io.Closeable;
import java.util.Collection;
import java.util.logging.Logger;

final class u
extends UDDITaskFactory.UDDITask {
    private static final Logger a;
    private final MetricsUDDITaskFactory b;
    private final Goid c;
    private static final String[] d;

    u(MetricsUDDITaskFactory metricsUDDITaskFactory, Goid goid) {
        this.b = metricsUDDITaskFactory;
        this.c = goid;
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    @Override
    public void apply(UDDITaskFactory.UDDITaskContext uDDITaskContext) {
        block18: {
            String[] stringArray = d;
            a.fine(stringArray[0] + String.valueOf(this.c) + ")");
            try {
                block17: {
                    String string;
                    UDDIRegistry uDDIRegistry = (UDDIRegistry)this.b.a.findByPrimaryKey(this.c);
                    try {
                        if (uDDIRegistry == null || !uDDIRegistry.isEnabled()) break block17;
                    }
                    catch (UDDIInvalidKeyException uDDIInvalidKeyException) {
                        throw u.a(uDDIInvalidKeyException);
                    }
                    UDDITemplate uDDITemplate = this.b.c.getUDDITemplate(uDDIRegistry.getUddiRegistryType());
                    try {
                        if (uDDITemplate == null) {
                            throw new UDDIException(d[1] + uDDIRegistry.getUddiRegistryType() + d[5]);
                        }
                    }
                    catch (UDDIInvalidKeyException uDDIInvalidKeyException) {
                        throw u.a(uDDIInvalidKeyException);
                    }
                    try {
                        String string2 = string = uDDITemplate.getServiceMetricsKeyedReference() == null ? null : uDDITemplate.getServiceMetricsKeyedReference().getKey();
                    }
                    catch (UDDIInvalidKeyException uDDIInvalidKeyException) {
                        throw u.a(uDDIInvalidKeyException);
                    }
                    if (string == null) break block18;
                    Collection<UDDIBusinessServiceStatus> collection = this.b.d.findByRegistryAndMetricsStatus(this.c, UDDIBusinessServiceStatus.Status.DELETE);
                    UDDIClient uDDIClient = null;
                    try {
                        uDDIClient = this.b.b.newUDDIClient(uDDIRegistry);
                        for (UDDIBusinessServiceStatus uDDIBusinessServiceStatus : collection) {
                            String string3 = uDDIBusinessServiceStatus.getUddiServiceKey();
                            String string4 = uDDIBusinessServiceStatus.getUddiMetricsTModelKey();
                            try {
                                uDDIClient.removeKeyedReference(string3, string, null, string4);
                            }
                            catch (UDDIInvalidKeyException uDDIInvalidKeyException) {
                                stringArray = d;
                                a.fine(stringArray[3] + string3 + stringArray[8]);
                            }
                            try {
                                uDDIClient.deleteTModel(string4);
                            }
                            catch (UDDIInvalidKeyException uDDIInvalidKeyException) {
                                stringArray = d;
                                a.fine(stringArray[2] + string4 + stringArray[8]);
                            }
                            uDDIBusinessServiceStatus.setUddiMetricsReferenceStatus(UDDIBusinessServiceStatus.Status.NONE);
                            uDDIBusinessServiceStatus.setUddiMetricsTModelKey(null);
                            this.b.d.update((PersistentEntity)uDDIBusinessServiceStatus);
                        }
                    }
                    catch (Throwable throwable) {
                        ResourceUtils.closeQuietly(uDDIClient);
                        throw throwable;
                    }
                    ResourceUtils.closeQuietly((Closeable)uDDIClient);
                    break block18;
                }
                stringArray = d;
                a.fine(stringArray[7] + String.valueOf(this.c) + stringArray[6]);
            }
            catch (ObjectModelException objectModelException) {
                uDDITaskContext.logAndAudit((AuditDetailMessage)SystemMessages.UDDI_METRICS_CLEANUP_FAILED, objectModelException, d[4] + String.valueOf(this.c) + ".");
            }
            catch (UDDIException uDDIException) {
                uDDITaskContext.logAndAudit((AuditDetailMessage)SystemMessages.UDDI_METRICS_CLEANUP_FAILED, ExceptionUtils.getDebugException((Throwable)uDDIException), ExceptionUtils.getMessage((Throwable)uDDIException));
            }
        }
    }

    /*
     * Unable to fully structure code
     */
    static {
        block10: {
            block9: {
                var5 = new String[9];
                var3_1 = 0;
                var2_2 = "&;[];q\u0015E:[H'm\u0006\u0016wWRuQ!!\u001e\u001eZ:vE\u00172YU&p\u0017\u001cw\u0016\u001f+12SL9e\u0011\u0000wPS!$\u0003\n\"PXub\n\u0017wkx\u0011ME\u00172YU&p\u0017\u001cwJE%aEB%(2JN<g\u0016E\u0003sS1a\tE9QHub\n\u00109Z\u001c3k\u0017E3[P0p\u0000Ep362LJ<g\u0000E9QHub\n\u00109Z\u001c\"l\u0000\u000bwLY8k\u0013\f9Y\u001c8a\u0011\u0017>]Ouv\u0000\u00032LY;g\u0000Ep3!6J]7e\u0016\u0000w[N'k\u0017E VY;$\u0017\u0000:QJ<j\u0002E:[H'm\u0006\u0016wXS'$\u0017\u00000WO!v\u001cEt\u0002By%L{\u001eN0c\f\u0016#LEuj\n\u0011wXS j\u0001E8L\u001c<wE\u0001>M]7h\u0000\u0001y";
                var4_3 = "&;[];q\u0015E:[H'm\u0006\u0016wWRuQ!!\u001e\u001eZ:vE\u00172YU&p\u0017\u001cw\u0016\u001f+12SL9e\u0011\u0000wPS!$\u0003\n\"PXub\n\u0017wkx\u0011ME\u00172YU&p\u0017\u001cwJE%aEB%(2JN<g\u0016E\u0003sS1a\tE9QHub\n\u00109Z\u001c3k\u0017E3[P0p\u0000Ep362LJ<g\u0000E9QHub\n\u00109Z\u001c\"l\u0000\u000bwLY8k\u0013\f9Y\u001c8a\u0011\u0017>]Ouv\u0000\u00032LY;g\u0000Ep3!6J]7e\u0016\u0000w[N'k\u0017E VY;$\u0017\u0000:QJ<j\u0002E:[H'm\u0006\u0016wXS'$\u0017\u00000WO!v\u001cEt\u0002By%L{\u001eN0c\f\u0016#LEuj\n\u0011wXS j\u0001E8L\u001c<wE\u0001>M]7h\u0000\u0001y".length();
                var1_4 = 39;
                var0_5 = -1;
lbl7:
                // 2 sources

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

                while (true) {
                    var5[var3_1++] = u.a(v0, u.a(v2));
                    if ((var0_5 += var1_4) < var4_3) {
                        var1_4 = var2_2.charAt(var0_5);
                        ** continue;
                    }
                    var2_2 = "lp\u0010\u0013g-KB7\u0013\u0019a6LFd^\u0019c!KQ7\u0018\u0013gdpaS7\\g!BLd\n\u000eld\r\u0006\u0002\u00029";
                    var4_3 = "lp\u0010\u0013g-KB7\u0013\u0019a6LFd^\u0019c!KQ7\u0018\u0013gdpaS7\\g!BLd\n\u000eld\r\u0006\u0002\u00029".length();
                    var1_4 = 43;
                    var0_5 = -1;
lbl22:
                    // 2 sources

                    while (true) {
                        v0 = 36;
                        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++] = u.a(v0, u.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;
            }
        }
        u.d = var5;
        u.a = Logger.getLogger(u.class.getName());
    }

    private static UDDIInvalidKeyException a(UDDIInvalidKeyException uDDIInvalidKeyException) {
        return uDDIInvalidKeyException;
    }

    private static char[] a(String string) {
        char[] cArray = string.toCharArray();
        if (cArray.length < 2) {
            cArray = cArray;
            cArray[0] = (char)(cArray[0] ^ '\u0001');
        }
        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 -> 1;
                    case 1 -> 51;
                    case 2 -> 90;
                    case 3 -> 88;
                    case 4 -> 49;
                    case 5 -> 96;
                    default -> 1;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

