Class ProfileController


  • @RestController
    @RequestMapping("/profiles")
    @ExposesResourceFor(Profile.class)
    public class ProfileController
    extends Object
    The ProfileController class is the @RestController that maps the endpoints of "/profiles" for communication between the server-side and client-side for Profile
    • Constructor Summary

      Constructors 
      Constructor Description
      ProfileController​(ProfileService profileService)
      Constructs the instance of ProfileService object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      String getAddress​(org.springframework.security.core.Authentication auth)
      The Get method which returns the profile address.
      org.springframework.http.ResponseEntity<org.springframework.core.io.Resource> getImage​(org.springframework.security.core.Authentication auth)
      The Get method which returns the profile image.
      Profile getOrder​(Long userId, org.springframework.security.core.Authentication auth)
      The Get method which returns the Profile matching the ID provided.
      String getUsername​(org.springframework.security.core.Authentication auth)
      The Get method which returns the username for the current user.
      Profile me​(org.springframework.security.core.Authentication auth)
      The Get method which returns the current authenticated profile.
      String updateAddress​(String address, org.springframework.security.core.Authentication auth)
      The Put method which lets the current user update their address.
      String updateUsername​(String name, org.springframework.security.core.Authentication auth)
      The Put method which allows the profile to update their username
      Profile uploadImage​(org.springframework.web.multipart.MultipartFile file, org.springframework.security.core.Authentication auth)
      The Put method which updates the current user's profile image.
    • Constructor Detail

      • ProfileController

        public ProfileController​(ProfileService profileService)
        Constructs the instance of ProfileService object.
        Parameters:
        profileService - The ProfileService to be created.
    • Method Detail

      • me

        @GetMapping(value="/me",
                    produces="application/json")
        public Profile me​(org.springframework.security.core.Authentication auth)
        The Get method which returns the current authenticated profile.
        Parameters:
        auth - The user authentication.
      • getOrder

        @GetMapping(value="/{userId:\\d+}",
                    produces="application/json")
        public Profile getOrder​(@PathVariable
                                Long userId,
                                org.springframework.security.core.Authentication auth)
        The Get method which returns the Profile matching the ID provided.
        Parameters:
        userId - The ID of the Profile requested.
        auth - The user authentication.
        Returns:
        The Profile matching the ID provided.
      • getUsername

        @GetMapping(value="/me/username",
                    produces="application/json")
        public String getUsername​(org.springframework.security.core.Authentication auth)
        The Get method which returns the username for the current user.
        Parameters:
        auth - The user authentication.
        Returns:
        The current user's username.
      • updateUsername

        @PutMapping(value="/me/username",
                    consumes="application/json",
                    produces="application/json")
        public String updateUsername​(@RequestBody
                                     String name,
                                     org.springframework.security.core.Authentication auth)
        The Put method which allows the profile to update their username
        Parameters:
        name - The new username.
        auth - The user authentication.
        Returns:
        The updated username.
      • getImage

        @GetMapping("/me/image")
        public org.springframework.http.ResponseEntity<org.springframework.core.io.Resource> getImage​(org.springframework.security.core.Authentication auth)
                                                                                               throws IOException
        The Get method which returns the profile image.
        Parameters:
        auth - The user authentication.
        Returns:
        The user's current profile image.
        Throws:
        IOException
      • uploadImage

        @PutMapping(value="/me/image",
                    produces="application/json")
        public Profile uploadImage​(@RequestBody
                                   org.springframework.web.multipart.MultipartFile file,
                                   org.springframework.security.core.Authentication auth)
                            throws IOException
        The Put method which updates the current user's profile image.
        Parameters:
        file - The path to the new image.
        auth - The user authentication.
        Returns:
        The updated profile image.
        Throws:
        IOException - If the file cannot be accessed from the reference provided.
      • getAddress

        @GetMapping(value="/me/address",
                    produces="application/json")
        public String getAddress​(org.springframework.security.core.Authentication auth)
        The Get method which returns the profile address.
        Parameters:
        auth - The user authentication.
        Returns:
        The user's current address.
      • updateAddress

        @PutMapping(value="/me/address",
                    consumes="application/json",
                    produces="application/json")
        public String updateAddress​(@RequestBody
                                    String address,
                                    org.springframework.security.core.Authentication auth)
        The Put method which lets the current user update their address.
        Parameters:
        address - The new user address.
        auth - The user authentication.
        Returns:
        The updated user address.