use of org.apache.commons.codec.binary.Base64InputStream in project tdi-studio-se by Talend.
the class JavaProcessor method generateWSDL.
private void generateWSDL(IFolder wsdlsPackageFolder, INode node) throws CoreException, IOException {
// retrieve WSDL content (compressed-n-encoded) -> zip-content.-> wsdls.(first named main.wsdl)
String wsdlContent = node.getElementParameter("WSDL_CONTENT").getValue().toString();
// String wsdlContent = (String) node.getPropertyValue("WSDL_CONTENT"); //$NON-NLS-1$
String uniqueName = node.getUniqueName();
if (null != uniqueName && null != wsdlContent && !wsdlContent.trim().isEmpty()) {
// configure decoding and uncompressing
InputStream wsdlStream = new BufferedInputStream(new InflaterInputStream(new Base64InputStream(new ByteArrayInputStream(wsdlContent.getBytes()))));
if (!wsdlsPackageFolder.exists()) {
wsdlsPackageFolder.create(true, true, null);
}
// generate WSDL file
if (checkIsZipStream(wsdlStream)) {
ZipInputStream zipIn = new ZipInputStream(wsdlStream);
ZipEntry zipEntry = null;
while ((zipEntry = zipIn.getNextEntry()) != null) {
String outputName = zipEntry.getName();
if ("main.wsdl".equals(outputName)) {
//$NON-NLS-1$
//$NON-NLS-1$
outputName = uniqueName + ".wsdl";
}
IFile wsdlFile = wsdlsPackageFolder.getFile(outputName);
if (!wsdlFile.exists()) {
// cause create file will do a close. add a warp to ignore close.
InputStream unCloseIn = new FilterInputStream(zipIn) {
@Override
public void close() throws IOException {
}
;
};
wsdlFile.create(unCloseIn, true, null);
}
zipIn.closeEntry();
}
zipIn.close();
} else {
//$NON-NLS-1$
IFile wsdlFile = wsdlsPackageFolder.getFile(uniqueName + ".wsdl");
wsdlFile.create(wsdlStream, true, null);
}
}
}
Aggregations