Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: Subscriber Notification when Adding file programatically
Hi Liferay Folks,
I'm adding a file in documents and media folder in liferay programatically. I know that all those user who have permission to view and subscribe the folder will get a notification through email once a new document is added but in my case it is not happening.
I'm adding file using following approach:-
Since I'm adding the file programmatically and the file added successfully but the mail notification is not triggerring
I'm adding a file in documents and media folder in liferay programatically. I know that all those user who have permission to view and subscribe the folder will get a notification through email once a new document is added but in my case it is not happening.
I'm adding file using following approach:-
DLAppLocalServiceUtil.addFileEntry(
userId, companyGroup.getGroupId(), folder.getFolderId(), fileName,
ContentTypes.TEXT_CSV_UTF8, csvContent.getBytes(), serviceContext);
Since I'm adding the file programmatically and the file added successfully but the mail notification is not triggerring
Hi ,
Did you resolved the issue i am also facing same issue.
Did you resolved the issue i am also facing same issue.
Hi Srini,
Looking at the Liferay source code, I don't see anything in any of the addFileEntry methods that sends out notifications. How are you trying to use it? Are you trying to use this service in a custom portlet?
Looking at the Liferay source code, I don't see anything in any of the addFileEntry methods that sends out notifications. How are you trying to use it? Are you trying to use this service in a custom portlet?
Andrew JardineHi Srini,
Looking at the Liferay source code, I don't see anything in any of the addFileEntry methods that sends out notifications. How are you trying to use it? Are you trying to use this service in a custom portlet?
Yes in from custom portlet i am adding file.
Hi srini,
I didn't dig for hours into the source, but in the 10 or 15 minutes that I spent looking through a few classes I didn't see the reference. For sure it is there though so if you really want to know how Liferay is doing it, then for sure you will find it in the source. Alternatively you could manage sending the email yourself by leveraging the SubscriptionLocalService and the MailUtil that Liferay provides.
The SubscriptionLocalService can be used to look up the users who are subscribed to the folder that the file is being added to and then you can use the MailUtil to send the message.
For the record, and I haven't checked this to be honest but, I think the subscription to folders is only a feature web content folders. As far as I know there is no such feature for the documents and media folders.
I didn't dig for hours into the source, but in the 10 or 15 minutes that I spent looking through a few classes I didn't see the reference. For sure it is there though so if you really want to know how Liferay is doing it, then for sure you will find it in the source. Alternatively you could manage sending the email yourself by leveraging the SubscriptionLocalService and the MailUtil that Liferay provides.
The SubscriptionLocalService can be used to look up the users who are subscribed to the folder that the file is being added to and then you can use the MailUtil to send the message.
For the record, and I haven't checked this to be honest but, I think the subscription to folders is only a feature web content folders. As far as I know there is no such feature for the documents and media folders.
Well it turn out it is not possible without providing the configuration. The solution I followed, I created a configuration where I provide my QA and Prod URL and whever the mail is triggered it find which environment it is and concatinate the file path with the specific URL.
Ok. I think maybe I didn't understand your original problem then. I thought the issue was that the email was not being sent out ... Not that it had the wrong link.
If it's just the link you are looking for, the configuration is not the worst solution, but also not ideal as you now have a dependency on liferay not changing something in the future. You'd be better to use the api to generate the url so that if the logic for a generated url changes, you get the changes automatically.
Just some food for thought.
If it's just the link you are looking for, the configuration is not the worst solution, but also not ideal as you now have a dependency on liferay not changing something in the future. You'd be better to use the api to generate the url so that if the logic for a generated url changes, you get the changes automatically.
Just some food for thought.
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™