Search in sources :

Example 1 with XmlFile

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;
}
Also used : BwPrincipal(org.bedework.calfacade.BwPrincipal) BwPreferences(org.bedework.calfacade.svc.BwPreferences) XmlFile(org.bedework.dumprestore.restore.XmlFile) File(java.io.File) XmlFile(org.bedework.dumprestore.restore.XmlFile) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException)

Aggregations

File (java.io.File)1 BwPrincipal (org.bedework.calfacade.BwPrincipal)1 CalFacadeException (org.bedework.calfacade.exc.CalFacadeException)1 BwPreferences (org.bedework.calfacade.svc.BwPreferences)1 XmlFile (org.bedework.dumprestore.restore.XmlFile)1