Search in sources :

Example 1 with Restore

use of org.exist.backup.Restore in project exist by eXist-db.

the class RpcConnection method restore.

@Override
public String restore(final String newAdminPassword, final String localFile, final boolean overwriteApps) throws EXistException {
    final int handle = Integer.parseInt(localFile);
    final SerializedResult sr = factory.resultSets.getSerializedResult(handle);
    if (sr == null) {
        throw new EXistException("Invalid handle specified");
    }
    final BufferingRestoreListener listener = new BufferingRestoreListener();
    final Future<Void> future = factory.restoreExecutorService.get().submit(() -> {
        final Path backupFile = sr.result;
        try {
            // de-reference the temp file in the SerializeResult, so it is not re-claimed before we need it
            sr.result = null;
            factory.resultSets.remove(handle);
            withDb((broker, transaction) -> {
                final Restore restore = new Restore();
                restore.restore(broker, transaction, newAdminPassword, backupFile, listener, overwriteApps);
                return null;
            });
            return null;
        } finally {
            TemporaryFileManager.getInstance().returnTemporaryFile(backupFile);
        }
    });
    final UUID uuid = UUID.randomUUID();
    factory.restoreTasks.put(uuid, Tuple(listener, future));
    return uuid.toString();
}
Also used : EXistException(org.exist.EXistException) Restore(org.exist.backup.Restore)

Example 2 with Restore

use of org.exist.backup.Restore in project exist by eXist-db.

the class LocalRestoreService method restore.

@Override
public void restore(final String backup, @Nullable final String newAdminPassword, final RestoreServiceTaskListener restoreListener, final boolean overwriteApps) throws XMLDBException {
    final Restore restore = new Restore();
    withDb((broker, transaction) -> {
        try {
            restore.restore(broker, transaction, newAdminPassword, Paths.get(backup), new RestoreListenerAdapter(restoreListener), overwriteApps);
        } catch (final SAXException e) {
            throw new XMLDBException(ErrorCodes.VENDOR_ERROR, e.getMessage());
        }
        return null;
    });
}
Also used : XMLDBException(org.xmldb.api.base.XMLDBException) Restore(org.exist.backup.Restore) SAXException(org.xml.sax.SAXException)

Aggregations

Restore (org.exist.backup.Restore)2 EXistException (org.exist.EXistException)1 SAXException (org.xml.sax.SAXException)1 XMLDBException (org.xmldb.api.base.XMLDBException)1