/*
 * Copyright 2011-2016 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 static com.google.common.collect.Maps.newHashMap;

import java.util.Map;
import java.util.Map.Entry;

import com.b2international.commons.Pair;

/**
 * Generic syntax exception
 * 
 * @since 5.4
 */
public final class SyntaxException extends BadRequestException {

	private static final long serialVersionUID = -6130929059690887226L;
	private final Map<Pair<Integer, Integer>, String> errors;
	
	public SyntaxException(String language, Map<Pair<Integer, Integer>, String> errors) {
		super("One or more %s syntax errors", language);
		this.errors = errors;
	}
	
	@Override
	protected Map<String, Object> getAdditionalInfo() {
		final Map<String, Object> info = newHashMap();
		for (Entry<Pair<Integer, Integer>, String> entry : errors.entrySet()) {
			info.put(String.format("[%s,%s]", entry.getKey().getA(), entry.getKey().getB()), entry.getValue());
		}
		return info;
	}
	
	public Map<Pair<Integer, Integer>, String> getErrors() {
		return errors;
	}

}

@@ -17,17 +17,17 @@
 2011-201
-6
+7
  B2i Hea
@@ -1038,46 +1038,38 @@
 Map%3C
-Pair%3CInteger, Integer%3E, String%3E errors
+String, Object%3E additionalInfo
 ;%0A%09%0A
@@ -1212,128 +1212,19 @@
 ;%0A%09%09
-this.errors = errors;%0A%09%7D%0A%09%0A%09@Override%0A%09protected Map%3CString, Object%3E getAdditionalInfo() %7B%0A%09%09final Map%3CString, Object%3E i
+additionalI
 nfo 
@@ -1316,17 +1316,27 @@
 )) %7B%0A%09%09%09
-i
+additionalI
 nfo.put(
@@ -1435,104 +1435,104 @@
 %09%7D%0A%09
-%09return info;
+%7D
 %0A%09
-%7D
 %0A%09
-%0A%09public Map%3CPair%3CInteger, Integer%3E, String%3E getErrors() %7B%0A%09%09return errors
+@Override%0A%09protected Map%3CString, Object%3E getAdditionalInfo() %7B%0A%09%09return additionalInfo
 ;%0A%09%7D%0A
+%09
 %0A%7D%0A

fix serialization issue in SyntaxException