public class GoogleUtil
extends java.lang.Object
Constructor and Description |
---|
GoogleUtil() |
Modifier and Type | Method and Description |
---|---|
static void |
checkOutNode(java.lang.String ticket,
java.lang.String objectId)
Checks out a repository node.
|
static com.google.gdata.data.docs.DocumentListEntry |
createGoogleDocumentEntry(org.springframework.social.connect.Connection<org.springframework.social.google.docs.api.GoogleDocs> connection,
java.lang.String objectName,
java.lang.String googleDocType)
Creates a new Google document in the user's Google Drive.
|
static java.lang.String |
createRepositoryGoogleDocFile(java.lang.String ticket,
java.lang.String parentObjectId,
java.lang.String objectType,
java.lang.String googleDocType,
org.springframework.core.io.Resource newGoogleDocFile)
Creates a new object in the repository under the provided parent objectId, of the provided object type and using the
Google doc type to create to get the appropriate file extension depending on the related mimetype of that Google doc type.
|
static void |
deleteGoogleDocument(org.springframework.social.connect.Connection<org.springframework.social.google.docs.api.GoogleDocs> connection,
java.lang.String resourceId)
Deletes a Google document represented by the passed in resourceId parameter.
|
static void |
ensureSystemEnabled(boolean googleDocsEnabled)
Ensures that the Google Docs system is enabled by throwing an
OCRuntimeException if the provided
boolean is false. |
static com.google.gdata.data.docs.DocumentListEntry |
getDocumentListEntry(org.springframework.social.connect.Connection<org.springframework.social.google.docs.api.GoogleDocs> connection,
java.lang.String resourceId)
Retrieves the Google Docs entry for the Google document specified by the passed in resourceId parameter.
|
static java.lang.String |
getNewEmptyGoogleDocFileName(java.lang.String googleDocType)
Constructs a new file name depending on the provided Google document type and appending
a timestamp at the end to ensure uniqueness.
|
static boolean |
hasConcurrentEditors(org.springframework.social.connect.Connection<org.springframework.social.google.docs.api.GoogleDocs> connection,
int idleThreshold,
java.lang.String resourceId)
Checks if the specified Google document has any concurrent editors - any edits that have occurred in the passed in
amount of time (in seconds).
|
static java.lang.String |
saveGoogleDocumentToRepository(org.springframework.social.connect.Connection<org.springframework.social.google.docs.api.GoogleDocs> connection,
java.lang.String ticket,
java.lang.String objectId,
java.lang.String mimetype,
java.lang.String resourceId,
java.lang.String comment)
Saves the content of a Google document to the repository object specified by the passed in objectId.
|
static com.google.gdata.data.docs.DocumentListEntry |
uploadRepositoryObjectToGoogleDocument(org.springframework.social.connect.Connection<org.springframework.social.google.docs.api.GoogleDocs> connection,
java.io.File file,
java.lang.String filename,
java.lang.String mimetype)
Uploads the content of a repository object to a blank Google document and returns the
DocumentListEntry of the
resulting new Google document. |
public static java.lang.String getNewEmptyGoogleDocFileName(java.lang.String googleDocType)
googleDocType
- the Google doc type to use to generate the new file name.OCRuntimeException
- if the provided googleDocType parameter is not "document", "spreadsheet" or "presentation".public static void ensureSystemEnabled(boolean googleDocsEnabled)
OCRuntimeException
if the provided
boolean is false.googleDocsEnabled
- true if the Google docs system is enabled, false otherwise.OCRuntimeException
- if the Google docs system is disabled.public static com.google.gdata.data.docs.DocumentListEntry getDocumentListEntry(org.springframework.social.connect.Connection<org.springframework.social.google.docs.api.GoogleDocs> connection, java.lang.String resourceId)
connection
- the API connection to Google Docs.resourceId
- the resourceId representing the Google document that the information should be fetched for.DocumentListEntry
for the information for the fetched Google document.OCRuntimeException
- if there is an error retrieving the information for the specified Google Docs resource.public static java.lang.String createRepositoryGoogleDocFile(java.lang.String ticket, java.lang.String parentObjectId, java.lang.String objectType, java.lang.String googleDocType, org.springframework.core.io.Resource newGoogleDocFile)
Resource
file. This is a
blank Word document, Excel spreadsheet or PowerPoint presentation.ticket
- a valid OC ticket.parentObjectId
- the objectId of the parent object to create this new repo object in.objectType
- the object type of the new repo object to create.googleDocType
- the Google doc type of the new object we're creating so we can fetch the appropriate file extension for our new repo object.newGoogleDocFile
- the Resource to use for the input stream for the content of the new repo object we're creating.OCRuntimeException
- if the repository object creation fails.public static com.google.gdata.data.docs.DocumentListEntry createGoogleDocumentEntry(org.springframework.social.connect.Connection<org.springframework.social.google.docs.api.GoogleDocs> connection, java.lang.String objectName, java.lang.String googleDocType)
connection
- the API connection to Google Docs, used to get the Google Docs service for creating our new Google document.objectName
- the objectName of the Google document we're creating.googleDocType
- the type of the Google document to create "document", "spreadsheet" or "presentation" are supported.OCRuntimeException
- if an unsupported Google Docs type is provided or there's an error creating the new Google document.public static java.lang.String saveGoogleDocumentToRepository(org.springframework.social.connect.Connection<org.springframework.social.google.docs.api.GoogleDocs> connection, java.lang.String ticket, java.lang.String objectId, java.lang.String mimetype, java.lang.String resourceId, java.lang.String comment)
connection
- the API connection to Google Docs to fetch the Google document's content.ticket
- a valid OC ticket.objectId
- the objectId of the object to save the Google document's content to.mimetype
- the mimetype of the repository object so we export the Google document's content in the correct format.resourceId
- the identifier of the Google Document to download the content from.comment
- the comment to use as the new minor version comment.OCRuntimeException
- if the provided mimetype does not correspond to a supported Google Doc type ('document', 'spreadsheet', or 'presentation')
or if the saving of the document's content fails.public static com.google.gdata.data.docs.DocumentListEntry uploadRepositoryObjectToGoogleDocument(org.springframework.social.connect.Connection<org.springframework.social.google.docs.api.GoogleDocs> connection, java.io.File file, java.lang.String filename, java.lang.String mimetype)
DocumentListEntry
of the
resulting new Google document. The content to be uploaded needs to be passed in as a file as this method uses the
ResumableGDataFileUploader
to upload the content.connection
- the API connection to Google Docs to upload the content in the provided file to a new Google document.file
- the file containing the data to upload to a new Google document.filename
- the name of the new Google document to create.mimetype
- the mimetype of the new Google document to create.DocumentListEntry
specifying the information for the newly created Google document.OCRuntimeException
- if there's an error uploading the provided content to a new Google document.public static void deleteGoogleDocument(org.springframework.social.connect.Connection<org.springframework.social.google.docs.api.GoogleDocs> connection, java.lang.String resourceId)
connection
- the API connection to Google Docs to delete the specified Google document.resourceId
- the resourceId of the Google document to delete.OCRuntimeException
- if an error occurs attempting to delete the Google document.public static void checkOutNode(java.lang.String ticket, java.lang.String objectId)
OCRuntimeException
if an error occurs checking out the node.ticket
- a valid OC ticket.objectId
- the objectId of the repository object to check out.OCRuntimeException
- if an error occurs attempting to check out the specified object.public static boolean hasConcurrentEditors(org.springframework.social.connect.Connection<org.springframework.social.google.docs.api.GoogleDocs> connection, int idleThreshold, java.lang.String resourceId)
connection
- the API connection to Google Docs to check for any concurrent edits on the Google document.idleThreshold
- the amount of time in seconds to consider an edit "concurrent".resourceId
- the resourceId of the Google document to check for concurrent edits.OCRuntimeException
- if an error occurs attempting to check for concurrent edits.