@Test public void testSetTimestamp() 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()); new DriveMetadataFeature(session, fileid).setMetadata(test, Collections.singletonMap("test", "t")); final long modified = System.currentTimeMillis(); new DriveTimestampFeature(session, fileid).setTimestamp(test, modified); assertEquals(modified, new DefaultAttributesFinderFeature(session).find(test).getModificationDate()); assertEquals(modified, new DriveAttributesFinderFeature(session, fileid).find(test).getModificationDate()); 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 setTimestamp(final Path file, final TransferStatus status) throws BackgroundException { try { final String fileid = this.fileid.getFileid(file, new DisabledListProgressListener()); final File properties = new File(); properties.setModifiedTime(new DateTime(status.getTimestamp())); session.getClient().files().update(fileid, properties).setFields("modifiedTime"). setSupportsTeamDrives(PreferencesFactory.get().getBoolean("googledrive.teamdrive.enable")).execute(); } catch(IOException e) { throw new DriveExceptionMappingService().map("Failure to write attributes of {0}", e, file); } }
DriveTimestampFeature extends DefaultTimestampFeature { @Override public void setTimestamp(final Path file, final TransferStatus status) throws BackgroundException { try { final String fileid = this.fileid.getFileid(file, new DisabledListProgressListener()); final File properties = new File(); properties.setModifiedTime(new DateTime(status.getTimestamp())); session.getClient().files().update(fileid, properties).setFields("modifiedTime"). setSupportsTeamDrives(PreferencesFactory.get().getBoolean("googledrive.teamdrive.enable")).execute(); } catch(IOException e) { throw new DriveExceptionMappingService().map("Failure to write attributes of {0}", e, file); } } }
DriveTimestampFeature extends DefaultTimestampFeature { @Override public void setTimestamp(final Path file, final TransferStatus status) throws BackgroundException { try { final String fileid = this.fileid.getFileid(file, new DisabledListProgressListener()); final File properties = new File(); properties.setModifiedTime(new DateTime(status.getTimestamp())); session.getClient().files().update(fileid, properties).setFields("modifiedTime"). setSupportsTeamDrives(PreferencesFactory.get().getBoolean("googledrive.teamdrive.enable")).execute(); } catch(IOException e) { throw new DriveExceptionMappingService().map("Failure to write attributes of {0}", e, file); } } DriveTimestampFeature(final DriveSession session, final DriveFileidProvider fileid); }
DriveTimestampFeature extends DefaultTimestampFeature { @Override public void setTimestamp(final Path file, final TransferStatus status) throws BackgroundException { try { final String fileid = this.fileid.getFileid(file, new DisabledListProgressListener()); final File properties = new File(); properties.setModifiedTime(new DateTime(status.getTimestamp())); session.getClient().files().update(fileid, properties).setFields("modifiedTime"). setSupportsTeamDrives(PreferencesFactory.get().getBoolean("googledrive.teamdrive.enable")).execute(); } catch(IOException e) { throw new DriveExceptionMappingService().map("Failure to write attributes of {0}", e, file); } } DriveTimestampFeature(final DriveSession session, final DriveFileidProvider fileid); @Override void setTimestamp(final Path file, final TransferStatus status); }
DriveTimestampFeature extends DefaultTimestampFeature { @Override public void setTimestamp(final Path file, final TransferStatus status) throws BackgroundException { try { final String fileid = this.fileid.getFileid(file, new DisabledListProgressListener()); final File properties = new File(); properties.setModifiedTime(new DateTime(status.getTimestamp())); session.getClient().files().update(fileid, properties).setFields("modifiedTime"). setSupportsTeamDrives(PreferencesFactory.get().getBoolean("googledrive.teamdrive.enable")).execute(); } catch(IOException e) { throw new DriveExceptionMappingService().map("Failure to write attributes of {0}", e, file); } } DriveTimestampFeature(final DriveSession session, final DriveFileidProvider fileid); @Override void setTimestamp(final Path file, final TransferStatus status);  }