Package org.syncany.config
Class DaemonConfigHelper
- java.lang.Object
-
- org.syncany.config.DaemonConfigHelper
-
public class DaemonConfigHelper extends java.lang.Object
The daemon helper provides helper functions to read and/or write the daemon configuration file as defined byDaemonConfigTO
.
-
-
Constructor Summary
Constructors Constructor Description DaemonConfigHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
addFolder(java.io.File localDir)
Adds the given folder to the user-specific daemon configuration (daemon.xml
).static DaemonConfigTO
createAndWriteDaemonConfig(java.io.File configFile, java.util.List<FolderTO> folders)
static DaemonConfigTO
createAndWriteDefaultDaemonConfig(java.io.File daemonConfigFile)
static DaemonConfigTO
createAndWriteExampleDaemonConfig(java.io.File daemonConfigFile)
static UserTO
getFirstDaemonUser(DaemonConfigTO daemonConfig)
static boolean
removeFolder(java.io.File localDir)
static boolean
removeFolder(java.lang.String localDirIdentifier)
-
-
-
Constructor Detail
-
DaemonConfigHelper
public DaemonConfigHelper()
-
-
Method Detail
-
getFirstDaemonUser
public static UserTO getFirstDaemonUser(DaemonConfigTO daemonConfig)
-
addFolder
public static boolean addFolder(java.io.File localDir) throws ConfigException
Adds the given folder to the user-specific daemon configuration (daemon.xml
).The method first reads the daemon configuration, checks if the folder is already present and adds it if it is not. If no daemon config file exists, a new default config file is created via
createAndWriteDefaultDaemonConfig(File)
. If the folder is already present in the current daemon config,false
is returned. If an error occurs (e.g. an I/O error or an invalid XML file), aConfigException
is thrown. If the folder was successfully added,true
is returned.- Parameters:
localDir
- Absolute path of the local folder to add to the daemon config- Returns:
- Returns
true
if the folder was successfully added to the daemon config,false
otherwise - Throws:
ConfigException
- If an error occurs, e.g. an I/O error or an invalid XML file
-
removeFolder
public static boolean removeFolder(java.io.File localDir) throws ConfigException
- Throws:
ConfigException
-
removeFolder
public static boolean removeFolder(java.lang.String localDirIdentifier) throws ConfigException
- Throws:
ConfigException
-
createAndWriteDefaultDaemonConfig
public static DaemonConfigTO createAndWriteDefaultDaemonConfig(java.io.File daemonConfigFile) throws ConfigException
- Throws:
ConfigException
-
createAndWriteExampleDaemonConfig
public static DaemonConfigTO createAndWriteExampleDaemonConfig(java.io.File daemonConfigFile) throws ConfigException
- Throws:
ConfigException
-
createAndWriteDaemonConfig
public static DaemonConfigTO createAndWriteDaemonConfig(java.io.File configFile, java.util.List<FolderTO> folders) throws ConfigException
- Throws:
ConfigException
-
-