Interface ExtRepository


public interface ExtRepository
Represents the external repository for Liferay's Document Library, providing utility methods for adding, deleting, retrieving, searching, and updating external repository file entries and folders.

Most data transferred in this class is in the external repository's domain format. For example, external repository data such as object keys and user names are strings expressed in the native external repository format.

One exception is the search(SearchContext, Query, ExtRepositoryQueryMapper) method where the Query contains Liferay identifiers and user names. To help with this, the ExtRepositoryQueryMapper instance can be used to translate such IDs to the native external repository format.

  • Method Details

    • addExtRepositoryFileEntry

      ExtRepositoryFileEntry addExtRepositoryFileEntry(String extRepositoryParentFolderKey, String fileName, String mimeType, String title, String description, String changeLog, InputStream inputStream) throws com.liferay.portal.kernel.exception.PortalException
      Adds an external repository file entry and associated metadata based on the InputStream object.
      Parameters:
      extRepositoryParentFolderKey - the primary key of the repository file entry's parent folder
      fileName - the repository file entry's file name
      mimeType - the repository file entry's MIME type
      title - the repository file entry's title
      description - the repository file entry's description
      changeLog - the repository file entry's version change log
      inputStream - the repository file entry's data (optionally null)
      Returns:
      the repository file entry
      Throws:
      com.liferay.portal.kernel.exception.PortalException - if the repository parent folder could not be found or if the repository file entry's information was invalid
    • addExtRepositoryFolder

      ExtRepositoryFolder addExtRepositoryFolder(String extRepositoryParentFolderKey, String name, String description) throws com.liferay.portal.kernel.exception.PortalException
      Adds an external repository folder.
      Parameters:
      extRepositoryParentFolderKey - the primary key of the repository folder's parent folder
      name - the repository folder's name
      description - the repository folder's description
      Returns:
      the repository folder
      Throws:
      com.liferay.portal.kernel.exception.PortalException - if the repository parent folder could not be found or if the repository folder's information was invalid
    • cancelCheckOut

      ExtRepositoryFileVersion cancelCheckOut(String extRepositoryFileEntryKey) throws com.liferay.portal.kernel.exception.PortalException
      Cancels the check out of the external repository file. If a user has not checked out the external repository file entry, invoking this method results in no changes.
      Parameters:
      extRepositoryFileEntryKey - the primary key of the repository file entry
      Returns:
      the discarded repository file version, or null if no version was available
      Throws:
      com.liferay.portal.kernel.exception.PortalException - if the repository file entry's information was invalid
    • checkInExtRepositoryFileEntry

      void checkInExtRepositoryFileEntry(String extRepositoryFileEntryKey, boolean createMajorVersion, String changeLog) throws com.liferay.portal.kernel.exception.PortalException
      Checks in the external repository file entry. If a user has not checked out the external repository file entry, invoking this method results in no changes.
      Parameters:
      extRepositoryFileEntryKey - the primary key of the repository file entry
      createMajorVersion - whether to increase the major or minor version number
      changeLog - the description of the changes being checked in
      Throws:
      com.liferay.portal.kernel.exception.PortalException - if the repository file entry's information was invalid
    • checkOutExtRepositoryFileEntry

      ExtRepositoryFileEntry checkOutExtRepositoryFileEntry(String extRepositoryFileEntryKey) throws com.liferay.portal.kernel.exception.PortalException
      Checks out the external repository file entry.
      Parameters:
      extRepositoryFileEntryKey - the primary key of the repository file entry
      Returns:
      the checked out repository file entry
      Throws:
      com.liferay.portal.kernel.exception.PortalException - if the repository file entry's information was invalid
    • copyExtRepositoryObject

      <T extends ExtRepositoryObject> T copyExtRepositoryObject(ExtRepositoryObjectType<T> extRepositoryObjectType, String extRepositoryFileEntryKey, String newExtRepositoryFolderKey, String newTitle) throws com.liferay.portal.kernel.exception.PortalException
      Copies the external repository object to a different parent folder.
      Parameters:
      extRepositoryObjectType - the repository object's type (file or folder)
      extRepositoryFileEntryKey - the primary key of the repository object
      newExtRepositoryFolderKey - the primary key of the repository destination folder
      newTitle - the new name of the repository object in the destination folder
      Returns:
      the repository object
      Throws:
      com.liferay.portal.kernel.exception.PortalException - if a portal exception occurred
    • deleteExtRepositoryObject

      void deleteExtRepositoryObject(ExtRepositoryObjectType<? extends ExtRepositoryObject> extRepositoryObjectType, String extRepositoryObjectKey) throws com.liferay.portal.kernel.exception.PortalException
      Deletes the external repository object.
      Parameters:
      extRepositoryObjectType - the repository object's type (file or folder)
      extRepositoryObjectKey - the primary key of the repository object
      Throws:
      com.liferay.portal.kernel.exception.PortalException - if a portal exception occurred
    • getAuthType

      String getAuthType()
    • getContentStream

      InputStream getContentStream(ExtRepositoryFileEntry extRepositoryFileEntry) throws com.liferay.portal.kernel.exception.PortalException
      Returns the content stream of the external repository file entry.
      Parameters:
      extRepositoryFileEntry - the primary key of the repository file entry
      Returns:
      the content stream of the repository file entry
      Throws:
      com.liferay.portal.kernel.exception.PortalException - if the repository file entry's information was invalid
    • getContentStream

      InputStream getContentStream(ExtRepositoryFileVersion extRepositoryFileVersion) throws com.liferay.portal.kernel.exception.PortalException
      Returns the content stream of the external repository file version.
      Parameters:
      extRepositoryFileVersion - the primary key of the repository file version
      Returns:
      the content stream of the repository file version
      Throws:
      com.liferay.portal.kernel.exception.PortalException - if the repository file version's information was invalid
    • getExtRepositoryFileVersion

      ExtRepositoryFileVersion getExtRepositoryFileVersion(ExtRepositoryFileEntry extRepositoryFileEntry, String version) throws com.liferay.portal.kernel.exception.PortalException
      Returns the external repository file version of the file entry, identified by the version name.
      Parameters:
      extRepositoryFileEntry - the primary key of the repository file entry
      version - the repository version name (e.g. 1.0)
      Returns:
      the repository file version of the file entry
      Throws:
      com.liferay.portal.kernel.exception.PortalException - if the repository file entry or version information was invalid
    • getExtRepositoryFileVersionDescriptor

      ExtRepositoryFileVersionDescriptor getExtRepositoryFileVersionDescriptor(String extRepositoryFileVersionKey)
      Returns the ExtRepositoryFileVersionDescriptor translated from the repository file version key. The descriptor describes the external repository file entry key and version name.
      Parameters:
      extRepositoryFileVersionKey - the repository file version's key
      Returns:
      the ExtRepositoryFileVersionDescriptor translated from the repository file version key
    • getExtRepositoryFileVersions

      List<ExtRepositoryFileVersion> getExtRepositoryFileVersions(ExtRepositoryFileEntry extRepositoryFileEntry) throws com.liferay.portal.kernel.exception.PortalException
      Returns the external repository file versions of the external repository file entry. The versions are ordered newest to oldest.
      Parameters:
      extRepositoryFileEntry - the primary key of the repository file entry
      Returns:
      the repository file versions of the repository file entry
      Throws:
      com.liferay.portal.kernel.exception.PortalException - if the repository file entry was invalid
    • getExtRepositoryObject

      <T extends ExtRepositoryObject> T getExtRepositoryObject(ExtRepositoryObjectType<T> extRepositoryObjectType, String extRepositoryObjectKey) throws com.liferay.portal.kernel.exception.PortalException
      Returns the external repository object matching the type and key.
      Parameters:
      extRepositoryObjectType - the repository object's type. Use ExtRepositoryObjectType.FILE, ExtRepositoryObjectType.FOLDER, or ExtRepositoryObjectType.OBJECT to specify file, folder, or both, respectively.
      extRepositoryObjectKey - the primary key of the repository object
      Returns:
      the repository object matching the type and key
      Throws:
      com.liferay.portal.kernel.exception.PortalException - if a portal exception occurred
    • getExtRepositoryObject

      <T extends ExtRepositoryObject> T getExtRepositoryObject(ExtRepositoryObjectType<T> extRepositoryObjectType, String extRepositoryFolderKey, String title) throws com.liferay.portal.kernel.exception.PortalException
      Returns the external repository object matching the type and title, in the parent folder.
      Parameters:
      extRepositoryObjectType - the repository object's type. Use ExtRepositoryObjectType.FILE, ExtRepositoryObjectType.FOLDER, or ExtRepositoryObjectType.OBJECT to specify file, folder, or both, respectively.
      extRepositoryFolderKey - the primary key of the repository object's parent folder
      title - the repository object's name
      Returns:
      the repository object matching the type and title, in the parent folder
      Throws:
      com.liferay.portal.kernel.exception.PortalException - if a portal exception occurred
    • getExtRepositoryObjects

      <T extends ExtRepositoryObject> List<T> getExtRepositoryObjects(ExtRepositoryObjectType<T> extRepositoryObjectType, String extRepositoryFolderKey) throws com.liferay.portal.kernel.exception.PortalException
      Returns the external repository objects matching the type, in the parent folder. Depending on the repository object type requested, this method may return only repository files, only repository folders, or both repository files and folders.
      Parameters:
      extRepositoryObjectType - the type of repository objects to return. Use ExtRepositoryObjectType.FILE, ExtRepositoryObjectType.FOLDER, or ExtRepositoryObjectType.OBJECT to specify file, folder, or both, respectively.
      extRepositoryFolderKey - the primary key of the repository folder to search
      Returns:
      the repository objects matching the type, in the parent folder
      Throws:
      com.liferay.portal.kernel.exception.PortalException - if a portal exception occurred
    • getExtRepositoryObjectsCount

      int getExtRepositoryObjectsCount(ExtRepositoryObjectType<? extends ExtRepositoryObject> extRepositoryObjectType, String extRepositoryFolderKey) throws com.liferay.portal.kernel.exception.PortalException
      Returns the number of elements in the external repository folder matching the object type. Depending on the repository object type requested, this method may only return the number of repository files, the number of repository folders, or the combined number of repository files and folders.
      Parameters:
      extRepositoryObjectType - the repository object type to count. Use ExtRepositoryObjectType.FILE, ExtRepositoryObjectType.FOLDER, or ExtRepositoryObjectType.OBJECT to specify file, folder, or both, respectively.
      extRepositoryFolderKey - the primary key of the repository folder to search
      Returns:
      the number of elements in the repository folder matching the object type
      Throws:
      com.liferay.portal.kernel.exception.PortalException - if a portal exception occurred
    • getExtRepositoryParentFolder

      ExtRepositoryFolder getExtRepositoryParentFolder(ExtRepositoryObject extRepositoryObject) throws com.liferay.portal.kernel.exception.PortalException
      Returns the external repository parent folder of the external repository object.
      Parameters:
      extRepositoryObject - the repository object (file or folder)
      Returns:
      the repository parent folder of the repository object
      Throws:
      com.liferay.portal.kernel.exception.PortalException - if the repository object's information was invalid
    • getLiferayLogin

      String getLiferayLogin(String extRepositoryLogin)
      Returns the Liferay login value, which is mapped from the user's external repository login value. A Liferay login value can be a user ID, screen name, email, etc, depending on the value returned by the getAuthType() method. The format of the repository login is specific for each repository implementation.
      Parameters:
      extRepositoryLogin - the user's repository login value
      Returns:
      the Liferay login value, which is mapped from the user's repository login value
    • getRootFolderKey

      String getRootFolderKey() throws com.liferay.portal.kernel.exception.PortalException
      Returns the primary key of the external repository root folder.
      Returns:
      the primary key of the repository root folder
      Throws:
      com.liferay.portal.kernel.exception.PortalException - if the repository root folder could not be accessed
    • getSubfolderKeys

      List<String> getSubfolderKeys(String extRepositoryFolderKey, boolean recurse) throws com.liferay.portal.kernel.exception.PortalException
      Returns the keys of the external repository subfolders stored inside the external repository folder.
      Parameters:
      extRepositoryFolderKey - the primary key of the repository folder
      recurse - whether to recurse through each repository subfolder
      Returns:
      the keys of the repository subfolders stored inside the repository folder
      Throws:
      com.liferay.portal.kernel.exception.PortalException - if the repository folder's information was invalid
    • getSupportedConfigurations

      String[] getSupportedConfigurations()
      Returns the supported configurations for the external repository. Each configuration may have a different list of supported parameters.
      Returns:
      the supported configurations for the repository
      See Also:
    • getSupportedParameters

      String[][] getSupportedParameters()
      Returns the supported external repository configuration parameters indexed by configuration type. These parameters are stored in the database when the repository is configured and made available through a UnicodeProperties object passed to the initRepository(UnicodeProperties, CredentialsProvider) method.
      Returns:
      the supported repository configuration parameters indexed by configuration type
      See Also:
    • initRepository

      void initRepository(com.liferay.portal.kernel.util.UnicodeProperties typeSettingsUnicodeProperties, CredentialsProvider credentialsProvider) throws com.liferay.portal.kernel.exception.PortalException
      Initializes the external repository and checks the connectivity between the external repository and Liferay Portal.

      This method uses the credentials provided by the CredentialsProvider object to authenticate to the repository. In addition, the method acquires the repository-specific configuration parameters from the type settings properties parameter. The parameters contained in the type settings properties parameter object are indexed by the key names returned by the getSupportedParameters() method. This method is called only once, the first time the repository is used.

      Parameters:
      typeSettingsUnicodeProperties - the type settings properties
      credentialsProvider - the Liferay Portal username and password
      Throws:
      com.liferay.portal.kernel.exception.PortalException - if a portal exception occurred
    • moveExtRepositoryObject

      <T extends ExtRepositoryObject> T moveExtRepositoryObject(ExtRepositoryObjectType<T> extRepositoryObjectType, String extRepositoryObjectKey, String newExtRepositoryFolderKey, String newTitle) throws com.liferay.portal.kernel.exception.PortalException
      Moves the external repository object to a different location. This method can also be used to rename repository objects.
      Parameters:
      extRepositoryObjectType - the repository object's type (file or folder)
      extRepositoryObjectKey - the primary key of the repository object
      newExtRepositoryFolderKey - the primary key of the destination repository folder
      newTitle - the new name of the repository object (may not change)
      Returns:
      the repository object
      Throws:
      com.liferay.portal.kernel.exception.PortalException - if the repository object could not be moved or if a portal exception occurred
    • search

      List<ExtRepositorySearchResult<?>> search(com.liferay.portal.kernel.search.SearchContext searchContext, com.liferay.portal.kernel.search.Query query, ExtRepositoryQueryMapper extRepositoryQueryMapper) throws com.liferay.portal.kernel.exception.PortalException
      Returns the external repository objects fulfilling the query. There may be some limitations due to back-end repository constraints.

      The limitations are repository specific, which means there is a specific set of constraints for each type of external repository (Documentum, SharePoint, etc). This method is given a Query object, which is a logic expression matching Lucene's capabilities. Implementors of external repositories must map that query to a native repository query. Some external repositories may be missing some of Lucene's capabilities, so the query may not be fully translated.

      Parameters:
      searchContext - the search context to be applied. The folder ID, start bound, and end bound attributes must be set in this search context.
      query - the logical expression describing the query to be performed. This may need to be translated to an equivalent native repository query.
      extRepositoryQueryMapper - the repository query mapper to translate Liferay IDs to the native repository format
      Returns:
      the repository objects fulfilling the query
      Throws:
      com.liferay.portal.kernel.exception.PortalException - if a portal exception occurred
    • updateExtRepositoryFileEntry

      ExtRepositoryFileEntry updateExtRepositoryFileEntry(String extRepositoryFileEntryKey, String mimeType, InputStream inputStream) throws com.liferay.portal.kernel.exception.PortalException
      Updates the external repository file entry's content.
      Parameters:
      extRepositoryFileEntryKey - the primary key of the repository file entry
      mimeType - the repository file entry's MIME type
      inputStream - the new repository file entry's content
      Returns:
      the updated file entry
      Throws:
      com.liferay.portal.kernel.exception.PortalException - if a portal exception occurred