Hello,
I have a requirement to restrict page creation based on some conditions.
For Example,
When an author wants to create a page I need to check some validity from my Java code
As soon as I found anything wrong I need to restrict the author from creating the page and show some error. (This error could be the exception message).
For this, I tried implementing EventListener, but Event is triggered after the page creation.
public JackrabbitEventFilter createPageEvent (String path) {
JackrabbitEventFilter jackrabbitEventFilterPage = new JackrabbitEventFilter();
return jackrabbitEventFilterPage.setAbsPath(path)
.setEventTypes(Event.NODE_ADDED)
.setIsDeep(true)
.setNodeTypes(new String[]{NT_PAGE, NT_TAG});
}
In the OnEvent I throw an exception,
@Override
public void onEvent(EventIterator events) {
throw new AccessControlException("Restricted");
// Or any kind of exception
}
But this is not working.
How I can achieve this?
Note: I also need to get the page properties that are filled up by the author.