@Test public void testSetFolderParticipantsSetsParticipantsCorrectlyOnFolder() throws AcmParticipantsException { final Long objectId = 1L; final String participantLdapId1 = "userId1"; final String participantType1 = "write"; final String participantLdapId2 = "userId2"; final String participantType2 = "read"; List<AcmParticipant> participants = new ArrayList<>(); AcmParticipant participant1 = new AcmParticipant(); participant1.setParticipantLdapId(participantLdapId1); participant1.setParticipantType(participantType1); participant1.setReplaceChildrenParticipant(true); participants.add(participant1); AcmParticipant participant2 = new AcmParticipant(); participant2.setParticipantLdapId(participantLdapId2); participant2.setParticipantType(participantType2); participants.add(participant2); AcmFolder folder = new AcmFolder(); folder.setId(objectId); EcmFile file = new EcmFile(); expect(mockFolderService.findById(objectId)).andReturn(folder); expect(mockFileDao.findByFolderId(objectId, FlushModeType.COMMIT)).andReturn(Arrays.asList(file)); expect(mockFileDao.save(file)).andReturn(file); expect(mockFolderService.saveFolder(folder)).andReturn(folder); expect(mockFolderDao.findSubFolders(objectId, FlushModeType.COMMIT)).andReturn(new ArrayList<>()); EntityManager em = mock(EntityManager.class); expect(mockFolderDao.getEm()).andReturn(em).anyTimes(); em.flush(); expectLastCall(); replayAll(); List<AcmParticipant> returnedParticipants = fileParticipantService.setFolderParticipants(objectId, participants); verifyAll(); assertEquals(2, returnedParticipants.size()); for (AcmParticipant participant : returnedParticipants) { switch (participant.getParticipantLdapId()) { case participantLdapId1: assertEquals(participantType1, participant.getParticipantType()); break; case participantLdapId2: assertEquals(participantType2, participant.getParticipantType()); break; default: fail("Unknown participantLdapId: [" + participant.getParticipantLdapId() + "] returned!"); break; } } assertEquals(1, file.getParticipants().size()); assertEquals(participantLdapId1, file.getParticipants().get(0).getParticipantLdapId()); assertEquals(participantType1, file.getParticipants().get(0).getParticipantType()); }
@Transactional(rollbackFor = Exception.class) public List<AcmParticipant> setFolderParticipants(Long objectId, List<AcmParticipant> participants) throws AcmParticipantsException { validateFileParticipants(participants); AcmFolder folder = getFolderService().findById(objectId); getFolderDao().getEm().detach(folder); setFolderParticipants(folder, participants, folder.getRestricted()); folder.setModified(new Date()); AcmFolder savedFolder = getFolderService().saveFolder(folder); return savedFolder.getParticipants(); }
EcmFileParticipantService { @Transactional(rollbackFor = Exception.class) public List<AcmParticipant> setFolderParticipants(Long objectId, List<AcmParticipant> participants) throws AcmParticipantsException { validateFileParticipants(participants); AcmFolder folder = getFolderService().findById(objectId); getFolderDao().getEm().detach(folder); setFolderParticipants(folder, participants, folder.getRestricted()); folder.setModified(new Date()); AcmFolder savedFolder = getFolderService().saveFolder(folder); return savedFolder.getParticipants(); } }
EcmFileParticipantService { @Transactional(rollbackFor = Exception.class) public List<AcmParticipant> setFolderParticipants(Long objectId, List<AcmParticipant> participants) throws AcmParticipantsException { validateFileParticipants(participants); AcmFolder folder = getFolderService().findById(objectId); getFolderDao().getEm().detach(folder); setFolderParticipants(folder, participants, folder.getRestricted()); folder.setModified(new Date()); AcmFolder savedFolder = getFolderService().saveFolder(folder); return savedFolder.getParticipants(); }  }
EcmFileParticipantService { @Transactional(rollbackFor = Exception.class) public List<AcmParticipant> setFolderParticipants(Long objectId, List<AcmParticipant> participants) throws AcmParticipantsException { validateFileParticipants(participants); AcmFolder folder = getFolderService().findById(objectId); getFolderDao().getEm().detach(folder); setFolderParticipants(folder, participants, folder.getRestricted()); folder.setModified(new Date()); AcmFolder savedFolder = getFolderService().saveFolder(folder); return savedFolder.getParticipants(); }  @Transactional(rollbackFor = Exception.class) EcmFile setFileParticipantsFromParentFolder(EcmFile file); @Transactional(rollbackFor = Exception.class) void setFolderParticipantsFromParentFolder(AcmFolder folder); List<AcmParticipant> getFolderParticipantsFromParentAssignedObject(String objectType, Long objectId); List<AcmParticipant> getFolderParticipantsFromAssignedObject(List<AcmParticipant> assignedObjectParticipants); @Transactional(rollbackFor = Exception.class) void inheritParticipantsFromAssignedObject(List<AcmParticipant> assignedObjectParticipants,
            List<AcmParticipant> originalAssignedObjectParticipants, AcmContainer acmContainer, boolean restricted); @Transactional(rollbackFor = Exception.class) List<AcmParticipant> setFileParticipants(Long objectId, List<AcmParticipant> participants); @Transactional(rollbackFor = Exception.class) List<AcmParticipant> setFolderParticipants(Long objectId, List<AcmParticipant> participants); EcmFileDao getFileDao(); void setFileDao(EcmFileDao fileDao); AcmParticipantService getParticipantService(); void setParticipantService(AcmParticipantService participantService); AcmFolderService getFolderService(); void setFolderService(AcmFolderService folderService); EcmFileParticipantServiceHelper getFileParticipantServiceHelper(); void setFileParticipantServiceHelper(EcmFileParticipantServiceHelper fileParticipantServiceHelper); AcmFolderDao getFolderDao(); void setFolderDao(AcmFolderDao folderDao); EcmFileConfig getEcmFileConfig(); void setEcmFileConfig(EcmFileConfig ecmFileConfig); }
