Fix merge conflict

feature/appm-store/pbac
Jayasanka 6 years ago
commit 723a605c7d

@ -32,12 +32,6 @@ public class Review {
@ApiModelProperty(name = "content", value = "Review message.")
private String content;
@ApiModelProperty(name = "rootParentId", value = "Root Parent id of the review")
private int rootParentId;
@ApiModelProperty(name = "immediateParentId", value = "Immediate Parent id of the review")
private int immediateParentId;
@ApiModelProperty(name = "username", value = "Username odf the Review creator")
private String username;
@ -50,6 +44,12 @@ public class Review {
@ApiModelProperty(name = "rating", value = "Rating value of the application release")
private int rating;
@ApiModelProperty(name = "releaseUuid", value = "UUID of the review associated application")
private String releaseUuid;
@ApiModelProperty(name = "releaseVersion", value = "Version of the review associated application")
private String releaseVersion;
@ApiModelProperty(name = "replies", value = "Replying reviews")
private List<Review> replies;
@ -69,22 +69,6 @@ public class Review {
this.content = content;
}
public int getRootParentId() {
return rootParentId;
}
public void setRootParentId(int rootParentId) {
this.rootParentId = rootParentId;
}
public int getImmediateParentId() {
return immediateParentId;
}
public void setImmediateParentId(int immediateParentId) {
this.immediateParentId = immediateParentId;
}
public String getUsername() {
return username;
}
@ -120,4 +104,12 @@ public class Review {
public List<Review> getReplies() { return replies; }
public void setReplies(List<Review> replies) { this.replies = replies; }
public String getReleaseUuid() { return releaseUuid; }
public void setReleaseUuid(String releaseUuid) { this.releaseUuid = releaseUuid; }
public String getReleaseVersion() { return releaseVersion; }
public void setReleaseVersion(String releaseVersion) { this.releaseVersion = releaseVersion; }
}

@ -16,7 +16,7 @@
* under the License.
*
*/
package org.wso2.carbon.device.application.mgt.core.dao.impl.review;
package org.wso2.carbon.device.application.mgt.core.dao.impl.Review;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@ -110,7 +110,7 @@ public class ReviewDAOImpl extends AbstractDAOImpl implements ReviewDAO {
try {
conn = this.getDBConnection();
StringJoiner joiner = new StringJoiner(",",
"SELECT rv.ID FROM AP_APP_REVIEW rv " + "WHERE rv.AP_APP_RELEASE_ID IN (",
"SELECT rv.ID FROM AP_APP_REVIEW rv WHERE rv.AP_APP_RELEASE_ID IN (",
") AND rv.USERNAME = ? AND rv.TENANT_ID = ?");
appReleaseIds.stream().map(ignored -> "?").forEach(joiner::add);
String query = joiner.toString();
@ -118,7 +118,7 @@ public class ReviewDAOImpl extends AbstractDAOImpl implements ReviewDAO {
for (Integer deviceId : appReleaseIds) {
ps.setObject(index++, deviceId);
}
ps.setInt(index++, tenantId);
ps.setString(index++, username);
ps.setInt(index, tenantId);
try (ResultSet rs = ps.executeQuery()) {
return rs.next();

@ -238,8 +238,8 @@ public class ReviewManagerImpl implements ReviewManager {
Review review = new Review();
review.setId(reviewDTO.getId());
review.setContent(reviewDTO.getContent());
review.setRootParentId(reviewDTO.getRootParentId());
review.setImmediateParentId(reviewDTO.getImmediateParentId());
review.setReleaseUuid(reviewDTO.getReleaseUuid());
review.setReleaseVersion(reviewDTO.getReleaseVersion());
review.setCreatedAt(reviewDTO.getCreatedAt());
review.setModifiedAt(reviewDTO.getModifiedAt());
review.setRating(reviewDTO.getRating());
@ -284,11 +284,6 @@ public class ReviewManagerImpl implements ReviewManager {
if (reviewDTO.getRootParentId() == -1 && reviewDTO.getImmediateParentId() == -1) {
if (!reviewDTO.getReleaseUuid().equals(uuid)) {
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()) {
Runnable task = () -> ReviewManagerImpl.this
.calculateRating(updatingReview.getRating(), reviewDTO.getRating(), uuid, tenantId);
@ -304,17 +299,35 @@ public class ReviewManagerImpl implements ReviewManager {
}
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 {
try {
ConnectionManagerUtil.beginDBTransaction();
if (this.reviewDAO.updateReview(reviewDTO, reviewId, isActiveReview, tenantId) == 1) {
if (!isActiveReview) {
updateAppRating(uuid, tenantId);
}
ConnectionManagerUtil.commitDBTransaction();
return true;
}

Loading…
Cancel
Save