Package org.openl.rules.repository.zip
Class JarLocalRepository
- java.lang.Object
-
- org.openl.rules.repository.zip.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 Summary
Constructors Constructor Description JarLocalRepository()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description FileDatacheck(String name)Read a file descriptor by the given path name.FileDatacheckHistory(String name, String version)Read a file descriptor by the given path name of the given version.voidclose()FileDatacopyHistory(String srcName, FileData destData, String version)Copy a file of the given version to the destination file.booleandelete(List<FileData> data)Delete multiple files or mark it as deleted in one transaction.booleandelete(FileData data)Delete a file or mark it as deleted.booleandeleteHistory(FileData data)Delete a file from the history.protected intgetHashVersion(Path path)StringgetId()Get unique identifier for Repository.StringgetName()Get repository name shown on UI.voidinitialize()List<FileData>list(String path)Return a list of files recursively in the given folder.List<FileData>listFiles(String path, String version)Return a list of files recursively in the given folder and given version.List<FileData>listFolders(String path)Return a list of folders in the given path (not recursively).List<FileData>listHistory(String name)List a versions of the given file.FileItemread(String name)Read a file by the given path name.FileItemreadHistory(String name, String version)Read a file by the given path name of the given version.List<FileData>save(List<FileItem> fileItems)Save multiple projects in one transaction.FileDatasave(FileData data, InputStream stream)Save a file.FileDatasave(FileData folderData, Iterable<FileItem> files, ChangesetType changesetType)Save the folder.voidsetId(String id)voidsetListener(Listener callback)Set a listener to monitor changes in the repository.voidsetName(String name)Featuressupports()Get the features supported by the repository.static booleanzipArchiveFilter(Path path)Verifies if it's an archive-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.openl.rules.repository.api.Repository
validateConnection
-
-
-
-
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:
trueif it's archive, otherwisefalse- See Also:
- List of file signatures
-
setId
public void setId(String id)
-
getId
public String getId()
Description copied from interface:RepositoryGet unique identifier for Repository. Used to distinguish one repository from another. Must be unique.- Specified by:
getIdin interfaceRepository- Returns:
- repository id.
-
setName
public void setName(String name)
-
getName
public String getName()
Description copied from interface:RepositoryGet repository name shown on UI.- Specified by:
getNamein interfaceRepository- Returns:
- repository name
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceRepository
-
list
public List<FileData> list(String path) throws IOException
Description copied from interface:RepositoryReturn a list of files recursively in the given folder.- Specified by:
listin interfaceRepository- 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:FolderRepositoryReturn a list of folders in the given path (not recursively).- Specified by:
listFoldersin interfaceFolderRepository- 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.
-
getHashVersion
protected int getHashVersion(Path path) throws IOException
- Throws:
IOException
-
listFiles
public List<FileData> listFiles(String path, String version) throws IOException
Description copied from interface:FolderRepositoryReturn a list of files recursively in the given folder and given version.- Specified by:
listFilesin interfaceFolderRepository- 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:RepositoryRead a file by the given path name.- Specified by:
readin interfaceRepository- 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:RepositoryRead a file descriptor by the given path name.- Specified by:
checkin interfaceRepository- 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:RepositoryRead a file descriptor by the given path name of the given version. If the version is null, then it will work likeRepository.check(String)method.- Specified by:
checkHistoryin interfaceRepository- 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)
-
readHistory
public FileItem readHistory(String name, String version) throws IOException
Description copied from interface:RepositoryRead a file by the given path name of the given version. If the version is null, then it will work likeRepository.read(String)method.- Specified by:
readHistoryin interfaceRepository- 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.- See Also:
Repository.read(String)
-
supports
public Features supports()
Description copied from interface:RepositoryGet 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:
supportsin interfaceRepository- Returns:
- Supported features
-
save
public FileData save(FileData folderData, Iterable<FileItem> files, ChangesetType changesetType)
Description copied from interface:FolderRepositorySave the folder.- Specified by:
savein interfaceFolderRepository- Parameters:
folderData- folder descriptorfiles- all files inside the folder recursively or only changed (modified, added, deleted) files depending on changesetTypechangesetType- ifChangesetType.DIFF, only changed files. IfChangesetType.FULLall files that exist in project- Returns:
- the resulted folder descriptor after successful writing.
-
save
public FileData save(FileData data, InputStream stream)
Description copied from interface:RepositorySave a file.- Specified by:
savein interfaceRepository- 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:RepositorySave multiple projects in one transaction. Used only in deployment services- Specified by:
savein interfaceRepository- Parameters:
fileItems- list of file descriptor and stream pairs
-
delete
public boolean delete(FileData data)
Description copied from interface:RepositoryDelete a file or mark it as deleted.- Specified by:
deletein interfaceRepository- 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:RepositoryDelete multiple files or mark it as deleted in one transaction.- Specified by:
deletein interfaceRepository- 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:RepositorySet a listener to monitor changes in the repository.- Specified by:
setListenerin interfaceRepository- Parameters:
callback- the listener.
-
listHistory
public List<FileData> listHistory(String name)
Description copied from interface:RepositoryList 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 byRepository.read(String)method.- Specified by:
listHistoryin interfaceRepository- Parameters:
name- the file name.- Returns:
- the list of file descriptions.
-
deleteHistory
public boolean deleteHistory(FileData data)
Description copied from interface:RepositoryDelete a file from the history. If the version is null, then it will delete all versions of the file from the history.- Specified by:
deleteHistoryin interfaceRepository- 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:RepositoryCopy a file of the given version to the destination file. If the version is null, then copy latest version.- Specified by:
copyHistoryin interfaceRepository- 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.
-
-