Class OneDriveAPI


  • public class OneDriveAPI
    extends Object
    The Class OneDriveAPI.
    • Field Detail

      • SCOPES

        public static final String SCOPES
        The Constant SCOPES.
    • Method Detail

      • createLink

        public com.microsoft.graph.models.extensions.SharingLink createLink​(String itemId,
                                                                            String type)
                                                                     throws OneDriveException
        Creates a public link to view a file content. Currently at 23/08/2019, the business account does not support the 'embed' link type (24.06.2020 the same). We use short lived embeddable links for business accounts
        Parameters:
        itemId - the item id
        type - must be view or embed
        Returns:
        the sharing link
        Throws:
        OneDriveException - the one drive exception
      • updateToken

        public void updateToken​(org.exoplatform.services.cms.clouddrives.onedrive.OneDriveStoredToken newToken)
                         throws org.exoplatform.services.cms.clouddrives.CloudDriveException
        Update token.
        Parameters:
        newToken - the new token
        Throws:
        org.exoplatform.services.cms.clouddrives.CloudDriveException - the cloud drive exception
      • removeFolder

        public void removeFolder​(String fileId)
        Removes the folder.
        Parameters:
        fileId - the file id
      • removeFile

        public void removeFile​(String fileId)
        Removes the file.
        Parameters:
        fileId - the file id
      • getUser

        public com.microsoft.graph.models.extensions.User getUser()
        Gets the user.
        Returns:
        the user
      • getRootId

        public String getRootId()
        Gets the root id.
        Returns:
        id of the root folder on the user's drive.
      • getUserId

        public String getUserId()
        Gets the user id.
        Returns:
        the user id
      • createFolder

        public com.microsoft.graph.models.extensions.DriveItem createFolder​(String parentId,
                                                                            String name,
                                                                            Calendar created)
        Creates the folder.
        Parameters:
        parentId - the parent id
        name - the name
        created - the created
        Returns:
        the drive item
      • copyFile

        public com.microsoft.graph.models.extensions.DriveItem copyFile​(String parentId,
                                                                        String fileName,
                                                                        String fileId)
                                                                 throws IOException,
                                                                        org.exoplatform.services.cms.clouddrives.CloudDriveException
        Copy file.
        Parameters:
        parentId - the parent id
        fileName - the file name
        fileId - the file id
        Returns:
        the drive item
        Throws:
        IOException - Signals that an I/O exception has occurred.
        org.exoplatform.services.cms.clouddrives.CloudDriveException - the cloud drive exception
      • copyFolder

        public com.microsoft.graph.models.extensions.DriveItem copyFolder​(String parentId,
                                                                          String name,
                                                                          String folderId)
                                                                   throws org.exoplatform.services.cms.clouddrives.CloudDriveException,
                                                                          IOException
        Copy folder.
        Parameters:
        parentId - the parent id
        name - the name
        folderId - the folder id
        Returns:
        the drive item
        Throws:
        org.exoplatform.services.cms.clouddrives.CloudDriveException - the cloud drive exception
        IOException - Signals that an I/O exception has occurred.
      • getStoredToken

        public org.exoplatform.services.cms.clouddrives.onedrive.OneDriveStoredToken getStoredToken()
        Gets the stored token.
        Returns:
        the stored token
      • getNotificationUrl

        @Deprecated
        public String getNotificationUrl()
        Deprecated.
        Gets the notification url.
        Returns:
        the notification url
      • getSubscription

        public com.microsoft.graph.models.extensions.Subscription getSubscription()
        Subscribes to receive drive changes using web socket.
        Returns:
        the subscription
      • copy

        public com.microsoft.graph.models.extensions.DriveItem copy​(String parentId,
                                                                    String fileName,
                                                                    String fileId,
                                                                    boolean isFile)
                                                             throws org.exoplatform.services.cms.clouddrives.RefreshAccessException,
                                                                    OneDriveException
        Copy.
        Parameters:
        parentId - the parent id
        fileName - the file name
        fileId - the file id
        isFile - the is file
        Returns:
        the drive item
        Throws:
        org.exoplatform.services.cms.clouddrives.RefreshAccessException - the refresh access exception
        OneDriveException - the one drive exception
      • getDriveItemCollectionPage

        public com.microsoft.graph.requests.extensions.IDriveItemCollectionPage getDriveItemCollectionPage​(String folderId)
        Gets a list of children of the folder, with pagination.
        Parameters:
        folderId - the folder id
        Returns:
        the drive item collection page
      • getFiles

        @Deprecated
        public List<com.microsoft.graph.models.extensions.DriveItem> getFiles​(String folderId)
        Deprecated.
        Gets the files.
        Parameters:
        folderId - the folder id
        Returns:
        the files
      • changes

        public org.exoplatform.services.cms.clouddrives.onedrive.OneDriveAPI.ChangesIterator changes​(String deltaToken)
        Changes.
        Parameters:
        deltaToken - starting from which to get changes.
        Returns:
        OneDriveAPI.ChangesIterator
      • getInsertUploadUrl

        public String getInsertUploadUrl​(String parentId,
                                         String name,
                                         String conflictBehavior)
                                  throws org.exoplatform.services.cms.clouddrives.RefreshAccessException,
                                         OneDriveException
        Gets url on which uploading should be done.
        Parameters:
        parentId - where should the new file be added.
        name - the name
        conflictBehavior - determines the behavior if a file with the name is already present. must be 'fail' or 'rename';
        Returns:
        url to upload the file. see the insertUpdate(String, InputStream)
        Throws:
        org.exoplatform.services.cms.clouddrives.RefreshAccessException - the refresh access exception
        OneDriveException - the one drive exception
      • insert

        public com.microsoft.graph.models.extensions.DriveItem insert​(String parentId,
                                                                      String fileName,
                                                                      Calendar created,
                                                                      Calendar modified,
                                                                      InputStream inputStream,
                                                                      String conflictBehavior)
                                                               throws OneDriveException
        Insert.
        Parameters:
        parentId - the parent id
        fileName - the file name
        created - the created
        modified - the modified
        inputStream - the input stream
        conflictBehavior - the conflict behavior
        Returns:
        the drive item
        Throws:
        OneDriveException - the one drive exception
      • updateFileContent

        public com.microsoft.graph.models.extensions.DriveItem updateFileContent​(String itemId,
                                                                                 Calendar created,
                                                                                 Calendar modified,
                                                                                 InputStream inputStream)
                                                                          throws OneDriveException
        Update file content.
        Parameters:
        itemId - the item id
        created - the created
        modified - the modified
        inputStream - the input stream
        Returns:
        the drive item
        Throws:
        OneDriveException - the one drive exception
      • getAllFiles

        public org.exoplatform.services.cms.clouddrives.onedrive.DeltaDriveFiles getAllFiles()
        Gets all the drive items.
        Returns:
        DeltaDriveFiles
      • updateFile

        public com.microsoft.graph.models.extensions.DriveItem updateFile​(com.microsoft.graph.models.extensions.DriveItem driveItem)
        Update file.
        Parameters:
        driveItem - the drive item
        Returns:
        the drive item
      • getItem

        public com.microsoft.graph.models.extensions.DriveItem getItem​(String itemId)
        Gets the item.
        Parameters:
        itemId - the item id
        Returns:
        the item
      • getDrive

        public com.microsoft.graph.models.extensions.Drive getDrive()
        Gets the current user drive.
        Returns:
        Drive the drive
      • getBusinessPreviewLink

        public String getBusinessPreviewLink​(String itemId)
        Gets short-lived embeddable URLs for an item (currently only for OneDrive business account by documentation).
        Parameters:
        itemId - the item id
        Returns:
        the preview link
      • getSimpleChildIterator

        public org.exoplatform.services.cms.clouddrives.onedrive.OneDriveAPI.SimpleChildIterator getSimpleChildIterator​(Collection<org.exoplatform.services.cms.clouddrives.onedrive.HashSetCompatibleDriveItem> items)
                                                                                                                 throws org.exoplatform.services.cms.clouddrives.CloudDriveException
        Gets the simple child iterator.
        Parameters:
        items - the items
        Returns:
        the simple child iterator
        Throws:
        org.exoplatform.services.cms.clouddrives.CloudDriveException - the cloud drive exception
      • getChildIterator

        public org.exoplatform.services.cms.clouddrives.onedrive.OneDriveAPI.ChildIterator getChildIterator​(String folderId)
        Gets the child iterator.
        Parameters:
        folderId - the folder id
        Returns:
        the child iterator