Search in sources :

Example 1 with StructrPath

use of org.structr.files.ssh.filesystem.StructrPath in project structr by structr.

the class StructrSchemaMethodsPath method getDirectoryStream.

@Override
public DirectoryStream<Path> getDirectoryStream(final DirectoryStream.Filter<? super Path> filter) {
    if (schemaNode != null) {
        return new DirectoryStream() {

            boolean closed = false;

            @Override
            public Iterator iterator() {
                final App app = StructrApp.getInstance(fs.getSecurityContext());
                final List<StructrPath> nodes = new LinkedList<>();
                try (final Tx tx = app.tx()) {
                    for (final SchemaMethod schemaMethod : schemaNode.getProperty(SchemaNode.schemaMethods)) {
                        // schema methods have a virtual file name so that external editors don't get confused
                        String name = schemaMethod.getProperty(SchemaMethod.virtualFileName);
                        if (name == null) {
                            // no virtual file name set, use real name
                            name = schemaMethod.getName();
                        }
                        nodes.add(new StructrSchemaMethodPath(fs, StructrSchemaMethodsPath.this, schemaNode, name));
                    }
                    tx.success();
                } catch (FrameworkException fex) {
                    logger.warn("", fex);
                }
                return nodes.iterator();
            }

            @Override
            public void close() throws IOException {
                closed = true;
            }
        };
    }
    return null;
}
Also used : StructrApp(org.structr.core.app.StructrApp) App(org.structr.core.app.App) Tx(org.structr.core.graph.Tx) SchemaMethod(org.structr.core.entity.SchemaMethod) FrameworkException(org.structr.common.error.FrameworkException) StructrPath(org.structr.files.ssh.filesystem.StructrPath) DirectoryStream(java.nio.file.DirectoryStream) LinkedList(java.util.LinkedList)

Example 2 with StructrPath

use of org.structr.files.ssh.filesystem.StructrPath in project structr by structr.

the class StructrSchemaNodePath method getDirectoryStream.

@Override
public DirectoryStream<Path> getDirectoryStream(DirectoryStream.Filter<? super Path> filter) {
    final AbstractSchemaNode schemaNode = getSchemaNode();
    if (schemaNode != null) {
        return new DirectoryStream() {

            boolean closed = false;

            @Override
            public Iterator iterator() {
                if (!closed) {
                    final List<StructrPath> children = new LinkedList<>();
                    // children.add(new StructrSchemaPropertiesPath(fs, StructrSchemaNodePath.this, schemaNode));
                    // children.add(new StructrSchemaViewsPath(fs, StructrSchemaNodePath.this, schemaNode));
                    children.add(new StructrSchemaMethodsPath(fs, StructrSchemaNodePath.this, schemaNode));
                    children.add(resolveStructrPath("extendsClass"));
                    return children.iterator();
                }
                return Collections.emptyIterator();
            }

            @Override
            public void close() throws IOException {
                closed = true;
            }
        };
    }
    return null;
}
Also used : StructrPath(org.structr.files.ssh.filesystem.StructrPath) AbstractSchemaNode(org.structr.core.entity.AbstractSchemaNode) DirectoryStream(java.nio.file.DirectoryStream) LinkedList(java.util.LinkedList)

Example 3 with StructrPath

use of org.structr.files.ssh.filesystem.StructrPath in project structr by structr.

the class StructrFilePath method getDirectoryStream.

@Override
public DirectoryStream<Path> getDirectoryStream(DirectoryStream.Filter<? super Path> filter) {
    final Folder folder = (Folder) getActualFile();
    if (folder != null) {
        return new DirectoryStream() {

            boolean closed = false;

            @Override
            public Iterator iterator() {
                if (!closed) {
                    final App app = StructrApp.getInstance(fs.getSecurityContext());
                    final List<StructrPath> files = new LinkedList<>();
                    try (final Tx tx = app.tx()) {
                        for (final Folder folder : folder.getFolders()) {
                            files.add(new StructrFilePath(fs, StructrFilePath.this, folder.getName()));
                        }
                        for (final File file : folder.getFiles()) {
                            files.add(new StructrFilePath(fs, StructrFilePath.this, file.getName()));
                        }
                        tx.success();
                    } catch (FrameworkException fex) {
                        logger.warn("", fex);
                    }
                    return files.iterator();
                }
                return Collections.emptyIterator();
            }

            @Override
            public void close() throws IOException {
                closed = true;
            }
        };
    }
    return null;
}
Also used : StructrApp(org.structr.core.app.StructrApp) App(org.structr.core.app.App) Tx(org.structr.core.graph.Tx) FrameworkException(org.structr.common.error.FrameworkException) StructrPath(org.structr.files.ssh.filesystem.StructrPath) DirectoryStream(java.nio.file.DirectoryStream) Folder(org.structr.web.entity.Folder) AbstractFile(org.structr.web.entity.AbstractFile) File(org.structr.web.entity.File) LinkedList(java.util.LinkedList)

