@Test public void testReadBucket() throws Exception { final Path container = new Path("test.cyberduck.ch", EnumSet.of(Path.Type.directory)); final GoogleStorageAccessControlListFeature f = new GoogleStorageAccessControlListFeature(session); final Acl acl = f.getPermission(container); assertTrue(acl.containsKey(new Acl.GroupUser("cloud-storage-analytics@google.com"))); assertFalse(acl.containsKey(new Acl.GroupUser(Acl.GroupUser.EVERYONE))); }
@Override public Acl getPermission(final Path file) throws BackgroundException { try { final Acl acl = new Acl(); if(containerService.isContainer(file)) { final BucketAccessControls controls = session.getClient().bucketAccessControls().list( containerService.getContainer(file).getName()).execute(); for(BucketAccessControl control : controls.getItems()) { final String entity = control.getEntity(); acl.addAll(this.toUser(entity, control.getEmail()), new Acl.Role(control.getRole())); } } else { final ObjectAccessControls controls = session.getClient().objectAccessControls().list(containerService.getContainer(file).getName(), containerService.getKey(file)).execute(); for(ObjectAccessControl control : controls.getItems()) { final String entity = control.getEntity(); acl.addAll(this.toUser(entity, control.getEmail()), this.toRole(control)); } } return acl; } catch(IOException e) { final BackgroundException failure = new GoogleStorageExceptionMappingService().map("Failure to read attributes of {0}", e, file); if(file.isPlaceholder()) { if(failure instanceof NotfoundException) { return Acl.EMPTY; } } if(failure instanceof InteroperabilityException) { return Acl.EMPTY; } throw failure; } }
GoogleStorageAccessControlListFeature extends DefaultAclFeature implements AclPermission { @Override public Acl getPermission(final Path file) throws BackgroundException { try { final Acl acl = new Acl(); if(containerService.isContainer(file)) { final BucketAccessControls controls = session.getClient().bucketAccessControls().list( containerService.getContainer(file).getName()).execute(); for(BucketAccessControl control : controls.getItems()) { final String entity = control.getEntity(); acl.addAll(this.toUser(entity, control.getEmail()), new Acl.Role(control.getRole())); } } else { final ObjectAccessControls controls = session.getClient().objectAccessControls().list(containerService.getContainer(file).getName(), containerService.getKey(file)).execute(); for(ObjectAccessControl control : controls.getItems()) { final String entity = control.getEntity(); acl.addAll(this.toUser(entity, control.getEmail()), this.toRole(control)); } } return acl; } catch(IOException e) { final BackgroundException failure = new GoogleStorageExceptionMappingService().map("Failure to read attributes of {0}", e, file); if(file.isPlaceholder()) { if(failure instanceof NotfoundException) { return Acl.EMPTY; } } if(failure instanceof InteroperabilityException) { return Acl.EMPTY; } throw failure; } } }
GoogleStorageAccessControlListFeature extends DefaultAclFeature implements AclPermission { @Override public Acl getPermission(final Path file) throws BackgroundException { try { final Acl acl = new Acl(); if(containerService.isContainer(file)) { final BucketAccessControls controls = session.getClient().bucketAccessControls().list( containerService.getContainer(file).getName()).execute(); for(BucketAccessControl control : controls.getItems()) { final String entity = control.getEntity(); acl.addAll(this.toUser(entity, control.getEmail()), new Acl.Role(control.getRole())); } } else { final ObjectAccessControls controls = session.getClient().objectAccessControls().list(containerService.getContainer(file).getName(), containerService.getKey(file)).execute(); for(ObjectAccessControl control : controls.getItems()) { final String entity = control.getEntity(); acl.addAll(this.toUser(entity, control.getEmail()), this.toRole(control)); } } return acl; } catch(IOException e) { final BackgroundException failure = new GoogleStorageExceptionMappingService().map("Failure to read attributes of {0}", e, file); if(file.isPlaceholder()) { if(failure instanceof NotfoundException) { return Acl.EMPTY; } } if(failure instanceof InteroperabilityException) { return Acl.EMPTY; } throw failure; } } GoogleStorageAccessControlListFeature(final GoogleStorageSession session); }
GoogleStorageAccessControlListFeature extends DefaultAclFeature implements AclPermission { @Override public Acl getPermission(final Path file) throws BackgroundException { try { final Acl acl = new Acl(); if(containerService.isContainer(file)) { final BucketAccessControls controls = session.getClient().bucketAccessControls().list( containerService.getContainer(file).getName()).execute(); for(BucketAccessControl control : controls.getItems()) { final String entity = control.getEntity(); acl.addAll(this.toUser(entity, control.getEmail()), new Acl.Role(control.getRole())); } } else { final ObjectAccessControls controls = session.getClient().objectAccessControls().list(containerService.getContainer(file).getName(), containerService.getKey(file)).execute(); for(ObjectAccessControl control : controls.getItems()) { final String entity = control.getEntity(); acl.addAll(this.toUser(entity, control.getEmail()), this.toRole(control)); } } return acl; } catch(IOException e) { final BackgroundException failure = new GoogleStorageExceptionMappingService().map("Failure to read attributes of {0}", e, file); if(file.isPlaceholder()) { if(failure instanceof NotfoundException) { return Acl.EMPTY; } } if(failure instanceof InteroperabilityException) { return Acl.EMPTY; } throw failure; } } GoogleStorageAccessControlListFeature(final GoogleStorageSession session); @Override Acl getPermission(final Path file); @Override void setPermission(final Path file, final Acl acl); @Override List<Acl.User> getAvailableAclUsers(); @Override List<Acl.Role> getAvailableAclRoles(final List<Path> files); }
GoogleStorageAccessControlListFeature extends DefaultAclFeature implements AclPermission { @Override public Acl getPermission(final Path file) throws BackgroundException { try { final Acl acl = new Acl(); if(containerService.isContainer(file)) { final BucketAccessControls controls = session.getClient().bucketAccessControls().list( containerService.getContainer(file).getName()).execute(); for(BucketAccessControl control : controls.getItems()) { final String entity = control.getEntity(); acl.addAll(this.toUser(entity, control.getEmail()), new Acl.Role(control.getRole())); } } else { final ObjectAccessControls controls = session.getClient().objectAccessControls().list(containerService.getContainer(file).getName(), containerService.getKey(file)).execute(); for(ObjectAccessControl control : controls.getItems()) { final String entity = control.getEntity(); acl.addAll(this.toUser(entity, control.getEmail()), this.toRole(control)); } } return acl; } catch(IOException e) { final BackgroundException failure = new GoogleStorageExceptionMappingService().map("Failure to read attributes of {0}", e, file); if(file.isPlaceholder()) { if(failure instanceof NotfoundException) { return Acl.EMPTY; } } if(failure instanceof InteroperabilityException) { return Acl.EMPTY; } throw failure; } } GoogleStorageAccessControlListFeature(final GoogleStorageSession session); @Override Acl getPermission(final Path file); @Override void setPermission(final Path file, final Acl acl); @Override List<Acl.User> getAvailableAclUsers(); @Override List<Acl.Role> getAvailableAclRoles(final List<Path> files);  }