added delete-config sub command

This commit is contained in:
Sebastian Sdorra
2011-05-19 14:47:44 +02:00
parent a1c1feb349
commit 75a11d5f89
4 changed files with 88 additions and 4 deletions

View File

@@ -118,6 +118,15 @@ public class ScmClientConfig
return config;
}
/**
* Method description
*
*/
public void delete()
{
fileHandler.delete();
}
/**
* Method description
*

View File

@@ -101,9 +101,7 @@ public class ScmClientConfigFileHandler
*/
public ScmClientConfigFileHandler()
{
Preferences prefs =
Preferences.userNodeForPackage(ScmClientConfigFileHandler.class);
prefs = Preferences.userNodeForPackage(ScmClientConfigFileHandler.class);
key = prefs.get(PREF_SECRET_KEY, null);
if (Util.isEmpty(key))
@@ -125,6 +123,22 @@ public class ScmClientConfigFileHandler
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*/
public void delete()
{
File configFile = getConfigFile();
if (configFile.exists() &&!configFile.delete())
{
throw new ScmConfigException("could not delete config file");
}
prefs.remove(PREF_SECRET_KEY);
}
/**
* Method description
*
@@ -286,4 +300,7 @@ public class ScmClientConfigFileHandler
/** Field description */
private String key;
/** Field description */
private Preferences prefs;
}