Class ContactPreferencesService

java.lang.Object
restapi.services.ContactPreferencesService

@Service public class ContactPreferencesService extends Object
  • Field Details

  • Constructor Details

    • ContactPreferencesService

      public ContactPreferencesService()
  • Method Details

    • addPreferences

      public void addPreferences(long userId, long contactId)
      Set user's preferences for contact to default
      Parameters:
      userId - User whose preferences we are setting
      contactId - Contact who we are setting the preferences for
    • findFriends

      public ContactEntity findFriends(long user1, long user2) throws CustomNotFoundException
      Finds the contact entity between two users and returns it or throws exception when not found
      Parameters:
      user1 - Id for user
      user2 - Id for user
      Returns:
      The friendship as ContactEntity
      Throws:
      CustomNotFoundException - When user are not friends
    • updateRange

      public void updateRange(long userId, long contactId, long range) throws CustomNotFoundException
      Updates most restrictive range between users when needed
      Parameters:
      userId - Id of user
      contactId - Id of contact
      range - New parameter for range
      Throws:
      CustomNotFoundException - When user not found
    • updateBlocked

      public void updateBlocked(long userId, long contactId, boolean blocked) throws CustomNotFoundException
      Updates most restrictive blocked between users when needed
      Parameters:
      userId - Id of user
      contactId - Id of contact
      blocked - New value (boolean) for blocked
      Throws:
      CustomNotFoundException - When users are not friends
    • changeParam

      public void changeParam(long userId, long contactId, long param) throws CustomNotFoundException
      Updates blocked on contact's configurations for contact. Updates most restrictive blocked between users when needed
      Parameters:
      userId - Id of user
      contactId - Id of contact
      param - New value (boolean) for blocked
      Throws:
      CustomNotFoundException - When users are not friends
    • changeBlocked

      public void changeBlocked(long userId, long contactId, boolean blocked) throws CustomNotFoundException
      Updates blocked on contact's configurations for contact. Updates most restrictive blocked between users when needed
      Parameters:
      userId - Id of user
      contactId - Id of contact
      blocked - New value (boolean) for blocked
      Throws:
      CustomNotFoundException - When users are not friends
    • getContacts

      public RestList getContacts(long userId)
      Get all contacts' parameters and personal info
      Parameters:
      userId - Id of user
      Returns:
      RestList with ContactDTOs
    • getContactDTOFromEntity

      public ContactDTO getContactDTOFromEntity(ContactPreferencesEntity entity) throws CustomNotFoundException
      Transforms Contact Entity to Contact DTO
      Parameters:
      entity - Contact Entity
      Returns:
      Contact DTO
      Throws:
      CustomNotFoundException - When user in ContactEntity not found
    • getContactDTO

      public ContactDTO getContactDTO(long userId, long contactId) throws CustomNotFoundException
      Returns Contact DTO corresponding to preferences of user for contact
      Parameters:
      userId - Id of user
      contactId - Id of contact
      Returns:
      Contact DTO
      Throws:
      CustomNotFoundException - When users are no contacts or user in ContactEntity not found