Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev 4.8.5 #280

Open
wants to merge 10 commits into
base: cbrelease-4.8.5
Choose a base branch
from
25 changes: 25 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
Expand All @@ -28,5 +29,29 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="target/generated-sources/annotations">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="m2e-apt" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="m2e-apt" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
11 changes: 11 additions & 0 deletions .project
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,15 @@
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
<filteredResources>
<filter>
<id>1691054016055</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
4 changes: 4 additions & 0 deletions .settings/org.eclipse.jdt.apt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
eclipse.preferences.version=1
org.eclipse.jdt.apt.aptEnabled=true
org.eclipse.jdt.apt.genSrcDir=target/generated-sources/annotations
org.eclipse.jdt.apt.genTestSrcDir=target/generated-test-sources/test-annotations
1 change: 1 addition & 0 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.processAnnotations=enabled
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
14 changes: 14 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"configurations": [
{
"type": "java",
"name": "Spring Boot-SbCbExtApplication<sb-cb-ext>",
"request": "launch",
"cwd": "${workspaceFolder}",
"mainClass": "org.sunbird.portal.SbCbExtApplication",
"projectName": "sb-cb-ext",
"args": "",
"envFile": "${workspaceFolder}/.env"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ private static Cluster createCluster(String[] hosts, PoolingOptions poolingOptio
}

private static ConsistencyLevel getConsistencyLevel() {
String consistency = ProjectUtil.getConfigValue(Constants.SUNBIRD_CASSANDRA_CONSISTENCY_LEVEL);
String consistency = PropertiesCache.getInstance().readProperty(Constants.SUNBIRD_CASSANDRA_CONSISTENCY_LEVEL);

logger.info("CassandraConnectionManagerImpl:getConsistencyLevel: level = " + consistency);

Expand Down
11 changes: 11 additions & 0 deletions src/main/java/org/sunbird/common/util/CbExtServerProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,9 @@ public class CbExtServerProperties {
@Value("${assessment.ratake.count.verification.enabled}")
private boolean assessmentRetakeCountVerificationEnabled;

@Value("${bulk.upload.tag.verification.regex}")
private String bulkUploadTagVerificationRegex;

public String getAssessmentSubmitTopic() {
return assessmentSubmitTopic;
}
Expand Down Expand Up @@ -1705,4 +1708,12 @@ public boolean isAssessmentRetakeCountVerificationEnabled() {
public void setAssessmentRetakeCountVerificationEnabled(boolean assessmentRetakeCountVerificationEnabled) {
this.assessmentRetakeCountVerificationEnabled = assessmentRetakeCountVerificationEnabled;
}

public String getBulkUploadTagVerificationRegex() {
return bulkUploadTagVerificationRegex;
}

public void setBulkUploadTagVerificationRegex(String bulkUploadTagVerificationRegex) {
this.bulkUploadTagVerificationRegex = bulkUploadTagVerificationRegex;
}
}
8 changes: 5 additions & 3 deletions src/main/java/org/sunbird/common/util/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,11 @@ public class Constants {
public static final String USERID = "id";
public static final String COMMENT = "comment";
public static final String COMMENT_BY = "commentBy";
public static final String COMMENT_UPDATED_ON = "commentupdatedon";
public static final String CREATED_ON = "createdon";
public static final String COMMENT_UPDATED_ON = "commentUpdatedOn";
public static final String CREATED_ON = "createdOn";
public static final String RATING = "rating";
public static final String REVIEW = "review";
public static final String UPDATED_ON = "updatedon";
public static final String UPDATED_ON = "updatedOn";
public static final String LATEST50REVIEWS = "latest50reviews";
public static final String SUMMARY_ACTIVITY_ID = "activityid";
public static final String SUMMARY_ACTIVITY_TYPE = "activitytype";
Expand Down Expand Up @@ -683,6 +683,7 @@ public class Constants {
public static final String BULK_USER_UPDATE_API_FAILED = "Bulk User Update API Failed";
public static final String SECURE_SETTINGS = "secureSettings";
public static final String API_USER_ENROLMENT = "user.enrolment";
public static final String USER_REGISTRATION_GROUP_LIST = "api.user.registration.group.list";
public static final String SUBMIT_ASSESSMENT_RESPONSE_KEY = "submitAssessmentResponse";
public static final String API_READ_ASSESSMENT = "api.assessment.read";
public static final String API_READ_ASSESSMENT_RESULT = "api.assessment.read.result";
Expand All @@ -692,6 +693,7 @@ public class Constants {
public static final String START_TIME_KEY = "startTime";
public static final String VERIFIED_PROFILE_FIELDS_KEY = "verifiedProfileFields";
public static final String PROFILE_APPROVAL_FIELDS_KEY = "profileApprovalFields";
public static final String BULK_UPLOAD_VERIFICATION_REGEX = "bulk.upload.tag.verification.regex";

private Constants() {
throw new IllegalStateException("Utility class");
Expand Down
21 changes: 6 additions & 15 deletions src/main/java/org/sunbird/common/util/ProjectUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,7 @@
public class ProjectUtil {

public static CbExtLogger logger = new CbExtLogger(ProjectUtil.class.getName());

public static PropertiesCache propertiesCache;

static {
propertiesCache = PropertiesCache.getInstance();
}

public static String getConfigValue(String key) {
if (StringUtils.isNotBlank(System.getenv(key))) {
return System.getenv(key);
}
return propertiesCache.readProperty(key);
}
public static String DEFAULT_BULK_UPLOAD_VERIFICATION_REGEX = "^[a-zA-Z\\s,]+$";

/**
* This method will check incoming value is null or empty it will do empty check
Expand Down Expand Up @@ -119,7 +107,6 @@ public static String firstLetterCapitalWithSingleSpace(final String words) {
public static Boolean validateEmailPattern(String email) {
String emailRegex = "^[a-zA-Z0-9_+&*-]+(?:\\." + "[a-zA-Z0-9_+&*-]+)*@" + "(?:[a-zA-Z0-9-]+\\.)+[a-z"
+ "A-Z]{2,7}$";
Boolean retValue = Boolean.FALSE;
Pattern pat = Pattern.compile(emailRegex);
if (pat.matcher(email).matches()) {
return Boolean.TRUE;
Expand Down Expand Up @@ -148,8 +135,12 @@ public static Boolean validateFullName(String firstName ) {
}

public static Boolean validateTag(List<String> tags) {
String regEx = PropertiesCache.getInstance().getProperty(Constants.BULK_UPLOAD_VERIFICATION_REGEX);
if (StringUtils.isBlank(regEx)) {
regEx = DEFAULT_BULK_UPLOAD_VERIFICATION_REGEX;
}
for (String tag : tags) {
if (!tag.matches("^[a-zA-Z]+(?: [a-zA-Z]+)*$")) {
if (!tag.matches(regEx)) {
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,10 @@ public ResponseEntity<?> generateUserReport() {
public ResponseEntity<?> downloadFile(@PathVariable("fileName") String fileName) {
return profileService.downloadFile(fileName);
}

@GetMapping("/user/v1/groups")
public ResponseEntity<?> getGroupList() throws Exception {
SBApiResponse response = profileService.getGroupList();
return new ResponseEntity<>(response, response.getResponseCode());
}
}
2 changes: 2 additions & 0 deletions src/main/java/org/sunbird/profile/service/ProfileService.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,6 @@ public interface ProfileService {
SBApiResponse getUserReport();

ResponseEntity<Resource> downloadFile(String fileName);

SBApiResponse getGroupList();
}
32 changes: 30 additions & 2 deletions src/main/java/org/sunbird/profile/service/ProfileServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,9 @@ public SBApiResponse userBasicInfo(String userId) {
Map<String, Object> personalDetail = (Map<String, Object>) profileData
.get(Constants.PERSONAL_DETAILS);
responseMap.put(Constants.EMAIL, personalDetail.get(Constants.PRIMARY_EMAIL));
if (personalDetail.containsKey(Constants.MOBILE)) {
responseMap.put(Constants.PHONE, String.valueOf(personalDetail.get(Constants.MOBILE)));
}
}

responseMap.put(Constants.FIRSTNAME, userData.get(Constants.FIRSTNAME));
Expand Down Expand Up @@ -886,7 +889,7 @@ private String validateBasicProfilePayload(Map<String, Object> requestObj) {
errList.add(Constants.REQUEST);
} else {
Map<String, Object> request = (Map<String, Object>) requestObj.get(Constants.REQUEST);
List<String> keys = Arrays.asList(Constants.USER_ID, Constants.POSITION, Constants.CHANNEL,
List<String> keys = Arrays.asList(Constants.USER_ID, Constants.GROUP, Constants.CHANNEL,
Constants.MAP_ID, Constants.ORGANIZATION_TYPE, Constants.ORGANIZATION_SUB_TYPE);
for (String key : keys) {
if (StringUtils.isBlank((String) request.get(key))) {
Expand Down Expand Up @@ -1017,7 +1020,7 @@ private String updateUserProfile(Map<String, Object> request) {
};
existingProfile.put(Constants.PROFESSIONAL_DETAILS, professionalDetails);
}
professionalDetails.get(0).put(Constants.DESIGNATION, request.get(Constants.POSITION));
professionalDetails.get(0).put(Constants.GROUP, request.get(Constants.GROUP));
professionalDetails.get(0).put(Constants.ORGANIZATION_TYPE, Constants.GOVERNMENT);

Map<String, Object> empDetails;
Expand Down Expand Up @@ -1186,6 +1189,17 @@ private boolean updateUser(Map<String, Object> requestObject) {
Map<String, Object> requestBody = (Map<String, Object>) requestObject.get(Constants.REQUEST);
personalDetails.put(Constants.FIRSTNAME.toLowerCase(), requestBody.get(Constants.FIRSTNAME));
personalDetails.put(Constants.PRIMARY_EMAIL, requestBody.get(Constants.EMAIL));
if (requestBody.containsKey(Constants.PHONE)) {
String incomingPhoneValue = "";
try {
incomingPhoneValue = (String) requestBody.get(Constants.PHONE);
long mobileNumber = Long.parseLong(incomingPhoneValue);
personalDetails.put(Constants.MOBILE, mobileNumber);
} catch (NumberFormatException e) {
log.error("Failed to parse mobile number from signup request. Received Phone: " + incomingPhoneValue
+ ", Exception: " + e.getMessage(), e);
}
}
profileDetails.put(Constants.PERSONAL_DETAILS, personalDetails);

Map<String, Object> professionDetailObj = new HashMap<String, Object>();
Expand Down Expand Up @@ -1595,4 +1609,18 @@ public ResponseEntity<Resource> downloadFile(String fileName) {
}
}
}

@Override
public SBApiResponse getGroupList() {
SBApiResponse response = ProjectUtil.createDefaultResponse(Constants.USER_REGISTRATION_GROUP_LIST);
List<String> groupList = serverConfig.getBulkUploadGroupValue();
if (CollectionUtils.isNotEmpty(groupList)) {
response.getResult().put(Constants.COUNT, groupList.size());
response.getResult().put(Constants.RESPONSE, groupList);
} else {
response.setResponseCode(HttpStatus.INTERNAL_SERVER_ERROR);
response.getParams().setStatus(Constants.FAILED);
}
return response;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,10 @@ private void processBulkUpload(HashMap<String, String> inputDataMap) throws IOEx
String tagStr = nextRow.getCell(4).getStringCellValue().trim();
List<String> tagList = new ArrayList<String>();
if (!StringUtils.isEmpty(tagStr)) {
tagList = Arrays.asList(tagStr.split(",", -1));
String[] tagStrList = tagStr.split(",", -1);
for(String tag : tagStrList) {
tagList.add(tag.trim());
}
}
userRegistration.setTag(tagList);
if (!ProjectUtil.validateTag(userRegistration.getTag())) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
package org.sunbird.ratings.controller;

import java.util.Map;

import javax.validation.Valid;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
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.ratings.model.LookupRequest;
import org.sunbird.ratings.model.RequestRating;
import org.sunbird.ratings.service.RatingService;

import javax.validation.Valid;

@RestController
public class RatingsController {

Expand All @@ -22,7 +28,6 @@ public class RatingsController {
public ResponseEntity<?> upsertRating(@Valid @RequestBody RequestRating requestRatingBody) {
SBApiResponse response = ratingService.upsertRating(requestRatingBody);
return new ResponseEntity<>(response, response.getResponseCode());

}

@GetMapping("/ratings/v1/read/{activityId}/{activityType}/{userId}")
Expand All @@ -31,7 +36,6 @@ public ResponseEntity<?> getRating(@PathVariable("activityId") String activityId
@PathVariable("userId") String userId) {
SBApiResponse response = ratingService.getRatings(activityId, activityType, userId);
return new ResponseEntity<>(response, response.getResponseCode());

}

@GetMapping("/ratings/v1/summary/{activityId}/{activityType}")
Expand All @@ -46,5 +50,11 @@ public ResponseEntity<?> ratingLookUp(@RequestBody LookupRequest request) {
SBApiResponse response = ratingService.ratingLookUp(request);
return new ResponseEntity<>(response, response.getResponseCode());
}

@PostMapping("/ratings/v2/read")
public ResponseEntity<?> readRating(@RequestBody Map<String, Object> request) {
SBApiResponse response = ratingService.readRatings(request);
return new ResponseEntity<>(response, response.getResponseCode());
}
}

Loading