package com.l7tech.external.assertions.gatewaymanagement.server;

import com.l7tech.gateway.api.ManagedObjectFactory;
import com.l7tech.gateway.api.PolicyDetail;
import com.l7tech.gateway.api.PolicyExportResult;
import com.l7tech.gateway.api.PolicyImportResult;
import com.l7tech.gateway.api.PolicyMO;
import com.l7tech.gateway.api.PolicyValidationResult;
import com.l7tech.gateway.api.Resource;
import com.l7tech.gateway.api.ResourceSet;
import com.l7tech.gateway.api.PolicyDetail.PolicyType;
import com.l7tech.gateway.api.impl.PolicyImportContext;
import com.l7tech.gateway.api.impl.PolicyValidationContext;
import com.l7tech.gateway.api.impl.VersionComment;
import com.l7tech.gateway.common.cluster.ClusterProperty;
import com.l7tech.gateway.common.service.ServiceHeader;
import com.l7tech.objectmodel.FindException;
import com.l7tech.objectmodel.Goid;
import com.l7tech.objectmodel.ObjectModelException;
import com.l7tech.objectmodel.SaveException;
import com.l7tech.policy.Policy;
import com.l7tech.policy.PolicyHeader;
import com.l7tech.policy.wsp.WspWriter;
import com.l7tech.server.cluster.ClusterPropertyManager;
import com.l7tech.server.policy.PolicyManager;
import com.l7tech.server.policy.PolicyVersionManager;
import com.l7tech.server.security.rbac.RbacServices;
import com.l7tech.server.security.rbac.SecurityFilter;
import com.l7tech.server.security.rbac.SecurityZoneManager;
import com.l7tech.server.service.ServiceManager;
import com.l7tech.util.Either;
import com.l7tech.util.Eithers;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.jetbrains.annotations.NotNull;
import org.springframework.transaction.PlatformTransactionManager;

@ResourceFactory.ResourceType(type = PolicyMO.class)
public class PolicyResourceFactory extends SecurityZoneableEntityManagerResourceFactory<PolicyMO, Policy, PolicyHeader> {
   private final PolicyManager o;
   private final PolicyHelper p;
   private final FolderResourceFactory q;
   private final PolicyVersionManager r;
   private final ClusterPropertyManager s;
   private final ServiceManager t;
   private final cr u = new cr();
   private static final String[] v;

   public PolicyResourceFactory(
      RbacServices var1,
      SecurityFilter var2,
      PlatformTransactionManager var3,
      PolicyManager var4,
      PolicyHelper var5,
      FolderResourceFactory var6,
      SecurityZoneManager var7,
      PolicyVersionManager var8,
      ClusterPropertyManager var9,
      ServiceManager var10
   ) {
      super(false, true, true, var1, var2, var3, var4, var7);
      this.o = var4;
      this.p = var5;
      this.q = var6;
      this.r = var8;
      this.s = var9;
      this.t = var10;
   }

   @ResourceFactory.ResourceMethod(name = "ImportPolicy", selectors = true, resource = true)
   public PolicyImportResult importPolicy(Map<String, String> var1, PolicyImportContext var2) throws ResourceFactory.ResourceNotFoundException, ResourceFactory.InvalidResourceException {
      return (PolicyImportResult)Eithers.extract2((Either)this.transactional(new bf(this, var1, var2), false));
   }

   @ResourceFactory.ResourceMethod(name = "ExportPolicy", selectors = true)
   public PolicyExportResult exportPolicy(Map<String, String> var1) throws ResourceFactory.ResourceNotFoundException {
      return (PolicyExportResult)Eithers.extract((Either)this.transactional(new bg(this, var1), true));
   }

   @ResourceFactory.ResourceMethod(name = "ValidatePolicy", selectors = true, resource = true)
   public PolicyValidationResult validatePolicy(Map<String, String> var1, PolicyValidationContext var2) throws ResourceFactory.ResourceNotFoundException, ResourceFactory.InvalidResourceException {
      return (PolicyValidationResult)Eithers.extract2((Either)this.transactional(new bh(this, var2, var1), true));
   }

   @ResourceFactory.ResourceMethod(name = "SetVersionComment", selectors = true, resource = true)
   public void setVersionComment(Map<String, String> var1, VersionComment var2) throws ResourceFactory.ResourceNotFoundException, ResourceFactory.InvalidResourceException {
      Eithers.extract2((Either)this.transactional(new bj(this, var1, var2), false));
   }

   public PolicyMO asResource(Policy var1) {
      PolicyMO var2 = ManagedObjectFactory.createPolicy();
      PolicyDetail var3 = ManagedObjectFactory.createPolicyDetail();
      var2.setId(var1.getId());
      var2.setGuid(var1.getGuid());
      var2.setPolicyDetail(var3);
      ArrayList var5 = new ArrayList();
      var2.setResourceSets(var5);
      ResourceSet var6 = ManagedObjectFactory.createResourceSet();
      var5.add(var6);
      String[] var9 = v;
      var6.setTag(var9[17]);
      Resource var7 = ManagedObjectFactory.createResource();
      var6.setResources(Collections.singletonList(var7));
      var7.setType(var9[17]);

      boolean var4;
      try {
         var7.setContent(WspWriter.getPolicyXml(var1.getAssertion()));
         var4 = this.p.hasRoutingAssertion(var1);
      } catch (IOException var10) {
         var9 = v;
         throw new ResourceFactory.ResourceAccessException(var9[7], var10);
      }

      label40: {
         label39: {
            label38: {
               label37: {
                  label36: {
                     try {
                        var3.setId(var1.getId());
                        var3.setGuid(var1.getGuid());
                        var3.setVersion(var1.getVersion());
                        var3.setFolderId(this.getFolderId(var1));
                        var3.setName(var1.getName());
                        switch (bk.a[var1.getType().ordinal()]) {
                           case 1:
                              var3.setPolicyType(PolicyType.INCLUDE);
                              break label39;
                           case 2:
                              break label38;
                           case 3:
                              break label37;
                           case 4:
                              break label36;
                           case 5:
                              break;
                           default:
                              break label40;
                        }
                     } catch (IOException var11) {
                        throw a(var11);
                     }

                     var3.setPolicyType(PolicyType.SERVICE_OPERATION);
                     break label39;
                  }

                  var3.setPolicyType(PolicyType.ID_PROVIDER);
                  break label39;
               }

               var3.setPolicyType(PolicyType.GLOBAL);
               break label39;
            }

            var3.setPolicyType(PolicyType.INTERNAL);
         }

         var3.setProperties(this.getProperties(var1, Policy.class));
         var3.getProperties().put(v[20], var4);
         this.doSecurityZoneAsResource(var2, var1);
         return var2;
      }

      String var10002 = String.valueOf(var1.getType());
      var9 = v;
      throw new ResourceFactory.ResourceAccessException(var9[10] + var10002);
   }

