/** * A helper method that serializes the element object. * * @param stream * the stream to which the element should be serialized. * @throws IOException * if an IO error occured or a property was not serializable. */ private void writeObject( final ObjectOutputStream stream ) throws IOException { stream.defaultWriteObject(); try { final DocumentBundle bundle = getBundle(); stream.writeObject( bundle.getMetaData().getBundleType() ); final MemoryDocumentBundle mem = new MemoryDocumentBundle(); BundleUtilities.copyStickyInto( mem, bundle ); BundleUtilities.copyInto( mem, bundle, LegacyBundleResourceRegistry.getInstance().getRegisteredFiles(), true ); BundleUtilities.copyMetaData( mem, bundle ); mem.getWriteableDocumentMetaData().setBundleType( "application/vnd.pentaho.serialized-bundle" ); final ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); BundleUtilities.writeAsZip( outputStream, mem ); stream.writeObject( outputStream.toByteArray() ); } catch ( ContentIOException e ) { throw new IOException( "Unable to serialize the bundle", e ); } }
/** * Writes a certain aspect into a own file. The name of file inside the bundle is returned as string. The file name * returned is always absolute and can be made relative by using the IOUtils of LibBase. If the writer-handler did not * generate a file on its own, it should return null. * * @param bundle * the bundle where to write to. * @param state * the writer state to hold the current processing information. * @return the name of the newly generated file or null if no file was created. * @throws IOException * if any error occured * @throws BundleWriterException * if a bundle-management error occured. */ public String writeReport( final WriteableDocumentBundle bundle, final BundleWriterState state ) throws IOException, BundleWriterException { BundleUtilities.copyStickyInto( bundle, state.getGlobalBundle() ); // Process all nodes starting at the top processSection( bundle, state.getMasterReport(), state.getMasterReport() ); // Don't return anything ... we may have created none-or-more files return null; }
BundleUtilities.copyStickyInto( mem, bundle ); BundleUtilities.copyInto( mem, bundle, LegacyBundleResourceRegistry.getInstance().getRegisteredFiles(), true ); BundleUtilities.copyMetaData( mem, bundle );