From d09124e2092dabd33c2360dbaa1c991bc7466685 Mon Sep 17 00:00:00 2001 From: Radhesh Date: Thu, 30 Jun 2022 18:38:35 +0530 Subject: [PATCH] CBP Rating + Feedback + Reply feature issue coding changes --- .../org/sunbird/ratings/service/RatingServiceImpl.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/sunbird/ratings/service/RatingServiceImpl.java b/src/main/java/org/sunbird/ratings/service/RatingServiceImpl.java index 2b4cd81c0..689fd4fb4 100644 --- a/src/main/java/org/sunbird/ratings/service/RatingServiceImpl.java +++ b/src/main/java/org/sunbird/ratings/service/RatingServiceImpl.java @@ -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); @@ -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); }