   public Policy fromResource(Object param1, boolean param2) throws ResourceFactory.InvalidResourceException {
      // $VF: Couldn't be decompiled
      // Please report this to the Vineflower issue tracker, at https://github.com/Vineflower/vineflower/issues with a copy of the class file (if you have the rights to distribute it!)
      // java.lang.RuntimeException: parsing failure!
      //   at org.jetbrains.java.decompiler.modules.decompiler.decompose.DomHelper.parseGraph(DomHelper.java:211)
      //   at org.jetbrains.java.decompiler.main.rels.MethodProcessor.codeToJava(MethodProcessor.java:174)
      //
      // Bytecode:
      // 000: aload 1
      // 001: instanceof com/l7tech/gateway/api/PolicyMO
      // 004: ifne 01c
      // 007: new com/l7tech/external/assertions/gatewaymanagement/server/ResourceFactory$InvalidResourceException
      // 00a: dup
      // 00b: getstatic com/l7tech/external/assertions/gatewaymanagement/server/ResourceFactory$InvalidResourceException$ExceptionType.UNEXPECTED_TYPE Lcom/l7tech/external/assertions/gatewaymanagement/server/ResourceFactory$InvalidResourceException$ExceptionType;
      // 00e: getstatic com/l7tech/external/assertions/gatewaymanagement/server/PolicyResourceFactory.v [Ljava/lang/String;
      // 011: bipush 16
      // 013: aaload
      // 014: invokespecial com/l7tech/external/assertions/gatewaymanagement/server/ResourceFactory$InvalidResourceException.<init> (Lcom/l7tech/external/assertions/gatewaymanagement/server/ResourceFactory$InvalidResourceException$ExceptionType;Ljava/lang/String;)V
      // 017: athrow
      // 018: invokestatic com/l7tech/external/assertions/gatewaymanagement/server/PolicyResourceFactory.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 01b: athrow
      // 01c: aload 1
      // 01d: checkcast com/l7tech/gateway/api/PolicyMO
      // 020: astore 3
      // 021: aload 3
      // 022: invokevirtual com/l7tech/gateway/api/PolicyMO.getPolicyDetail ()Lcom/l7tech/gateway/api/PolicyDetail;
      // 025: astore 4
      // 027: aload 0
      // 028: getfield com/l7tech/external/assertions/gatewaymanagement/server/PolicyResourceFactory.u Lcom/l7tech/external/assertions/gatewaymanagement/server/cr;
      // 02b: aload 3
      // 02c: invokevirtual com/l7tech/gateway/api/PolicyMO.getResourceSets ()Ljava/util/List;
      // 02f: invokevirtual com/l7tech/external/assertions/gatewaymanagement/server/cr.a (Ljava/util/List;)Ljava/util/Map;
      // 032: astore 5
      // 034: aload 0
      // 035: getfield com/l7tech/external/assertions/gatewaymanagement/server/PolicyResourceFactory.u Lcom/l7tech/external/assertions/gatewaymanagement/server/cr;
      // 038: aload 5
      // 03a: getstatic com/l7tech/external/assertions/gatewaymanagement/server/PolicyResourceFactory.v [Ljava/lang/String;
      // 03d: astore 12
      // 03f: aload 12
      // 041: bipush 14
      // 043: aaload
      // 044: aload 12
      // 046: bipush 17
      // 048: aaload
      // 049: bipush 1
      // 04a: aconst_null
      // 04b: invokevirtual com/l7tech/external/assertions/gatewaymanagement/server/cr.a (Ljava/util/Map;Ljava/lang/String;Ljava/lang/String;ZLcom/l7tech/util/Functions$UnaryThrows;)Lcom/l7tech/gateway/api/Resource;
      // 04e: astore 6
      // 050: aload 4
      // 052: ifnonnull 068
      // 055: new com/l7tech/external/assertions/gatewaymanagement/server/ResourceFactory$InvalidResourceException
      // 058: dup
      // 059: getstatic com/l7tech/external/assertions/gatewaymanagement/server/ResourceFactory$InvalidResourceException$ExceptionType.MISSING_VALUES Lcom/l7tech/external/assertions/gatewaymanagement/server/ResourceFactory$InvalidResourceException$ExceptionType;
      // 05c: aload 12
      // 05e: bipush 4
      // 05f: aaload
      // 060: invokespecial com/l7tech/external/assertions/gatewaymanagement/server/ResourceFactory$InvalidResourceException.<init> (Lcom/l7tech/external/assertions/gatewaymanagement/server/ResourceFactory$InvalidResourceException$ExceptionType;Ljava/lang/String;)V
      // 063: athrow
      // 064: invokestatic com/l7tech/external/assertions/gatewaymanagement/server/PolicyResourceFactory.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 067: athrow
      // 068: aload 4
      // 06a: invokevirtual com/l7tech/gateway/api/PolicyDetail.getPolicyType ()Lcom/l7tech/gateway/api/PolicyDetail$PolicyType;
      // 06d: ifnonnull 085
      // 070: new com/l7tech/external/assertions/gatewaymanagement/server/ResourceFactory$InvalidResourceException
      // 073: dup
      // 074: getstatic com/l7tech/external/assertions/gatewaymanagement/server/ResourceFactory$InvalidResourceException$ExceptionType.MISSING_VALUES Lcom/l7tech/external/assertions/gatewaymanagement/server/ResourceFactory$InvalidResourceException$ExceptionType;
      // 077: getstatic com/l7tech/external/assertions/gatewaymanagement/server/PolicyResourceFactory.v [Ljava/lang/String;
      // 07a: bipush 8
      // 07c: aaload
      // 07d: invokespecial com/l7tech/external/assertions/gatewaymanagement/server/ResourceFactory$InvalidResourceException.<init> (Lcom/l7tech/external/assertions/gatewaymanagement/server/ResourceFactory$InvalidResourceException$ExceptionType;Ljava/lang/String;)V
      // 080: athrow
      // 081: invokestatic com/l7tech/external/assertions/gatewaymanagement/server/PolicyResourceFactory.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 084: athrow
      // 085: aload 5
      // 087: invokeinterface java/util/Map.size ()I 1
      // 08c: bipush 1
      // 08d: if_icmple 0bd
      // 090: new com/l7tech/external/assertions/gatewaymanagement/server/ResourceFactory$InvalidResourceException
      // 093: dup
      // 094: getstatic com/l7tech/external/assertions/gatewaymanagement/server/ResourceFactory$InvalidResourceException$ExceptionType.INVALID_VALUES Lcom/l7tech/external/assertions/gatewaymanagement/server/ResourceFactory$InvalidResourceException$ExceptionType;
      // 097: aload 5
      // 099: invokeinterface java/util/Map.keySet ()Ljava/util/Set; 1
      // 09e: getstatic com/l7tech/external/assertions/gatewaymanagement/server/PolicyResourceFactory.v [Ljava/lang/String;
      // 0a1: bipush 17
      // 0a3: aaload
      // 0a4: invokeinterface java/util/Set.remove (Ljava/lang/Object;)Z 2
      // 0a9: getstatic com/l7tech/external/assertions/gatewaymanagement/server/PolicyResourceFactory.v [Ljava/lang/String;
      // 0ac: bipush 15
      // 0ae: aaload
      // 0af: swap
      // 0b0: invokedynamic makeConcatWithConstants (Ljava/lang/String;Z)Ljava/lang/String; bsm=java/lang/invoke/StringConcatFactory.makeConcatWithConstants (Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/invoke/CallSite; args=[ "\u0001\u0001" ]
      // 0b5: invokespecial com/l7tech/external/assertions/gatewaymanagement/server/ResourceFactory$InvalidResourceException.<init> (Lcom/l7tech/external/assertions/gatewaymanagement/server/ResourceFactory$InvalidResourceException$ExceptionType;Ljava/lang/String;)V
      // 0b8: athrow
      // 0b9: invokestatic com/l7tech/external/assertions/gatewaymanagement/server/PolicyResourceFactory.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 0bc: athrow
      // 0bd: aload 0
      // 0be: getfield com/l7tech/external/assertions/gatewaymanagement/server/PolicyResourceFactory.q Lcom/l7tech/external/assertions/gatewaymanagement/server/FolderResourceFactory;
      // 0c1: aload 4
      // 0c3: invokevirtual com/l7tech/gateway/api/PolicyDetail.getFolderId ()Ljava/lang/String;
      // 0c6: invokestatic com/l7tech/util/Option.optional (Ljava/lang/Object;)Lcom/l7tech/util/Option;
      // 0c9: invokevirtual com/l7tech/external/assertions/gatewaymanagement/server/FolderResourceFactory.a (Lcom/l7tech/util/Option;)Lcom/l7tech/util/Option;
      // 0cc: astore 7
      // 0ce: aload 7
      // 0d0: invokevirtual com/l7tech/util/Option.isSome ()Z
      // 0d3: ifne 11e
      // 0d6: iload 2
      // 0d7: ifeq 0f5
      // 0da: goto 0e1
      // 0dd: invokestatic com/l7tech/external/assertions/gatewaymanagement/server/PolicyResourceFactory.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 0e0: athrow
      // 0e1: new com/l7tech/external/assertions/gatewaymanagement/server/ResourceFactory$InvalidResourceException
      // 0e4: dup
      // 0e5: getstatic com/l7tech/external/assertions/gatewaymanagement/server/ResourceFactory$InvalidResourceException$ExceptionType.INVALID_VALUES Lcom/l7tech/external/assertions/gatewaymanagement/server/ResourceFactory$InvalidResourceException$ExceptionType;
      // 0e8: getstatic com/l7tech/external/assertions/gatewaymanagement/server/PolicyResourceFactory.v [Ljava/lang/String;
      // 0eb: bipush 0
      // 0ec: aaload
      // 0ed: invokespecial com/l7tech/external/assertions/gatewaymanagement/server/ResourceFactory$InvalidResourceException.<init> (Lcom/l7tech/external/assertions/gatewaymanagement/server/ResourceFactory$InvalidResourceException$ExceptionType;Ljava/lang/String;)V
      // 0f0: athrow
      // 0f1: invokestatic com/l7tech/external/assertions/gatewaymanagement/server/PolicyResourceFactory.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 0f4: athrow
      // 0f5: new com/l7tech/objectmodel/folder/Folder
      // 0f8: dup
      // 0f9: invokespecial com/l7tech/objectmodel/folder/Folder.<init> ()V
      // 0fc: astore 8
      // 0fe: aload 8
      // 100: aload 4
      // 102: invokevirtual com/l7tech/gateway/api/PolicyDetail.getFolderId ()Ljava/lang/String;
      // 105: invokestatic com/l7tech/util/Option.optional (Ljava/lang/Object;)Lcom/l7tech/util/Option;
      // 108: getstatic com/l7tech/objectmodel/folder/Folder.ROOT_FOLDER_ID Lcom/l7tech/objectmodel/Goid;
      // 10b: invokevirtual com/l7tech/objectmodel/Goid.toString ()Ljava/lang/String;
      // 10e: invokevirtual com/l7tech/util/Option.orSome (Ljava/lang/Object;)Ljava/lang/Object;
      // 111: checkcast java/lang/String
      // 114: invokevirtual com/l7tech/objectmodel/folder/Folder.setId (Ljava/lang/String;)V
      // 117: aload 8
      // 119: invokestatic com/l7tech/util/Option.some (Ljava/lang/Object;)Lcom/l7tech/util/Option;
      // 11c: astore 7
      // 11e: aload 0
      // 11f: aload 4
      // 121: invokevirtual com/l7tech/gateway/api/PolicyDetail.getName ()Ljava/lang/String;
      // 124: invokevirtual com/l7tech/external/assertions/gatewaymanagement/server/PolicyResourceFactory.asName (Ljava/lang/String;)Ljava/lang/String;
      // 127: astore 8
      // 129: getstatic com/l7tech/external/assertions/gatewaymanagement/server/bk.b [I
      // 12c: aload 4
      // 12e: invokevirtual com/l7tech/gateway/api/PolicyDetail.getPolicyType ()Lcom/l7tech/gateway/api/PolicyDetail$PolicyType;
      // 131: invokevirtual com/l7tech/gateway/api/PolicyDetail$PolicyType.ordinal ()I
      // 134: iaload
      // 135: tableswitch 75 1 5 35 43 51 59 67
      // 158: getstatic com/l7tech/policy/PolicyType.INCLUDE_FRAGMENT Lcom/l7tech/policy/PolicyType;
      // 15b: astore 9
      // 15d: goto 195
      // 160: getstatic com/l7tech/policy/PolicyType.INTERNAL Lcom/l7tech/policy/PolicyType;
      // 163: astore 9
      // 165: goto 195
      // 168: getstatic com/l7tech/policy/PolicyType.GLOBAL_FRAGMENT Lcom/l7tech/policy/PolicyType;
      // 16b: astore 9
      // 16d: goto 195
      // 170: getstatic com/l7tech/policy/PolicyType.IDENTITY_PROVIDER_POLICY Lcom/l7tech/policy/PolicyType;
      // 173: astore 9
      // 175: goto 195
      // 178: getstatic com/l7tech/policy/PolicyType.POLICY_BACKED_OPERATION Lcom/l7tech/policy/PolicyType;
      // 17b: astore 9
      // 17d: goto 195
      // 180: new com/l7tech/external/assertions/gatewaymanagement/server/ResourceFactory$InvalidResourceException
      // 183: dup
      // 184: getstatic com/l7tech/external/assertions/gatewaymanagement/server/ResourceFactory$InvalidResourceException$ExceptionType.INVALID_VALUES Lcom/l7tech/external/assertions/gatewaymanagement/server/ResourceFactory$InvalidResourceException$ExceptionType;
      // 187: getstatic com/l7tech/external/assertions/gatewaymanagement/server/PolicyResourceFactory.v [Ljava/lang/String;
      // 18a: astore 12
      // 18c: aload 12
      // 18e: bipush 11
      // 190: aaload
      // 191: invokespecial com/l7tech/external/assertions/gatewaymanagement/server/ResourceFactory$InvalidResourceException.<init> (Lcom/l7tech/external/assertions/gatewaymanagement/server/ResourceFactory$InvalidResourceException$ExceptionType;Ljava/lang/String;)V
      // 194: athrow
      // 195: aload 0
      // 196: getfield com/l7tech/external/assertions/gatewaymanagement/server/PolicyResourceFactory.p Lcom/l7tech/external/assertions/gatewaymanagement/server/PolicyHelper;
      // 199: aload 6
      // 19b: invokevirtual com/l7tech/gateway/api/Resource.getContent ()Ljava/lang/String;
      // 19e: invokevirtual com/l7tech/external/assertions/gatewaymanagement/server/PolicyHelper.validatePolicySyntax (Ljava/lang/String;)Ljava/lang/String;
      // 1a1: astore 10
      // 1a3: new com/l7tech/policy/Policy
      // 1a6: dup
      // 1a7: aload 9
      // 1a9: aload 8
      // 1ab: aload 10
      // 1ad: bipush 0
      // 1ae: invokespecial com/l7tech/policy/Policy.<init> (Lcom/l7tech/policy/PolicyType;Ljava/lang/String;Ljava/lang/String;Z)V
      // 1b1: astore 11
      // 1b3: aload 11
      // 1b5: aload 7
      // 1b7: invokevirtual com/l7tech/util/Option.some ()Ljava/lang/Object;
      // 1ba: checkcast com/l7tech/objectmodel/folder/Folder
      // 1bd: invokevirtual com/l7tech/policy/Policy.setFolder (Lcom/l7tech/objectmodel/folder/Folder;)V
      // 1c0: aload 0
      // 1c1: aload 11
      // 1c3: aload 4
      // 1c5: invokevirtual com/l7tech/gateway/api/PolicyDetail.getProperties ()Ljava/util/Map;
      // 1c8: ldc com/l7tech/policy/Policy
      // 1ca: invokevirtual com/l7tech/external/assertions/gatewaymanagement/server/PolicyResourceFactory.setProperties (Lcom/l7tech/objectmodel/PersistentEntity;Ljava/util/Map;Ljava/lang/Class;)V
      // 1cd: aload 0
      // 1ce: aload 3
      // 1cf: aload 11
      // 1d1: iload 2
      // 1d2: invokevirtual com/l7tech/external/assertions/gatewaymanagement/server/PolicyResourceFactory.doSecurityZoneFromResource (Lcom/l7tech/gateway/api/SecurityZoneableObject;Lcom/l7tech/objectmodel/PersistentEntity;Z)V
      // 1d5: aload 11
      // 1d7: invokevirtual com/l7tech/policy/Policy.getType ()Lcom/l7tech/policy/PolicyType;
      // 1da: invokevirtual com/l7tech/policy/PolicyType.isSecurityZoneable ()Z
      // 1dd: ifne 217
      // 1e0: aload 11
      // 1e2: invokevirtual com/l7tech/policy/Policy.getSecurityZone ()Lcom/l7tech/objectmodel/SecurityZone;
      // 1e5: ifnull 217
      // 1e8: goto 1ef
      // 1eb: invokestatic com/l7tech/external/assertions/gatewaymanagement/server/PolicyResourceFactory.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 1ee: athrow
      // 1ef: new com/l7tech/external/assertions/gatewaymanagement/server/ResourceFactory$InvalidResourceException
      // 1f2: dup
      // 1f3: getstatic com/l7tech/external/assertions/gatewaymanagement/server/ResourceFactory$InvalidResourceException$ExceptionType.INVALID_VALUES Lcom/l7tech/external/assertions/gatewaymanagement/server/ResourceFactory$InvalidResourceException$ExceptionType;
      // 1f6: aload 11
      // 1f8: invokevirtual com/l7tech/policy/Policy.getType ()Lcom/l7tech/policy/PolicyType;
      // 1fb: invokevirtual com/l7tech/policy/PolicyType.getName ()Ljava/lang/String;
      // 1fe: getstatic com/l7tech/external/assertions/gatewaymanagement/server/PolicyResourceFactory.v [Ljava/lang/String;
      // 201: bipush 19
      // 203: aaload
      // 204: swap
      // 205: getstatic com/l7tech/external/assertions/gatewaymanagement/server/PolicyResourceFactory.v [Ljava/lang/String;
      // 208: bipush 5
      // 209: aaload
      // 20a: invokedynamic makeConcatWithConstants (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String; bsm=java/lang/invoke/StringConcatFactory.makeConcatWithConstants (Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/invoke/CallSite; args=[ "\u0001\u0001\u0001" ]
      // 20f: invokespecial com/l7tech/external/assertions/gatewaymanagement/server/ResourceFactory$InvalidResourceException.<init> (Lcom/l7tech/external/assertions/gatewaymanagement/server/ResourceFactory$InvalidResourceException$ExceptionType;Ljava/lang/String;)V
      // 212: athrow
      // 213: invokestatic com/l7tech/external/assertions/gatewaymanagement/server/PolicyResourceFactory.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 216: athrow
      // 217: aload 11
      // 219: areturn
      // try (0 -> 11): 11 com/l7tech/external/assertions/gatewaymanagement/server/ResourceFactory$InvalidResourceException
      // try (40 -> 50): 50 com/l7tech/external/assertions/gatewaymanagement/server/ResourceFactory$InvalidResourceException
      // try (52 -> 63): 63 com/l7tech/external/assertions/gatewaymanagement/server/ResourceFactory$InvalidResourceException
      // try (65 -> 85): 85 com/l7tech/external/assertions/gatewaymanagement/server/ResourceFactory$InvalidResourceException
      // try (94 -> 99): 100 com/l7tech/external/assertions/gatewaymanagement/server/ResourceFactory$InvalidResourceException
      // try (97 -> 110): 110 com/l7tech/external/assertions/gatewaymanagement/server/ResourceFactory$InvalidResourceException
      // try (178 -> 201): 202 com/l7tech/external/assertions/gatewaymanagement/server/ResourceFactory$InvalidResourceException
      // try (198 -> 220): 220 com/l7tech/external/assertions/gatewaymanagement/server/ResourceFactory$InvalidResourceException
   }

