use of org.wso2.carbon.apimgt.throttle.policy.deployer.dto.Condition in project carbon-apimgt by wso2.
the class SubscriptionValidationDataUtil method fromApiPolicyToApiPolicyListDTO.
public static ApiPolicyListDTO fromApiPolicyToApiPolicyListDTO(List<APIPolicy> model) {
ApiPolicyListDTO apiPolicyListDTO = new ApiPolicyListDTO();
if (model != null) {
for (APIPolicy apiPolicyModel : model) {
ApiPolicyDTO policyDTO = new ApiPolicyDTO();
policyDTO.setName(apiPolicyModel.getName());
policyDTO.setQuotaType(apiPolicyModel.getQuotaType());
policyDTO.setTenantId(apiPolicyModel.getTenantId());
policyDTO.setTenantDomain(apiPolicyModel.getTenantDomain());
policyDTO.setApplicableLevel(apiPolicyModel.getApplicableLevel());
policyDTO.setDefaultLimit(getThrottleLimitDTO(apiPolicyModel));
apiPolicyListDTO.getList().add(policyDTO);
List<APIPolicyConditionGroup> retrievedGroups = apiPolicyModel.getConditionGroups();
List<ApiPolicyConditionGroupDTO> condGroups = new ArrayList<ApiPolicyConditionGroupDTO>();
for (APIPolicyConditionGroup retGroup : retrievedGroups) {
ApiPolicyConditionGroupDTO group = new ApiPolicyConditionGroupDTO();
group.setConditionGroupId(retGroup.getConditionGroupId());
group.setQuotaType(retGroup.getQuotaType());
group.setDefaultLimit(getThrottleLimitDTO(retGroup));
group.setPolicyId(retGroup.getPolicyId());
List<org.wso2.carbon.apimgt.internal.service.dto.ConditionDTO> condition = new ArrayList<org.wso2.carbon.apimgt.internal.service.dto.ConditionDTO>();
List<ConditionDTO> retrievedConditions = retGroup.getConditionDTOS();
for (ConditionDTO retrievedCondition : retrievedConditions) {
org.wso2.carbon.apimgt.internal.service.dto.ConditionDTO conditionDTO = new org.wso2.carbon.apimgt.internal.service.dto.ConditionDTO();
conditionDTO.setConditionType(retrievedCondition.getConditionType());
conditionDTO.setIsInverted(retrievedCondition.isInverted());
conditionDTO.setName(retrievedCondition.getConditionName());
conditionDTO.setValue(retrievedCondition.getConditionValue());
condition.add(conditionDTO);
}
group.setCondition(condition);
condGroups.add(group);
}
policyDTO.setConditionGroups(condGroups);
}
apiPolicyListDTO.setCount(model.size());
} else {
apiPolicyListDTO.setCount(0);
}
return apiPolicyListDTO;
}
use of org.wso2.carbon.apimgt.throttle.policy.deployer.dto.Condition in project carbon-apimgt by wso2.
the class WSDLSOAPOperationExtractorImplTestCase method testGetSwaggerModelForSimpleType.
@Test
public void testGetSwaggerModelForSimpleType() throws Exception {
APIMWSDLReader wsdlReader = new APIMWSDLReader(Thread.currentThread().getContextClassLoader().getResource("wsdls/sample-service.wsdl").toExternalForm());
byte[] wsdlContent = wsdlReader.getWSDL();
WSDL11SOAPOperationExtractor processor = SOAPOperationBindingUtils.getWSDL11SOAPOperationExtractor(wsdlContent, wsdlReader);
Map<String, ModelImpl> parameterModelMap = processor.getWsdlInfo().getParameterModelMap();
Assert.assertNotNull(parameterModelMap);
// get simple type
Assert.assertNotNull(parameterModelMap.get("Condition"));
Assert.assertEquals("string", parameterModelMap.get("Condition").getType());
// get simple type inside complex type
Assert.assertNotNull(parameterModelMap.get("ItemSearchRequest").getProperties().get("Availability"));
Assert.assertEquals("string", parameterModelMap.get("ItemSearchRequest").getProperties().get("Availability").getType());
}
use of org.wso2.carbon.apimgt.throttle.policy.deployer.dto.Condition in project carbon-apimgt by wso2.
the class CommonThrottleMappingUtil method fromJWTClaimsConditionToDTO.
/**
* Converts a JWT Claims Condition model object into a DTO
*
* @param condition JWT Claims Condition model object
* @return DTO object that was derived from JWT Claims Condition model object
*/
public static JWTClaimsConditionDTO fromJWTClaimsConditionToDTO(JWTClaimsCondition condition) {
JWTClaimsConditionDTO dto = new JWTClaimsConditionDTO();
dto.setClaimUrl(condition.getClaimUrl());
dto.setAttribute(condition.getAttribute());
return dto;
}
use of org.wso2.carbon.apimgt.throttle.policy.deployer.dto.Condition in project carbon-apimgt by wso2.
the class CommonThrottleMappingUtil method fromConditionalGroupDTOToPipeline.
/**
* Converts a single Conditional Group DTO into a Pipeline object
*
* @param dto Conditional Group DTO
* @return Derived Pipeline object from Conditional Group DTO
* @throws UnsupportedThrottleLimitTypeException
* @throws UnsupportedThrottleConditionTypeException
*/
public static Pipeline fromConditionalGroupDTOToPipeline(ConditionalGroupDTO dto) throws UnsupportedThrottleLimitTypeException, UnsupportedThrottleConditionTypeException {
Pipeline pipeline = new Pipeline();
pipeline.setDescription(dto.getDescription());
pipeline.setEnabled(true);
pipeline.setQuotaPolicy(fromDTOToQuotaPolicy(dto.getLimit()));
List<Condition> conditions = fromDTOListToConditionList(dto.getConditions());
pipeline.setConditions(conditions);
return pipeline;
}
use of org.wso2.carbon.apimgt.throttle.policy.deployer.dto.Condition in project carbon-apimgt by wso2.
the class CommonThrottleMappingUtil method fromDTOToQueryParameterCondition.
/**
* Converts a Query Parameter Condition DTO object into a model object
*
* @param dto Query Parameter Condition DTO object
* @param invertCondition Invert condition relevant to the DTO
* @return Query Parameter Condition model object derived from Query Parameter Condition DTO
*/
public static QueryParameterCondition fromDTOToQueryParameterCondition(QueryParameterConditionDTO dto, boolean invertCondition) {
QueryParameterCondition queryParameterCondition = new QueryParameterCondition();
queryParameterCondition.setConditionEnabled(Boolean.TRUE.toString());
queryParameterCondition.setInvertCondition(invertCondition);
queryParameterCondition.setParameter(dto.getParameterName());
queryParameterCondition.setValue(dto.getParameterValue());
return queryParameterCondition;
}
Aggregations