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: Document library actions in a scheduler task
I need to list document library files and delete some ones periodically.
I have a class that implements MessageListener to run this task, but the scheduler class does not have a request and I don't know how can I get the repositorId without it.
public class MyScheduler implements MessageListener {
@Override
public void receive(Message message) throws MessageListenerException {
...
Long parentFolderId = DLFolderConstants.DEFAULT_PARENT_FOLDER_ID;
Folder folder = DLAppServiceUtil.getFolder(repositoryId, parentFolderId, folderName);
List<FileEntry> fileEntries = DLAppServiceUtil.getFileEntries(repositoryId, folder.getFolderId());
...
}
}
Is there any way to get repositoryid ?
Any alternative to run document library actions in sheduler task?
You coud use other service util, or service reference like DLFileEntryLocalServiceUtil:
There a methods with folderId without repositoryId, you can choose the one that meets your expectations.
Thanks for the hint but I don't find any method that fits my requirements in other services.
I need to list files inside a folder and I only have the folder name and the parentFolderID.
Hi
While sending message. In the message payload, it need to be sent .
How you are sending the message.
Regards
Sushil
Hi,
Check if you can pass the repositoryid in the message itself.
Hope it helps
Regards
Sushil
I'm not sending a Message and I think that I can't do it.
My Scheduler is defined in liferay-portlet.xml:
<scheduler-entry>
<scheduler-description>
My scheduler to delete files
</scheduler-description>
<scheduler-event-listener-class>com.example.MyScheduler</scheduler-event-listener-class>
<trigger>
<simple>
<property-key>10</property-key>
<time-unit>minute</time-unit>
</simple>
</trigger>
</scheduler-entry>
To send the message, I would have to create it dynamically, right?
I want to avoid a programmatically scheduler, because I need to start the scheduler without user interaction.
Powered by Liferay™