   @Override
   protected void beforeCreateEntity(EntityManagerResourceFactory.EntityBag<Policy> var1) throws ObjectModelException {
      UUID var2 = UUID.randomUUID();
      ((Policy)var1.getEntity()).setGuid(var2.toString());

      try {
         this.p.checkPolicyAssertionAccess((Policy)var1.getEntity());
      } catch (ResourceFactory.InvalidResourceException var4) {
         throw new SaveException(var4);
      }
   }

   @Override
   protected void afterCreateEntity(EntityManagerResourceFactory.EntityBag<Policy> param1, Goid param2) throws ObjectModelException {
      // $VF: Couldn't be decompiled
      // Please report this to the Vineflower issue tracker, at https://github.com/Vineflower/vineflower/issues with a copy of the class file (if you have the rights to distribute it!)
      // java.lang.RuntimeException: parsing failure!
      //   at org.jetbrains.java.decompiler.modules.decompiler.decompose.DomHelper.parseGraph(DomHelper.java:211)
      //   at org.jetbrains.java.decompiler.main.rels.MethodProcessor.codeToJava(MethodProcessor.java:174)
      //
      // Bytecode:
      // 00: getstatic com/l7tech/policy/PolicyType.INTERNAL Lcom/l7tech/policy/PolicyType;
      // 03: aload 1
      // 04: invokevirtual com/l7tech/external/assertions/gatewaymanagement/server/EntityManagerResourceFactory$EntityBag.getEntity ()Lcom/l7tech/objectmodel/PersistentEntity;
      // 07: checkcast com/l7tech/policy/Policy
      // 0a: invokevirtual com/l7tech/policy/Policy.getType ()Lcom/l7tech/policy/PolicyType;
      // 0d: invokevirtual com/l7tech/policy/PolicyType.equals (Ljava/lang/Object;)Z
      // 10: ifeq 6a
      // 13: getstatic com/l7tech/external/assertions/gatewaymanagement/server/PolicyResourceFactory.v [Ljava/lang/String;
      // 16: bipush 12
      // 18: aaload
      // 19: aload 1
      // 1a: invokevirtual com/l7tech/external/assertions/gatewaymanagement/server/EntityManagerResourceFactory$EntityBag.getEntity ()Lcom/l7tech/objectmodel/PersistentEntity;
      // 1d: checkcast com/l7tech/policy/Policy
      // 20: invokevirtual com/l7tech/policy/Policy.getInternalTag ()Ljava/lang/String;
      // 23: invokevirtual java/lang/String.equals (Ljava/lang/Object;)Z
      // 26: ifeq 6a
      // 29: goto 30
      // 2c: invokestatic com/l7tech/external/assertions/gatewaymanagement/server/PolicyResourceFactory.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 2f: athrow
      // 30: aload 0
      // 31: getfield com/l7tech/external/assertions/gatewaymanagement/server/PolicyResourceFactory.s Lcom/l7tech/server/cluster/ClusterPropertyManager;
      // 34: getstatic com/l7tech/external/assertions/gatewaymanagement/server/PolicyResourceFactory.v [Ljava/lang/String;
      // 37: bipush 18
      // 39: aaload
      // 3a: invokeinterface com/l7tech/server/cluster/ClusterPropertyManager.getProperty (Ljava/lang/String;)Ljava/lang/String; 2
      // 3f: ifnonnull 6a
      // 42: goto 49
      // 45: invokestatic com/l7tech/external/assertions/gatewaymanagement/server/PolicyResourceFactory.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 48: athrow
      // 49: aload 0
      // 4a: getfield com/l7tech/external/assertions/gatewaymanagement/server/PolicyResourceFactory.s Lcom/l7tech/server/cluster/ClusterPropertyManager;
      // 4d: getstatic com/l7tech/external/assertions/gatewaymanagement/server/PolicyResourceFactory.v [Ljava/lang/String;
      // 50: bipush 18
      // 52: aaload
      // 53: aload 1
      // 54: invokevirtual com/l7tech/external/assertions/gatewaymanagement/server/EntityManagerResourceFactory$EntityBag.getEntity ()Lcom/l7tech/objectmodel/PersistentEntity;
      // 57: checkcast com/l7tech/policy/Policy
      // 5a: invokevirtual com/l7tech/policy/Policy.getGuid ()Ljava/lang/String;
      // 5d: invokeinterface com/l7tech/server/cluster/ClusterPropertyManager.putProperty (Ljava/lang/String;Ljava/lang/String;)Lcom/l7tech/gateway/common/cluster/ClusterProperty; 3
      // 62: pop
      // 63: goto 6a
      // 66: invokestatic com/l7tech/external/assertions/gatewaymanagement/server/PolicyResourceFactory.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 69: athrow
      // 6a: return
      // try (0 -> 16): 17 com/l7tech/objectmodel/ObjectModelException
      // try (7 -> 26): 27 com/l7tech/objectmodel/ObjectModelException
      // try (19 -> 40): 41 com/l7tech/objectmodel/ObjectModelException
   }

