I have more than one user having admin roles who are subscribed to a common folder which store some sort of images and documents. When one user add some images in the folder a notification email is sent to the subscribed user who has the view permission. My Problem starts from here when I upload the images through the portal, email notification is sent successfully. But when I try to save the image using the following code the email notification is not send.
**
_dlAppLocalService.addFileEntry(userId, companyGroup.getGroupId(), folder.getFolderId(), fileName,
ContentTypes.TEXT_CSV_UTF8, fileContent.getBytes(), serviceContext);
**
For further explanation :- This particular code is triggered inside the Schedular so I'm creating ServiceContext as follows:-
long companyId = _portal.getDefaultCompanyId();
Company company = _companyLocalService.getCompany(companyId);
Group companyGroup = _groupLocalService.getCompanyGroup(companyId);
User defaultUser = company.getDefaultUser();
long userId = defaultUser.getUserId();
ServiceContext serviceContext = new ServiceContext();
serviceContext.setCompanyId(companyId);
serviceContext.setUserId(userId);
and then passing service context inside the above method. I found that request and themeDisplay are coming as null in com.liferay.portlet.documentlibrary.util.DLImpl.startWorkflowInstance(long, DLFileVersion, String, ServiceContext) which leads to blankEntryURL and com.liferay.portlet.documentlibrary.service.impl.DLAppHelperLocalServiceImpl.notifySubscribers(long, FileVersion, String, ServiceContext) method fails to execute.
Can anyone help?. How I can get the file entryURL without having objects of themeDisplay and request?
You can avoid blank entryURL
adding the line below before the call to addFileEntry()
:
serviceContext.setAttribute("entryURL", "anyNotEmptyURL");
But it is not enough for the method notifySubscribers()
to run to the end. You need to add another line of code:
serviceContext.setCommand(Constants.ADD);
Unless a proper command value, the notification will be aborted.