@Override public void restore(final InputStream input, final boolean overwrite) throws IOException { checkNotNull(input); log.debug("Restoring database: {}", name); try (ODatabaseDocumentTx db = openDb()) { if (db.exists()) { checkState(overwrite, "Database already exists: %s", name); } else { db.create(); } log.debug("Starting restore"); db.restore(input, null, null, new LoggingCommandOutputListener("RESTORE")); log.debug("Completed restore"); if (db.getStorage().isClosed()) { // restore can leave storage layer closed, so re-open it db.getStorage().open(SYSTEM_USER, SYSTEM_PASSWORD, null); } } }
public boolean reuseResource(final String iKey, final Object[] iAdditionalArgs, final DB iValue) { if (((ODatabasePooled) iValue).isUnderlyingOpen()) { ((ODatabasePooled) iValue).reuse(owner, iAdditionalArgs); if (iValue.getStorage().isClosed()) // STORAGE HAS BEEN CLOSED: REOPEN IT iValue.getStorage().open((String) iAdditionalArgs[0], (String) iAdditionalArgs[1], null); else if (!iValue.getUser().checkPassword((String) iAdditionalArgs[1])) throw new OSecurityAccessException(iValue.getName(), "User or password not valid for database: '" + iValue.getName() + "'"); return true; } return false; } };