   @Override
   protected void beforeDeleteEntity(EntityManagerResourceFactory.EntityBag<Policy> param1) throws ObjectModelException {
      // $VF: Couldn't be decompiled
      // Please report this to the Vineflower issue tracker, at https://github.com/Vineflower/vineflower/issues with a copy of the class file (if you have the rights to distribute it!)
      // java.lang.RuntimeException: parsing failure!
      //   at org.jetbrains.java.decompiler.modules.decompiler.decompose.DomHelper.parseGraph(DomHelper.java:211)
      //   at org.jetbrains.java.decompiler.main.rels.MethodProcessor.codeToJava(MethodProcessor.java:174)
      //
      // Bytecode:
      // 00: aload 0
      // 01: aload 1
      // 02: invokevirtual com/l7tech/external/assertions/gatewaymanagement/server/EntityManagerResourceFactory$EntityBag.getEntity ()Lcom/l7tech/objectmodel/PersistentEntity;
      // 05: checkcast com/l7tech/policy/Policy
      // 08: invokevirtual com/l7tech/external/assertions/gatewaymanagement/server/PolicyResourceFactory.a (Lcom/l7tech/policy/Policy;)Z
      // 0b: ifeq 2e
      // 0e: aload 0
      // 0f: invokevirtual com/l7tech/external/assertions/gatewaymanagement/server/PolicyResourceFactory.b ()Z
      // 12: ifeq 2e
      // 15: goto 1c
      // 18: invokestatic com/l7tech/external/assertions/gatewaymanagement/server/PolicyResourceFactory.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 1b: athrow
      // 1c: new com/l7tech/objectmodel/DeleteException
      // 1f: dup
      // 20: getstatic com/l7tech/external/assertions/gatewaymanagement/server/PolicyResourceFactory.v [Ljava/lang/String;
      // 23: bipush 13
      // 25: aaload
      // 26: invokespecial com/l7tech/objectmodel/DeleteException.<init> (Ljava/lang/String;)V
      // 29: athrow
      // 2a: invokestatic com/l7tech/external/assertions/gatewaymanagement/server/PolicyResourceFactory.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 2d: athrow
      // 2e: return
      // try (0 -> 9): 10 com/l7tech/objectmodel/ObjectModelException
      // try (6 -> 19): 19 com/l7tech/objectmodel/ObjectModelException
   }

