Forums de discussion

LR7GA4: NoSuchFolderException, but the folder exist!

thumbnail
Luigi Candita, modifié il y a 6 années.

LR7GA4: NoSuchFolderException, but the folder exist!

Junior Member Publications: 38 Date d'inscription: 04/05/09 Publications récentes
Hi at all

I have this problem when I'm trying to upload a file inside a DLFolder.

After created the folder with this (in my actionCommand)

                dlFolder = DLFolderLocalServiceUtil.addFolder(
                        currentUserId,
                        scopeGroupIp,
                        serviceContext.getThemeDisplay().getScopeGroup().getGroupId(),
                        false,
                        parentFolderId,
                        folderName,
                        description,
                        false,
                        serviceContext);


the result is DLFolder object with all data setted. If I check in the table dlfolder I found the new folder without problem (repositoryid, groupid are right).

But if I try to add a new DLFileEntry with this:

 DLFileEntry dlFileEntry = DLFileEntryLocalServiceUtil
                    .addFileEntry(
                            currentUserId,
                            user.getGroupId(),
                            scopeGroupIp,
                            dlFolder.getFolderId(),
                            uploadedFile.getName(),
                            mimeType,
                            title,
                            description,
                            "",
                            fileEntryTypeId,
                            null,
                            uploadedFile,
                            is,
                            uploadedFile.getTotalSpace(),
                            _serviceContext);


I have this:

10:20:13,917 ERROR [http-nio-8080-exec-1][UploadDocumentActionCommand:151] null
com.liferay.document.library.kernel.exception.NoSuchFolderException
        at com.liferay.portlet.documentlibrary.service.impl.DLFileEntryLocalServiceImpl.validateFile(DLFileEntryLocalServiceImpl.java:2072)
        at com.liferay.portlet.documentlibrary.service.impl.DLFileEntryLocalServiceImpl.validateFile(DLFileEntryLocalServiceImpl.java:2734)
        at com.liferay.portlet.documentlibrary.service.impl.DLFileEntryLocalServiceImpl.addFileEntry(DLFileEntryLocalServiceImpl.java:192)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)


But the folder exist!!!
What I'm wrong? There is a valid sample to see how create a DLFileEntry?

Thanks,

Luis
What I'm wrong? Which portlet source I can check to
thumbnail
Olaf Kock, modifié il y a 6 années.

RE: LR7GA4: NoSuchFolderException, but the folder exist!

Liferay Legend Publications: 6403 Date d'inscription: 23/09/08 Publications récentes
Luigi Candita:
 DLFileEntry dlFileEntry = DLFileEntryLocalServiceUtil
                    .addFileEntry(
                            currentUserId,
                            user.getGroupId(),
                            scopeGroupIp,  ...


According to Javadoc, the interface of DLFileEntryLocalService.addFileEntry is
DLFileEntry addFileEntry(long userId,
                         long groupId,
                         long repositoryId,...


Just checking these first parameters, number 2 and 3 look suspicious: Unless you are referring to the folder within the user's own site, user.getGroupId() is wrong. And scopeGroupId also doesn't sound like a repositoryId.

Plus, in Liferay7, you should - if possible - no longer use the *Util classes, rather get the actual service injected. This proper and explicit dependency management is a lot better in OSGi times.
thumbnail
Luigi Candita, modifié il y a 6 années.

RE: LR7GA4: NoSuchFolderException, but the folder exist!

Junior Member Publications: 38 Date d'inscription: 04/05/09 Publications récentes
I think that is better to understand the meaning of scope and repository ids and forget wrong samples. (pre-osgi)

Thank you Olaf!