Restrict Page Creation Based on Condition | Community
Skip to main content
Sady_Rifat
Community Advisor
Community Advisor
April 17, 2023

Restrict Page Creation Based on Condition

  • April 17, 2023
  • 1 reply
  • 564 views

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,

@9944223 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.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

SivakumarKanoori
Community Advisor
Community Advisor
April 17, 2023

@sady_rifat :Instead of writing the event listener .Can you try below. 

 

in the create page wizard, the below validation happens from the below validations.js file . You can write your validation in the below JS file.

 

JS file location: /libs/cq/gui/components/siteadmin/admin/clientlibs/validations/js/validations.js

 

 

 

SO its better to overlay and customize this js file instead of writing event listener.

 

Thanks,Siva
Sady_Rifat
Community Advisor
Community Advisor
April 17, 2023

Using clientlib is possible. But the requirement is to use Java directly. If it's not possible to solve by Java directly then I will go for the clientlib solution.