use of org.exist.backup.CreateBackupDialog in project exist by eXist-db.
the class ClientFrame method backupAction.
private void backupAction(final ActionEvent ev) {
// get the collection to highlight in the backup dialog
final String defaultSelectedCollection;
final ResourceDescriptor[] selResources = getSelectedResources();
if (selResources != null) {
if (selResources.length == 1 && selResources[0].isCollection()) {
// use the selected collection
defaultSelectedCollection = path.toString() + "/" + selResources[0].getName().toString();
} else {
// use the current collection
defaultSelectedCollection = path.toString();
}
} else {
defaultSelectedCollection = path.toString();
}
final CreateBackupDialog dialog = new CreateBackupDialog(properties.getProperty(InteractiveClient.URI, "xmldb:exist://"), properties.getProperty(InteractiveClient.USER, SecurityManager.DBA_USER), properties.getProperty(InteractiveClient.PASSWORD, null), Paths.get(preferences.get("directory.backup", System.getProperty("user.home"))), defaultSelectedCollection);
if (JOptionPane.showOptionDialog(this, dialog, Messages.getString("ClientFrame.157"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null) == JOptionPane.YES_OPTION) {
final String collection = dialog.getCollection();
final String backuptarget = dialog.getBackupTarget();
final boolean deduplicateBlobs = dialog.getDeduplicateBlobs();
final Path target = Paths.get(backuptarget).normalize();
if (Files.exists(target)) {
final int response = JOptionPane.showConfirmDialog(this, String.format("%s %s %s", Messages.getString("CreateBackupDialog.6a"), backuptarget, Messages.getString("CreateBackupDialog.6b")), Messages.getString("CreateBackupDialog.6c"), JOptionPane.YES_NO_OPTION);
if (response == JOptionPane.YES_OPTION) {
// User wants file/directory to be removed
deleteDirectory(target);
} else {
JOptionPane.showMessageDialog(null, "Backup aborted, backup has not been deleted.");
return;
}
}
try {
final Backup backup = new Backup(properties.getProperty(InteractiveClient.USER, SecurityManager.DBA_USER), properties.getProperty(InteractiveClient.PASSWORD, null), Paths.get(backuptarget), XmldbURI.xmldbUriFor(properties.getProperty(InteractiveClient.URI, "xmldb:exist://") + collection), null, deduplicateBlobs);
backup.backup(true, this);
} catch (final XMLDBException | IOException | SAXException | URISyntaxException e) {
showErrorMessage(e.getClass().getSimpleName() + ": " + e.getMessage(), e);
}
}
}
Aggregations