Java Code Examples for org.wso2.carbon.identity.core.util.IdentityUtil#getMaximumItemPerPage()

The following examples show how to use org.wso2.carbon.identity.core.util.IdentityUtil#getMaximumItemPerPage() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IdentityProviderManager.java    From carbon-identity-framework with Apache License 2.0 6 votes vote down vote up
/**
 * Validate limit.
 *
 * @param limit given limit value.
 * @return validated limit and offset value.
 */
private int validateLimit(Integer limit) throws IdentityProviderManagementClientException {

    if (limit == null) {
        if (log.isDebugEnabled()) {
            log.debug("Given limit is null. Therefore we get the default limit from " +
                    "identity.xml.");
        }
        limit = IdentityUtil.getDefaultItemsPerPage();
    }
    if (limit < 0) {
        String message = "Given limit: " + limit + " is a negative value.";
        throw IdPManagementUtil.handleClientException(IdPManagementConstants.ErrorMessage.ERROR_CODE_RETRIEVE_IDP,
                message);
    }

    int maximumItemsPerPage = IdentityUtil.getMaximumItemPerPage();
    if (limit > maximumItemsPerPage) {
        if (log.isDebugEnabled()) {
            log.debug("Given limit exceed the maximum limit. Therefore we get the default limit from " +
                    "identity.xml. limit: " + maximumItemsPerPage);
        }
        limit = maximumItemsPerPage;
    }
    return limit;
}
 
Example 2
Source File: ServerScriptLibrariesService.java    From identity-api-server with Apache License 2.0 5 votes vote down vote up
/**
 * Validate the limit.
 *
 * @param limit Limit value.
 * @return Validated limit.
 */
private int validateLimit(Integer limit) {

    final int maximumItemPerPage = IdentityUtil.getMaximumItemPerPage();
    if (limit == null) {
        return IdentityUtil.getDefaultItemsPerPage();
    } else if (limit <= maximumItemPerPage) {
        return limit;
    } else {
        return maximumItemPerPage;
    }
}
 
Example 3
Source File: ServerApplicationManagementService.java    From identity-api-server with Apache License 2.0 5 votes vote down vote up
private int validateAndGetLimit(Integer limit) {

        final int maximumItemPerPage = IdentityUtil.getMaximumItemPerPage();
        if (limit != null && limit > 0 && limit <= maximumItemPerPage) {
            return limit;
        } else {
            return IdentityUtil.getDefaultItemsPerPage();
        }
    }