@@ -0,0 +1,2750 @@
+/*%0A * #%25L%0A * BroadleafCommerce Workflow%0A * %25%25%0A * Copyright (C) 2009 - 2013 Broadleaf Commerce%0A * %25%25%0A * NOTICE:  All information contained herein is, and remains%0A * the property of Broadleaf Commerce, LLC%0A * The intellectual and technical concepts contained%0A * herein are proprietary to Broadleaf Commerce, LLC%0A * and may be covered by U.S. and Foreign Patents,%0A * patents in process, and are protected by trade secret or copyright law.%0A * Dissemination of this information or reproduction of this material%0A * is strictly forbidden unless prior written permission is obtained%0A * from Broadleaf Commerce, LLC.%0A * #L%25%0A */%0Apackage org.broadleafcommerce.common.exception;%0A%0Aimport org.apache.commons.logging.Log;%0Aimport org.apache.commons.logging.LogFactory;%0A%0A/**%0A * @author Jeff Fischer%0A */%0Apublic class ExceptionHelper %7B%0A%0A    private static final Log LOG = LogFactory.getLog(ExceptionHelper.class);%0A%0A    public static %3CG extends Throwable, J extends RuntimeException%3E RuntimeException refineException(Class%3CG%3E refineType, Class%3CJ%3E wrapType, Throwable e) %7B%0A        if (refineType.isAssignableFrom(e.getClass())) %7B%0A            return wrapException(e, wrapType);%0A        %7D%0A        Throwable rootCause = e;%0A        boolean eof = false;%0A        while (!eof) %7B%0A            if (rootCause.getCause() != null) %7B%0A                rootCause = rootCause.getCause();%0A                if (refineType.isAssignableFrom(rootCause.getClass())) %7B%0A                    return wrapException(e, wrapType);%0A                %7D%0A            %7D else %7B%0A                eof = true;%0A            %7D%0A        %7D%0A        return wrapException(e, wrapType);%0A    %7D%0A%0A    public static %3CG extends Throwable, J extends RuntimeException%3E void processException(Class%3CG%3E refineType, Class%3CJ%3E wrapType, Throwable e) throws G %7B%0A        if (refineType.isAssignableFrom(e.getClass())) %7B%0A            throw (G) e;%0A        %7D%0A        Throwable rootCause = e;%0A        boolean eof = false;%0A        while (!eof) %7B%0A            if (rootCause.getCause() != null) %7B%0A                rootCause = rootCause.getCause();%0A                if (refineType.isAssignableFrom(rootCause.getClass())) %7B%0A                    throw (G) rootCause;%0A                %7D%0A            %7D else %7B%0A                eof = true;%0A            %7D%0A        %7D%0A        throw wrapException(e, wrapType);%0A    %7D%0A%0A    private static %3CJ extends RuntimeException%3E RuntimeException wrapException(Throwable e, Class%3CJ%3E wrapType) %7B%0A        if (e instanceof RuntimeException) %7B%0A            return (RuntimeException) e;%0A        %7D%0A        try %7B%0A            return wrapType.getConstructor(Throwable.class).newInstance(e);%0A        %7D catch (Exception e1) %7B%0A            LOG.error(%22Could not wrap exception%22, e1);%0A            throw new RuntimeException(e);%0A        %7D%0A    %7D%0A%0A%7D%0A

add exception helper utility class