@Test public void testSet() { assertSetAndGetSucceeds("group", createGroupPrincipal("foo")); assertSetAndGetSucceeds("permissions", PosixFilePermissions.fromString("rwxrwxrwx")); assertSetFails("permissions", ImmutableList.of(PosixFilePermission.GROUP_EXECUTE)); assertSetFails("permissions", ImmutableSet.of("foo")); }
@Override public void set(File file, String view, String attribute, Object value, boolean create) { switch (attribute) { case "group": checkNotCreate(view, attribute, create); GroupPrincipal group = checkType(view, attribute, value, GroupPrincipal.class); if (!(group instanceof UserLookupService.JimfsGroupPrincipal)) { group = createGroupPrincipal(group.getName()); } file.setAttribute("posix", "group", group); break; case "permissions": file.setAttribute( "posix", "permissions", toPermissions(checkType(view, attribute, value, Set.class))); break; default: } }
PosixAttributeProvider extends AttributeProvider { @Override public void set(File file, String view, String attribute, Object value, boolean create) { switch (attribute) { case "group": checkNotCreate(view, attribute, create); GroupPrincipal group = checkType(view, attribute, value, GroupPrincipal.class); if (!(group instanceof UserLookupService.JimfsGroupPrincipal)) { group = createGroupPrincipal(group.getName()); } file.setAttribute("posix", "group", group); break; case "permissions": file.setAttribute( "posix", "permissions", toPermissions(checkType(view, attribute, value, Set.class))); break; default: } } }
PosixAttributeProvider extends AttributeProvider { @Override public void set(File file, String view, String attribute, Object value, boolean create) { switch (attribute) { case "group": checkNotCreate(view, attribute, create); GroupPrincipal group = checkType(view, attribute, value, GroupPrincipal.class); if (!(group instanceof UserLookupService.JimfsGroupPrincipal)) { group = createGroupPrincipal(group.getName()); } file.setAttribute("posix", "group", group); break; case "permissions": file.setAttribute( "posix", "permissions", toPermissions(checkType(view, attribute, value, Set.class))); break; default: } }  }
PosixAttributeProvider extends AttributeProvider { @Override public void set(File file, String view, String attribute, Object value, boolean create) { switch (attribute) { case "group": checkNotCreate(view, attribute, create); GroupPrincipal group = checkType(view, attribute, value, GroupPrincipal.class); if (!(group instanceof UserLookupService.JimfsGroupPrincipal)) { group = createGroupPrincipal(group.getName()); } file.setAttribute("posix", "group", group); break; case "permissions": file.setAttribute( "posix", "permissions", toPermissions(checkType(view, attribute, value, Set.class))); break; default: } }  @Override String name(); @Override ImmutableSet<String> inherits(); @Override ImmutableSet<String> fixedAttributes(); @SuppressWarnings("unchecked") @Override ImmutableMap<String, ?> defaultValues(Map<String, ?> userProvidedDefaults); @NullableDecl @Override Object get(File file, String attribute); @Override void set(File file, String view, String attribute, Object value, boolean create); @Override Class<PosixFileAttributeView> viewType(); @Override PosixFileAttributeView view(
      FileLookup lookup, ImmutableMap<String, FileAttributeView> inheritedViews); @Override Class<PosixFileAttributes> attributesType(); @Override PosixFileAttributes readAttributes(File file); }
PosixAttributeProvider extends AttributeProvider { @Override public void set(File file, String view, String attribute, Object value, boolean create) { switch (attribute) { case "group": checkNotCreate(view, attribute, create); GroupPrincipal group = checkType(view, attribute, value, GroupPrincipal.class); if (!(group instanceof UserLookupService.JimfsGroupPrincipal)) { group = createGroupPrincipal(group.getName()); } file.setAttribute("posix", "group", group); break; case "permissions": file.setAttribute( "posix", "permissions", toPermissions(checkType(view, attribute, value, Set.class))); break; default: } }  @Override String name(); @Override ImmutableSet<String> inherits(); @Override ImmutableSet<String> fixedAttributes(); @SuppressWarnings("unchecked") @Override ImmutableMap<String, ?> defaultValues(Map<String, ?> userProvidedDefaults); @NullableDecl @Override Object get(File file, String attribute); @Override void set(File file, String view, String attribute, Object value, boolean create); @Override Class<PosixFileAttributeView> viewType(); @Override PosixFileAttributeView view(
      FileLookup lookup, ImmutableMap<String, FileAttributeView> inheritedViews); @Override Class<PosixFileAttributes> attributesType(); @Override PosixFileAttributes readAttributes(File file);  }