JcrRepositoryFileUtils { static void checkNodeForTree( final Node childNode, List<RepositoryFileTree> children, final Session session, final PentahoJcrConstants pentahoJcrConstants, final IPathConversionHelper pathConversionHelper, final String childNodeFilter, final ILockHelper lockHelper, final int depth, final boolean showHidden, final IRepositoryAccessVoterManager accessVoterManager, RepositoryRequest.FILES_TYPE_FILTER types, MutableBoolean foundFiltered, boolean isRootFiltered, final boolean includeSystemFolders, final String rootPath ) throws RepositoryException { RepositoryFile file = nodeToFile( session, pentahoJcrConstants, pathConversionHelper, lockHelper, childNode ); if ( isSupportedNodeType( pentahoJcrConstants, childNode ) ) { RepositoryFileAcl fileAcl; try { fileAcl = JcrRepositoryFileAclUtils.getAcl( session, pentahoJcrConstants, file.getId() ); } catch ( AccessDeniedException e ) { return; } if ( accessVoterManager.hasAccess( file, RepositoryFilePermission.READ, fileAcl, PentahoSessionHolder.getSession() ) ) { MutableBoolean foundFilteredAtomic = new MutableBoolean( !isPentahoFolder( pentahoJcrConstants, childNode ) ); RepositoryFileTree repositoryFileTree = getTreeByNode( session, pentahoJcrConstants, pathConversionHelper, lockHelper, childNode, depth - 1, childNodeFilter, showHidden, accessVoterManager, types, foundFilteredAtomic, includeSystemFolders, rootPath ); if ( repositoryFileTree != null && ( foundFilteredAtomic.booleanValue() || isRootFiltered ) ) { foundFiltered.setValue( true ); children.add( repositoryFileTree ); } } } }  static RepositoryFile getFileById( final Session session, final PentahoJcrConstants pentahoJcrConstants,
      final IPathConversionHelper pathConversionHelper, final ILockHelper lockHelper, final Serializable fileId ); static RepositoryFile nodeToFile( final Session session, final PentahoJcrConstants pentahoJcrConstants,
      final IPathConversionHelper pathConversionHelper, final ILockHelper lockHelper, final Node node ); static RepositoryFile nodeToFileOld( final Session session, final PentahoJcrConstants pentahoJcrConstants,
      final IPathConversionHelper pathConversionHelper, final ILockHelper lockHelper, final Node node,
      final boolean loadMaps, IPentahoLocale pentahoLocale ); static RepositoryFile nodeToFile( final Session session, final PentahoJcrConstants pentahoJcrConstants,
      final IPathConversionHelper pathConversionHelper, final ILockHelper lockHelper, final Node node,
      final boolean loadMaps, IPentahoLocale pentahoLocale ); static String getLocalizedString( final Session session, final PentahoJcrConstants pentahoJcrConstants,
      final Node localizedStringNode, IPentahoLocale pentahoLocale ); static Map<String, Properties> getLocalePropertiesMap( final Session session,
      final PentahoJcrConstants pentahoJcrConstants, final Node localesNode ); static String getAbsolutePath( final Session session, final PentahoJcrConstants pentahoJcrConstants,
      final Node node ); static Serializable getNodeId( final Session session, final PentahoJcrConstants pentahoJcrConstants,
      final Node node ); static String getNodeName( final Session session, final PentahoJcrConstants pentahoJcrConstants,
      final Node node ); static String getVersionId( final Session session, final PentahoJcrConstants pentahoJcrConstants,
      final Node node ); static Node createFolderNode( final Session session, final PentahoJcrConstants pentahoJcrConstants,
      final Serializable parentFolderId, final RepositoryFile folder ); static Node createFileNode( final Session session, final PentahoJcrConstants pentahoJcrConstants,
      final Serializable parentFolderId, final RepositoryFile file, final IRepositoryFileData content,
      final ITransformer<IRepositoryFileData> transformer ); static Node updateFileNode( final Session session, final PentahoJcrConstants pentahoJcrConstants,
      final RepositoryFile file, final IRepositoryFileData content,
      final ITransformer<IRepositoryFileData> transformer ); static Node updateFolderNode( final Session session, final PentahoJcrConstants pentahoJcrConstants,
      final RepositoryFile folder ); static IRepositoryFileData getContent( final Session session, final PentahoJcrConstants pentahoJcrConstants,
      final Serializable fileId, final Serializable versionId, final ITransformer<IRepositoryFileData> transformer ); static List<RepositoryFile> getChildren( final Session session, final PentahoJcrConstants pentahoJcrConstants,
      final IPathConversionHelper pathConversionHelper, final ILockHelper lockHelper,
      final RepositoryRequest repositoryRequest ); @Deprecated static List<RepositoryFile> getChildren( final Session session, final PentahoJcrConstants pentahoJcrConstants,
      final IPathConversionHelper pathConversionHelper, final ILockHelper lockHelper, final Serializable folderId,
      final String filter ); @Deprecated static List<RepositoryFile> getChildren( final Session session, final PentahoJcrConstants pentahoJcrConstants,
      final IPathConversionHelper pathConversionHelper, final ILockHelper lockHelper, final Serializable folderId,
      final String filter, Boolean showHiddenFiles ); static boolean isPentahoFolder( final PentahoJcrConstants pentahoJcrConstants, final Node node ); static boolean isPentahoHierarchyNode( final Session session, final PentahoJcrConstants pentahoJcrConstants,
      final Node node ); static boolean isLocked( final PentahoJcrConstants pentahoJcrConstants, final Node node ); static boolean isPentahoFile( final PentahoJcrConstants pentahoJcrConstants, final Node node ); static boolean isVersioned( final Session session, final PentahoJcrConstants pentahoJcrConstants,
      final Node node ); static boolean isSupportedNodeType( final PentahoJcrConstants pentahoJcrConstants, final Node node ); static void checkoutNearestVersionableFileIfNecessary( final Session session,
      final PentahoJcrConstants pentahoJcrConstants, final Serializable fileId ); static void checkoutNearestVersionableNodeIfNecessary( final Session session,
      final PentahoJcrConstants pentahoJcrConstants, final Node node ); static void checkinNearestVersionableFileIfNecessary( final Session session,
      final PentahoJcrConstants pentahoJcrConstants, final Serializable fileId, final String versionMessage ); static void checkinNearestVersionableFileIfNecessary( final Session session,
      final PentahoJcrConstants pentahoJcrConstants, final Serializable fileId, final String versionMessage,
      final Date versionDate, final boolean aclOnlyChange ); static void checkinNearestVersionableNodeIfNecessary( final Session session,
      final PentahoJcrConstants pentahoJcrConstants, final Node node, final String versionMessage ); static void checkinNearestVersionableNodeIfNecessary( final Session session,
      final PentahoJcrConstants pentahoJcrConstants, final Node node, final String versionMessage, Date versionDate,
      final boolean aclOnlyChange ); static void deleteFile( final Session session, final PentahoJcrConstants pentahoJcrConstants,
      final Serializable fileId, final ILockHelper lockTokenHelper ); static RepositoryFile nodeIdToFile( final Session session, final PentahoJcrConstants pentahoJcrConstants,
      final IPathConversionHelper pathConversionHelper, final ILockHelper lockHelper, final Serializable fileId ); static Object getVersionSummaries( final Session session, final PentahoJcrConstants pentahoJcrConstants,
      final Serializable fileId, final boolean includeAclOnlyChanges ); static RepositoryFile getFileAtVersion( final Session session, final PentahoJcrConstants pentahoJcrConstants,
      final IPathConversionHelper pathConversionHelper, final ILockHelper lockHelper, final Serializable fileId,
      final Serializable versionId ); static String getFileContentType( final Session session, final PentahoJcrConstants pentahoJcrConstants,
      final Serializable fileId, final Serializable versionId ); static Serializable getParentId( final Session session, final Serializable fileId ); static Serializable getBaseVersionId( final Session session, final Serializable fileId ); static Object getVersionSummary( final Session session, final PentahoJcrConstants pentahoJcrConstants,
      final Serializable fileId, final Serializable versionId ); static RepositoryFileTree getTree( final Session session, final PentahoJcrConstants pentahoJcrConstants,
      final IPathConversionHelper pathConversionHelper, final ILockHelper lockHelper, final String absPath,
      final RepositoryRequest repositoryRequest, IRepositoryAccessVoterManager accessVoterManager ); static Node updateFileLocaleProperties( final Session session, final Serializable fileId, String locale,
      Properties properties ); static Node deleteFileLocaleProperties( final Session session, final Serializable fileId, String locale ); static void setFileMetadata( final Session session, final Serializable fileId,
      Map<String, Serializable> metadataMap ); static Map<String, Serializable> getFileMetadata( final Session session, final Serializable fileId ); static List<Character> getReservedChars(); static void checkName( final String name ); static RepositoryFile createFolder( final Session session,
      final CredentialsStrategySessionFactory sessionFactory, final RepositoryFile parentFolder,
      final RepositoryFile folder, final boolean inheritAces, final RepositoryFileSid ownerSid,
      final IPathConversionHelper pathConversionHelper, final String versionMessage ); static RepositoryFile getFileByAbsolutePath( final Session session, final String absPath,
      final IPathConversionHelper pathConversionHelper, final ILockHelper lockHelper, final boolean loadMaps,
      final IPentahoLocale locale ); static IRepositoryVersionManager getRepositoryVersionManager(); static void setRepositoryVersionManager( IRepositoryVersionManager repositoryVersionManager );  }
