use of org.kie.workbench.common.screens.explorer.model.FolderListing in project kie-wb-common by kiegroup.
the class ExplorerServiceHelper method getFolderListing.
public FolderListing getFolderListing(final Path path, final ActiveOptions options) {
// Get list of files and folders contained in the path
final List<FolderItem> folderItems = new ArrayList<FolderItem>();
final boolean includeTags = options.contains(Option.SHOW_TAG_FILTER);
// Scan upwards until the path exists (as the current path could have been deleted)
org.uberfire.java.nio.file.Path nioPath = Paths.convert(path);
while (!Files.exists(nioPath)) {
nioPath = nioPath.getParent();
}
final Path basePath = Paths.convert(nioPath);
final DirectoryStream<org.uberfire.java.nio.file.Path> nioPaths = ioService.newDirectoryStream(nioPath, dotFileFilter);
for (org.uberfire.java.nio.file.Path np : nioPaths) {
if (Files.isRegularFile(np)) {
final org.uberfire.backend.vfs.Path p = Paths.convert(np);
final String lockedBy = Paths.readLockedBy(p);
final FolderItem folderItem = new FolderItem(p, p.getFileName(), FolderItemType.FILE, false, lockedBy, includeTags ? metadataService.getTags(p) : Collections.<String>emptyList(), getRestrictedOperations(p));
folderItems.add(folderItem);
} else if (Files.isDirectory(np)) {
final org.uberfire.backend.vfs.Path p = Paths.convert(np);
boolean lockedItems = !lockService.retrieveLockInfos(Paths.convert(np), true).isEmpty();
final FolderItem folderItem = new FolderItem(p, p.getFileName(), FolderItemType.FOLDER, lockedItems, null, Collections.<String>emptyList(), getRestrictedOperations(p));
folderItems.add(folderItem);
}
}
Collections.sort(folderItems, Sorters.ITEM_SORTER);
return new FolderListing(toFolderItem(nioPath), folderItems, getPathSegments(basePath));
}
use of org.kie.workbench.common.screens.explorer.model.FolderListing in project kie-wb-common by kiegroup.
the class ExplorerServiceImpl method getFolderListing.
@Override
public FolderListing getFolderListing(final WorkspaceProject project, final Module module, final FolderItem item, final ActiveOptions options) {
// TODO: BUSINESS_CONTENT, TECHNICAL_CONTENT
final FolderListing result = helper.getFolderListing(item, options);
if (result != null) {
final org.uberfire.java.nio.file.Path userNavPath = userServices.buildPath("explorer", "user.nav");
final org.uberfire.java.nio.file.Path lastUserNavPath = userServices.buildPath("explorer", "last.user.nav");
this.executorService.execute(new DescriptiveRunnable() {
@Override
public String getDescription() {
return "Serialize Navigation State";
}
@Override
public void run() {
try {
Package pkg = null;
if (item.getItem() instanceof Package) {
pkg = (Package) item.getItem();
}
helper.store(userNavPath, lastUserNavPath, project, module, pkg, item, options);
} catch (final Exception e) {
LOGGER.error("Can't serialize user's state navigation", e);
}
}
});
}
return result;
}
Aggregations