use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.AdvancedThrottlePolicyInfoDTO in project carbon-apimgt by wso2.
the class AdvancedThrottlePolicyMappingUtil method fromAdvancedPolicyToInfoDTO.
/**
* Converts a single Advanced Policy model into REST API DTO
*
* @param apiPolicy Advanced Policy model object
* @return Converted Advanced policy REST API DTO object
* @throws UnsupportedThrottleLimitTypeException
* @throws UnsupportedThrottleConditionTypeException
*/
public static AdvancedThrottlePolicyInfoDTO fromAdvancedPolicyToInfoDTO(APIPolicy apiPolicy) throws UnsupportedThrottleLimitTypeException, UnsupportedThrottleConditionTypeException {
AdvancedThrottlePolicyInfoDTO policyDTO = new AdvancedThrottlePolicyInfoDTO();
policyDTO = CommonThrottleMappingUtil.updateFieldsFromToPolicyToDTO(apiPolicy, policyDTO);
if (apiPolicy.getDefaultQuotaPolicy() != null) {
policyDTO.setDefaultLimit(CommonThrottleMappingUtil.fromQuotaPolicyToDTO(apiPolicy.getDefaultQuotaPolicy()));
}
policyDTO.setType(ADVACNCED_THROTTLING_POLICY_INFO_TYPE);
return policyDTO;
}
use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.AdvancedThrottlePolicyInfoDTO in project carbon-apimgt by wso2.
the class AdvancedThrottlePolicyMappingUtil method fromAPIPolicyArrayToListDTO.
/**
* Converts an array of Advanced Policy objects into a List DTO
*
* @param apiPolicies Array of Advanced Policies
* @return A List DTO of converted Advanced Policies
* @throws UnsupportedThrottleLimitTypeException
* @throws UnsupportedThrottleConditionTypeException
*/
public static AdvancedThrottlePolicyListDTO fromAPIPolicyArrayToListDTO(APIPolicy[] apiPolicies) throws UnsupportedThrottleLimitTypeException, UnsupportedThrottleConditionTypeException {
AdvancedThrottlePolicyListDTO listDTO = new AdvancedThrottlePolicyListDTO();
List<AdvancedThrottlePolicyInfoDTO> advancedPolicyDTOs = new ArrayList<>();
if (apiPolicies != null) {
for (APIPolicy apiPolicy : apiPolicies) {
advancedPolicyDTOs.add(fromAdvancedPolicyToInfoDTO(apiPolicy));
}
}
listDTO.setList(advancedPolicyDTOs);
listDTO.setCount(advancedPolicyDTOs.size());
return listDTO;
}
Aggregations