EcmFileParticipantService { @Transactional(rollbackFor = Exception.class) public List<AcmParticipant> setFolderParticipants(Long objectId, List<AcmParticipant> participants) throws AcmParticipantsException { validateFileParticipants(participants); AcmFolder folder = getFolderService().findById(objectId); getFolderDao().getEm().detach(folder); setFolderParticipants(folder, participants, folder.getRestricted()); folder.setModified(new Date()); AcmFolder savedFolder = getFolderService().saveFolder(folder); return savedFolder.getParticipants(); }  @Transactional(rollbackFor = Exception.class) EcmFile setFileParticipantsFromParentFolder(EcmFile file); @Transactional(rollbackFor = Exception.class) void setFolderParticipantsFromParentFolder(AcmFolder folder); List<AcmParticipant> getFolderParticipantsFromParentAssignedObject(String objectType, Long objectId); List<AcmParticipant> getFolderParticipantsFromAssignedObject(List<AcmParticipant> assignedObjectParticipants); @Transactional(rollbackFor = Exception.class) void inheritParticipantsFromAssignedObject(List<AcmParticipant> assignedObjectParticipants,
            List<AcmParticipant> originalAssignedObjectParticipants, AcmContainer acmContainer, boolean restricted); @Transactional(rollbackFor = Exception.class) List<AcmParticipant> setFileParticipants(Long objectId, List<AcmParticipant> participants); @Transactional(rollbackFor = Exception.class) List<AcmParticipant> setFolderParticipants(Long objectId, List<AcmParticipant> participants); EcmFileDao getFileDao(); void setFileDao(EcmFileDao fileDao); AcmParticipantService getParticipantService(); void setParticipantService(AcmParticipantService participantService); AcmFolderService getFolderService(); void setFolderService(AcmFolderService folderService); EcmFileParticipantServiceHelper getFileParticipantServiceHelper(); void setFileParticipantServiceHelper(EcmFileParticipantServiceHelper fileParticipantServiceHelper); AcmFolderDao getFolderDao(); void setFolderDao(AcmFolderDao folderDao); EcmFileConfig getEcmFileConfig(); void setEcmFileConfig(EcmFileConfig ecmFileConfig);  }