|
|
@ -28,7 +28,6 @@ import org.wso2.carbon.device.application.mgt.common.PaginationResult;
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.exception.ReviewDoesNotExistException;
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.exception.ReviewDoesNotExistException;
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.exception.ReviewManagementException;
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.exception.ReviewManagementException;
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.exception.DBConnectionException;
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.exception.DBConnectionException;
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.exception.TransactionManagementException;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.services.*;
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.services.*;
|
|
|
|
import org.wso2.carbon.device.application.mgt.core.dao.ApplicationReleaseDAO;
|
|
|
|
import org.wso2.carbon.device.application.mgt.core.dao.ApplicationReleaseDAO;
|
|
|
|
import org.wso2.carbon.device.application.mgt.core.dao.ReviewDAO;
|
|
|
|
import org.wso2.carbon.device.application.mgt.core.dao.ReviewDAO;
|
|
|
@ -84,20 +83,7 @@ public class ReviewManagerImpl implements ReviewManager {
|
|
|
|
Runnable task = () -> calculateRating(review.getRating(), -12345, uuid, tenantId);
|
|
|
|
Runnable task = () -> calculateRating(review.getRating(), -12345, uuid, tenantId);
|
|
|
|
new Thread(task).start();
|
|
|
|
new Thread(task).start();
|
|
|
|
review.setUsername(username);
|
|
|
|
review.setUsername(username);
|
|
|
|
try {
|
|
|
|
isSuccess = this.reviewDAO.addReview(review, uuid, tenantId);
|
|
|
|
ConnectionManagerUtil.beginDBTransaction();
|
|
|
|
|
|
|
|
isSuccess = this.reviewDAO.addReview(review, uuid, tenantId);
|
|
|
|
|
|
|
|
if (isSuccess) {
|
|
|
|
|
|
|
|
ConnectionManagerUtil.commitDBTransaction();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
ConnectionManagerUtil.rollbackDBTransaction();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (TransactionManagementException e) {
|
|
|
|
|
|
|
|
ConnectionManagerUtil.rollbackDBTransaction();
|
|
|
|
|
|
|
|
throw new ReviewManagementException(
|
|
|
|
|
|
|
|
"Transaction Management Exception occurs,Review for application release with UUID:" + uuid
|
|
|
|
|
|
|
|
+ " is failed ", e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return isSuccess;
|
|
|
|
return isSuccess;
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
@ -147,24 +133,7 @@ public class ReviewManagerImpl implements ReviewManager {
|
|
|
|
if (review.getRating() == 0) {
|
|
|
|
if (review.getRating() == 0) {
|
|
|
|
review.setRating(existingReview.getRating());
|
|
|
|
review.setRating(existingReview.getRating());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
return this.reviewDAO.updateReview(review, reviewId, username, tenantId) == 1;
|
|
|
|
ConnectionManagerUtil.beginDBTransaction();
|
|
|
|
|
|
|
|
if (this.reviewDAO.updateReview(review, reviewId, username, tenantId) == 1) {
|
|
|
|
|
|
|
|
ConnectionManagerUtil.commitDBTransaction();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ConnectionManagerUtil.rollbackDBTransaction();
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
} catch (TransactionManagementException e) {
|
|
|
|
|
|
|
|
ConnectionManagerUtil.rollbackDBTransaction();
|
|
|
|
|
|
|
|
throw new ReviewManagementException(
|
|
|
|
|
|
|
|
"Transaction management error occurs when updating review with review id " + reviewId + ".", e);
|
|
|
|
|
|
|
|
} catch (ReviewManagementDAOException e) {
|
|
|
|
|
|
|
|
ConnectionManagerUtil.rollbackDBTransaction();
|
|
|
|
|
|
|
|
throw new ReviewManagementException(
|
|
|
|
|
|
|
|
"Error occured while updating review with review id " + reviewId + ".", e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (ReviewManagementDAOException e) {
|
|
|
|
} catch (ReviewManagementDAOException e) {
|
|
|
|
throw new ReviewManagementException("Error occured while getting review with review id " + reviewId + ".",
|
|
|
|
throw new ReviewManagementException("Error occured while getting review with review id " + reviewId + ".",
|
|
|
|
e);
|
|
|
|
e);
|
|
|
@ -242,23 +211,14 @@ public class ReviewManagerImpl implements ReviewManager {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Runnable task = () -> calculateRating(0, existingReview.getRating(), uuid, tenantId);
|
|
|
|
Runnable task = () -> calculateRating(0, existingReview.getRating(), uuid, tenantId);
|
|
|
|
new Thread(task).start();
|
|
|
|
new Thread(task).start();
|
|
|
|
ConnectionManagerUtil.beginDBTransaction();
|
|
|
|
return isAuthorizedUser(username, existingReview.getUsername(), tenantId)
|
|
|
|
if (isAuthorizedUser(username, existingReview.getUsername(), tenantId)
|
|
|
|
&& this.reviewDAO.deleteReview(username, reviewId) == 1;
|
|
|
|
&& this.reviewDAO.deleteReview(username, reviewId) == 1) {
|
|
|
|
|
|
|
|
ConnectionManagerUtil.commitDBTransaction();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ConnectionManagerUtil.rollbackDBTransaction();
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
throw new ReviewManagementException(
|
|
|
|
throw new ReviewManagementException(
|
|
|
|
"DB Connection error occurs deleting review with review id " + reviewId + ".", e);
|
|
|
|
"DB Connection error occurs deleting review with review id " + reviewId + ".", e);
|
|
|
|
} catch (ReviewManagementDAOException e) {
|
|
|
|
} catch (ReviewManagementDAOException e) {
|
|
|
|
throw new ReviewManagementException("Error occured while deleting review with review id " + reviewId + ".",
|
|
|
|
throw new ReviewManagementException("Error occured while deleting review with review id " + reviewId + ".",
|
|
|
|
e);
|
|
|
|
e);
|
|
|
|
} catch (TransactionManagementException e) {
|
|
|
|
|
|
|
|
throw new ReviewManagementException(
|
|
|
|
|
|
|
|
"Transaction Management Exception occurs deleting review with review id " + reviewId + ".", e);
|
|
|
|
|
|
|
|
} catch (UserStoreException e) {
|
|
|
|
} catch (UserStoreException e) {
|
|
|
|
throw new ReviewManagementException(
|
|
|
|
throw new ReviewManagementException(
|
|
|
|
"User-store exception while checking whether the user " + username + " of tenant " + tenantId
|
|
|
|
"User-store exception while checking whether the user " + username + " of tenant " + tenantId
|
|
|
@ -330,20 +290,7 @@ public class ReviewManagerImpl implements ReviewManager {
|
|
|
|
tmpVal = currentRating - oldRatingVal;
|
|
|
|
tmpVal = currentRating - oldRatingVal;
|
|
|
|
updatedRating = (tmpVal + newRatingVal) / numOfUsers;
|
|
|
|
updatedRating = (tmpVal + newRatingVal) / numOfUsers;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
this.applicationReleaseDAO.updateRatingValue(uuid, updatedRating, numOfUsers);
|
|
|
|
ConnectionManagerUtil.beginDBTransaction();
|
|
|
|
|
|
|
|
this.applicationReleaseDAO.updateRatingValue(uuid, updatedRating, numOfUsers);
|
|
|
|
|
|
|
|
ConnectionManagerUtil.commitDBTransaction();
|
|
|
|
|
|
|
|
} catch (TransactionManagementException e) {
|
|
|
|
|
|
|
|
ConnectionManagerUtil.rollbackDBTransaction();
|
|
|
|
|
|
|
|
log.error(
|
|
|
|
|
|
|
|
"Transaction Management Exception occured while updated the rating value of the application release UUID: "
|
|
|
|
|
|
|
|
+ uuid, e);
|
|
|
|
|
|
|
|
} catch (ApplicationManagementDAOException e) {
|
|
|
|
|
|
|
|
ConnectionManagerUtil.rollbackDBTransaction();
|
|
|
|
|
|
|
|
log.error("Error occured while updated the rating value of the application release UUID: " + uuid,
|
|
|
|
|
|
|
|
e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (ApplicationManagementDAOException e) {
|
|
|
|
} catch (ApplicationManagementDAOException e) {
|
|
|
|
log.error("Error occured while getting the rating value of the application release UUID: " + uuid, e);
|
|
|
|
log.error("Error occured while getting the rating value of the application release UUID: " + uuid, e);
|
|
|
|