use of org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.APIOperationPoliciesDTO in project carbon-apimgt by wso2.
the class OperationPolicyMappingUtil method fromOperationPolicyListToDTO.
public static APIOperationPoliciesDTO fromOperationPolicyListToDTO(List<OperationPolicy> operationPolicyList) {
APIOperationPoliciesDTO dto = new APIOperationPoliciesDTO();
List<OperationPolicyDTO> request = new ArrayList<>();
List<OperationPolicyDTO> response = new ArrayList<>();
List<OperationPolicyDTO> fault = new ArrayList<>();
for (OperationPolicy op : operationPolicyList) {
OperationPolicyDTO policyDTO = fromOperationPolicyToDTO(op);
if (APIConstants.OPERATION_SEQUENCE_TYPE_REQUEST.equals(op.getDirection())) {
request.add(policyDTO);
} else if (APIConstants.OPERATION_SEQUENCE_TYPE_RESPONSE.equals(op.getDirection())) {
response.add(policyDTO);
} else if (APIConstants.OPERATION_SEQUENCE_TYPE_FAULT.equals(op.getDirection())) {
fault.add(policyDTO);
}
}
dto.setRequest(request);
dto.setResponse(response);
dto.setFault(fault);
return dto;
}
use of org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.APIOperationPoliciesDTO in project carbon-apimgt by wso2.
the class OperationPolicyMappingUtil method fromDTOToAPIOperationPoliciesList.
public static List<OperationPolicy> fromDTOToAPIOperationPoliciesList(APIOperationPoliciesDTO apiOperationPoliciesDTO) {
List<OperationPolicy> operationPoliciesList = new ArrayList<>();
if (apiOperationPoliciesDTO != null) {
List<OperationPolicyDTO> request = apiOperationPoliciesDTO.getRequest();
List<OperationPolicyDTO> response = apiOperationPoliciesDTO.getResponse();
List<OperationPolicyDTO> fault = apiOperationPoliciesDTO.getFault();
int requestCount = 1;
int responseCount = 1;
int faultCount = 1;
for (OperationPolicyDTO op : request) {
OperationPolicy operationPolicy = fromDTOToOperationPolicy(op);
operationPolicy.setDirection(APIConstants.OPERATION_SEQUENCE_TYPE_REQUEST);
operationPolicy.setOrder(requestCount);
operationPoliciesList.add(operationPolicy);
requestCount += 1;
}
for (OperationPolicyDTO op : response) {
OperationPolicy operationPolicy = fromDTOToOperationPolicy(op);
operationPolicy.setDirection(APIConstants.OPERATION_SEQUENCE_TYPE_RESPONSE);
operationPolicy.setOrder(responseCount);
operationPoliciesList.add(operationPolicy);
responseCount += 1;
}
for (OperationPolicyDTO op : fault) {
OperationPolicy operationPolicy = fromDTOToOperationPolicy(op);
operationPolicy.setDirection(APIConstants.OPERATION_SEQUENCE_TYPE_FAULT);
operationPolicy.setOrder(faultCount);
operationPoliciesList.add(operationPolicy);
faultCount += 1;
}
}
return operationPoliciesList;
}
Aggregations