Fórum

No Repository exists with the primary key

thumbnail
Rocco Piliero, modificado 7 Anos atrás.

No Repository exists with the primary key

New Member Postagens: 7 Data de Entrada: 12/11/16 Postagens Recentes
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, modificado 7 Anos atrás.

RE: No Repository exists with the primary key

Liferay Legend Postagens: 1519 Data de Entrada: 07/08/06 Postagens Recentes
Don't use DLFileEntryLocalService it's internal implementation to Liferay repository. DLAppLocalService is the correct service to use.
thumbnail
Rocco Piliero, modificado 7 Anos atrás.

RE: No Repository exists with the primary key

New Member Postagens: 7 Data de Entrada: 12/11/16 Postagens Recentes
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.