留言板

No Repository exists with the primary key

thumbnail
Rocco Piliero,修改在7 年前。

No Repository exists with the primary key

New Member 帖子: 7 加入日期: 16-11-12 最近的帖子
Hi,
I have a problem with the repository primary key using liferay portal 6.2
My target is to read a file from a custom folder and save it into Document Library. If I use DLAppLocalServiceUtil it's all ok but if I use DLFileEntryLocalServiceUtil, it throws a NoSuchRepositoryException with the message "No Repository exists with the primary key 28311".
I get the RepositoryId in this way
Folder folder = DLAppLocalServiceUtil.getFolder(Long.parseLong(folderId));
Folder folderUser = DLAppLocalServiceUtil.addFolder(userId, folder.getRepositoryId(), folder.getFolderId()...);
Long repositoryId = folderUser.getRepositoryId();

In both case parameters are the same. So, why in DLFileEntryLocalServiceUtil case it throws that exception?

Thank you
thumbnail
Mika Koivisto,修改在7 年前。

RE: No Repository exists with the primary key

Liferay Legend 帖子: 1519 加入日期: 06-8-7 最近的帖子
Don't use DLFileEntryLocalService it's internal implementation to Liferay repository. DLAppLocalService is the correct service to use.
thumbnail
Rocco Piliero,修改在7 年前。

RE: No Repository exists with the primary key

New Member 帖子: 7 加入日期: 16-11-12 最近的帖子
Mika Koivisto:
Don't use DLFileEntryLocalService it's internal implementation to Liferay repository. DLAppLocalService is the correct service to use.

Thanks for your answer. I've tried to use DLFileEntryLocalService instead of DLAppLocalService because I've a zero bytes file problem. In detail: I upload a file into liferay-tomcat temp folder, then I try to save this file in Document Library using DLAppLocalService.addFileEntry and passing it a java.io.File created in this way
File file = new File("<file in temp folder>").</file>

Sometimes it happens that in my Document Library is uploaded an empty file. Reading liferay code it seems that if file is null, liferay creates an empty byte array and stores it.
The real problem is that I don't understand why sometimes the upload with DLAppLocalService goes well and sometimes not, without errors.
Can you help me?
Thank you.