Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Alba María Álvarez
/
AppRecetas
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
00497e1e
authored
Jun 15, 2025
by
Alba María Álvarez
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
refactor(exception): cambio nombre excepción UnprocessableEntityException
parent
5077971f
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
22 additions
and
28 deletions
src/main/java/com/example/apprecetas/exceptions/EntityNotFoundException.java → src/main/java/com/example/apprecetas/exception/EntityNotFoundException.java
src/main/java/com/example/apprecetas/exceptions/ErrorMessage.java → src/main/java/com/example/apprecetas/exception/ErrorMessage.java
src/main/java/com/example/apprecetas/exceptions/ExceptionController.java → src/main/java/com/example/apprecetas/exception/ExceptionController.java
src/main/java/com/example/apprecetas/exceptions/UnvalidInputEntityException.java → src/main/java/com/example/apprecetas/exception/UnprocessableEntityException.java
src/main/java/com/example/apprecetas/recipe/application/impl/DeleteRecipeUseCaseImpl.java
src/main/java/com/example/apprecetas/recipe/application/impl/ReadRecipeUseCaseImpl.java
src/main/java/com/example/apprecetas/recipe/infrastructure/controller/CreateRecipeController.java
src/main/java/com/example/apprecetas/recipe/infrastructure/controller/UpdateRecipeController.java
src/main/java/com/example/apprecetas/recipe/infrastructure/repository/impl/UpdateRecipeRepositoryImpl.java
src/main/java/com/example/apprecetas/user/application/impl/DeleteUserUseCaseImpl.java
src/main/java/com/example/apprecetas/user/application/impl/ReadUserUseCaseImpl.java
src/main/java/com/example/apprecetas/user/application/impl/UpdateUserUseCaseImpl.java
src/main/java/com/example/apprecetas/user/infrastructure/controller/CreateUserController.java
src/main/java/com/example/apprecetas/user/infrastructure/controller/UpdateUserController.java
src/main/java/com/example/apprecetas/exception
s
/EntityNotFoundException.java
→
src/main/java/com/example/apprecetas/exception/EntityNotFoundException.java
View file @
00497e1e
package
com
.
example
.
apprecetas
.
exception
s
;
package
com
.
example
.
apprecetas
.
exception
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.web.bind.annotation.ResponseStatus
;
import
org.springframework.web.bind.annotation.ResponseStatus
;
...
...
src/main/java/com/example/apprecetas/exception
s
/ErrorMessage.java
→
src/main/java/com/example/apprecetas/exception/ErrorMessage.java
View file @
00497e1e
package
com
.
example
.
apprecetas
.
exception
s
;
package
com
.
example
.
apprecetas
.
exception
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
...
...
src/main/java/com/example/apprecetas/exception
s
/ExceptionController.java
→
src/main/java/com/example/apprecetas/exception/ExceptionController.java
View file @
00497e1e
package
com
.
example
.
apprecetas
.
exception
s
;
package
com
.
example
.
apprecetas
.
exception
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.HttpStatusCode
;
import
org.springframework.http.HttpStatusCode
;
...
@@ -12,10 +12,9 @@ import java.time.LocalDateTime;
...
@@ -12,10 +12,9 @@ import java.time.LocalDateTime;
@RestControllerAdvice
@RestControllerAdvice
public
class
ExceptionController
{
public
class
ExceptionController
{
//MethodArgumentNotValidException
@ExceptionHandler
(
UnprocessableEntityException
.
class
)
@ExceptionHandler
(
UnvalidInputEntityException
.
class
)
@ResponseStatus
(
HttpStatus
.
BAD_REQUEST
)
@ResponseStatus
(
HttpStatus
.
BAD_REQUEST
)
public
ResponseEntity
<
ErrorMessage
>
handle
(
Un
validInput
EntityException
ex
)
{
public
ResponseEntity
<
ErrorMessage
>
handle
(
Un
processable
EntityException
ex
)
{
return
new
ResponseEntity
<>(
new
ErrorMessage
(
LocalDateTime
.
now
(),
HttpStatus
.
BAD_REQUEST
.
value
(),
return
new
ResponseEntity
<>(
new
ErrorMessage
(
LocalDateTime
.
now
(),
HttpStatus
.
BAD_REQUEST
.
value
(),
ex
.
getMessage
()),
HttpStatusCode
.
valueOf
(
HttpStatus
.
BAD_REQUEST
.
value
()));
ex
.
getMessage
()),
HttpStatusCode
.
valueOf
(
HttpStatus
.
BAD_REQUEST
.
value
()));
}
}
...
...
src/main/java/com/example/apprecetas/exception
s/UnvalidInput
EntityException.java
→
src/main/java/com/example/apprecetas/exception
/Unprocessable
EntityException.java
View file @
00497e1e
package
com
.
example
.
apprecetas
.
exception
s
;
package
com
.
example
.
apprecetas
.
exception
;
public
class
Un
validInput
EntityException
extends
RuntimeException
{
public
class
Un
processable
EntityException
extends
RuntimeException
{
public
Un
validInput
EntityException
(
String
message
)
{
public
Un
processable
EntityException
(
String
message
)
{
super
(
message
);
super
(
message
);
}
}
}
}
src/main/java/com/example/apprecetas/recipe/application/impl/DeleteRecipeUseCaseImpl.java
View file @
00497e1e
package
com
.
example
.
apprecetas
.
recipe
.
application
.
impl
;
package
com
.
example
.
apprecetas
.
recipe
.
application
.
impl
;
import
com.example.apprecetas.exception
s
.EntityNotFoundException
;
import
com.example.apprecetas.exception.EntityNotFoundException
;
import
com.example.apprecetas.recipe.application.DeleteRecipeUseCase
;
import
com.example.apprecetas.recipe.application.DeleteRecipeUseCase
;
import
com.example.apprecetas.recipe.domain.repository.DeleteRecipeRepository
;
import
com.example.apprecetas.recipe.domain.repository.DeleteRecipeRepository
;
import
com.example.apprecetas.recipe.domain.repository.ReadRecipeRepository
;
import
com.example.apprecetas.recipe.domain.repository.ReadRecipeRepository
;
import
com.example.apprecetas.recipe.infrastructure.repository.jpa.RecipeJpa
;
import
com.example.apprecetas.recipe.infrastructure.repository.jpa.RecipeJpa
;
import
lombok.RequiredArgsConstructor
;
import
lombok.RequiredArgsConstructor
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
@Service
@Service
...
...
src/main/java/com/example/apprecetas/recipe/application/impl/ReadRecipeUseCaseImpl.java
View file @
00497e1e
package
com
.
example
.
apprecetas
.
recipe
.
application
.
impl
;
package
com
.
example
.
apprecetas
.
recipe
.
application
.
impl
;
import
com.example.apprecetas.exception
s
.EntityNotFoundException
;
import
com.example.apprecetas.exception.EntityNotFoundException
;
import
com.example.apprecetas.recipe.application.ReadRecipeUseCase
;
import
com.example.apprecetas.recipe.application.ReadRecipeUseCase
;
import
com.example.apprecetas.recipe.domain.repository.ReadRecipeRepository
;
import
com.example.apprecetas.recipe.domain.repository.ReadRecipeRepository
;
import
com.example.apprecetas.recipe.infrastructure.controller.dto.output.RecipeOutputDto
;
import
com.example.apprecetas.recipe.infrastructure.controller.dto.output.RecipeOutputDto
;
...
@@ -8,7 +8,6 @@ import com.example.apprecetas.recipe.infrastructure.mapper.RecipeMapper;
...
@@ -8,7 +8,6 @@ import com.example.apprecetas.recipe.infrastructure.mapper.RecipeMapper;
import
com.example.apprecetas.recipe.infrastructure.repository.jpa.RecipeJpa
;
import
com.example.apprecetas.recipe.infrastructure.repository.jpa.RecipeJpa
;
import
lombok.RequiredArgsConstructor
;
import
lombok.RequiredArgsConstructor
;
import
org.mapstruct.factory.Mappers
;
import
org.mapstruct.factory.Mappers
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
import
java.util.List
;
...
...
src/main/java/com/example/apprecetas/recipe/infrastructure/controller/CreateRecipeController.java
View file @
00497e1e
package
com
.
example
.
apprecetas
.
recipe
.
infrastructure
.
controller
;
package
com
.
example
.
apprecetas
.
recipe
.
infrastructure
.
controller
;
import
com.example.apprecetas.exception
s.UnvalidInput
EntityException
;
import
com.example.apprecetas.exception
.Unprocessable
EntityException
;
import
com.example.apprecetas.recipe.application.CreateRecipeUseCase
;
import
com.example.apprecetas.recipe.application.CreateRecipeUseCase
;
import
com.example.apprecetas.recipe.infrastructure.controller.dto.input.RecipeInputDto
;
import
com.example.apprecetas.recipe.infrastructure.controller.dto.input.RecipeInputDto
;
import
com.example.apprecetas.recipe.infrastructure.controller.dto.output.RecipeOutputDto
;
import
com.example.apprecetas.recipe.infrastructure.controller.dto.output.RecipeOutputDto
;
import
jakarta.validation.Valid
;
import
jakarta.validation.Valid
;
import
lombok.RequiredArgsConstructor
;
import
lombok.RequiredArgsConstructor
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.validation.BindingResult
;
import
org.springframework.validation.BindingResult
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
...
@@ -30,7 +29,7 @@ public class CreateRecipeController {
...
@@ -30,7 +29,7 @@ public class CreateRecipeController {
String
errorMsg
=
result
.
getFieldErrors
().
stream
()
String
errorMsg
=
result
.
getFieldErrors
().
stream
()
.
map
(
fieldError
->
fieldError
.
getField
()
+
": "
+
fieldError
.
getDefaultMessage
())
.
map
(
fieldError
->
fieldError
.
getField
()
+
": "
+
fieldError
.
getDefaultMessage
())
.
collect
(
Collectors
.
joining
(
";"
));
.
collect
(
Collectors
.
joining
(
";"
));
throw
new
Un
validInput
EntityException
(
errorMsg
);
throw
new
Un
processable
EntityException
(
errorMsg
);
}
}
URI
location
=
URI
.
create
(
"recipe"
);
URI
location
=
URI
.
create
(
"recipe"
);
return
ResponseEntity
.
created
(
location
).
body
(
service
.
create
(
recipeInputDto
));
return
ResponseEntity
.
created
(
location
).
body
(
service
.
create
(
recipeInputDto
));
...
...
src/main/java/com/example/apprecetas/recipe/infrastructure/controller/UpdateRecipeController.java
View file @
00497e1e
package
com
.
example
.
apprecetas
.
recipe
.
infrastructure
.
controller
;
package
com
.
example
.
apprecetas
.
recipe
.
infrastructure
.
controller
;
import
com.example.apprecetas.exception
s.UnvalidInput
EntityException
;
import
com.example.apprecetas.exception
.Unprocessable
EntityException
;
import
com.example.apprecetas.recipe.application.UpdateRecipeUseCase
;
import
com.example.apprecetas.recipe.application.UpdateRecipeUseCase
;
import
lombok.RequiredArgsConstructor
;
import
lombok.RequiredArgsConstructor
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.ResponseEntity
;
import
com.example.apprecetas.recipe.infrastructure.controller.dto.input.RecipeInputDto
;
import
com.example.apprecetas.recipe.infrastructure.controller.dto.input.RecipeInputDto
;
import
com.example.apprecetas.recipe.infrastructure.controller.dto.output.RecipeOutputDto
;
import
com.example.apprecetas.recipe.infrastructure.controller.dto.output.RecipeOutputDto
;
import
jakarta.validation.Valid
;
import
jakarta.validation.Valid
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.BindingResult
;
import
org.springframework.validation.BindingResult
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
...
@@ -26,7 +25,7 @@ public class UpdateRecipeController {
...
@@ -26,7 +25,7 @@ public class UpdateRecipeController {
String
errorMsg
=
result
.
getFieldErrors
().
stream
()
String
errorMsg
=
result
.
getFieldErrors
().
stream
()
.
map
(
fieldError
->
fieldError
.
getField
()
+
": "
+
fieldError
.
getDefaultMessage
())
.
map
(
fieldError
->
fieldError
.
getField
()
+
": "
+
fieldError
.
getDefaultMessage
())
.
collect
(
Collectors
.
joining
(
";"
));
.
collect
(
Collectors
.
joining
(
";"
));
throw
new
Un
validInput
EntityException
(
errorMsg
);
throw
new
Un
processable
EntityException
(
errorMsg
);
}
}
return
ResponseEntity
.
ok
().
body
(
service
.
update
(
id
,
recipeInputDto
));
return
ResponseEntity
.
ok
().
body
(
service
.
update
(
id
,
recipeInputDto
));
}
}
...
...
src/main/java/com/example/apprecetas/recipe/infrastructure/repository/impl/UpdateRecipeRepositoryImpl.java
View file @
00497e1e
package
com
.
example
.
apprecetas
.
recipe
.
infrastructure
.
repository
.
impl
;
package
com
.
example
.
apprecetas
.
recipe
.
infrastructure
.
repository
.
impl
;
import
com.example.apprecetas.exception
s
.EntityNotFoundException
;
import
com.example.apprecetas.exception.EntityNotFoundException
;
import
com.example.apprecetas.recipe.domain.repository.UpdateRecipeRepository
;
import
com.example.apprecetas.recipe.domain.repository.UpdateRecipeRepository
;
import
com.example.apprecetas.recipe.infrastructure.repository.jpa.RecipeJpa
;
import
com.example.apprecetas.recipe.infrastructure.repository.jpa.RecipeJpa
;
import
com.example.apprecetas.recipe.infrastructure.repository.jpa.RecipeRepositoryJpa
;
import
com.example.apprecetas.recipe.infrastructure.repository.jpa.RecipeRepositoryJpa
;
import
lombok.RequiredArgsConstructor
;
import
lombok.RequiredArgsConstructor
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Repository
;
import
org.springframework.stereotype.Repository
;
@Repository
@Repository
...
...
src/main/java/com/example/apprecetas/user/application/impl/DeleteUserUseCaseImpl.java
View file @
00497e1e
package
com
.
example
.
apprecetas
.
user
.
application
.
impl
;
package
com
.
example
.
apprecetas
.
user
.
application
.
impl
;
import
com.example.apprecetas.exception
s
.EntityNotFoundException
;
import
com.example.apprecetas.exception.EntityNotFoundException
;
import
com.example.apprecetas.user.application.DeleteUserUseCase
;
import
com.example.apprecetas.user.application.DeleteUserUseCase
;
import
com.example.apprecetas.user.domain.repository.DeleteUserRepository
;
import
com.example.apprecetas.user.domain.repository.DeleteUserRepository
;
import
com.example.apprecetas.user.domain.repository.ReadUserRepository
;
import
com.example.apprecetas.user.domain.repository.ReadUserRepository
;
...
...
src/main/java/com/example/apprecetas/user/application/impl/ReadUserUseCaseImpl.java
View file @
00497e1e
package
com
.
example
.
apprecetas
.
user
.
application
.
impl
;
package
com
.
example
.
apprecetas
.
user
.
application
.
impl
;
import
com.example.apprecetas.exception
s
.EntityNotFoundException
;
import
com.example.apprecetas.exception.EntityNotFoundException
;
import
com.example.apprecetas.user.application.ReadUserUseCase
;
import
com.example.apprecetas.user.application.ReadUserUseCase
;
import
com.example.apprecetas.user.domain.repository.ReadUserRepository
;
import
com.example.apprecetas.user.domain.repository.ReadUserRepository
;
import
com.example.apprecetas.user.infrastructure.controller.dto.UserOutputDto
;
import
com.example.apprecetas.user.infrastructure.controller.dto.UserOutputDto
;
...
...
src/main/java/com/example/apprecetas/user/application/impl/UpdateUserUseCaseImpl.java
View file @
00497e1e
package
com
.
example
.
apprecetas
.
user
.
application
.
impl
;
package
com
.
example
.
apprecetas
.
user
.
application
.
impl
;
import
com.example.apprecetas.exception
s
.EntityNotFoundException
;
import
com.example.apprecetas.exception.EntityNotFoundException
;
import
com.example.apprecetas.user.application.UpdateUserUseCase
;
import
com.example.apprecetas.user.application.UpdateUserUseCase
;
import
com.example.apprecetas.user.domain.repository.ReadUserRepository
;
import
com.example.apprecetas.user.domain.repository.ReadUserRepository
;
import
com.example.apprecetas.user.domain.repository.UpdateUserRepository
;
import
com.example.apprecetas.user.domain.repository.UpdateUserRepository
;
...
...
src/main/java/com/example/apprecetas/user/infrastructure/controller/CreateUserController.java
View file @
00497e1e
package
com
.
example
.
apprecetas
.
user
.
infrastructure
.
controller
;
package
com
.
example
.
apprecetas
.
user
.
infrastructure
.
controller
;
import
com.example.apprecetas.exception
s.UnvalidInput
EntityException
;
import
com.example.apprecetas.exception
.Unprocessable
EntityException
;
import
com.example.apprecetas.user.application.CreateUserUseCase
;
import
com.example.apprecetas.user.application.CreateUserUseCase
;
import
com.example.apprecetas.user.infrastructure.controller.dto.UserInputDto
;
import
com.example.apprecetas.user.infrastructure.controller.dto.UserInputDto
;
import
com.example.apprecetas.user.infrastructure.controller.dto.UserOutputDto
;
import
com.example.apprecetas.user.infrastructure.controller.dto.UserOutputDto
;
...
@@ -29,7 +29,7 @@ public class CreateUserController {
...
@@ -29,7 +29,7 @@ public class CreateUserController {
String
errorMsg
=
result
.
getFieldErrors
().
stream
()
String
errorMsg
=
result
.
getFieldErrors
().
stream
()
.
map
(
fieldError
->
fieldError
.
getField
()
+
": "
+
fieldError
.
getDefaultMessage
())
.
map
(
fieldError
->
fieldError
.
getField
()
+
": "
+
fieldError
.
getDefaultMessage
())
.
collect
(
Collectors
.
joining
(
"; "
));
.
collect
(
Collectors
.
joining
(
"; "
));
throw
new
Un
validInput
EntityException
(
errorMsg
);
throw
new
Un
processable
EntityException
(
errorMsg
);
}
}
URI
location
=
URI
.
create
(
"/user"
);
URI
location
=
URI
.
create
(
"/user"
);
return
ResponseEntity
.
created
(
location
).
body
(
service
.
create
(
userInputDto
));
return
ResponseEntity
.
created
(
location
).
body
(
service
.
create
(
userInputDto
));
...
...
src/main/java/com/example/apprecetas/user/infrastructure/controller/UpdateUserController.java
View file @
00497e1e
package
com
.
example
.
apprecetas
.
user
.
infrastructure
.
controller
;
package
com
.
example
.
apprecetas
.
user
.
infrastructure
.
controller
;
import
com.example.apprecetas.exception
s.UnvalidInput
EntityException
;
import
com.example.apprecetas.exception
.Unprocessable
EntityException
;
import
com.example.apprecetas.user.application.UpdateUserUseCase
;
import
com.example.apprecetas.user.application.UpdateUserUseCase
;
import
com.example.apprecetas.user.infrastructure.controller.dto.UserInputDto
;
import
com.example.apprecetas.user.infrastructure.controller.dto.UserInputDto
;
import
com.example.apprecetas.user.infrastructure.controller.dto.UserOutputDto
;
import
com.example.apprecetas.user.infrastructure.controller.dto.UserOutputDto
;
...
@@ -25,7 +25,7 @@ public class UpdateUserController {
...
@@ -25,7 +25,7 @@ public class UpdateUserController {
String
errorMsg
=
result
.
getFieldErrors
().
stream
()
String
errorMsg
=
result
.
getFieldErrors
().
stream
()
.
map
(
fieldError
->
fieldError
.
getField
()
+
": "
+
fieldError
.
getDefaultMessage
())
.
map
(
fieldError
->
fieldError
.
getField
()
+
": "
+
fieldError
.
getDefaultMessage
())
.
collect
(
Collectors
.
joining
(
"; "
));
.
collect
(
Collectors
.
joining
(
"; "
));
throw
new
Un
validInput
EntityException
(
errorMsg
);
throw
new
Un
processable
EntityException
(
errorMsg
);
}
}
return
ResponseEntity
.
ok
().
body
(
service
.
updateById
(
id
,
userInputDto
));
return
ResponseEntity
.
ok
().
body
(
service
.
updateById
(
id
,
userInputDto
));
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment