ganning127 commented on code in PR #417:
URL: https://github.com/apache/airavata-custos/pull/417#discussion_r1975672772


##########
services/src/main/java/org/apache/custos/service/profile/UserProfileService.java:
##########
@@ -207,6 +333,30 @@ public org.apache.custos.core.user.profile.api.UserProfile 
getUserProfile(UserPr
         }
     }
 
+    /**
+     * Returns the full user profile, including roles inherited from groups
+     * @param request Must specify profile.username
+     * @return The full user profile
+     */
+    public org.apache.custos.core.user.profile.api.UserProfile 
getFullUserProfile(UserProfileRequest request) {
+        try {
+            LOGGER.debug("Request received to getFullUserProfile for " + 
request.getProfile().getUsername() + "at " + request.getTenantId());
+            String userId = request.getProfile().getUsername() + "@" + 
request.getTenantId();
+            Optional<UserProfile> entity = repository.findById(userId);
+
+            if (entity.isPresent()) {
+                UserProfile profileEntity = entity.get();
+                return 
UserProfileMapper.createFullUserProfileFromUserProfileEntity(profileEntity);
+            } else {
+                return null;

Review Comment:
   I think we should actually throw an exception instead of returning null. 
Will update the code to reflect that!



##########
services/src/main/java/org/apache/custos/service/profile/UserProfileService.java:
##########
@@ -207,6 +333,30 @@ public org.apache.custos.core.user.profile.api.UserProfile 
getUserProfile(UserPr
         }
     }
 
+    /**
+     * Returns the full user profile, including roles inherited from groups
+     * @param request Must specify profile.username
+     * @return The full user profile
+     */
+    public org.apache.custos.core.user.profile.api.UserProfile 
getFullUserProfile(UserProfileRequest request) {
+        try {
+            LOGGER.debug("Request received to getFullUserProfile for " + 
request.getProfile().getUsername() + "at " + request.getTenantId());
+            String userId = request.getProfile().getUsername() + "@" + 
request.getTenantId();
+            Optional<UserProfile> entity = repository.findById(userId);
+
+            if (entity.isPresent()) {
+                UserProfile profileEntity = entity.get();
+                return 
UserProfileMapper.createFullUserProfileFromUserProfileEntity(profileEntity);
+            } else {
+                return null;

Review Comment:
   I think we should actually throw an EntityNotFoundException instead of 
returning null. Will update the code to reflect that!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to