   @Override
   protected void afterDeleteEntity(EntityManagerResourceFactory.EntityBag<Policy> var1) throws ObjectModelException {
      if (this.a((Policy)var1.getEntity())) {
         ClusterProperty var2 = (ClusterProperty)this.s.findByUniqueName(v[18]);

         try {
            if (var2 == null) {
               return;
            }
         } catch (ObjectModelException var3) {
            throw a(var3);
         }

         this.s.delete(var2);
      }
   }

   private boolean a(@NotNull Policy param1) throws FindException {
      // $VF: Couldn't be decompiled
      // Please report this to the Vineflower issue tracker, at https://github.com/Vineflower/vineflower/issues with a copy of the class file (if you have the rights to distribute it!)
      // java.lang.RuntimeException: parsing failure!
      //   at org.jetbrains.java.decompiler.modules.decompiler.decompose.DomHelper.parseGraph(DomHelper.java:211)
      //   at org.jetbrains.java.decompiler.main.rels.MethodProcessor.codeToJava(MethodProcessor.java:174)
      //
      // Bytecode:
      // 00: aload 1
      // 01: ifnonnull 0f
      // 04: bipush 0
      // 05: invokestatic com/l7tech/external/assertions/gatewaymanagement/server/PolicyResourceFactory.c (I)V
      // 08: goto 0f
      // 0b: invokestatic com/l7tech/external/assertions/gatewaymanagement/server/PolicyResourceFactory.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 0e: athrow
      // 0f: getstatic com/l7tech/policy/PolicyType.INTERNAL Lcom/l7tech/policy/PolicyType;
      // 12: aload 1
      // 13: invokevirtual com/l7tech/policy/Policy.getType ()Lcom/l7tech/policy/PolicyType;
      // 16: invokevirtual com/l7tech/policy/PolicyType.equals (Ljava/lang/Object;)Z
      // 19: ifeq 7a
      // 1c: getstatic com/l7tech/external/assertions/gatewaymanagement/server/PolicyResourceFactory.v [Ljava/lang/String;
      // 1f: bipush 6
      // 21: aaload
      // 22: aload 1
      // 23: invokevirtual com/l7tech/policy/Policy.getInternalTag ()Ljava/lang/String;
      // 26: invokevirtual java/lang/String.equals (Ljava/lang/Object;)Z
      // 29: ifeq 7a
      // 2c: goto 33
      // 2f: invokestatic com/l7tech/external/assertions/gatewaymanagement/server/PolicyResourceFactory.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 32: athrow
      // 33: aload 0
      // 34: getfield com/l7tech/external/assertions/gatewaymanagement/server/PolicyResourceFactory.s Lcom/l7tech/server/cluster/ClusterPropertyManager;
      // 37: getstatic com/l7tech/external/assertions/gatewaymanagement/server/PolicyResourceFactory.v [Ljava/lang/String;
      // 3a: bipush 2
      // 3b: aaload
      // 3c: invokeinterface com/l7tech/server/cluster/ClusterPropertyManager.getProperty (Ljava/lang/String;)Ljava/lang/String; 2
      // 41: ifnull 7a
      // 44: goto 4b
      // 47: invokestatic com/l7tech/external/assertions/gatewaymanagement/server/PolicyResourceFactory.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 4a: athrow
      // 4b: aload 0
      // 4c: getfield com/l7tech/external/assertions/gatewaymanagement/server/PolicyResourceFactory.s Lcom/l7tech/server/cluster/ClusterPropertyManager;
      // 4f: getstatic com/l7tech/external/assertions/gatewaymanagement/server/PolicyResourceFactory.v [Ljava/lang/String;
      // 52: bipush 18
      // 54: aaload
      // 55: invokeinterface com/l7tech/server/cluster/ClusterPropertyManager.getProperty (Ljava/lang/String;)Ljava/lang/String; 2
      // 5a: astore 2
      // 5b: aload 2
      // 5c: ifnull 7a
      // 5f: aload 2
      // 60: invokevirtual java/lang/String.trim ()Ljava/lang/String;
      // 63: aload 1
      // 64: invokevirtual com/l7tech/policy/Policy.getGuid ()Ljava/lang/String;
      // 67: invokevirtual java/lang/String.equals (Ljava/lang/Object;)Z
      // 6a: ifeq 7a
      // 6d: goto 74
      // 70: invokestatic com/l7tech/external/assertions/gatewaymanagement/server/PolicyResourceFactory.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 73: athrow
      // 74: bipush 1
      // 75: ireturn
      // 76: invokestatic com/l7tech/external/assertions/gatewaymanagement/server/PolicyResourceFactory.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 79: athrow
      // 7a: bipush 0
      // 7b: ireturn
      // try (0 -> 4): 5 com/l7tech/objectmodel/FindException
      // try (7 -> 19): 20 com/l7tech/objectmodel/FindException
      // try (12 -> 29): 30 com/l7tech/objectmodel/FindException
      // try (39 -> 47): 48 com/l7tech/objectmodel/FindException
      // try (41 -> 52): 52 com/l7tech/objectmodel/FindException
   }

