001/*
002 * The contents of this file are subject to the license and copyright
003 * detailed in the LICENSE and NOTICE files at the root of the source
004 * tree.
005 */
006package org.fcrepo.kernel.api.exception;
007
008import java.util.HashSet;
009import java.util.List;
010import java.util.Set;
011
012/**
013 * Wrapper to hold multiple constraint violation exceptions for later reporting.
014 * @author whikloj
015 */
016public class MultipleConstraintViolationException extends ConstraintViolationException {
017
018    private Set<ConstraintViolationException> exceptionTypes = new HashSet<>();
019
020    private String fullMessage = "";
021
022    public Set<ConstraintViolationException> getExceptionTypes() {
023        return exceptionTypes;
024    }
025
026    public MultipleConstraintViolationException(final List<ConstraintViolationException> exceptions) {
027        super("There are multiple exceptions");
028        for (final ConstraintViolationException exception : exceptions) {
029            exceptionTypes.add(exception);
030            fullMessage += exception.getMessage() + "\n";
031        }
032    }
033
034    @Override
035    public String getMessage() {
036        return fullMessage;
037    }
038
039}