public class DriveTemplate extends AbstractGoogleApiOperations implements DriveOperations
DriveOperations
implementation.isAuthorized, restTemplate
Constructor and Description |
---|
DriveTemplate(org.springframework.web.client.RestTemplate restTemplate,
boolean isAuthorized) |
Modifier and Type | Method and Description |
---|---|
FileComment |
addComment(java.lang.String fileId,
FileComment comment)
Adds a comment to a file
|
UserPermission |
addPermission(java.lang.String fileId,
UserPermission permission,
boolean sendNotificationEmails)
Adds a permission to a file
|
CommentReply |
addReply(java.lang.String fileId,
java.lang.String commentId,
CommentReply reply)
Adds a reply to a file comment
|
DriveFile |
createFileMetadata(DriveFile metadata)
Creates an empty file with metadata
|
DriveFile |
createFolder(java.lang.String parentId,
java.lang.String name)
Creates a folder
|
void |
delete(java.lang.String id)
Permanently deletes a file
|
org.springframework.core.io.Resource |
downloadFile(DriveFile file)
Downloads a file from Google Drive.
|
org.springframework.core.io.Resource |
downloadFile(java.lang.String id)
Downloads a file from Google Drive.
|
DriveFileQueryBuilder |
driveFileQuery()
Creates a
DriveFileQueryBuilder |
FileCommentQueryBuilder |
fileCommentQueryBuilder(java.lang.String fileId)
Returns a
FileCommentQueryBuilder for listing the comments of a
file |
DriveAbout |
getAbout()
Get general Google Drive details for the current user
|
DriveApp |
getApp(java.lang.String id)
Returns an application by its ID
|
java.util.List<DriveApp> |
getApps()
Returns the applications authorized by the user to access Google Drive
API
|
FileCommentsPage |
getComments(java.lang.String fileId,
java.lang.String pageToken)
Returns the first default page of comments on a file
|
DriveFile |
getFile(java.lang.String id)
Retrieves a file by its ID
|
DriveFilesPage |
getFiles(java.lang.String parent,
java.lang.String pageToken)
Returns the files and folders under a specified folder
|
java.util.List<UserPermission> |
getPermissions(java.lang.String fileId)
Returns the permissions of a file
|
java.util.List<FileRevision> |
getRevisions(java.lang.String fileId)
Returns the revisions of a file
|
DriveFilesPage |
getRootFiles(java.lang.String pageToken)
Returns files and folders under the root folder
|
DriveFilesPage |
getTrashedFiles(java.lang.String pageToken)
Returns trashed files and folders
|
DriveFile |
hide(java.lang.String id)
Hides a file
|
void |
removeComment(java.lang.String fileId,
java.lang.String commentId)
Removes a comment from a file
|
void |
removePermission(java.lang.String fileId,
java.lang.String permissionId)
Removes a permission from a file
|
void |
removeReply(java.lang.String fileId,
java.lang.String commentId,
java.lang.String replyId)
Removes a reply from a file comment
|
DriveFile |
star(java.lang.String id)
Stars a file
|
DriveFile |
trash(java.lang.String id)
Moves a file to trash
|
DriveFile |
unhide(java.lang.String id)
Unhides a file
|
DriveFile |
unstar(java.lang.String id)
Remove the star from a file
|
DriveFile |
untrash(java.lang.String id)
Restores a file from trash
|
FileComment |
updateComment(java.lang.String fileId,
java.lang.String commentId,
FileComment comment)
Updates a comment to a file
|
CommentReply |
updateReply(java.lang.String fileId,
java.lang.String commentId,
java.lang.String replyId,
CommentReply reply)
Updates a reply to a file comment
|
FileRevision |
updateRevision(java.lang.String fileId,
java.lang.String revisionId,
FileRevision revision)
Updates a file revision
|
UserPermission |
updatesPermission(java.lang.String fileId,
java.lang.String permissionId,
UserPermission permission)
Updates a permission to a file
|
DriveFile |
upload(org.springframework.core.io.Resource resource,
DriveFile metadata,
UploadParameters parameters)
Uploads a file using multipart
|
deleteEntity, deleteEntity, getEntity, patch, requireAuthorization, saveEntity, saveEntity
public DriveTemplate(org.springframework.web.client.RestTemplate restTemplate, boolean isAuthorized)
public DriveAbout getAbout()
DriveOperations
getAbout
in interface DriveOperations
DriveAbout
with details for the current userpublic java.util.List<DriveApp> getApps()
DriveOperations
getApps
in interface DriveOperations
DriveApp
for the current userpublic DriveApp getApp(java.lang.String id)
DriveOperations
getApp
in interface DriveOperations
id
- The ID of the applicationDriveApp
matching the IDpublic DriveFile getFile(java.lang.String id)
DriveOperations
getFile
in interface DriveOperations
id
- the ID to retrieve byDriveFile
matching the IDpublic DriveFileQueryBuilder driveFileQuery()
DriveOperations
DriveFileQueryBuilder
driveFileQuery
in interface DriveOperations
DriveFileQueryBuilder
public DriveFilesPage getRootFiles(java.lang.String pageToken)
DriveOperations
getRootFiles
in interface DriveOperations
pageToken
- Page token or nullDriveFilesPage
public DriveFilesPage getFiles(java.lang.String parent, java.lang.String pageToken)
DriveOperations
getFiles
in interface DriveOperations
parent
- folder ID or "root"pageToken
- Page token or nullDriveFilesPage
public DriveFilesPage getTrashedFiles(java.lang.String pageToken)
DriveOperations
getTrashedFiles
in interface DriveOperations
pageToken
- Page token or nullDriveFilesPage
public DriveFile trash(java.lang.String id)
DriveOperations
trash
in interface DriveOperations
id
- The ID of the file to trashDriveFile
public DriveFile untrash(java.lang.String id)
DriveOperations
untrash
in interface DriveOperations
id
- The ID of the file to untrash return The updated
DriveFile
DriveFile
public DriveFile star(java.lang.String id)
DriveOperations
star
in interface DriveOperations
id
- The ID of the file to starDriveFile
public DriveFile unstar(java.lang.String id)
DriveOperations
unstar
in interface DriveOperations
id
- The ID of the file to unstarDriveFile
public DriveFile hide(java.lang.String id)
DriveOperations
hide
in interface DriveOperations
id
- The ID of the file to hideDriveFile
public DriveFile unhide(java.lang.String id)
DriveOperations
unhide
in interface DriveOperations
id
- The ID of the file to unhideDriveFile
public void delete(java.lang.String id)
DriveOperations
delete
in interface DriveOperations
id
- The ID of the file to deletepublic DriveFile upload(org.springframework.core.io.Resource resource, DriveFile metadata, UploadParameters parameters)
DriveOperations
upload
in interface DriveOperations
resource
- Reference to the file's contentmetadata
- The file's metadataparameters
- Parameters for uploading and processing the filepublic DriveFile createFileMetadata(DriveFile metadata)
DriveOperations
createFileMetadata
in interface DriveOperations
metadata
- The file's propertiesDriveFile
representing the created filepublic DriveFile createFolder(java.lang.String parentId, java.lang.String name)
DriveOperations
createFolder
in interface DriveOperations
parentId
- The parent folder ID or "root"name
- The name of the folder to createDriveFile
representing the created folderpublic java.util.List<UserPermission> getPermissions(java.lang.String fileId)
DriveOperations
getPermissions
in interface DriveOperations
fileId
- The ID of the fileUserPermission
for the filepublic UserPermission addPermission(java.lang.String fileId, UserPermission permission, boolean sendNotificationEmails)
DriveOperations
addPermission
in interface DriveOperations
fileId
- The file IDpermission
- UserPermission
with the permission settingssendNotificationEmails
- Whether to send notification e-mailsUserPermission
public UserPermission updatesPermission(java.lang.String fileId, java.lang.String permissionId, UserPermission permission)
DriveOperations
updatesPermission
in interface DriveOperations
fileId
- The file IDpermissionId
- the ID of the permissionpermission
- UserPermission
with new role and additionalRoles
propertiesUserPermission
public void removePermission(java.lang.String fileId, java.lang.String permissionId)
DriveOperations
removePermission
in interface DriveOperations
fileId
- The file IDpermissionId
- The ID of the permissionpublic java.util.List<FileRevision> getRevisions(java.lang.String fileId)
DriveOperations
getRevisions
in interface DriveOperations
fileId
- The ID of the fileFileRevision
public FileRevision updateRevision(java.lang.String fileId, java.lang.String revisionId, FileRevision revision)
DriveOperations
updateRevision
in interface DriveOperations
fileId
- The ID of the filerevisionId
- The ID of the revisionrevision
- FileRevision
with new pinned, publishAuto, published
and publishedOutsideDomain propertiesFileRevision
public FileCommentQueryBuilder fileCommentQueryBuilder(java.lang.String fileId)
DriveOperations
FileCommentQueryBuilder
for listing the comments of a
filefileCommentQueryBuilder
in interface DriveOperations
fileId
- The ID of the fileFileCommentQueryBuilder
for the filepublic FileCommentsPage getComments(java.lang.String fileId, java.lang.String pageToken)
DriveOperations
getComments
in interface DriveOperations
fileId
- The ID of the filepageToken
- Page token or nullpublic FileComment addComment(java.lang.String fileId, FileComment comment)
DriveOperations
addComment
in interface DriveOperations
fileId
- The ID of the filecomment
- The new commentFileComment
public FileComment updateComment(java.lang.String fileId, java.lang.String commentId, FileComment comment)
DriveOperations
updateComment
in interface DriveOperations
fileId
- The ID of the filecommentId
- The ID of the commentcomment
- Comment with the new contentFileComment
public void removeComment(java.lang.String fileId, java.lang.String commentId)
DriveOperations
removeComment
in interface DriveOperations
fileId
- The ID of the filecommentId
- The ID of the commentpublic CommentReply addReply(java.lang.String fileId, java.lang.String commentId, CommentReply reply)
DriveOperations
addReply
in interface DriveOperations
fileId
- The ID of the filecommentId
- The ID of the commentreply
- The new replyCommentReply
public CommentReply updateReply(java.lang.String fileId, java.lang.String commentId, java.lang.String replyId, CommentReply reply)
DriveOperations
updateReply
in interface DriveOperations
fileId
- The ID of the filecommentId
- The ID of the commentreplyId
- The ID of the replyreply
- Reply with new contentCommentReply
public void removeReply(java.lang.String fileId, java.lang.String commentId, java.lang.String replyId)
DriveOperations
removeReply
in interface DriveOperations
fileId
- The ID of the filecommentId
- The ID of the commentreplyId
- The ID of the replypublic org.springframework.core.io.Resource downloadFile(java.lang.String id)
DriveOperations
downloadFile
in interface DriveOperations
id
- The file IDpublic org.springframework.core.io.Resource downloadFile(DriveFile file)
DriveOperations
DriveFile.getDownloadUrl()
, which may have expired since the file
metadata was fetched.downloadFile
in interface DriveOperations
file
- The file metadata