Merge branch 'application-mgt-new' into 'application-mgt-new'

Fix APPM deadlock issue in review management

See merge request entgra/carbon-device-mgt!143
feature/appm-store/pbac
Dharmakeerthi Lasantha 6 years ago
commit e6f54646f8

@ -284,11 +284,6 @@ public class ReviewManagerImpl implements ReviewManager {
if (reviewDTO.getRootParentId() == -1 && reviewDTO.getImmediateParentId() == -1) { if (reviewDTO.getRootParentId() == -1 && reviewDTO.getImmediateParentId() == -1) {
if (!reviewDTO.getReleaseUuid().equals(uuid)) { if (!reviewDTO.getReleaseUuid().equals(uuid)) {
isActiveReview = false; isActiveReview = false;
if (!addReview(updatingReview, uuid, true)) {
String msg = "Review Updating Status: New review adding is failed.";
log.error(msg);
throw new ReviewManagementException(msg);
}
} else if (updatingReview.getRating() > 0 && updatingReview.getRating() != reviewDTO.getRating()) { } else if (updatingReview.getRating() > 0 && updatingReview.getRating() != reviewDTO.getRating()) {
Runnable task = () -> ReviewManagerImpl.this Runnable task = () -> ReviewManagerImpl.this
.calculateRating(updatingReview.getRating(), reviewDTO.getRating(), uuid, tenantId); .calculateRating(updatingReview.getRating(), reviewDTO.getRating(), uuid, tenantId);
@ -304,17 +299,35 @@ public class ReviewManagerImpl implements ReviewManager {
} }
reviewDTO.setContent(updatingReview.getContent()); reviewDTO.setContent(updatingReview.getContent());
} }
return updateReviewInDB(reviewDTO, uuid, reviewId, isActiveReview, tenantId);
if (updateReviewInDB(reviewDTO, reviewId, isActiveReview, tenantId)) {
if (!isActiveReview) {
if (addReview(updatingReview, uuid, true)) {
return true;
} else {
if (updateReviewInDB(reviewDTO, reviewId, true, tenantId)) {
return false;
} else {
String msg = "Review Updating Status: Adding new Review for application release which has UUID: "
+ "" + uuid + " is failed and the old review restoring is also failed.";
log.error(msg);
throw new ApplicationManagementException(msg);
}
}
}
return true;
} else {
String msg = "Review Updating is failed. Hence please contact the administrator.";
log.error(msg);
throw new ApplicationManagementException(msg);
}
} }
private boolean updateReviewInDB(ReviewDTO reviewDTO, String uuid, int reviewId, boolean isActiveReview, private boolean updateReviewInDB(ReviewDTO reviewDTO, int reviewId, boolean isActiveReview,
int tenantId) throws ReviewManagementException, ApplicationManagementException { int tenantId) throws ReviewManagementException, ApplicationManagementException {
try { try {
ConnectionManagerUtil.beginDBTransaction(); ConnectionManagerUtil.beginDBTransaction();
if (this.reviewDAO.updateReview(reviewDTO, reviewId, isActiveReview, tenantId) == 1) { if (this.reviewDAO.updateReview(reviewDTO, reviewId, isActiveReview, tenantId) == 1) {
if (!isActiveReview) {
updateAppRating(uuid, tenantId);
}
ConnectionManagerUtil.commitDBTransaction(); ConnectionManagerUtil.commitDBTransaction();
return true; return true;
} }

Loading…
Cancel
Save