Package org.syncany.config
Class ConfigHelper
- java.lang.Object
-
- org.syncany.config.ConfigHelper
-
public class ConfigHelper extends java.lang.Object
The config helper provides convenience functions to load the configuration from the local application repo.
-
-
Constructor Summary
Constructors Constructor Description ConfigHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanconfigExists(java.io.File localDir)Returns true if the config.xml file exists, given a local directory.static java.io.FilefindLocalDirInPath(java.io.File startingPath)Helper method to find the local sync directory, starting from a path equal or inside the local sync directory.static ConfigloadConfig(java.io.File localDir)Loads aConfigobject from the given local directory.static ConfigTOloadConfigTO(java.io.File localDir)Loads the config transfer object from the local directory or throws an exception if the file does not exist.static RepoTOloadRepoTO(java.io.File localDir, ConfigTO configTO)Loads the repository transfer object from the local directory.
-
-
-
Constructor Detail
-
ConfigHelper
public ConfigHelper()
-
-
Method Detail
-
loadConfig
public static Config loadConfig(java.io.File localDir) throws ConfigException
Loads aConfigobject from the given local directory.If the config file (.syncany/config.xml) does not exist,
nullis returned. If it does, the method tries to do the following:- Load the .syncany/config.xml file and load the plugin given by the config file
- Read .syncany/repo, decrypt it using the master key (if necessary) and load it
- Instantiate a
Configobject with the transfer objects
- Returns:
- Returns an instantiated
Configobject, ornullif the config file does not exist - Throws:
ConfigException- an exception if the config is invalid
-
configExists
public static boolean configExists(java.io.File localDir)
Returns true if the config.xml file exists, given a local directory.
-
loadConfigTO
public static ConfigTO loadConfigTO(java.io.File localDir) throws ConfigException
Loads the config transfer object from the local directory or throws an exception if the file does not exist.- Throws:
ConfigException
-
loadRepoTO
public static RepoTO loadRepoTO(java.io.File localDir, ConfigTO configTO) throws ConfigException
Loads the repository transfer object from the local directory.- Throws:
ConfigException
-
findLocalDirInPath
public static java.io.File findLocalDirInPath(java.io.File startingPath)
Helper method to find the local sync directory, starting from a path equal or inside the local sync directory. If the starting path is not inside or equal to the local directory,nullis returned.To find the local directory, the method looks for a file named "
Config.DIR_APPLICATION/Config.FILE_CONFIG". If it is found, it stops. If not, it continues looking in the parent directory.Example: If /home/user/Syncany is the local sync directory and /home/user/NotSyncany is not a local directory, the method will return the following:
- findLocalDirInPath(/home/user/Syncany) -> /home/user/Syncany
- findLocalDirInPath(/home/user/Syncany/some/subfolder) -> /home/user/Syncany
- findLocalDirInPath(/home/user/NotSyncany) ->null
- Parameters:
startingPath- Path to start the search from- Returns:
- Returns the local directory (if found), or
nullotherwise
-
-