0

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) -

  1. GroupA
  2. 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?

Coder
  • 3,090
  • 8
  • 49
  • 85
  • In case Daniele's answer didn't help (as you haven't accepted it yet): Which version are you using? – Olaf Kock Jul 14 '15 at 05:40
  • already mentioned above liferay 6.2 – Coder Jul 15 '15 at 05:16
  • sorry, not exact enough a question: I was looking for the exact release, e.g. "CE GA4"? There were a few permission issues in GA3 that you might want to rule out - they led to guest view permissions missing. – Olaf Kock Jul 15 '15 at 05:46

1 Answers1

0

Using DLAppLocalServiceUtil and DLFileEntryServiceUtil is not the right way. Thery bypass permissions updating and right repository managment.

Use DLAppServiceUtil instead to move and to update.

Daniele Baggio
  • 2,157
  • 1
  • 14
  • 21
  • For general rule the DLAppServiceUtil class manages correctly the permission settings. This is true expecially creating a new file entry. Use ```DLAppServiceUtil.moveFileEntry``` to move the file. – Daniele Baggio Jul 13 '15 at 13:03
  • I have used DLAPPServiceUtil but the file status is not getting updated to Approved. It stays as Draft – Coder Jul 15 '15 at 05:18