@Test public void setMetadata() throws Exception { final Path home = DriveHomeFinderService.MYDRIVE_FOLDER; final Path test = new Path(home, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file)); final DriveFileidProvider fileid = new DriveFileidProvider(session).withCache(cache); new DriveTouchFeature(session, fileid).touch(test, new TransferStatus()); assertEquals(Collections.emptyMap(), new DriveMetadataFeature(session, fileid).getMetadata(test)); new DriveMetadataFeature(session, fileid).setMetadata(test, Collections.singletonMap("test", "t")); assertEquals(Collections.singletonMap("test", "t"), new DriveMetadataFeature(session, fileid).getMetadata(test)); new DriveDeleteFeature(session, fileid).delete(Collections.<Path>singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback()); }
@Override public void setMetadata(final Path file, final TransferStatus status) throws BackgroundException { try { final String fileid = this.fileid.getFileid(file, new DisabledListProgressListener()); final File body = new File(); body.setProperties(status.getMetadata()); session.getClient().files().update(fileid, body).setFields("properties"). setSupportsTeamDrives(PreferencesFactory.get().getBoolean("googledrive.teamdrive.enable")).execute(); } catch(IOException e) { throw new DriveExceptionMappingService().map("Failure to write attributes of {0}", e, file); } }
DriveMetadataFeature implements Metadata { @Override public void setMetadata(final Path file, final TransferStatus status) throws BackgroundException { try { final String fileid = this.fileid.getFileid(file, new DisabledListProgressListener()); final File body = new File(); body.setProperties(status.getMetadata()); session.getClient().files().update(fileid, body).setFields("properties"). setSupportsTeamDrives(PreferencesFactory.get().getBoolean("googledrive.teamdrive.enable")).execute(); } catch(IOException e) { throw new DriveExceptionMappingService().map("Failure to write attributes of {0}", e, file); } } }
DriveMetadataFeature implements Metadata { @Override public void setMetadata(final Path file, final TransferStatus status) throws BackgroundException { try { final String fileid = this.fileid.getFileid(file, new DisabledListProgressListener()); final File body = new File(); body.setProperties(status.getMetadata()); session.getClient().files().update(fileid, body).setFields("properties"). setSupportsTeamDrives(PreferencesFactory.get().getBoolean("googledrive.teamdrive.enable")).execute(); } catch(IOException e) { throw new DriveExceptionMappingService().map("Failure to write attributes of {0}", e, file); } } DriveMetadataFeature(final DriveSession session, final DriveFileidProvider fileid); }
DriveMetadataFeature implements Metadata { @Override public void setMetadata(final Path file, final TransferStatus status) throws BackgroundException { try { final String fileid = this.fileid.getFileid(file, new DisabledListProgressListener()); final File body = new File(); body.setProperties(status.getMetadata()); session.getClient().files().update(fileid, body).setFields("properties"). setSupportsTeamDrives(PreferencesFactory.get().getBoolean("googledrive.teamdrive.enable")).execute(); } catch(IOException e) { throw new DriveExceptionMappingService().map("Failure to write attributes of {0}", e, file); } } DriveMetadataFeature(final DriveSession session, final DriveFileidProvider fileid); @Override Map<String, String> getDefault(final Local local); @Override Map<String, String> getMetadata(final Path file); @Override void setMetadata(final Path file, final TransferStatus status); }
DriveMetadataFeature implements Metadata { @Override public void setMetadata(final Path file, final TransferStatus status) throws BackgroundException { try { final String fileid = this.fileid.getFileid(file, new DisabledListProgressListener()); final File body = new File(); body.setProperties(status.getMetadata()); session.getClient().files().update(fileid, body).setFields("properties"). setSupportsTeamDrives(PreferencesFactory.get().getBoolean("googledrive.teamdrive.enable")).execute(); } catch(IOException e) { throw new DriveExceptionMappingService().map("Failure to write attributes of {0}", e, file); } } DriveMetadataFeature(final DriveSession session, final DriveFileidProvider fileid); @Override Map<String, String> getDefault(final Local local); @Override Map<String, String> getMetadata(final Path file); @Override void setMetadata(final Path file, final TransferStatus status);  }