掲示板

No Repository exists with the primary key

thumbnail
7年前 に Rocco Piliero によって更新されました。

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
7年前 に Mika Koivisto によって更新されました。

RE: No Repository exists with the primary key

Liferay Legend 投稿: 1519 参加年月日: 06/08/07 最新の投稿
Don't use DLFileEntryLocalService it's internal implementation to Liferay repository. DLAppLocalService is the correct service to use.
thumbnail
7年前 に Rocco Piliero によって更新されました。

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.