diff --git a/actors/sunbird-lms-mw/actors/common/src/main/java/org/sunbird/learner/actors/coursebatch/CourseEnrollmentActor.java b/actors/sunbird-lms-mw/actors/common/src/main/java/org/sunbird/learner/actors/coursebatch/CourseEnrollmentActor.java index 3d60fc7b58..4d12da64e7 100644 --- a/actors/sunbird-lms-mw/actors/common/src/main/java/org/sunbird/learner/actors/coursebatch/CourseEnrollmentActor.java +++ b/actors/sunbird-lms-mw/actors/common/src/main/java/org/sunbird/learner/actors/coursebatch/CourseEnrollmentActor.java @@ -77,7 +77,10 @@ private void enrollCourseBatch(Request actorMessage) { Map courseMap = (Map) actorMessage.getRequest(); CourseBatch courseBatch = courseBatchDao.readById((String) courseMap.get(JsonKey.BATCH_ID)); validateCourseBatch( - courseBatch, courseMap, (String) actorMessage.getContext().get(JsonKey.REQUESTED_BY)); + courseBatch, + courseMap, + (String) actorMessage.getContext().get(JsonKey.REQUESTED_BY), + ActorOperations.ENROLL_COURSE.getValue()); UserCourses userCourseResult = userCourseDao.read(UserCoursesService.getPrimaryKey(courseMap)); @@ -165,7 +168,10 @@ private void unenrollCourseBatch(Request actorMessage) { Map request = actorMessage.getRequest(); CourseBatch courseBatch = courseBatchDao.readById((String) request.get(JsonKey.BATCH_ID)); validateCourseBatch( - courseBatch, request, (String) actorMessage.getContext().get(JsonKey.REQUESTED_BY)); + courseBatch, + request, + (String) actorMessage.getContext().get(JsonKey.REQUESTED_BY), + ActorOperations.UNENROLL_COURSE.getValue()); UserCourses userCourseResult = userCourseDao.read(UserCoursesService.getPrimaryKey(request)); UserCoursesService.validateUserUnenroll(userCourseResult); Response result = updateUserCourses(userCourseResult); @@ -249,7 +255,10 @@ public static Map getCourseObjectFromEkStep( * @Params */ private void validateCourseBatch( - CourseBatch courseBatchDetails, Map request, String requestedBy) { + CourseBatch courseBatchDetails, + Map request, + String requestedBy, + String actorOperation) { if (ProjectUtil.isNull(courseBatchDetails)) { ProjectCommonException.throwClientErrorException( @@ -280,7 +289,9 @@ private void validateCourseBatch( if (StringUtils.isNotBlank(courseBatchDetails.getEnrollmentEndDate())) { courseBatchEnrollmentEndDate = format.parse(courseBatchDetails.getEnrollmentEndDate()); } - if (courseBatchEnrollmentEndDate != null && courseBatchEnrollmentEndDate.before(todaydate)) { + if (ActorOperations.ENROLL_COURSE.getValue().equals(actorOperation) + && courseBatchEnrollmentEndDate != null + && courseBatchEnrollmentEndDate.before(todaydate)) { ProjectLogger.log( "CourseEnrollmentActor validateCourseBatch Enrollment Date has ended.", LoggerEnum.INFO.name());