I am quite fond of the bulk editor feature of CQ and in the past I have used it quite often to quickly view and update content from within the Bulk editor console.
Recently I found the need to refer to this “old friend” to make some quick content updates from within the Bulk editor console when I noticed something was not right. (I had not used this feature for sometime).
I found there were two issues:
- Bulk editor (BE) could not add multi-value properties.
- BE could not add properties other than type String.
I did not test the aforementioned issues in old versions of CQ, so cannot say if these are new bugs or this has always been the case with bulk editor. Since I did not have much time to go through Adobe support, I fixed it for my own installation.
In this post, I’ll tackle the first part i.e. Adding multi-value property (only String for now). In a later post I’ll take up the second part. I’m using the latest release of AEM 5.6.1.
I observed that the save operation relied on the Default Sling POST servlet while it should have used the default bulk editor post handler script (/libs/wcm/core/components/bulkeditor/save/POST.jsp).
Let’s try out by searching for a property for editing.
Navigate to bulk editor console at http://<host>:<port>/etc/importers/bulkeditor.html and configure the following properties –
rootpath = /content/geometrixx-media
Query params = <Keep it empty>
Content mode = <unchecked>
Properties = Select sling:resourceType
Custom properties = cq:allowedTemplates
Click on search and let the result load. In my local instance a total of 362 results were returned of which only one row contained non-empty “cq:allowedTemplates” property. You might have to click on search button 2 or 3 times for results to load properly.
Now edit the multivalue “cq:allowedTemplates” property and click save. In CRXDELite, check the property and you’ll find that the whole comma separated string gets stored as the first element of the array.
The expected behaviour was for the comma separated string to persist each value as individual array element e.g.
If you edit any property and click on save, the resulting POST will be handled by the Sling Default POST servlet, even when there is a save POST handler available for this (/libs/wcm/core/components/bulkeditor/save/POST.jsp). To invoke the bulk editor save POST handler, you would like the POST to be made to http://<host>:<port>/etc/importers/bulkeditor/save
Gear up for making some code changes. There are two parts to this problem, Firstly the save action should be handled by the appropriate save POST script and secondly multivalue properties (only String for now) should be editable.
Follow these steps : –
- Before making edits, overlay the bulk editor component under /apps, such that we have /apps/wcm/core/components/bulkeditor (We do not want to make any edits under /libs).To test that the overlayed bulk editor component is being referred to by the bulk editor page, change the title in bulkeditor.jsp to something like:<title>CQ5 customized BulkEditor</title>
Refresh the bulk editor page http://<host>:<port>/etc/importers/bulkeditor.html. You should see the updated page title.
- Under the overlayed bulk editor component, open all the Java files (json.java, POST.java, tsv.java) and update the package imports to start from “apps.wcm.core…..” instead of “libs.wcm.core…..”
- “save” operation should post to http://<host>:<port>/etc/importers/bulkeditor/save instead of Sling default POST servlet. To make this change follow instructions below:
– Open bulkeditor.jsp
– Add below lines (Refer attached screenshot):
String saveURL = “/etc/importers/bulkeditor/save”;
Remove browser cache (Shorthand “Ctrl + Shift + Delete” -> Empty the cache) and refresh the bulk editor page. Search using same settings as described above. Edit a property and click save. Using firebug or browser supported debugging tool monitor the request being fired. You should see the “save” action POSTing to “http://<host>:<port>/etc/importers/bulkeditor/save”.
This would result in the overlayed “/apps/wcm/core/components/bulkeditor/save/POST.jsp” script being called. Put some loggers in this script to ensure this script is indeed being called.
- Allowing multivalue String properties editing through bulk editor interface
As you might have noted, cq:allowedTemplates is a multivalue property (String ). If you tried editing any multivalue property via the OOTB implementation of bulk editor, you would notice that the whole comma separated value gets stored as the first element of the array, instead of each comma separated value being stored as the array element. In short, bulk editor save operation does not distinguish between String and String.
Open “/apps/wcm/core/components/bulkeditor/save/POST.jsp” for editing and make following changes. Refer attached file
There are other ways to achieve the same thing but I find this to be the easy and simple way. Also, please note that the above steps are not applicable for tsv file import utility.
In the follow up to this post I’ll discuss the second part “Bulk Editor interface should support adding properties other than type String, e.g. Long,Boolean, Date”. In the meantime feel free to suggest alternate approaches you may like/prefer.