Skip to content

Commit

Permalink
validation added for course enrol api, allowed primarycategory is Cou… (
Browse files Browse the repository at this point in the history
#148)

* validation added for course enrol api, allowed primarycategory is Course. (#147)

* Update externalresource.properties

---------

Co-authored-by: shankaragoudab <140387294+shankaragoudab@users.noreply.github.com>
  • Loading branch information
karthik-tarento and shankaragoudab authored Mar 28, 2024
1 parent 7b14e41 commit b114141
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ class CourseEnrolmentActor @Inject()(@Named("course-batch-notification-actor") c
val userId: String = request.get(JsonKey.USER_ID).asInstanceOf[String]
val batchId: String = request.get(JsonKey.BATCH_ID).asInstanceOf[String]
logger.info(request.asInstanceOf[Request].getRequestContext, "CourseEnrolmentActor Request for enroll recieved, UserId : " + userId + ", courseId : " + courseId +", batchId : "+batchId)
val fieldList = List(JsonKey.PRIMARYCATEGORY, JsonKey.IDENTIFIER, JsonKey.BATCHES)
val contentData = getContentReadAPIData(courseId, fieldList, request)
if (contentData.size() == 0 || !util.Arrays.asList(getConfigValue(JsonKey.COURSE_ENROLL_ALLOWED_PRIMARY_CATEGORY).split(","): _*).contains(contentData.get(JsonKey.PRIMARYCATEGORY).asInstanceOf[String]))
ProjectCommonException.throwClientErrorException(ResponseCode.accessDeniedToEnrolOrUnenrolCourse, courseId);
val batchData: CourseBatch = courseBatchDao.readById( courseId, batchId, request.getRequestContext)
val enrolmentData: UserCourses = userCoursesDao.read(request.getRequestContext, userId, courseId, batchId)
val batchUserData: BatchUser = batchUserDao.read(request.getRequestContext, batchId, userId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1138,5 +1138,6 @@ public final class JsonKey {
public static final String USERID_LIST="userIdList";
public static final String LRC_PROGRESS_DETAILS = "lrcProgressDetails";
public static final String USERS_COUNT = "system.count(userid)";
public static final String COURSE_ENROLL_ALLOWED_PRIMARY_CATEGORY = "course_enroll_allowed_primary_category";
private JsonKey() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -223,3 +223,4 @@ kafka_user_enrolment_event_topic=dev.user.enrolment.event
content_bucket=/content-store/content
static_host_url=https://static.karmayogiprod.nic.in
profile_update_url=/app/user-profile/details
course_enroll_allowed_primary_category=Course,Blended Program,Standalone Assessment

0 comments on commit b114141

Please sign in to comment.