Using liferay 6.2 api to insert images in document library. The code also moves images from one folder to another folder
But After moving the images their folders do not get guest view
permissions and images can't be viewed.
I have two groups (sites) -
- GroupA
- GroupB
GroupA user creates folders, inserts files and also moves files. GroupB user should be able to see the files.
All the folders and files are created under Global scope
in document library.
public void moveFilesToFolder(final HttpServletRequest request, final List<DLFileEntry> filesToMove, final DLFolder toFolder)
throws Exception {
final ServiceContext sc = ServiceContextFactory.getInstance(request);
sc.setWorkflowAction(WorkflowConstants.STATUS_APPROVED);
sc.setAddGuestPermissions(true);
sc.setAddGroupPermissions(true);
for (final DLFileEntry file : filesToMove) {
DLAppServiceUtil.moveFileEntry(file.getFileEntryId(), toFolder.getFolderId(), sc)
}
// update folders to have guest permissions
DLAppLocalServiceUtil.updateFolder(toFolder.getFolderId(), toFolder.getParentFolderId(), toFolder.getName(),
toFolder.getDescription(), sc);
}
This doesn't seem to work and guest permissions are not set for all the users. The weird behavior is that when the user who performed the move operation looks at the permissions from UI, gues view permission is checked but for any other user the permission is not checked.
As per suggestions below I have used DLAppServiceUtil
to move files. But It doesnt change status of file to approved from draft.
Also what is the correct method to use to copy files? There is no method in DLAppServiceUtil
to copy files from one folder to another
Anybody knows how to solve this issue?