Examples of PaginatedPolicySetDTO


Examples of org.wso2.carbon.identity.entitlement.dto.PaginatedPolicySetDTO

     * @return PaginatedPolicySetDTO object containing the number of pages and the set of policies
     *         that reside in the given page.
     */
    private PaginatedPolicySetDTO doPaging(int pageNumber, PolicyDTO[] policySet) {

        PaginatedPolicySetDTO paginatedPolicySet = new PaginatedPolicySetDTO();
        if (policySet.length == 0) {
            paginatedPolicySet.setPolicySet(new PolicyDTO[0]);
            return paginatedPolicySet;
        }
        String itemsPerPage = ServerConfiguration.getInstance().getFirstProperty("ItemsPerPage");
        int itemsPerPageInt = DEFAULT_ITEMS_PER_PAGE;
        if (itemsPerPage != null) {
            itemsPerPageInt = Integer.parseInt(itemsPerPage);
        }
        int numberOfPages = (int) Math.ceil((double) policySet.length / itemsPerPageInt);
        if (pageNumber > numberOfPages - 1) {
            pageNumber = numberOfPages - 1;
        }
        int startIndex = pageNumber * itemsPerPageInt;
        int endIndex = (pageNumber + 1) * itemsPerPageInt;
        PolicyDTO[] returnedPolicySet = new PolicyDTO[itemsPerPageInt];

        for (int i = startIndex, j = 0; i < endIndex && i < policySet.length; i++, j++) {
            returnedPolicySet[j] = policySet[i];
        }

        paginatedPolicySet.setPolicySet(returnedPolicySet);
        paginatedPolicySet.setNumberOfPages(numberOfPages);

        return paginatedPolicySet;
    }
View Full Code Here

Examples of org.wso2.carbon.identity.entitlement.stub.dto.PaginatedPolicySetDTO

            return stub.getAllPolicies(policyTypeFilter, policySearchString, pageNumber);
        } catch (Exception e) {
            String message = "Error while loading all policies from backend service";
            handleException(message, e);
        }
        PaginatedPolicySetDTO paginatedPolicySetDTO =  new PaginatedPolicySetDTO();
        paginatedPolicySetDTO.setPolicySet(new PolicyDTO[0]);
        return paginatedPolicySetDTO;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.