use of org.wso2.carbon.apimgt.core.models.WSDLOperationParam in project carbon-apimgt by wso2.
the class WSDL11ProcessorImpl method getParameters.
/**
* Returns parameters, given http binding operation, verb and content type
*
* @param bindingOperation {@link BindingOperation} object
* @param verb HTTP verb
* @param contentType Content type
* @return parameters, given http binding operation, verb and content type
*/
private List<WSDLOperationParam> getParameters(BindingOperation bindingOperation, String verb, String contentType) {
List<WSDLOperationParam> params = new ArrayList<>();
Operation operation = bindingOperation.getOperation();
// or content type is not provided
if (APIMWSDLUtils.canContainBody(verb) && !APIMWSDLUtils.hasFormDataParams(contentType)) {
WSDLOperationParam param = new WSDLOperationParam();
param.setName("Payload");
param.setParamType(WSDLOperationParam.ParamTypeEnum.BODY);
params.add(param);
if (log.isDebugEnabled()) {
log.debug("Adding default Param for operation:" + operation.getName() + ", contentType: " + contentType);
}
return params;
}
if (operation != null) {
Input input = operation.getInput();
if (input != null) {
Message message = input.getMessage();
if (message != null) {
Map map = message.getParts();
map.forEach((name, partObj) -> {
WSDLOperationParam param = new WSDLOperationParam();
param.setName(name.toString());
if (log.isDebugEnabled()) {
log.debug("Identified param for operation: " + operation.getName() + " param: " + name);
}
if (APIMWSDLUtils.canContainBody(verb)) {
if (log.isDebugEnabled()) {
log.debug("Operation " + operation.getName() + " can contain a body.");
}
// In POST, PUT operations, parameters always in body according to HTTP Binding spec
if (APIMWSDLUtils.hasFormDataParams(contentType)) {
param.setParamType(WSDLOperationParam.ParamTypeEnum.FORM_DATA);
if (log.isDebugEnabled()) {
log.debug("Param " + name + " type was set to formData.");
}
}
// no else block since if content type is not form-data related, there can be only one
// parameter which is payload body. This is handled in the first if block which is
// if (canContainBody(verb) && !hasFormDataParams(contentType)) { .. }
} else {
// In GET operations, parameters always query or path as per HTTP Binding spec
if (isUrlReplacement(bindingOperation)) {
param.setParamType(WSDLOperationParam.ParamTypeEnum.PATH);
if (log.isDebugEnabled()) {
log.debug("Param " + name + " type was set to Path.");
}
} else {
param.setParamType(WSDLOperationParam.ParamTypeEnum.QUERY);
if (log.isDebugEnabled()) {
log.debug("Param " + name + " type was set to Query.");
}
}
}
Part part = (Part) partObj;
param.setDataType(part.getTypeName().getLocalPart());
if (log.isDebugEnabled()) {
log.debug("Param " + name + " data type was set to " + param.getDataType());
}
params.add(param);
});
}
}
}
return params;
}
use of org.wso2.carbon.apimgt.core.models.WSDLOperationParam in project carbon-apimgt by wso2.
the class WSDL11ProcessorImpl method getOperation.
/**
* Retrieves WSDL operation given the binding operation and http verb
*
* @param bindingOperation {@link BindingOperation} object
* @param verb HTTP verb
* @return WSDL operation for the given binding operation and http verb
*/
private WSDLOperation getOperation(BindingOperation bindingOperation, String verb) {
WSDLOperation wsdlOperation = null;
for (Object boExtElement : bindingOperation.getExtensibilityElements()) {
if (boExtElement instanceof HTTPOperation) {
HTTPOperation httpOperation = (HTTPOperation) boExtElement;
if (!StringUtils.isBlank(httpOperation.getLocationURI())) {
wsdlOperation = new WSDLOperation();
wsdlOperation.setVerb(verb);
wsdlOperation.setURI(APIMWSDLUtils.replaceParentheses(httpOperation.getLocationURI()));
if (log.isDebugEnabled()) {
log.debug("Found HTTP Binding operation; name: " + bindingOperation.getName() + " [" + wsdlOperation.getVerb() + " " + wsdlOperation.getURI() + "]");
}
if (APIMWSDLUtils.canContainBody(verb)) {
String boContentType = getContentType(bindingOperation.getBindingInput());
wsdlOperation.setContentType(boContentType != null ? boContentType : TEXT_XML_MEDIA_TYPE);
}
List<WSDLOperationParam> paramList = getParameters(bindingOperation, verb, wsdlOperation.getContentType());
wsdlOperation.setParameters(paramList);
}
}
}
return wsdlOperation;
}
Aggregations