cogProgrammatically delete a page without storing it in the trash bin
Developed by

Thomas Mortagne

Rating
Rate!
0 Votes
LicenseGNU Lesser General Public License 2.1

Description

Sometimes the step which store the deleted document in the trash bin does not work for various reason (not enough memory and database storage, too long page name in filesystem storage, etc.) or you just don't plan to pollute the trash bin. It's not possible to skip the trash bin with the UI but you can do it programmatically if you have programing right:

{{velocity}}
## Accessing those two objects require programming right
#set($protectedContext = $xcontext.context)
#set($protectedDocument = $xwiki.getDocument("MySpace.MyPage").document)

$protectedContext.getWiki().deleteDocument($protectedDocument, false, $protectedContext)
{{/velocity}}

Prerequisites & Installation Instructions

Copy the code snippet to a page and save it.

Tags:
Created by Thomas Mortagne on 2018/10/18 09:33
     

Get Connected