@Test(expected = NotfoundException.class) public void testWriteNotFound() throws Exception { final Path container = new Path("test.cyberduck.ch", EnumSet.of(Path.Type.directory)); final Path test = new Path(container, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file)); final GoogleStorageAccessControlListFeature f = new GoogleStorageAccessControlListFeature(session); final Acl acl = new Acl(); acl.addAll(new Acl.GroupUser(Acl.GroupUser.EVERYONE), new Acl.Role(Acl.Role.READ)); f.setPermission(test, acl); }
@Override public void setPermission(final Path file, final Acl acl) throws BackgroundException { try { if(containerService.isContainer(file)) { final List<BucketAccessControl> bucketAccessControls = this.toBucketAccessControl(acl); session.getClient().buckets().update(containerService.getContainer(file).getName(), new Bucket().setAcl(bucketAccessControls)).execute(); } else { final List<ObjectAccessControl> objectAccessControls = this.toObjectAccessControl(acl); session.getClient().objects().update(containerService.getContainer(file).getName(), containerService.getKey(file), new StorageObject().setAcl(objectAccessControls)).execute(); } } catch(IOException e) { final BackgroundException failure = new GoogleStorageExceptionMappingService().map("Cannot change permissions of {0}", e, file); if(file.isPlaceholder()) { if(failure instanceof NotfoundException) { return; } } throw failure; } }
GoogleStorageAccessControlListFeature extends DefaultAclFeature implements AclPermission { @Override public void setPermission(final Path file, final Acl acl) throws BackgroundException { try { if(containerService.isContainer(file)) { final List<BucketAccessControl> bucketAccessControls = this.toBucketAccessControl(acl); session.getClient().buckets().update(containerService.getContainer(file).getName(), new Bucket().setAcl(bucketAccessControls)).execute(); } else { final List<ObjectAccessControl> objectAccessControls = this.toObjectAccessControl(acl); session.getClient().objects().update(containerService.getContainer(file).getName(), containerService.getKey(file), new StorageObject().setAcl(objectAccessControls)).execute(); } } catch(IOException e) { final BackgroundException failure = new GoogleStorageExceptionMappingService().map("Cannot change permissions of {0}", e, file); if(file.isPlaceholder()) { if(failure instanceof NotfoundException) { return; } } throw failure; } } }
GoogleStorageAccessControlListFeature extends DefaultAclFeature implements AclPermission { @Override public void setPermission(final Path file, final Acl acl) throws BackgroundException { try { if(containerService.isContainer(file)) { final List<BucketAccessControl> bucketAccessControls = this.toBucketAccessControl(acl); session.getClient().buckets().update(containerService.getContainer(file).getName(), new Bucket().setAcl(bucketAccessControls)).execute(); } else { final List<ObjectAccessControl> objectAccessControls = this.toObjectAccessControl(acl); session.getClient().objects().update(containerService.getContainer(file).getName(), containerService.getKey(file), new StorageObject().setAcl(objectAccessControls)).execute(); } } catch(IOException e) { final BackgroundException failure = new GoogleStorageExceptionMappingService().map("Cannot change permissions of {0}", e, file); if(file.isPlaceholder()) { if(failure instanceof NotfoundException) { return; } } throw failure; } } GoogleStorageAccessControlListFeature(final GoogleStorageSession session); }
GoogleStorageAccessControlListFeature extends DefaultAclFeature implements AclPermission { @Override public void setPermission(final Path file, final Acl acl) throws BackgroundException { try { if(containerService.isContainer(file)) { final List<BucketAccessControl> bucketAccessControls = this.toBucketAccessControl(acl); session.getClient().buckets().update(containerService.getContainer(file).getName(), new Bucket().setAcl(bucketAccessControls)).execute(); } else { final List<ObjectAccessControl> objectAccessControls = this.toObjectAccessControl(acl); session.getClient().objects().update(containerService.getContainer(file).getName(), containerService.getKey(file), new StorageObject().setAcl(objectAccessControls)).execute(); } } catch(IOException e) { final BackgroundException failure = new GoogleStorageExceptionMappingService().map("Cannot change permissions of {0}", e, file); if(file.isPlaceholder()) { if(failure instanceof NotfoundException) { return; } } 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 void setPermission(final Path file, final Acl acl) throws BackgroundException { try { if(containerService.isContainer(file)) { final List<BucketAccessControl> bucketAccessControls = this.toBucketAccessControl(acl); session.getClient().buckets().update(containerService.getContainer(file).getName(), new Bucket().setAcl(bucketAccessControls)).execute(); } else { final List<ObjectAccessControl> objectAccessControls = this.toObjectAccessControl(acl); session.getClient().objects().update(containerService.getContainer(file).getName(), containerService.getKey(file), new StorageObject().setAcl(objectAccessControls)).execute(); } } catch(IOException e) { final BackgroundException failure = new GoogleStorageExceptionMappingService().map("Cannot change permissions of {0}", e, file); if(file.isPlaceholder()) { if(failure instanceof NotfoundException) { return; } } 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);  }