diff --git a/javawebpoc-web/src/main/java/br/com/viktor/javawebpoc/controller/util/GlobalExceptionHandler.java b/javawebpoc-web/src/main/java/br/com/viktor/javawebpoc/controller/util/GlobalExceptionHandler.java
index 4aa4f00..ac9e143 100644
--- a/javawebpoc-web/src/main/java/br/com/viktor/javawebpoc/controller/util/GlobalExceptionHandler.java
+++ b/javawebpoc-web/src/main/java/br/com/viktor/javawebpoc/controller/util/GlobalExceptionHandler.java
@@ -5,6 +5,8 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.http.HttpStatus;
+import org.springframework.http.converter.HttpMessageNotReadableException;
+import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
@@ -14,6 +16,9 @@
import br.com.viktor.javawebpoc.exception.alreadyExists.AlreadyExistsException;
import br.com.viktor.javawebpoc.exception.invalidArgument.InvalidArgumentException;
import br.com.viktor.javawebpoc.exception.notFound.NotFoundException;
+import br.com.viktor.javawebpoc.l10n.MessageKey;
+
+import com.fasterxml.jackson.core.JsonParseException;
@ControllerAdvice
public class GlobalExceptionHandler {
@@ -53,4 +58,25 @@ public ErrorResponse generalExceptionHandler(JavaWebPoCException ex, Locale loca
return response;
}
+ @ExceptionHandler(HttpRequestMethodNotSupportedException.class)
+ @ResponseStatus(value = HttpStatus.NOT_IMPLEMENTED)
+ @ResponseBody
+ public ErrorResponse jsonErrorHandler(HttpRequestMethodNotSupportedException ex, Locale locale){
+ ErrorResponse response = new ErrorResponse();
+ response.setMessage(messageSource.getMessage(MessageKey.METHODNOTSUPPORTED_EXCEPTION.getMessageKey(), new Object[]{}, locale));
+ return response;
+ }
+
+ @ExceptionHandler(HttpMessageNotReadableException.class)
+ @ResponseStatus(value = HttpStatus.BAD_REQUEST)
+ @ResponseBody
+ public ErrorResponse httpMessageInvalidErrorHandler(HttpMessageNotReadableException ex, Locale locale){
+ if(ex.getCause() instanceof JsonParseException){
+ ErrorResponse response = new ErrorResponse();
+ response.setMessage(messageSource.getMessage(MessageKey.JSONBADREQUEST_EXCEPTION.getMessageKey(), new Object[]{}, locale));
+ return response;
+ }
+ return null;
+ }
+
}
\ No newline at end of file
diff --git a/javawebpoc-web/src/main/java/br/com/viktor/javawebpoc/l10n/MessageKey.java b/javawebpoc-web/src/main/java/br/com/viktor/javawebpoc/l10n/MessageKey.java
index 9a93ef1..4c3814c 100644
--- a/javawebpoc-web/src/main/java/br/com/viktor/javawebpoc/l10n/MessageKey.java
+++ b/javawebpoc-web/src/main/java/br/com/viktor/javawebpoc/l10n/MessageKey.java
@@ -8,6 +8,8 @@ public enum MessageKey {
NULLARGUMENT_EXCEPTION("br.com.viktor.javawebpoc.exception.nullargumentexception"),
INVALIDSTUDENT_EXCEPTION("br.com.viktor.javawebpoc.exception.invalidstudentexception"),
NOTFOUND_EXCEPTION("br.com.viktor.javawebpoc.exception.notfoundexception"),
+ JSONBADREQUEST_EXCEPTION("br.com.viktor.javawebpoc.exception.jsonbadrequest"),
+ METHODNOTSUPPORTED_EXCEPTION("br.com.viktor.javawebpoc.exception.methodnotsupported"),
VALIDATION_INVALID("br.com.viktor.javawebpoc.validation.invalid"),
VALIDATION_FIELD_REQUIRED("br.com.viktor.javawebpoc.validation.fieldrequired"),
diff --git a/javawebpoc-web/src/main/resources/l10n/javawebpocException.properties b/javawebpoc-web/src/main/resources/l10n/javawebpocException_en_US.properties
similarity index 57%
rename from javawebpoc-web/src/main/resources/l10n/javawebpocException.properties
rename to javawebpoc-web/src/main/resources/l10n/javawebpocException_en_US.properties
index 494a397..72b139e 100644
--- a/javawebpoc-web/src/main/resources/l10n/javawebpocException.properties
+++ b/javawebpoc-web/src/main/resources/l10n/javawebpocException_en_US.properties
@@ -1,10 +1,14 @@
-br.com.viktor.javawebpoc.exception.javawebpocexception=There was an internal error
+br.com.viktor.javawebpoc.exception.javawebpocexception=There was an internal error.
-br.com.viktor.javawebpoc.exception.alreadyexistsexception=Argument already exists
+br.com.viktor.javawebpoc.exception.alreadyexistsexception=Argument already exists.
br.com.viktor.javawebpoc.exception.studentexistsexception=Student already exists: {0}
-br.com.viktor.javawebpoc.exception.nullargumentexception=Null argument: {0}
-br.com.viktor.javawebpoc.exception.argumentexception=Invalid argument: {0}
-br.com.viktor.javawebpoc.exception.invalidstudentexception=Invalid Student: {0}
+br.com.viktor.javawebpoc.exception.nullargumentexception=Null argument: {0}.
+br.com.viktor.javawebpoc.exception.argumentexception=Invalid argument: {0}.
+br.com.viktor.javawebpoc.exception.invalidstudentexception=Invalid Student: {0}.
+
+br.com.viktor.javawebpoc.exception.notfoundexception=Not found.
+
+br.com.viktor.javawebpoc.exception.jsonbadrequest=JSON has an invalid format.
+br.com.viktor.javawebpoc.exception.methodnotsupported=HTTP method not supported.
-br.com.viktor.javawebpoc.exception.notfoundexception=Not found
\ No newline at end of file
diff --git a/javawebpoc-web/src/main/resources/l10n/javawebpocException_pt_BR.properties b/javawebpoc-web/src/main/resources/l10n/javawebpocException_pt_BR.properties
index 2507fc3..02ea4ad 100644
--- a/javawebpoc-web/src/main/resources/l10n/javawebpocException_pt_BR.properties
+++ b/javawebpoc-web/src/main/resources/l10n/javawebpocException_pt_BR.properties
@@ -1,10 +1,14 @@
-br.com.viktor.javawebpoc.exception.javawebpocexception=Houve um erro interno na aplicação
+br.com.viktor.javawebpoc.exception.javawebpocexception=Houve um erro interno na aplicação.
-br.com.viktor.javawebpoc.exception.alreadyexistsexception=Argumento já existente
-br.com.viktor.javawebpoc.exception.studentexistsexception=Estudante já existente: {0}
+br.com.viktor.javawebpoc.exception.alreadyexistsexception=Argumento já existente.
+br.com.viktor.javawebpoc.exception.studentexistsexception=Estudante já existente: {0}
-br.com.viktor.javawebpoc.exception.nullargumentexception=Argumento nulo: {0}
-br.com.viktor.javawebpoc.exception.argumentexception=Argumento inválido: {0}
-br.com.viktor.javawebpoc.exception.invalidstudentexception=Estudante inválido: {0}
+br.com.viktor.javawebpoc.exception.nullargumentexception=Argumento nulo: {0}.
+br.com.viktor.javawebpoc.exception.argumentexception=Argumento inválido: {0}.
+br.com.viktor.javawebpoc.exception.invalidstudentexception=Estudante inválido: {0}.
+
+br.com.viktor.javawebpoc.exception.notfoundexception=Não encontrado.
+
+br.com.viktor.javawebpoc.exception.jsonbadrequest=O JSON está mal formado.
+br.com.viktor.javawebpoc.exception.methodnotsupported=Método HTTP não disponÃvel.
-br.com.viktor.javawebpoc.exception.notfoundexception=Não encontrado
\ No newline at end of file
diff --git a/javawebpoc-web/src/main/resources/l10n/javawebpocValidation.properties b/javawebpoc-web/src/main/resources/l10n/javawebpocValidation.properties
deleted file mode 100644
index 89afa2b..0000000
--- a/javawebpoc-web/src/main/resources/l10n/javawebpocValidation.properties
+++ /dev/null
@@ -1,12 +0,0 @@
-br.com.viktor.javawebpoc.validation.studentinvalid=Invalid student
-br.com.viktor.javawebpoc.validation.studentnamesize=Student's name have to be between {0} and {1} caracters long
-br.com.viktor.javawebpoc.validation.studentnamenull=Student's name cannot be null
-
-
-br.com.viktor.javawebpoc.student=estudante
-br.com.viktor.javawebpoc.name=nome
-
-
-br.com.viktor.javawebpoc.validation.invalid=Invalido {0}.
-br.com.viktor.javawebpoc.validation.fieldrequired=A(o) {0} é obrigatório.
-br.com.viktor.javawebpoc.validation.stringlength=A(o) {0} precisa ter entre {1} e {2} caracteres.
diff --git a/javawebpoc-web/src/main/resources/l10n/javawebpocValidation_en_US.properties b/javawebpoc-web/src/main/resources/l10n/javawebpocValidation_en_US.properties
new file mode 100644
index 0000000..b2d964c
--- /dev/null
+++ b/javawebpoc-web/src/main/resources/l10n/javawebpocValidation_en_US.properties
@@ -0,0 +1,12 @@
+br.com.viktor.javawebpoc.validation.studentinvalid=Invalid student.
+br.com.viktor.javawebpoc.validation.studentnamesize=Student's name have to be between {0} and {1} caracters long.
+br.com.viktor.javawebpoc.validation.studentnamenull=Student's name cannot be null.
+
+
+br.com.viktor.javawebpoc.student=student
+br.com.viktor.javawebpoc.name=name
+
+
+br.com.viktor.javawebpoc.validation.invalid=Invalid {0}.
+br.com.viktor.javawebpoc.validation.fieldrequired=The {0} is required.
+br.com.viktor.javawebpoc.validation.stringlength=The {0} needs to be between {1} and {2} characters.
\ No newline at end of file
diff --git a/javawebpoc-web/src/main/resources/l10n/javawebpocValidation_pt_BR.properties b/javawebpoc-web/src/main/resources/l10n/javawebpocValidation_pt_BR.properties
index d7cac14..56bf032 100644
--- a/javawebpoc-web/src/main/resources/l10n/javawebpocValidation_pt_BR.properties
+++ b/javawebpoc-web/src/main/resources/l10n/javawebpocValidation_pt_BR.properties
@@ -1,3 +1,12 @@
-br.com.viktor.javawebpoc.validation.studentinvalid=Estudante inválido
-br.com.viktor.javawebpoc.validation.studentnamesize=O nome do estudante precisa estar entre {0} e {1} caracters
-br.com.viktor.javawebpoc.validation.studentnamenull=O nome do estudante não pode ser vazio
\ No newline at end of file
+br.com.viktor.javawebpoc.validation.studentinvalid=Estudante inválido.
+br.com.viktor.javawebpoc.validation.studentnamesize=O nome do estudante precisa estar entre {0} e {1} caracteres.
+br.com.viktor.javawebpoc.validation.studentnamenull=O nome do estudante não pode ser vazio.
+
+
+br.com.viktor.javawebpoc.student=estudante
+br.com.viktor.javawebpoc.name=nome
+
+
+br.com.viktor.javawebpoc.validation.invalid=Invalido {0}.
+br.com.viktor.javawebpoc.validation.fieldrequired=A(o) {0} é obrigatório.
+br.com.viktor.javawebpoc.validation.stringlength=A(o) {0} precisa ter entre {1} e {2} caracteres.
\ No newline at end of file
diff --git a/javawebpoc-web/src/main/resources/localizationContext.xml b/javawebpoc-web/src/main/resources/localizationContext.xml
index f60453d..e93a90d 100644
--- a/javawebpoc-web/src/main/resources/localizationContext.xml
+++ b/javawebpoc-web/src/main/resources/localizationContext.xml
@@ -13,6 +13,6 @@
l10n/javawebpocValidation
+
-
\ No newline at end of file