* @date 25.08.2006
*/
public void export(OutputStream outputStream, IFilter filter)
throws NOAException {
if (outputStream == null)
throw new NOAException(
Messages
.getString("PersistenceService_error_message_invalid_output_stream")); //$NON-NLS-1$
if (filter == null || !filter.isSupported(document))
throw new NOAException(
Messages
.getString("PersistenceService.error_filter_invalid_message")); //$NON-NLS-1$
String filterDefinition = filter.getFilterDefinition(document);
OutputStreamToXOutputStreamAdapter streamAdapter = new OutputStreamToXOutputStreamAdapter(
outputStream);
PropertyValue[] properties = new PropertyValue[2];
properties[0] = new PropertyValue();
properties[0].Name = "FilterName"; //$NON-NLS-1$
properties[0].Value = filterDefinition;
properties[1] = new PropertyValue(
"OutputStream", -1, streamAdapter, PropertyState.DIRECT_VALUE); //$NON-NLS-1$
if (!filter.isExternalFilter())
document.fireDocumentEvent(IDocument.EVENT_ON_SAVE_AS);
try {
xStorable.storeToURL("private:stream", properties); //$NON-NLS-1$
} catch (Throwable throwable) {
String message = throwable.getMessage();
if (throwable instanceof ErrorCodeIOException) {
message = ErrorCodeTranslator
.getErrorCodeMessage(((ErrorCodeIOException) throwable).ErrCode);
if (message == null)
message = Messages
.getString(
"PersistenceService.error_io_message", String.valueOf(((ErrorCodeIOException) throwable).ErrCode)); //$NON-NLS-1$
} else if (message == null || message.length() == 0)
message = ERROR_MESSAGE;
throw new NOAException(message, throwable);
}
if (!filter.isExternalFilter())
document.fireDocumentEvent(IDocument.EVENT_ON_SAVE_AS_DONE);
}