Class EventController
- java.lang.Object
-
- edu.cnm.deepdive.picmegallery.controller.EventController
-
@RestController @RequestMapping("/events") @ExposesResourceFor(Event.class) public class EventController extends Object
This Class is a @RestController that handles the endpoints for communication between the client side to the serverside for the Events.
-
-
Constructor Summary
Constructors Constructor Description EventController(EventService eventService)
This Constructor creates an EventService object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
delete(long id, org.springframework.security.core.Authentication auth)
This delete method deletes an event by the specified event id.Event
get(long id, String passkey, org.springframework.security.core.Authentication auth)
This get method returns access to an Event in the PicMe Database, for those who did not originate the Event.List<Event>
getAllUserEvents(User user, org.springframework.security.core.Authentication auth)
This method gets all Events in the PicMeDatabase for a specified User.Event
getEvent(long id, org.springframework.security.core.Authentication auth)
This method gets the event specified for the User who created this event.List<Photo>
getPhotos(long id, String passkey, org.springframework.security.core.Authentication auth)
This method gets the photos associated with an Event in the PicMe Database, for those who did not originate the Event.List<Photo>
getPhotos(long id, org.springframework.security.core.Authentication auth)
This method gets the photos associated with an Event in the PicMe Database, for the Event originator/creator.Event
post(Event event, org.springframework.security.core.Authentication auth, String passkey, String name)
This is a post method that creates a new Event in the PicMe Database.
-
-
-
Constructor Detail
-
EventController
@Autowired public EventController(EventService eventService)
This Constructor creates an EventService object.- Parameters:
eventService
- is an EventService object.
-
-
Method Detail
-
post
@PostMapping(consumes="application/json", produces="application/json") public Event post(@RequestBody Event event, org.springframework.security.core.Authentication auth, String passkey, String name)
This is a post method that creates a new Event in the PicMe Database.- Parameters:
event
- is the event being created.auth
- is an authentication object.passkey
- is the associated passkey needed to get access to an Event.name
- is the name of the Event.- Returns:
- the created Event.
-
get
@GetMapping(value="/{id}", produces="application/json") public Event get(@PathVariable long id, @RequestHeader(value="Passkey",required=true) String passkey, org.springframework.security.core.Authentication auth)
This get method returns access to an Event in the PicMe Database, for those who did not originate the Event.- Parameters:
auth
- is the associated Authentication object.id
- is the associated Event id.passkey
- is the associated passkey.- Returns:
- access to the specified Event in the PicMeDatabase.
-
getEvent
@GetMapping(value="/{id}/creator", produces="application/json") public Event getEvent(@PathVariable long id, org.springframework.security.core.Authentication auth)
This method gets the event specified for the User who created this event.- Parameters:
id
- the associated event idauth
- the authentication object- Returns:
- the event for the creator.
-
getPhotos
@GetMapping(value="/{id}/photos", produces="application/json") public List<Photo> getPhotos(@PathVariable long id, @RequestHeader(value="Passkey",required=true) String passkey, org.springframework.security.core.Authentication auth)
This method gets the photos associated with an Event in the PicMe Database, for those who did not originate the Event. Hence a passkey is required.- Parameters:
id
- id the primary key associated with the specific event object.passkey
- is the associated passkey for an event.auth
- auth the auth object and source of authentication for a specified user.- Returns:
- a List of photos
-
getPhotos
@GetMapping(value="/{id}/photos/creator", produces="application/json") public List<Photo> getPhotos(@PathVariable long id, org.springframework.security.core.Authentication auth)
This method gets the photos associated with an Event in the PicMe Database, for the Event originator/creator.- Parameters:
id
- the primary key associated with the specific event object.auth
- the auth object and source of authentication for a specified user.- Returns:
- a List of photos
-
getAllUserEvents
@GetMapping(produces="application/json") public List<Event> getAllUserEvents(User user, org.springframework.security.core.Authentication auth)
This method gets all Events in the PicMeDatabase for a specified User.- Parameters:
user
- is a User object.auth
- is an Authentication object.- Returns:
- a list of events associated with a specific User.
-
delete
@DeleteMapping(value="/{id}", consumes="application/json") public void delete(@PathVariable long id, org.springframework.security.core.Authentication auth)
This delete method deletes an event by the specified event id.- Parameters:
id
- the primary key associated with the specific event object.auth
- is an Authentication object.
-
-