Class RelationshipController


  • @RestController
    @ExposesResourceFor(Relationship.class)
    public class RelationshipController
    extends java.lang.Object
    RelationshipController provides endpoints which allow the client to access data relating to Relationship.
    Since:
    1.0
    Version:
    1.0
    Author:
    Robert Dominugez, Roderick Frechette, Laura Steiner
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.List<Relationship> myFollows​(org.springframework.security.core.Authentication auth)
      Gets all relationships in which the current user is following another user.
      java.util.List<Relationship> myFriends​(org.springframework.security.core.Authentication auth)
      Gets all relationships in which the current user is a friend.
      java.util.List<Relationship> myPendingRequests​(org.springframework.security.core.Authentication auth)
      Gets all relationships in which the user has received a friend request and hasn't yet responded.
      Relationship requestFriendship​(org.springframework.security.core.Authentication auth, User user)
      Creates a relationship between the current user and another user.
      boolean setFriendshipAccepted​(org.springframework.security.core.Authentication auth, long relationshipId, boolean accepted)
      Updates a relationship between two users.
      Relationship startFollowing​(org.springframework.security.core.Authentication auth, User user)
      Lets the current user start following another user.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • RelationshipController

        public RelationshipController​(RelationshipService relationshipService,
                                      UserService userService)
        Autowired constructor for RelationshipController.
        Parameters:
        relationshipService - RelationshipService
        userService - UserService
    • Method Detail

      • myFriends

        @GetMapping(value="/friendships",
                    produces="application/json")
        public java.util.List<Relationship> myFriends​(org.springframework.security.core.Authentication auth)
        Gets all relationships in which the current user is a friend.
        Parameters:
        auth - Authentication
        Returns:
        List<Relationship>
      • myFollows

        @GetMapping(value="/follows",
                    produces="application/json")
        public java.util.List<Relationship> myFollows​(org.springframework.security.core.Authentication auth)
        Gets all relationships in which the current user is following another user.
        Parameters:
        auth - Authentication
        Returns:
        List<Relationship>
      • myPendingRequests

        @GetMapping(value="/pending",
                    produces="application/json")
        public java.util.List<Relationship> myPendingRequests​(org.springframework.security.core.Authentication auth)
        Gets all relationships in which the user has received a friend request and hasn't yet responded.
        Parameters:
        auth - Authentication
        Returns:
        List<Relationship>
      • requestFriendship

        @ResponseStatus(CREATED)
        @PostMapping(value="/friendships",
                     consumes="application/json",
                     produces="application/json")
        public Relationship requestFriendship​(org.springframework.security.core.Authentication auth,
                                              @RequestBody
                                              User user)
        Creates a relationship between the current user and another user. This relationship is not yet a friendship, but is a follow and a friend request rolled into one.
        Parameters:
        auth - Authentication
        user - User
        Returns:
        a new relationship between two users.
      • startFollowing

        @ResponseStatus(CREATED)
        @PostMapping(value="/follows",
                     consumes="application/json",
                     produces="application/json")
        public Relationship startFollowing​(org.springframework.security.core.Authentication auth,
                                           @RequestBody
                                           User user)
        Lets the current user start following another user.
        Parameters:
        auth - Authentication
        user - User
        Returns:
        a new relationship following another user
      • setFriendshipAccepted

        @PutMapping(value="/friendships/{relationshipId}",
                    consumes="application/json",
                    produces="application/json")
        public boolean setFriendshipAccepted​(org.springframework.security.core.Authentication auth,
                                             @PathVariable
                                             long relationshipId,
                                             @RequestBody
                                             boolean accepted)
        Updates a relationship between two users.
        Parameters:
        auth - Authentication
        relationshipId - long
        accepted - boolean
        Returns:
        the updated relationship