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
-
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
Get 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
-