/** * Returns all children of the listingPath for a source */ private List<CatalogItem> getChildrenForSourcePath(String sourceName, List<String> listingPath) { final List<CatalogItem> catalogItems = new ArrayList<>(); final StoragePlugin plugin = getStoragePlugin(sourceName); if (plugin instanceof FileSystemPlugin) { // For file based plugins, use the list method to get the listing. That code will merge in any promoted datasets // that are in the namespace for us. This is in line with what the UI does. final List<SchemaEntity> list = ((FileSystemPlugin) plugin).list(listingPath, context.getUserPrincipal().getName()); for (SchemaEntity entity : list) { final CatalogItem catalogItem = convertSchemaEntityToCatalogItem(entity, listingPath); if (catalogItem != null) { catalogItems.add(catalogItem); } } } else { // for non-file based plugins we can go directly to the namespace catalogItems.addAll(getNamespaceChildrenForPath(new NamespaceKey(listingPath))); } return catalogItems; }
public NamespaceTree listSource(SourceName sourceName, SourceConfig sourceConfig, String userName) throws IOException, PhysicalDatasetNotFoundException, NamespaceException { try { final StoragePlugin plugin = checkNotNull(catalogService.getSource(sourceName.getName()), "storage plugin %s not found", sourceName); if (plugin instanceof FileSystemPlugin) { final NamespaceTree ns = new NamespaceTree(); addToNamespaceTree(ns, ((FileSystemPlugin) plugin).list(singletonList(sourceName.getName()), userName), sourceName, sourceName.getName()); fillInTags(ns); return ns; } else { return newNamespaceTree(namespaceService.list(new NamespaceKey(singletonList(sourceConfig.getName())))); } } catch (IOException | DatasetNotFoundException e) { throw new RuntimeException(e); } }
public NamespaceTree listFolder(SourceName sourceName, SourceFolderPath folderPath, String userName) throws IOException, PhysicalDatasetNotFoundException, NamespaceException { final String name = sourceName.getName(); final String prefix = folderPath.toPathString(); try { final StoragePlugin plugin = checkNotNull(catalogService.getSource(name), "storage plugin %s not found", sourceName); if (plugin instanceof FileSystemPlugin) { final NamespaceTree ns = new NamespaceTree(); addToNamespaceTree(ns, ((FileSystemPlugin) plugin).list(folderPath.toPathList(), userName), sourceName, prefix); fillInTags(ns); return ns; } else { return newNamespaceTree(namespaceService.list(folderPath.toNamespaceKey())); } } catch (IOException | DatasetNotFoundException e) { throw new RuntimeException(e); } }
SchemaEntity schemaEntityFolder2 = new SchemaEntity(com.dremio.common.utils.PathUtils.constructFullPath(folderConfig2.getFullPathList()), SchemaEntity.SchemaEntityType.FOLDER, "testuser"); when(storagePlugin.list(eq(Arrays.asList(sourceConfig.getName())), any(String.class))).thenReturn(Arrays.asList(schemaEntityFolder1, schemaEntityFolder2));