Search in sources :

Example 11 with WSDLProcessor

use of org.wso2.carbon.apimgt.core.api.WSDLProcessor in project carbon-apimgt by wso2.

the class APIPublisherImpl method updateAPIWSDL.

@Override
public String updateAPIWSDL(String apiId, InputStream inputStream) throws APIMgtDAOException, APIMgtWSDLException {
    byte[] wsdlContent;
    try {
        wsdlContent = IOUtils.toByteArray(inputStream);
        WSDLProcessor processor = WSDLProcessFactory.getInstance().getWSDLProcessor(wsdlContent);
        if (!processor.canProcess()) {
            throw new APIMgtWSDLException("Unable to process WSDL by the processor " + processor.getClass().getName(), ExceptionCodes.CANNOT_PROCESS_WSDL_CONTENT);
        }
        if (log.isDebugEnabled()) {
            log.debug("Successfully validated the content of WSDL. API uuid: " + apiId);
        }
        getApiDAO().addOrUpdateWSDL(apiId, wsdlContent, getUsername());
        if (log.isDebugEnabled()) {
            log.debug("Successfully added WSDL to the DB. API uuid: " + apiId);
        }
        return new String(wsdlContent, APIMgtConstants.ENCODING_UTF_8);
    } catch (IOException e) {
        throw new APIMgtWSDLException("Error while updating WSDL of API " + apiId, e, ExceptionCodes.INTERNAL_WSDL_EXCEPTION);
    }
}
Also used : WSDLProcessor(org.wso2.carbon.apimgt.core.api.WSDLProcessor) APIMgtWSDLException(org.wso2.carbon.apimgt.core.exception.APIMgtWSDLException) IOException(java.io.IOException)

Aggregations

WSDLProcessor (org.wso2.carbon.apimgt.core.api.WSDLProcessor)11 APIMgtWSDLException (org.wso2.carbon.apimgt.core.exception.APIMgtWSDLException)8 IOException (java.io.IOException)4 WSDLArchiveInfo (org.wso2.carbon.apimgt.core.models.WSDLArchiveInfo)3 Test (org.testng.annotations.Test)2 APINotFoundException (org.wso2.carbon.apimgt.core.exception.APINotFoundException)2 LabelException (org.wso2.carbon.apimgt.core.exception.LabelException)2 API (org.wso2.carbon.apimgt.core.models.API)2 CompositeAPI (org.wso2.carbon.apimgt.core.models.CompositeAPI)2 Label (org.wso2.carbon.apimgt.core.models.Label)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 Response (javax.ws.rs.core.Response)1 APIPublisher (org.wso2.carbon.apimgt.core.api.APIPublisher)1 WorkflowResponse (org.wso2.carbon.apimgt.core.api.WorkflowResponse)1 APIManagementException (org.wso2.carbon.apimgt.core.exception.APIManagementException)1 WSDLInfo (org.wso2.carbon.apimgt.core.models.WSDLInfo)1 GeneralWorkflowResponse (org.wso2.carbon.apimgt.core.workflow.GeneralWorkflowResponse)1 ErrorDTO (org.wso2.carbon.apimgt.rest.api.common.dto.ErrorDTO)1