Search in sources :

Example 6 with StructrPath

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

the class StructrSchemaPropertyPath method getDirectoryStream.

@Override
public DirectoryStream<Path> getDirectoryStream(DirectoryStream.Filter<? super Path> filter) {
    if (schemaProperty != 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()) {
                    // add configuration "files" for this schema property
                    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) FrameworkException(org.structr.common.error.FrameworkException) StructrPath(org.structr.files.ssh.filesystem.StructrPath) DirectoryStream(java.nio.file.DirectoryStream) LinkedList(java.util.LinkedList)

Example 7 with StructrPath

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

the class StructrSchemaViewsPath 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 SchemaView schemaView : schemaNode.getProperty(SchemaNode.schemaViews)) {
            if (pathComponent.equals(schemaView.getName())) {
                path = new StructrSchemaViewPath(fs, StructrSchemaViewsPath.this, schemaNode, schemaView);
            }
        }
        tx.success();
    } catch (FrameworkException fex) {
        logger.warn("", fex);
    }
    return path;
}
Also used : StructrApp(org.structr.core.app.StructrApp) App(org.structr.core.app.App) SchemaView(org.structr.core.entity.SchemaView) Tx(org.structr.core.graph.Tx) FrameworkException(org.structr.common.error.FrameworkException) StructrPath(org.structr.files.ssh.filesystem.StructrPath)

Example 8 with StructrPath

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

the class StructrFilesPath method getDirectoryStream.

@Override
public DirectoryStream<Path> getDirectoryStream(final DirectoryStream.Filter<? super Path> filter) {
    return new DirectoryStream() {

        boolean closed = false;

        @Override
        public Iterator iterator() {
            if (!closed) {
                final App app = StructrApp.getInstance(fs.getSecurityContext());
                final PropertyKey<Boolean> hasParentKey = StructrApp.key(AbstractFile.class, "hasParent");
                final List<StructrPath> files = new LinkedList<>();
                try (final Tx tx = app.tx()) {
                    for (final Folder folder : app.nodeQuery(Folder.class).and(hasParentKey, false).getAsList()) {
                        files.add(new StructrFilePath(fs, StructrFilesPath.this, folder.getName()));
                    }
                    for (final File file : app.nodeQuery(File.class).and(hasParentKey, false).getAsList()) {
                        files.add(new StructrFilePath(fs, StructrFilesPath.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;
        }
    };
}
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 9 with StructrPath

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

the class StructrSchemaPath method getDirectoryStream.

@Override
public DirectoryStream<Path> getDirectoryStream(final DirectoryStream.Filter<? super Path> filter) {
    return new DirectoryStream() {

        boolean closed = false;

        @Override
        public Iterator iterator() {
            if (!closed) {
                final App app = StructrApp.getInstance(fs.getSecurityContext());
                final List<StructrPath> nodes = new LinkedList<>();
                try (final Tx tx = app.tx()) {
                    for (final SchemaNode schemaNode : app.nodeQuery(SchemaNode.class).getAsList()) {
                        nodes.add(new StructrSchemaNodePath(fs, StructrSchemaPath.this, schemaNode.getName()));
                    }
                    for (final SchemaRelationshipNode rel : app.nodeQuery(SchemaRelationshipNode.class).getAsList()) {
                        nodes.add(new StructrSchemaNodePath(fs, StructrSchemaPath.this, rel.getName()));
                    }
                    tx.success();
                } catch (FrameworkException fex) {
                    logger.warn("", fex);
                }
                return nodes.iterator();
            }
            return Collections.emptyIterator();
        }

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

Example 10 with StructrPath

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

the class StructrSchemaViewsPath 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 SchemaView schemaView : schemaNode.getProperty(SchemaNode.schemaViews)) {
                        nodes.add(new StructrSchemaViewPath(fs, StructrSchemaViewsPath.this, schemaNode, schemaView));
                    }
                    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) SchemaView(org.structr.core.entity.SchemaView) 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)

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