01-04-2006 10:21 AM
01-05-2006 08:36 AM
01-06-2006 07:38 AM
01-06-2006 08:27 AM
ContentService contentService; // by Spring injection
ContentReader sourceReader; // passed in
ContentWriter targetWriter; // passed in
// do the stuff with the source stream
…
List<ContentReader> innerReaders = new ArrayList<ContentReader>(5);
// some kind of loop
…
{
String innerMimetype = …; // you get it somehow
// use the temp writer so that the file will be cleaned up
ContentWriter innerSource = contentService.getTempWriter();
// fill it with the inner document. Be sure to close the stream if you accessed it directly.
…
// get a target to transform to
ContentWriter innerTarget = contentService.getTempWriter();
// now transform
ContentTransformer innerToTextTransformer = contentTransformerRegistry.getTransformer(innerMimetype, MimetypeMap.TEXT_PLAIN);
innerToTextTransformer.transform(innerSource.getReader(), innerTarget);
// add the target to the list of readers
innerReaders.add(innerTarget.getReader());
}
// now you have a list of readers that are the text version of all inner documents
OutputStream targetos = null;
try
{
// write the stream to the output target.
targetOs = targetWriter.getOutputStream(); // can only do this once
for (ContentReader innerReader: innerReaders)
{
// you can't use targetWriter.putContent(innerReader) because, as the javadoc states,
// the ouput channel will be closed and the reader and writer may only be used once
InputStream innerSourceIs = innerReader.getInputStream();
copy(innerSourceIs, targetOs); // inner source input stream will be closed
}
}
finally
{
// close the output stream
…
}
// done
/**
* Copies the input stream to the output stream, closing only the input stream upon completion
*/
private void copy(InputStream is, OutputStream os)
{
// see Spring FileCopyUtils for example code, if required
…
}
01-06-2006 06:11 PM
05-07-2007 10:35 AM
ContentTransformer innerToTextTransformer = contentTransformerRegistry.getTransformer(innerMimetype, MimetypeMap.TEXT_PLAIN);
05-07-2007 01:05 PM
05-08-2007 03:41 AM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.