@Test public void testRun() throws Exception { final ReadAclWorker worker = new ReadAclWorker(Arrays.<Path>asList(new Path("/a", EnumSet.of(Path.Type.file)), new Path("/b", EnumSet.of(Path.Type.file)))) { @Override public void cleanup(final List<Acl.UserAndRole> result) { throw new UnsupportedOperationException(); } }; assertEquals(1, worker.run(new NullSession(new Host(new TestProtocol())) { @Override @SuppressWarnings("unchecked") public <T> T _getFeature(final Class<T> type) { if(type == AclPermission.class) { return (T) new DefaultAclFeature() { @Override public Acl getPermission(final Path file) { return new Acl(new Acl.DomainUser("a"), new Acl.Role("r")); } @Override public void setPermission(final Path file, final Acl acl) { } @Override public List<Acl.User> getAvailableAclUsers() { throw new UnsupportedOperationException(); } @Override public List<Acl.Role> getAvailableAclRoles(final List<Path> files) { throw new UnsupportedOperationException(); } }; } return super._getFeature(type); } }).size() ); }
@Override public List<Acl.UserAndRole> run(final Session<?> session) throws BackgroundException { final AclPermission feature = session.getFeature(AclPermission.class); if(log.isDebugEnabled()) { log.debug(String.format("Run with feature %s", feature)); } final List<Acl.UserAndRole> updated = new ArrayList<Acl.UserAndRole>(); for(Path next : files) { if(this.isCanceled()) { throw new ConnectionCanceledException(); } if(Acl.EMPTY == next.attributes().getAcl()) { next.attributes().setAcl(feature.getPermission(next)); } for(Acl.UserAndRole acl : next.attributes().getAcl().asList()) { if(updated.contains(acl)) { continue; } updated.add(acl); } } return updated; }
ReadAclWorker extends Worker<List<Acl.UserAndRole>> { @Override public List<Acl.UserAndRole> run(final Session<?> session) throws BackgroundException { final AclPermission feature = session.getFeature(AclPermission.class); if(log.isDebugEnabled()) { log.debug(String.format("Run with feature %s", feature)); } final List<Acl.UserAndRole> updated = new ArrayList<Acl.UserAndRole>(); for(Path next : files) { if(this.isCanceled()) { throw new ConnectionCanceledException(); } if(Acl.EMPTY == next.attributes().getAcl()) { next.attributes().setAcl(feature.getPermission(next)); } for(Acl.UserAndRole acl : next.attributes().getAcl().asList()) { if(updated.contains(acl)) { continue; } updated.add(acl); } } return updated; } }
ReadAclWorker extends Worker<List<Acl.UserAndRole>> { @Override public List<Acl.UserAndRole> run(final Session<?> session) throws BackgroundException { final AclPermission feature = session.getFeature(AclPermission.class); if(log.isDebugEnabled()) { log.debug(String.format("Run with feature %s", feature)); } final List<Acl.UserAndRole> updated = new ArrayList<Acl.UserAndRole>(); for(Path next : files) { if(this.isCanceled()) { throw new ConnectionCanceledException(); } if(Acl.EMPTY == next.attributes().getAcl()) { next.attributes().setAcl(feature.getPermission(next)); } for(Acl.UserAndRole acl : next.attributes().getAcl().asList()) { if(updated.contains(acl)) { continue; } updated.add(acl); } } return updated; } ReadAclWorker(final List<Path> files); }
ReadAclWorker extends Worker<List<Acl.UserAndRole>> { @Override public List<Acl.UserAndRole> run(final Session<?> session) throws BackgroundException { final AclPermission feature = session.getFeature(AclPermission.class); if(log.isDebugEnabled()) { log.debug(String.format("Run with feature %s", feature)); } final List<Acl.UserAndRole> updated = new ArrayList<Acl.UserAndRole>(); for(Path next : files) { if(this.isCanceled()) { throw new ConnectionCanceledException(); } if(Acl.EMPTY == next.attributes().getAcl()) { next.attributes().setAcl(feature.getPermission(next)); } for(Acl.UserAndRole acl : next.attributes().getAcl().asList()) { if(updated.contains(acl)) { continue; } updated.add(acl); } } return updated; } ReadAclWorker(final List<Path> files); @Override List<Acl.UserAndRole> run(final Session<?> session); @Override String getActivity(); @Override List<Acl.UserAndRole> initialize(); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString(); }
ReadAclWorker extends Worker<List<Acl.UserAndRole>> { @Override public List<Acl.UserAndRole> run(final Session<?> session) throws BackgroundException { final AclPermission feature = session.getFeature(AclPermission.class); if(log.isDebugEnabled()) { log.debug(String.format("Run with feature %s", feature)); } final List<Acl.UserAndRole> updated = new ArrayList<Acl.UserAndRole>(); for(Path next : files) { if(this.isCanceled()) { throw new ConnectionCanceledException(); } if(Acl.EMPTY == next.attributes().getAcl()) { next.attributes().setAcl(feature.getPermission(next)); } for(Acl.UserAndRole acl : next.attributes().getAcl().asList()) { if(updated.contains(acl)) { continue; } updated.add(acl); } } return updated; } ReadAclWorker(final List<Path> files); @Override List<Acl.UserAndRole> run(final Session<?> session); @Override String getActivity(); @Override List<Acl.UserAndRole> initialize(); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString();  }