use of org.wso2.carbon.apimgt.impl.wsdl.exceptions.APIMgtWSDLException in project carbon-apimgt by wso2.
the class WSDLProcessFactory method getWSDLProcessor.
/**
* Returns the appropriate WSDL 1.1 or 2.0 processor based on the content {@code wsdlContent}.
*
* @param wsdlContent Content of the WSDL
* @return WSDL 1.1 or 2.0 processor for the provided content
* @throws APIMgtWSDLException If an error occurs while determining the processor
*/
public WSDLProcessor getWSDLProcessor(byte[] wsdlContent) throws APIMgtWSDLException {
for (String clazz : getWSDLProcessorClasses()) {
WSDLProcessor processor;
try {
processor = (WSDLProcessor) Class.forName(clazz).newInstance();
boolean canProcess = processor.init(wsdlContent);
if (canProcess) {
return processor;
}
} catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
throw new APIMgtWSDLException("Error while instantiating " + clazz, e, ExceptionCodes.INTERNAL_WSDL_EXCEPTION);
}
}
// no processors found if this line reaches
throw new APIMgtWSDLException("No WSDL processor found to process WSDL content", ExceptionCodes.CANNOT_PROCESS_WSDL_CONTENT);
}
use of org.wso2.carbon.apimgt.impl.wsdl.exceptions.APIMgtWSDLException in project carbon-apimgt by wso2.
the class WSDLProcessFactory method getWSDLProcessorForPath.
/**
* Returns the appropriate WSDL 1.1 or 2.0 processor based on the file path {@code wsdlPath}.
*
* @param wsdlPath File path containing WSDL files and dependant files
* @return WSDL 1.1 or 2.0 processor for the provided content
* @throws APIMgtWSDLException If an error occurs while determining the processor
*/
public WSDLProcessor getWSDLProcessorForPath(String wsdlPath) throws APIMgtWSDLException {
for (String clazz : getWSDLProcessorClasses()) {
WSDLProcessor processor;
try {
processor = (WSDLProcessor) Class.forName(clazz).newInstance();
boolean canProcess = processor.initPath(wsdlPath);
if (canProcess) {
return processor;
}
} catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
throw new APIMgtWSDLException("Error while instantiating " + clazz, e, ExceptionCodes.INTERNAL_WSDL_EXCEPTION);
}
}
// no processors found if this line reaches
throw new APIMgtWSDLException("No WSDL processor found to process WSDL content", ExceptionCodes.CANNOT_PROCESS_WSDL_CONTENT);
}
use of org.wso2.carbon.apimgt.impl.wsdl.exceptions.APIMgtWSDLException in project carbon-apimgt by wso2.
the class WSDL11ProcessorImpl method getWSDLByteArrayOutputStream.
/**
* Retrieves a {@link ByteArrayOutputStream} for provided {@link Definition}.
*
* @param definition WSDL Definition
* @return A {@link ByteArrayOutputStream} for provided {@link Definition}
* @throws APIMgtWSDLException If an error occurs while creating {@link ByteArrayOutputStream}
*/
private ByteArrayOutputStream getWSDLByteArrayOutputStream(Definition definition) throws APIMgtWSDLException {
WSDLWriter writer = getWsdlFactoryInstance().newWSDLWriter();
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
try {
writer.writeWSDL(definition, byteArrayOutputStream);
} catch (WSDLException e) {
throw new APIMgtWSDLException("Error while stringifying WSDL definition", e, ExceptionCodes.INTERNAL_WSDL_EXCEPTION);
}
return byteArrayOutputStream;
}
use of org.wso2.carbon.apimgt.impl.wsdl.exceptions.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();
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.exceptions.APIMgtWSDLException in project carbon-apimgt by wso2.
the class WSDL11ProcessorImpl method getUpdatedWSDLPath.
/**
* Updates the endpoints of all the WSDL files in the path based on the provided API (context) and Label (host).
*
* @param api Provided API object
* @param label Provided label object
* @return Updated WSDL file path
* @throws APIMgtWSDLException Error while updating WSDL files
*/
@Override
public String getUpdatedWSDLPath(API api, Label label) throws APIMgtWSDLException {
if (label != null) {
for (Map.Entry<String, Definition> entry : pathToDefinitionMap.entrySet()) {
Definition definition = entry.getValue();
if (log.isDebugEnabled()) {
log.debug("Updating endpoints of WSDL: " + entry.getKey());
}
updateEndpoints(label.getAccessUrls(), api, definition);
if (log.isDebugEnabled()) {
log.debug("Successfully updated endpoints of WSDL: " + entry.getKey());
}
try (FileOutputStream wsdlFileOutputStream = new FileOutputStream(new File(entry.getKey()))) {
WSDLWriter writer = getWsdlFactoryInstance().newWSDLWriter();
writer.writeWSDL(definition, wsdlFileOutputStream);
} catch (IOException | WSDLException e) {
throw new APIMgtWSDLException("Failed to create WSDL archive for API:" + api.getName() + ":" + api.getVersion() + " for label " + label.getName(), ExceptionCodes.ERROR_WHILE_CREATING_WSDL_ARCHIVE);
}
}
}
return wsdlArchiveExtractedPath;
}
Aggregations