use of org.wso2.carbon.apimgt.impl.wsdl.model.WSDLOperation in project carbon-apimgt by wso2.
the class WSDL11ProcessorImpl method getWsdlInfo.
@Override
public WSDLInfo getWsdlInfo() throws APIMgtWSDLException {
WSDLInfo wsdlInfo = new WSDLInfo();
Map<String, String> endpointsMap = getEndpoints();
Set<WSDLOperation> operations = getHttpBindingOperations();
wsdlInfo.setEndpoints(endpointsMap);
wsdlInfo.setVersion(APIMgtConstants.WSDLConstants.WSDL_VERSION_11);
if (!operations.isEmpty()) {
wsdlInfo.setHasHttpBindingOperations(true);
wsdlInfo.setHttpBindingOperations(operations);
} else {
wsdlInfo.setHasHttpBindingOperations(false);
}
wsdlInfo.setHasSoapBindingOperations(hasSoapBindingOperations());
return wsdlInfo;
}
use of org.wso2.carbon.apimgt.impl.wsdl.model.WSDLOperation in project carbon-apimgt by wso2.
the class WSDL11ProcessorImpl method getHttpBindingOperations.
/**
* Retrieves all the operations defined in WSDL(s).
*
* @return a set of {@link WSDLOperation} defined in WSDL(s)
*/
private Set<WSDLOperation> getHttpBindingOperations() {
if (wsdlDefinition != null) {
return getHttpBindingOperations(wsdlDefinition);
} else {
Set<WSDLOperation> allOperations = new HashSet<>();
for (Definition definition : pathToDefinitionMap.values()) {
Set<WSDLOperation> operations = getHttpBindingOperations(definition);
allOperations.addAll(operations);
}
return allOperations;
}
}
use of org.wso2.carbon.apimgt.impl.wsdl.model.WSDLOperation 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;
}
use of org.wso2.carbon.apimgt.impl.wsdl.model.WSDLOperation in project carbon-apimgt by wso2.
the class APIMWSDLUtils method getUriTemplatesForWSDLOperations.
/**
* Generates URI templates to be assigned to an API from a set of operations extracted from WSDL.
*
* @param operations a Set of {@link WSDLOperation} objects
* @return Map of URI Templates
*/
public static Map<String, UriTemplate> getUriTemplatesForWSDLOperations(Set<WSDLOperation> operations, boolean isHttpBinding) {
Map<String, UriTemplate> uriTemplateMap = new HashMap<>();
// add default "POST /" operation if no http binding methods required or operations are not provided
if (!isHttpBinding || operations == null || operations.isEmpty()) {
if (log.isDebugEnabled()) {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("Adding the POST / operation. ");
stringBuilder.append("isHttpBinding: ").append(isHttpBinding).append(". ");
stringBuilder.append("operations are null?: ").append(operations == null).append(". ");
if (operations != null) {
stringBuilder.append("operations are empty?: ").append(operations.isEmpty()).append(". ");
}
log.debug(stringBuilder.toString());
}
UriTemplate.UriTemplateBuilder builderForPOSTRootCtx = new UriTemplate.UriTemplateBuilder();
builderForPOSTRootCtx.uriTemplate("/");
builderForPOSTRootCtx.httpVerb("POST");
builderForPOSTRootCtx.policy(APIUtils.getDefaultAPIPolicy());
builderForPOSTRootCtx.templateId(APIUtils.generateOperationIdFromPath("/", "POST"));
uriTemplateMap.put(builderForPOSTRootCtx.getTemplateId(), builderForPOSTRootCtx.build());
return uriTemplateMap;
}
// add URI templates for operations
for (WSDLOperation operation : operations) {
if (log.isDebugEnabled()) {
log.debug("Adding URI template for WSDL operation: " + operation.getVerb() + ", " + operation.getURI());
}
UriTemplate.UriTemplateBuilder builder = new UriTemplate.UriTemplateBuilder();
builder.uriTemplate(operation.getURI().startsWith("/") ? operation.getURI() : "/" + operation.getURI());
builder.httpVerb(operation.getVerb());
builder.policy(APIUtils.getDefaultAPIPolicy());
builder.templateId(APIUtils.generateOperationIdFromPath(builder.getUriTemplate(), operation.getVerb()));
builder.contentType(operation.getContentType());
List<URITemplateParam> uriTemplateParams = getUriTemplatesParamsForWSDLOperationParams(operation.getParameters());
builder.parameters(uriTemplateParams);
uriTemplateMap.put(builder.getTemplateId(), builder.build());
}
return uriTemplateMap;
}
use of org.wso2.carbon.apimgt.impl.wsdl.model.WSDLOperation in project carbon-apimgt by wso2.
the class WSDL11SOAPOperationExtractor method getSOAPBindingOperations.
/**
* Retrieves all the operations defined in the provided Binding.
*
* @param binding WSDL binding
* @return a set of {@link WSDLOperation} defined in the provided Binding
*/
private Set<WSDLSOAPOperation> getSOAPBindingOperations(Binding binding) throws APIMgtWSDLException {
Set<WSDLSOAPOperation> allBindingOperations = new HashSet<>();
if (binding.getExtensibilityElements() != null && binding.getExtensibilityElements().size() > 0) {
List extensibilityElements = binding.getExtensibilityElements();
for (Object extensibilityElement : extensibilityElements) {
if (extensibilityElement instanceof SOAPBinding || extensibilityElement instanceof SOAP12Binding) {
for (Object opObj : binding.getBindingOperations()) {
BindingOperation bindingOperation = (BindingOperation) opObj;
WSDLSOAPOperation wsdlSoapOperation = getSOAPOperation(bindingOperation);
if (wsdlSoapOperation != null) {
allBindingOperations.add(wsdlSoapOperation);
} else {
log.warn("Unable to get soap operation details from binding operation: " + bindingOperation.getName());
}
}
}
}
} else {
throw new APIMgtWSDLException("Cannot further process to get soap binding operations");
}
return allBindingOperations;
}
Aggregations