@Override public DocumentTranslationMap write(ExportedDocument[] docs) throws IOException { initWriter(); out.write("<documents>".getBytes()); out.flush(); DocumentTranslationMap map = super.write(docs); writer.flush(); out.write("</documents>".getBytes()); return map; }
protected DocumentWriter makeDocumentWriter(OutputStream outputStream, boolean exportAsTree, boolean exportAsZip) throws IOException { DocumentWriter documentWriter; if (exportAsZip) { documentWriter = new NuxeoArchiveWriter(outputStream); } else { if (exportAsTree) { documentWriter = new XMLDocumentTreeWriter(outputStream); } else { documentWriter = new XMLDocumentWriter(outputStream); } } return documentWriter; } }
/** * {@inheritDoc} */ public final byte[] exportXMLAsByteArray(DocumentModel doc, CoreSession session) { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); DocumentWriter documentWriter = new XMLDocumentWriter(outputStream); DocumentReader documentReader = new TypedSingleDocumentReader(session, doc); DocumentPipe pipe = new DocumentPipeImpl(); pipe.setReader(documentReader); pipe.setWriter(documentWriter); try { pipe.run(); } catch (IOException e) { throw new NuxeoException("Error while trying to export the document to XML.", e); } finally { if (documentReader != null) { documentReader.close(); } if (documentWriter != null) { documentWriter.close(); } } return outputStream.toByteArray(); } }
@Override public DocumentTranslationMap write(Collection<ExportedDocument> docs) throws IOException { initWriter(); out.write("<documents>".getBytes()); out.flush(); DocumentTranslationMap map = super.write(docs); writer.flush(); out.write("</documents>".getBytes()); return map; }