Class JarLocalRepository

  • All Implemented Interfaces:
    Closeable, AutoCloseable, FolderRepository, Repository

    public class JarLocalRepository
    extends Object
    Read only implementation of Jar Repository to support deploying of jars from classpath as it is without unzipping to temporary directories.

    NOTE: This repository type doesn't support write actions!

    Author:
    Vladyslav Pikus
    • Constructor Detail

      • JarLocalRepository

        public JarLocalRepository()
    • Method Detail

      • initialize

        public void initialize()
      • zipArchiveFilter

        public static boolean zipArchiveFilter​(Path path)
        Verifies if it's an archive
        Parameters:
        path - path to archive
        Returns:
        true if it's archive, otherwise false
        See Also:
        List of file signatures
      • setId

        public void setId​(String id)
      • getId

        public String getId()
        Description copied from interface: Repository
        Get unique identifier for Repository. Used to distinguish one repository from another. Must be unique.
        Specified by:
        getId in interface Repository
        Returns:
        repository id.
      • setName

        public void setName​(String name)
      • getName

        public String getName()
        Description copied from interface: Repository
        Get repository name shown on UI.
        Specified by:
        getName in interface Repository
        Returns:
        repository name
      • list

        public List<FileData> list​(String path)
                            throws IOException
        Description copied from interface: Repository
        Return a list of files recursively in the given folder.
        Specified by:
        list in interface Repository
        Parameters:
        path - the folder to scan. The path must be ended by '/' or be empty.
        Returns:
        the list of the file descriptors. Invalid files are ignored.
        Throws:
        IOException - if not possible to read the directory.
      • listFolders

        public List<FileData> listFolders​(String path)
                                   throws IOException
        Description copied from interface: FolderRepository
        Return a list of folders in the given path (not recursively).
        Specified by:
        listFolders in interface FolderRepository
        Parameters:
        path - the folder to scan. The path must be ended by '/' or be empty.
        Returns:
        the list of the folder descriptors. Invalid folders are ignored.
        Throws:
        IOException - if not possible to read the directory.
      • listFiles

        public List<FileData> listFiles​(String path,
                                        String version)
                                 throws IOException
        Description copied from interface: FolderRepository
        Return a list of files recursively in the given folder and given version.
        Specified by:
        listFiles in interface FolderRepository
        Parameters:
        path - the folder to scan. The path must be ended by '/' or be empty.
        version - the version of the folder to read, can be null.
        Returns:
        the list of the file descriptors. Invalid files are ignored.
        Throws:
        IOException - if not possible to read the directory.
      • read

        public FileItem read​(String name)
                      throws IOException
        Description copied from interface: Repository
        Read a file by the given path name.
        Specified by:
        read in interface Repository
        Parameters:
        name - the path name of the file to read.
        Returns:
        the file descriptor or null if the file is absent.
        Throws:
        IOException - if not possible to read the file.
      • check

        public FileData check​(String name)
                       throws IOException
        Description copied from interface: Repository
        Read a file descriptor by the given path name.
        Specified by:
        check in interface Repository
        Parameters:
        name - the path name of the file to read.
        Returns:
        the file descriptor or null if the file is absent.
        Throws:
        IOException - if not possible to read the file descriptor.
      • checkHistory

        public FileData checkHistory​(String name,
                                     String version)
                              throws IOException
        Description copied from interface: Repository
        Read a file descriptor by the given path name of the given version. If the version is null, then it will work like Repository.check(String) method.
        Specified by:
        checkHistory in interface Repository
        Parameters:
        name - the path name of the file to read.
        version - the version of the file to read, can be null.
        Returns:
        the file descriptor or null if the file is absent.
        Throws:
        IOException - if not possible to read the file descriptor.
        See Also:
        Repository.read(String)
      • supports

        public Features supports()
        Description copied from interface: Repository
        Get the features supported by the repository. If specific feature is supported, repository instance can be casted to interface class that support that feature.
        Specified by:
        supports in interface Repository
        Returns:
        Supported features
      • save

        public FileData save​(FileData data,
                             InputStream stream)
        Description copied from interface: Repository
        Save a file.
        Specified by:
        save in interface Repository
        Parameters:
        data - the file descriptor.
        stream - the stream to save with the specified file descriptor.
        Returns:
        the resulted file descriptor after successful writing.
      • save

        public List<FileData> save​(List<FileItem> fileItems)
        Description copied from interface: Repository
        Save multiple projects in one transaction. Used only in deployment services
        Specified by:
        save in interface Repository
        Parameters:
        fileItems - list of file descriptor and stream pairs
      • delete

        public boolean delete​(FileData data)
        Description copied from interface: Repository
        Delete a file or mark it as deleted.
        Specified by:
        delete in interface Repository
        Parameters:
        data - the file descriptor to delete.
        Returns:
        true if file has been deleted successfully or false if the file is absent.
      • delete

        public boolean delete​(List<FileData> data)
                       throws IOException
        Description copied from interface: Repository
        Delete multiple files or mark it as deleted in one transaction.
        Specified by:
        delete in interface Repository
        Parameters:
        data - list of files to delete
        Returns:
        true if at least one file is deleted
        Throws:
        IOException - if not possible to delete the file
      • setListener

        public void setListener​(Listener callback)
        Description copied from interface: Repository
        Set a listener to monitor changes in the repository.
        Specified by:
        setListener in interface Repository
        Parameters:
        callback - the listener.
      • listHistory

        public List<FileData> listHistory​(String name)
        Description copied from interface: Repository
        List a versions of the given file. If the repository does not support file versions, then it will return one record of the given file. The order of the file descriptions is undefined, but the first element is the actual file which can be access by Repository.read(String) method.
        Specified by:
        listHistory in interface Repository
        Parameters:
        name - the file name.
        Returns:
        the list of file descriptions.
      • deleteHistory

        public boolean deleteHistory​(FileData data)
        Description copied from interface: Repository
        Delete a file from the history. If the version is null, then it will delete all versions of the file from the history.
        Specified by:
        deleteHistory in interface Repository
        Parameters:
        data - the file descriptor to delete. The fields "name", "version", "author" and "comment" must be initialized.
        Returns:
        true if file has been deleted successfully or false if the file is absent.
        See Also:
        Repository.delete(FileData)
      • copyHistory

        public FileData copyHistory​(String srcName,
                                    FileData destData,
                                    String version)
        Description copied from interface: Repository
        Copy a file of the given version to the destination file. If the version is null, then copy latest version.
        Specified by:
        copyHistory in interface Repository
        Parameters:
        srcName - the file to copy.
        destData - the destination file descriptor.
        version - the version of the file to copy
        Returns:
        the file descriptor of the resulted file.