Class ApiController
java.lang.Object
edu.ucsb.cs156.organic.controllers.ApiController
- Direct Known Subclasses:
CoursesController
,JobsController
,SchoolsController
,StudentsController
,SystemInfoController
,UserInfoController
,UsersController
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected Object
genericMessage
(String message) This creates a plain old java object that can be returned as a JSON responseprotected CurrentUser
com.fasterxml.jackson.databind.ObjectMapper
Special ObjectMapper that ignores Mockito mocksException handler to return HTTP status code 403 Forbidden when an AccessDeniedException is thrownstatic com.fasterxml.jackson.databind.ObjectMapper
-
Constructor Details
-
ApiController
public ApiController()
-
-
Method Details
-
getCurrentUser
-
genericMessage
This creates a plain old java object that can be returned as a JSON response- Returns:
- a Map object with a single key/value pair: "message" => message
-
handleIllegalArgumentException
@ExceptionHandler(java.lang.IllegalArgumentException.class) @ResponseStatus(BAD_REQUEST) public Object handleIllegalArgumentException(Throwable e) -
handleGenericException
@ExceptionHandler(EntityNotFoundException.class) @ResponseStatus(NOT_FOUND) public Object handleGenericException(Throwable e) -
handleAccessDeniedException
@ExceptionHandler(org.springframework.security.access.AccessDeniedException.class) @ResponseStatus(FORBIDDEN) public Object handleAccessDeniedException(Throwable e) Exception handler to return HTTP status code 403 Forbidden when an AccessDeniedException is thrown- Parameters:
e
- AccessDeniedException- Returns:
- map with type and message
-
getMapper
public com.fasterxml.jackson.databind.ObjectMapper getMapper()Special ObjectMapper that ignores Mockito mocks- Returns:
- ObjectMapper mapper
-
mapperThatIgnoresMockitoMocks
public static com.fasterxml.jackson.databind.ObjectMapper mapperThatIgnoresMockitoMocks()
-