Skip to content

Commit 225ddc1

Browse files
committed
Merge pull request 'chore: general cleanup of docstrings and mappers' (#44) from general-cleanup into main
Reviewed-on: https://codeberg.org/OpenPodcastAPI/opa-java/pulls/44
2 parents 2bb4a1c + bb8bde8 commit 225ddc1

File tree

4 files changed

+3
-63
lines changed

4 files changed

+3
-63
lines changed

src/main/java/org/openpodcastapi/opa/subscription/SubscriptionEntity.java

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -57,99 +57,71 @@ public SubscriptionEntity(UUID uuid, UserEntity user, FeedEntity feed) {
5757
this.feed = feed;
5858
}
5959

60-
/// Retrieves the subscription ID
61-
///
6260
/// @return the subscription ID
6361
public Long getId() {
6462
return this.id;
6563
}
6664

67-
/// Sets the subscription ID
68-
///
6965
/// @param id the subscription ID
7066
public void setId(Long id) {
7167
this.id = id;
7268
}
7369

74-
/// Retrieves the subscription UUID
75-
///
7670
/// @return the subscription UUID
7771
public UUID getUuid() {
7872
return this.uuid;
7973
}
8074

81-
/// Sets the subscription UUID
82-
///
8375
/// @param uuid the subscription UUID
8476
public void setUuid(UUID uuid) {
8577
this.uuid = uuid;
8678
}
8779

88-
/// Retrieves the user associated with the entity
89-
///
9080
/// @return the associated user
9181
public UserEntity getUser() {
9282
return this.user;
9383
}
9484

95-
/// Sets the user associated with the subscription
96-
///
9785
/// @param user the subscription UUID
9886
public void setUser(UserEntity user) {
9987
this.user = user;
10088
}
10189

102-
/// Retrieves the feed associated with the entity
103-
///
10490
/// @return the associated subscription
10591
public FeedEntity getFeed() {
10692
return this.feed;
10793
}
10894

109-
/// Sets the subscription associated with the user subscription
110-
///
11195
/// @param feed the subscription UUID
11296
public void setFeed(FeedEntity feed) {
11397
this.feed = feed;
11498
}
11599

116-
/// Retrieves the creation date of the subscription
117-
///
118100
/// @return the creation date
119101
public Instant getCreatedAt() {
120102
return this.createdAt;
121103
}
122104

123-
/// Sets the creation date for the subscription
124-
///
125105
/// @param createdAt the creation timestamp
126106
public void setCreatedAt(Instant createdAt) {
127107
this.createdAt = createdAt;
128108
}
129109

130-
/// Retrieves the last update timestamp for the subscription
131-
///
132110
/// @return the last updated timestamp
133111
public Instant getUpdatedAt() {
134112
return this.updatedAt;
135113
}
136114

137-
/// Sets the last updated date for the subscription
138-
///
139115
/// @param updatedAt the last updated timestamp
140116
public void setUpdatedAt(Instant updatedAt) {
141117
this.updatedAt = updatedAt;
142118
}
143119

144-
/// Retrieves the unsubscribed timestamp for the entity
145-
///
146120
/// @return the unsubscribed timestamp
147121
public Instant getUnsubscribedAt() {
148122
return this.unsubscribedAt;
149123
}
150124

151-
/// Sets the unsubscribed timestamp
152-
///
153125
/// @param unsubscribedAt the unsubscribed timestamp
154126
public void setUnsubscribedAt(Instant unsubscribedAt) {
155127
this.unsubscribedAt = unsubscribedAt;

src/main/java/org/openpodcastapi/opa/user/UserEntity.java

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -90,106 +90,76 @@ public UserEntity(Long id, UUID uuid, String username, String password, String e
9090
this.updatedAt = updatedAt;
9191
}
9292

93-
/// Retrieves the ID of a user entity
94-
///
9593
/// @return the ID of the user entity
9694
public Long getId() {
9795
return this.id;
9896
}
9997

100-
/// Retrieves the UUID of a user entity
101-
///
10298
/// @return the UUID of the user entity
10399
public UUID getUuid() {
104100
return this.uuid;
105101
}
106102

107-
/// Sets the UUID of a user entity
108-
///
109103
/// @param uuid the UUID for the entity
110104
public void setUuid(UUID uuid) {
111105
this.uuid = uuid;
112106
}
113107

114-
/// Retrieves the username of a user entity
115-
///
116108
/// @return a user's username
117109
public String getUsername() {
118110
return this.username;
119111
}
120112

121-
/// Sets the username of a user entity
122-
///
123113
/// @param username the user's username
124114
public void setUsername(String username) {
125115
this.username = username;
126116
}
127117

128-
/// Retrieves the user's password hash
129-
///
130118
/// @return the hashed password
131119
public String getPassword() {
132120
return this.password;
133121
}
134122

135-
/// Sets the user's password. The password must be hashed first
136-
///
137123
/// @param password the hashed password
138124
public void setPassword(String password) {
139125
this.password = password;
140126
}
141127

142-
/// Retrieves a user's email address
143-
///
144128
/// @return the user's email address
145129
public String getEmail() {
146130
return this.email;
147131
}
148132

149-
/// Sets the user's email address.
150-
///
151133
/// @param email the user's email address
152134
public void setEmail(String email) {
153135
this.email = email;
154136
}
155137

156-
/// Retrieves a user's subscriptions
157-
///
158138
/// @return a set of subscriptions
159139
public Set<SubscriptionEntity> getSubscriptions() {
160140
return this.subscriptions;
161141
}
162142

163-
/// Sets a user's subscriptions
164-
///
165143
/// @param subscriptions the set of subscriptions to add to the user
166144
public void setSubscriptions(Set<SubscriptionEntity> subscriptions) {
167145
this.subscriptions = subscriptions;
168146
}
169147

170-
/// Retrieves a user's roles
171-
///
172148
/// @return a set of user roles
173149
public Set<UserRoles> getUserRoles() {
174150
return this.userRoles;
175151
}
176152

177-
/// Sets a user's roles
178-
///
179153
/// @param userRoles a set of user roles
180154
public void setUserRoles(Set<UserRoles> userRoles) {
181155
this.userRoles = userRoles;
182156
}
183157

184-
/// Retrieves the creation date of the user
185-
///
186158
/// @return the user creation date
187159
public Instant getCreatedAt() {
188160
return this.createdAt;
189161
}
190162

191-
/// Retrieves the last updated timestamp for the user
192-
///
193163
/// @return the last updated timestamp
194164
public Instant getUpdatedAt() {
195165
return this.updatedAt;

src/main/java/org/openpodcastapi/opa/user/UserMapper.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
import org.mapstruct.Mapper;
44
import org.mapstruct.Mapping;
5+
import org.mapstruct.ReportingPolicy;
56

67
/// Mapper for user items
7-
@Mapper(componentModel = "spring")
8+
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
89
public interface UserMapper {
910
/// Maps a user entity to a DTO.
1011
///
@@ -18,9 +19,6 @@ public interface UserMapper {
1819
///
1920
/// @param dto the user creation DTO to map
2021
/// @return the mapped entity
21-
@Mapping(target = "uuid", ignore = true)
22-
@Mapping(target = "subscriptions", ignore = true)
2322
@Mapping(target = "password", ignore = true)
24-
@Mapping(target = "userRoles", ignore = true)
2523
UserEntity toEntity(UserDTO.CreateUserDTO dto);
2624
}

src/main/java/org/openpodcastapi/opa/user/UserRestController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public UserRestController(UserService userService) {
5353
/// @param uuid the UUID of the user
5454
/// @return a response containing a summary of the action
5555
@DeleteMapping("/{uuid}")
56-
@PreAuthorize("hasRole('ADMIN') or #uuid == principal.uuid")
56+
@PreAuthorize("hasRole('ADMIN') or #uuid == authentication.principal.uuid" )
5757
public ResponseEntity<@NonNull String> deleteUser(@PathVariable String uuid) {
5858
// Attempt to validate the UUID value from the provided string
5959
// If the value is invalid, the GlobalExceptionHandler will throw a 400.

0 commit comments

Comments
 (0)