use of org.pentaho.platform.api.repository2.unified.RepositoryRequest in project pentaho-platform by pentaho.
the class UnifiedRepositoryTestUtils method stubGetChildren.
/**
* Stubs a {@code getChildren} call. {@code childrenNames} is zero or more file/folder names. A folder is
* indicated by a trailing forward slash.
*
* <p>
* Example:
* </p>
*
* <pre>
* stubGetChildren( repo, "/public", "hello/", "file1.txt" );
* </pre>
*/
public static void stubGetChildren(final IUnifiedRepository repo, RepositoryRequest request, final String... childrenNames) {
List<RepositoryFile> children = new ArrayList<RepositoryFile>(childrenNames.length);
for (String childName : childrenNames) {
if (childName.startsWith(RepositoryFile.SEPARATOR)) {
throw new IllegalArgumentException("child names must not begin with a forward slash");
}
final String fullChildPath = request.getPath() + RepositoryFile.SEPARATOR + (childName.endsWith(RepositoryFile.SEPARATOR) ? StringUtils.substringBefore(childName, RepositoryFile.SEPARATOR) : childName);
RepositoryFile child = null;
if (childName.endsWith(RepositoryFile.SEPARATOR)) {
child = makeFolderObject(fullChildPath, true);
} else {
child = makeFileObject(fullChildPath, true);
}
children.add(child);
}
doReturn(children).when(repo).getChildren(request);
}
use of org.pentaho.platform.api.repository2.unified.RepositoryRequest in project pentaho-metaverse by pentaho.
the class RepositoryLocator method startScan.
@Override
public void startScan() throws MetaverseLocatorException {
if (unifiedRepository == null) {
try {
unifiedRepository = getUnifiedRepository(session);
} catch (Exception e) {
throw new MetaverseLocatorException(Messages.getString("ERROR.RepositoryLocator.ScanAbortedNoRepo"), e);
}
}
RepositoryRequest request = new RepositoryRequest(ClientRepositoryPaths.getRootFolderPath(), true, -1, null);
RepositoryFileTree root = unifiedRepository.getTree(request);
List<RepositoryFileTree> children = root.getChildren();
LocatorRunner lr = new RepositoryLocatorRunner();
lr.setRoot(children);
startScan(lr);
}
use of org.pentaho.platform.api.repository2.unified.RepositoryRequest in project pentaho-metaverse by pentaho.
the class LocatorTestUtils method getMockIUnifiedRepository.
public static IUnifiedRepository getMockIUnifiedRepository() {
IUnifiedRepository repo = mock(IUnifiedRepository.class);
when(repo.getTree(any(RepositoryRequest.class))).thenAnswer(new Answer<RepositoryFileTree>() {
@Override
public RepositoryFileTree answer(InvocationOnMock invocationOnMock) throws Throwable {
Object[] args = invocationOnMock.getArguments();
return getTree((RepositoryRequest) args[0]);
}
});
return repo;
}
use of org.pentaho.platform.api.repository2.unified.RepositoryRequest in project pentaho-kettle by pentaho.
the class RepositoryBrowserController method populateFoldersLazy.
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);
}
}
use of org.pentaho.platform.api.repository2.unified.RepositoryRequest in project pentaho-kettle by pentaho.
the class RepositoryFileProvider method populateFoldersLazy.
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);
}
}
Aggregations