@@ -26,31 +26,31 @@ public class SubscriptionService {
2626
2727 /// Fetches an existing repository from the database or creates a new one if none is found
2828 ///
29- /// @param dto the [SubscriptionDTO.SubscriptionCreateDTO] containing the subscriptionEntity data
29+ /// @param dto the [SubscriptionDTO.SubscriptionCreateDTO] containing the subscription data
3030 /// @return the fetched or created [SubscriptionEntity]
3131 protected SubscriptionEntity fetchOrCreateSubscription (SubscriptionDTO .SubscriptionCreateDTO dto ) {
3232 UUID feedUuid = UUID .fromString (dto .uuid ());
3333 return subscriptionRepository
3434 .findByUuid (feedUuid )
3535 .orElseGet (() -> {
36- log .debug ("Creating new subscriptionEntity with UUID {}" , dto .uuid ());
36+ log .debug ("Creating new subscription with UUID {}" , dto .uuid ());
3737 return subscriptionRepository .save (subscriptionMapper .toEntity (dto ));
3838 });
3939 }
4040
41- /// Fetches a single subscriptionEntity for an authenticated userEntity, if it exists
41+ /// Fetches a single subscription for an authenticated userEntity, if it exists
4242 ///
43- /// @param subscriptionUuid the UUID of the subscriptionEntity
44- /// @param userId the database ID of the userEntity
45- /// @return a [SubscriptionDTO.UserSubscriptionDTO] of the userEntity subscriptionEntity
43+ /// @param subscriptionUuid the UUID of the subscription
44+ /// @param userId the database ID of the user
45+ /// @return a [SubscriptionDTO.UserSubscriptionDTO] of the user subscription
4646 /// @throws EntityNotFoundException if no entry is found
4747 @ Transactional (readOnly = true )
4848 public SubscriptionDTO .UserSubscriptionDTO getUserSubscriptionBySubscriptionUuid (UUID subscriptionUuid , Long userId ) {
49- log .debug ("Fetching subscriptionEntity {} for userEntity {}" , subscriptionUuid , userId );
49+ log .debug ("Fetching subscription {} for userEntity {}" , subscriptionUuid , userId );
5050 UserSubscriptionEntity subscription = userSubscriptionRepository .findByUserIdAndSubscriptionUuid (userId , subscriptionUuid )
51- .orElseThrow (() -> new EntityNotFoundException ("subscriptionEntity not found for userEntity" ));
51+ .orElseThrow (() -> new EntityNotFoundException ("subscription not found for userEntity" ));
5252
53- log .debug ("SubscriptionEntity {} for userEntity {} found" , subscriptionUuid , userId );
53+ log .debug ("Subscription {} for userEntity {} found" , subscriptionUuid , userId );
5454 return userSubscriptionMapper .toDto (subscription );
5555 }
5656
@@ -65,29 +65,29 @@ public Page<SubscriptionDTO.UserSubscriptionDTO> getAllSubscriptionsForUser(Long
6565 .map (userSubscriptionMapper ::toDto );
6666 }
6767
68- /// Gets all active subscriptions for the authenticated userEntity
68+ /// Gets all active subscriptions for the authenticated user
6969 ///
70- /// @param userId the database ID of the authenticated userEntity
70+ /// @param userId the database ID of the authenticated user
7171 /// @return a paginated set of [SubscriptionDTO.UserSubscriptionDTO] objects
7272 @ Transactional (readOnly = true )
7373 public Page <SubscriptionDTO .UserSubscriptionDTO > getAllActiveSubscriptionsForUser (Long userId , Pageable pageable ) {
7474 log .debug ("Fetching all active subscriptions for {}" , userId );
7575 return userSubscriptionRepository .findAllByUserIdAndIsSubscribedTrue (userId , pageable ).map (userSubscriptionMapper ::toDto );
7676 }
7777
78- /// Persists a new userEntity subscriptionEntity to the database
79- /// If an existing entry is found for the userEntity and subscriptionEntity , the `isSubscribed` property is set to `true`
78+ /// Persists a new user subscription to the database
79+ /// If an existing entry is found for the user and subscription , the `isSubscribed` property is set to `true`
8080 ///
81- /// @param subscriptionEntity the target subscriptionEntity
82- /// @param userId the ID of the target userEntity
83- /// @return a [SubscriptionDTO.UserSubscriptionDTO] representation of the subscriptionEntity link
84- /// @throws EntityNotFoundException if no matching userEntity is found
81+ /// @param subscriptionEntity the target [SubscriptionEntity]
82+ /// @param userId the ID of the target user
83+ /// @return a [SubscriptionDTO.UserSubscriptionDTO] representation of the subscription link
84+ /// @throws EntityNotFoundException if no matching user is found
8585 protected SubscriptionDTO .UserSubscriptionDTO persistUserSubscription (SubscriptionEntity subscriptionEntity , Long userId ) {
8686 UserEntity userEntity = userRepository .findById (userId ).orElseThrow (() -> new EntityNotFoundException ("userEntity not found" ));
8787 log .debug ("{}" , userEntity );
8888
8989 UserSubscriptionEntity newSubscription = userSubscriptionRepository .findByUserIdAndSubscriptionUuid (userId , subscriptionEntity .getUuid ()).orElseGet (() -> {
90- log .debug ("Creating new userEntity subscriptionEntity for userEntity {} and subscriptionEntity {}" , userId , subscriptionEntity .getUuid ());
90+ log .debug ("Creating new subscription for user {} and subscription {}" , userId , subscriptionEntity .getUuid ());
9191 UserSubscriptionEntity createdSubscription = new UserSubscriptionEntity ();
9292 createdSubscription .setIsSubscribed (true );
9393 createdSubscription .setUser (userEntity );
@@ -99,10 +99,10 @@ protected SubscriptionDTO.UserSubscriptionDTO persistUserSubscription(Subscripti
9999 return userSubscriptionMapper .toDto (userSubscriptionRepository .save (newSubscription ));
100100 }
101101
102- /// Creates UserSubscriptionEntity links in bulk. If the SubscriptionEntity isn't already in the system, this is added before the userEntity is subscribed.
102+ /// Creates [ UserSubscriptionEntity] links in bulk. If the [ SubscriptionEntity] isn't already in the system, this is added before the user is subscribed.
103103 ///
104104 /// @param requests a list of [SubscriptionDTO.SubscriptionCreateDTO] objects to create
105- /// @param userId the ID of the requesting userEntity
105+ /// @param userId the ID of the requesting user
106106 /// @return a [SubscriptionDTO.BulkSubscriptionResponseDTO] DTO containing a list of successes and failures
107107 @ Transactional
108108 public SubscriptionDTO .BulkSubscriptionResponseDTO addSubscriptions (List <SubscriptionDTO .SubscriptionCreateDTO > requests , Long userId ) {
@@ -113,7 +113,7 @@ public SubscriptionDTO.BulkSubscriptionResponseDTO addSubscriptions(List<Subscri
113113
114114 for (SubscriptionDTO .SubscriptionCreateDTO dto : requests ) {
115115 try {
116- // Fetch or create the subscriptionEntity object to subscribe the userEntity to
116+ // Fetch or create the subscription object to subscribe the user to
117117 SubscriptionEntity subscriptionEntity = this .fetchOrCreateSubscription (dto );
118118 log .debug ("{}" , subscriptionEntity );
119119 // If all is successful, persist the new UserSubscriptionEntity and add a UserSubscriptionDTO to the successes list
@@ -131,15 +131,15 @@ public SubscriptionDTO.BulkSubscriptionResponseDTO addSubscriptions(List<Subscri
131131 return new SubscriptionDTO .BulkSubscriptionResponseDTO (successes , failures );
132132 }
133133
134- /// Updates the status of a subscriptionEntity for a given userEntity
134+ /// Updates the status of a subscription for a given user
135135 ///
136- /// @param feedUUID the UUID of the subscriptionEntity feed
137- /// @param userId the ID of the userEntity
136+ /// @param feedUUID the UUID of the subscription feed
137+ /// @param userId the ID of the user
138138 /// @return a [SubscriptionDTO.UserSubscriptionDTO] containing the updated object
139139 @ Transactional
140140 public SubscriptionDTO .UserSubscriptionDTO unsubscribeUserFromFeed (UUID feedUUID , Long userId ) {
141141 UserSubscriptionEntity subscription = userSubscriptionRepository .findByUserIdAndSubscriptionUuid (userId , feedUUID )
142- .orElseThrow (() -> new EntityNotFoundException ("no subscriptionEntity found" ));
142+ .orElseThrow (() -> new EntityNotFoundException ("no subscription found" ));
143143
144144 subscription .setIsSubscribed (false );
145145 return userSubscriptionMapper .toDto (userSubscriptionRepository .save (subscription ));
0 commit comments