Package restapi.services
Class ContactPreferencesService
java.lang.Object
restapi.services.ContactPreferencesService
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate @NonNull ContactPreferencesRepository
private @NonNull ContactRepository
private final @NonNull LocationService
private @NonNull UserService
private @NonNull UserSessionService
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addPreferences
(long userId, long contactId) Set user's preferences for contact to defaultvoid
changeBlocked
(long userId, long contactId, boolean blocked) Updates blocked on contact's configurations for contact.void
changeParam
(long userId, long contactId, long param) Updates blocked on contact's configurations for contact.findFriends
(long user1, long user2) Finds the contact entity between two users and returns it or throws exception when not foundgetContactDTO
(long userId, long contactId) Returns Contact DTO corresponding to preferences of user for contactTransforms Contact Entity to Contact DTOgetContacts
(long userId) Get all contacts' parameters and personal infovoid
updateBlocked
(long userId, long contactId, boolean blocked) Updates most restrictive blocked between users when neededvoid
updateRange
(long userId, long contactId, long range) Updates most restrictive range between users when needed
-
Field Details
-
contactRepository
-
contactPreferencesRepository
-
userService
-
userSessionService
-
locationService
-
-
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 settingcontactId
- Contact who we are setting the preferences for
-
findFriends
Finds the contact entity between two users and returns it or throws exception when not found- Parameters:
user1
- Id for useruser2
- Id for user- Returns:
- The friendship as ContactEntity
- Throws:
CustomNotFoundException
- When user are not friends
-
updateRange
Updates most restrictive range between users when needed- Parameters:
userId
- Id of usercontactId
- Id of contactrange
- 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 usercontactId
- Id of contactblocked
- New value (boolean) for blocked- Throws:
CustomNotFoundException
- When users are not friends
-
changeParam
Updates blocked on contact's configurations for contact. Updates most restrictive blocked between users when needed- Parameters:
userId
- Id of usercontactId
- Id of contactparam
- 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 usercontactId
- Id of contactblocked
- New value (boolean) for blocked- Throws:
CustomNotFoundException
- When users are not friends
-
getContacts
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
Returns Contact DTO corresponding to preferences of user for contact- Parameters:
userId
- Id of usercontactId
- Id of contact- Returns:
- Contact DTO
- Throws:
CustomNotFoundException
- When users are no contacts or user in ContactEntity not found
-