use of org.pentaho.platform.api.repository2.unified.RepositoryFileTree in project pentaho-kettle by pentaho.
the class PurRepository method loadRepositoryDirectoryTree.
@Deprecated
@Override
public RepositoryDirectoryInterface loadRepositoryDirectoryTree(boolean eager) throws KettleException {
// this method forces a reload of the repository directory tree structure
// a new rootRef will be obtained - this is a SoftReference which will be used
// by any calls to getRootDir()
RepositoryDirectoryInterface rootDir;
if (eager) {
RepositoryFileTree rootFileTree = loadRepositoryFileTree(ClientRepositoryPaths.getRootFolderPath());
rootDir = initRepositoryDirectoryTree(rootFileTree);
} else {
RepositoryFile root = pur.getFile("/");
rootDir = new LazyUnifiedRepositoryDirectory(root, null, pur, purRepositoryServiceRegistry);
}
rootRef.setRef(rootDir);
return rootDir;
}
use of org.pentaho.platform.api.repository2.unified.RepositoryFileTree in project pentaho-kettle by pentaho.
the class PurRepository method fillRepositoryDirectoryFromTree.
private void fillRepositoryDirectoryFromTree(final RepositoryDirectoryInterface parentDir, final RepositoryFileTree treeNode) throws KettleException {
try {
List<RepositoryElementMetaInterface> fileChildren = new ArrayList<RepositoryElementMetaInterface>();
List<RepositoryFileTree> children = treeNode.getChildren();
if (children != null) {
for (RepositoryFileTree child : children) {
if (child.getFile().isFolder()) {
RepositoryDirectory dir = new RepositoryDirectory(parentDir, child.getFile().getName());
dir.setObjectId(new StringObjectId(child.getFile().getId().toString()));
parentDir.addSubdirectory(dir);
fillRepositoryDirectoryFromTree(dir, child);
} else {
// a real file, like a Transformation or Job
RepositoryLock lock = unifiedRepositoryLockService.getLock(child.getFile());
RepositoryObjectType objectType = getObjectType(child.getFile().getName());
fileChildren.add(new EERepositoryObject(child, parentDir, null, objectType, null, lock, false));
}
}
parentDir.setRepositoryObjects(fileChildren);
}
} catch (Exception e) {
throw new KettleException("Unable to load directory structure from repository", e);
}
}
use of org.pentaho.platform.api.repository2.unified.RepositoryFileTree in project pentaho-metaverse by pentaho.
the class LocatorTestUtils method createFileTree.
private static RepositoryFileTree createFileTree(File root) {
RepositoryFile repFile = new RepositoryFile(root.getPath(), root.getName(), root.isDirectory(), false, false, null, root.getAbsolutePath(), new Date(root.lastModified()), new Date(root.lastModified()), false, null, null, null, null, root.getName(), null, null, null, root.length(), "Admin", null);
List<RepositoryFileTree> children = new ArrayList<RepositoryFileTree>();
File[] files = root.listFiles();
for (File file : files) {
if (file.isHidden()) {
continue;
}
if (file.isDirectory()) {
RepositoryFileTree kid = createFileTree(file);
children.add(kid);
} else if (file.isFile()) {
RepositoryFile kid = new RepositoryFile(file.getPath(), file.getName(), file.isDirectory(), false, false, null, file.getPath(), new Date(file.lastModified()), new Date(file.lastModified()), false, null, null, null, null, file.getName(), null, null, null, root.length(), "Admin", null);
RepositoryFileTree kidTree = new RepositoryFileTree(kid, null);
children.add(kidTree);
}
}
RepositoryFileTree fileTree = new RepositoryFileTree(repFile, children);
return fileTree;
}
use of org.pentaho.platform.api.repository2.unified.RepositoryFileTree in project pentaho-metaverse by pentaho.
the class LocatorTestUtils method getTree.
/**
* ************ end -- load job and trans methods for the mock diRepo ****************
*/
public static RepositoryFileTree getTree(RepositoryRequest req) {
File root = new File(SOLUTION_PATH);
RepositoryFileTree rft = createFileTree(root);
return rft;
}
use of org.pentaho.platform.api.repository2.unified.RepositoryFileTree in project pentaho-platform by pentaho.
the class JcrRepositoryFileUtilsTest method testCheckNodeForTree.
@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();
}
}
Aggregations