-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add user profile #29
add user profile #29
Conversation
Signed-off-by: David BRAQUART <[email protected]>
Signed-off-by: David BRAQUART <[email protected]>
bd5e9d4
to
e0f85d9
Compare
Signed-off-by: David BRAQUART <[email protected]>
Signed-off-by: David BRAQUART <[email protected]>
Signed-off-by: David BRAQUART <[email protected]>
Signed-off-by: David BRAQUART <[email protected]>
…ofile # Conflicts: # src/main/java/org/gridsuite/useradmin/server/UserAdminController.java # src/main/java/org/gridsuite/useradmin/server/service/UserAdminService.java # src/main/resources/application-local.yml # src/test/java/org/gridsuite/useradmin/server/UserAdminTest.java
Signed-off-by: David BRAQUART <[email protected]>
Signed-off-by: David BRAQUART <[email protected]>
Signed-off-by: David BRAQUART <[email protected]>
c636359
to
a3ad1ec
Compare
Signed-off-by: David BRAQUART <[email protected]>
a3ad1ec
to
87fbf39
Compare
Signed-off-by: David BRAQUART <[email protected]>
62e2037
to
154339c
Compare
Signed-off-by: David BRAQUART <[email protected]>
ca38798
to
cee73e0
Compare
src/main/java/org/gridsuite/useradmin/server/service/UserAdminService.java
Outdated
Show resolved
Hide resolved
return new UserInfos(entity.getSub(), isAdminFn.test(entity.getSub()), profileName); | ||
} | ||
|
||
public void update(UserInfos userInfos, Optional<UserProfileEntity> userProfileEntity) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's weird to give a dto and an entity as arguments to this method.
Maybe do the setSub() and setProfile directly in the service
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes done
if (entity == null) { | ||
return null; | ||
} | ||
Boolean globalValidity = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this part should be out of the toDto() method. Just pass a boolean
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes done
assertIsAdmin(userId); | ||
return userAdminRepository.deleteAllBySubIn(subs); | ||
} | ||
|
||
@Transactional() | ||
public void updateUser(String sub, String userId, UserInfos userInfos) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You already have the "sub" in the userInfos
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually they are different. "sub" is the resource I want to access/change, while "userInfos.sub" is the new name I may want to set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should really a user sub be updatable ?
} | ||
|
||
@Transactional() | ||
public void updateProfile(UUID profileUuid, String userId, UserProfile userProfile) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You already have the "profileUuid" in the userProfile
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I remove it, I will have a warning in Controller (unused param). what to do ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's fine like this as we keep the profileUuid in the endpoint
public ResponseEntity<UserProfile> updateUser(@PathVariable("sub") String sub, | ||
@RequestHeader("userId") String userId, | ||
@RequestBody UserInfos userInfos) { | ||
service.updateUser(sub, userId, userInfos); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove "sub" and work with userInfos nope ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no I need both
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes as discussed, it's the classic way to update a resource with rest api
UUID id, | ||
String name, | ||
UUID loadFlowParameterId, | ||
Boolean validity |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isValid ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
renamed as allParametersLinksValid
Signed-off-by: David BRAQUART <[email protected]>
Signed-off-by: David BRAQUART <[email protected]>
Signed-off-by: David BRAQUART <[email protected]>
Signed-off-by: David BRAQUART <[email protected]>
Signed-off-by: David BRAQUART <[email protected]>
src/main/java/org/gridsuite/useradmin/server/RestTemplateConfig.java
Outdated
Show resolved
Hide resolved
src/main/java/org/gridsuite/useradmin/server/RestResponseEntityExceptionHandler.java
Show resolved
Hide resolved
src/main/java/org/gridsuite/useradmin/server/UserAdminController.java
Outdated
Show resolved
Hide resolved
src/main/java/org/gridsuite/useradmin/server/UserAdminController.java
Outdated
Show resolved
Hide resolved
src/main/java/org/gridsuite/useradmin/server/UserAdminController.java
Outdated
Show resolved
Hide resolved
src/main/java/org/gridsuite/useradmin/server/entity/UserProfileEntity.java
Outdated
Show resolved
Hide resolved
src/main/java/org/gridsuite/useradmin/server/entity/UserInfosEntity.java
Show resolved
Hide resolved
src/main/java/org/gridsuite/useradmin/server/service/DirectoryService.java
Show resolved
Hide resolved
assertIsAdmin(userId); | ||
return userAdminRepository.deleteAllBySubIn(subs); | ||
} | ||
|
||
@Transactional() | ||
public void updateUser(String sub, String userId, UserInfos userInfos) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should really a user sub be updatable ?
src/main/java/org/gridsuite/useradmin/server/service/UserAdminService.java
Outdated
Show resolved
Hide resolved
Signed-off-by: David BRAQUART <[email protected]>
Signed-off-by: David BRAQUART <[email protected]>
Signed-off-by: David BRAQUART <[email protected]>
Signed-off-by: David BRAQUART <[email protected]>
Signed-off-by: David BRAQUART <[email protected]>
src/main/java/org/gridsuite/useradmin/server/controller/UserProfileController.java
Outdated
Show resolved
Hide resolved
src/main/java/org/gridsuite/useradmin/server/entity/UserProfileEntity.java
Outdated
Show resolved
Hide resolved
src/main/java/org/gridsuite/useradmin/server/service/DirectoryService.java
Show resolved
Hide resolved
src/main/java/org/gridsuite/useradmin/server/service/UserProfileService.java
Show resolved
Hide resolved
src/main/java/org/gridsuite/useradmin/server/service/UserProfileService.java
Outdated
Show resolved
Hide resolved
src/main/java/org/gridsuite/useradmin/server/service/UserProfileService.java
Outdated
Show resolved
Hide resolved
src/main/java/org/gridsuite/useradmin/server/service/UserProfileService.java
Outdated
Show resolved
Hide resolved
src/test/java/org/gridsuite/useradmin/server/UserAdminTest.java
Outdated
Show resolved
Hide resolved
Signed-off-by: David BRAQUART <[email protected]>
50f6375
to
472d2bd
Compare
Signed-off-by: David BRAQUART <[email protected]>
Signed-off-by: David BRAQUART <[email protected]>
UserInfosEntity user = userInfosRepository.findBySub(sub).orElseThrow(() -> new UserAdminException(NOT_FOUND)); | ||
Optional<UserProfileEntity> profile = userProfileRepository.findByName(userInfos.profileName()); | ||
user.setSub(userInfos.sub()); | ||
user.setProfile(profile.orElse(null)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we return a bad_input if the profile is not define ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we have a common habit to return 404 if we try to update a missing resource.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No I agree if the user is missing, but if the profile is missing ? Here if the profile does not exist we just set it to null but we don't throw.
src/main/java/org/gridsuite/useradmin/server/service/DirectoryService.java
Outdated
Show resolved
Hide resolved
src/main/java/org/gridsuite/useradmin/server/entity/UserInfosEntity.java
Show resolved
Hide resolved
src/main/java/org/gridsuite/useradmin/server/service/DirectoryService.java
Show resolved
Hide resolved
Signed-off-by: David BRAQUART <[email protected]>
Signed-off-by: David BRAQUART <[email protected]>
Signed-off-by: David BRAQUART <[email protected]>
Signed-off-by: David BRAQUART <[email protected]>
Quality Gate passedIssues Measures |
No description provided.