org.exoplatform.clouddrive.gdrive
Class JCRLocalGoogleDrive

java.lang.Object
  extended by org.exoplatform.clouddrive.CloudDrive
      extended by org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive
          extended by org.exoplatform.clouddrive.gdrive.JCRLocalGoogleDrive
All Implemented Interfaces:
org.exoplatform.clouddrive.oauth2.UserTokenRefreshListener

public class JCRLocalGoogleDrive
extends org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive
implements org.exoplatform.clouddrive.oauth2.UserTokenRefreshListener

JCR local storage for Google Drive. Created by The eXo Platform SAS.

Version:
$Id: JCRLocalGoogleDrive.java 00000 Sep 13, 2012 pnedonosko $
Author:
Peter Nedonosko

Nested Class Summary
protected  class JCRLocalGoogleDrive.Connect
          Connect algorithm for Google Drive.
protected  class JCRLocalGoogleDrive.FileAPI
           
protected  class JCRLocalGoogleDrive.Sync
          Sync algorithm for Google Drive.
 
Nested classes/interfaces inherited from class org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive
org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive.AbstractCommand, org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive.AbstractFileAPI, org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive.CommandCallable, org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive.ConnectCommand, org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive.ExoJCREnvironment, org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive.ExoJCRSettings, org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive.FileChange, org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive.JCRListener, org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive.NoConnectCommand, org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive.NoSyncCommand, org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive.SyncCommand, org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive.SyncFilesCommand
 
Nested classes/interfaces inherited from class org.exoplatform.clouddrive.CloudDrive
org.exoplatform.clouddrive.CloudDrive.Command, org.exoplatform.clouddrive.CloudDrive.CommandProgress, org.exoplatform.clouddrive.CloudDrive.ListenerSupport
 
Field Summary
 
Fields inherited from class org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive
accentsConverter, actionDrive, ALREADY_DONE, commandEnv, commandExecutor, CURRENT_LOCALFORMAT, currentChangeId, currentConnect, currentSync, DUMMY_DATA, ECD_CLOUDDRIVE, ECD_CLOUDFILE, ECD_CLOUDFILERESOURCE, ECD_CLOUDFOLDER, ECD_IGNORED, ECD_LOCALFORMAT, EXO_DATETIME, EXO_MODIFY, EXO_THUMBNAIL, EXO_THUMBNAILS, EXO_TRASHFOLDER, fileAPI, fileChanges, fileChangeSequencer, fileCopies, fileHistory, fileRemovals, fileSynchronizers, fileTrash, finder, HISTORY_EXPIRATION, HISTORY_MAX_LENGTH, jcrListener, MIX_REFERENCEABLE, noConnect, noSyncCommand, NT_FILE, NT_FOLDER, NT_RESOURCE, NT_UNSTRUCTURED, repository, rootNodeHolder, rootUUID, rootWorkspace, sessionProviders, syncLock, user, USER_NODEPATH, USER_SESSIONPROVIDER, USER_WORKSPACE
 
Fields inherited from class org.exoplatform.clouddrive.CloudDrive
listeners, LOG
 
Constructor Summary
protected JCRLocalGoogleDrive(org.exoplatform.clouddrive.gdrive.GoogleDriveConnector.API apiBuilder, GoogleProvider provider, javax.jcr.Node driveNode, org.exoplatform.services.jcr.ext.app.SessionProviderService sessionProviders, org.exoplatform.clouddrive.jcr.NodeFinder finder)
          Create drive by loading it from local JCR node.
protected JCRLocalGoogleDrive(GoogleUser user, javax.jcr.Node driveNode, org.exoplatform.services.jcr.ext.app.SessionProviderService sessionProviders, org.exoplatform.clouddrive.jcr.NodeFinder finder)
          Create newly connecting drive.
 
Method Summary
protected  boolean checkAccessScope(org.exoplatform.clouddrive.CloudDriveAccessException cause)
          Throw RefreshAccessException if currently coded scope doesn't match the one used by the drive access tokens.
protected  org.exoplatform.clouddrive.CloudFileAPI createFileAPI()
          
protected  org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive.ConnectCommand getConnectCommand()
          
 String getState()
          
protected  org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive.SyncCommand getSyncCommand()
          
 GoogleUser getUser()
          
protected  void initDrive(javax.jcr.Node driveNode)
          
protected  boolean isAccessScopeMatch()
          Check if currently coded scope match the one used by the drive access tokens.
