diff --git a/pom.xml b/pom.xml
index ff25492db..ed05a2309 100644
--- a/pom.xml
+++ b/pom.xml
@@ -219,6 +219,11 @@
jjwt
0.9.1
+
+ org.apache.commons
+ commons-csv
+ 1.9.0
+
diff --git a/src/main/java/org/sunbird/common/util/Constants.java b/src/main/java/org/sunbird/common/util/Constants.java
index 51e2f4a8b..35cb537a3 100644
--- a/src/main/java/org/sunbird/common/util/Constants.java
+++ b/src/main/java/org/sunbird/common/util/Constants.java
@@ -1088,6 +1088,9 @@ public class Constants {
public static final String SECTION_LEVEL_DEFINITION = "sectionLevelDefinition";
public static final String ASSESSMENT_HIERARCHY_SAVE_NOT_AVBL = "Assessment hierarchy save point not available, failed to process request";
+ public static final String SEQUENCE_NO = "seqno";
+ public static final String API_EXPLORE_COURSE_UPDATE = "api.explore.course.update";
+ public static final String API_EXPLORE_COURSE_DELETE = "api.explore.course.delete";
private Constants() {
throw new IllegalStateException("Utility class");
diff --git a/src/main/java/org/sunbird/course/controller/ExploreCourseController.java b/src/main/java/org/sunbird/course/controller/ExploreCourseController.java
index a17291461..4fa6ec8a6 100644
--- a/src/main/java/org/sunbird/course/controller/ExploreCourseController.java
+++ b/src/main/java/org/sunbird/course/controller/ExploreCourseController.java
@@ -1,8 +1,13 @@
package org.sunbird.course.controller;
+import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import org.sunbird.common.model.SBApiResponse;
import org.sunbird.course.service.ExploreCourseService;
@@ -37,4 +42,16 @@ public ResponseEntity getPublicCourseListV2() {
SBApiResponse response = courseService.getExploreCourseListV2();
return new ResponseEntity<>(response, response.getResponseCode());
}
+
+ @PostMapping("/course/v1/explore/upsert")
+ public ResponseEntity upsertCourse(@RequestBody Map request) {
+ SBApiResponse response = courseService.upsertExploreCourse(request);
+ return new ResponseEntity<>(response, response.getResponseCode());
+ }
+
+ @DeleteMapping("/course/v1/explore/delete/{courseId}")
+ public ResponseEntity deleteExploreCourse(@PathVariable String courseId) {
+ SBApiResponse response = courseService.deleteExploreCourse(courseId);
+ return new ResponseEntity<>(response, response.getResponseCode());
+ }
}
diff --git a/src/main/java/org/sunbird/course/service/ExploreCourseService.java b/src/main/java/org/sunbird/course/service/ExploreCourseService.java
index f74331865..3f0861931 100644
--- a/src/main/java/org/sunbird/course/service/ExploreCourseService.java
+++ b/src/main/java/org/sunbird/course/service/ExploreCourseService.java
@@ -1,5 +1,6 @@
package org.sunbird.course.service;
+import java.util.Map;
import org.sunbird.common.model.SBApiResponse;
/**
@@ -32,4 +33,8 @@ public interface ExploreCourseService {
* @return - Course details in Sunbird API Response format.
*/
public SBApiResponse getExploreCourseListV2();
+
+ public SBApiResponse upsertExploreCourse(Map request);
+
+ public SBApiResponse deleteExploreCourse(String id);
}
diff --git a/src/main/java/org/sunbird/course/service/ExploreCourseServiceImpl.java b/src/main/java/org/sunbird/course/service/ExploreCourseServiceImpl.java
index 0e4a60608..e64574c75 100644
--- a/src/main/java/org/sunbird/course/service/ExploreCourseServiceImpl.java
+++ b/src/main/java/org/sunbird/course/service/ExploreCourseServiceImpl.java
@@ -12,6 +12,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
+import org.springframework.util.ObjectUtils;
import org.sunbird.cache.RedisCacheMgr;
import org.sunbird.cassandra.utils.CassandraOperation;
import org.sunbird.common.model.SBApiResponse;
@@ -20,6 +21,7 @@
import org.sunbird.common.util.Constants;
import org.sunbird.common.util.ProjectUtil;
import org.sunbird.core.exception.ApplicationLogicError;
+import org.sunbird.staff.model.StaffInfo;
/**
* Implementation of ExploreCourseService
@@ -183,4 +185,134 @@ public SBApiResponse getExploreCourseListV2() {
}
return response;
}
+
+ @Override
+ public SBApiResponse upsertExploreCourse(Map requestObj) {
+ SBApiResponse response =
+ ProjectUtil.createDefaultResponse(Constants.API_EXPLORE_COURSE_UPDATE);
+ logger.info("ExploreCourseService::upsertExploreCourse:inside method");
+ Map masterData = (Map) requestObj.get(Constants.REQUEST);
+ String errMsg = validateUpsertRequest(masterData);
+ if (StringUtils.isNotBlank(errMsg)) {
+ response.getParams().setErrmsg(errMsg);
+ response.setResponseCode(HttpStatus.BAD_REQUEST);
+ return response;
+ }
+ try {
+ List> dataList = (List>) masterData.get(Constants.DATA);
+ Iterator> iterator = dataList.iterator();
+
+ while (iterator.hasNext()) {
+ Map, ?> itemMap = (Map) iterator.next();
+ Map request = new HashMap<>();
+ request.put(Constants.IDENTIFIER, itemMap.get(Constants.IDENTIFIER));
+
+ List