use of org.wso2.carbon.apimgt.api.UnsupportedThrottleLimitTypeException in project carbon-apimgt by wso2.
the class AdvancedThrottlePolicyMappingUtil method fromAdvancedPolicyToDTO.
/**
* 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 AdvancedThrottlePolicyDTO fromAdvancedPolicyToDTO(APIPolicy apiPolicy) throws UnsupportedThrottleLimitTypeException, UnsupportedThrottleConditionTypeException {
AdvancedThrottlePolicyDTO policyDTO = new AdvancedThrottlePolicyDTO();
policyDTO = CommonThrottleMappingUtil.updateFieldsFromToPolicyToDTO(apiPolicy, policyDTO);
List<ConditionalGroupDTO> groupDTOs = CommonThrottleMappingUtil.fromPipelineListToConditionalGroupDTOList(apiPolicy.getPipelines());
policyDTO.setConditionalGroups(groupDTOs);
policyDTO.setType(ADVANCED_THROTTLING_POLICY_TYPE);
if (apiPolicy.getDefaultQuotaPolicy() != null) {
policyDTO.setDefaultLimit(CommonThrottleMappingUtil.fromQuotaPolicyToDTO(apiPolicy.getDefaultQuotaPolicy()));
}
return policyDTO;
}
use of org.wso2.carbon.apimgt.api.UnsupportedThrottleLimitTypeException in project carbon-apimgt by wso2.
the class GlobalThrottlePolicyMappingUtil method fromGlobalThrottlePolicyDTOToModel.
/**
* Converts a single Global policy DTO object into model object
*
* @param dto Global policy DTO object
* @return Model object derived from DTO
* @throws UnsupportedThrottleLimitTypeException
*/
public static GlobalPolicy fromGlobalThrottlePolicyDTOToModel(CustomRuleDTO dto) throws UnsupportedThrottleLimitTypeException {
// update mandatory fields such as tenantDomain etc.
dto = CommonThrottleMappingUtil.updateDefaultMandatoryFieldsOfThrottleDTO(dto);
GlobalPolicy globalPolicy = new GlobalPolicy(dto.getPolicyName());
globalPolicy = CommonThrottleMappingUtil.updateFieldsFromDTOToPolicy(dto, globalPolicy);
globalPolicy.setKeyTemplate(dto.getKeyTemplate());
globalPolicy.setSiddhiQuery(dto.getSiddhiQuery());
return globalPolicy;
}
use of org.wso2.carbon.apimgt.api.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.api.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;
}
use of org.wso2.carbon.apimgt.api.UnsupportedThrottleLimitTypeException in project carbon-apimgt by wso2.
the class CommonThrottleMappingUtil method fromPipelineToConditionalGroupDTO.
/**
* Converts a single Pipeline object into a Conditional Group DTO object
*
* @param pipeline Pipeline object
* @return Derived DTO object from Pipeline object
* @throws UnsupportedThrottleLimitTypeException
* @throws UnsupportedThrottleConditionTypeException
*/
public static ConditionalGroupDTO fromPipelineToConditionalGroupDTO(Pipeline pipeline) throws UnsupportedThrottleLimitTypeException, UnsupportedThrottleConditionTypeException {
ConditionalGroupDTO groupDTO = new ConditionalGroupDTO();
groupDTO.setDescription(pipeline.getDescription());
groupDTO.setLimit(fromQuotaPolicyToDTO(pipeline.getQuotaPolicy()));
List<ThrottleConditionDTO> conditionDTOList = fromConditionListToDTOList(pipeline.getConditions());
groupDTO.setConditions(conditionDTOList);
return groupDTO;
}
Aggregations