use of org.wso2.carbon.apimgt.api.UnsupportedThrottleConditionTypeException in project carbon-apimgt by wso2.
the class CommonThrottleMappingUtil method fromDTOToIPCondition.
/**
* Converts a IP Condition DTO object into a model object
*
* @param dto IP Condition DTO object
* @return IP Condition model object derived from DTO
*/
public static IPCondition fromDTOToIPCondition(ThrottleConditionDTO dto) throws UnsupportedThrottleConditionTypeException {
String ipConditionType = mapIPConditionTypeFromDTOToModel(dto.getIpCondition().getIpConditionType());
IPCondition ipCondition = new IPCondition(ipConditionType);
ipCondition = updateFieldsFromDTOToCondition(dto, ipCondition);
ipCondition.setSpecificIP(dto.getIpCondition().getSpecificIP());
ipCondition.setStartingIP(dto.getIpCondition().getStartingIP());
ipCondition.setEndingIP(dto.getIpCondition().getEndingIP());
return ipCondition;
}
use of org.wso2.carbon.apimgt.api.UnsupportedThrottleConditionTypeException in project carbon-apimgt by wso2.
the class AdvancedThrottlePolicyMappingUtil method fromAPIPolicyArrayToListDTO.
/**
* Converts an array of Advanced Policy objects into a List DTO
*
* @param policies Array of Advanced Policies
* @return A List DTO of converted Advanced Policies
* @throws UnsupportedThrottleLimitTypeException - If error occurs
* @throws UnsupportedThrottleConditionTypeException - If error occurs
*/
public static AdvancedThrottlePolicyListDTO fromAPIPolicyArrayToListDTO(List<APIPolicy> policies) throws UnsupportedThrottleLimitTypeException, UnsupportedThrottleConditionTypeException {
AdvancedThrottlePolicyListDTO listDTO = new AdvancedThrottlePolicyListDTO();
List<AdvancedThrottlePolicyDTO> advancedPolicyDTOs = new ArrayList<>();
if (policies != null) {
for (APIPolicy policy : policies) {
advancedPolicyDTOs.add(fromAdvancedPolicyToDTO(policy));
}
}
listDTO.setList(advancedPolicyDTOs);
listDTO.setCount(advancedPolicyDTOs.size());
return listDTO;
}
use of org.wso2.carbon.apimgt.api.UnsupportedThrottleConditionTypeException 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 - If error occurs
* @throws UnsupportedThrottleConditionTypeException - If error occurs
*/
public static AdvancedThrottlePolicyDTO fromAdvancedPolicyToInfoDTO(APIPolicy apiPolicy) throws UnsupportedThrottleLimitTypeException, UnsupportedThrottleConditionTypeException {
AdvancedThrottlePolicyDTO policyDTO = new AdvancedThrottlePolicyDTO();
policyDTO = CommonThrottleMappingUtil.updateFieldsFromToPolicyToDTO(apiPolicy, policyDTO);
if (apiPolicy.getDefaultQuotaPolicy() != null) {
policyDTO.setDefaultLimit(CommonThrottleMappingUtil.fromQuotaPolicyToDTO(apiPolicy.getDefaultQuotaPolicy()));
}
return policyDTO;
}
use of org.wso2.carbon.apimgt.api.UnsupportedThrottleConditionTypeException in project carbon-apimgt by wso2.
the class ApplicationThrottlePolicyMappingUtil method fromApplicationThrottlePolicyToDTO.
/**
* Converts a single Application Policy model into REST API DTO
*
* @param appPolicy An Application Policy model object
* @return Converted Application policy REST API DTO object
* @throws UnsupportedThrottleLimitTypeException - If error occurs
*/
public static ApplicationThrottlePolicyDTO fromApplicationThrottlePolicyToDTO(Policy appPolicy) throws UnsupportedThrottleLimitTypeException, UnsupportedThrottleConditionTypeException {
ApplicationThrottlePolicyDTO policyDTO = new ApplicationThrottlePolicyDTO();
policyDTO = CommonThrottleMappingUtil.updateFieldsFromToPolicyToDTO(appPolicy, policyDTO);
if (appPolicy.getDefaultQuotaPolicy() != null) {
policyDTO.setDefaultLimit(CommonThrottleMappingUtil.fromQuotaPolicyToDTO(appPolicy.getDefaultQuotaPolicy()));
}
return policyDTO;
}
use of org.wso2.carbon.apimgt.api.UnsupportedThrottleConditionTypeException in project carbon-apimgt by wso2.
the class ApplicationThrottlePolicyMappingUtil method fromApplicationPolicyArrayToListDTO.
/**
* Converts an array of Application Policy objects into a List DTO
*
* @param appPolicies Array of Application Policies
* @return A List DTO of converted Application Policies
* @throws UnsupportedThrottleLimitTypeException - If error occurs
*/
public static ApplicationThrottlePolicyListDTO fromApplicationPolicyArrayToListDTO(List<ApplicationPolicy> appPolicies) throws UnsupportedThrottleLimitTypeException, UnsupportedThrottleConditionTypeException {
ApplicationThrottlePolicyListDTO listDTO = new ApplicationThrottlePolicyListDTO();
List<ApplicationThrottlePolicyDTO> appPolicyDTOList = new ArrayList<>();
if (appPolicies != null) {
for (Policy policy : appPolicies) {
ApplicationThrottlePolicyDTO dto = fromApplicationThrottlePolicyToDTO(policy);
appPolicyDTOList.add(dto);
}
}
listDTO.setCount(appPolicyDTOList.size());
listDTO.setList(appPolicyDTOList);
return listDTO;
}
Aggregations