use of org.structr.core.app.App 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;
}
use of org.structr.core.app.App in project structr by structr.
the class StructrFilePath method createDirectory.
@Override
public void createDirectory(FileAttribute<?>... attrs) throws IOException {
final App app = StructrApp.getInstance(fs.getSecurityContext());
try (final Tx tx = app.tx()) {
final String name = getFileName().toString();
final Folder newFolder = app.create(Folder.class, new NodeAttribute<>(AbstractNode.name, name));
// set parent folder
setParentFolder(newFolder);
tx.success();
} catch (FrameworkException fex) {
logger.warn("Unable to delete file {}: {}", new Object[] { getActualFile().getPath(), fex.getMessage() });
}
}
use of org.structr.core.app.App 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;
}
use of org.structr.core.app.App 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;
}
use of org.structr.core.app.App 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;
}
Aggregations