@Test public void testFindFolderChildren() { AcmFolder folderToDelete = new AcmFolder(); folderToDelete.setId(1L); AcmFolder subFolder1 = new AcmFolder(); subFolder1.setId(11L); AcmFolder subFolder2 = new AcmFolder(); subFolder2.setId(12L); AcmFolder subFolder3 = new AcmFolder(); subFolder3.setId(21L); EcmFile subFile1 = new EcmFile(); subFile1.setFolder(folderToDelete); subFile1.setFileId(111L); EcmFile subFile2 = new EcmFile(); subFile2.setFileId(112L); subFile2.setFolder(subFolder1); EcmFile subFile3 = new EcmFile(); subFile3.setFileId(113L); subFile3.setFolder(subFolder3); subFolder1.setChildrenFolders(new ArrayList<>()); subFolder2.setChildrenFolders(Collections.singletonList(subFolder3)); subFolder3.setChildrenFolders(new ArrayList<>()); folderToDelete.setChildrenFolders(Arrays.asList(subFolder1, subFolder2)); Set<AcmFolder> childFolders = new HashSet<>(); Set<EcmFile> childFiles = new HashSet<>(); expect(fileDaoMock.findByFolderId(folderToDelete.getId())).andReturn(Collections.singletonList(subFile1)); expect(fileDaoMock.findByFolderId(subFolder1.getId())).andReturn(Collections.singletonList(subFile2)); expect(fileDaoMock.findByFolderId(subFolder3.getId())).andReturn(Collections.singletonList(subFile3)); expect(fileDaoMock.findByFolderId(subFolder2.getId())).andReturn(new ArrayList<>()); replayAll(); unit.findFolderChildren(folderToDelete, childFiles, childFolders); verifyAll(); Assert.assertTrue(childFolders.contains(subFolder1)); Assert.assertTrue(childFolders.contains(subFolder2)); Assert.assertTrue(childFolders.contains(subFolder3)); Assert.assertFalse(childFolders.contains(folderToDelete)); Assert.assertTrue(childFiles.contains(subFile1)); Assert.assertTrue(childFiles.contains(subFile2)); Assert.assertTrue(childFiles.contains(subFile3)); }
void findFolderChildren(AcmFolder folder, Set<EcmFile> childFiles, Set<AcmFolder> childFolders) { if (folder == null) { return; } childFiles.addAll(fileDao.findByFolderId(folder.getId())); for (AcmFolder childFolder : folder.getChildrenFolders()) { childFolders.add(childFolder); findFolderChildren(childFolder, childFiles, childFolders); } }
AcmFolderServiceImpl implements AcmFolderService, ApplicationEventPublisherAware { void findFolderChildren(AcmFolder folder, Set<EcmFile> childFiles, Set<AcmFolder> childFolders) { if (folder == null) { return; } childFiles.addAll(fileDao.findByFolderId(folder.getId())); for (AcmFolder childFolder : folder.getChildrenFolders()) { childFolders.add(childFolder); findFolderChildren(childFolder, childFiles, childFolders); } } }
AcmFolderServiceImpl implements AcmFolderService, ApplicationEventPublisherAware { void findFolderChildren(AcmFolder folder, Set<EcmFile> childFiles, Set<AcmFolder> childFolders) { if (folder == null) { return; } childFiles.addAll(fileDao.findByFolderId(folder.getId())); for (AcmFolder childFolder : folder.getChildrenFolders()) { childFolders.add(childFolder); findFolderChildren(childFolder, childFiles, childFolders); } }  }
AcmFolderServiceImpl implements AcmFolderService, ApplicationEventPublisherAware { void findFolderChildren(AcmFolder folder, Set<EcmFile> childFiles, Set<AcmFolder> childFolders) { if (folder == null) { return; } childFiles.addAll(fileDao.findByFolderId(folder.getId())); for (AcmFolder childFolder : folder.getChildrenFolders()) { childFolders.add(childFolder); findFolderChildren(childFolder, childFiles, childFolders); } }  @Override @AcmAcquireAndReleaseObjectLock(objectIdArgIndex = 0, objectType = "FOLDER", lockType = "WRITE", lockChildObjects = false, unlockChildObjects = false) AcmFolder addNewFolder(Long parentFolderId, String newFolderName); @Override @AcmAcquireAndReleaseObjectLock(objectIdArgIndex = 0, objectType = "FOLDER", lockType = "WRITE", lockChildObjects = false, unlockChildObjects = false) AcmFolder addNewFolder(Long parentFolderId, String newFolderName, Long parentId, String parentType); @Override @AcmAcquireAndReleaseObjectLock(acmObjectArgIndex = 0, objectType = "FOLDER", lockType = "WRITE", lockChildObjects = false, unlockChildObjects = false) AcmFolder addNewFolder(AcmFolder parentFolder, String newFolderName); @Override AcmFolder addNewFolderByPath(String targetObjectType, Long targetObjectId, String newPath); @Override String findFolderPath(String cmisFolderObjectId); @Override @AcmAcquireAndReleaseObjectLock(objectIdArgIndex = 0, objectType = "FOLDER", lockType = "DELETE") AcmFolder renameFolder(Long folderId, String newFolderName); @Override @AcmAcquireAndReleaseObjectLock(objectIdArgIndex = 0, objectType = "FOLDER", lockType = "READ", lockChildObjects = false, unlockChildObjects = false) List<AcmObject> getFolderChildren(Long folderId); @Override @AcmAcquireAndReleaseObjectLock(acmObjectArgIndex = 0, objectType = "FOLDER", lockType = "DELETE") @AcmAcquireAndReleaseObjectLock(acmObjectArgIndex = 1, objectType = "FOLDER", lockType = "WRITE", lockChildObjects = false, unlockChildObjects = false) AcmFolder moveFolder(AcmFolder folderForMoving, AcmFolder dstFolder); @Override AcmFolder moveFolderInArkcase(AcmFolder folderForMoving, AcmFolder dstFolder); @Override @AcmAcquireAndReleaseObjectLock(acmObjectArgIndex = 0, objectType = "FOLDER", lockType = "DELETE") @AcmAcquireAndReleaseObjectLock(acmObjectArgIndex = 1, objectType = "FOLDER", lockType = "WRITE", lockChildObjects = false, unlockChildObjects = false) AcmFolder moveRootFolder(AcmFolder folderForMoving, AcmFolder dstFolder); @Override @AcmAcquireAndReleaseObjectLock(objectIdArgIndex = 0, objectType = "FOLDER", lockType = "READ") @AcmAcquireAndReleaseObjectLock(objectIdArgIndex = 1, objectType = "FOLDER", lockType = "WRITE", lockChildObjects = false, unlockChildObjects = false) AcmFolder copyFolder(Long folderToBeCopiedId, Long copyDstFolderId, Long targetObjectId, String targetObjectType); @Override @AcmAcquireAndReleaseObjectLock(acmObjectArgIndex = 0, objectType = "FOLDER", lockType = "READ") @AcmAcquireAndReleaseObjectLock(acmObjectArgIndex = 1, objectType = "FOLDER", lockType = "WRITE", lockChildObjects = false, unlockChildObjects = false) AcmFolder copyFolder(AcmFolder toBeCopied, AcmFolder dstFolder, Long targetObjectId, String targetObjectType); @Override @AcmAcquireAndReleaseObjectLock(objectIdArgIndex = 0, objectType = "FOLDER", lockType = "DELETE", lockChildObjects = false, unlockChildObjects = false) void deleteFolderIfEmpty(Long folderId); @Override @Transactional(rollbackFor = Exception.class) @AcmAcquireAndReleaseObjectLock(objectIdArgIndex = 0, objectType = "FOLDER", lockType = "DELETE") void deleteFolderTreeSafe(Long folderId, Authentication authentication); @Override @Transactional(rollbackFor = Exception.class) @AcmAcquireAndReleaseObjectLock(objectIdArgIndex = 0, objectType = "FOLDER", lockType = "DELETE") void deleteFolderTree(Long folderId, Authentication authentication); void deleteAlfrescoFolderTree(AcmFolder folder); @Override @Transactional @AcmAcquireAndReleaseObjectLock(acmObjectArgIndex = 0, objectType = "CONTAINER", lockType = "DELETE") void deleteContainerSafe(AcmContainer container, Authentication authentication); @Override @Transactional(rollbackFor = Exception.class) @AcmAcquireAndReleaseObjectLock(objectIdArgIndex = 0, objectType = "CONTAINER", lockType = "DELETE") void deleteContainer(Long containerId, Authentication authentication); @Override @Transactional(rollbackFor = Exception.class) @AcmAcquireAndReleaseObjectLock(acmObjectArgIndex = 0, objectType = "CONTAINER", lockType = "DELETE") void deleteContainerAndContent(AcmContainer container, String user); @Override void deleteFolderContent(AcmFolder folder, String user); @Override String getCmisRepositoryId(AcmFolder folder); @Override DeleteFolderInfo getFolderToDeleteInfo(Long folderId); @Override void recordMetadataOfExistingFolderChildren(AcmFolder parentFolder, String userId); @Override AcmFolder createFolder(AcmFolder targetParentFolder, String cmisFolderId, String folderName); @Override AcmFolder findById(Long folderId); @Override AcmFolder findByNameAndParent(String name, AcmFolder parent); @Override @AcmAcquireAndReleaseObjectLock(acmObjectArgIndex = 0, objectType = "CONTAINER", lockType = "WRITE", lockChildObjects = false, unlockChildObjects = false) void addFolderStructure(AcmContainer container, AcmFolder parentFolder, JSONArray folderStructure); @Override String getFolderPath(AcmFolder folder); @Override boolean folderPathExists(String folderPath, AcmContainer container); @Override @AcmAcquireAndReleaseObjectLock(objectIdArgIndex = 0, objectType = "FOLDER", lockType = "READ") @AcmAcquireAndReleaseObjectLock(acmObjectArgIndex = 2, objectType = "FOLDER", lockType = "WRITE", lockChildObjects = false, unlockChildObjects = false) void copyFolderStructure(Long folderId, AcmContainer containerOfCopy, AcmFolder rootFolderOfCopy); @Override @AcmAcquireAndReleaseObjectLock(objectIdArgIndex = 0, objectType = "FILE", lockType = "READ") @AcmAcquireAndReleaseObjectLock(acmObjectArgIndex = 2, objectType = "FOLDER", lockType = "WRITE", lockChildObjects = false, unlockChildObjects = false) void copyDocumentStructure(Long documentId, AcmContainer containerOfCopy, AcmFolder rootFolderOfCopy); @Override AcmContainer findContainerByFolderId(Long folderId); @Override AcmContainer findContainerByFolderIdTransactionIndependent(Long folderId); @Override List<AcmFolder> findModifiedSince(Date lastModified, int start, int pageSize); @Override AcmFolder getRootFolder(Long parentObjectId, String parentObjectType); @Override @Transactional void removeLockAndSendMessage(Long objectId, String message); @Override AcmFolder saveFolder(AcmFolder folder); EcmFileDao getFileDao(); void setFileDao(EcmFileDao fileDao); ApplicationEventPublisher getApplicationEventPublisher(); @Override void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher); AcmFolderDao getFolderDao(); void setFolderDao(AcmFolderDao folderDao); AcmContainerDao getContainerDao(); void setContainerDao(AcmContainerDao containerDao); MuleContextManager getMuleContextManager(); void setMuleContextManager(MuleContextManager muleContextManager); EcmFileService getFileService(); void setFileService(EcmFileService fileService); FolderAndFilesUtils getFolderAndFilesUtils(); void setFolderAndFilesUtils(FolderAndFilesUtils folderAndFilesUtils); CmisConfigUtils getCmisConfigUtils(); void setCmisConfigUtils(CmisConfigUtils cmisConfigUtils); EcmFileParticipantService getFileParticipantService(); void setFileParticipantService(EcmFileParticipantService fileParticipantService); EcmFileConfig getEcmFileConfig(); void setEcmFileConfig(EcmFileConfig ecmFileConfig); MessageChannel getGenericMessagesChannel(); void setGenericMessagesChannel(MessageChannel genericMessagesChannel); AcmObjectLockService getObjectLockService(); void setObjectLockService(AcmObjectLockService objectLockService); }
AcmFolderServiceImpl implements AcmFolderService, ApplicationEventPublisherAware { void findFolderChildren(AcmFolder folder, Set<EcmFile> childFiles, Set<AcmFolder> childFolders) { if (folder == null) { return; } childFiles.addAll(fileDao.findByFolderId(folder.getId())); for (AcmFolder childFolder : folder.getChildrenFolders()) { childFolders.add(childFolder); findFolderChildren(childFolder, childFiles, childFolders); } }  @Override @AcmAcquireAndReleaseObjectLock(objectIdArgIndex = 0, objectType = "FOLDER", lockType = "WRITE", lockChildObjects = false, unlockChildObjects = false) AcmFolder addNewFolder(Long parentFolderId, String newFolderName); @Override @AcmAcquireAndReleaseObjectLock(objectIdArgIndex = 0, objectType = "FOLDER", lockType = "WRITE", lockChildObjects = false, unlockChildObjects = false) AcmFolder addNewFolder(Long parentFolderId, String newFolderName, Long parentId, String parentType); @Override @AcmAcquireAndReleaseObjectLock(acmObjectArgIndex = 0, objectType = "FOLDER", lockType = "WRITE", lockChildObjects = false, unlockChildObjects = false) AcmFolder addNewFolder(AcmFolder parentFolder, String newFolderName); @Override AcmFolder addNewFolderByPath(String targetObjectType, Long targetObjectId, String newPath); @Override String findFolderPath(String cmisFolderObjectId); @Override @AcmAcquireAndReleaseObjectLock(objectIdArgIndex = 0, objectType = "FOLDER", lockType = "DELETE") AcmFolder renameFolder(Long folderId, String newFolderName); @Override @AcmAcquireAndReleaseObjectLock(objectIdArgIndex = 0, objectType = "FOLDER", lockType = "READ", lockChildObjects = false, unlockChildObjects = false) List<AcmObject> getFolderChildren(Long folderId); @Override @AcmAcquireAndReleaseObjectLock(acmObjectArgIndex = 0, objectType = "FOLDER", lockType = "DELETE") @AcmAcquireAndReleaseObjectLock(acmObjectArgIndex = 1, objectType = "FOLDER", lockType = "WRITE", lockChildObjects = false, unlockChildObjects = false) AcmFolder moveFolder(AcmFolder folderForMoving, AcmFolder dstFolder); @Override AcmFolder moveFolderInArkcase(AcmFolder folderForMoving, AcmFolder dstFolder); @Override @AcmAcquireAndReleaseObjectLock(acmObjectArgIndex = 0, objectType = "FOLDER", lockType = "DELETE") @AcmAcquireAndReleaseObjectLock(acmObjectArgIndex = 1, objectType = "FOLDER", lockType = "WRITE", lockChildObjects = false, unlockChildObjects = false) AcmFolder moveRootFolder(AcmFolder folderForMoving, AcmFolder dstFolder); @Override @AcmAcquireAndReleaseObjectLock(objectIdArgIndex = 0, objectType = "FOLDER", lockType = "READ") @AcmAcquireAndReleaseObjectLock(objectIdArgIndex = 1, objectType = "FOLDER", lockType = "WRITE", lockChildObjects = false, unlockChildObjects = false) AcmFolder copyFolder(Long folderToBeCopiedId, Long copyDstFolderId, Long targetObjectId, String targetObjectType); @Override @AcmAcquireAndReleaseObjectLock(acmObjectArgIndex = 0, objectType = "FOLDER", lockType = "READ") @AcmAcquireAndReleaseObjectLock(acmObjectArgIndex = 1, objectType = "FOLDER", lockType = "WRITE", lockChildObjects = false, unlockChildObjects = false) AcmFolder copyFolder(AcmFolder toBeCopied, AcmFolder dstFolder, Long targetObjectId, String targetObjectType); @Override @AcmAcquireAndReleaseObjectLock(objectIdArgIndex = 0, objectType = "FOLDER", lockType = "DELETE", lockChildObjects = false, unlockChildObjects = false) void deleteFolderIfEmpty(Long folderId); @Override @Transactional(rollbackFor = Exception.class) @AcmAcquireAndReleaseObjectLock(objectIdArgIndex = 0, objectType = "FOLDER", lockType = "DELETE") void deleteFolderTreeSafe(Long folderId, Authentication authentication); @Override @Transactional(rollbackFor = Exception.class) @AcmAcquireAndReleaseObjectLock(objectIdArgIndex = 0, objectType = "FOLDER", lockType = "DELETE") void deleteFolderTree(Long folderId, Authentication authentication); void deleteAlfrescoFolderTree(AcmFolder folder); @Override @Transactional @AcmAcquireAndReleaseObjectLock(acmObjectArgIndex = 0, objectType = "CONTAINER", lockType = "DELETE") void deleteContainerSafe(AcmContainer container, Authentication authentication); @Override @Transactional(rollbackFor = Exception.class) @AcmAcquireAndReleaseObjectLock(objectIdArgIndex = 0, objectType = "CONTAINER", lockType = "DELETE") void deleteContainer(Long containerId, Authentication authentication); @Override @Transactional(rollbackFor = Exception.class) @AcmAcquireAndReleaseObjectLock(acmObjectArgIndex = 0, objectType = "CONTAINER", lockType = "DELETE") void deleteContainerAndContent(AcmContainer container, String user); @Override void deleteFolderContent(AcmFolder folder, String user); @Override String getCmisRepositoryId(AcmFolder folder); @Override DeleteFolderInfo getFolderToDeleteInfo(Long folderId); @Override void recordMetadataOfExistingFolderChildren(AcmFolder parentFolder, String userId); @Override AcmFolder createFolder(AcmFolder targetParentFolder, String cmisFolderId, String folderName); @Override AcmFolder findById(Long folderId); @Override AcmFolder findByNameAndParent(String name, AcmFolder parent); @Override @AcmAcquireAndReleaseObjectLock(acmObjectArgIndex = 0, objectType = "CONTAINER", lockType = "WRITE", lockChildObjects = false, unlockChildObjects = false) void addFolderStructure(AcmContainer container, AcmFolder parentFolder, JSONArray folderStructure); @Override String getFolderPath(AcmFolder folder); @Override boolean folderPathExists(String folderPath, AcmContainer container); @Override @AcmAcquireAndReleaseObjectLock(objectIdArgIndex = 0, objectType = "FOLDER", lockType = "READ") @AcmAcquireAndReleaseObjectLock(acmObjectArgIndex = 2, objectType = "FOLDER", lockType = "WRITE", lockChildObjects = false, unlockChildObjects = false) void copyFolderStructure(Long folderId, AcmContainer containerOfCopy, AcmFolder rootFolderOfCopy); @Override @AcmAcquireAndReleaseObjectLock(objectIdArgIndex = 0, objectType = "FILE", lockType = "READ") @AcmAcquireAndReleaseObjectLock(acmObjectArgIndex = 2, objectType = "FOLDER", lockType = "WRITE", lockChildObjects = false, unlockChildObjects = false) void copyDocumentStructure(Long documentId, AcmContainer containerOfCopy, AcmFolder rootFolderOfCopy); @Override AcmContainer findContainerByFolderId(Long folderId); @Override AcmContainer findContainerByFolderIdTransactionIndependent(Long folderId); @Override List<AcmFolder> findModifiedSince(Date lastModified, int start, int pageSize); @Override AcmFolder getRootFolder(Long parentObjectId, String parentObjectType); @Override @Transactional void removeLockAndSendMessage(Long objectId, String message); @Override AcmFolder saveFolder(AcmFolder folder); EcmFileDao getFileDao(); void setFileDao(EcmFileDao fileDao); ApplicationEventPublisher getApplicationEventPublisher(); @Override void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher); AcmFolderDao getFolderDao(); void setFolderDao(AcmFolderDao folderDao); AcmContainerDao getContainerDao(); void setContainerDao(AcmContainerDao containerDao); MuleContextManager getMuleContextManager(); void setMuleContextManager(MuleContextManager muleContextManager); EcmFileService getFileService(); void setFileService(EcmFileService fileService); FolderAndFilesUtils getFolderAndFilesUtils(); void setFolderAndFilesUtils(FolderAndFilesUtils folderAndFilesUtils); CmisConfigUtils getCmisConfigUtils(); void setCmisConfigUtils(CmisConfigUtils cmisConfigUtils); EcmFileParticipantService getFileParticipantService(); void setFileParticipantService(EcmFileParticipantService fileParticipantService); EcmFileConfig getEcmFileConfig(); void setEcmFileConfig(EcmFileConfig ecmFileConfig); MessageChannel getGenericMessagesChannel(); void setGenericMessagesChannel(MessageChannel genericMessagesChannel); AcmObjectLockService getObjectLockService(); void setObjectLockService(AcmObjectLockService objectLockService);  }