@Override public FileStatus getFileStatus(Path p) throws IOException { Preconditions.checkNotNull(p); String fileId = toFileId(p); File metadata = client.files().get(fileId) .setFields("id,mimeType,modifiedTime,size,permissions") .execute(); return toFileStatus(metadata); }
private File getFileImpl(String fileId, int retry) { try { logger.trace("getFile(" + fileId + ")"); // control we are not exceeding number of requests/second bandwidthController.newRequest(); // get file from google File file = drive.files().get(fileId) .setFields(REQUEST_FILE_FIELDS).execute(); logger.trace("getFile(" + fileId + ") = " + file.getName()); return file; } catch (GoogleJsonResponseException e) { if (e.getStatusCode() == 404) { return null; } throw new RuntimeException("Error while getting list of files", e); } catch (Exception e) { if (retry > 0) { try { Thread.sleep(1000); } catch (InterruptedException e1) { throw new RuntimeException(e1); } logger.warn("Getting file data failed. Retrying... '" + fileId); return getFileImpl(fileId, --retry); } throw new RuntimeException(e); } }
public File getFile(String id) { Drive drive = driveFactory.getDrive(this.credential); try { File file = executeWithRetry(options, () -> drive.files().get(id).execute()); if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, "Got file : " + file.getId() + ":" + file.getName()); } return file; } catch (IOException e) { throw new JDriveSyncException(JDriveSyncException.Reason.IOException, "Failed to execute get file request: " + e.getMessage(), e); } }
.setFields("parents") .setSupportsTeamDrives(PreferencesFactory.get().getBoolean("googledrive.teamdrive.enable")) .execute(); for(String parent : reference.getParents()) { previousParents.append(parent);
@Override public Map<String, String> getMetadata(final Path file) throws BackgroundException { try { final String fileid = this.fileid.getFileid(file, new DisabledListProgressListener()); final Map<String, String> properties = session.getClient().files().get(fileid).setFields("properties") .setSupportsTeamDrives(PreferencesFactory.get().getBoolean("googledrive.teamdrive.enable")).execute().getProperties(); if(null == properties) { return Collections.emptyMap(); } return properties; } catch(IOException e) { throw new DriveExceptionMappingService().map("Failure to read attributes of {0}", e, file); } }
public File getMetadata(String id, String metadata) throws IOException { LOG.debug("[getMetadata] id={}, metadata={}.", id, metadata); return drive.files().get(id).setFields(metadata).execute(); }
public File getMetadata(String id, String metadata) throws IOException { LOG.debug("[getMetadata] id={}, metadata={}.", id, metadata); return drive.files().get(id).setFields(metadata).execute(); }
@Override public FileStatus getFileStatus(Path p) throws IOException { Preconditions.checkNotNull(p); String fileId = toFileId(p); File metadata = client.files().get(fileId) .setFields("id,mimeType,modifiedTime,size,permissions") .execute(); return toFileStatus(metadata); }
public static com.google.api.services.drive.model.File getFile(final Drive driveService, final String id) throws IOException { LOGGER.debug("Loading file: {}.", id); return driveService.files().get(id) .setFields("id,name,modifiedTime") .execute(); }
public static com.google.api.services.drive.model.File getFile(final Drive driveService, final String id) throws IOException { LOGGER.debug("Loading file: {}.", id); return driveService.files().get(id) .setFields("id,name,modifiedTime") .execute(); }