Class ApiController
java.lang.Object
edu.ucsb.cs156.gauchoride.controllers.ApiController
- Direct Known Subclasses:
 ChatMessageController,DriverAvailabilityController,DriversController,RideController,RiderApplicationController,ShiftController,SystemInfoController,UserInfoController,UserProfileController,UsersController
Base class for all API controllers.
 
 Provides a method to get the current user as well as common methods for
 error handling.
- 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionprotected ObjectgenericMessage(String message) This creates a plain old java object that can be returned as a JSON responseprotected CurrentUserGet the current userThis catches any EntityNotFoundExceptions and returns a 404 (NOT_FOUND) response 
- 
Constructor Details
- 
ApiController
public ApiController() 
 - 
 - 
Method Details
- 
getCurrentUser
Get the current user- Returns:
 - the current user
 
 - 
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
 
 - 
handleGenericException
@ExceptionHandler(EntityNotFoundException.class) @ResponseStatus(NOT_FOUND) public Object handleGenericException(Throwable e) This catches any EntityNotFoundExceptions and returns a 404 (NOT_FOUND) response- Returns:
 - a Map object that can be returned as a JSON response
 
 
 -