Search in sources :

Example 16 with CustomRuleDTO

use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.CustomRuleDTO in project carbon-apimgt by wso2.

the class GlobalThrottlePolicyMappingUtil method fromGlobalPolicyArrayToListDTO.

/**
 * Converts an array of Global policy model objects into REST API DTO objects
 *
 * @param GlobalPolicies An array of Global Policy model objects
 * @return A List DTO of Global Policy DTOs derived from the array of model objects
 * @throws UnsupportedThrottleLimitTypeException
 */
public static CustomRuleListDTO fromGlobalPolicyArrayToListDTO(GlobalPolicy[] GlobalPolicies) throws UnsupportedThrottleLimitTypeException {
    CustomRuleListDTO listDTO = new CustomRuleListDTO();
    List<CustomRuleDTO> globalPolicyDTOList = new ArrayList<>();
    if (GlobalPolicies != null) {
        for (GlobalPolicy policy : GlobalPolicies) {
            CustomRuleDTO dto = fromGlobalThrottlePolicyToDTO(policy);
            globalPolicyDTOList.add(dto);
        }
    }
    listDTO.setCount(globalPolicyDTOList.size());
    listDTO.setList(globalPolicyDTOList);
    return listDTO;
}
Also used : CustomRuleDTO(org.wso2.carbon.apimgt.rest.api.admin.v1.dto.CustomRuleDTO) GlobalPolicy(org.wso2.carbon.apimgt.api.model.policy.GlobalPolicy) ArrayList(java.util.ArrayList) CustomRuleListDTO(org.wso2.carbon.apimgt.rest.api.admin.v1.dto.CustomRuleListDTO)

Aggregations

CustomPolicy (org.wso2.carbon.apimgt.core.models.policy.CustomPolicy)9 CustomRuleDTO (org.wso2.carbon.apimgt.rest.api.admin.dto.CustomRuleDTO)6 GlobalPolicy (org.wso2.carbon.apimgt.api.model.policy.GlobalPolicy)5 APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)3 APIProvider (org.wso2.carbon.apimgt.api.APIProvider)3 APIMgtAdminService (org.wso2.carbon.apimgt.core.api.APIMgtAdminService)3 APIManagementException (org.wso2.carbon.apimgt.core.exception.APIManagementException)3 ErrorDTO (org.wso2.carbon.apimgt.rest.api.common.dto.ErrorDTO)3 ArrayList (java.util.ArrayList)2 Response (javax.ws.rs.core.Response)2 Test (org.junit.Test)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 Test (org.testng.annotations.Test)2 APIMgtAdminServiceImpl (org.wso2.carbon.apimgt.core.impl.APIMgtAdminServiceImpl)2 PoliciesApiServiceImpl (org.wso2.carbon.apimgt.rest.api.admin.impl.PoliciesApiServiceImpl)2 CustomRuleDTO (org.wso2.carbon.apimgt.rest.api.admin.v1.dto.CustomRuleDTO)2 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 PolicyNotFoundException (org.wso2.carbon.apimgt.api.PolicyNotFoundException)1 APIPolicy (org.wso2.carbon.apimgt.api.model.policy.APIPolicy)1