use of com.google.api.services.drive.model.File in project Aegis by Decad3nce.
the class BackupGoogleAccountsActivity method createAegisFolder.
private void createAegisFolder() {
Log.i(TAG, "Creating aeGis folder");
Thread t = new Thread(new Runnable() {
@Override
public void run() {
try {
File body = new File();
body.setTitle("aeGis Backup");
body.setDescription("Backup stored by aeGis");
body.setMimeType("application/vnd.google-apps.folder");
File file = service.files().insert(body).execute();
if (file != null) {
finish();
}
} catch (UserRecoverableAuthIOException e) {
startActivityForResult(e.getIntent(), REQUEST_AUTHORIZATION);
} catch (IOException e) {
e.printStackTrace();
}
}
});
t.start();
}
use of com.google.api.services.drive.model.File in project camel by apache.
the class AbstractGoogleDriveTestSupport method uploadTestFile.
protected File uploadTestFile() {
File fileMetadata = new File();
fileMetadata.setTitle(UPLOAD_FILE.getName());
FileContent mediaContent = new FileContent(null, UPLOAD_FILE);
final Map<String, Object> headers = new HashMap<String, Object>();
// parameter type is com.google.api.services.drive.model.File
headers.put("CamelGoogleDrive.content", fileMetadata);
// parameter type is com.google.api.client.http.AbstractInputStreamContent
headers.put("CamelGoogleDrive.mediaContent", mediaContent);
File result = requestBodyAndHeaders("google-drive://drive-files/insert", null, headers);
return result;
}
use of com.google.api.services.drive.model.File in project camel by apache.
the class DriveChildrenIntegrationTest method testUploadFileToFolder.
@Test
public void testUploadFileToFolder() throws Exception {
File folder = uploadTestFolder();
File file = uploadTestFile();
final Map<String, Object> headers = new HashMap<String, Object>();
// parameter type is String
headers.put("CamelGoogleDrive.folderId", folder.getId());
com.google.api.services.drive.model.ChildReference child = new com.google.api.services.drive.model.ChildReference();
child.setId(file.getId());
// parameter type is com.google.api.services.drive.model.ChildReference
headers.put("CamelGoogleDrive.content", child);
requestBodyAndHeaders("direct://INSERT", null, headers);
final com.google.api.services.drive.model.ChildList result = requestBody("direct://LIST", folder.getId());
assertNotNull("insert result", result);
LOG.debug("insert: " + result);
}
use of com.google.api.services.drive.model.File in project camel by apache.
the class DriveCommentsIntegrationTest method testComment.
@Test
public void testComment() throws Exception {
// 1. create test file
File testFile = uploadTestFile();
String fileId = testFile.getId();
// 2. comment on that file
Map<String, Object> headers = new HashMap<String, Object>();
// parameter type is String
headers.put("CamelGoogleDrive.fileId", fileId);
// parameter type is com.google.api.services.drive.model.Comment
com.google.api.services.drive.model.Comment comment = new com.google.api.services.drive.model.Comment();
comment.setContent("Camel rocks!");
headers.put("CamelGoogleDrive.content", comment);
requestBodyAndHeaders("direct://INSERT", null, headers);
// 3. get a list of comments on the file
// using String message body for single parameter "fileId"
com.google.api.services.drive.model.CommentList result1 = requestBody("direct://LIST", fileId);
assertNotNull(result1.get("items"));
LOG.debug("list: " + result1);
Comment comment2 = result1.getItems().get(0);
// 4. now try and get that comment
headers = new HashMap<String, Object>();
// parameter type is String
headers.put("CamelGoogleDrive.fileId", fileId);
// parameter type is String
headers.put("CamelGoogleDrive.commentId", comment2.getCommentId());
final com.google.api.services.drive.model.Comment result3 = requestBodyAndHeaders("direct://GET", null, headers);
assertNotNull("get result", result3);
// 5. delete the comment
headers = new HashMap<String, Object>();
// parameter type is String
headers.put("CamelGoogleDrive.fileId", fileId);
// parameter type is String
headers.put("CamelGoogleDrive.commentId", comment2.getCommentId());
requestBodyAndHeaders("direct://DELETE", null, headers);
// 6. ensure the comment is gone
headers = new HashMap<String, Object>();
// parameter type is String
headers.put("CamelGoogleDrive.fileId", fileId);
// parameter type is String
headers.put("CamelGoogleDrive.commentId", comment2.getCommentId());
try {
final com.google.api.services.drive.model.Comment result4 = requestBodyAndHeaders("direct://GET", null, headers);
assertTrue("Should have thrown an exception.", false);
} catch (Exception e) {
e.printStackTrace();
}
}
use of com.google.api.services.drive.model.File in project camel by apache.
the class DriveFilesIntegrationTest method testTrash.
@Test
public void testTrash() throws Exception {
File testFile = uploadTestFile();
String fileId = testFile.getId();
assertNotNull("trash result", requestBody("direct://TRASH", fileId));
assertNotNull("untrash result", requestBody("direct://UNTRASH", fileId));
}
Aggregations