/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.objectmodel.ConstraintViolationException
 *  com.l7tech.util.ArrayUtils
 *  com.l7tech.util.ExceptionUtils
 *  org.hibernate.exception.ConstraintViolationException
 *  org.springframework.aop.ThrowsAdvice
 *  org.springframework.dao.DataIntegrityViolationException
 */
package com.l7tech.server.util;

import com.l7tech.server.util.c;
import com.l7tech.util.ArrayUtils;
import com.l7tech.util.ExceptionUtils;
import java.lang.reflect.Method;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.hibernate.exception.ConstraintViolationException;
import org.springframework.aop.ThrowsAdvice;
import org.springframework.dao.DataIntegrityViolationException;

public class ConstraintViolationThrowsAdvice
implements ThrowsAdvice {
    private static final Logger a;
    private static final String[] b;

    public void afterThrowing(Method method, Object[] objectArray, Object object, DataIntegrityViolationException dataIntegrityViolationException) throws com.l7tech.objectmodel.ConstraintViolationException {
        block7: {
            block8: {
                Object[] objectArray2 = method.getExceptionTypes();
                try {
                    try {
                        if (!ArrayUtils.contains((Object[])objectArray2, com.l7tech.objectmodel.ConstraintViolationException.class)) break block7;
                        if (!a.isLoggable(Level.FINE)) break block8;
                    }
                    catch (com.l7tech.objectmodel.ConstraintViolationException constraintViolationException) {
                        throw ConstraintViolationThrowsAdvice.a(constraintViolationException);
                    }
                    a.log(Level.FINE, b[0], ExceptionUtils.getDebugException((Throwable)dataIntegrityViolationException));
                }
                catch (com.l7tech.objectmodel.ConstraintViolationException constraintViolationException) {
                    throw ConstraintViolationThrowsAdvice.a(constraintViolationException);
                }
            }
            ConstraintViolationException constraintViolationException = (ConstraintViolationException)ExceptionUtils.getCauseIfCausedBy((Throwable)dataIntegrityViolationException, ConstraintViolationException.class);
            try {
                if (constraintViolationException != null) {
                    throw new com.l7tech.objectmodel.ConstraintViolationException(constraintViolationException.getMessage());
                }
            }
            catch (com.l7tech.objectmodel.ConstraintViolationException constraintViolationException2) {
                throw ConstraintViolationThrowsAdvice.a(constraintViolationException2);
            }
        }
        a.log(Level.WARNING, ExceptionUtils.getDebugException((Throwable)dataIntegrityViolationException), new c(this, dataIntegrityViolationException));
        throw new DataIntegrityViolationException(b[1]);
    }

    /*
     * Enabled aggressive block sorting
     */
    static {
        String[] stringArray = new String[2];
        int n2 = 0;
        String string = "?#\u000e=%`|\u0017-B\r!ft0$\u0016,'`|\r34 /~t\r#\r'\u0005jv\u001c:\u0016 /|5\u00189B\n/|f\r8\u0003 .fC\u0010%\u000e(4{z\u0017\u000f\u001a*%ba\u0010%\f<=+\u0016(\"sf\u001cj\u00071#we\r#\r'`}v\u001a?\u0010;%v5\u001d?\u0007i4}5\u001d+\u0016(`{{\r/\u0005;)flY<\u000b&,sa\u0010%\fg";
        int n3 = "?#\u000e=%`|\u0017-B\r!ft0$\u0016,'`|\r34 /~t\r#\r'\u0005jv\u001c:\u0016 /|5\u00189B\n/|f\r8\u0003 .fC\u0010%\u000e(4{z\u0017\u000f\u001a*%ba\u0010%\f<=+\u0016(\"sf\u001cj\u00071#we\r#\r'`}v\u001a?\u0010;%v5\u001d?\u0007i4}5\u001d+\u0016(`{{\r/\u0005;)flY<\u000b&,sa\u0010%\fg".length();
        int n4 = 73;
        int n5 = -1;
        while (true) {
            int n6 = ++n5;
            stringArray[n2++] = ConstraintViolationThrowsAdvice.a(88, ConstraintViolationThrowsAdvice.a(string.substring(n6, n6 + n4)));
            if ((n5 += n4) >= n3) {
                b = stringArray;
                a = Logger.getLogger(ConstraintViolationThrowsAdvice.class.getName());
                return;
            }
            n4 = string.charAt(n5);
        }
    }

    private static com.l7tech.objectmodel.ConstraintViolationException a(com.l7tech.objectmodel.ConstraintViolationException constraintViolationException) {
        return constraintViolationException;
    }

    private static char[] a(String string) {
        char[] cArray = string.toCharArray();
        if (cArray.length < 2) {
            cArray = cArray;
            cArray[0] = (char)(cArray[0] ^ 0x4D);
        }
        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 -> 33;
                    case 1 -> 18;
                    case 2 -> 58;
                    case 3 -> 17;
                    case 4 -> 24;
                    case 5 -> 74;
                    default -> 77;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

