Examples of AclFileAttributeView


Examples of java.nio.file.attribute.AclFileAttributeView

              else
                throw new CloudsyncException(msg + "\n  try to run with '--permissions try'");
            }
            break;
          case Item.ATTRIBUTE_ACL:
            AclFileAttributeView aclView = Files.getFileAttributeView(path, AclFileAttributeView.class, LinkOption.NOFOLLOW_LINKS);
            if (aclView != null) {
              List<AclEntry> acls = aclView.getAcl();
              for (int i = 0; i < values.length; i = i + 4) {

                Builder aclEntryBuilder = AclEntry.newBuilder();

                aclEntryBuilder.setType(AclEntryType.valueOf(values[i]));
                aclEntryBuilder.setPrincipal(lookupService.lookupPrincipalByName(values[i + 1]));

                Set<AclEntryFlag> flags = new HashSet<AclEntryFlag>();
                for (String flag : StringUtils.splitPreserveAllTokens(values[i + 2], ",")) {
                  flags.add(AclEntryFlag.valueOf(flag));
                }
                if (flags.size() > 0)
                  aclEntryBuilder.setFlags(flags);

                Set<AclEntryPermission> aclPermissions = new HashSet<AclEntryPermission>();
                for (String flag : StringUtils.splitPreserveAllTokens(values[i + 3], ",")) {
                  aclPermissions.add(AclEntryPermission.valueOf(flag));
                }
                if (aclPermissions.size() > 0)
                  aclEntryBuilder.setPermissions(aclPermissions);
                acls.add(aclEntryBuilder.build());
              }
              aclView.setAcl(acls);
            } else {
              String msg = "Can't restore 'acl' permissions on '" + item.getPath() + "'. They are not supported.";
              if (permissionType.equals(PermissionType.TRY))
                LOGGER.log(Level.WARNING, msg);
              else
View Full Code Here

Examples of java.nio.file.attribute.AclFileAttributeView

        }
      }

      if (!type.equals(ItemType.LINK)) {

        AclFileAttributeView aclView = Files.getFileAttributeView(path, AclFileAttributeView.class, LinkOption.NOFOLLOW_LINKS);
        if (aclView != null) {
          if (!attributes.containsKey(Item.ATTRIBUTE_POSIX))
            attributes.put(Item.ATTRIBUTE_OWNER, new String[] { aclView.getOwner().getName() });

          AclFileAttributeView parentAclView = Files.getFileAttributeView(path.getParent(), AclFileAttributeView.class, LinkOption.NOFOLLOW_LINKS);

          List<AclEntry> aclList = getLocalAclEntries(type, parentAclView.getAcl(), aclView.getAcl());
          if (aclList.size() > 0) {
            List<String> aclData = new ArrayList<String>();
            for (AclEntry acl : aclList) {
              List<String> flags = new ArrayList<String>();
              for (AclEntryFlag flag : acl.flags()) {
View Full Code Here

Examples of java.nio.file.attribute.AclFileAttributeView

    assertSetFails("acl", ImmutableList.of("hello"));
  }

  @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());
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.