protected static GoogleUser loadUser(org.exoplatform.clouddrive.gdrive.GoogleDriveConnector.API apiBuilder, GoogleProvider provider, javax.jcr.Node driveNode)
          Load user from the drive Node.
protected  List<com.google.api.services.drive.model.ParentReference> mergeParents(String parentId, List<com.google.api.services.drive.model.ParentReference> cloudParents, Collection<String> localParentIds)
          Merge file's local and cloud parents (in case of move replace source on destination).
 void onUserTokenRefresh(org.exoplatform.clouddrive.oauth2.UserToken token)
          
protected  Long readChangeId()
          
protected  void refreshAccess()
          
protected  void saveChangeId(Long id)
          
protected  void updateAccess(org.exoplatform.clouddrive.CloudUser newUser)
          
 
Methods inherited from class org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive
addJCRListener, checkTrashed, cleanName, cleanNode, cleanRemoved, cleanup, cleanUpdated, commitChanges, configure, connect, copyNode, createIfNotCloudFile, disconnect, editLink, fileNode, findNode, findNodes, getChangeId, getConnectDate, getFile, getId, getInitDate, getLink, getLocalUser, getOrCleanFileNode, getPath, getTitle, hasFile, hasRemoved, hasUpdated, initCommon, initCopy, initFile, initFolder, initRemove, isConnected, isDrive, isDrive, isDrive, isSameDrive, listFiles, listFiles, listFiles, loadHistory, migrateName, moveFile, nextChangeId, openFile, openFolder, previewLink, readFile, readNode, readNodes, removeJCRListener, rollback, rootName, rootNode, rootTitle, saveChanges, savedChanges, session, setChangeId, synchronize, systemSession, title, tryCreateCloudFile
 
Methods inherited from class org.exoplatform.clouddrive.CloudDrive
addListener, removeListener, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JCRLocalGoogleDrive

protected JCRLocalGoogleDrive(GoogleUser user,
                              javax.jcr.Node driveNode,
                              org.exoplatform.services.jcr.ext.app.SessionProviderService sessionProviders,
                              org.exoplatform.clouddrive.jcr.NodeFinder finder)
                       throws org.exoplatform.clouddrive.CloudDriveException,
                              javax.jcr.RepositoryException
Create newly connecting drive.

Parameters:
user -
driveNode -
sessionProviders -
Throws:
org.exoplatform.clouddrive.CloudDriveException
javax.jcr.RepositoryException

JCRLocalGoogleDrive

protected JCRLocalGoogleDrive(org.exoplatform.clouddrive.gdrive.GoogleDriveConnector.API apiBuilder,
                              GoogleProvider provider,
                              javax.jcr.Node driveNode,
                              org.exoplatform.services.jcr.ext.app.SessionProviderService sessionProviders,
                              org.exoplatform.clouddrive.jcr.NodeFinder finder)
                       throws javax.jcr.RepositoryException,
                              GoogleDriveException,
                              org.exoplatform.clouddrive.CloudDriveException
Create drive by loading it from local JCR node.

Parameters:
apiBuilder - GoogleDriveConnector.API API builder
provider - GoogleProvider
driveNode - Node root of the drive
sessionProviders -
Throws:
javax.jcr.RepositoryException - if local storage error
org.exoplatform.clouddrive.CloudDriveException - if cannot load tokens stored locally
GoogleDriveException - if error communicating with Google Drive services
Method Detail

loadUser

protected static GoogleUser loadUser(org.exoplatform.clouddrive.gdrive.GoogleDriveConnector.API apiBuilder,
                                     GoogleProvider provider,
                                     javax.jcr.Node driveNode)
                              throws javax.jcr.RepositoryException,
                                     GoogleDriveException,
                                     org.exoplatform.clouddrive.CloudDriveException
Load user from the drive Node.

Parameters:
apiBuilder - GoogleDriveConnector.API API builder
provider - GoogleProvider
driveNode - Node root of the drive
Returns:
GoogleUser
Throws:
javax.jcr.RepositoryException
GoogleDriveException
org.exoplatform.clouddrive.CloudDriveException

getUser

public GoogleUser getUser()

Specified by:
getUser in class org.exoplatform.clouddrive.CloudDrive

getState

public String getState()

Specified by:
getState in class org.exoplatform.clouddrive.CloudDrive

onUserTokenRefresh

public void onUserTokenRefresh(org.exoplatform.clouddrive.oauth2.UserToken token)
                        throws org.exoplatform.clouddrive.CloudDriveException

Specified by:
onUserTokenRefresh in interface org.exoplatform.clouddrive.oauth2.UserTokenRefreshListener
Throws:
org.exoplatform.clouddrive.CloudDriveException

