use of com.google.api.services.drive.model.File in project camel by apache.
the class DriveFilesIntegrationTest method testTouch.
@Test
public void testTouch() throws Exception {
File theTestFile = uploadTestFile();
DateTime createdDate = theTestFile.getModifiedDate();
// using String message body for single parameter "fileId"
File result = requestBody("direct://TOUCH", theTestFile.getId());
assertNotNull("touch result", result);
assertTrue(result.getModifiedDate().getValue() > createdDate.getValue());
}
use of com.google.api.services.drive.model.File in project camel by apache.
the class FilesConsumerIntegrationTest method testListConsumer.
@Test
public void testListConsumer() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
File testFile = uploadTestFile();
String fileId = testFile.getId();
assertMockEndpointsSatisfied();
FileList fileList = mock.getReceivedExchanges().get(0).getIn().getBody(com.google.api.services.drive.model.FileList.class);
assertTrue(fileInList(fileId, fileList));
}
use of com.google.api.services.drive.model.File in project local-data-aragopedia by aragonopendata.
the class GoogleDriveAPI method downloadAllFiles.
public void downloadAllFiles(String path) {
List<File> files = listOwnerFiles();
for (File file : files) {
try {
String downloadUrl = file.getExportLinks().get("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
HttpResponse resp = service.getRequestFactory().buildGetRequest(new GenericUrl(downloadUrl)).execute();
InputStream input = resp.getContent();
java.io.File f = new java.io.File(path + java.io.File.separator + file.getTitle() + ".xlsx");
FileUtils.copyInputStreamToFile(input, f);
} catch (IOException e) {
e.printStackTrace();
}
}
}
use of com.google.api.services.drive.model.File 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.File in project local-data-aragopedia by aragonopendata.
the class GoogleDriveAPI method downloadFilesAfterDate.
public void downloadFilesAfterDate(String path, String stringDateLastChange) {
List<File> files = listOwnerFilesAfterDate(stringDateLastChange);
for (File file : files) {
try {
String downloadUrl = file.getExportLinks().get("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
HttpResponse resp = service.getRequestFactory().buildGetRequest(new GenericUrl(downloadUrl)).execute();
InputStream input = resp.getContent();
java.io.File f = new java.io.File(path + java.io.File.separator + file.getTitle() + ".xlsx");
FileUtils.copyInputStreamToFile(input, f);
} catch (IOException e) {
e.printStackTrace();
}
}
}
Aggregations