   private boolean b() throws FindException {
      for (ServiceHeader var3 : this.t.findAllHeaders()) {
         try {
            if (var3.isTracingEnabled()) {
               return true;
            }
         } catch (FindException var4) {
            throw a(var4);
         }
      }

      return false;
   }

   protected void updateEntity(Policy var1, Policy var2) throws ResourceFactory.InvalidResourceException {
      var1.setFolder(this.q.a(var1.getFolder(), var2.getFolder()));
      var1.setType(var2.getType());
      var1.setName(var2.getName());
      var1.setSoap(var2.isSoap());
      var1.setInternalTag(var2.getInternalTag());
      var1.setInternalSubTag(var2.getInternalSubTag());
      var1.setXml(var2.getXml());
      var1.setSecurityZone(var2.getSecurityZone());
   }

   @Override
   protected List<PolicyHeader> filterHeaders(List<PolicyHeader> var1) {
      ArrayList var2 = new ArrayList(var1.size());

      for (PolicyHeader var4 : var1) {
         try {
            switch (bk.a[var4.getPolicyType().ordinal()]) {
               case 1:
               case 2:
               case 3:
               case 4:
                  var2.add(var4);
            }
         } catch (ResourceFactory.ResourceAccessException var5) {
            throw a(var5);
         }
      }

      return var2;
   }

