Skip to content

Commit

Permalink
[PDI-15928] Get Repository Names step hangs when working with the Pen…
Browse files Browse the repository at this point in the history
…taho

Repository - fix missing subdirectory if path does not root
  • Loading branch information
Sergey Travin authored and Sergey Travin committed Mar 2, 2017
1 parent 424c3d6 commit b6ac0a3
Showing 1 changed file with 19 additions and 9 deletions.
Expand Up @@ -567,19 +567,29 @@ public RepositoryDirectoryInterface loadRepositoryDirectoryTree(
boolean includeEmptyFolder,
boolean includeAcls )
throws KettleException {
RepositoryFileTree repoTree = loadRepositoryFileTree( path, filter, depth, showHidden, includeAcls, FILES_TYPE_FILTER.FILES_FOLDERS );
RepositoryFile folder = repoTree.getFile();

//load count levels from root to destination path to load folder tree
int fromRootToDest = StringUtils.countMatches( path, "/" );
//create new root directory "/"
RepositoryDirectory dir = new RepositoryDirectory();
dir.setObjectId( new StringObjectId( folder.getId().toString() ) );
loadRepositoryDirectory( dir, folder, repoTree );
//fetch folder tree from root "/" to destination path for populate folder
RepositoryFileTree rootDirTree = loadRepositoryFileTree( "/", "*", fromRootToDest, showHidden, includeAcls, FILES_TYPE_FILTER.FOLDERS );
//populate directory by folder tree
fillRepositoryDirectoryFromTree( dir, rootDirTree );

RepositoryDirectoryInterface destinationDir = dir.findDirectory( path );
//search for goal path and filter
RepositoryFileTree repoTree = loadRepositoryFileTree( path, filter, depth, showHidden, includeAcls, FILES_TYPE_FILTER.FILES_FOLDERS );
//populate the directory with founded files and subdirectories with files
fillRepositoryDirectoryFromTree( destinationDir, repoTree );

if ( includeEmptyFolder ) {
RepositoryDirectoryInterface folders =
initRepositoryDirectoryTree(
loadRepositoryFileTree( path, null, depth, showHidden, includeAcls, FILES_TYPE_FILTER.FOLDERS ) );
return copyFrom( folders, dir );
return copyFrom( folders, destinationDir );
} else {
return dir;
return destinationDir;
}
}

Expand Down Expand Up @@ -651,7 +661,7 @@ private RepositoryDirectoryInterface initRepositoryDirectoryTree( RepositoryFile
RepositoryFile rootFolder = repoTree.getFile();
RepositoryDirectory rootDir = new RepositoryDirectory();
rootDir.setObjectId( new StringObjectId( rootFolder.getId().toString() ) );
loadRepositoryDirectory( rootDir, rootFolder, repoTree );
fillRepositoryDirectoryFromTree( rootDir, repoTree );

// Example: /etc
RepositoryDirectory etcDir = rootDir.findDirectory( ClientRepositoryPaths.getEtcFolderPath() );
Expand All @@ -672,7 +682,7 @@ private RepositoryDirectoryInterface initRepositoryDirectoryTree( RepositoryFile
return newRoot;
}

private void loadRepositoryDirectory( final RepositoryDirectoryInterface parentDir, final RepositoryFile folder,
private void fillRepositoryDirectoryFromTree( final RepositoryDirectoryInterface parentDir,
final RepositoryFileTree treeNode ) throws KettleException {
try {
List<RepositoryElementMetaInterface> fileChildren = new ArrayList<RepositoryElementMetaInterface>();
Expand All @@ -683,7 +693,7 @@ private void loadRepositoryDirectory( final RepositoryDirectoryInterface parentD
RepositoryDirectory dir = new RepositoryDirectory( parentDir, child.getFile().getName() );
dir.setObjectId( new StringObjectId( child.getFile().getId().toString() ) );
parentDir.addSubdirectory( dir );
loadRepositoryDirectory( dir, child.getFile(), child );
fillRepositoryDirectoryFromTree( dir, child );
} else {
// a real file, like a Transformation or Job
RepositoryLock lock = unifiedRepositoryLockService.getLock( child.getFile() );
Expand Down

0 comments on commit b6ac0a3

Please sign in to comment.