Frage

We've setup liferay to use JackRabbit as its document repository. Now what I'm trying to do is retrieve an specific document, and all I know about it is it's name, and sometimes the name of the folder it may be located in.

I know DLFileEntryLocalServiceUtil allows me to retrieve said document but requires me to have it's id before handing it over. My question is, how can I get the id of the file I'm looking for if all I have is the file name and it's location?

War es hilfreich?

Lösung

Below code snippet could help you,

FileEntry fileEntry = DLAppServiceUtil.getFileEntry(repositoryId, CREATED_FOLDER_ID, fileName);

In above, you have pass repositoryId could be equivalent to groupId which you can get it from themedisplay.getGroupId(), your folderId and fileName

you can get folderId by below code,

        long FOLDER_ID = 0;
        long repositoryId = themeDisplay.getScopeGroupId();
        long parentFolderId = DLFolderConstants.DEFAULT_PARENT_FOLDER_ID;
        List<Folder> lFolder = DLAppServiceUtil.getFolders(repositoryId, parentFolderId);
        for (Folder folder : lFolder)
        {
            if (folder.getName().equalsIgnoreCase(FOLDER_NAME))
            {
                FOLDER_ID = folder.getFolderId();
                break;
            }
        }

Please let me know if it helps

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top