protected RepositoryFileTree loadRepositoryFileTree( String path ) { readWriteLock.readLock().lock(); RepositoryFileTree result; try { result = pur.getTree( path, -1, null, true ); } finally { readWriteLock.readLock().unlock(); } return result; }
private RepositoryFileTree loadRepositoryFileTreeFolders( String path, int depth, boolean includeAcls, boolean showHidden ) { RepositoryRequest repoRequest = new RepositoryRequest(); repoRequest.setDepth( depth ); repoRequest.setIncludeAcls( includeAcls ); repoRequest.setChildNodeFilter( "*" ); repoRequest.setTypes( FILES_TYPE_FILTER.FOLDERS ); repoRequest.setPath( path ); repoRequest.setShowHidden( showHidden ); readWriteLock.readLock().lock(); RepositoryFileTree result; try { result = pur.getTree( repoRequest ); } finally { readWriteLock.readLock().unlock(); } return result; } }
private RepositoryFileTree loadRepositoryFileTree( String path, String filter, int depth, boolean showHidden, boolean includeAcls, FILES_TYPE_FILTER types ) { RepositoryRequest repoRequest = new RepositoryRequest(); repoRequest.setPath( Utils.isEmpty( path ) ? "/" : path ); repoRequest.setChildNodeFilter( filter == null ? "*" : filter ); repoRequest.setDepth( depth ); repoRequest.setShowHidden( showHidden ); repoRequest.setIncludeAcls( includeAcls ); repoRequest.setTypes( types == null ? FILES_TYPE_FILTER.FILES_FOLDERS : types ); readWriteLock.readLock().lock(); RepositoryFileTree fileTree; try { fileTree = pur.getTree( repoRequest ); } finally { readWriteLock.readLock().unlock(); } return fileTree; }
@Override public List<RepositoryElementMetaInterface> getRepositoryObjects( ) { if ( fileChildren == null ) { fileChildren = new ArrayList<>(); synchronized ( fileChildren ) { UnifiedRepositoryLockService lockService = (UnifiedRepositoryLockService) registry.getService( ILockService.class ); RepositoryFileTree tree = repository.getTree( new RepositoryRequest( this.self.getPath(), showHidden, 1, null ) ); for ( RepositoryFileTree tchild : tree.getChildren() ) { RepositoryFile child = tchild.getFile(); if ( !child.isFolder() ) { RepositoryLock lock = null; try { lock = lockService.getLock( child ); RepositoryObjectType objectType = PurRepository.getObjectType( child.getName() ); EERepositoryObject repositoryObject = new EERepositoryObject( child, this, null, objectType, null, lock, false ); repositoryObject.setVersioningEnabled( tchild.getVersioningEnabled() ); repositoryObject.setVersionCommentEnabled( tchild.getVersionCommentEnabled() ); fileChildren.add( repositoryObject ); } catch ( KettleException e ) { logger.error( "Error converting Unified Repository file to PDI RepositoryObject: " + child.getPath() + ". File will be skipped", e ); } } } } } return fileChildren; }
public void populateFoldersLazy( RepositoryDirectory repositoryDirectory ) { RepositoryRequest repositoryRequest = new RepositoryRequest( repositoryDirectory.getPath(), true, 1, null ); repositoryRequest.setTypes( RepositoryRequest.FILES_TYPE_FILTER.FOLDERS ); repositoryRequest.setIncludeSystemFolders( false ); RepositoryFileTree tree = getRepository().getUnderlyingRepository().getTree( repositoryRequest ); for ( RepositoryFileTree repositoryFileTree : tree.getChildren() ) { org.pentaho.platform.api.repository2.unified.RepositoryFile repositoryFile = repositoryFileTree.getFile(); RepositoryDirectory repositoryDirectory1 = RepositoryDirectory.build( repositoryDirectory.getPath(), repositoryFile, isAdmin() ); repositoryDirectory.addChild( repositoryDirectory1 ); } }
public void populateFilesLazy( RepositoryDirectory repositoryDirectory, String filter ) { RepositoryRequest repositoryRequest = new RepositoryRequest(); repositoryRequest.setPath( repositoryDirectory.getPath() ); repositoryRequest.setDepth( 1 ); repositoryRequest.setShowHidden( true ); repositoryRequest.setTypes( RepositoryRequest.FILES_TYPE_FILTER.FILES ); repositoryRequest.setChildNodeFilter( filter ); RepositoryFileTree tree = getRepository().getUnderlyingRepository().getTree( repositoryRequest ); for ( RepositoryFileTree repositoryFileTree : tree.getChildren() ) { org.pentaho.platform.api.repository2.unified.RepositoryFile repositoryFile = repositoryFileTree.getFile(); RepositoryFile repositoryFile1 = RepositoryFile.build( repositoryDirectory.getPath(), repositoryFile, isAdmin() ); repositoryDirectory.addChild( repositoryFile1 ); } }
public RepositoryFileTree call() throws Exception { return delegatee.getTree( repositoryRequest ); } }, Messages.getInstance().getString( "ExceptionLoggingDecorator.getTree", repositoryRequest.getPath() ) ); //$NON-NLS-1$
/** * Gets a tree rooted at path. * * @param path * path to file * @param depth * 0 fetches just file at path; positive integer n fetches node at path plus n levels of children; * negative integer fetches all children * @param filter * filter may be a full name or a partial name with one or more wildcard characters ("*"), or a * disjunction (using the "|" character to represent logical OR) of these; filter does not apply to root * node * @param showHidden * is a boolean which identify whether to include the hidden files/folders in the list or not * @return file or {@code null} if the file does not exist or access is denied */ @Override public RepositoryFileTree getTree( final String path, final int depth, final String filter, final boolean showHidden ) { return repository.getTree( path, depth, filter, showHidden ); }
public RepositoryFileTreeDto getTreeFromRequest( final RepositoryRequest repositoryRequest ) { // RepositoryFileTree tree = repo.getTree( path, depth, filter, showHidden ); IAuthorizationPolicy policy = PentahoSystem.get( IAuthorizationPolicy.class ); boolean isAdmin = policy.isAllowed( AdministerSecurityAction.NAME ); // Filter system folders from non-admin users. // PDI uses this web-service and system folders must be returned to admin repository database connections. if ( !isAdmin ) { repositoryRequest.setIncludeSystemFolders( false ); //Non Admin users can never get system folders getLogger().warn( "User does not have administrator privileges; setting includeSystemFolders to false." ); } RepositoryFileTree tree = repo.getTree( repositoryRequest ); if ( tree != null ) { return new RepositoryFileTreeAdapter( repositoryRequest ).marshal( tree ); } else { return null; } }
/** * Stubs a {@code getTree} call. {@code rootPath} is the root of the tree to return. {@code paths} is zero or * more paths, relative to {@code rootPath} (i.e. they must not begin with a forward slash). Intermediate folders * are created automatically. To specify an empty folder, end the path with a forward slash. * * <p> * Example: * </p> * * <pre> * stubGetTree( repo, "/public", "relUrlTest.url", "hello/file.txt", * "hello/file2.txt", "hello2/" ); * </pre> */ public static void stubGetTree( final IUnifiedRepository repo, final String rootPath, final String... paths ) { RepositoryFileTree.Builder root = new RepositoryFileTree.Builder( makeFolderObject( rootPath, true ) ); for ( String path : paths ) { if ( path.startsWith( RepositoryFile.SEPARATOR ) ) { throw new IllegalArgumentException( "all paths must be relative" ); } String[] pathSegments = path.split( RepositoryFile.SEPARATOR ); boolean leafIsFolder = path.endsWith( RepositoryFile.SEPARATOR ); addChild( root, leafIsFolder, pathSegments, 0 ); } doReturn( root.build() ).when( repo ).getTree( eq( rootPath ), anyInt(), anyString(), anyBoolean() ); }