Search in sources :

Example 46 with APIMgtWSDLException

use of org.wso2.carbon.apimgt.impl.wsdl.exceptions.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);
}
Also used : APIMgtWSDLException(org.wso2.carbon.apimgt.impl.wsdl.exceptions.APIMgtWSDLException) APIMgtWSDLException(org.wso2.carbon.apimgt.impl.wsdl.exceptions.APIMgtWSDLException) WSDLException(javax.wsdl.WSDLException) ByteArrayInputStream(java.io.ByteArrayInputStream) WSDLWriter(javax.wsdl.xml.WSDLWriter) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Example 47 with APIMgtWSDLException

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();
    wsdlInfo.setEndpoints(endpointsMap);
    wsdlInfo.setVersion(APIConstants.WSDL_VERSION_11);
    return wsdlInfo;
}
Also used : WSDLInfo(org.wso2.carbon.apimgt.impl.wsdl.model.WSDLInfo)

Example 48 with APIMgtWSDLException

use of org.wso2.carbon.apimgt.impl.wsdl.exceptions.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;
}
Also used : APIManagementException(org.wso2.carbon.apimgt.api.APIManagementException) APIMgtWSDLException(org.wso2.carbon.apimgt.impl.wsdl.exceptions.APIMgtWSDLException) WSDLException(javax.wsdl.WSDLException) ErrorItem(org.wso2.carbon.apimgt.api.ErrorItem) WSDLReader(javax.wsdl.xml.WSDLReader) APIMWSDLReader(org.wso2.carbon.apimgt.impl.utils.APIMWSDLReader)

Example 49 with APIMgtWSDLException

use of org.wso2.carbon.apimgt.impl.wsdl.exceptions.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);
    }
}
Also used : APIMgtWSDLException(org.wso2.carbon.apimgt.impl.wsdl.exceptions.APIMgtWSDLException) ByteArrayInputStream(java.io.ByteArrayInputStream) APIMgtWSDLException(org.wso2.carbon.apimgt.impl.wsdl.exceptions.APIMgtWSDLException) WSDLException(org.apache.woden.WSDLException) WSDLWriter(org.apache.woden.WSDLWriter) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Example 50 with APIMgtWSDLException

use of org.wso2.carbon.apimgt.impl.wsdl.exceptions.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;
}
Also used : WSDLInfo(org.wso2.carbon.apimgt.impl.wsdl.model.WSDLInfo)

Aggregations

APIMgtWSDLException (org.wso2.carbon.apimgt.core.exception.APIMgtWSDLException)24 APIMgtWSDLException (org.wso2.carbon.apimgt.impl.wsdl.exceptions.APIMgtWSDLException)22 IOException (java.io.IOException)15 File (java.io.File)12 APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)10 ByteArrayInputStream (java.io.ByteArrayInputStream)9 HashMap (java.util.HashMap)9 Map (java.util.Map)9 WSDLException (javax.wsdl.WSDLException)9 WSDLException (org.apache.woden.WSDLException)9 InputStream (java.io.InputStream)8 WSDLProcessor (org.wso2.carbon.apimgt.core.api.WSDLProcessor)8 FileInputStream (java.io.FileInputStream)7 WSDLSOAPOperation (org.wso2.carbon.apimgt.impl.wsdl.model.WSDLSOAPOperation)7 WSDLReader (javax.wsdl.xml.WSDLReader)5 ErrorItem (org.wso2.carbon.apimgt.api.ErrorItem)5 APIMWSDLReader (org.wso2.carbon.apimgt.impl.utils.APIMWSDLReader)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 FileOutputStream (java.io.FileOutputStream)4 ArrayList (java.util.ArrayList)4