-
Notifications
You must be signed in to change notification settings - Fork 69
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
APP-2983: Implementation of user service in BDK 2.0 #195
Conversation
Create UserService class to wrap all the user api endpoints provided by the pod to retrieve user, list of users, perform action to get and update role, delegate, entitlements, avatar, disclaimer, status of user. Create an entry to user service in SymphonyBdk by calling method SymphonyBdk#user Create an example for user service Update javadoc
symphony-bdk-core/src/main/java/com/symphony/bdk/core/SymphonyBdk.java
Outdated
Show resolved
Hide resolved
symphony-bdk-core/src/main/java/com/symphony/bdk/core/service/user/UserDetailMapper.java
Outdated
Show resolved
Hide resolved
symphony-bdk-core/src/main/java/com/symphony/bdk/core/SymphonyBdk.java
Outdated
Show resolved
Hide resolved
97b9a41
to
1d3ef0b
Compare
@symphony-hong How do the services will handle OBO authentication? At the moment, it is only possible to call those services using the regular bot authentication (i.e. bot's |
I thought, for handling the OBO authentication, we just need pass the obo's |
|
I have several ideas for it:
|
@symphony-hong could you make a small demo for both of each? |
Okay I will do it when we're working with the ticket about Fluent API |
Using MapperStruct to create a mapper for user detail to make it more generic Refactor user service entry Update a more complicated example for user service
1d3ef0b
to
1ea37a5
Compare
Define UserService#authSession for setting up the authSession using by UserService instance. In SymphonyBDK, passing the authSession or oboSession to UserService instance to make it run with normal or obo session respectively.
@symphony-thibault or we can do like what I did in last update. Is this your point at the beginning? |
|
||
private final UserApi userApi; | ||
private final UsersApi usersApi; | ||
private AuthSession authSession; |
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.
In a multi-threaded environment (Spring for instance): this will cause big issues for sure :) Also, we should also keep in mind that OBO is not supported for all API endpoints (cf. https://developers.symphony.com/restapi/reference#obo-enabled-endpoints).
We should enforce developers to use OBO authentication on OBO-Enabled endpoints only.
4df3dca
to
4fdca64
Compare
symphony-bdk-core/src/test/java/com/symphony/bdk/core/test/BdkMockServer.java
Show resolved
Hide resolved
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.
LGTM
symphony-bdk-core/src/main/java/com/symphony/bdk/core/service/user/UserDetailMapper.java
Outdated
Show resolved
Hide resolved
symphony-bdk-core/src/main/java/com/symphony/bdk/core/service/user/UserService.java
Show resolved
Hide resolved
symphony-bdk-core/src/main/java/com/symphony/bdk/core/service/user/UserService.java
Outdated
Show resolved
Hide resolved
symphony-bdk-core/src/main/java/com/symphony/bdk/core/service/user/UserService.java
Outdated
Show resolved
Hide resolved
symphony-bdk-core/src/main/java/com/symphony/bdk/core/service/user/UserService.java
Outdated
Show resolved
Hide resolved
symphony-bdk-core/src/main/java/com/symphony/bdk/core/service/user/UserService.java
Outdated
Show resolved
Hide resolved
symphony-bdk-core/src/main/java/com/symphony/bdk/core/service/user/UserService.java
Show resolved
Hide resolved
symphony-bdk-core/src/main/java/com/symphony/bdk/core/service/user/UserService.java
Outdated
Show resolved
Hide resolved
Last minute idea: we could create a custom annotation |
symphony-bdk-core/src/main/java/com/symphony/bdk/core/service/OboEnabled.java
Show resolved
Hide resolved
symphony-bdk-core/src/main/java/com/symphony/bdk/core/service/user/constant/RoleId.java
Show resolved
Hide resolved
|
||
/** | ||
* Retrieve user details of a particular user. | ||
* @see <a href="https://developers.symphony.com/restapi/reference#get-user-v2">Get User v2</a> |
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.
@see
is usually placed at the end of the Javadoc comment block (cf. https://www.oracle.com/technical-resources/articles/java/javadoc-tool.html)
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.
LGTM 👍
* @param uid User Id | ||
* @return User found by uid | ||
*/ | ||
public UserV2 getUserById(@NonNull Long uid) { |
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 could have a getUser(UserId id) method to cover both cases (long id and string email)
And then UserId.id(123) and UserId.email("bob@mail.com")
This way we don't mess up with primitive types and avoid having methods suffixed with byId/byEmail
But maybe the API does not always support id and email?
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.
the API for getting user accept only one of the params: username, uid or email. If we pass more than one param, the error 400 is returned. That's why I splitted it to 3 different methods.
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 does not prevent the UserService to have the logic to set the username/uid/email based on the UserId passed as a parameter
but do all the APIs related to user support passing username, uid or email? (otherwise we would not have a consistent API where UserId can be used everywhere)
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.
Nope, only the API for getting user:
https://github.com/symphonyoss/symphony-api-spec/blob/master/pod/pod-api-public.yaml#L1784
and the API for seaching users:
https://github.com/symphonyoss/symphony-api-spec/blob/master/pod/pod-api-public.yaml#L1426
* @param image The avatar image for the user profile picture.The image must be a base64-encoded. | ||
* @see <a href="https://developers.symphony.com/restapi/reference#update-user-avatar">Update User Avatar</a> | ||
*/ | ||
public void updateAvatarOfUser(@NonNull Long uid, @NonNull String image) { |
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.
As a API user in Java I would perhaps prefer to send an inputstream here (and then have the SDK do the encoding for me)
* @param image The avatar image in bytes array for the user profile picture. | ||
* @see <a href="https://developers.symphony.com/restapi/reference#update-user-avatar">Update User Avatar</a> | ||
*/ | ||
public void updateAvatarOfUser(@NonNull Long uid, @NonNull byte[] image) { |
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.
ah that one is better :)
Create UserService class to wrap all the user api endpoints provided
by the pod to retrieve user, list of users, perform action to get and
update role, delegate, entitlements, avatar, disclaimer, status of user.
Create an entry to user service in SymphonyBdk by calling method SymphonyBdk#user
Create an example for user service
Update javadoc
Unittest added with code coverage >90%