use of org.wso2.carbon.apimgt.impl.wsdl.model.WSDLValidationResponse in project carbon-apimgt by wso2.
the class APIMWSDLReader method validateWSDLFile.
/**
* Extract the WSDL file and validates it
*
* @param inputStream file input stream
* @return Validation information
* @throws APIManagementException Error occurred during validation
*/
public static WSDLValidationResponse validateWSDLFile(InputStream inputStream) throws APIManagementException {
WSDLValidationResponse wsdlValidationResponse;
String path = System.getProperty(APIConstants.JAVA_IO_TMPDIR) + File.separator + APIConstants.WSDL_ARCHIVES_TEMP_FOLDER + File.separator + UUID.randomUUID().toString();
String wsdlFilePath = path + File.separator + APIConstants.WSDL_FILE + APIConstants.WSDL_FILE_EXTENSION;
// Append an additional '/' if not found before the prefix
if (!wsdlFilePath.startsWith("/")) {
wsdlFilePath = "/" + wsdlFilePath;
}
APIFileUtil.extractSingleWSDLFile(inputStream, path, wsdlFilePath);
String finalPath = APIConstants.FILE_URI_PREFIX + wsdlFilePath;
try {
WSDLProcessor processor = getWSDLProcessor(finalPath);
wsdlValidationResponse = new WSDLValidationResponse();
if (processor.hasError()) {
wsdlValidationResponse.setValid(false);
wsdlValidationResponse.setError(processor.getError());
} else {
wsdlValidationResponse.setValid(true);
wsdlValidationResponse.setWsdlInfo(processor.getWsdlInfo());
wsdlValidationResponse.setWsdlProcessor(processor);
}
return wsdlValidationResponse;
} catch (APIManagementException e) {
return handleExceptionDuringValidation(e);
}
}
Aggregations