From 99857c9acc91e16a110d443cd7b3716a3e3599b3 Mon Sep 17 00:00:00 2001 From: nishadi Date: Tue, 16 Jan 2018 16:01:19 +0530 Subject: [PATCH] Modify Util validateCommentListPageSize method is added. --- .../application/mgt/core/dao/common/Util.java | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/common/Util.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/common/Util.java index 2743a120c6..1513951128 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/common/Util.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/common/Util.java @@ -22,11 +22,16 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.json.JSONException; import org.wso2.carbon.device.application.mgt.common.Application; +import org.wso2.carbon.device.application.mgt.common.Platform; +import org.wso2.carbon.device.application.mgt.common.User; import org.wso2.carbon.device.application.mgt.common.Category; import org.wso2.carbon.device.application.mgt.common.Lifecycle; import org.wso2.carbon.device.application.mgt.common.LifecycleState; -import org.wso2.carbon.device.application.mgt.common.Platform; -import org.wso2.carbon.device.application.mgt.common.User; +import org.wso2.carbon.device.application.mgt.common.PaginationRequest; + +import org.wso2.carbon.device.application.mgt.common.exception.CommentManagementException; +import org.wso2.carbon.device.application.mgt.core.config.Configuration; +import org.wso2.carbon.device.application.mgt.core.config.ConfigurationManager; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -123,4 +128,18 @@ public class Util { } } } + + public static PaginationRequest validateCommentListPageSize(PaginationRequest paginationRequest) throws + CommentManagementException{ + if (paginationRequest.getLimit() == 0) { + Configuration commentManagementConfig = ConfigurationManager.getInstance().getConfiguration(); + if (commentManagementConfig != null) { + paginationRequest.setLimit(commentManagementConfig.getPaginationConfiguration().getCommentListPageSize()); + } else { + throw new CommentManagementException("Device-Mgt configuration has not initialized. Please check the " + + "cdm-config.xml file."); + } + } + return paginationRequest; + } }