Package java.nio.file.attribute

Examples of java.nio.file.attribute.FileOwnerAttributeView


     * @see java.nio.file.attribute.UserPrincipalLookupService
     */
    public static Path setOwner(Path path, UserPrincipal owner)
        throws IOException
    {
        FileOwnerAttributeView view =
            getFileAttributeView(path, FileOwnerAttributeView.class);
        if (view == null)
            throw new UnsupportedOperationException();
        view.setOwner(owner);
        return path;
    }
View Full Code Here


              else
                throw new CloudsyncException(msg + "\n  try to run with '--permissions try'");
            }
            break;
          case Item.ATTRIBUTE_OWNER:
            FileOwnerAttributeView ownerView = Files.getFileAttributeView(path, FileOwnerAttributeView.class, LinkOption.NOFOLLOW_LINKS);
            if (ownerView != null) {
              principal = lookupService.lookupPrincipalByName(values[0]);
              ownerView.setOwner(principal);
            } else {
              String msg = "Can't restore 'owner' permissions on '" + item.getPath() + "'. They are not supported.";
              if (permissionType.equals(PermissionType.TRY))
                LOGGER.log(Level.WARNING, msg);
              else
View Full Code Here

            arr = aclData.toArray(arr);
            attributes.put(Item.ATTRIBUTE_ACL, arr);
          }
        } else if (!attributes.containsKey(Item.ATTRIBUTE_POSIX)) {

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

      return Item.fromLocalData(file.getName(), type, filesize, creationTime, modifyTime, accessTime, attributes);
View Full Code Here

    assertSetFails("owner", "root");
  }

  @Test
  public void testView() throws IOException {
    FileOwnerAttributeView view = provider.view(fileLookup(), NO_INHERITED_VIEWS);
    assertThat(view).isNotNull();

    assertThat(view.name()).isEqualTo("owner");
    assertThat(view.getOwner()).isEqualTo(createUserPrincipal("user"));

    view.setOwner(createUserPrincipal("root"));
    assertThat(view.getOwner()).isEqualTo(createUserPrincipal("root"));
    assertThat(file.getAttribute("owner", "owner")).isEqualTo(createUserPrincipal("root"));
  }
View Full Code Here

TOP

Related Classes of java.nio.file.attribute.FileOwnerAttributeView

Copyright © 2018 www.massapicom. 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.