}
}
private static void restoreWithGui(final String username, final String password, final String dbaPassword, final File f, final String uri) {
final GuiRestoreListener listener = new GuiRestoreListener();
final Callable<Void> callable = new Callable<Void>() {
@Override
public Void call() throws Exception {
final Restore restore = new Restore();
try {
restore.restore(listener, username, password, dbaPassword, f, uri);
listener.hideDialog();
if (JOptionPane.showConfirmDialog(null, "Would you like to rebuild the application repository?\nThis is only necessary if application packages were restored.", "Rebuild App Repository?",
JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
System.out.println("Rebuilding application repository ...");
try {
String rootURI = uri;
if(!(rootURI.contains(XmldbURI.ROOT_COLLECTION) || rootURI.endsWith( XmldbURI.ROOT_COLLECTION))) {
rootURI += XmldbURI.ROOT_COLLECTION;
}
final Collection root = DatabaseManager.getCollection(rootURI, username, dbaPassword);
ClientFrame.repairRepository(root);
System.out.println("Application repository rebuilt successfully.");
} catch (XMLDBException e) {
reportError(e);
System.err.println("Rebuilding application repository failed!");
}
}
} catch (final Exception e) {
ClientFrame.showErrorMessage(e.getMessage(), null); //$NON-NLS-1$
} finally {
if(listener.hasProblems()) {
ClientFrame.showErrorMessage(listener.warningsAndErrorsAsString(), null);
}
}
return null;
}