/*
 * Copyright 2011-2015 B2i Healthcare Pte Ltd, http://b2i.sg
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.b2international.snowowl.core.exceptions;

import java.util.Collection;
import java.util.Map;

import javax.validation.ConstraintViolation;

import com.b2international.commons.validation.ConstraintViolations;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMap.Builder;


/**
 * @since 4.1.1
 */
public class ValidationException extends BadRequestException {

	private static final long serialVersionUID = 5786944138934316434L;
	private Collection<? extends ConstraintViolation<?>> violations;

	public ValidationException(Collection<? extends ConstraintViolation<?>> violations) {
		super("%s validation error%s", violations.size(), violations.size() == 1 ? "" : "s");
		this.violations = violations;
	}
	
	@Override
	protected Map<String, Object> getAdditionalInfo() {
		final Builder<String, Object> builder = ImmutableMap.<String, Object>builder();
		return builder.put("violations", ConstraintViolations.format(this.violations)).build();
	}
	
}

@@ -17,17 +17,17 @@
 2011-201
-5
+7
  B2i Hea
@@ -976,16 +976,22 @@
 %0Apublic 
+final 
 class Va
@@ -1089,94 +1089,80 @@
 D = 
-5786944138934316434L;%0A%09private Collection%3C? extends ConstraintViolation%3C?%3E%3E violations
+-1656929747149578841L;%0A%09private final Map%3CString, Object%3E additionalInfo
 ;%0A%0A%09
@@ -1339,109 +1339,8 @@
 %22);%0A
-%09%09this.violations = violations;%0A%09%7D%0A%09%0A%09@Override%0A%09protected Map%3CString, Object%3E getAdditionalInfo() %7B%0A
 %09%09fi
@@ -1423,14 +1423,29 @@
 ;%0A%09%09
-return
+this.additionalInfo =
  bui
@@ -1495,21 +1495,16 @@
 .format(
-this.
 violatio
@@ -1522,10 +1522,104 @@
 );%0A%09%7D%0A%09%0A
+%09@Override%0A%09protected Map%3CString, Object%3E getAdditionalInfo() %7B%0A%09%09return additionalInfo;%0A%09%7D%0A%09%0A
 %7D%0A

fix Java serialization of ValidationException