r1541 - xwiki/trunk/core/src/main/java/com/xpn/xwiki/web
Jeremi Joslin
jeremi at users.forge.objectweb.org
Mon Nov 13 22:52:33 CET 2006
Author: jeremi
Date: 2006-11-13 22:52:32 +0100 (Mon, 13 Nov 2006)
New Revision: 1541
Modified:
xwiki/trunk/core/src/main/java/com/xpn/xwiki/web/DownloadAction.java
Log:
add a friendly message if we can't get the content of an attachment
Modified: xwiki/trunk/core/src/main/java/com/xpn/xwiki/web/DownloadAction.java
===================================================================
--- xwiki/trunk/core/src/main/java/com/xpn/xwiki/web/DownloadAction.java 2006-11-13 21:24:32 UTC (rev 1540)
+++ xwiki/trunk/core/src/main/java/com/xpn/xwiki/web/DownloadAction.java 2006-11-13 21:52:32 UTC (rev 1541)
@@ -78,7 +78,17 @@
response.addHeader("Content-disposition", "inline; filename=\"" + ofilename + "\"");
response.setDateHeader("Last-Modified", attachment.getDate().getTime());
// Sending the content of the attachment
- byte[] data = attachment.getContent(context);
+ byte[] data;
+ try {
+ data = attachment.getContent(context);
+ }
+ catch(XWikiException e) {
+ Object[] args = { filename };
+ throw new XWikiException(XWikiException.MODULE_XWIKI_APP,
+ XWikiException.ERROR_XWIKI_APP_ATTACHMENT_NOT_FOUND,
+ "Attachment content {0} not found", null, args);
+ }
+
response.setContentLength(data.length);
try {
response.getOutputStream().write(data);
More information about the Xwiki-notifications
mailing list