AEM(CQ5.6) BULK EDITOR Extension Part 1

29 / Nov / 2013 by ashish.panwar 5 comments

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.

ISSUE

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.
e.g. cq:allowedTemplates=/apps/geometrixx-media/templates/.*,/apps/geometrixx/templates/.*

The expected behaviour was for the comma separated string to persist each value as individual array element e.g.
cq:allowedTemplates=/apps/geometrixx-media/templates/.*,/apps/geometrixx/templates/.*

CAUSE

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

SOLUTION

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 : –

  1. 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.
  2. 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…..”
  3. “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”;
    bulkEditorConfig.put(“saveURL”,saveURL);
    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.
  4. 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[1]

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.

REFERENCES/LINKS

FOUND THIS USEFUL? SHARE IT

comments (5)

  1. Shailesh

    Hi Ashish,

    I found this article on web and seems only article on bulk loader where some customization is done, if you still follow this thread, I had a few questions about bulk loader as below , please respond with your comments :

    the GQL query parameter does not accept multiple parameter , how do I do that?
    Can I put date filters in GQL field for last published between dates?
    Can I disable the bulk editing in grid and only use this as readonly reports UI tool? ( how do I disable bulk editing options)?

    Reply
  2. ritesh

    Hi Ashish,

    i tried clicking on the search for 2-3 times but i didnt get the sling:resources or the title.
    but however when i searched for the geometrix – /content/geometrixx_mobile i got the sling:resources and the jcr:title.

    not sure why this is not happening for our websites

    i am trying to search the tags in the etc section – /etc/tags/dsm_keywords/automotive
    here only the path appears but not the others

    Reply
  3. ashish.panwar Post author

    Hi Ritesh,

    Like I mentioned in the post, this is frequently seen in bulk editor interface that all results are not loaded correctly. The way I have got around this situation is to click on search button 2, 3 times to let all results load correctly.
    Also verify the response is coming alright in any browser plugins such as firebug.

    Reply
  4. ritesh

    when i use the bulk editor, in the search result only the ‘path’ is displaying but not the sling:resourceType or the jcr:title in the search area

    Reply

Leave a comment -