Example #1
0
  // ----- private methods -----
  private void listFolder(final StructrShellCommand parent, final List<AbstractFile> folder)
      throws FrameworkException, IOException {

    for (final AbstractFile child : folder) {

      if (parent.isAllowed(child, Permission.read, false)) {

        if (child instanceof Folder) {

          term.setBold(true);
          term.setTextColor(4);
          term.print(child.getName() + "  ");
          term.setTextColor(7);
          term.setBold(false);

        } else {

          term.print(child.getName() + "  ");
        }
      }
    }

    if (!folder.isEmpty()) {
      term.println();
    }
  }
Example #2
0
  @Override
  public void execute(final StructrShellCommand parent) throws IOException {

    final App app = StructrApp.getInstance();

    try (final Tx tx = app.tx()) {

      final Folder currentFolder = parent.getCurrentFolder();
      if (currentFolder != null) {

        listFolder(parent, currentFolder.getProperty(AbstractFile.children));

      } else {

        listFolder(
            parent, app.nodeQuery(AbstractFile.class).and(AbstractFile.parent, null).getAsList());
      }

      tx.success();

    } catch (FrameworkException fex) {

      logger.warn("", fex);
    }
  }