File f = chooser.getSelectedFile(); String restoreFile = f.getAbsolutePath(); try { Restore restore = new Restore(properties.getProperty("user", "admin"), properties.getProperty("password", null), new File(restoreFile), properties.getProperty("uri", "xmldb:exist: restore.restore(true, this); client.reloadCollection(); } catch (Exception e) { e.printStackTrace(); }
JPanel askPass = new JPanel(new BorderLayout()); askPass.add(new JLabel("dba/admin password to use for the restore process:"), BorderLayout.NORTH); JPasswordField passInput = new JPasswordField(25); askPass.add(passInput, BorderLayout.CENTER); if (JOptionPane.showOptionDialog(this, askPass, "Admin Password", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null) == JOptionPane.YES_OPTION) { String newDbaPass = passInput.getPassword().length == 0 ? null : new String(passInput.getPassword()); File f = chooser.getSelectedFile(); String restoreFile = f.getAbsolutePath(); try { Restore restore = new Restore(properties.getProperty("user", "admin"), properties.getProperty("password", null), newDbaPass, new File(restoreFile), properties.getProperty("uri", "xmldb:exist: restore.restore(true, this);  if (properties.getProperty("user", "admin").equals("admin") && newDbaPass != null) properties.setProperty("password", newDbaPass); client.reloadCollection(); } catch (Exception e) { showErrorMessage("Exception: " + e.getMessage(), e); } }
    private void restoreAction(ActionEvent ev) {        JFileChooser chooser = new JFileChooser();        chooser.setMultiSelectionEnabled(false);        chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);        chooser.setFileFilter(new FileFilter() {            public boolean accept(File f) {                if (f.isDirectory())                    return true;                if (f.getName().equals("__contents__.xml"))                    return true;                return false;            }                        public String getDescription() {                return "__contents__.xml files";            }        });                if (chooser.showDialog(null, "Select backup file for restore") == JFileChooser.APPROVE_OPTION) {            File f = chooser.getSelectedFile();            String restoreFile = f.getAbsolutePath();            try {                Restore restore = new Restore(properties.getProperty("user",                        "admin"), properties.getProperty("password", null),                        new File(restoreFile), properties.getProperty("uri",                        "xmldb:exist://"));                restore.restore(true, this);                client.reloadCollection();            } catch (Exception e) {                e.printStackTrace();            }        }    }