refreshAccess

protected void refreshAccess()
                      throws GoogleDriveException

Specified by:
refreshAccess in class org.exoplatform.clouddrive.CloudDrive
Throws:
GoogleDriveException

updateAccess

protected void updateAccess(org.exoplatform.clouddrive.CloudUser newUser)
                     throws org.exoplatform.clouddrive.CloudDriveException,
                            javax.jcr.RepositoryException

Specified by:
updateAccess in class org.exoplatform.clouddrive.CloudDrive
Throws:
org.exoplatform.clouddrive.CloudDriveException
javax.jcr.RepositoryException

isAccessScopeMatch

protected boolean isAccessScopeMatch()
                              throws javax.jcr.RepositoryException,
                                     org.exoplatform.clouddrive.DriveRemovedException
Check if currently coded scope match the one used by the drive access tokens.

Throws:
org.exoplatform.clouddrive.DriveRemovedException
javax.jcr.RepositoryException

checkAccessScope

protected boolean checkAccessScope(org.exoplatform.clouddrive.CloudDriveAccessException cause)
                            throws javax.jcr.RepositoryException,
                                   org.exoplatform.clouddrive.RefreshAccessException,
                                   org.exoplatform.clouddrive.DriveRemovedException
Throw RefreshAccessException if currently coded scope doesn't match the one used by the drive access tokens.

Parameters:
cause - CloudDriveAccessException
Returns:
false if access coded and currently used access scopes match, otherwise RefreshAccessException will be thrown with given cause CloudDriveAccessException
Throws:
javax.jcr.RepositoryException
org.exoplatform.clouddrive.RefreshAccessException
org.exoplatform.clouddrive.DriveRemovedException

readChangeId

protected Long readChangeId()
                     throws javax.jcr.RepositoryException,
                            org.exoplatform.clouddrive.CloudDriveException

Specified by:
readChangeId in class org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive
Throws:
javax.jcr.RepositoryException
org.exoplatform.clouddrive.CloudDriveException

saveChangeId

protected void saveChangeId(Long id)
                     throws org.exoplatform.clouddrive.CloudDriveException,
                            javax.jcr.RepositoryException

Specified by:
saveChangeId in class org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive
Throws:
org.exoplatform.clouddrive.CloudDriveException
javax.jcr.RepositoryException

initDrive

protected void initDrive(javax.jcr.Node driveNode)
                  throws org.exoplatform.clouddrive.CloudDriveException,
                         javax.jcr.RepositoryException

Overrides:
initDrive in class org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive
Throws:
org.exoplatform.clouddrive.CloudDriveException
javax.jcr.RepositoryException

getConnectCommand

protected org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive.ConnectCommand getConnectCommand()
                                                                                      throws org.exoplatform.clouddrive.DriveRemovedException,
                                                                                             javax.jcr.RepositoryException

Specified by:
getConnectCommand in class org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive
Throws:
org.exoplatform.clouddrive.DriveRemovedException
javax.jcr.RepositoryException

getSyncCommand

protected org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive.SyncCommand getSyncCommand()
                                                                                throws org.exoplatform.clouddrive.DriveRemovedException,
                                                                                       org.exoplatform.clouddrive.SyncNotSupportedException,
                                                                                       javax.jcr.RepositoryException

Specified by:
getSyncCommand in class org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive
Throws:
org.exoplatform.clouddrive.DriveRemovedException
org.exoplatform.clouddrive.SyncNotSupportedException
javax.jcr.RepositoryException

createFileAPI

protected org.exoplatform.clouddrive.CloudFileAPI createFileAPI()
                                                         throws org.exoplatform.clouddrive.DriveRemovedException,
                                                                org.exoplatform.clouddrive.SyncNotSupportedException,
                                                                javax.jcr.RepositoryException

Specified by:
createFileAPI in class org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive
Throws:
org.exoplatform.clouddrive.DriveRemovedException
org.exoplatform.clouddrive.SyncNotSupportedException
javax.jcr.RepositoryException

mergeParents

protected List<com.google.api.services.drive.model.ParentReference> mergeParents(String parentId,
                                                                                 List<com.google.api.services.drive.model.ParentReference> cloudParents,
                                                                                 Collection<String> localParentIds)
Merge file's local and cloud parents (in case of move replace source on destination).

Parameters:
parentId - String current local parent id
cloudParents - List of ParentReference on cloud side
localParentIds - List of parent ids locally
Returns:


Copyright © 2003–2014 eXo Platform SAS. All rights reserved.