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 policy 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 fromAdvancedPolicyToDTO(APIPolicy policy) throws UnsupportedThrottleLimitTypeException, UnsupportedThrottleConditionTypeException {
AdvancedThrottlePolicyDTO policyDTO = new AdvancedThrottlePolicyDTO();
policyDTO = CommonThrottleMappingUtil.updateFieldsFromToPolicyToDTO(policy, policyDTO);
List<ConditionalGroupDTO> groupDTOs = CommonThrottleMappingUtil.fromPipelineListToConditionalGroupDTOList(policy.getPipelines());
policyDTO.setConditionalGroups(groupDTOs);
if (policy.getDefaultQuotaPolicy() != null) {
policyDTO.setDefaultLimit(CommonThrottleMappingUtil.fromQuotaPolicyToDTO(policy.getDefaultQuotaPolicy()));
}
return policyDTO;
}
use of org.wso2.carbon.apimgt.api.UnsupportedThrottleLimitTypeException in project carbon-apimgt by wso2.
the class AdvancedThrottlePolicyMappingUtil method fromAdvancedPolicyDTOToPolicy.
/**
* Converts a single Advanced Policy DTO into a model object
*
* @param dto Advanced policy DTO object
* @return Converted Advanced policy model object
* @throws UnsupportedThrottleLimitTypeException - If error occurs
* @throws UnsupportedThrottleConditionTypeException - If error occurs
*/
public static APIPolicy fromAdvancedPolicyDTOToPolicy(AdvancedThrottlePolicyDTO dto) throws UnsupportedThrottleLimitTypeException, UnsupportedThrottleConditionTypeException {
APIPolicy apiPolicy = new APIPolicy(dto.getId(), dto.getPolicyName());
apiPolicy = CommonThrottleMappingUtil.updateFieldsFromDTOToPolicy(dto, apiPolicy);
List<Pipeline> pipelines = CommonThrottleMappingUtil.fromConditionalGroupDTOListToPipelineList(dto.getConditionalGroups());
apiPolicy.setPipelines(pipelines);
if (dto.getDefaultLimit() != null) {
apiPolicy.setDefaultQuotaPolicy(CommonThrottleMappingUtil.fromDTOToQuotaPolicy(dto.getDefaultLimit()));
}
return apiPolicy;
}
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 - If error occurs
*/
public static ApplicationPolicy fromApplicationThrottlePolicyDTOToModel(ApplicationThrottlePolicyDTO dto) throws UnsupportedThrottleLimitTypeException {
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 BlockingConditionMappingUtil method fromBlockConditionListToListDTO.
/**
* Converts a List of Block Condition in to REST API LIST DTO Object.
*
* @param blockConditionList A List of Block Conditions
* @return REST API List DTO object derived from Block Condition list
* @throws UnsupportedThrottleLimitTypeException - If error occurs
*/
public static BlockingConditionListDTO fromBlockConditionListToListDTO(List<BlockConditions> blockConditionList) throws UnsupportedThrottleLimitTypeException {
BlockingConditionListDTO listDTO = new BlockingConditionListDTO();
List<BlockingConditionDTO> blockingConditionDTOList = new ArrayList<>();
if (blockConditionList != null) {
for (BlockConditions blockCondition : blockConditionList) {
BlockingConditionDTO dto = fromBlockingConditionToDTO(blockCondition);
blockingConditionDTOList.add(dto);
}
}
listDTO.setCount(blockingConditionDTOList.size());
listDTO.setList(blockingConditionDTOList);
return listDTO;
}
use of org.wso2.carbon.apimgt.api.UnsupportedThrottleLimitTypeException in project carbon-apimgt by wso2.
the class BlockingConditionMappingUtil method fromBlockingConditionDTOToBlockCondition.
/**
* Convert BlockingConditionDTO to BlockCondition.
*
* @param blockingConditionDTO blockindConditionDTO to be converted
* @return BlockCondition Object
* @throws UnsupportedThrottleLimitTypeException - If error occurs
*/
public static BlockConditions fromBlockingConditionDTOToBlockCondition(BlockingConditionDTO blockingConditionDTO) throws UnsupportedThrottleLimitTypeException {
BlockConditions blockConditions = new BlockConditions();
blockConditions.setUuid(blockingConditionDTO.getConditionId());
blockConditions.setConditionType(blockingConditionDTO.getConditionType());
blockConditions.setConditionValue(blockingConditionDTO.getConditionValue());
blockConditions.setEnabled(blockingConditionDTO.getStatus());
if (APIMgtConstants.ThrottlePolicyConstants.BLOCKING_CONDITION_IP_RANGE.equals(blockConditions.getConditionType())) {
blockConditions.setStartingIP(blockingConditionDTO.getIpCondition().getStartingIP());
blockConditions.setEndingIP(blockingConditionDTO.getIpCondition().getEndingIP());
}
return blockConditions;
}
Aggregations