@Test public void testCheckNodeForTree() throws Exception { List<RepositoryFileTree> children = new ArrayList<>(); IPathConversionHelper pathConversionHelper = new DefaultPathConversionHelper(); ILockHelper lockHelperMock = mock( ILockHelper.class ); IRepositoryAccessVoterManager repositoryAccessVoterManagerMock = mock( IRepositoryAccessVoterManager.class ); MutableBoolean foundFiltered = new MutableBoolean(); RepositoryFile fileMock = mock( RepositoryFile.class ); when( fileMock.getId() ).thenReturn( 1 ); PowerMockito.mockStatic( JcrRepositoryFileUtils.class ); PowerMockito.mockStatic( JcrRepositoryFileAclUtils.class ); PowerMockito.doCallRealMethod().when( JcrRepositoryFileUtils.class, "checkNodeForTree", nodeMock, children, sessionMock, pJcrConstMock, pathConversionHelper, "childNodeFilter", lockHelperMock, 0, false, repositoryAccessVoterManagerMock, RepositoryRequest.FILES_TYPE_FILTER.FOLDERS, foundFiltered, true, false, "/" ); when( JcrRepositoryFileUtils.nodeToFile( sessionMock, pJcrConstMock, pathConversionHelper, lockHelperMock, nodeMock ) ).thenReturn( fileMock ); when( JcrRepositoryFileUtils.isSupportedNodeType( pJcrConstMock, nodeMock ) ).thenReturn( true ); when( JcrRepositoryFileAclUtils.getAcl( sessionMock, pJcrConstMock, 1 ) ).thenThrow( new AccessDeniedException() ); try { JcrRepositoryFileUtils.checkNodeForTree( nodeMock, children, sessionMock, pJcrConstMock, pathConversionHelper, "childNodeFilter", lockHelperMock, 0, false, repositoryAccessVoterManagerMock, RepositoryRequest.FILES_TYPE_FILTER.FOLDERS, foundFiltered, true, false, "/" ); } catch ( Exception e ) { fail(); } }