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; + } }