use of org.wso2.carbon.apimgt.rest.api.admin.exceptions.UnsupportedThrottleLimitTypeException 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;
}
use of org.wso2.carbon.apimgt.rest.api.admin.exceptions.UnsupportedThrottleLimitTypeException in project carbon-apimgt by wso2.
the class ApplicationThrottlePolicyMappingUtil method fromApplicationThrottlePolicyDTOToModel.
/**
* Converts a single Application Policy DTO into a model object
*
* @param dto Application Policy DTO Object
* @return Converted Application Policy Model object
* @throws UnsupportedThrottleLimitTypeException
*/
public static ApplicationPolicy fromApplicationThrottlePolicyDTOToModel(ApplicationThrottlePolicyDTO dto) throws UnsupportedThrottleLimitTypeException {
// update mandatory fields such as tenantDomain etc.
dto = CommonThrottleMappingUtil.updateDefaultMandatoryFieldsOfThrottleDTO(dto);
ApplicationPolicy appPolicy = new ApplicationPolicy(dto.getPolicyName());
appPolicy = CommonThrottleMappingUtil.updateFieldsFromDTOToPolicy(dto, appPolicy);
if (dto.getDefaultLimit() != null) {
appPolicy.setDefaultQuotaPolicy(CommonThrottleMappingUtil.fromDTOToQuotaPolicy(dto.getDefaultLimit()));
}
return appPolicy;
}
Aggregations