Class ApiController
java.lang.Object
edu.ucsb.cs156.dining.controllers.ApiController
- Direct Known Subclasses:
AdminController,DiningCommonsController,ModeratorController,ReviewController,SystemInfoController,UCSBDiningMenuController,UCSBDiningMenuItemsController,UserInfoController,UsersController
This is an abstract class that provides common functionality for all API controllers.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected ObjectgenericMessage(String message) This method returns a generic message.protected CurrentUserThis method returns the current user.This method handles the EntityNotFoundException.This method handles the UnsupportedOperationException.
-
Constructor Details
-
ApiController
public ApiController()
-
-
Method Details
-
getCurrentUser
This method returns the current user.- Returns:
- the current user
-
genericMessage
This method returns a generic message.- Parameters:
message- the message- Returns:
- a map with the message
-
handleGenericException
@ExceptionHandler(EntityNotFoundException.class) @ResponseStatus(NOT_FOUND) public Object handleGenericException(Throwable e) This method handles the EntityNotFoundException.- Parameters:
e- the exception- Returns:
- a map with the type and message of the exception
-
handleUnsupportedOperation
@ExceptionHandler(java.lang.UnsupportedOperationException.class) public org.springframework.http.ResponseEntity<Map<String,String>> handleUnsupportedOperation(UnsupportedOperationException e) This method handles the UnsupportedOperationException. This maps to a 403/Forbidden.- Parameters:
e- the exception- Returns:
- a map with the type and message of the exception
-