Skip to content

Commit

Permalink
Merge pull request #105 from sunbird-cb/upsert-issue
Browse files Browse the repository at this point in the history
CBP Rating + Feedback + Reply feature issue coding changes
  • Loading branch information
pkranga authored Jun 30, 2022
2 parents 3acb36c + d09124e commit d5fd10a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/main/java/org/sunbird/ratings/service/RatingServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,10 @@ public SBApiResponse upsertRating(RequestRating requestRating) {
}
response.setResponseCode(HttpStatus.OK);
response.getParams().setStatus(Constants.SUCCESSFUL);
kafkaProducer.push(updateRatingTopicName, ratingMessage);
if(requestRating.getComment()==null && requestRating.getCommentBy()==null) {
System.out.println("Message "+mapper.writeValueAsString(ratingMessage));
kafkaProducer.push(updateRatingTopicName, ratingMessage);
}
} catch (ValidationException ex) {
logger.error(ex);
processExceptionBody(response, ex, "", HttpStatus.BAD_REQUEST);
Expand Down Expand Up @@ -370,10 +373,11 @@ private void validateRatingsInfo(ValidationBody validationBody, String flag) thr
|| validationBody.getRequestRating().getRating() > 5) {
errObjList.add(ResponseMessage.Message.INVALID_INPUT + ResponseMessage.Message.INVALID_RATING);
}
if (StringUtils.isEmpty(validationBody.getRequestRating().getReview())
|| (!Pattern.matches("^[-A-Za-z0-9.!;_?@&\n\"\", ]++$", validationBody.getRequestRating().getReview()))) {
if (validationBody.getRequestRating().getReview()!=null){
if(!Pattern.matches("^[-A-Za-z0-9.!;_?@&\n\"\", ]++$", validationBody.getRequestRating().getReview())) {
errObjList.add(ResponseMessage.Message.INVALID_REVIEW);
}
}
if (StringUtils.isEmpty(validationBody.getRequestRating().getUserId())) {
errObjList.add(ResponseMessage.Message.INVALID_USER);
}
Expand Down

0 comments on commit d5fd10a

Please sign in to comment.