46 this.view = view; 47 this.isPosixView = true; 48 } 49 50 FileOwnerAttributeViewImpl(AclFileAttributeView view) { 51 this.view = view; 52 this.isPosixView = false; 53 } 54 55 @Override 56 public String name() { 57 return "owner"; 58 } 59 60 @Override 61 public void setAttribute(String attribute, Object value) 62 throws IOException 63 { 64 if (attribute.equals(OWNER_NAME)) { 65 setOwner((UserPrincipal)value); 66 return; 67 } 68 throw new UnsupportedOperationException("'" + name() + ":" + 69 attribute + "' not supported"); 70 } 71 72 @Override 73 public Map<String,Object> readAttributes(String[] attributes) throws IOException { 74 Map<String,Object> result = new HashMap<>(); 75 for (String attribute: attributes) { 76 if (attribute.equals("*") || attribute.equals(OWNER_NAME)) { 77 result.put(OWNER_NAME, getOwner()); 78 } 79 } 80 return result; 81 } 82 83 @Override 84 public UserPrincipal getOwner() throws IOException { 85 if (isPosixView) { 86 return ((PosixFileAttributeView)view).readAttributes().owner(); 87 } else { 88 return ((AclFileAttributeView)view).getOwner(); 89 } 90 } 91 92 @Override 93 public void setOwner(UserPrincipal owner) 94 throws IOException 95 { 96 if (isPosixView) { 97 ((PosixFileAttributeView)view).setOwner(owner); | 46 this.view = view; 47 this.isPosixView = true; 48 } 49 50 FileOwnerAttributeViewImpl(AclFileAttributeView view) { 51 this.view = view; 52 this.isPosixView = false; 53 } 54 55 @Override 56 public String name() { 57 return "owner"; 58 } 59 60 @Override 61 public void setAttribute(String attribute, Object value) 62 throws IOException 63 { 64 if (attribute.equals(OWNER_NAME)) { 65 setOwner((UserPrincipal)value); 66 } else { 67 throw new IllegalArgumentException("'" + name() + ":" + 68 attribute + "' not recognized"); 69 } 70 } 71 72 @Override 73 public Map<String,Object> readAttributes(String[] attributes) throws IOException { 74 Map<String,Object> result = new HashMap<>(); 75 for (String attribute: attributes) { 76 if (attribute.equals("*") || attribute.equals(OWNER_NAME)) { 77 result.put(OWNER_NAME, getOwner()); 78 } else { 79 throw new IllegalArgumentException("'" + name() + ":" + 80 attribute + "' not recognized"); 81 } 82 } 83 return result; 84 } 85 86 @Override 87 public UserPrincipal getOwner() throws IOException { 88 if (isPosixView) { 89 return ((PosixFileAttributeView)view).readAttributes().owner(); 90 } else { 91 return ((AclFileAttributeView)view).getOwner(); 92 } 93 } 94 95 @Override 96 public void setOwner(UserPrincipal owner) 97 throws IOException 98 { 99 if (isPosixView) { 100 ((PosixFileAttributeView)view).setOwner(owner); |