public static CmisContentStreamType convert(final ContentStream contentStream, final boolean allowClose) {
if (contentStream == null) {
return null;
}
CmisContentStreamType result = new CmisContentStreamType();
result.setFilename(contentStream.getFileName());
result.setLength(contentStream.getBigLength());
result.setMimeType(contentStream.getMimeType());
InputStream in = contentStream.getStream();
final InputStream stream;
// avoid double buffering
if (!(in instanceof BufferedInputStream) && !(in instanceof ByteArrayInputStream)) {
stream = new BufferedInputStream(in, BUFFER_SIZE);
} else {
stream = contentStream.getStream();
}
result.setStream(new DataHandler(new DataSource() {
public OutputStream getOutputStream() throws IOException {
return null;
}