Foros de discusión

Permissions: open documents created by coding

Raffaele Canetta, modificado hace 10 años.

Permissions: open documents created by coding

New Member Mensajes: 8 Fecha de incorporación: 2/08/13 Mensajes recientes
Hello, I have a problem that I'm not able to solve.
I implemented a custom portlet that creates documents, in this way:

DLFileEntry fileEntryPreventivo = DLFileEntryLocalServiceUtil.addFileEntry(userId, groupId, repositoryId, cartellaPreventivi.getFolderId(), fileName_preventivo, "", fileName_preventivo, "", "", fileEntryTypeId, null, filePreventivo, inputStream, size, serviceContext);

where the variables are defined as follows:

long repositoryId = themeDisplay.getScopeGroupId();
long groupId = themeDisplay.getScopeGroupId();
long parentFolderId = DLFolderConstants.DEFAULT_PARENT_FOLDER_ID;
long fileEntryTypeId = DLFileEntryTypeConstants.FILE_ENTRY_TYPE_ID_BASIC_DOCUMENT;
Folder cartellaPreventivi = DLAppServiceUtil.getFolder(repositoryId, parentFolderId, Costanti.PREVENTIVI);
String relativePath = "C://temp/";
File filePreventivo = new File(relativePath + fileName_preventivo);
FileOutputStream outStream = new FileOutputStream(relativePath + fileName_preventivo);
document.write(outStream);
outStream.close();

Once the application creates the file (it works fine), I can access to the file within the portal only if I have an Administrator Role, but not if I am a Power User or a simple User.
How can I fix it?
Thank you very much
Raffaele
thumbnail
Zsolt Balogh, modificado hace 10 años.

RE: Permissions: open documents created by coding

Expert Mensajes: 463 Fecha de incorporación: 23/03/09 Mensajes recientes
Hi Raffaele,

You should take a look at the serviceContext paratmer you are passing to the service. It has some permission related fields.

Zsolt
thumbnail
Krzysztof Gołębiowski, modificado hace 10 años.

RE: Permissions: open documents created by coding

Liferay Master Mensajes: 549 Fecha de incorporación: 25/06/11 Mensajes recientes
Hi Raffaele,
I implemented Document Library bridge for one of our projects, and every time I used DLFileEntryLocalServiceUtil I got lots of problems (similar to the one you have). I finally ended up using DLAppServiceUtil for adding and modifying files from custom portlets (I think there was even forum thread where somebody from Liferay stated that DLFileEntryLocalService is more for internal use, external interface for accessing DL is DLAppServiceUtil).

This is example that works for me:

FileEntry fileEntry = DLAppServiceUtil.addFileEntry(repositoryId, folderId, sourceFileName, mimeType, title,
description, changeLog, is, size, serviceContext);


Regards,
KG
Raffaele Canetta, modificado hace 10 años.

RE: Permissions: open documents created by coding

New Member Mensajes: 8 Fecha de incorporación: 2/08/13 Mensajes recientes
Thank you very much for your advice, but in my application it is not working.
At first I got a file size exception, so I create the portal-ext.properties file setting the max size to 0, and I resolved this problem.
But it is not working yet, now on the very line I copied from your code I get the following error:
com.liferay.portal.kernel.exception.SystemException: java.io.IOException: The handle is invalid
How can I manage to solve it?
thumbnail
Krzysztof Gołębiowski, modificado hace 10 años.

RE: Permissions: open documents created by coding

Liferay Master Mensajes: 549 Fecha de incorporación: 25/06/11 Mensajes recientes
Could you paste whole exception here (including com.liferay packages)?