use of org.wso2.carbon.apimgt.core.exception.APIMgtWSDLException in project carbon-apimgt by wso2.
the class WSDL11ProcessorImpl method getSingleWSDL.
/**
* Retrieves an InputStream representing the WSDL (single WSDL scenario) attached to the processor
*
* @return Retrieves an InputStream representing the WSDL
* @throws APIMgtWSDLException when error occurred while getting the InputStream
*/
private ByteArrayInputStream getSingleWSDL() throws APIMgtWSDLException {
WSDLWriter writer = getWsdlFactoryInstance().newWSDLWriter();
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
try {
writer.writeWSDL(wsdlDefinition, byteArrayOutputStream);
} catch (WSDLException e) {
throw new APIMgtWSDLException("Error while converting WSDL definition object to text format", e, ExceptionCodes.INTERNAL_WSDL_EXCEPTION);
}
byte[] bytes = byteArrayOutputStream.toByteArray();
return new ByteArrayInputStream(bytes);
}
use of org.wso2.carbon.apimgt.core.exception.APIMgtWSDLException 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();
wsdlInfo.setEndpoints(endpointsMap);
wsdlInfo.setVersion(APIConstants.WSDL_VERSION_11);
return wsdlInfo;
}
use of org.wso2.carbon.apimgt.core.exception.APIMgtWSDLException in project carbon-apimgt by wso2.
the class WSDL11ProcessorImpl method init.
@Override
public boolean init(URL url) throws APIMgtWSDLException {
setMode(Mode.SINGLE);
WSDLReader wsdlReader = getWsdlFactoryInstance().newWSDLReader();
// switch off the verbose mode
wsdlReader.setFeature(JAVAX_WSDL_VERBOSE_MODE, false);
wsdlReader.setFeature(JAVAX_WSDL_IMPORT_DOCUMENTS, false);
try {
wsdlDefinition = wsdlReader.readWSDL(url.toString(), getSecuredParsedDocumentFromURL(url));
if (log.isDebugEnabled()) {
log.debug("Successfully initialized an instance of " + this.getClass().getSimpleName() + " with a single WSDL.");
}
} catch (WSDLException | APIManagementException e) {
// This implementation class cannot process the WSDL.
log.debug("Cannot process the WSDL by " + this.getClass().getName(), e);
setError(new ErrorItem(ExceptionCodes.CANNOT_PROCESS_WSDL_CONTENT.getErrorMessage(), e.getMessage(), ExceptionCodes.CANNOT_PROCESS_WSDL_CONTENT.getErrorCode(), ExceptionCodes.CANNOT_PROCESS_WSDL_CONTENT.getHttpStatusCode()));
}
return !hasError;
}
use of org.wso2.carbon.apimgt.core.exception.APIMgtWSDLException in project carbon-apimgt by wso2.
the class WSDL20ProcessorImpl method getSingleWSDL.
/**
* Retrieves an InputStream representing the WSDL (single WSDL scenario) attached to the processor
*
* @return Retrieves an InputStream representing the WSDL
* @throws APIMgtWSDLException when error occurred while getting the InputStream
*/
private ByteArrayInputStream getSingleWSDL() throws APIMgtWSDLException {
WSDLWriter writer;
try {
writer = getWsdlFactoryInstance().newWSDLWriter();
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
writer.writeWSDL(wsdlDescription.toElement(), byteArrayOutputStream);
byte[] bytes = byteArrayOutputStream.toByteArray();
return new ByteArrayInputStream(bytes);
} catch (WSDLException e) {
throw new APIMgtWSDLException("Error while stringifying WSDL definition", e, ExceptionCodes.INTERNAL_WSDL_EXCEPTION);
}
}
use of org.wso2.carbon.apimgt.core.exception.APIMgtWSDLException in project carbon-apimgt by wso2.
the class WSDL20ProcessorImpl method getWsdlInfo.
@Override
public WSDLInfo getWsdlInfo() throws APIMgtWSDLException {
Map<String, String> endpointsMap = getEndpoints();
WSDLInfo wsdlInfo = new WSDLInfo();
wsdlInfo.setEndpoints(endpointsMap);
wsdlInfo.setVersion(WSDL_VERSION_20);
return wsdlInfo;
}
Aggregations