|
15 | 15 | import java.util.Map; |
16 | 16 | import java.util.Set; |
17 | 17 |
|
| 18 | +import com.igot.cb.user.UserUtilityService; |
18 | 19 | import org.apache.commons.collections.CollectionUtils; |
19 | 20 | import org.apache.commons.collections.MapUtils; |
20 | 21 | import org.apache.commons.lang3.StringUtils; |
| 22 | +import org.springframework.beans.factory.annotation.Autowired; |
21 | 23 | import org.springframework.http.HttpStatus; |
22 | 24 | import org.springframework.stereotype.Service; |
23 | 25 |
|
@@ -68,6 +70,7 @@ public class CbPlanServiceImpl { |
68 | 70 |
|
69 | 71 | private final RequestValidator requestValidator; |
70 | 72 |
|
| 73 | + |
71 | 74 | public CbPlanServiceImpl(AccessTokenValidator accessTokenValidator, CassandraOperation cassandraOperation, |
72 | 75 | CbExtServerProperties serverProperties, UserAndOrgServiceImpl userAndOrgService, |
73 | 76 | ContentInfoServiceImpl contentService, EsUtilService esUtilService, RequestValidator requestValidator) { |
@@ -631,12 +634,24 @@ public ApiResponse searchCbPlan(SearchCriteria searchCriteria, String userOrgId, |
631 | 634 | // Create a copy of item so we don’t mutate original |
632 | 635 | Map<String, Object> enrichedItem = new HashMap<>(item); |
633 | 636 | String createdBy = (String) enrichedItem.get(Constants.CREATED_BY); |
634 | | - if (StringUtils.isNotBlank(createdBy)) { |
635 | | - String createdByUserName = ""; |
636 | 637 |
|
637 | | - enrichedItem.put(Constants.CREATED_BY_NAME, createdByUserName); |
| 638 | + if (item.containsKey(Constants.CREATED_BY) && item.get(Constants.CREATED_BY) != null) { |
| 639 | + Object createdByObj = item.get(Constants.CREATED_BY); |
| 640 | + Map<String, Object> userInfoMap = new HashMap<>(); |
| 641 | + if (createdByObj instanceof String && !((String) createdByObj).trim().isEmpty()) { |
| 642 | + // fetch user details from DB |
| 643 | + userInfoMap = userAndOrgService.readUserProfile( |
| 644 | + (String) item.get(Constants.CREATED_BY), |
| 645 | + Arrays.asList(Constants.FIRSTNAME, Constants.USER_ID) |
| 646 | + ); |
| 647 | + if (userInfoMap != null) { |
| 648 | + |
| 649 | + enrichedItem.put(Constants.CREATED_BY_NAME, |
| 650 | + userInfoMap.get(Constants.FIRSTNAME)); |
| 651 | + enrichedItem.put(Constants.CREATED_BY, item.get(Constants.CREATED_BY)); |
| 652 | + } |
| 653 | + } |
638 | 654 | } |
639 | | - enrichedItem.put(Constants.CREATED_BY, createdBy); |
640 | 655 |
|
641 | 656 | if (item.containsKey(Constants.CONTENT_LIST) && item.get(Constants.CONTENT_LIST) != null) { |
642 | 657 | Object contentListObj = item.get(Constants.CONTENT_LIST); |
@@ -667,6 +682,7 @@ public ApiResponse searchCbPlan(SearchCriteria searchCriteria, String userOrgId, |
667 | 682 | return response; |
668 | 683 | } |
669 | 684 |
|
| 685 | + |
670 | 686 | private void createSuccessResponse(ApiResponse response) { |
671 | 687 | response.setParams(new ApiRespParam()); |
672 | 688 | response.getParams().setStatus(Constants.SUCCESS); |
|
0 commit comments