package com.l7tech.server.service;

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

class af implements Callable<Boolean> {
   final ServiceTemplateBootstrapService this$0;
   private static final String a;

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

   public Boolean call() throws Exception {
      try {
         if (!this.this$0.j.isMaster() || !ServiceTemplateBootstrapService.c.get()) {
            return false;
         }
      } catch (Exception var12) {
         throw a(var12);
      }

      File var1 = new File(ServiceTemplateBootstrapService.d);

      try {
         if (!var1.exists()) {
            return false;
         }
      } catch (Exception var10) {
         throw a(var10);
      }

      try {
         if (!var1.isDirectory()) {
            return false;
         }
      } catch (Exception var14) {
         throw a(var14);
      }

      File[] var2 = var1.listFiles();

      try {
         if (var2 == null) {
            return false;
         }
      } catch (Exception var13) {
         throw a(var13);
      }

      for (File var6 : var2) {
         ServiceTemplate var7 = this.this$0.i.findByAutoProvisionName(var6.getName());

         try {
            if (var7 == null || ServiceTemplateBootstrapService.b.containsKey(var7.getName())) {
               continue;
            }
         } catch (Exception var11) {
            throw a(var11);
         }

         Goid var8 = this.this$0.a(var7);

         try {
            if (var8 != null) {
               ServiceTemplateBootstrapService.b.put(var7.getName(), var8);
               ServiceTemplateBootstrapService.a.info(var7.getName() + a);
            }
         } catch (Exception var9) {
            throw a(var9);
         }
      }

      return false;
   }

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

   static {
      String var10002 = a(
         14,
         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"
         )
      );
      byte var10001 = -1;
      a = var10002;
   }

   private static char[] a(String var0) {
      char[] var10000 = var0.toCharArray();
      if (var10000.length < 2) {
         var10000[0] = (char)(var10000[0] ^ 109);
      }

      return var10000;
   }

   private static String a(int var0, char[] var1) {
      int var10003 = var1.length;
      int var10002 = var0;
      char[] var10001 = var1;
      int var10000 = var10003;

      for (int var2 = 0; var10000 > var2; var2++) {
         var10001[var2] = (char)(var10001[var2] ^ var10002 ^ switch (var2 % 7) {
            case 0 -> 115;
            case 1 -> 6;
            case 2 -> 42;
            case 3 -> 68;
            case 4 -> 127;
            case 5 -> 36;
            default -> 109;
         });
      }

      return new String(var10001).intern();
   }
}
