/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.gateway.common.service.ServiceTemplate
 *  com.l7tech.objectmodel.Goid
 */
package com.l7tech.server.service;

import com.l7tech.gateway.common.service.ServiceTemplate;
import com.l7tech.objectmodel.Goid;
import com.l7tech.server.service.ServiceTemplateBootstrapService;
import java.io.File;
import java.util.concurrent.Callable;

class af
implements Callable<Boolean> {
    final ServiceTemplateBootstrapService this$0;
    private static final String a = af.a(14, af.a("Q(M$\u0005O\u0011\u0013iHj\u0002O\u0011\u000baG/QC\u0010]xV%\u0007C\u0010\u0014gJ/\u0015\u0005\u0013\bjH#\u0002B\u0006\u0019(W?\u0012I\u0006\u000e{B?\u001dF\u001aS"));

    af(ServiceTemplateBootstrapService serviceTemplateBootstrapService) {
        this.this$0 = serviceTemplateBootstrapService;
    }

    @Override
    public Boolean call() throws Exception {
        block16: {
            try {
                if (!this.this$0.j.isMaster() || !ServiceTemplateBootstrapService.c.get()) break block16;
            }
            catch (Exception exception) {
                throw af.a(exception);
            }
            File file = new File(ServiceTemplateBootstrapService.d);
            try {
                if (!file.exists()) {
                    return false;
                }
            }
            catch (Exception exception) {
                throw af.a(exception);
            }
            try {
                if (!file.isDirectory()) {
                    return false;
                }
            }
            catch (Exception exception) {
                throw af.a(exception);
            }
            File[] fileArray = file.listFiles();
            try {
                if (fileArray == null) {
                    return false;
                }
            }
            catch (Exception exception) {
                throw af.a(exception);
            }
            for (File file2 : fileArray) {
                ServiceTemplate serviceTemplate = this.this$0.i.findByAutoProvisionName(file2.getName());
                try {
                    if (serviceTemplate == null || ServiceTemplateBootstrapService.b.containsKey(serviceTemplate.getName())) continue;
                }
                catch (Exception exception) {
                    throw af.a(exception);
                }
                Goid goid = this.this$0.a(serviceTemplate);
                try {
                    if (goid == null) continue;
                    ServiceTemplateBootstrapService.b.put(serviceTemplate.getName(), goid);
                    ServiceTemplateBootstrapService.a.info(serviceTemplate.getName() + a);
                }
                catch (Exception exception) {
                    throw af.a(exception);
                }
            }
        }
        return false;
    }

    private static Exception a(Exception exception) {
        return exception;
    }

    private static char[] a(String string) {
        char[] cArray = string.toCharArray();
        if (cArray.length < 2) {
            cArray = cArray;
            cArray[0] = (char)(cArray[0] ^ 0x6D);
        }
        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 -> 115;
                    case 1 -> 6;
                    case 2 -> 42;
                    case 3 -> 68;
                    case 4 -> 127;
                    case 5 -> 36;
                    default -> 109;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

