Class GuvnorRepository

  • All Implemented Interfaces:
    Repository

    @Alternative
    public class GuvnorRepository
    extends Object
    implements Repository
    Repository implementation that is using Guvnor as a storage
    • Constructor Detail

      • GuvnorRepository

        public GuvnorRepository()
    • Method Detail

      • getName

        public String getName()
        Description copied from interface: Repository
        Returns name used to identify this repository.
        Specified by:
        getName in interface Repository
      • listDirectories

        public Collection<Directory> listDirectories​(String startAt)
        Description copied from interface: Repository
        Retrieves all directories stored under startAt location. NOTE: Directory should be always relative to the repository root
        Specified by:
        listDirectories in interface Repository
        Parameters:
        startAt - - location where directories should be fetched from
        Returns:
        - list of directories
      • listAssetsRecursively

        public Collection<Asset> listAssetsRecursively​(String startAt,
                                                       Filter filter)
        Description copied from interface: Repository
        Retrieves all directories stored under startAt location including all sub folders. NOTE: Directory should be always relative to the repository root
        Specified by:
        listAssetsRecursively in interface Repository
        Parameters:
        startAt - - location where directories should be fetched from
        filter - - filter that allows to narrow the results
        Returns:
        - list of assets found
      • createDirectory

        public Directory createDirectory​(String location)
        Description copied from interface: Repository
        Stores new directory in given location, in case of sub folders existence in the location all sub folders are created as well.
        Specified by:
        createDirectory in interface Repository
        Parameters:
        location - - location in the repository to be created
        Returns:
        - returns identifier of the new directory
      • directoryExists

        public boolean directoryExists​(String directory)
        Description copied from interface: Repository
        Examines repository if given directory exists in the repository NOTE: Directory should be always relative to the repository root
        Specified by:
        directoryExists in interface Repository
        Parameters:
        directory - - directory to check
        Returns:
        - true if and only if given directory exists
      • deleteDirectory

        public boolean deleteDirectory​(String directory,
                                       boolean failIfNotEmpty)
        Description copied from interface: Repository
        Deletes directory from repository including its content NOTE: Directory should be always relative to the repository root
        Specified by:
        deleteDirectory in interface Repository
        Parameters:
        directory - - directory to be deleted
        failIfNotEmpty - - indicates if delete operation should fail in case given directory is not empty
      • copyDirectory

        public boolean copyDirectory​(String uniqueId,
                                     String location)
        Description copied from interface: Repository
        Copy directory given by uniqueId into destination given by location
        Specified by:
        copyDirectory in interface Repository
        Parameters:
        uniqueId - - source directory path relative to repository root
        location - - destination where directory will be copied to
        Returns:
        - true when copy operation was successful otherwise false
      • moveDirectory

        public boolean moveDirectory​(String uniqueId,
                                     String location,
                                     String name)
        Description copied from interface: Repository
        Moves directory given by uniqueId into destination given by location and renames it with given name
        Specified by:
        moveDirectory in interface Repository
        Parameters:
        uniqueId - - source directory path relative to repository root
        location - - final destination where directory should be moved to
        name - - name of the directory after move, if null is given name is not changed
        Returns:
        - returns true if move operation was successful otherwise false
      • listAssets

        public Collection<Asset> listAssets​(String location)
        Description copied from interface: Repository
        Retrieves all assets stored in the given location. NOTE: This will not load the actual content of the asset but only its meta data
        Specified by:
        listAssets in interface Repository
        Parameters:
        location - - location that assets should be collected from
        Returns:
        - list of available assets
      • listAssets

        public Collection<Asset> listAssets​(String location,
                                            Filter filter)
        Description copied from interface: Repository
        Retrieves all assets stored in the given location. NOTE: This will not load the actual content of the asset but only its meta data
        Specified by:
        listAssets in interface Repository
        Parameters:
        location - - location that assets should be collected from
        filter - - allows to defined filter criteria to fetch only assets of interest
        Returns:
        - list of available assets
      • loadAsset

        public Asset loadAsset​(String assetUniqueId)
                        throws org.uberfire.java.nio.file.NoSuchFileException
        Description copied from interface: Repository
        Loads an asset given by the assetUniqueId including actual content of the asset.
        Specified by:
        loadAsset in interface Repository
        Parameters:
        assetUniqueId - - unique identifier of the asset to load
        Returns:
        return loaded asset including content
        Throws:
        org.uberfire.java.nio.file.NoSuchFileException - - throws in case of asset given by id does not exist
      • loadAssetFromPath

        public Asset loadAssetFromPath​(String path)
                                throws org.uberfire.java.nio.file.NoSuchFileException
        Description copied from interface: Repository
        Loads an asset given by the path including actual content of the asset.
        Specified by:
        loadAssetFromPath in interface Repository
        Parameters:
        path - - complete path of the asset to load (relative to the repository root)
        Returns:
        return loaded asset including content
        Throws:
        org.uberfire.java.nio.file.NoSuchFileException - - throws in case of asset given by id does not exist
      • createAsset

        public String createAsset​(Asset asset)
        Description copied from interface: Repository
        Stores given asset in the repository. asset need to have all meta data and content available for the operation to successfully complete.
        Specified by:
        createAsset in interface Repository
        Parameters:
        asset - - asset to be stored
        Returns:
        returns asset unique identifier that can be used to locate it
      • updateAsset

        public String updateAsset​(Asset asset,
                                  String commitMessage,
                                  String sessionId)
                           throws org.uberfire.java.nio.file.NoSuchFileException
        Description copied from interface: Repository
        Updates content of the asset
        Specified by:
        updateAsset in interface Repository
        Parameters:
        asset - - asset to be stored with new content in it, all other data (like name, location) should be same
        Returns:
        - returns uniqueId of the asset
        Throws:
        org.uberfire.java.nio.file.NoSuchFileException - - throws in case of asset given by id does not exist
      • deleteAsset

        public boolean deleteAsset​(String assetUniqueId)
        Description copied from interface: Repository
        Deletes asset from repository identified by assetUniqueId if exists
        Specified by:
        deleteAsset in interface Repository
        Parameters:
        assetUniqueId - - unique identifier of the asset
        Returns:
        return true if and only if operation completed successfully otherwise false
      • deleteAssetFromPath

        public boolean deleteAssetFromPath​(String path)
        Description copied from interface: Repository
        Deletes asset from repository given by the path if exists
        Specified by:
        deleteAssetFromPath in interface Repository
        Parameters:
        path - - complete path of the asset to delete
        Returns:
        return true if and only if operation completed successfully otherwise false
      • assetExists

        public boolean assetExists​(String assetUniqueId)
        Description copied from interface: Repository
        Examines repository if asset given by the assetUniqueId exists
        Specified by:
        assetExists in interface Repository
        Parameters:
        assetUniqueId - - unique identifier of the asset
        Returns:
        true if and only if asset exists otherwise false
      • copyAsset

        public boolean copyAsset​(String uniqueId,
                                 String location)
        Description copied from interface: Repository
        Copy asset given by uniqueId into destination given by location
        Specified by:
        copyAsset in interface Repository
        Parameters:
        uniqueId - - source asset unique id
        location - - destination where asset will be copied to
        Returns:
        - true when copy operation was successful otherwise false
      • moveAsset

        public boolean moveAsset​(String uniqueId,
                                 String location,
                                 String name)
        Description copied from interface: Repository
        Moves asset given by uniqueId into destination given by location and renames it with given name
        Specified by:
        moveAsset in interface Repository
        Parameters:
        uniqueId - - source asset unique id
        location - - final destination where asset should be moved to
        name - - name of the asset after move, if null is given name is not changed
        Returns:
        - returns true if move operation was successful otherwise false