CQ5 workflow content inbox | Approve folder content wrong url

252 Views Asked by At

We have created a workflow to send approval mail to approver. The payload is jcr:content of a folder or a PDF.
After the coding, the behaviour is for:
A pdf : It generate right URL as http:///damadmin.html#/content/ab/cd/abc.pdf
A folder : It generate the wrong url as http:///damadmin.html#/content/folder-name/jcr:content

So, for folder, we have updated the code to change the payload as the folder-path instead of folder-path/jcr:content
for that we used,

WorkflowData wfData = wfSession.newWorkflowData("JCR_PATH", folder_node_path);
    wfSession.updateWorkflowData(workItem.getWorkflow(), wfData);

After the code change,
When a user modify any dam content like a pdf, the url is correct as http:///damadmin.html#/
but when the user modify a folder properties, the mail sent to approver has the wrong url as http:///

means /damadmin.html# is missing.

We need that the correct link should be added for both PDF and Folder. Thanks in advance.

1

There are 1 best solutions below

0
GaganB On

Issue is resolved.
I am using CQ 5.5.

Sharing my experience.

We don't need to change the payload. The payload can remain as jcr:content

We need to do two things:

  1. Make sure the folder-path/jcr:content has the value in property jcr:title. It will be shown in content column of the inbox page.

  2. For the folder link in inbox page, it must be as /content//jcr:content. The problem is because /damadmin.html# is not added before the url.
    This problem is not coming for any Asset or Page.
    Solution is:
    You need add the following code in /libs/cq/workflow/components/inbox/list/json.jsp


A=> Add private method

private String handleDamPathForFolder(Logger log, String payloadUrl, Session session, WorkItem wi)
{
    try
    {
        if(isFolderNode(session, wi))
        {
            return ("/damadmin.html#"+payloadUrl);
        }
    }catch (Exception e)
    {
        log.error("Unable to handle path creation for work item: " + wi.getId(), e);
    }
    return payloadUrl;
}

We have to write the method isFolderNode which will return true if the node is a folder.



B=>Replace

JSONWriterUtil.write(writer, "payload", pathBuilder.getPath(wi),JSONWriterUtil.WriteMode.BOTH, xss);


by the follwoing


JSONWriterUtil.write(writer,"payload",handleDamPathForFolder(log,pathBuilder.getPath(wi), session, wi), JSONWriterUtil.WriteMode.BOTH, xss);

<br/>