use of java.nio.file.attribute.AclFileAttributeView in project neo4j by neo4j.
the class BootloaderCommandTestBase method addConf.
protected void addConf(Setting<?> setting, String value) {
try {
if (!Files.exists(confFile)) {
Files.createDirectories(confFile.getParent());
if (IS_OS_WINDOWS) {
Files.createFile(confFile);
AclFileAttributeView attrs = Files.getFileAttributeView(confFile, AclFileAttributeView.class);
attrs.setAcl(List.of(AclEntry.newBuilder().setType(AclEntryType.ALLOW).setPrincipal(attrs.getOwner()).setPermissions(AclEntryPermission.READ_DATA, AclEntryPermission.WRITE_DATA, AclEntryPermission.READ_ATTRIBUTES, AclEntryPermission.WRITE_ATTRIBUTES, AclEntryPermission.READ_NAMED_ATTRS, AclEntryPermission.WRITE_NAMED_ATTRS, AclEntryPermission.APPEND_DATA, AclEntryPermission.READ_ACL, AclEntryPermission.SYNCHRONIZE).build()));
} else {
Files.createFile(confFile, PosixFilePermissions.asFileAttribute(Set.of(OWNER_READ, OWNER_WRITE)));
}
}
FileUtils.writeToFile(confFile, String.format("%s=%s%n", setting.name(), value), true);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
use of java.nio.file.attribute.AclFileAttributeView in project jimfs by google.
the class AclAttributeProviderTest method testView.
@Test
public void testView() throws IOException {
AclFileAttributeView view = provider.view(fileLookup(), ImmutableMap.<String, FileAttributeView>of("owner", new OwnerAttributeProvider().view(fileLookup(), NO_INHERITED_VIEWS)));
assertNotNull(view);
assertThat(view.name()).isEqualTo("acl");
assertThat(view.getAcl()).isEqualTo(defaultAcl);
view.setAcl(ImmutableList.<AclEntry>of());
view.setOwner(FOO);
assertThat(view.getAcl()).isEqualTo(ImmutableList.<AclEntry>of());
assertThat(view.getOwner()).isEqualTo(FOO);
assertThat(file.getAttribute("acl", "acl")).isEqualTo(ImmutableList.<AclEntry>of());
}
Aggregations