Class BoxFilesManager

java.lang.Object
org.apache.camel.component.box.api.BoxFilesManager

public class BoxFilesManager extends Object
Provides operations to manage Box files.
  • Constructor Details

    • BoxFilesManager

      public BoxFilesManager(com.box.sdk.BoxAPIConnection boxConnection)
      Create files manager to manage the files of Box connection's authenticated user.
      Parameters:
      boxConnection - - Box connection to authenticated user account.
  • Method Details

    • getFileInfo

      public com.box.sdk.BoxFile.Info getFileInfo(String fileId, String... fields)
      Get file information.
      Parameters:
      fileId - - the id of file.
      fields - - the information fields to retrieve; if null all information fields are retrieved.
      Returns:
      The file information.
    • updateFileInfo

      public com.box.sdk.BoxFile updateFileInfo(String fileId, com.box.sdk.BoxFile.Info info)
      Update file information.
      Parameters:
      fileId - - the id of file to update.
      info - - the updated information
      Returns:
      The updated file.
    • uploadFile

      public com.box.sdk.BoxFile uploadFile(String parentFolderId, InputStream content, String fileName, Date created, Date modified, Long size, Boolean check, com.box.sdk.ProgressListener listener)
      Upload a new file to parent folder.
      Parameters:
      parentFolderId - - the id of parent folder.
      content - - a stream containing contents of the file to upload.
      fileName - the name to give the uploaded file.
      created - - the content created date that will be given to the uploaded file.
      modified - - the content modified date that will be given to the uploaded file.
      size - - the size of the file's content used for monitoring the upload's progress.
      check - - if the file name is already used, call the uploadNewVersion instead.
      listener - - a listener for monitoring the upload's progress.
      Returns:
      The uploaded file.
    • uploadNewFileVersion

      public com.box.sdk.BoxFile uploadNewFileVersion(String fileId, InputStream fileContent, Date modified, Long fileSize, com.box.sdk.ProgressListener listener)
      Upload a new version of file.
      Parameters:
      fileId - - the id of file.
      fileContent - - a stream containing contents of the file to upload.
      modified - - the content modified date that will be given to the uploaded file.
      fileSize - - the size of the file's content used for monitoring the upload's progress.
      listener - - a listener for monitoring the upload's progress.
      Returns:
      The uploaded file.
    • getFileVersions

      public Collection<com.box.sdk.BoxFileVersion> getFileVersions(String fileId)
      Get any previous versions of file.
      Parameters:
      fileId - - the id of file.
      Returns:
      The list of previous file versions.
    • downloadFile

      public OutputStream downloadFile(String fileId, OutputStream output, Long rangeStart, Long rangeEnd, com.box.sdk.ProgressListener listener)
      Download a file.
      Parameters:
      fileId - - the id of file.
      output - - the stream to which the file contents will be written.
      rangeStart - - the byte offset in file at which to start the download; if null the entire contents of file will be downloaded.
      rangeEnd - - the byte offset in file at which to stop the download; if null the entire contents of file will be downloaded.
      listener - - a listener for monitoring the download's progress; if null the download's progress will not be monitored.
      Returns:
      The stream containing the contents of the downloaded file.
    • downloadPreviousFileVersion

      public OutputStream downloadPreviousFileVersion(String fileId, Integer version, OutputStream output, com.box.sdk.ProgressListener listener)
      Download a previous version of file.
      Parameters:
      fileId - - the id of file.
      version - - the version of file to download; initial version of file has value of 0, second version of file is 1 and so on.
      output - - the stream to which the version contents will be written.
      listener - - a listener for monitoring the download's progress; if null the download's progress will not be monitored.
      Returns:
      The stream containing the contents of the downloaded file version.
    • promoteFileVersion

      public com.box.sdk.BoxFileVersion promoteFileVersion(String fileId, Integer version)
      Promote a previous version of file.
      Parameters:
      fileId - - the id of file.
      version - - the version of file to promote; initial version of file has value of 0, second version of file is 1 and so on.
      Returns:
      The promoted version of file.
    • copyFile

      public com.box.sdk.BoxFile copyFile(String fileId, String destinationFolderId, String newName)
      Copy file to destination folder while optionally giving it a new name.
      Parameters:
      fileId - - the id of file to copy.
      destinationFolderId - - the id of the destination folder.
      newName - - the new name for copied file; if newName is null, the copied file has same name as the original.
      Returns:
      The copied file.
    • moveFile

      public com.box.sdk.BoxFile moveFile(String fileId, String destinationFolderId, String newName)
      Move file to destination folder while optionally giving it a new name.
      Parameters:
      fileId - - the id of file to move.
      destinationFolderId - - the id of the destination folder.
      newName - - the new name of moved file; if newName is null, the moved file has same name as the original.
      Returns:
      The moved file.
    • renameFile

      public com.box.sdk.BoxFile renameFile(String fileId, String newFileName)
      Rename file giving it the name newName
      Parameters:
      fileId - - the id of file to rename.
      newFileName - - the new name of file.
      Returns:
      The renamed file.
    • deleteFile

      public void deleteFile(String fileId)
      Delete the file.
      Parameters:
      fileId - - the id of file to delete.
    • deleteFileVersion

      public void deleteFileVersion(String fileId, Integer version)
      Delete a file version.
      Parameters:
      fileId - - the id of file with version to delete.
      version - - the version of file to delete; initial version of file has value of 0, second version of file is 1 and so on.
    • createFileSharedLink

      public com.box.sdk.BoxSharedLink createFileSharedLink(String fileId, com.box.sdk.BoxSharedLink.Access access, Date unshareDate, com.box.sdk.BoxSharedLink.Permissions permissions)
      Create a shared link to file.
      Parameters:
      fileId - - the id of the file to create shared link on.
      access - - the access level of the shared link.
      unshareDate - - the date and time at which time the created shared link will expire; if unsharedDate is null then a non-expiring link is created.
      permissions - - the permissions of the created link; if permissions is null then the created shared link is created with default permissions.
      Returns:
      The created shared link.
    • getDownloadURL

      public URL getDownloadURL(String fileId)
      Get an expiring URL for downloading a file directly from Box. This can be user, for example, for sending as a redirect to a browser to cause the browser to download the file directly from Box.
      Parameters:
      fileId - - the id of file.
      Returns:
      The temporary download URL
    • getFilePreviewLink

      public URL getFilePreviewLink(String fileId)
      Get an expiring URL for creating an embedded preview session. The URL will expire after 60 seconds and the preview session will expire after 60 minutes.
      Parameters:
      fileId - - the id of the file to get preview link on.
      Returns:
      The preview link.
    • createFileMetadata

      public com.box.sdk.Metadata createFileMetadata(String fileId, com.box.sdk.Metadata metadata, String typeName)
      Create metadata for file in either the global properties template or the specified template type.
      Parameters:
      fileId - - the id of the file to create metadata for.
      metadata - - the new metadata values.
      typeName - - the metadata template type name; if null the global properties template type is used.
      Returns:
      The metadata returned from the server.
    • getFileMetadata

      public com.box.sdk.Metadata getFileMetadata(String fileId, String typeName)
      Gets the file properties metadata.
      Parameters:
      fileId - - the id of the file to retrieve metadata for.
      typeName - - the metadata template type name; if null the global properties template type is used.
      Returns:
      The metadata returned from the server.
    • updateFileMetadata

      public com.box.sdk.Metadata updateFileMetadata(String fileId, com.box.sdk.Metadata metadata)
      Update the file properties metadata.
      Parameters:
      fileId - - the id of file to delete.
      metadata - - the new metadata values.
      Returns:
      The metadata returned from the server.
    • deleteFileMetadata

      public void deleteFileMetadata(String fileId)
      Delete the file properties metadata.
      Parameters:
      fileId - - the id of file to delete.
    • checkUpload

      public void checkUpload(String fileName, String parentFolderId, Long size)
      Does a pre-verification before upload, to check if the filename already exists or if there is permission to upload. It will throw a BoxAPIResponseException if there is any problem in uploading the given file.
      Parameters:
      fileName - the name to give the uploaded file.
      parentFolderId - - the id of parent folder.
      size - - the size of the file's content used for monitoring the upload's progress.