*
* @author Andreas Br�ker
*/
public void export(String url, IFilter filter) throws DocumentException {
if (url == null)
throw new DocumentException(Messages.getString("PersistenceService.error_url_invalid_message")); //$NON-NLS-1$
if (filter == null)
throw new DocumentException(Messages.getString("PersistenceService.error_filter_invalid_message")); //$NON-NLS-1$
String filterDefinition = filter.getFilterDefinition(document);
PropertyValue[] properties = new PropertyValue[1];
if (filterDefinition != null) {
properties[0] = new PropertyValue();
properties[0].Name = "FilterName"; //$NON-NLS-1$
properties[0].Value = filterDefinition;
}
//TODO set compression mode for pdf
if (!filter.isExternalFilter())
document.fireDocumentEvent(IDocument.EVENT_ON_SAVE_AS);
try {
url = URLAdapter.adaptURL(url);
xStorable.storeToURL(url, properties);
}
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 DocumentException(message, throwable);
}
if (!filter.isExternalFilter())
document.fireDocumentEvent(IDocument.EVENT_ON_SAVE_AS_DONE);
}