Skip to content

Commit

Permalink
Assessment submit prod issue fix changes and added the changes from t…
Browse files Browse the repository at this point in the history
…he given commit id to my private branch (#158)
  • Loading branch information
Basava1132 authored Dec 2, 2022
1 parent 1dc4885 commit f6eac10
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,17 @@ public Map<String, Object> submitAssessment(String rootOrg, AssessmentSubmission
if (Boolean.TRUE.equals(data.isAssessment()) && !"".equals(parentId)) {
// get parent data for assessment
try {
SunbirdApiResp contentHierarchy = contentService.getHeirarchyResponse(parentId);
if (contentHierarchy != null) {
persist.put("parentContentType", contentHierarchy.getResult().getContent().getContentType());
Map<String, Object> contentResponse = contentService.searchLiveContent(parentId);
if (!ObjectUtils.isEmpty(contentResponse)) {
Map<String, Object> contentResult = (Map<String, Object>) contentResponse.get(Constants.RESULT);
if (0 < (Integer) contentResult.get(Constants.COUNT)) {
List<Map<String, Object>> contentList = (List<Map<String, Object>>) contentResult
.get(Constants.CONTENT);
Map<String, Object> content = contentList.get(0);
persist.put(Constants.PARENT_CONTENT_SEARCH, (String) content.get(Constants.CONTENT_TYPE_SEARCH));
}
}
} catch (Exception e) {
} catch (Exception e) {
logger.error(e);
}
} else {
Expand Down
12 changes: 5 additions & 7 deletions src/main/java/org/sunbird/common/service/ContentServiceImpl.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
package org.sunbird.common.service;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
Expand All @@ -17,6 +13,8 @@

import com.fasterxml.jackson.databind.ObjectMapper;

import static java.util.Objects.nonNull;

@Service
public class ContentServiceImpl implements ContentService {

Expand All @@ -37,7 +35,7 @@ public SunbirdApiResp getHeirarchyResponse(String contentId) {
.append("?hierarchyType=detail");
SunbirdApiResp response = mapper.convertValue(outboundRequestHandlerService.fetchResult(url.toString()),
SunbirdApiResp.class);
if (response.getResponseCode().equalsIgnoreCase("Ok")) {
if (nonNull(response) && response.getResponseCode().equalsIgnoreCase("Ok")) {
return response;
}

Expand Down Expand Up @@ -186,7 +184,7 @@ public Map<String, Object> searchLiveContent(String contentId) {
Map<String, Object> contentRequestValue = new HashMap<>();
contentRequestValue.put(Constants.FILTERS, filters);
contentRequestValue.put(Constants.FIELDS,
Arrays.asList(Constants.IDENTIFIER, Constants.NAME, Constants.PRIMARY_CATEGORY, Constants.BATCHES, Constants.LEAF_NODES_COUNT));
Arrays.asList(Constants.IDENTIFIER, Constants.NAME, Constants.PRIMARY_CATEGORY, Constants.BATCHES, Constants.LEAF_NODES_COUNT, Constants.CONTENT_TYPE_SEARCH));
Map<String, Object> contentRequest = new HashMap<>();
contentRequest.put(Constants.REQUEST, contentRequestValue);
response = outboundRequestHandlerService.fetchResultUsingPost(
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/sunbird/common/util/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,7 @@ public class Constants {
public static final String MIN = "min";
public static final String MAX = "max";
public static final String CONTENT_TYPE_SEARCH = "contentType";
public static final String PARENT_CONTENT_SEARCH="parentContentType";
public static final String NEW_COURSES = "newcourses";
public static final String OVERVIEW_BATCH_KEY = "/overview?batchId=";
public static final String LEAF_NODES_COUNT = "leafNodesCount";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ public SBApiResponse profileUpdate(Map<String, Object> request, String userToken
response.getResult().put(Constants.RESPONSE, Constants.SUCCESS);
response.getParams().setStatus(Constants.SUCCESS);
} else {
if (Constants.CLIENT_ERROR.equalsIgnoreCase((String) updateResponse.get(Constants.RESPONSE_CODE))) {
if (updateResponse != null && Constants.CLIENT_ERROR
.equalsIgnoreCase((String) updateResponse.get(Constants.RESPONSE_CODE))) {
response.setResponseCode(HttpStatus.BAD_REQUEST);
} else {
response.setResponseCode(HttpStatus.INTERNAL_SERVER_ERROR);
Expand Down

0 comments on commit f6eac10

Please sign in to comment.