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;
}
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;
}
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;
}
};
}
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;
}
};
}
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;
}
Aggregations