   protected Policy filterEntity(Policy var1) {
      Policy var2 = null;
      switch (bk.a[var1.getType().ordinal()]) {
         case 1:
         case 2:
         case 3:
         case 4:
         case 5:
            var2 = var1;
         default:
            return var2;
      }
   }

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

   static {
      String[] var5 = new String[21];
      int var3 = 0;
      String var2 = "@w\u0013N1G\u0010hw\u000b\n2ZEh|>Gj\u0018_9P^r8\u0019E&\u0015pHw\u000bd!Y\\&h\u001eX5XUr}\r\ns\u0010C!8\u0010Lt\u0010C(=\f\n9@Cr8\u0011E \u0015Rc8\u0011_8Y\u0011rj\u001eI1\u001b@it\u0016I-\u001bWsq\u001b\u0012ok;O6@WRj\u001eI1e_jq\u001cS\u000fkq\fY=[W&|\u001a^5\\\\u\u0019&q\f\n:ZD&k\u001aI!GYra_P;[Ugz\u0013O\u000bb}\u001d_3\u0018Dty\u001cO\u001dEw\nF0\u0015^il_X1ABo}\tOtE_jq\u001cStM]j\u001dkq\fY=[W&|\u001a^5\\\\u8R\n$Z\\o{\u0006\n L@cMew\u0012\u00058\u0002Dc{\u0017\u00051MDcj\u0011K8\u001aQuk\u001aX \\_hkPM5AUqy\u0006G5[Qa}\u0012O:A\u001fu}\r\\1G\u001fVw\u0013C7Lbck\u0010_&VU@y\u001c^;GI#G{\u001cO'F\u0010i~__:FEvh\u0010X PT&h\u0010F=VI&l\u0006Z1\u000f\u0010\u0013sv\u0014D;B^&h\u0010F=VI&l\u0006Z1\u000bb}\u001d_3\u0018Dty\u001cOLEy\u0011D;A\u0010b}\u0013O P\u0010vw\u0013C7L\u0010ol_C'\u0015Ssj\rO:A\\\u007f8\u0016Dt@Cc8\u001eYtAXc8\u0018F;WQj8\u001bO6@W&l\rK7P\u0010vw\u0013C7L\u0006vw\u0013C7L\u0019sv\u001aR$PSr}\u001b\n&PCim\rI1\u0015Ccl\f\n\u000fc`\u000fO7AUb8\u000fE8\\S\u007f\u0006vw\u0013C7L\u0011rj\u001eI1\u001b@it\u0016I-\u001bWsq\u001b";
      int var4 = "@w\u0013N1G\u0010hw\u000b\n2ZEh|>Gj\u0018_9P^r8\u0019E&\u0015pHw\u000bd!Y\\&h\u001eX5XUr}\r\ns\u0010C!8\u0010Lt\u0010C(=\f\n9@Cr8\u0011E \u0015Rc8\u0011_8Y\u0011rj\u001eI1\u001b@it\u0016I-\u001bWsq\u001b\u0012ok;O6@WRj\u001eI1e_jq\u001cS\u000fkq\fY=[W&|\u001a^5\\\\u\u0019&q\f\n:ZD&k\u001aI!GYra_P;[Ugz\u0013O\u000bb}\u001d_3\u0018Dty\u001cO\u001dEw\nF0\u0015^il_X1ABo}\tOtE_jq\u001cStM]j\u001dkq\fY=[W&|\u001a^5\\\\u8R\n$Z\\o{\u0006\n L@cMew\u0012\u00058\u0002Dc{\u0017\u00051MDcj\u0011K8\u001aQuk\u001aX \\_hkPM5AUqy\u0006G5[Qa}\u0012O:A\u001fu}\r\\1G\u001fVw\u0013C7Lbck\u0010_&VU@y\u001c^;GI#G{\u001cO'F\u0010i~__:FEvh\u0010X PT&h\u0010F=VI&l\u0006Z1\u000f\u0010\u0013sv\u0014D;B^&h\u0010F=VI&l\u0006Z1\u000bb}\u001d_3\u0018Dty\u001cOLEy\u0011D;A\u0010b}\u0013O P\u0010vw\u0013C7L\u0010ol_C'\u0015Ssj\rO:A\\\u007f8\u0016Dt@Cc8\u001eYtAXc8\u0018F;WQj8\u001bO6@W&l\rK7P\u0010vw\u0013C7L\u0006vw\u0013C7L\u0019sv\u001aR$PSr}\u001b\n&PCim\rI1\u0015Ccl\f\n\u000fc`\u000fO7AUb8\u000fE8\\S\u007f\u0006vw\u0013C7L\u0011rj\u001eI1\u001b@it\u0016I-\u001bWsq\u001b"
         .length();
      char var1 = 16;
      int var7 = -1;

      label24:
      while (true) {
         byte var10000 = 13;
         String var10001 = var2.substring(++var7, var7 + var1);
         byte var10002 = -1;

         while (true) {
            String var8 = d(var10000, a(var10001));
            switch (var10002) {
               case 0:
                  var5[var3++] = var8;
                  if ((var7 += var1) >= var4) {
                     v = var5;
                     return;
                  }

                  var1 = var2.charAt(var7);
                  break;
               default:
                  var5[var3++] = var8;
                  if ((var7 += var1) < var4) {
                     var1 = var2.charAt(var7);
                     continue label24;
                  }

                  var2 = ":\u001b\u007f/[ |\u0005\u001232A)9J\n\u0002\u0015`\u0014W,(\u0003\u001at";
                  var4 = ":\u001b\u007f/[ |\u0005\u001232A)9J\n\u0002\u0015`\u0014W,(\u0003\u001at".length();
                  var1 = 15;
                  var7 = -1;
            }

            var10000 = 97;
            var10001 = var2.substring(++var7, var7 + var1);
            var10002 = 0;
         }
      }
   }

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

      return var10000;
   }

   private static String d(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 -> 11;
            case 1 -> 21;
            case 2 -> 114;
            case 3 -> 39;
            case 4 -> 89;
            case 5 -> 56;
            default -> 61;
         });
      }

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