RE: RE: Document library actions in a scheduler task

Sonia Castro,修改在5 年前。 New Member 帖子: 3 加入日期: 15-12-3 最近的帖子

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?

thumbnail
Vilmos Papp,修改在5 年前。 Liferay Master 帖子: 529 加入日期: 10-10-21 最近的帖子

You coud use other service util, or  service reference like DLFileEntryLocalServiceUtil:

https://github.com/vilmospapp/liferay-portal/blob/master/portal-kernel/src/com/liferay/document/library/kernel/service/DLFileEntryLocalServiceUtil.java#L703

There a methods with folderId without repositoryId, you can choose the one that meets your expectations.

Sonia Castro,修改在5 年前。 New Member 帖子: 3 加入日期: 15-12-3 最近的帖子

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.

 

thumbnail
Sushil Patidar,修改在5 年前。 Expert 帖子: 467 加入日期: 11-10-31 最近的帖子

Hi 

While sending message. In the message payload, it need to be sent .

How you are sending the message.

Regards

Sushil

thumbnail
Sushil Patidar,修改在5 年前。 Expert 帖子: 467 加入日期: 11-10-31 最近的帖子

Hi,

 

Check if you can pass the repositoryid in the message itself.

Hope it helps

 

Regards

Sushil

Sonia Castro,修改在5 年前。 New Member 帖子: 3 加入日期: 15-12-3 最近的帖子

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.