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 void
close()
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.String
getName()
Get the name of this repository defined by the iris.scripts.repos property.String
getScriptBodyByDisplayPath(String displayPath)
Get the body of a script file via the display path.String
getScriptBodyByDisplayPath(String displayPath, ScriptPathLoaderState state)
Get the specified script at the specified state.String
getScriptBodyByRelativePath(String relativePath)
Get the body of a script file via the relative path.String
getScriptBodyByRelativePath(String relativePath, ScriptPathLoaderState state)
Get the specified script at the specified state.ScriptPathLoaderState
getState()
Get astate
object that represents the current branch HEAD commit.void
lock()
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)
void
refresh()
Refresh the loader internally.void
unlock()
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 astate
object that represents the current branch HEAD commit.- Specified by:
getState
in interfaceScriptPathLoader
- Returns:
- The current branch HEAD or null if updates were disabled.
-
lock
public void lock()Description copied from interface:ScriptPathLoader
Acquire 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:
lock
in interfaceScriptPathLoader
-
unlock
public void unlock()Description copied from interface:ScriptPathLoader
Release a previously acquired read lock.- Specified by:
unlock
in interfaceScriptPathLoader
-
getAvailableScriptDisplayPaths
- Specified by:
getAvailableScriptDisplayPaths
in interfaceScriptPathLoader
- Returns:
- The display paths currently available from this loader.
-
getScriptBodyByDisplayPath
Get the body of a script file via the display path.- Specified by:
getScriptBodyByDisplayPath
in 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:
getScriptBodyByRelativePath
in 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:ScriptPathLoader
Gets the display paths available from this loader when it was in the specifiedstate
.- Specified by:
getAvailableScriptDisplayPaths
in 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:ScriptPathLoader
Get the specified script at the specified state.- Specified by:
getScriptBodyByRelativePath
in 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:ScriptPathLoader
Get the specified script at the specified state.- Specified by:
getScriptBodyByDisplayPath
in 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:ScriptPathLoader
Refresh the loader internally. Will respect existing read locks.- Specified by:
refresh
in interfaceScriptPathLoader
-
close
public void close()Description copied from interface:ScriptPathLoader
Free resources associated with this loader.- Specified by:
close
in 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)
-