/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.identity.User
 *  com.l7tech.identity.UserBean
 *  com.l7tech.util.ExceptionUtils
 */
package com.l7tech.server.service;

import com.l7tech.identity.User;
import com.l7tech.identity.UserBean;
import com.l7tech.server.service.MigrationBundleBootstrapService;
import com.l7tech.util.ExceptionUtils;
import java.io.File;
import java.io.IOException;
import java.nio.file.FileVisitOption;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.stream.Collectors;
import java.util.stream.Stream;

class g
implements Callable<Boolean> {
    final UserBean val$adminUser;
    final MigrationBundleBootstrapService this$0;
    private static final String a = g.a(108, g.a("MWF=\u00196M\u007fY\u000f7\u0015<\t+BG4\\0\u0018eRC4\u000fhM"));

    /*
     * Ignored method signature, as it can't be verified against descriptor
     */
    g(MigrationBundleBootstrapService migrationBundleBootstrapService, UserBean userBean) {
        this.this$0 = migrationBundleBootstrapService;
        this.val$adminUser = userBean;
    }

    @Override
    public Boolean call() throws Exception {
        List list;
        File file = new File(this.this$0.b);
        try {
            if (!file.exists()) {
                return false;
            }
        }
        catch (Throwable throwable) {
            throw g.a(throwable);
        }
        try {
            if (!file.isDirectory()) {
                return false;
            }
        }
        catch (Throwable throwable) {
            throw g.a(throwable);
        }
        try {
            Stream<Path> stream = Files.find(file.toPath(), Integer.MAX_VALUE, this::lambda$call$0, new FileVisitOption[0]);
            try {
                list = stream.collect(Collectors.toList());
            }
            catch (Throwable throwable) {
                if (stream != null) {
                    try {
                        stream.close();
                    }
                    catch (Throwable throwable2) {
                        throwable.addSuppressed(throwable2);
                    }
                }
                throw throwable;
            }
            try {
                if (stream != null) {
                    stream.close();
                }
            }
            catch (Throwable throwable) {
                throw g.a(throwable);
            }
        }
        catch (IOException iOException) {
            throw new MigrationBundleBootstrapService.BundleInstallFailedException(a + ExceptionUtils.getMessage((Throwable)iOException), iOException);
        }
        try {
            if (list.isEmpty()) {
                return false;
            }
        }
        catch (Throwable throwable) {
            throw g.a(throwable);
        }
        list.sort(Path::compareTo);
        for (Path path : list) {
            File file2 = path.toFile();
            try {
                if (!file2.isFile()) continue;
                this.this$0.a(file2, (User)this.val$adminUser);
            }
            catch (Throwable throwable) {
                throw g.a(throwable);
            }
        }
        return true;
    }

    private boolean lambda$call$0(Path path, BasicFileAttributes basicFileAttributes) {
        return basicFileAttributes.isRegularFile() && this.this$0.a(path.toFile());
    }

    private static Throwable a(Throwable throwable) {
        return throwable;
    }

    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 -> 103;
                    case 1 -> 90;
                    case 2 -> 67;
                    case 3 -> 61;
                    case 4 -> 16;
                    case 5 -> 62;
                    default -> 1;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

