Author: vmassol
Date: 2007-11-25 08:25:45 +0100 (Sun, 25 Nov 2007)
New Revision: 6069
Modified:
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/web/DeleteAction.java
Log:
XWIKI-1892: Erasing a document that hasn't been previously deleted generates a
NPE
Modified:
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/web/DeleteAction.java
===================================================================
---
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/web/DeleteAction.java
2007-11-25 07:15:33 UTC (rev 6068)
+++
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/web/DeleteAction.java
2007-11-25 07:25:45 UTC (rev 6069)
@@ -51,15 +51,18 @@
String sindex = request.getParameter("id");
if (sindex != null) {
long index = Long.parseLong(sindex);
- XWikiDeletedDocument dd = xwiki.getRecycleBinStore()
- .getDeletedDocument(doc, index, context, true);
- DeletedDocument ddapi = new DeletedDocument(dd, context);
- if (!ddapi.canDelete()) {
- throw new
XWikiException(XWikiException.MODULE_XWIKI_ACCESS,
- XWikiException.ERROR_XWIKI_ACCESS_DENIED,
- "You can't delete from recycle bin before some time
has passed");
+ XWikiDeletedDocument dd =
xwiki.getRecycleBinStore().getDeletedDocument(doc, index, context, true);
+ // If the document hasn't been previously delete (ie it's not
in the deleted document store) then
+ // don't try to delete it and instead redirect to the view
page.
+ if (dd != null) {
+ DeletedDocument ddapi = new DeletedDocument(dd, context);
+ if (!ddapi.canDelete()) {
+ throw new
XWikiException(XWikiException.MODULE_XWIKI_ACCESS,
+ XWikiException.ERROR_XWIKI_ACCESS_DENIED,
+ "You can't delete from recycle bin before some
time has passed");
+ }
+ xwiki.getRecycleBinStore().deleteFromRecycleBin(doc,
index, context, true);
}
- xwiki.getRecycleBinStore().deleteFromRecycleBin(doc, index,
context, true);
sendRedirect(response, doc.getURL("view", context));
redirected = true;
} else {
_______________________________________________
notifications mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/notifications