Skip to content

Commit

Permalink
Merge pull request #255 from niharikasingh84/lms-service
Browse files Browse the repository at this point in the history
Lms service
  • Loading branch information
rahul-tarento authored Jul 12, 2019
2 parents 3c94b6e + af4acf6 commit 6aace13
Showing 1 changed file with 17 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.apache.commons.lang3.StringUtils;
import org.sunbird.actor.core.BaseActor;
import org.sunbird.actor.router.ActorConfig;
import java.util.stream.Collectors;
import org.sunbird.common.ElasticSearchHelper;
import org.sunbird.common.exception.ProjectCommonException;
import org.sunbird.common.factory.EsClientFactory;
Expand Down Expand Up @@ -500,27 +501,31 @@ private void validateMentors(CourseBatch courseBatch) {
List<String> mentors = courseBatch.getMentors();
if (CollectionUtils.isNotEmpty(mentors)) {
String batchCreatorRootOrgId = getRootOrg(courseBatch.getCreatedBy());

List<Map<String, Object>> mentorDetailList = userOrgService.getUsersByIds(mentors);
Map<String, Map<String, Object>> mentorDetails =
mentorDetailList
.stream()
.collect(Collectors.toMap(map -> (String) map.get(JsonKey.ID), map -> map));
for (String userId : mentors) {
Map<String, Object> result = userOrgService.getUserById(userId);
String mentorRootOrgId = getRootOrg(userId);
Map<String, Object> result = mentorDetails.get(userId);
String mentorRootOrgId = getRootOrgFromUserMap(result);
if (!batchCreatorRootOrgId.equals(mentorRootOrgId)) {
throw new ProjectCommonException(
ResponseCode.userNotAssociatedToRootOrg.getErrorCode(),
ResponseCode.userNotAssociatedToRootOrg.getErrorMessage(),
ResponseCode.CLIENT_ERROR.getResponseCode(),
userId);
ResponseCode.userNotAssociatedToRootOrg.getErrorCode(),
ResponseCode.userNotAssociatedToRootOrg.getErrorMessage(),
ResponseCode.CLIENT_ERROR.getResponseCode(),
userId);
}
if ((ProjectUtil.isNull(result))
|| (ProjectUtil.isNotNull(result) && result.isEmpty())
|| (ProjectUtil.isNotNull(result)
|| (ProjectUtil.isNotNull(result) && result.isEmpty())
|| (ProjectUtil.isNotNull(result)
&& result.containsKey(JsonKey.IS_DELETED)
&& ProjectUtil.isNotNull(result.get(JsonKey.IS_DELETED))
&& (Boolean) result.get(JsonKey.IS_DELETED))) {
throw new ProjectCommonException(
ResponseCode.invalidUserId.getErrorCode(),
ResponseCode.invalidUserId.getErrorMessage(),
ResponseCode.CLIENT_ERROR.getResponseCode());
ResponseCode.invalidUserId.getErrorCode(),
ResponseCode.invalidUserId.getErrorMessage(),
ResponseCode.CLIENT_ERROR.getResponseCode());
}
}
}
Expand Down

0 comments on commit 6aace13

Please sign in to comment.