Example 4 with StructrPath

use of org.structr.files.ssh.filesystem.StructrPath in project structr by structr.

the class StructrSchemaPropertiesPath method getDirectoryStream.

@Override
public DirectoryStream<Path> getDirectoryStream(DirectoryStream.Filter<? super Path> filter) {
    if (schemaNode != null) {
        return new DirectoryStream() {

            boolean closed = false;

            @Override
            public Iterator iterator() {
                final App app = StructrApp.getInstance(fs.getSecurityContext());
                final List<StructrPath> nodes = new LinkedList<>();
                try (final Tx tx = app.tx()) {
                    for (final SchemaProperty schemaProperty : schemaNode.getProperty(SchemaNode.schemaProperties)) {
                        nodes.add(new StructrSchemaPropertyPath(fs, StructrSchemaPropertiesPath.this, schemaNode, schemaProperty));
                    }
                    tx.success();
                } catch (FrameworkException fex) {
                    logger.warn("", fex);
                }
                return nodes.iterator();
            }

            @Override
            public void close() throws IOException {
                closed = true;
            }
        };
    }
    return null;
}
Also used : StructrApp(org.structr.core.app.StructrApp) App(org.structr.core.app.App) SchemaProperty(org.structr.core.entity.SchemaProperty) Tx(org.structr.core.graph.Tx) FrameworkException(org.structr.common.error.FrameworkException) StructrPath(org.structr.files.ssh.filesystem.StructrPath) DirectoryStream(java.nio.file.DirectoryStream) LinkedList(java.util.LinkedList)

Example 5 with StructrPath

use of org.structr.files.ssh.filesystem.StructrPath in project structr by structr.

the class StructrSchemaPropertiesPath method resolveStructrPath.

@Override
public StructrPath resolveStructrPath(final String pathComponent) {
    final App app = StructrApp.getInstance(fs.getSecurityContext());
    StructrPath path = null;
    try (final Tx tx = app.tx()) {
        for (final SchemaProperty schemaProperty : schemaNode.getProperty(SchemaNode.schemaProperties)) {
            if (pathComponent.equals(schemaProperty.getName())) {
                path = new StructrSchemaPropertyPath(fs, StructrSchemaPropertiesPath.this, schemaNode, schemaProperty);
            }
        }
        tx.success();
    } catch (FrameworkException fex) {
        logger.warn("", fex);
    }
    return path;
}
Also used : StructrApp(org.structr.core.app.StructrApp) App(org.structr.core.app.App) SchemaProperty(org.structr.core.entity.SchemaProperty) Tx(org.structr.core.graph.Tx) FrameworkException(org.structr.common.error.FrameworkException) StructrPath(org.structr.files.ssh.filesystem.StructrPath)

Aggregations

StructrPath (org.structr.files.ssh.filesystem.StructrPath)10 FrameworkException (org.structr.common.error.FrameworkException)9 App (org.structr.core.app.App)9 StructrApp (org.structr.core.app.StructrApp)9 Tx (org.structr.core.graph.Tx)9 DirectoryStream (java.nio.file.DirectoryStream)8 LinkedList (java.util.LinkedList)8 SchemaProperty (org.structr.core.entity.SchemaProperty)2 SchemaView (org.structr.core.entity.SchemaView)2 AbstractFile (org.structr.web.entity.AbstractFile)2 File (org.structr.web.entity.File)2 Folder (org.structr.web.entity.Folder)2 AbstractSchemaNode (org.structr.core.entity.AbstractSchemaNode)1 SchemaMethod (org.structr.core.entity.SchemaMethod)1 SchemaNode (org.structr.core.entity.SchemaNode)1 SchemaRelationshipNode (org.structr.core.entity.SchemaRelationshipNode)1