use of org.bedework.dumprestore.restore.XmlFile in project bw-calendar-engine by Bedework.
the class RestorePrincipal method doRestore.
/**
* Restore everything owned by this principal
*
* @throws CalFacadeException on error
*/
public boolean doRestore() throws CalFacadeException {
try {
final String prPath = topPath();
final File pdir = Utils.directory(prPath);
if (pdir == null) {
addInfo("No user data found at " + prPath);
return false;
}
final XmlFile prXml = new XmlFile(pdir, "principal.xml", false);
final XmlFile prefsXml = new XmlFile(pdir, "preferences.xml", false);
final BwPrincipal pr = fxml.fromXml(prXml.getRoot(), BwUser.class, BwPrincipal.getRestoreCallback());
final BwPreferences prefs = fxml.fromXml(prefsXml.getRoot(), BwPreferences.class, BwPreferences.getRestoreCallback());
incCount(Counters.users);
incCount(Counters.userPrefs);
if (getGlobals().getDryRun()) {
info(pr.toString());
info(prefs.toString());
} else {
getRi().restorePrincipal(pr);
getRi().restoreUserPrefs(prefs);
}
restoreCategories();
restoreContacts();
restoreLocations();
restoreCollections();
} catch (final CalFacadeException ce) {
throw ce;
} catch (final Throwable t) {
throw new CalFacadeException(t);
}
return true;
}
Aggregations