@Test public void testInheritParticipantsFromAssignedObject() { final Long objectId = 1L; final String participantLdapId = "userId2"; final String participantType = "write"; final String participantLdapId1 = "userId1"; final String participantType1 = "assignee"; final String participantLdapId2 = "userId2"; final String participantType2 = "assignee"; final String participantLdapId3 = "userId3"; final String participantType3 = "owning group"; expect(ecmFileConfigMock.getFileParticipant("write")).andReturn("assignee,owner").anyTimes(); expect(ecmFileConfigMock.getFileParticipant("read")).andReturn("follower,reader").anyTimes(); expect(ecmFileConfigMock.getFileParticipant("no-access")).andReturn("No Access").anyTimes(); expect(ecmFileConfigMock.getFileParticipant("group-write")).andReturn("owning group").anyTimes(); expect(ecmFileConfigMock.getFileParticipant("group-read")).andReturn("follower group").anyTimes(); expect(ecmFileConfigMock.getFileParticipant("*")).andReturn("*").anyTimes(); expect(ecmFileConfigMock.getFileParticipant("group-no-access")).andReturn("owning group").anyTimes(); AcmContainer acmContainer = new AcmContainer(); AcmFolder acmFolder = new AcmFolder(); acmFolder.setId(objectId); acmContainer.setFolder(acmFolder); List<AcmParticipant> assignedObjectParticipants = new ArrayList<>(); AcmParticipant participantAssign1 = new AcmParticipant(); participantAssign1.setParticipantLdapId(participantLdapId1); participantAssign1.setParticipantType(participantType1); participantAssign1.setReplaceChildrenParticipant(true); assignedObjectParticipants.add(participantAssign1); AcmParticipant participantAssign2 = new AcmParticipant(); participantAssign2.setParticipantLdapId(participantLdapId3); participantAssign2.setParticipantType(participantType3); participantAssign2.setReplaceChildrenParticipant(false); assignedObjectParticipants.add(participantAssign2); List<AcmParticipant> orignalObjectParticipants = new ArrayList<>(); AcmParticipant participantOrig1 = new AcmParticipant(); participantOrig1.setParticipantLdapId(participantLdapId2); participantOrig1.setParticipantType(participantType2); participantOrig1.setReplaceChildrenParticipant(false); orignalObjectParticipants.add(participantOrig1); AcmParticipant participantOrig2 = new AcmParticipant(); participantOrig2.setParticipantLdapId(participantLdapId3); participantOrig2.setParticipantType(participantType3); participantOrig2.setReplaceChildrenParticipant(false); orignalObjectParticipants.add(participantOrig1); EcmFile file = new EcmFile(); AcmParticipant childFolderParticipant = new AcmParticipant(); childFolderParticipant.setParticipantLdapId(participantLdapId); childFolderParticipant.setParticipantType(participantType); expect(mockFileDao.findByFolderId(acmFolder.getId(), FlushModeType.COMMIT)).andReturn(Arrays.asList(file)); expect(mockFileDao.save(file)).andReturn(file); EntityManager em = mock(EntityManager.class); expect(mockFolderDao.getEm()).andReturn(em).anyTimes(); expect(mockFolderDao.findSubFolders(objectId, FlushModeType.COMMIT)).andReturn(new ArrayList<>()); replayAll(); fileParticipantService.inheritParticipantsFromAssignedObject(assignedObjectParticipants, orignalObjectParticipants, acmContainer, false); verifyAll(); assertEquals(participantLdapId1, file.getParticipants().get(0).getParticipantLdapId()); }
@Transactional(rollbackFor = Exception.class) public void inheritParticipantsFromAssignedObject(List<AcmParticipant> assignedObjectParticipants, List<AcmParticipant> originalAssignedObjectParticipants, AcmContainer acmContainer, boolean restricted) { if (acmContainer == null) { log.warn("Null container passed in " + getClass().getName() + ".inheritParticipantsFromAssignedObject()"); return; } if (acmContainer.getFolder() != null) { inheritParticipantsFromAssignedObject(assignedObjectParticipants, originalAssignedObjectParticipants, acmContainer.getFolder(), restricted); } if (acmContainer.getAttachmentFolder() != null && (acmContainer.getFolder() == null || (acmContainer.getAttachmentFolder() != acmContainer.getFolder() && acmContainer.getAttachmentFolder().getId() != null && !acmContainer.getAttachmentFolder().getId().equals(acmContainer.getFolder().getId())))) { inheritParticipantsFromAssignedObject(assignedObjectParticipants, originalAssignedObjectParticipants, acmContainer.getAttachmentFolder(), restricted); } }
EcmFileParticipantService { @Transactional(rollbackFor = Exception.class) public void inheritParticipantsFromAssignedObject(List<AcmParticipant> assignedObjectParticipants, List<AcmParticipant> originalAssignedObjectParticipants, AcmContainer acmContainer, boolean restricted) { if (acmContainer == null) { log.warn("Null container passed in " + getClass().getName() + ".inheritParticipantsFromAssignedObject()"); return; } if (acmContainer.getFolder() != null) { inheritParticipantsFromAssignedObject(assignedObjectParticipants, originalAssignedObjectParticipants, acmContainer.getFolder(), restricted); } if (acmContainer.getAttachmentFolder() != null && (acmContainer.getFolder() == null || (acmContainer.getAttachmentFolder() != acmContainer.getFolder() && acmContainer.getAttachmentFolder().getId() != null && !acmContainer.getAttachmentFolder().getId().equals(acmContainer.getFolder().getId())))) { inheritParticipantsFromAssignedObject(assignedObjectParticipants, originalAssignedObjectParticipants, acmContainer.getAttachmentFolder(), restricted); } } }
EcmFileParticipantService { @Transactional(rollbackFor = Exception.class) public void inheritParticipantsFromAssignedObject(List<AcmParticipant> assignedObjectParticipants, List<AcmParticipant> originalAssignedObjectParticipants, AcmContainer acmContainer, boolean restricted) { if (acmContainer == null) { log.warn("Null container passed in " + getClass().getName() + ".inheritParticipantsFromAssignedObject()"); return; } if (acmContainer.getFolder() != null) { inheritParticipantsFromAssignedObject(assignedObjectParticipants, originalAssignedObjectParticipants, acmContainer.getFolder(), restricted); } if (acmContainer.getAttachmentFolder() != null && (acmContainer.getFolder() == null || (acmContainer.getAttachmentFolder() != acmContainer.getFolder() && acmContainer.getAttachmentFolder().getId() != null && !acmContainer.getAttachmentFolder().getId().equals(acmContainer.getFolder().getId())))) { inheritParticipantsFromAssignedObject(assignedObjectParticipants, originalAssignedObjectParticipants, acmContainer.getAttachmentFolder(), restricted); } }  }
EcmFileParticipantService { @Transactional(rollbackFor = Exception.class) public void inheritParticipantsFromAssignedObject(List<AcmParticipant> assignedObjectParticipants, List<AcmParticipant> originalAssignedObjectParticipants, AcmContainer acmContainer, boolean restricted) { if (acmContainer == null) { log.warn("Null container passed in " + getClass().getName() + ".inheritParticipantsFromAssignedObject()"); return; } if (acmContainer.getFolder() != null) { inheritParticipantsFromAssignedObject(assignedObjectParticipants, originalAssignedObjectParticipants, acmContainer.getFolder(), restricted); } if (acmContainer.getAttachmentFolder() != null && (acmContainer.getFolder() == null || (acmContainer.getAttachmentFolder() != acmContainer.getFolder() && acmContainer.getAttachmentFolder().getId() != null && !acmContainer.getAttachmentFolder().getId().equals(acmContainer.getFolder().getId())))) { inheritParticipantsFromAssignedObject(assignedObjectParticipants, originalAssignedObjectParticipants, acmContainer.getAttachmentFolder(), restricted); } }  @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 void inheritParticipantsFromAssignedObject(List<AcmParticipant> assignedObjectParticipants, List<AcmParticipant> originalAssignedObjectParticipants, AcmContainer acmContainer, boolean restricted) { if (acmContainer == null) { log.warn("Null container passed in " + getClass().getName() + ".inheritParticipantsFromAssignedObject()"); return; } if (acmContainer.getFolder() != null) { inheritParticipantsFromAssignedObject(assignedObjectParticipants, originalAssignedObjectParticipants, acmContainer.getFolder(), restricted); } if (acmContainer.getAttachmentFolder() != null && (acmContainer.getFolder() == null || (acmContainer.getAttachmentFolder() != acmContainer.getFolder() && acmContainer.getAttachmentFolder().getId() != null && !acmContainer.getAttachmentFolder().getId().equals(acmContainer.getFolder().getId())))) { inheritParticipantsFromAssignedObject(assignedObjectParticipants, originalAssignedObjectParticipants, acmContainer.getAttachmentFolder(), restricted); } }  @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);  }