use of com.google.api.services.drive.model.FileList in project local-data-aragopedia by aragonopendata.
the class GoogleDriveAPI method listOwnerFiles.
public List<File> listOwnerFiles() {
FileList result;
List<File> files = new ArrayList<>();
com.google.api.services.drive.Drive.Files.List request = null;
try {
do {
request = service.files().list().setMaxResults(500);
result = request.execute();
files.addAll(result.getItems());
request.setPageToken(result.getNextPageToken());
} while (request.getPageToken() != null && request.getPageToken().length() > 0);
} catch (IOException e) {
log.error("Error list files", e);
}
return files;
}
use of com.google.api.services.drive.model.FileList in project local-data-aragopedia by aragonopendata.
the class GoogleDriveAPI method listOwnerFilesAfterDate.
public List<File> listOwnerFilesAfterDate(String stringDateLastChange) {
SimpleDateFormat formatFullDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date dateLastChange = null;
try {
dateLastChange = formatFullDate.parse(stringDateLastChange);
} catch (ParseException e1) {
log.error("Error parse date in list", e1);
}
FileList result;
List<File> files = null;
try {
result = service.files().list().setMaxResults(500).execute();
files = result.getItems();
} catch (IOException e) {
log.error("Error list files", e);
}
if (files == null || files.size() == 0) {
log.error("No files found");
} else {
log.info("Files:\n");
for (File file : files) {
DateTime dateTime = file.getModifiedDate();
Date dateModifyFile = new Date(dateTime.getValue());
if (dateModifyFile.after(dateLastChange))
log.info("Title " + file.getTitle() + " id " + file.getId() + " DateTime " + formatFullDate.format(dateModifyFile));
}
}
return files;
}
Aggregations