Package com.illumon.iris.db.util.scripts
Class ScriptRepository
java.lang.Object
com.illumon.iris.db.util.scripts.ScriptRepository
- All Implemented Interfaces:
ScriptPathLoader
public class ScriptRepository extends Object implements ScriptPathLoader
A ScriptPathLoader that loads scripts from a git repository.
If this class is created with updateEnabled = false it loads scripts as if no git repository was present.
-
Method Summary
Modifier and Type Method Description voidclose()Free resources associated with this loader.Set<String>getAvailableScriptDisplayPaths()Set<String>getAvailableScriptDisplayPaths(ScriptPathLoaderState state)Gets the display paths available from this loader when it was in the specifiedstate.Set<String>getGroupNames()Get the users allowed to access this repo, defined by the iris.scripts.repo.[name].users property.StringgetName()Get the name of this repository defined by the iris.scripts.repos property.StringgetScriptBodyByDisplayPath(String displayPath)Get the body of a script file via the display path.StringgetScriptBodyByDisplayPath(String displayPath, ScriptPathLoaderState state)Get the specified script at the specified state.StringgetScriptBodyByRelativePath(String relativePath)Get the body of a script file via the relative path.StringgetScriptBodyByRelativePath(String relativePath, ScriptPathLoaderState state)Get the specified script at the specified state.ScriptPathLoaderStategetState()Get astateobject that represents the current branch HEAD commit.voidlock()Acquire a read lock.static List<ScriptRepository>readRepoConfigs(com.fishlib.configuration.Configuration config, String propertyPrefix, com.fishlib.io.logger.Logger log, boolean globalUpdateEnabled, boolean globalGcEnabled, String defaultBranch, boolean resetGitLockFiles)static List<ScriptRepository>readRepoConfigsForUser(com.fishlib.configuration.Configuration config, String propertyPrefix, com.fishlib.io.logger.Logger log, String userName)static List<ScriptRepository>readRepoConfigsForUser(com.fishlib.configuration.Configuration config, String propertyPrefix, com.fishlib.io.logger.Logger log, String userName, IrisGroupProvider groupProvider)voidrefresh()Refresh the loader internally.voidunlock()Release a previously acquired read lock.
-
Method Details
-
getName
Get the name of this repository defined by the iris.scripts.repos property.- Returns:
- The name of this repo.
-
getGroupNames
Get the users allowed to access this repo, defined by the iris.scripts.repo.[name].users property.- Returns:
- The names of all users allowed to access the repo.
-
getState
Get astateobject that represents the current branch HEAD commit.- Specified by:
getStatein interfaceScriptPathLoader- Returns:
- The current branch HEAD or null if updates were disabled.
-
lock
public void lock()Description copied from interface:ScriptPathLoaderAcquire a read lock. Use before invoking any of the get* methods, and hold for as long as consistency is required for this loader.- Specified by:
lockin interfaceScriptPathLoader
-
unlock
public void unlock()Description copied from interface:ScriptPathLoaderRelease a previously acquired read lock.- Specified by:
unlockin interfaceScriptPathLoader
-
getAvailableScriptDisplayPaths
- Specified by:
getAvailableScriptDisplayPathsin interfaceScriptPathLoader- Returns:
- The display paths currently available from this loader.
-
getScriptBodyByDisplayPath
Get the body of a script file via the display path.- Specified by:
getScriptBodyByDisplayPathin interfaceScriptPathLoader- Parameters:
displayPath- The display path to load a script for.- Returns:
- A String representing the body of the script.
- Throws:
IOException- If the file is not accessible.
-
getScriptBodyByRelativePath
Get the body of a script file via the relative path.- Specified by:
getScriptBodyByRelativePathin interfaceScriptPathLoader- Parameters:
relativePath- The relative path to load a script for.- Returns:
- A String representing the body of the script
- Throws:
IOException- If the file is not accessible
-
getAvailableScriptDisplayPaths
Description copied from interface:ScriptPathLoaderGets the display paths available from this loader when it was in the specifiedstate.- Specified by:
getAvailableScriptDisplayPathsin interfaceScriptPathLoader- Parameters:
state- The state of the loader to use when retrieving the list.- Returns:
- A list of all display paths available when the loader was in the specified state.
- Throws:
IOException- If a problem occurred loading the script.
-
getScriptBodyByRelativePath
public String getScriptBodyByRelativePath(String relativePath, ScriptPathLoaderState state) throws IOExceptionDescription copied from interface:ScriptPathLoaderGet the specified script at the specified state.- Specified by:
getScriptBodyByRelativePathin interfaceScriptPathLoader- Parameters:
relativePath- The relative path to the script.state- The state of the loader.- Returns:
- The script at relativePath at the specified state.
- Throws:
IOException- If a problem occurred loading the script.
-
getScriptBodyByDisplayPath
public String getScriptBodyByDisplayPath(String displayPath, ScriptPathLoaderState state) throws IOExceptionDescription copied from interface:ScriptPathLoaderGet the specified script at the specified state.- Specified by:
getScriptBodyByDisplayPathin interfaceScriptPathLoader- Parameters:
displayPath- The display path to the script.state- The state of the loader.- Returns:
- The script at displayPath at the specified state.
- Throws:
IOException- If a problem occurred loading the script.
-
refresh
public void refresh()Description copied from interface:ScriptPathLoaderRefresh the loader internally. Will respect existing read locks.- Specified by:
refreshin interfaceScriptPathLoader
-
close
public void close()Description copied from interface:ScriptPathLoaderFree resources associated with this loader.- Specified by:
closein interfaceScriptPathLoader
-
readRepoConfigs
public static List<ScriptRepository> readRepoConfigs(@NotNull com.fishlib.configuration.Configuration config, @NotNull String propertyPrefix, @NotNull com.fishlib.io.logger.Logger log, boolean globalUpdateEnabled, boolean globalGcEnabled, @Nullable String defaultBranch, boolean resetGitLockFiles) -
readRepoConfigsForUser
public static List<ScriptRepository> readRepoConfigsForUser(@NotNull com.fishlib.configuration.Configuration config, @NotNull String propertyPrefix, @NotNull com.fishlib.io.logger.Logger log, @NotNull String userName, @NotNull IrisGroupProvider groupProvider) -
readRepoConfigsForUser
public static List<ScriptRepository> readRepoConfigsForUser(@NotNull com.fishlib.configuration.Configuration config, @NotNull String propertyPrefix, @NotNull com.fishlib.io.logger.Logger log, @NotNull String userName)
-